SVN_SILENT made messages (.desktop file)
[kdeadmin.git] / kpackage / kpackage.h
blob50c7b655cb68f2618842ca6f1f4589e03e673cfc
1 /*
2 ** Copyright (C) 2007 Toivo Pedaste <toivo@ucs.uwa.edu.au>
3 **
4 ** This is the main widget for kpackage
5 ** The whole widget is a DND drop zone where users can drop packages to
6 ** be installed.
7 */
9 /*
10 ** This program is free software; you can redistribute it and/or modify
11 ** it under the terms of the GNU General Public License as published by
12 ** the Free Software Foundation; either version 2 of the License, or
13 ** (at your option) any later version.
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ** GNU General Public License for more details.
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program in a file called COPYING; if not, write to
22 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 ** MA 02110-1301, USA.
27 ** Bug reports and questions can be sent to kde-devel@kde.org
30 #ifndef KPACKAGE_H
31 #define KPACKAGE_H
33 // KDE headers
34 #include <kurl.h>
35 #include <kxmlguiwindow.h>
36 #include <kpPty.h>
37 #include <ksharedconfig.h>
38 #include <QtGui/QDragEnterEvent>
39 #include <QtGui/QLabel>
40 #include <QtGui/QFrame>
41 #include <QtGui/QResizeEvent>
42 #include <QtGui/QDropEvent>
43 #include <QtGui/QCloseEvent>
45 #include <kpkg.h>
47 class KFileDialog;
48 class QProgressBar;
49 class QLabel;
50 class Search;
51 class FindF;
52 class pkgInterface;
53 class managementWidget;
54 class kpRun;
56 //////////////////////////////////////////////////////////////////////////////
58 #define kpinterfaceN 3
60 enum {UPACKAGE = 0, DEBt, RPMt, SLACKt};
62 //////////////////////////////////////////////////////////////////////////////
63 class KPACKAGE : public QWidget
65 Q_OBJECT
67 ///////////// METHODS ------------------------------------------------------
68 public:
69 KPACKAGE(const KSharedConfigPtr &_config, QWidget *parent);
70 // Constructor
72 ~KPACKAGE();
73 // Destructor
75 void setStatus(const QString &s);
76 // this sets the status bar's string to s
78 void setPercent(int x);
79 // this set the status bar's progress to x
81 QString getStatus();
82 // this gets the current status string on the status bar
84 // void setMode(int newmode, pkgInterface *type, int refresh);
85 // This sets the mode to newmode and updates the display accordingly.
87 void setup();
89 pkgInterface *pkType(const QString &fname);
90 // find type of package
92 void openNetFiles(const QStringList &urls, bool install=true);
93 void openNetFile(const KUrl & url, bool install=true);
94 // open a file given a URL
96 QString fetchNetFile(const KUrl & url);
97 // fetch a file given a URL
99 static QString getFileName(const KUrl & url, QString &cacheName);
100 // return file name, if not local file cachename is name for cache entry
102 static bool isFileLocal( const KUrl & url );
103 // true if URL refers to local or cached file
105 protected:
106 void resizeEvent(QResizeEvent *re);
107 // This is called when the widget is resized
109 void dropEvent(QDropEvent *);
110 // This is called when a URL has been dropped in the drop zone
112 void dragEnterEvent(QDragEnterEvent* e);
114 private:
116 void setupModeWidgets();
117 // This sets up the mode widgets (ie management/installation widgets)
119 void setupStatusBar();
120 // This sets up the status bar
122 void arrangeWidgets();
123 // This arranges the widgets in the window (should be called after a
124 // resize event)
126 KFileDialog* getFileDialog(const QString &captiontext);
128 ///////////// SLOTS --------------------------------------------------------
129 public slots:
131 // void modeFinished(int mode, pkgInterface *interface, int refresh);
132 // This is called when the mode `mode' has finished. KPACKAGE should
133 // then change modes appropriately
135 void fileOpen();
136 // This is called when File->Open is selected from the menu
138 void clearMarked();
139 // clear package Marks
141 void markAll();
142 // mark all packages in the selected view
144 void expandTree();
145 void collapseTree();
146 // expand and collapse file tree
148 void fileOpenUrl();
149 // menu item FIle->OpenUrl
151 void find();
152 // search for package
154 void findf();
155 // search for file in package
157 void fileQuit();
158 // This is called when File->Quit is selected from the menu
160 void reload();
161 // reload file package information
163 ///////////// SIGNALS ------------------------------------------------------
165 ///////////// DATA ---------------------------------------------------------
166 public:
168 enum { Management, Installation } ;
169 // Widget modes
171 KSharedConfigPtr config;
172 // pointer to kconfig object
174 managementWidget *management;
175 // management widget
177 KUrl save_url;
178 // save the URL entered
180 FindF *findialog;
181 // find file dialog
183 QString displayMsg;
185 private:
186 int mode;
187 // Widget mode
189 // Menu item identifiers
191 QFrame *statusbar;
192 // the status bar
194 QProgressBar *processProgress;
195 // Progress bar for showing progress
197 QLabel *status;
198 // The actual status
200 KFileDialog *file_dialog;
201 /// If we load a file from the net this is the corresponding URL
203 Search *srchdialog;
204 // find package dialog
209 //////////////////////////////////////////////////////////////////////////////
210 extern KPKG *kpkg;
212 extern KPACKAGE *kpackage;
213 extern kpPty *kpty;
214 extern kpRun *kprun;
215 extern kpRun *kpstart;
217 extern QString hostName;
219 extern pkgInterface *kpinterface[];
221 void KpMsg(const QString &lab, const QString &msg, bool stop);
222 void KpMsgE(const QString &msg, bool stop = false);
223 #endif