|
|
|
@ -30,32 +30,32 @@
|
|
|
|
|
#include "addalternatives.h"
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
|
|
#include <qtimer.h>
|
|
|
|
|
#include <tqtimer.h>
|
|
|
|
|
|
|
|
|
|
#include <kmessagebox.h>
|
|
|
|
|
#include <kaboutdialog.h>
|
|
|
|
|
#include <ktextedit.h>
|
|
|
|
|
#include <kdebug.h>
|
|
|
|
|
#include <klocale.h>
|
|
|
|
|
#include <qlayout.h>
|
|
|
|
|
#include <qfile.h>
|
|
|
|
|
#include <qtextstream.h>
|
|
|
|
|
#include <tqlayout.h>
|
|
|
|
|
#include <tqfile.h>
|
|
|
|
|
#include <tqtextstream.h>
|
|
|
|
|
#include <kgenericfactory.h>
|
|
|
|
|
#include <kstdguiitem.h>
|
|
|
|
|
#include <kdeversion.h>
|
|
|
|
|
|
|
|
|
|
typedef KGenericFactory<Kalternatives, QWidget> KalternativesFactory;
|
|
|
|
|
typedef KGenericFactory<Kalternatives, TQWidget> KalternativesFactory;
|
|
|
|
|
K_EXPORT_COMPONENT_FACTORY( kcm_kalternatives, KalternativesFactory("kcmkalternatives"))
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
KCModule *create_kalternatives(QWidget *parent, const char *name)
|
|
|
|
|
KCModule *create_kalternatives(TQWidget *parent, const char *name)
|
|
|
|
|
{
|
|
|
|
|
return new Kalternatives(parent, name);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Kalternatives::Kalternatives(QWidget *parent, const char *name, const QStringList&)
|
|
|
|
|
Kalternatives::Kalternatives(TQWidget *parent, const char *name, const TQStringList&)
|
|
|
|
|
:KCModule(/*KalternativesFactory::instance(), */parent, name), myAboutData(0)
|
|
|
|
|
{
|
|
|
|
|
setUseRootOnlyMsg(false);
|
|
|
|
@ -80,12 +80,12 @@ m_mgr = new AltFilesManager("/var/lib/rpm/alternatives");
|
|
|
|
|
m_mgr = new AltFilesManager("/var/lib/dpkg/alternatives");
|
|
|
|
|
#else
|
|
|
|
|
KMessageBox::sorry(this, i18n("Kalternatives only work on Debian- or Mandrake-based systems"), i18n("Wrong System Type"));
|
|
|
|
|
QTimer::singleShot(0, this, SLOT(die()));
|
|
|
|
|
TQTimer::singleShot(0, this, SLOT(die()));
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
MainWindow *mainwindow = new MainWindow(this);
|
|
|
|
|
QBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint());
|
|
|
|
|
TQBoxLayout *layout = new TQVBoxLayout(this, 0, KDialog::spacingHint());
|
|
|
|
|
layout->addWidget( mainwindow );
|
|
|
|
|
layout->activate();
|
|
|
|
|
|
|
|
|
@ -94,11 +94,11 @@ m_mgr = new AltFilesManager("/var/lib/rpm/alternatives");
|
|
|
|
|
connect(mainwindow->m_hideAlt, SIGNAL(clicked()), this,
|
|
|
|
|
SLOT(slotHideAlternativesClicked()));
|
|
|
|
|
|
|
|
|
|
connect(mainwindow->m_altList, SIGNAL(selectionChanged( QListViewItem* )), this,
|
|
|
|
|
SLOT(slotSelectAlternativesClicked(QListViewItem *)));
|
|
|
|
|
connect(mainwindow->m_altList, SIGNAL(selectionChanged( TQListViewItem* )), this,
|
|
|
|
|
SLOT(slotSelectAlternativesClicked(TQListViewItem *)));
|
|
|
|
|
|
|
|
|
|
connect(mainwindow->m_optionsList, SIGNAL(clicked(QListViewItem *)),
|
|
|
|
|
this, SLOT(slotOptionClicked(QListViewItem *)));
|
|
|
|
|
connect(mainwindow->m_optionsList, SIGNAL(clicked(TQListViewItem *)),
|
|
|
|
|
this, SLOT(slotOptionClicked(TQListViewItem *)));
|
|
|
|
|
connect(mainwindow->m_bAdd, SIGNAL(clicked()), this,
|
|
|
|
|
SLOT(slotAddClicked()));
|
|
|
|
|
connect(mainwindow->m_bDelete, SIGNAL(clicked()), this,
|
|
|
|
@ -161,7 +161,7 @@ void Kalternatives::die()
|
|
|
|
|
void Kalternatives::load()
|
|
|
|
|
{
|
|
|
|
|
clearList(m_altList);
|
|
|
|
|
QPtrList<Item> *itemslist = m_mgr->getGlobalAlternativeList();
|
|
|
|
|
TQPtrList<Item> *itemslist = m_mgr->getGlobalAlternativeList();
|
|
|
|
|
Item *i;
|
|
|
|
|
TreeItemElement *treeit;
|
|
|
|
|
for(i = itemslist->first(); i; i = itemslist->next())
|
|
|
|
@ -188,8 +188,8 @@ void Kalternatives::load()
|
|
|
|
|
|
|
|
|
|
void Kalternatives::clearList(KListView* list)
|
|
|
|
|
{
|
|
|
|
|
QListViewItemIterator it( list );
|
|
|
|
|
QListViewItem *tmp;
|
|
|
|
|
TQListViewItemIterator it( list );
|
|
|
|
|
TQListViewItem *tmp;
|
|
|
|
|
while( (tmp=it.current()) )
|
|
|
|
|
{
|
|
|
|
|
it++;
|
|
|
|
@ -198,7 +198,7 @@ void Kalternatives::clearList(KListView* list)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Kalternatives::slotSelectAlternativesClicked(QListViewItem *alternative)
|
|
|
|
|
void Kalternatives::slotSelectAlternativesClicked(TQListViewItem *alternative)
|
|
|
|
|
{
|
|
|
|
|
clearList(m_optionsList);
|
|
|
|
|
TreeItemElement *treeItem;
|
|
|
|
@ -215,14 +215,14 @@ void Kalternatives::slotSelectAlternativesClicked(QListViewItem *alternative)
|
|
|
|
|
{
|
|
|
|
|
Alternative *a = altItem->getAlternative();
|
|
|
|
|
|
|
|
|
|
QString priority;
|
|
|
|
|
TQString priority;
|
|
|
|
|
priority.setNum(a->getPriority());
|
|
|
|
|
|
|
|
|
|
m_optionsList->insertItem(altItem);
|
|
|
|
|
|
|
|
|
|
altItem->setText( 1, priority);
|
|
|
|
|
altItem->setText( 2, a->getPath());
|
|
|
|
|
QString m_small_desc = altItem->getDescription();
|
|
|
|
|
TQString m_small_desc = altItem->getDescription();
|
|
|
|
|
|
|
|
|
|
if (!m_small_desc.isEmpty())
|
|
|
|
|
{
|
|
|
|
@ -243,9 +243,9 @@ void Kalternatives::slotHideAlternativesClicked()
|
|
|
|
|
{
|
|
|
|
|
if (m_hideAlt->isChecked ())
|
|
|
|
|
{
|
|
|
|
|
QListViewItemIterator it( m_altList );
|
|
|
|
|
TQListViewItemIterator it( m_altList );
|
|
|
|
|
TreeItemElement *i;
|
|
|
|
|
QListViewItem *tmp;
|
|
|
|
|
TQListViewItem *tmp;
|
|
|
|
|
while ( it.current() )
|
|
|
|
|
{
|
|
|
|
|
if((i = dynamic_cast<TreeItemElement *>(it.current())))
|
|
|
|
@ -269,7 +269,7 @@ void Kalternatives::slotHideAlternativesClicked()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Kalternatives::slotOptionClicked(QListViewItem *option)
|
|
|
|
|
void Kalternatives::slotOptionClicked(TQListViewItem *option)
|
|
|
|
|
{
|
|
|
|
|
AltItemElement *altItem;
|
|
|
|
|
if((altItem = dynamic_cast<AltItemElement *>(option)))
|
|
|
|
@ -330,7 +330,7 @@ void Kalternatives::slotPropertiesClicked()
|
|
|
|
|
|
|
|
|
|
if((altItem = dynamic_cast<AltItemElement *>(m_optionsList->selectedItem())))
|
|
|
|
|
{
|
|
|
|
|
QString text;
|
|
|
|
|
TQString text;
|
|
|
|
|
PropertiesWindow *prop = new PropertiesWindow(this);
|
|
|
|
|
prop->bClose->setGuiItem(KStdGuiItem::close());
|
|
|
|
|
|
|
|
|
@ -341,10 +341,10 @@ void Kalternatives::slotPropertiesClicked()
|
|
|
|
|
text += i18n( "Path : %1\n" ).arg( a->getPath() );
|
|
|
|
|
text += i18n( "Priority : %1\n" ).arg( a->getPriority() );
|
|
|
|
|
|
|
|
|
|
QStringList* slavesList = a->getSlaves();
|
|
|
|
|
TQStringList* slavesList = a->getSlaves();
|
|
|
|
|
text += i18n( "Slave :", "Slaves :", slavesList->count() );
|
|
|
|
|
|
|
|
|
|
for ( QStringList::Iterator it = slavesList->begin(); it != slavesList->end(); ++it )
|
|
|
|
|
for ( TQStringList::Iterator it = slavesList->begin(); it != slavesList->end(); ++it )
|
|
|
|
|
{
|
|
|
|
|
text += "\n\t";
|
|
|
|
|
text += *it;
|
|
|
|
@ -357,7 +357,7 @@ void Kalternatives::slotPropertiesClicked()
|
|
|
|
|
|
|
|
|
|
void Kalternatives::save()
|
|
|
|
|
{
|
|
|
|
|
QListViewItemIterator it( m_altList );
|
|
|
|
|
TQListViewItemIterator it( m_altList );
|
|
|
|
|
TreeItemElement *treeItem;
|
|
|
|
|
|
|
|
|
|
while ( it.current() )
|
|
|
|
@ -366,11 +366,11 @@ void Kalternatives::save()
|
|
|
|
|
{
|
|
|
|
|
if(treeItem->isNbrAltChanged())
|
|
|
|
|
{
|
|
|
|
|
QString parentPath = QString("%1/%2")
|
|
|
|
|
TQString parentPath = TQString("%1/%2")
|
|
|
|
|
.arg(m_mgr->getAltDir())
|
|
|
|
|
.arg(treeItem->getName());
|
|
|
|
|
|
|
|
|
|
QFile origFile(parentPath);
|
|
|
|
|
TQFile origFile(parentPath);
|
|
|
|
|
if(origFile.exists())
|
|
|
|
|
{
|
|
|
|
|
origFile.remove();
|
|
|
|
@ -378,7 +378,7 @@ void Kalternatives::save()
|
|
|
|
|
|
|
|
|
|
if( origFile.open( IO_WriteOnly ))
|
|
|
|
|
{
|
|
|
|
|
QTextStream stream( &origFile );
|
|
|
|
|
TQTextStream stream( &origFile );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Item *item = treeItem->getItem();
|
|
|
|
@ -405,8 +405,8 @@ void Kalternatives::save()
|
|
|
|
|
stream << a->getPath() << endl;
|
|
|
|
|
stream << a->getPriority() << endl;
|
|
|
|
|
|
|
|
|
|
QStringList *slaveList = a->getSlaves();
|
|
|
|
|
QStringList::Iterator it = slaveList->begin();
|
|
|
|
|
TQStringList *slaveList = a->getSlaves();
|
|
|
|
|
TQStringList::Iterator it = slaveList->begin();
|
|
|
|
|
for ( ; it != slaveList->end(); ++it )
|
|
|
|
|
{
|
|
|
|
|
stream << *it << endl;
|
|
|
|
@ -446,7 +446,7 @@ void Kalternatives::configChanged()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString Kalternatives::quickHelp() const
|
|
|
|
|
TQString Kalternatives::quickHelp() const
|
|
|
|
|
{
|
|
|
|
|
return i18n("<h1>Kalternatives</h1>\n"
|
|
|
|
|
"A Mandrake/Debian alternatives-system manager.");
|
|
|
|
|