summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2024-08-09 14:47:08 +0300
committerMavridis Philippe <mavridisf@gmail.com>2024-08-09 14:47:08 +0300
commit47becbedc6788937ab25df5220f0bf25291b62e8 (patch)
tree8ece1fe748e9da588a7162596aaa75e47ac3a0f9 /src
downloadtdealternatives-47becbedc6788937ab25df5220f0bf25291b62e8.tar.gz
tdealternatives-47becbedc6788937ab25df5220f0bf25291b62e8.zip
Initial commit
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am21
-rw-r--r--src/addalternatives.cpp121
-rw-r--r--src/addalternatives.h50
-rw-r--r--src/addalternativesui.ui259
-rw-r--r--src/addslaves.cpp55
-rw-r--r--src/addslaves.h43
-rw-r--r--src/addslavesui.ui167
-rw-r--r--src/altcontroller.cpp53
-rw-r--r--src/altcontroller.h44
-rw-r--r--src/altitemelement.cpp118
-rw-r--r--src/altitemelement.h58
-rw-r--r--src/altparser.cpp609
-rw-r--r--src/altparser.h140
-rw-r--r--src/hi16-app-kalternatives.pngbin0 -> 1033 bytes
-rw-r--r--src/hi32-app-kalternatives.pngbin0 -> 2749 bytes
-rw-r--r--src/kalternatives.cpp457
-rw-r--r--src/kalternatives.desktop37
-rw-r--r--src/kalternatives.h83
-rw-r--r--src/kalternatives.lsm16
-rw-r--r--src/kalternativesui.rc8
-rw-r--r--src/main.cpp77
-rw-r--r--src/main.h8
-rw-r--r--src/mainwindow.ui392
-rw-r--r--src/propertieswindow.ui106
-rw-r--r--src/treeitemelement.cpp70
-rw-r--r--src/treeitemelement.h56
26 files changed, 3048 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..765d616
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,21 @@
+INCLUDES = $(all_includes)
+
+noinst_HEADERS = kalternatives.h altparser.h altcontroller.h altitemelement.h treeitemelement.h addslaves.h addalternatives.h
+
+KDE_ICON = kalternatives
+
+# Install this plugin in the KDE modules directory
+kde_module_LTLIBRARIES = kcm_kalternatives.la
+
+kcm_kalternatives_la_SOURCES = addslavesui.ui propertieswindow.ui addalternativesui.ui mainwindow.ui altcontroller.cpp kalternatives.cpp altparser.cpp altitemelement.cpp treeitemelement.cpp addslaves.cpp addalternatives.cpp
+
+kcm_kalternatives_la_LIBADD = $(LIB_KDEUI) $(LIB_KIO)
+kcm_kalternatives_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
+
+
+kcm_kalternatives_la_METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kalternatives.pot
+
+xdg_apps_DATA = kalternatives.desktop
diff --git a/src/addalternatives.cpp b/src/addalternatives.cpp
new file mode 100644
index 0000000..220192b
--- /dev/null
+++ b/src/addalternatives.cpp
@@ -0,0 +1,121 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "addalternatives.h"
+#include "addslaves.h"
+#include "treeitemelement.h"
+#include "kalternatives.h"
+#include "altcontroller.h"
+#include "altitemelement.h"
+#include "altparser.h"
+
+#include <qregexp.h>
+#include <qstringlist.h>
+
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <knuminput.h>
+#include <kstdguiitem.h>
+#include <kurlrequester.h>
+
+AddAlternatives::AddAlternatives(TreeItemElement *treeItem, Kalternatives *kalt, int countSlaves):
+AddAlternativesUi(kalt),m_treeItem(treeItem), m_kalt(kalt), m_countSlave(countSlaves)
+{
+ m_bOk->setGuiItem(KStdGuiItem::ok());
+ m_bCancel->setGuiItem(KStdGuiItem::cancel());
+ m_bAddSlave->setGuiItem(KGuiItem(i18n("&Add Slave"), "edit_add"));
+
+ m_Path->setCaption( i18n( "Choose Alternative" ) );
+ m_Path->setFilter( i18n( "*|All Files" ) );
+ m_Path->setMode( KFile::File | KFile::LocalOnly );
+}
+
+AddAlternatives::~AddAlternatives()
+{
+}
+
+void AddAlternatives::slotAddSlaveClicked()
+{
+ AddSlaves *addSlaves = new AddSlaves(this);
+ addSlaves->exec();
+}
+
+void AddAlternatives::slotOkClicked()
+{
+ if(!m_Path->url().isEmpty())
+ {
+
+ Item *item = m_treeItem->getItem();
+ Alternative *a = new Alternative(item);
+
+ a->setPath(m_Path->url());
+ a->setPriority(m_Priority->value());
+
+ int countSlave = 0;
+
+ if (!m_textSlave->text().isEmpty())
+ {
+ QRegExp reg("\n");
+ QStringList slaveList = QStringList::split(reg, m_textSlave->text());
+ QStringList::Iterator it = slaveList.begin();
+ for ( ; it != slaveList.end(); ++it )
+ {
+ a->addSlave(*it);
+ countSlave++;
+ }
+ }
+
+ if (countSlave == m_countSlave)
+ {
+ item->addAlternative(a);
+
+
+ AltItemElement *altItem = new AltItemElement(m_kalt->optionsList(), a);
+
+ m_treeItem->getAltController()->addAltItem(altItem);
+
+
+ QString priority;
+ priority.setNum(a->getPriority());
+
+ altItem->setText( 1, priority);
+ altItem->setText( 2, a->getPath());
+ QString m_small_desc = altItem->getDescription();
+
+ if (!m_small_desc.isEmpty())
+ {
+ altItem->setText( 3, m_small_desc);
+ }
+ else
+ {
+ altItem->searchDescription();
+ }
+ m_treeItem->setNbrAltChanged(TRUE);
+ emit m_kalt->configChanged();
+ close();
+ }
+ else
+ {
+ KMessageBox::sorry(this, i18n("The number of slaves is not good."), i18n("Number Of Slaves"));
+ }
+ }
+}
+
+#include "addalternatives.moc"
diff --git a/src/addalternatives.h b/src/addalternatives.h
new file mode 100644
index 0000000..679b744
--- /dev/null
+++ b/src/addalternatives.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _ADDALTERNATIVES_H_
+#define _ADDALTERNATIVES_H_
+
+#include "addalternativesui.h"
+
+#include <ktextedit.h>
+
+class TreeItemElement;
+class Kalternatives;
+
+class AddAlternatives : public AddAlternativesUi
+{
+ Q_OBJECT
+
+ TreeItemElement *m_treeItem;
+ Kalternatives *m_kalt;
+ int m_countSlave;
+
+public:
+ AddAlternatives(TreeItemElement *treeItem, Kalternatives *kalt, int countSlaves);
+ virtual ~AddAlternatives();
+
+ void addSlave(const QString& text){m_textSlave->append(text);}
+
+protected slots:
+ void slotOkClicked();
+ void slotAddSlaveClicked();
+};
+
+#endif //ADDALTERNATIVES_H_
diff --git a/src/addalternativesui.ui b/src/addalternativesui.ui
new file mode 100644
index 0000000..e30f26c
--- /dev/null
+++ b/src/addalternativesui.ui
@@ -0,0 +1,259 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>AddAlternativesUi</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>AddAlternatives</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>440</width>
+ <height>200</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Add Alternative</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="resizeMode">
+ <enum>Minimum</enum>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Path:</string>
+ </property>
+ </widget>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>m_Path</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout11</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Priority:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>m_Priority</cstring>
+ </property>
+ <property name="maxValue">
+ <number>1000</number>
+ </property>
+ <property name="minValue">
+ <number>-1000</number>
+ </property>
+ <property name="value">
+ <number>20</number>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer8</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>80</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KTextEdit">
+ <property name="name">
+ <cstring>m_textSlave</cstring>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout13</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_bAddSlave</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Add Slave</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>170</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_bOk</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_bCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>m_bCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>AddAlternatives</receiver>
+ <slot>close()</slot>
+ </connection>
+ <connection>
+ <sender>m_bAddSlave</sender>
+ <signal>clicked()</signal>
+ <receiver>AddAlternatives</receiver>
+ <slot>slotAddSlaveClicked()</slot>
+ </connection>
+ <connection>
+ <sender>m_bOk</sender>
+ <signal>clicked()</signal>
+ <receiver>AddAlternatives</receiver>
+ <slot>slotOkClicked()</slot>
+ </connection>
+</connections>
+<slots>
+ <slot access="protected">slotOkClicked()</slot>
+ <slot access="protected">slotAddSlaveClicked()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>ktextedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/src/addslaves.cpp b/src/addslaves.cpp
new file mode 100644
index 0000000..12b47ba
--- /dev/null
+++ b/src/addslaves.cpp
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "addslaves.h"
+#include "addalternatives.h"
+
+#include <klocale.h>
+#include <kstdguiitem.h>
+#include <kurlrequester.h>
+
+#include <iostream>
+using namespace std;
+
+AddSlaves::AddSlaves(AddAlternatives *addAlternatives):
+AddSlavesUi(addAlternatives), m_addAlternatives(addAlternatives)
+{
+ m_bOk->setGuiItem(KStdGuiItem::ok());
+ m_bCancel->setGuiItem(KStdGuiItem::cancel());
+
+ m_Path->setCaption( i18n( "Choose Slave" ) );
+ m_Path->setFilter( i18n( "*|All Files" ) );
+ m_Path->setMode( KFile::File | KFile::LocalOnly );
+}
+
+AddSlaves::~AddSlaves()
+{
+}
+
+void AddSlaves::slotOkClicked()
+{
+ if(!m_Path->url().isEmpty())
+ {
+ m_addAlternatives->addSlave(m_Path->url());
+ close();
+ }
+}
+
+#include "addslaves.moc"
diff --git a/src/addslaves.h b/src/addslaves.h
new file mode 100644
index 0000000..efcb274
--- /dev/null
+++ b/src/addslaves.h
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _ADDSLAVES_H_
+#define _ADDSLAVES_H_
+
+#include "addslavesui.h"
+
+class AddAlternatives;
+
+class AddSlaves : public AddSlavesUi
+{
+ Q_OBJECT
+
+ AddAlternatives *m_addAlternatives;
+
+public:
+ AddSlaves(AddAlternatives *addAlternatives);
+ virtual ~AddSlaves();
+
+protected slots:
+ void slotOkClicked();
+
+};
+
+#endif //ADDSLAVES_H_
diff --git a/src/addslavesui.ui b/src/addslavesui.ui
new file mode 100644
index 0000000..deb21e0
--- /dev/null
+++ b/src/addslavesui.ui
@@ -0,0 +1,167 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>AddSlavesUi</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>AddSlaves</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>439</width>
+ <height>83</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Add Slave</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="resizeMode">
+ <enum>Minimum</enum>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout13</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout12</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Path:</string>
+ </property>
+ </widget>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>m_Path</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout13</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>170</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_bOk</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_bCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>m_bCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>AddSlaves</receiver>
+ <slot>close()</slot>
+ </connection>
+ <connection>
+ <sender>m_bOk</sender>
+ <signal>clicked()</signal>
+ <receiver>AddSlaves</receiver>
+ <slot>slotOkClicked()</slot>
+ </connection>
+</connections>
+<slots>
+ <slot access="protected">slotOkClicked()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/src/altcontroller.cpp b/src/altcontroller.cpp
new file mode 100644
index 0000000..3aae52a
--- /dev/null
+++ b/src/altcontroller.cpp
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "altcontroller.h"
+#include "altitemelement.h"
+#include "treeitemelement.h"
+
+AltController::AltController()
+{
+ m_altItemslist = new AltItemList;
+}
+
+AltController::~AltController()
+{
+ if(m_altItemslist) delete m_altItemslist;
+}
+
+
+void AltController::setBoutonOnOff(KListView *list, AltItemElement *altItem)
+{
+ QListViewItemIterator it( list );
+ AltItemElement *alt;
+ while ( it.current() )
+ {
+ if((alt = dynamic_cast<AltItemElement *>(it.current())))
+ {
+ if((alt!=altItem) && alt->isOn())
+ {
+ alt->setState(QCheckListItem::Off);
+ }
+ }
+ ++it;
+ }
+
+}
+//#include "altcontroller.moc"
diff --git a/src/altcontroller.h b/src/altcontroller.h
new file mode 100644
index 0000000..87bde19
--- /dev/null
+++ b/src/altcontroller.h
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _ALTCONTROLLER_H_
+#define _ALTCONTROLLER_H_
+
+#include <klistview.h>
+#include <qptrlist.h>
+
+class AltItemElement;
+
+typedef QPtrList<AltItemElement> AltItemList;
+
+
+class AltController
+{
+ AltItemList *m_altItemslist;
+
+public:
+ AltController();
+ ~AltController();
+
+ void setBoutonOnOff(KListView *list, AltItemElement *altItem);
+ void addAltItem(AltItemElement *altItem) {m_altItemslist->append(altItem);}
+ AltItemList *getAltItemList() {return m_altItemslist;}
+};
+#endif // _ALTCONTROLLER_H_
diff --git a/src/altitemelement.cpp b/src/altitemelement.cpp
new file mode 100644
index 0000000..63e9b00
--- /dev/null
+++ b/src/altitemelement.cpp
@@ -0,0 +1,118 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+
+#include "altitemelement.h"
+#include "altcontroller.h"
+#include "altparser.h"
+
+#include <qtimer.h>
+#include <klocale.h>
+#include <kdebug.h>
+/******************************* AltItemElement ********************/
+
+AltItemElement::AltItemElement(KListView *parent, Alternative *alternative)
+: QCheckListItem(parent, "", QCheckListItem::RadioButton),
+ m_alt(alternative),
+ m_parent(parent),
+ m_bisBroken(alternative->isBroken()),
+ m_path(alternative->getPath())
+{
+ setOn(alternative->isSelected());
+ setEnabled(!m_bisBroken);
+ m_desc = "";
+}
+
+AltItemElement::~AltItemElement()
+{
+ delete m_alt;
+}
+
+
+void AltItemElement::searchDescription()
+{
+ QString exec = m_path;
+ int posSlash = exec.findRev("/");
+
+ if (posSlash != -1)
+ {
+ exec.remove(0, posSlash+1);
+ }
+
+ if (!exec.isEmpty())
+ {
+ KProcess *procdesc = new KProcess();
+ *procdesc << "whatis";
+ *procdesc << exec;
+
+ connect(procdesc, SIGNAL(receivedStdout(KProcess *, char *, int)), this,
+ SLOT(slotGetDescription(KProcess *, char *, int)));
+ //connect(procdesc, SIGNAL( receivedStderr(KProcess *, char *, int) ), this,
+ // SLOT(slotGetDescription(KProcess *, char *, int)));
+ connect(procdesc, SIGNAL( processExited(KProcess *)), this,
+ SLOT(slotDescriptionTermined(KProcess *)));
+ procdesc->start(KProcess::NotifyOnExit,/*KProcess::Block,*/ KProcess::AllOutput);
+ }
+}
+
+
+void AltItemElement::slotDescriptionTermined(KProcess *proc)
+{
+ if (!proc->exitStatus())
+ {
+ int pos = m_desc.find("\n");
+ if (pos != -1)
+ {
+ m_desc.truncate(pos);
+ }
+
+ pos = m_desc.find("]");
+ if (pos != -1)
+ {
+ m_desc.remove(0, pos+1);
+ }
+
+ pos = m_desc.find(")");
+ if (pos != -1)
+ {
+ m_desc.remove(0, pos+1);
+ }
+
+ pos = m_desc.find("-");
+ if (pos != -1)
+ {
+ m_desc.remove(0, pos+2);
+ }
+ }
+ else
+ {
+ m_desc = i18n( "no description" );
+ }
+ setText( 3, m_desc);
+}
+
+void AltItemElement::slotGetDescription(KProcess *, char *buffer, int buflen)
+{
+ m_desc += QString::fromLatin1(buffer, buflen);
+}
+
+
+
+#include "altitemelement.moc"
diff --git a/src/altitemelement.h b/src/altitemelement.h
new file mode 100644
index 0000000..c935cea
--- /dev/null
+++ b/src/altitemelement.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _ALTITEMELEMENT_H_
+#define _ALTITEMELEMENT_H_
+
+#include <qlistview.h>
+#include <klistview.h>
+#include <qstring.h>
+#include <kprocess.h>
+
+class Alternative;
+class AltController;
+
+class AltItemElement : public QObject, public QCheckListItem
+{
+ Q_OBJECT
+
+ Alternative *m_alt;
+ KListView *m_parent;
+ bool m_bisBroken;
+ QString m_path;
+ QString m_desc;
+
+public:
+ AltItemElement(KListView *parent, Alternative *alternative );
+ ~AltItemElement();
+
+ bool isBroken() const { return m_bisBroken; }
+ KListView *getParent() const { return m_parent; }
+ Alternative *getAlternative() { return m_alt; }
+ QString getPath() const {return m_path; }
+ QString getDescription() const {return m_desc;}
+ void searchDescription();
+
+private slots:
+ void slotDescriptionTermined(KProcess *);
+ void slotGetDescription(KProcess *proc, char *buffer, int buflen);
+};
+
+#endif //_ALTITEMELEMENT_H_
diff --git a/src/altparser.cpp b/src/altparser.cpp
new file mode 100644
index 0000000..bb31d88
--- /dev/null
+++ b/src/altparser.cpp
@@ -0,0 +1,609 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Juanjo Álvarez *
+ * juanjux@yahoo.es *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "altparser.h"
+#include <qfileinfo.h>
+#include <qfile.h>
+#include <qdir.h>
+#include <qstringlist.h>
+
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+Alternative::Alternative(Item *parentarg) : m_parent(parentarg)
+{
+ m_priority = 1;
+ m_altSlaves = new QStringList;
+}
+
+// Copy constructor
+Alternative::Alternative(const Alternative &alt) :
+ m_altPath(alt.getPath()),
+ m_priority(alt.getPriority()),
+ m_parent(alt.getParent())
+{
+ m_altSlaves = new QStringList( *(alt.m_altSlaves) );
+}
+
+Alternative::~Alternative()
+{
+ if(m_altSlaves)delete m_altSlaves;
+}
+
+Alternative& Alternative::operator=(const Alternative &alt)
+{
+ if(this != &alt)
+ {
+ if(m_altSlaves)delete m_altSlaves;
+ m_altPath = alt.getPath();
+ m_priority = alt.getPriority();
+ m_parent = alt.getParent();
+ m_altSlaves = new QStringList( *(alt.m_altSlaves) );
+ }
+ return (*this);
+}
+
+void Alternative::setSlaves(QStringList *slaves)
+{
+ if(m_altSlaves) delete m_altSlaves;
+ m_altSlaves = slaves;
+}
+
+bool Alternative::isSelected() const
+{
+ if(m_parent->isBroken()) return false;
+ QFileInfo file("/etc/alternatives/"+m_parent->getName());
+ if(!file.isSymLink()) return false;
+ if(file.readLink() == m_altPath) return 1;
+ return 0;
+}
+
+
+bool Alternative::isBroken() const
+{
+ return !QFile::exists(m_altPath);
+}
+
+bool Alternative::select()
+{
+// This method was 19 lines in Python in the original kalternatives :-D
+ if(isSelected()) return true;
+ if(isBroken())
+ {
+ m_selectError = QString("Broken alternative: Unexisting path %1").arg(m_altPath);
+ return false;
+ }
+
+ // Remove the current link:
+ QString parentPath = QString("/etc/alternatives/%1").arg(m_parent->getName());
+ QFile origlink(parentPath);
+ if(!origlink.remove())
+ {
+ m_selectError = QString("Could not delete alternative link %1: %2").arg(parentPath).arg(origlink.errorString());
+ return false;
+ }
+
+ // Then we do the main link:
+ if(symlink(m_altPath.ascii(), parentPath.ascii()) == -1)
+ {
+ m_selectError = QString(strerror(errno));
+ return false;
+ }
+
+ // And finally the slaves
+ SlaveList *parslaves = m_parent->getSlaves();
+ parslaves->setAutoDelete(1);
+ if(parslaves->count() == 0 || m_altSlaves->count() == 0) return true;
+ int count = 0;
+ QStringList::iterator sl;
+ Slave *parsl;
+ for( sl = m_altSlaves->begin(); sl != m_altSlaves->end(); ++sl)
+ {
+ parsl = parslaves->at(count);
+ QString parstr = QString("/etc/alternatives/%1").arg(parsl->slname);
+ QFile parlink(parstr);
+ if(!parlink.remove())
+ {
+ m_selectError = QString("Could not delete slave alternative link %1: %2").arg(parstr).arg(parlink.errorString());
+ return false;
+ }
+ if(symlink( (*sl).ascii(), parstr.ascii()) == -1)
+ {
+ m_selectError = QString(strerror(errno));
+ return false;
+ }
+ ++count;
+ }
+ return true;
+}
+
+
+//*************************************** Item
+
+Item::Item()
+{
+ m_mode = "auto";
+ m_itemSlaves = new SlaveList;
+ m_itemAlts = new AltsPtrList;
+ m_itemSlaves->setAutoDelete(1);
+ m_itemAlts->setAutoDelete(1);
+}
+
+// Deep copy
+Item::Item(const Item &item) :
+ m_name(item.m_name),
+ m_mode(item.m_mode),
+ m_path(item.m_path)
+{
+ m_itemSlaves = new SlaveList;
+ m_itemAlts = new AltsPtrList;
+ m_itemSlaves->setAutoDelete(1);
+ m_itemAlts->setAutoDelete(1);
+ Slave *slave;
+ Slave *slavecopy;
+ for(slave = item.m_itemSlaves->first(); slave; slave = item.m_itemSlaves->next())
+ {
+ slavecopy = new Slave;
+ slavecopy->slname = slave->slname;
+ slavecopy->slpath = slave->slpath;
+ m_itemSlaves->append(slavecopy);
+ }
+
+ Alternative *alt;
+ Alternative *altcopy;
+ for(alt = item.m_itemAlts->first(); alt; alt = item.m_itemAlts->next())
+ {
+ // The Alternative class already has a deep copy constructor:
+ altcopy = new Alternative( (*alt) );
+ m_itemAlts->append(altcopy);
+ }
+}
+
+Item& Item::operator=(const Item &item)
+{
+ if(this != &item)
+ {
+ if(m_itemSlaves)delete m_itemSlaves;
+ if(m_itemAlts)delete m_itemAlts;
+ m_name = item.m_name;
+ m_mode = item.m_mode;
+ m_path = item.m_path;
+ m_itemSlaves = new SlaveList;
+ m_itemAlts = new AltsPtrList;
+ m_itemSlaves->setAutoDelete(1);
+ m_itemAlts->setAutoDelete(1);
+ Slave *slave;
+ Slave *slavecopy;
+ for(slave = item.m_itemSlaves->first(); slave; slave = item.m_itemSlaves->next())
+ {
+ slavecopy = new Slave;
+ slavecopy->slname = slave->slname;
+ slavecopy->slpath = slave->slpath;
+ m_itemSlaves->append(slavecopy);
+ }
+
+ Alternative *alt;
+ Alternative *altcopy;
+ for(alt = item.m_itemAlts->first(); alt; alt = item.m_itemAlts->next())
+ {
+ altcopy = new Alternative( (*alt) );
+ m_itemAlts->append(altcopy);
+ }
+ }
+ return (*this);
+}
+
+
+
+Item::~Item()
+{
+ if(m_itemSlaves)delete m_itemSlaves;
+ if(m_itemAlts)delete m_itemAlts;
+}
+
+Alternative *Item::getSelected() const
+{
+ Alternative *a;
+ for(a = m_itemAlts->first(); a; a = m_itemAlts->next())
+ {
+ if(a->isSelected())
+ {
+ return a;
+ break;
+ }
+ }
+ return NULL;
+}
+
+void Item::setSlaves(SlaveList *slaves)
+{
+ if(this->m_itemSlaves)delete this->m_itemSlaves;
+ this->m_itemSlaves = slaves;
+}
+
+void Item::addSlave(const QString &namearg, const QString &patharg)
+{
+ Slave *s = new Slave;
+ s->slname = namearg;
+ s->slpath = patharg;
+ m_itemSlaves->append(s);
+}
+
+void Item::delSlave(const QString &namearg)
+{
+ QPtrListIterator<Slave> it(*m_itemSlaves);
+
+ Slave *s;
+ while( (s = it.current()) != 0)
+ {
+ ++it;
+ if(s->slname == namearg)
+ {
+ m_itemSlaves->remove(s);
+ break;
+ }
+ }
+}
+void Item::delSlaveByPath(const QString &patharg)
+{
+ QPtrListIterator<Slave> it(*m_itemSlaves);
+
+ Slave *s;
+ while( (s = it.current()) != 0)
+ {
+ ++it;
+ if(s->slpath == patharg)
+ {
+ m_itemSlaves->remove(s);
+ break;
+ }
+ }
+}
+
+Alternative *Item::getAlternative(const QString &altpath)
+{
+ Alternative *a;
+ for(a = m_itemAlts->first(); a; a = m_itemAlts->next())
+ {
+ if(a->getPath() == altpath)
+ {
+ return a;
+ break;
+ }
+ }
+ return NULL;
+}
+
+void Item::setAlternatives(AltsPtrList &alts)
+{
+ if(this->m_itemAlts)delete this->m_itemAlts;
+ this->m_itemAlts = &alts;
+}
+
+void Item::delAlternativeByPath(const QString &patharg)
+{
+ QPtrListIterator<Alternative> it(*m_itemAlts);
+
+ Alternative *a;
+ while( (a = it.current()) != 0)
+ {
+ ++it;
+ if(a->getPath() == patharg)
+ {
+ m_itemAlts->remove(a);
+ break;
+ }
+ }
+}
+
+void Item::delAlternativeByPriority(int priorityarg)
+{
+ QPtrListIterator<Alternative> it(*m_itemAlts);
+
+ Alternative *a;
+ while( (a = it.current()) != 0)
+ {
+ ++it;
+ if(a->getPriority() == priorityarg)
+ {
+ m_itemAlts->remove(a);
+ break;
+ }
+ }
+}
+
+bool Item::isBroken() const
+{
+ return !QFile::exists(m_path);
+}
+
+/********************** AltFIlesManager ************/
+
+AltFilesManager::AltFilesManager(const QString &altdirarg) :
+ m_altdir(altdirarg)
+{
+ m_itemlist = new ItemPtrList;
+ m_itemlist->setAutoDelete(1);
+ m_parseOk = true;
+ m_errorMsg = "";
+ if(!parseAltFiles(m_errorMsg))
+ {
+ m_parseOk = false;
+ }
+ //debugPrintAlts();
+}
+
+AltFilesManager::~AltFilesManager()
+{
+ //delete m_itemlist;
+ /*
+ Item *item;
+ for(item = m_itemlist->first(); item; item = m_itemlist->next())
+ {
+ delete item;
+ }
+
+ delete m_itemlist;
+ */
+}
+
+Item* AltFilesManager::getItem(const QString &name) const
+{
+ QPtrListIterator<Item> it(*m_itemlist);
+ Item *i;
+ while( (i = it.current()) != 0)
+ {
+ ++it;
+ if(i->getName() == name)
+ {
+ return i;
+ break;
+ }
+ }
+ return NULL;
+}
+
+bool AltFilesManager::parseAltFiles(QString &errorstr)
+{
+ QDir d(m_altdir);
+ QStringList fileList = d.entryList();
+ QStringList lines;
+ QFile altFile;
+ QString line, tmp;
+ int nslaves;
+ unsigned int index, slavesend;
+
+ for( QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it)
+ {
+ Item *item = new Item;
+ if(*it == "." || *it == "..") {
+ delete item;
+ continue;
+ }
+
+ item->setName(*it);
+ altFile.setName(m_altdir+"/"+*it);
+
+ if(!altFile.open( IO_ReadOnly ))
+ {
+ errorstr = altFile.errorString();
+ delete item;
+ return false;
+ }
+
+ lines.clear();
+ while ( !altFile.atEnd() )
+ {
+ if(!altFile.readLine(line, 9999))
+ {
+ errorstr = altFile.errorString();
+ delete item;
+ return false;
+ }
+ lines.append(line);
+ }
+
+ line = lines[0];
+ tmp = line.left(line.length()-1);
+ item->setMode(tmp);
+
+ line = lines[1];
+ tmp = line.left(line.length()-1);
+ item->setPath(tmp);
+
+ index = 2;
+ line = lines[index];
+ nslaves = 0;
+ SlaveList *slaves = new SlaveList;
+ slaves->setAutoDelete(1);
+
+ while(line != "\n")
+ {
+ tmp = line.left(line.length()-1);
+ Slave *slave = new Slave;
+ nslaves++;
+ slave->slname = tmp;
+
+ line = lines[++index];
+ tmp = line.left(line.length()-1);
+ slave->slpath = tmp;
+
+ slaves->append(slave);
+ line = lines[++index];
+ }
+
+ item->setSlaves(slaves);
+
+ ++index;
+ while(index < lines.count()-1)
+ {
+ line = lines[index];
+ Alternative *a = new Alternative(item);
+ tmp = line.left(line.length()-1);
+ a->setPath(tmp);
+
+ if(line=="\n") {
+ //File end (with a \n)
+ delete a;
+ break;
+ }
+
+ if(++index == lines.count())
+ {
+ item->addAlternative(a);
+ break;
+ }
+
+
+ line = lines[index];
+ tmp = line.left(line.length()-1);
+ a->setPriority(tmp.toInt());
+
+ if(++index == lines.count())
+ {
+ item->addAlternative(a);
+ break;
+ }
+
+ line = lines[index];
+ if(line != "\n" and nslaves > 0)
+ {
+ slavesend = index+nslaves;
+ while(index < slavesend)
+ {
+ line = lines[index];
+ tmp = line.left(line.length()-1);
+ a->addSlave(tmp);
+ ++index;
+ }
+ }
+ else
+ {
+ if (nslaves >0)
+ {
+ ++index;
+ }
+ }
+ item->addAlternative(a);
+ }
+ m_itemlist->append(item);
+ altFile.close();
+ }
+
+ return true;
+}
+
+//FIXME: This must be in a son of qptrlist!
+/*
+int AltFilesManager::compareItems(Item i1, Item i2)
+{
+ return i1.getPath().compare(i2.getPath());
+}
+*/
+
+/*
+void AltFilesManager::debugPrintAlts() const
+{
+ printf("----------------------------------\n");
+ Item *item;
+ for(item = m_itemlist->first(); item; item = m_itemlist->next())
+ {
+ printf("\nItem: %s\n", item->getName().ascii());
+ printf("\tMode: %s\n", item->getMode().ascii());
+ printf("\tPath: %s\n", item->getPath().ascii());
+ if(item->getSlaves()->count() == 0)
+ printf("\tNo slaves\n");
+ else
+ {
+ Slave *slave;
+ SlaveList *slaves = item->getSlaves();
+ for(slave = slaves->first(); slave; slave = slaves->next())
+ {
+ printf("\tSlave name: %s\n", slave->name.ascii());
+ printf("\tSlave path: %s\n", slave->path.ascii());
+ }
+ }
+ printf("\tAlternatives:\n");
+ if(item->getAlternatives()->count() == 0)
+ printf("\t\tNO ALTERNATIVES!");
+ else
+ {
+ Alternative *a;
+ AltsPtrList *alts = item->getAlternatives();
+ for(a = alts->first(); a; a = alts->next())
+ {
+ printf("\t\tPath: %s\n", a->getPath().ascii());
+ printf("\t\tPriority: %d\n", a->getPriority());
+ printf("\t\tSlaves:\n");
+ if(a->getSlaves()->count() == 0)
+ printf("\t\t\tNo slaves\n");
+ else
+ {
+ QStringList altslaves = *(a->getSlaves());
+ QStringList::iterator sl;
+ for( sl = altslaves.begin(); sl != altslaves.end(); ++sl)
+ {
+ printf("\t\t\t%s\n", (*sl).ascii());
+ }
+ }
+ }
+ }
+ }
+}
+*/
+/*
+// ************************************** Test
+int main(int argc, char **argv)
+{
+ AltFilesManager a("/var/lib/rpm/alternatives");
+ if(!a.parsingOk())
+ printf("ERROR PARSING ALT FILES: %s\n", a.getErrorMsg().ascii());
+ else
+ printf("\nOK, Finished parsing\n");
+
+ Item *item= a.getItem("vi");
+ if(item == NULL) return 0;
+ printf("Nombre item: %s\n", item->getName().ascii());
+ printf("Path item: %s\n", item->getPath().ascii());
+ Alternative *alt = item->getSelected();
+ if(alt == NULL) return 0;
+ printf("Selected alt: %s\n", alt->getPath().ascii());
+
+ Alternative *vimminimal = item->getAlternative("/bin/vim-minimal");
+ if(vimminimal == NULL) { printf("NULL!\n"); return 0; }
+ printf("Not selected alt: %s\n", vimminimal->getPath().ascii());
+
+ printf("Selecting vim-minimal instead of vim-enhanced as vi\n");
+ if(!vimminimal->select())
+ {
+ printf("ERROR: %s\n", vimminimal->getSelectError().ascii());
+ }
+
+ printf("Now selecting vim-enhanced...\n");
+ Alternative *vimen = item->getAlternative("/usr/bin/vim-enhanced");
+ if(vimen == NULL) { printf("NULL!\n"); return 0; }
+ if(!vimen->select())
+ {
+ printf("ERROR: %s\n", alt->getSelectError().ascii());
+ }
+ return 0;
+ }
+*/
diff --git a/src/altparser.h b/src/altparser.h
new file mode 100644
index 0000000..74842df
--- /dev/null
+++ b/src/altparser.h
@@ -0,0 +1,140 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Juanjo Álvarez *
+ * juanjux@yahoo.es *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _ALTPARSER_H_
+#define _ALTPARSER_H_
+
+
+//FIXME: Cosas pa mirar:
+//Comprobar entradas NULL y demás (sobre todo antes de los delete)
+//
+//Quitar el stdio.h
+
+#include <qstring.h>
+#include <qobject.h>
+#include <qptrlist.h>
+#include <qstringlist.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+class Item;
+
+struct Slave
+{
+ QString slname;
+ QString slpath;
+};
+
+class Alternative
+{
+ QString m_altPath;
+ QString m_selectError;
+ int m_priority;
+ Item *m_parent;
+ QStringList *m_altSlaves;
+public:
+ Alternative(Item *parentarg);
+ Alternative(const Alternative &alt);
+ ~Alternative();
+ Alternative& operator=(const Alternative &alt);
+
+ Item* getParent() const { return m_parent; }
+ QString getPath() const { return m_altPath; }
+ void setPath(const QString &patharg) { m_altPath = patharg; }
+ int getPriority() const { return m_priority; }
+ void setPriority(int priorityarg) { m_priority = priorityarg; }
+ QStringList* getSlaves() const { return m_altSlaves; }
+ void setSlaves(QStringList *m_altSlaves);
+ void addSlave(const QString &slave) { m_altSlaves->append(slave); }
+ uint countSlaves() const { return m_altSlaves->count(); }
+ QString getSlave(int pos) const { return *(m_altSlaves->at(pos)); }
+ bool isSelected() const;
+ bool isBroken() const;
+ bool select();
+ QString getSelectError() const { return m_selectError; }
+};
+
+typedef QPtrList<Slave> SlaveList;
+typedef QPtrList<Alternative> AltsPtrList;
+
+class Item
+{
+ QString m_name;
+ QString m_mode;
+ QString m_path;
+ SlaveList *m_itemSlaves;
+ AltsPtrList *m_itemAlts;
+public:
+ Item();
+ // Deep copy constructor:
+ Item(const Item &item);
+ ~Item();
+ Item& operator=(const Item &item);
+
+ Alternative* getSelected() const;
+ QString getName() const { return m_name; }
+ void setName(const QString &namearg) { m_name = namearg; }
+ QString getMode() const { return m_mode; }
+ //Check the input (FIXME)
+ void setMode(const QString &modearg) { m_mode = modearg; }
+ QString getPath() const { return m_path; }
+ void setPath(const QString &patharg) { m_path = patharg; }
+ SlaveList *getSlaves() const { return m_itemSlaves; }
+ void setSlaves(SlaveList *slaves);
+ void addSlave(const QString &namearg, const QString &patharg);
+ void delSlave(const QString &namearg);
+ void delSlaveByPath(const QString &patharg);
+ AltsPtrList *getAlternatives() const { return m_itemAlts; }
+ Alternative *getAlternative(const QString &altpath);
+ void setAlternatives(AltsPtrList &alts);
+ int countAlternatives() const { return m_itemAlts->count(); }
+ void delAlternativeByPath(const QString &patharg);
+ void delAlternativeByPriority(int priorityarg);
+ void addAlternative(Alternative *altarg) { m_itemAlts->append(altarg); }
+ bool isBroken() const;
+};
+
+typedef QPtrList<Item> ItemPtrList;
+
+class AltFilesManager
+{
+ ItemPtrList *m_itemlist;
+ QString m_altdir;
+ QString m_errorMsg;
+ bool m_parseOk;
+
+ bool parseAltFiles(QString &errorstr);
+public:
+ AltFilesManager(const QString &altdir);
+ ~AltFilesManager();
+
+ ItemPtrList* getGlobalAlternativeList() const { return this->m_itemlist; }
+ bool parsingOk() const { return m_parseOk; }
+ QString getErrorMsg() const { return m_errorMsg; }
+ Item* getItem (const QString &name) const;
+ //FIXME: Put in a #ifdef
+ void debugPrintAlts() const;
+ QString getAltDir() { return m_altdir ;}
+//protected:
+ //virtual int compareItems(Item i1, Item i2);
+};
+#endif // _KALTERNATIVES_H_
diff --git a/src/hi16-app-kalternatives.png b/src/hi16-app-kalternatives.png
new file mode 100644
index 0000000..4ed606c
--- /dev/null
+++ b/src/hi16-app-kalternatives.png
Binary files differ
diff --git a/src/hi32-app-kalternatives.png b/src/hi32-app-kalternatives.png
new file mode 100644
index 0000000..45ae1a1
--- /dev/null
+++ b/src/hi32-app-kalternatives.png
Binary files differ
diff --git a/src/kalternatives.cpp b/src/kalternatives.cpp
new file mode 100644
index 0000000..120f704
--- /dev/null
+++ b/src/kalternatives.cpp
@@ -0,0 +1,457 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Juanjo *
+ * juanjux@yahoo.es *
+ * *
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "kalternatives.h"
+#include "altparser.h"
+#include "propertieswindow.h"
+#include "altcontroller.h"
+#include "altitemelement.h"
+#include "treeitemelement.h"
+#include "addalternatives.h"
+#include "mainwindow.h"
+
+#include <qtimer.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 <kgenericfactory.h>
+#include <kstdguiitem.h>
+#include <kdeversion.h>
+
+typedef KGenericFactory<Kalternatives, QWidget> KalternativesFactory;
+K_EXPORT_COMPONENT_FACTORY( kcm_kalternatives, KalternativesFactory("kcmkalternatives"))
+
+extern "C"
+{
+ KCModule *create_kalternatives(QWidget *parent, const char *name)
+ {
+ return new Kalternatives(parent, name);
+ };
+}
+
+Kalternatives::Kalternatives(QWidget *parent, const char *name, const QStringList&)
+:KCModule(/*KalternativesFactory::instance(), */parent, name), myAboutData(0)
+{
+ setUseRootOnlyMsg(false);
+
+ int user = getuid();
+
+ if (user == 0)
+ {
+ m_bisRoot = true;
+ setButtons(KCModule::Help|KCModule::Apply);
+ }
+ else
+ {
+ m_bisRoot = false;
+ setButtons(Help);
+ }
+
+#ifdef MANDRAKE
+m_mgr = new AltFilesManager("/var/lib/rpm/alternatives");
+#else
+ #ifdef DEBIAN
+ 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()));
+ #endif
+#endif
+
+ MainWindow *mainwindow = new MainWindow(this);
+ QBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint());
+ layout->addWidget( mainwindow );
+ layout->activate();
+
+ mainwindow->m_altList->setShowToolTips(1);
+
+ connect(mainwindow->m_hideAlt, SIGNAL(clicked()), this,
+ SLOT(slotHideAlternativesClicked()));
+
+ connect(mainwindow->m_altList, SIGNAL(selectionChanged( QListViewItem* )), this,
+ SLOT(slotSelectAlternativesClicked(QListViewItem *)));
+
+ connect(mainwindow->m_optionsList, SIGNAL(clicked(QListViewItem *)),
+ this, SLOT(slotOptionClicked(QListViewItem *)));
+ connect(mainwindow->m_bAdd, SIGNAL(clicked()), this,
+ SLOT(slotAddClicked()));
+ connect(mainwindow->m_bDelete, SIGNAL(clicked()), this,
+ SLOT(slotDeleteClicked()));
+ connect(mainwindow->m_bProperties, SIGNAL(clicked()), this,
+ SLOT(slotPropertiesClicked()));
+
+ m_altList = mainwindow->m_altList;
+ m_optionsList = mainwindow->m_optionsList;
+ m_altTilte = mainwindow->m_altTilte;
+ m_statusCombo = mainwindow->m_statusCombo;
+ m_hideAlt = mainwindow->m_hideAlt;
+
+ mainwindow->m_bDelete->setGuiItem(KStdGuiItem::del());
+ mainwindow->m_bAdd->setGuiItem(KGuiItem(i18n("&Add"), "edit_add"));
+ mainwindow->m_bProperties->setGuiItem(KGuiItem( i18n( "&Properties" ), "configure"));
+
+ if(!m_bisRoot)
+ {
+ mainwindow->m_bDelete->setEnabled(false);
+ mainwindow->m_bAdd->setEnabled(false);
+ mainwindow->m_bProperties->setEnabled(false);
+ m_statusCombo->setEnabled(false);
+ }
+
+ myAboutData = new KAboutData("kcmkalternatives", I18N_NOOP("Kalternatives"),
+ KALT_VERSION, I18N_NOOP("KDE Mandrake/Debian alternatives-system manager"),
+ KAboutData::License_GPL, I18N_NOOP("(c) 2004 Juanjo Alvarez Martinez\n"
+ "(c) 2004 Mario Bensi"));
+
+ myAboutData->addAuthor("Juanjo Alvarez Martinez", 0, "juanjo@juanjoalvarez.net",
+ "http://juanjoalvarez.net");
+ myAboutData->addAuthor("Mario Bensi", 0, "nef@ipsquad.net", "http://ipsquad.net");
+ myAboutData->addAuthor("Pino Toscano", 0, "toscano.pino@tiscali.it");
+
+#if KDE_IS_VERSION(3,2,90)
+ setAboutData( myAboutData );
+#endif
+
+ load();
+ m_hideAlt->setChecked(true);
+ slotHideAlternativesClicked();
+}
+
+Kalternatives::~Kalternatives()
+{
+ if(m_mgr) delete m_mgr;
+ if(m_altList) delete m_altList;
+ if(m_optionsList) delete m_optionsList;
+ if(m_altTilte) delete m_altTilte;
+ if(m_statusCombo) delete m_statusCombo;
+ if(m_hideAlt) delete m_hideAlt;
+}
+
+void Kalternatives::die()
+{
+ delete this;
+}
+
+void Kalternatives::load()
+{
+ clearList(m_altList);
+ QPtrList<Item> *itemslist = m_mgr->getGlobalAlternativeList();
+ Item *i;
+ TreeItemElement *treeit;
+ for(i = itemslist->first(); i; i = itemslist->next())
+ {
+ AltController *altcontroller = new AltController();
+ treeit = new TreeItemElement(m_altList, i, altcontroller);
+
+ AltsPtrList *altList = i->getAlternatives();
+ Alternative *a = altList->first();
+
+ AltItemElement *ael;
+
+ for(; a; a=altList->next())
+ {
+ ael = new AltItemElement(m_optionsList, a);
+ if(!m_bisRoot) ael->setEnabled(false);
+ treeit->getAltController()->addAltItem(ael);
+ }
+ }
+}
+
+
+
+
+void Kalternatives::clearList(KListView* list)
+{
+ QListViewItemIterator it( list );
+ QListViewItem *tmp;
+ while( (tmp=it.current()) )
+ {
+ it++;
+ list->takeItem(tmp);
+ }
+}
+
+
+void Kalternatives::slotSelectAlternativesClicked(QListViewItem *alternative)
+{
+ clearList(m_optionsList);
+ TreeItemElement *treeItem;
+ if((treeItem = dynamic_cast<TreeItemElement *>(alternative)))
+ {
+ Item *item = treeItem->getItem();
+
+ m_altTilte->setText(treeItem->getName());
+ m_statusCombo->setCurrentItem(item->getMode());
+
+ AltItemList *altItemList = treeItem->getAltController()->getAltItemList();
+
+ for( AltItemElement *altItem= altItemList->first(); altItem ; altItem = altItemList->next())
+ {
+ Alternative *a = altItem->getAlternative();
+
+ QString priority;
+ priority.setNum(a->getPriority());
+
+ m_optionsList->insertItem(altItem);
+
+ altItem->setText( 1, priority);
+ altItem->setText( 2, a->getPath());
+ QString m_small_desc = altItem->getDescription();
+
+ if (!m_small_desc.isEmpty())
+ {
+ altItem->setText( 3, m_small_desc);
+ }
+ else
+ {
+ altItem->searchDescription();
+ }
+ }
+ }
+ m_optionsList->setSelected(m_optionsList->firstChild(), 1);
+}
+
+
+
+void Kalternatives::slotHideAlternativesClicked()
+{
+ if (m_hideAlt->isChecked ())
+ {
+ QListViewItemIterator it( m_altList );
+ TreeItemElement *i;
+ QListViewItem *tmp;
+ while ( it.current() )
+ {
+ if((i = dynamic_cast<TreeItemElement *>(it.current())))
+ {
+ if ((i->getItem()->getAlternatives()->count()) <= 1)
+ {
+ tmp = it.current();
+ it++;
+ m_altList->takeItem(tmp);
+ continue;
+ }
+ }
+ it++;
+ }
+ }
+ else
+ {
+ load();
+ }
+ m_altList->setSelected(m_altList->firstChild (), 1);
+}
+
+
+void Kalternatives::slotOptionClicked(QListViewItem *option)
+{
+ AltItemElement *altItem;
+ if((altItem = dynamic_cast<AltItemElement *>(option)))
+ {
+ if( !altItem->isOn())
+ return;
+ TreeItemElement *treeItem;
+ if((treeItem = dynamic_cast<TreeItemElement *>(m_altList->selectedItem())))
+ {
+ treeItem->getAltController()->setBoutonOnOff(m_optionsList, altItem);
+ treeItem->setChanged(TRUE);
+ emit changed(true);
+ }
+ }
+}
+
+void Kalternatives::slotAddClicked()
+{
+ TreeItemElement *treeItem;
+ if((treeItem = dynamic_cast<TreeItemElement *>(m_altList->selectedItem())))
+ {
+ m_optionsList->setSelected(m_optionsList->firstChild(), 1);
+
+ AltItemElement *altItem;
+ if((altItem = dynamic_cast<AltItemElement *>(m_optionsList->selectedItem())))
+ {
+ int countSlave = altItem->getAlternative()->countSlaves();
+ AddAlternatives *addAlternatives = new AddAlternatives(treeItem, this, countSlave);
+ addAlternatives->show();
+ }
+ }
+}
+void Kalternatives::slotDeleteClicked()
+{
+ TreeItemElement *treeItem;
+ if((treeItem = dynamic_cast<TreeItemElement *>(m_altList->selectedItem())))
+ {
+ AltItemElement *altItem;
+ if((altItem = dynamic_cast<AltItemElement *>(m_optionsList->selectedItem())))
+ {
+ treeItem->getItem()->delAlternativeByPath(altItem->getPath());
+
+ AltItemList *altItemList = treeItem->getAltController()->getAltItemList();
+
+ altItemList->remove(altItem);
+ m_optionsList->takeItem(altItem);
+
+ treeItem->setNbrAltChanged(TRUE);
+ emit changed( TRUE );
+ m_optionsList->setSelected(m_optionsList->firstChild (), 1);
+ }
+ }
+}
+
+void Kalternatives::slotPropertiesClicked()
+{
+ AltItemElement *altItem;
+
+ if((altItem = dynamic_cast<AltItemElement *>(m_optionsList->selectedItem())))
+ {
+ QString text;
+ PropertiesWindow *prop = new PropertiesWindow(this);
+ prop->bClose->setGuiItem(KStdGuiItem::close());
+
+ Alternative *a = altItem->getAlternative();
+
+
+ text += i18n( "Description :\n%1\n" ).arg( altItem->getDescription() );
+ text += i18n( "Path : %1\n" ).arg( a->getPath() );
+ text += i18n( "Priority : %1\n" ).arg( a->getPriority() );
+
+ QStringList* slavesList = a->getSlaves();
+ text += i18n( "Slave :", "Slaves :", slavesList->count() );
+
+ for ( QStringList::Iterator it = slavesList->begin(); it != slavesList->end(); ++it )
+ {
+ text += "\n\t";
+ text += *it;
+ }
+ prop->m_text->setText(text);
+ prop->show();
+ }
+}
+
+
+void Kalternatives::save()
+{
+ QListViewItemIterator it( m_altList );
+ TreeItemElement *treeItem;
+
+ while ( it.current() )
+ {
+ if((treeItem = dynamic_cast<TreeItemElement *>(it.current())))
+ {
+ if(treeItem->isNbrAltChanged())
+ {
+ QString parentPath = QString("%1/%2")
+ .arg(m_mgr->getAltDir())
+ .arg(treeItem->getName());
+
+ QFile origFile(parentPath);
+ if(origFile.exists())
+ {
+ origFile.remove();
+ }
+
+ if( origFile.open( IO_WriteOnly ))
+ {
+ QTextStream stream( &origFile );
+
+
+ Item *item = treeItem->getItem();
+
+ stream << item->getMode() << endl;
+ stream << item->getPath() << endl;
+
+ SlaveList *slaveList = item->getSlaves();
+ Slave *slave = slaveList->first();
+ for(; slave; slave = slaveList->next())
+ {
+ stream << slave->slname << endl;
+ stream << slave->slpath << endl;
+ }
+
+ stream << endl;
+
+ AltItemList *altItemList = treeItem->getAltController()->getAltItemList();
+ AltItemElement *altItem= altItemList->first();
+ for( ; altItem ; altItem = altItemList->next())
+ {
+ Alternative *a = altItem->getAlternative();
+
+ stream << a->getPath() << endl;
+ stream << a->getPriority() << endl;
+
+ QStringList *slaveList = a->getSlaves();
+ QStringList::Iterator it = slaveList->begin();
+ for ( ; it != slaveList->end(); ++it )
+ {
+ stream << *it << endl;
+ }
+ }
+ origFile.close();
+ }
+ treeItem->setNbrAltChanged(FALSE);
+ }
+ if(treeItem->isChanged())
+ {
+ AltItemList *altItemList = treeItem->getAltController()->getAltItemList();
+ AltItemElement *altItem= altItemList->first();
+ for( ; altItem ; altItem = altItemList->next())
+ {
+ if( altItem->isOn() )
+ {
+ Alternative *a = altItem->getAlternative();
+ if(!a->select())
+ {
+ kdDebug() << a->getSelectError() << endl;
+ }
+ }
+ }
+ treeItem->setChanged(FALSE);
+ }
+ }
+ it++;
+ }
+ emit changed( false );
+}
+
+
+void Kalternatives::configChanged()
+{
+ emit changed(true);
+}
+
+
+QString Kalternatives::quickHelp() const
+{
+ return i18n("<h1>Kalternatives</h1>\n"
+ "A Mandrake/Debian alternatives-system manager.");
+}
+
+
+
+#include "kalternatives.moc"
diff --git a/src/kalternatives.desktop b/src/kalternatives.desktop
new file mode 100644
index 0000000..abbd53c
--- /dev/null
+++ b/src/kalternatives.desktop
@@ -0,0 +1,37 @@
+[Desktop Entry]
+Encoding=UTF-8
+Exec=kcmshell kalternatives
+Icon=misc
+Type=Application
+
+X-KDE-ModuleType=Library
+X-KDE-Library=kalternatives
+X-KDE-RootOnly=true
+X-KDE-HasReadOnlyMode=true
+X-KDE-ParentApp=kcontrol
+
+Comment=Kalternatives - KDE Mandrake/Debian alternatives-system manager
+Comment[da]=Alternative systemhåndteringer, Kalternatives for KDE Mandrake/Debian
+Comment[es]=Kalternatives - administrador alternativo del sistema KDE en Mandrake/Debian
+Comment[et]=Kalternatives - KDE Mandrake/Debiani alternatiivide süsteemi haldur
+Comment[fr]=KAlternatives - Un gestionnaire du système d'alternatives Mandrake / Debian pour KDE
+Comment[gl]=Kalternatives - Xestión do sistema de alternativas da Mandrake/Debian
+Comment[it]=Kalternatives - Gestione dei sistemi di alternative di Mandrake e Debian per KDE
+Comment[pt]=Kalternatives - Gestão de sistema de alternativas para Mandrake/Debian
+Comment[pt_BR]=Kalternatives - Gestão de sistema de alternativas para Mandrake/Debian
+Comment[sv]=Kalternativ - KDE:s Mandrake och Debian alternativ systemhantering
+Comment[ta]=Kalternatives - கேடியி மாண்ட்ரேக்/டெபியன் மாற்றுகள் அமைப்பு மேலாளர்
+Comment[tr]=Kseçenekleri - KDE Mandarake/Debian seçenekleri sistem yöneticisi
+Comment[xx]=xxKalternatives - KDE Mandrake/Debian alternatives-system managerxx
+Keywords=Kalternatives,kalternatives
+Keywords[fr]=Kalternatives,kalternatives,alternatives
+Keywords[sv]=Kalternativ,kalternativ
+Keywords[tr]=Kseçenekleri,kseçenekleri
+Keywords[xx]=xxKalternatives,kalternativesxx
+Name=Kalternatives
+Name[ta]=Kமாற்றுகள்
+Name[tr]=Kseçenekleri
+Name[xx]=xxKalternativesxx
+
+
+Categories=Qt;KDE;X-KDE-settings-system;
diff --git a/src/kalternatives.h b/src/kalternatives.h
new file mode 100644
index 0000000..8094423
--- /dev/null
+++ b/src/kalternatives.h
@@ -0,0 +1,83 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Juanjo *
+ * juanjux@yahoo.es *
+ * *
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _KALTERNATIVES_H_
+#define _KALTERNATIVES_H_
+
+//#ifdef HAVE_CONFIG_H
+//#include <config.h>
+//#endif
+
+#include <klistview.h>
+#include <kpushbutton.h>
+#include <kcombobox.h>
+#include <qwidget.h>
+#include <qlabel.h>
+#include <qcheckbox.h>
+#include <kcmodule.h>
+#include <kaboutdata.h>
+
+#define KALT_VERSION "0.12"
+
+class AltFilesManager;
+
+class Kalternatives : public KCModule
+{
+ Q_OBJECT
+
+ bool m_bisRoot;
+ AltFilesManager *m_mgr;
+ KListView* m_optionsList;
+ KListView* m_altList;
+ KComboBox* m_statusCombo;
+ QLabel* m_altTilte;
+ QCheckBox* m_hideAlt;
+ KAboutData *myAboutData;
+
+ void clearList(KListView* list);
+
+public:
+ Kalternatives(QWidget *parent=0, const char *name=0, const QStringList& = QStringList() );
+ virtual ~Kalternatives();
+ KListView *optionsList() const {return m_optionsList;}
+ bool isBisRoot() const {return m_bisRoot;}
+
+ virtual void load();
+ virtual void save();
+ virtual QString quickHelp() const;
+ virtual const KAboutData *aboutData()const { return myAboutData; };
+
+public slots:
+ void configChanged();
+
+private slots:
+ void slotSelectAlternativesClicked(QListViewItem *);
+ void slotHideAlternativesClicked();
+ void die();
+ void slotOptionClicked(QListViewItem *option);
+ void slotAddClicked();
+ void slotDeleteClicked();
+ void slotPropertiesClicked();
+};
+
+#endif // _KALTERNATIVES_H_
diff --git a/src/kalternatives.lsm b/src/kalternatives.lsm
new file mode 100644
index 0000000..8558492
--- /dev/null
+++ b/src/kalternatives.lsm
@@ -0,0 +1,16 @@
+Begin3
+Title: kalternatives -- Some description
+Version: 0.12
+Entered-date:
+Description:
+Keywords: KDE Qt
+Author: Juanjo <juanjux@yahoo.es>
+Maintained-by: Juanjo <juanjux@yahoo.es>
+Home-page:
+Alternate-site:
+Primary-site: ftp://ftp.kde.org/pub/kde/unstable/apps/utils
+ xxxxxx kalternatives-0.12.tar.gz
+ xxx kalternatives-0.12.lsm
+Platform: Linux. Needs KDE
+Copying-policy: GPL
+End
diff --git a/src/kalternativesui.rc b/src/kalternativesui.rc
new file mode 100644
index 0000000..347fe72
--- /dev/null
+++ b/src/kalternativesui.rc
@@ -0,0 +1,8 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="kalternatives" version="1">
+<MenuBar>
+ <Menu name="custom"><text>C&amp;ustom</text>
+ <Action name="custom_action" />
+ </Menu>
+</MenuBar>
+</kpartgui>
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..860a2ba
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,77 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Juanjo *
+ * juanjux@yahoo.es *
+ * *
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "main.h"
+#include "kalternatives.h"
+#include <kuniqueapplication.h>
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+KUniqueApplication *app = 0; // Global
+
+static const char description[] =
+ I18N_NOOP("A KDE Manager for the Debian/Mandrake alternatives system");
+
+static const char version[] = "0.10";
+
+static KCmdLineOptions options[] =
+{
+// { "+[URL]", I18N_NOOP( "Document to open." ), 0 },
+ KCmdLineLastOption
+};
+
+int main(int argc, char **argv)
+{
+ KAboutData about("kalternatives", I18N_NOOP("kalternatives"), version, description,
+ KAboutData::License_GPL, "(C) 2004 Juanjo Alvarez Martinez and Mario Bensi", 0, 0, "juanjux@yahoo.es, nef@ipsquad.net");
+ about.addAuthor( "Juanjo Alvarez Martinez and Mario Bensi", 0, "juanjux@yahoo.es, nef@ipsquad.net" );
+
+ KCmdLineArgs::init(argc, argv, &about);
+ KCmdLineArgs::addCmdLineOptions( options );
+ KUniqueApplication rapp;
+ app = &rapp;
+ Kalternatives *mainWin = 0;
+
+ if (app->isRestored())
+ {
+ //RESTORE(kalternatives);
+ }
+ else
+ {
+ // no session.. just start up normally
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ /// @todo do something with the command line args here
+
+ mainWin = new Kalternatives();
+ app->setMainWidget( mainWin );
+ mainWin->show();
+
+
+ args->clear();
+ }
+ return app->exec();
+}
+
diff --git a/src/main.h b/src/main.h
new file mode 100644
index 0000000..24ff6c8
--- /dev/null
+++ b/src/main.h
@@ -0,0 +1,8 @@
+#ifndef _MAIN_H_
+#define _MAIN_H_
+
+#include <kuniqueapplication.h>
+
+extern KUniqueApplication *app;
+
+#endif //_MAIN_H_
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
new file mode 100644
index 0000000..8df2d9a
--- /dev/null
+++ b/src/mainwindow.ui
@@ -0,0 +1,392 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>MainWindow</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>Kalternatives</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>615</width>
+ <height>490</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="caption">
+ <string>Alternatives Manager</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QSplitter" row="0" column="0">
+ <property name="name">
+ <cstring>splitter2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KListView">
+ <column>
+ <property name="text">
+ <string>Alternatives</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_altList</cstring>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="lineWidth">
+ <number>1</number>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <property name="alignment">
+ <set>AlignAuto</set>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>m_hideAlt</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="acceptDrops">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Hide useless alternatives</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout24</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout22</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout5_2</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>status :</string>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <item>
+ <property name="text">
+ <string>auto</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>manual</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>m_statusCombo</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>88</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_altTilte</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Automake</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>88</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="KListView">
+ <column>
+ <property name="text">
+ <string>Choice</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Priority</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Option</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Description</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_optionsList</cstring>
+ </property>
+ <property name="resizePolicy">
+ <enum>AutoOneFit</enum>
+ </property>
+ <property name="hScrollBarMode">
+ <enum>Auto</enum>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ <property name="fullWidth">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_bAdd</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Add</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_bProperties</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Properties</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>m_bDelete</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klistview.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>klistview.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/src/propertieswindow.ui b/src/propertieswindow.ui
new file mode 100644
index 0000000..026df51
--- /dev/null
+++ b/src/propertieswindow.ui
@@ -0,0 +1,106 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>PropertiesWindow</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>PropertiesWindow</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>532</width>
+ <height>407</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Alternative Properties</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout17</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KTextEdit">
+ <property name="name">
+ <cstring>m_text</cstring>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line3</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>bClose</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Close</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>bClose</sender>
+ <signal>clicked()</signal>
+ <receiver>PropertiesWindow</receiver>
+ <slot>close()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>ktextedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/src/treeitemelement.cpp b/src/treeitemelement.cpp
new file mode 100644
index 0000000..b6732d9
--- /dev/null
+++ b/src/treeitemelement.cpp
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "treeitemelement.h"
+#include "altparser.h"
+#include "altcontroller.h"
+#include <qfont.h>
+#include <qpainter.h>
+
+#include <iostream>
+using namespace std;
+
+TreeItemElement::TreeItemElement(KListView *parent, Item *itemarg, AltController *altControl )
+: QListViewItem(parent, itemarg->getName()),
+ m_item(itemarg),
+ m_name(itemarg->getName()),
+ m_changed(FALSE),
+ m_nbrAltChanged(FALSE),
+ m_altControl(altControl)
+{
+}
+
+
+TreeItemElement::~TreeItemElement()
+{
+}
+
+void TreeItemElement::paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int align )
+{
+ QColor color;
+
+ if (m_changed || m_nbrAltChanged)
+ {
+ color=QColor("red");
+ QFont f = p->font();
+ f.setBold(true);
+ p->setFont(f);
+ }
+
+ // the pallet of colors is saved
+ QColorGroup _cg( cg );
+ QColor oldText=_cg.text();
+
+ // modification of the pallet of colors by defining
+ //our new color as color of text
+ _cg.setColor( QColorGroup::Text, color );
+
+ QListViewItem::paintCell( p, _cg, column, width, align );
+
+ // restoration of the pallet of "standard" colors
+ _cg.setColor( QColorGroup::Text, oldText );
+
+}
diff --git a/src/treeitemelement.h b/src/treeitemelement.h
new file mode 100644
index 0000000..8551f5d
--- /dev/null
+++ b/src/treeitemelement.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Mario Bensi *
+ * nef@ipsquad.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef _TREEITEMELEMENT_H_
+#define _TREEITEMELEMENT_H_
+
+#include <qstring.h>
+#include <qptrlist.h>
+#include <qlistview.h>
+#include <klistview.h>
+
+class AltController;
+class Item;
+
+
+class TreeItemElement : public QListViewItem
+{
+ Item *m_item;
+ QString m_name;
+ bool m_changed;
+ bool m_nbrAltChanged;
+ AltController *m_altControl;
+
+public:
+ TreeItemElement(KListView *parent, Item *itemarg, AltController *altControl);
+ ~TreeItemElement();
+
+ QString getName() const { return m_name; }
+ Item *getItem() const { return m_item; }
+ void setChanged(bool c) { m_changed = c; }
+ bool isChanged() const { return m_changed; }
+ void setNbrAltChanged(bool c) { m_nbrAltChanged = c; }
+ bool isNbrAltChanged() const { return m_nbrAltChanged; }
+ AltController *getAltController() {return m_altControl;}
+
+ virtual void paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int align );
+};
+
+#endif //_TREEITEMELEMENT_H_