SVN_SILENT made messages (.desktop file)
[kdeadmin.git] / kpackage / managementWidget.h
blob77cfae0b72478368b7819f9a8be9516dcf0dbe1a
1 /*
2 ** Copyright (C) 1999,2000 Toivo Pedaste <toivo@ucs.uwa.edu.au>
3 **
4 // Author: Damyan Pepper
5 //
6 // This widget is used to provide the management mode of ksetup.
7 // There are two subwidgets; firstly a tree list showing all the
8 // currently installed packages and secondly a display of the currently
9 // selected package's properties.
11 // There are also some control buttons which allow the currently
12 // selected package to be uninstalled or verified.
16 ** This program is free software; you can redistribute it and/or modify
17 ** it under the terms of the GNU General Public License as published by
18 ** the Free Software Foundation; either version 2 of the License, or
19 ** (at your option) any later version.
21 ** This program is distributed in the hope that it will be useful,
22 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ** GNU General Public License for more details.
26 ** You should have received a copy of the GNU General Public License
27 ** along with this program in a file called COPYING; if not, write to
28 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
29 ** MA 02110-1301, USA.
33 ** Bug reports and questions can be sent to kde-devel@kde.org
36 #ifndef MANAGEMENTWIDGET_H
37 #define MANAGEMENTWIDGET_H
39 // Standard Headers
41 // Qt Headers
42 #include <QtGui/QFrame>
43 #include <QtGui/QPushButton>
44 #include <Qt3Support/Q3PtrList>
46 #include <QtGui/QLayout>
47 #include <QtGui/QTabWidget>
48 #include <QtGui/QLabel>
49 #include <Qt3Support/Q3HBox>
50 //Added by qt3to4:
51 #include <QtGui/QResizeEvent>
52 #include <QtGui/QBoxLayout>
53 #include <QtCore/QList>
54 #include <QtCore/QSet>
56 // KDE headers
57 #include <kaction.h>
58 #include <k3listview.h>
59 #include <k3listviewsearchline.h>
61 // ksetup headers
62 #include "packageInfo.h"
63 #include "kplview.h"
65 class QSplitter;
66 class QComboBox;
68 class packageDisplayWidget;
69 class packageInfo;
70 class managementWidget;
72 class KpListViewSearchLine : public K3ListViewSearchLine
74 Q_OBJECT
76 public:
78 KpListViewSearchLine(QWidget *parent, KpTreeList *listView);
80 ~KpListViewSearchLine();
83 void updateSearch(const QString &s = QString());
85 private:
86 KpTreeList *list;
90 class managementWidget : public QFrame
92 Q_OBJECT
94 ///////////// METHODS ------------------------------------------------------
95 public:
96 managementWidget(QWidget *parent);
97 // Constructor
99 ~managementWidget();
100 // Destructor
102 KpTreeListItem *updatePackage(packageInfo *pki, bool wantInstall, bool haveInstall=false);
103 // update package in treelist
105 void readPSeparator();
106 void writePSeparator();
107 // config: position of panel separator
109 void doChangePackage(packageInfo *p);
110 // emit change package
112 KpTreeListItem *search(QString str, bool subStr, bool wrap,
113 bool start = false);
115 enum {INSTALLED, NEW, UPDATES, AVAILABLE, ALL};
117 protected:
118 void resizeEvent(QResizeEvent *re);
119 // This is called when the widget is resized
121 private:
122 void setupWidgets();
123 // This sets up the sub-widgets
125 void setupInstButton();
126 // Set button for inst or uninst
128 void arrangeWidgets();
129 // This arranges the widgets in the window (should be called after a
130 // resize event)
132 void setupMultButton(int &cntInstall, int &cntUnInstall);
133 // Setup mult install/uninstall button appropriately
136 ///////////// SLOTS ------------------------------------------------------
137 public slots:
138 void collectData(bool refresh);
139 // This collects data about all the packages installed.
140 // The list tree is filled with this data. Whenever something happens
141 // that requires data to be (re)collected a signal connected to this slot
142 // should be emitted. This function can also be called directly.
144 void rebuildListTree();
145 // This rebuilds the list tree. This would normally be called if the
146 // data contained about the packages has been changed (e.g. a verification
147 // failed / succeeded).
149 void updatePackageState(QList<packageInfo *> packs, bool wantInstall);
151 void uninstallMultClicked();
152 // This is called when uninstalling multiple packages
154 void uninstallSingleClicked();
155 // This is called when uninstalling a single package
157 void installSingleClicked();
158 // This is called when the install button has been clicked with single package
160 void installMultClicked();
161 // This is called when the install button has been clicked with multiple packages
163 void setInstallAction(QAction *a) { install_action = a; }
164 void setUninstallAction(QAction *a) { uninstall_action = a; }
166 void packageHighlighted(Q3ListViewItem *);
167 // This is called when a package has been highlighted in the list tree
169 void filterChanged(int);
170 // treelist display tab changed
172 void checkMarked();
173 // Count marked packages that can be installed/uninstalled
175 ///////////// SIGNALS ------------------------------------------------------
178 ///////////// DATA ---------------------------------------------------------
179 private:
181 QPushButton *linstButton,*luinstButton,*instButton,*uinstButton;
182 // This button is used to (un)install the selected package
184 packageDisplayWidget *packageDisplay;
185 // This widget displays the package info / file-list
187 QBoxLayout *top, *leftbox, *rightbox, *lbuttons, *rbuttons, *searchBox;
188 // These are the geometry managers
190 QFrame *leftpanel, *rightpanel;
191 // frame to put QBox in
193 QSplitter *vPan;
194 // veritcal panner between panels
196 QFrame *searchToolBar;
197 QLabel *searchLabel;
198 QComboBox *searchCombo;
200 Q3PtrList<KpTreeListItem> selList;
201 // list for selected packages
203 QString tType[5];
204 // identifiers for tree display
206 public:
207 QList<packageInfo *> allPackages;
208 // The list of packages
210 QSet<QString> isInstalled;
211 // List of the names of installed packages
213 QHash<QString, packageInfo *> dirInstPackages;
214 // maps installed package name to package
216 QHash<QString, packageInfo *> dirUninstPackages;
217 // maps uninstalled package name to package
219 QHash<QString, packageInfo *> dirInfoPackages;
220 // maps Info package name to package
222 KpTreeList *treeList;
223 // This is the tree list where all the packages / groups are displayed
225 KpListViewSearchLine *searchLine;
226 // Widget for search treeList
228 QAction *install_action;
229 QAction *uninstall_action;
232 #endif