2 ** Copyright (C) 2007 Toivo Pedaste <toivo@ucs.uwa.edu.au>
4 ** This is the main widget for kpackage
5 ** The whole widget is a DND drop zone where users can drop packages to
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
35 #include <kxmlguiwindow.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>
53 class managementWidget
;
56 //////////////////////////////////////////////////////////////////////////////
58 #define kpinterfaceN 3
60 enum {UPACKAGE
= 0, DEBt
, RPMt
, SLACKt
};
62 //////////////////////////////////////////////////////////////////////////////
63 class KPACKAGE
: public QWidget
67 ///////////// METHODS ------------------------------------------------------
69 KPACKAGE(const KSharedConfigPtr
&_config
, QWidget
*parent
);
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
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.
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
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
);
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
126 KFileDialog
* getFileDialog(const QString
&captiontext
);
128 ///////////// 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
136 // This is called when File->Open is selected from the menu
139 // clear package Marks
142 // mark all packages in the selected view
146 // expand and collapse file tree
149 // menu item FIle->OpenUrl
152 // search for package
155 // search for file in package
158 // This is called when File->Quit is selected from the menu
161 // reload file package information
163 ///////////// SIGNALS ------------------------------------------------------
165 ///////////// DATA ---------------------------------------------------------
168 enum { Management
, Installation
} ;
171 KSharedConfigPtr config
;
172 // pointer to kconfig object
174 managementWidget
*management
;
178 // save the URL entered
189 // Menu item identifiers
194 QProgressBar
*processProgress
;
195 // Progress bar for showing progress
200 KFileDialog
*file_dialog
;
201 /// If we load a file from the net this is the corresponding URL
204 // find package dialog
209 //////////////////////////////////////////////////////////////////////////////
212 extern KPACKAGE
*kpackage
;
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);