-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 92 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.h | 3 |
2 files changed, 65 insertions, 30 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index ae073ef..a25f5a7 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,1160 +1,1192 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | mainwin.cpp - description | 2 | mainwin.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 13:32:30 BST 2002 | 4 | begin : Mon Aug 26 13:32:30 BST 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include <linux/limits.h> | 18 | #include <linux/limits.h> |
19 | #include <unistd.h> | 19 | #include <unistd.h> |
20 | 20 | ||
21 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
22 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | 27 | ||
28 | #include <qaction.h> | 28 | #include <qaction.h> |
29 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | #include <qmenubar.h> | 35 | #include <qmenubar.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | #include <qwhatsthis.h> | 40 | #include <qwhatsthis.h> |
41 | #include <qwidgetstack.h> | 41 | #include <qwidgetstack.h> |
42 | 42 | ||
43 | #include "categoryfilterimpl.h" | 43 | #include "categoryfilterimpl.h" |
44 | #include "datamgr.h" | 44 | #include "datamgr.h" |
45 | #include "global.h" | 45 | #include "global.h" |
46 | #include "helpwindow.h" | 46 | #include "helpwindow.h" |
47 | #include "inputdlg.h" | 47 | #include "inputdlg.h" |
48 | #include "installdlgimpl.h" | 48 | #include "installdlgimpl.h" |
49 | #include "letterpushbutton.h" | 49 | #include "letterpushbutton.h" |
50 | #include "mainwin.h" | 50 | #include "mainwin.h" |
51 | #include "settingsimpl.h" | 51 | #include "settingsimpl.h" |
52 | #include "utils.h" | 52 | #include "utils.h" |
53 | 53 | ||
54 | extern int compareVersions( const char *v1, const char *v2 ); | 54 | extern int compareVersions( const char *v1, const char *v2 ); |
55 | 55 | ||
56 | MainWindow :: MainWindow() | 56 | MainWindow :: MainWindow() |
57 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 57 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) |
58 | { | 58 | { |
59 | setCaption( tr( "AQPkg - Package Manager" ) ); | 59 | setCaption( tr( "AQPkg - Package Manager" ) ); |
60 | 60 | ||
61 | #ifdef QWS | ||
62 | // read download directory from config file | ||
63 | Config cfg( "aqpkg" ); | ||
64 | cfg.setGroup( "settings" ); | ||
65 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | ||
66 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | ||
67 | |||
68 | #endif | ||
69 | |||
70 | // Create UI widgets | 61 | // Create UI widgets |
71 | initMainWidget(); | 62 | initMainWidget(); |
72 | initProgressWidget(); | 63 | initProgressWidget(); |
73 | 64 | ||
74 | // Build menu and tool bars | 65 | // Build menu and tool bars |
75 | setToolBarsMovable( FALSE ); | 66 | setToolBarsMovable( FALSE ); |
76 | 67 | ||
77 | QPEToolBar *bar = new QPEToolBar( this ); | 68 | QPEToolBar *bar = new QPEToolBar( this ); |
78 | bar->setHorizontalStretchable( TRUE ); | 69 | bar->setHorizontalStretchable( TRUE ); |
79 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 70 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
80 | mb->setMargin( 0 ); | 71 | mb->setMargin( 0 ); |
81 | bar = new QPEToolBar( this ); | 72 | bar = new QPEToolBar( this ); |
82 | 73 | ||
83 | // Find toolbar | 74 | // Find toolbar |
84 | findBar = new QPEToolBar( this ); | 75 | findBar = new QPEToolBar( this ); |
85 | addToolBar( findBar, QMainWindow::Top, true ); | 76 | addToolBar( findBar, QMainWindow::Top, true ); |
86 | findBar->setHorizontalStretchable( true ); | 77 | findBar->setHorizontalStretchable( true ); |
87 | findEdit = new QLineEdit( findBar ); | 78 | findEdit = new QLineEdit( findBar ); |
88 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); | 79 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); |
89 | findBar->setStretchableWidget( findEdit ); | 80 | findBar->setStretchableWidget( findEdit ); |
90 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); | 81 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); |
82 | |||
83 | // Quick jump toolbar | ||
84 | jumpBar = new QPEToolBar( this ); | ||
85 | addToolBar( jumpBar, QMainWindow::Top, true ); | ||
86 | jumpBar->setHorizontalStretchable( true ); | ||
87 | QWidget *w = new QWidget( jumpBar ); | ||
88 | jumpBar->setStretchableWidget( w ); | ||
91 | 89 | ||
90 | QGridLayout *layout = new QGridLayout( w ); | ||
91 | //QVBoxLayout *vbox = new QVBoxLayout( w, 0, -1 ); | ||
92 | //QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); | ||
93 | //QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); | ||
94 | |||
95 | char text[2]; | ||
96 | text[1] = '\0'; | ||
97 | for ( int i = 0 ; i < 26 ; ++i ) | ||
98 | { | ||
99 | text[0] = 'A' + i; | ||
100 | LetterPushButton *b = new LetterPushButton( text, w ); | ||
101 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | ||
102 | layout->addWidget( b, i / 13, i % 13); | ||
103 | /* | ||
104 | if ( i < 13 ) | ||
105 | hbox3->addWidget( b ); | ||
106 | else | ||
107 | hbox4->addWidget( b ); | ||
108 | */ | ||
109 | } | ||
110 | |||
111 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); | ||
112 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); | ||
113 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); | ||
114 | a->addTo( jumpBar ); | ||
115 | jumpBar->hide(); | ||
116 | |||
92 | // Packages menu | 117 | // Packages menu |
93 | QPopupMenu *popup = new QPopupMenu( this ); | 118 | QPopupMenu *popup = new QPopupMenu( this ); |
94 | 119 | ||
95 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | 120 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); |
96 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 121 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
97 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); | 122 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); |
98 | a->addTo( popup ); | 123 | a->addTo( popup ); |
99 | a->addTo( bar ); | 124 | a->addTo( bar ); |
100 | 125 | ||
101 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | 126 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); |
102 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 127 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
103 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); | 128 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); |
104 | actionUpgrade->addTo( popup ); | 129 | actionUpgrade->addTo( popup ); |
105 | actionUpgrade->addTo( bar ); | 130 | actionUpgrade->addTo( bar ); |
106 | 131 | ||
107 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | 132 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); |
108 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | 133 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); |
109 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 134 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
110 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 135 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
111 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); | 136 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); |
112 | actionDownload->addTo( popup ); | 137 | actionDownload->addTo( popup ); |
113 | actionDownload->addTo( bar ); | 138 | actionDownload->addTo( bar ); |
114 | 139 | ||
115 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | 140 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); |
116 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 141 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
117 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); | 142 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); |
118 | a->addTo( popup ); | 143 | a->addTo( popup ); |
119 | a->addTo( bar ); | 144 | a->addTo( bar ); |
120 | 145 | ||
121 | mb->insertItem( tr( "Actions" ), popup ); | 146 | mb->insertItem( tr( "Actions" ), popup ); |
122 | 147 | ||
123 | // View menu | 148 | // View menu |
124 | popup = new QPopupMenu( this ); | 149 | popup = new QPopupMenu( this ); |
125 | 150 | ||
126 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 151 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
127 | actionUninstalled->setToggleAction( TRUE ); | 152 | actionUninstalled->setToggleAction( TRUE ); |
128 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 153 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
129 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | 154 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); |
130 | actionUninstalled->addTo( popup ); | 155 | actionUninstalled->addTo( popup ); |
131 | 156 | ||
132 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 157 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
133 | actionInstalled->setToggleAction( TRUE ); | 158 | actionInstalled->setToggleAction( TRUE ); |
134 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 159 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
135 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | 160 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); |
136 | actionInstalled->addTo( popup ); | 161 | actionInstalled->addTo( popup ); |
137 | 162 | ||
138 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 163 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
139 | actionUpdated->setToggleAction( TRUE ); | 164 | actionUpdated->setToggleAction( TRUE ); |
140 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 165 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); |
141 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); | 166 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); |
142 | actionUpdated->addTo( popup ); | 167 | actionUpdated->addTo( popup ); |
143 | 168 | ||
144 | popup->insertSeparator(); | 169 | popup->insertSeparator(); |
145 | 170 | ||
146 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); | 171 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); |
147 | actionFilter->setToggleAction( TRUE ); | 172 | actionFilter->setToggleAction( TRUE ); |
148 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); | 173 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); |
149 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | 174 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); |
150 | actionFilter->addTo( popup ); | 175 | actionFilter->addTo( popup ); |
151 | 176 | ||
152 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); | 177 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); |
153 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); | 178 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); |
154 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | 179 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); |
155 | a->addTo( popup ); | 180 | a->addTo( popup ); |
156 | 181 | ||
157 | popup->insertSeparator(); | 182 | popup->insertSeparator(); |
158 | 183 | ||
159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 184 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
160 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); | 185 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
161 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); | 186 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); |
162 | a->addTo( popup ); | 187 | a->addTo( popup ); |
163 | 188 | ||
164 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 189 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
165 | actionFindNext->setEnabled( FALSE ); | 190 | actionFindNext->setEnabled( FALSE ); |
166 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 191 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); |
167 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); | 192 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); |
168 | actionFindNext->addTo( popup ); | 193 | actionFindNext->addTo( popup ); |
169 | actionFindNext->addTo( findBar ); | 194 | actionFindNext->addTo( findBar ); |
170 | 195 | ||
196 | |||
197 | popup->insertSeparator(); | ||
198 | |||
199 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); | ||
200 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); | ||
201 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); | ||
202 | a->addTo( popup ); | ||
203 | |||
171 | mb->insertItem( tr( "View" ), popup ); | 204 | mb->insertItem( tr( "View" ), popup ); |
172 | 205 | ||
173 | 206 | ||
174 | // Options menu | 207 | // Options menu |
175 | popup = new QPopupMenu( this ); | 208 | popup = new QPopupMenu( this ); |
176 | 209 | ||
177 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 ); | 210 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 ); |
178 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 211 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
179 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | 212 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); |
180 | a->addTo( popup ); | 213 | a->addTo( popup ); |
181 | 214 | ||
182 | popup->insertSeparator(); | 215 | popup->insertSeparator(); |
183 | 216 | ||
184 | a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 ); | 217 | a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 ); |
185 | a->setWhatsThis( tr( "Click here for help." ) ); | 218 | a->setWhatsThis( tr( "Click here for help." ) ); |
186 | connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) ); | 219 | connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) ); |
187 | a->addTo( popup ); | 220 | a->addTo( popup ); |
188 | 221 | ||
189 | a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 ); | 222 | a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 ); |
190 | a->setWhatsThis( tr( "Click here for software version information." ) ); | 223 | a->setWhatsThis( tr( "Click here for software version information." ) ); |
191 | connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) ); | 224 | connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) ); |
192 | a->addTo( popup ); | 225 | a->addTo( popup ); |
193 | 226 | ||
194 | mb->insertItem( tr( "Options" ), popup ); | 227 | mb->insertItem( tr( "Options" ), popup ); |
195 | 228 | ||
196 | // Finish find toolbar creation | 229 | // Finish find toolbar creation |
197 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 230 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
198 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 231 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
199 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 232 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
200 | a->addTo( findBar ); | 233 | a->addTo( findBar ); |
201 | findBar->hide(); | 234 | findBar->hide(); |
202 | 235 | ||
203 | // Create widget stack and add UI widgets | 236 | // Create widget stack and add UI widgets |
204 | stack = new QWidgetStack( this ); | 237 | stack = new QWidgetStack( this ); |
205 | stack->addWidget( progressWindow, 2 ); | 238 | stack->addWidget( progressWindow, 2 ); |
206 | stack->addWidget( networkPkgWindow, 1 ); | 239 | stack->addWidget( networkPkgWindow, 1 ); |
207 | setCentralWidget( stack ); | 240 | setCentralWidget( stack ); |
208 | stack->raiseWidget( progressWindow ); | 241 | stack->raiseWidget( progressWindow ); |
209 | 242 | ||
210 | // Delayed call to finish initialization | 243 | // Delayed call to finish initialization |
211 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 244 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
212 | } | 245 | } |
213 | 246 | ||
214 | MainWindow :: ~MainWindow() | 247 | MainWindow :: ~MainWindow() |
215 | { | 248 | { |
216 | delete mgr; | 249 | delete mgr; |
217 | } | 250 | } |
218 | 251 | ||
219 | void MainWindow :: initMainWidget() | 252 | void MainWindow :: initMainWidget() |
220 | { | 253 | { |
221 | networkPkgWindow = new QWidget( this ); | 254 | networkPkgWindow = new QWidget( this ); |
222 | 255 | ||
223 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 256 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
224 | 257 | ||
225 | serversList = new QComboBox( networkPkgWindow ); | 258 | serversList = new QComboBox( networkPkgWindow ); |
226 | connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); | 259 | connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); |
227 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 260 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
228 | 261 | ||
229 | installedIcon = Resource::loadPixmap( "aqpkg/installed" ); | 262 | installedIcon = Resource::loadPixmap( "aqpkg/installed" ); |
230 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 263 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); |
231 | 264 | ||
232 | packagesList = new QListView( networkPkgWindow ); | 265 | packagesList = new QListView( networkPkgWindow ); |
233 | packagesList->addColumn( tr( "Packages" ), 225 ); | 266 | packagesList->addColumn( tr( "Packages" ), 225 ); |
234 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | 267 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); |
235 | 268 | ||
236 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 269 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
237 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 270 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
238 | hbox1->addWidget( l ); | 271 | hbox1->addWidget( l ); |
239 | hbox1->addWidget( serversList ); | 272 | hbox1->addWidget( serversList ); |
240 | |||
241 | |||
242 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); | ||
243 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); | ||
244 | |||
245 | if ( showJumpTo ) | ||
246 | { | ||
247 | char text[2]; | ||
248 | text[1] = '\0'; | ||
249 | for ( int i = 0 ; i < 26 ; ++i ) | ||
250 | { | ||
251 | text[0] = 'A' + i; | ||
252 | LetterPushButton *b = new LetterPushButton( text, networkPkgWindow ); | ||
253 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | ||
254 | if ( i < 13 ) | ||
255 | hbox3->addWidget( b ); | ||
256 | else | ||
257 | hbox4->addWidget( b ); | ||
258 | } | ||
259 | } | ||
260 | 273 | ||
261 | vbox->addWidget( packagesList ); | 274 | vbox->addWidget( packagesList ); |
262 | 275 | ||
263 | downloadEnabled = TRUE; | 276 | downloadEnabled = TRUE; |
264 | } | 277 | } |
265 | 278 | ||
266 | void MainWindow :: initProgressWidget() | 279 | void MainWindow :: initProgressWidget() |
267 | { | 280 | { |
268 | progressWindow = new QWidget( this ); | 281 | progressWindow = new QWidget( this ); |
269 | 282 | ||
270 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | 283 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); |
271 | 284 | ||
272 | m_status = new QLabel( progressWindow ); | 285 | m_status = new QLabel( progressWindow ); |
273 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 286 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
274 | layout->addWidget( m_status ); | 287 | layout->addWidget( m_status ); |
275 | 288 | ||
276 | m_progress = new QProgressBar( progressWindow ); | 289 | m_progress = new QProgressBar( progressWindow ); |
277 | layout->addWidget( m_progress ); | 290 | layout->addWidget( m_progress ); |
278 | } | 291 | } |
279 | 292 | ||
280 | void MainWindow :: init() | 293 | void MainWindow :: init() |
281 | { | 294 | { |
295 | #ifdef QWS | ||
296 | // read download directory from config file | ||
297 | Config cfg( "aqpkg" ); | ||
298 | cfg.setGroup( "settings" ); | ||
299 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | ||
300 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | ||
301 | |||
302 | #endif | ||
303 | |||
282 | stack->raiseWidget( progressWindow ); | 304 | stack->raiseWidget( progressWindow ); |
283 | 305 | ||
284 | mgr = new DataManager(); | 306 | mgr = new DataManager(); |
285 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); | 307 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); |
286 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 308 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), |
287 | this, SLOT( setProgressMessage( const QString & ) ) ); | 309 | this, SLOT( setProgressMessage( const QString & ) ) ); |
288 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); | 310 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); |
289 | mgr->loadServers(); | 311 | mgr->loadServers(); |
290 | 312 | ||
291 | showUninstalledPkgs = false; | 313 | showUninstalledPkgs = false; |
292 | showInstalledPkgs = false; | 314 | showInstalledPkgs = false; |
293 | showUpgradedPkgs = false; | 315 | showUpgradedPkgs = false; |
294 | categoryFilterEnabled = false; | 316 | categoryFilterEnabled = false; |
295 | 317 | ||
296 | updateData(); | 318 | updateData(); |
297 | 319 | ||
298 | stack->raiseWidget( networkPkgWindow ); | 320 | stack->raiseWidget( networkPkgWindow ); |
299 | } | 321 | } |
300 | /* | 322 | /* |
301 | void MainWindow :: setDocument( const QString &doc ) | 323 | void MainWindow :: setDocument( const QString &doc ) |
302 | { | 324 | { |
303 | // Remove path from package | 325 | // Remove path from package |
304 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 326 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
305 | // std::cout << "Selecting package " << package << std::endl; | 327 | // std::cout << "Selecting package " << package << std::endl; |
306 | 328 | ||
307 | // First select local server | 329 | // First select local server |
308 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 330 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
309 | { | 331 | { |
310 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 332 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
311 | { | 333 | { |
312 | serversList->setCurrentItem( i ); | 334 | serversList->setCurrentItem( i ); |
313 | break; | 335 | break; |
314 | } | 336 | } |
315 | } | 337 | } |
316 | serverSelected( 0 ); | 338 | serverSelected( 0 ); |
317 | 339 | ||
318 | // Now set the check box of the selected package | 340 | // Now set the check box of the selected package |
319 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 341 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
320 | item != 0 ; | 342 | item != 0 ; |
321 | item = (QCheckListItem *)item->nextSibling() ) | 343 | item = (QCheckListItem *)item->nextSibling() ) |
322 | { | 344 | { |
323 | if ( item->text().startsWith( package ) ) | 345 | if ( item->text().startsWith( package ) ) |
324 | { | 346 | { |
325 | item->setOn( true ); | 347 | item->setOn( true ); |
326 | break; | 348 | break; |
327 | } | 349 | } |
328 | } | 350 | } |
329 | } | 351 | } |
330 | */ | 352 | */ |
331 | void MainWindow :: displaySettings() | 353 | void MainWindow :: displaySettings() |
332 | { | 354 | { |
333 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 355 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
334 | if ( dlg->showDlg( 0 ) ) | 356 | if ( dlg->showDlg( 0 ) ) |
335 | { | 357 | { |
336 | stack->raiseWidget( progressWindow ); | 358 | stack->raiseWidget( progressWindow ); |
337 | updateData(); | 359 | updateData(); |
338 | stack->raiseWidget( networkPkgWindow ); | 360 | stack->raiseWidget( networkPkgWindow ); |
339 | } | 361 | } |
340 | delete dlg; | 362 | delete dlg; |
341 | } | 363 | } |
342 | 364 | ||
343 | void MainWindow :: displayHelp() | 365 | void MainWindow :: displayHelp() |
344 | { | 366 | { |
345 | HelpWindow *dlg = new HelpWindow( this ); | 367 | HelpWindow *dlg = new HelpWindow( this ); |
346 | dlg->exec(); | 368 | dlg->exec(); |
347 | delete dlg; | 369 | delete dlg; |
348 | } | 370 | } |
349 | 371 | ||
350 | void MainWindow :: displayFindBar() | 372 | void MainWindow :: displayFindBar() |
351 | { | 373 | { |
352 | findBar->show(); | 374 | findBar->show(); |
353 | findEdit->setFocus(); | 375 | findEdit->setFocus(); |
354 | } | 376 | } |
355 | 377 | ||
378 | void MainWindow :: displayJumpBar() | ||
379 | { | ||
380 | jumpBar->show(); | ||
381 | } | ||
382 | |||
356 | void MainWindow :: repeatFind() | 383 | void MainWindow :: repeatFind() |
357 | { | 384 | { |
358 | searchForPackage( findEdit->text() ); | 385 | searchForPackage( findEdit->text() ); |
359 | } | 386 | } |
360 | 387 | ||
361 | void MainWindow :: findPackage( const QString &text ) | 388 | void MainWindow :: findPackage( const QString &text ) |
362 | { | 389 | { |
363 | actionFindNext->setEnabled( !text.isEmpty() ); | 390 | actionFindNext->setEnabled( !text.isEmpty() ); |
364 | searchForPackage( text ); | 391 | searchForPackage( text ); |
365 | } | 392 | } |
366 | 393 | ||
367 | void MainWindow :: hideFindBar() | 394 | void MainWindow :: hideFindBar() |
368 | { | 395 | { |
369 | findBar->hide(); | 396 | findBar->hide(); |
370 | } | 397 | } |
371 | 398 | ||
399 | void MainWindow :: hideJumpBar() | ||
400 | { | ||
401 | jumpBar->hide(); | ||
402 | } | ||
403 | |||
372 | void MainWindow :: displayAbout() | 404 | void MainWindow :: displayAbout() |
373 | { | 405 | { |
374 | QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) ); | 406 | QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) ); |
375 | } | 407 | } |
376 | 408 | ||
377 | void MainWindow :: filterUninstalledPackages() | 409 | void MainWindow :: filterUninstalledPackages() |
378 | { | 410 | { |
379 | showUninstalledPkgs = actionUninstalled->isOn(); | 411 | showUninstalledPkgs = actionUninstalled->isOn(); |
380 | if ( showUninstalledPkgs ) | 412 | if ( showUninstalledPkgs ) |
381 | { | 413 | { |
382 | showInstalledPkgs = FALSE; | 414 | showInstalledPkgs = FALSE; |
383 | showUpgradedPkgs = FALSE; | 415 | showUpgradedPkgs = FALSE; |
384 | } | 416 | } |
385 | serverSelected( -1 ); | 417 | serverSelected( -1 ); |
386 | 418 | ||
387 | actionInstalled->setOn( FALSE ); | 419 | actionInstalled->setOn( FALSE ); |
388 | actionUpdated->setOn( FALSE ); | 420 | actionUpdated->setOn( FALSE ); |
389 | } | 421 | } |
390 | 422 | ||
391 | void MainWindow :: filterInstalledPackages() | 423 | void MainWindow :: filterInstalledPackages() |
392 | { | 424 | { |
393 | showInstalledPkgs = actionInstalled->isOn(); | 425 | showInstalledPkgs = actionInstalled->isOn(); |
394 | if ( showInstalledPkgs ) | 426 | if ( showInstalledPkgs ) |
395 | { | 427 | { |
396 | showUninstalledPkgs = FALSE; | 428 | showUninstalledPkgs = FALSE; |
397 | showUpgradedPkgs = FALSE; | 429 | showUpgradedPkgs = FALSE; |
398 | } | 430 | } |
399 | serverSelected( -1 ); | 431 | serverSelected( -1 ); |
400 | 432 | ||
401 | actionUninstalled->setOn( FALSE ); | 433 | actionUninstalled->setOn( FALSE ); |
402 | actionUpdated->setOn( FALSE ); | 434 | actionUpdated->setOn( FALSE ); |
403 | } | 435 | } |
404 | 436 | ||
405 | void MainWindow :: filterUpgradedPackages() | 437 | void MainWindow :: filterUpgradedPackages() |
406 | { | 438 | { |
407 | showUpgradedPkgs = actionUpdated->isOn(); | 439 | showUpgradedPkgs = actionUpdated->isOn(); |
408 | if ( showUpgradedPkgs ) | 440 | if ( showUpgradedPkgs ) |
409 | { | 441 | { |
410 | showUninstalledPkgs = FALSE; | 442 | showUninstalledPkgs = FALSE; |
411 | showInstalledPkgs = FALSE; | 443 | showInstalledPkgs = FALSE; |
412 | } | 444 | } |
413 | serverSelected( -1 ); | 445 | serverSelected( -1 ); |
414 | 446 | ||
415 | actionUninstalled->setOn( FALSE ); | 447 | actionUninstalled->setOn( FALSE ); |
416 | actionInstalled->setOn( FALSE ); | 448 | actionInstalled->setOn( FALSE ); |
417 | } | 449 | } |
418 | 450 | ||
419 | bool MainWindow :: setFilterCategory() | 451 | bool MainWindow :: setFilterCategory() |
420 | { | 452 | { |
421 | // Get categories; | 453 | // Get categories; |
422 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); | 454 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); |
423 | if ( dlg.exec() == QDialog::Accepted ) | 455 | if ( dlg.exec() == QDialog::Accepted ) |
424 | { | 456 | { |
425 | categoryFilter = dlg.getSelectedFilter(); | 457 | categoryFilter = dlg.getSelectedFilter(); |
426 | 458 | ||
427 | if ( categoryFilter == "" ) | 459 | if ( categoryFilter == "" ) |
428 | return false; | 460 | return false; |
429 | 461 | ||
430 | categoryFilterEnabled = true; | 462 | categoryFilterEnabled = true; |
431 | serverSelected( -1 ); | 463 | serverSelected( -1 ); |
432 | actionFilter->setOn( TRUE ); | 464 | actionFilter->setOn( TRUE ); |
433 | return true; | 465 | return true; |
434 | } | 466 | } |
435 | 467 | ||
436 | return false; | 468 | return false; |
437 | } | 469 | } |
438 | 470 | ||
439 | void MainWindow :: filterCategory() | 471 | void MainWindow :: filterCategory() |
440 | { | 472 | { |
441 | if ( !actionFilter->isOn() ) | 473 | if ( !actionFilter->isOn() ) |
442 | { | 474 | { |
443 | filterByCategory( FALSE ); | 475 | filterByCategory( FALSE ); |
444 | } | 476 | } |
445 | else | 477 | else |
446 | { | 478 | { |
447 | actionFilter->setOn( filterByCategory( TRUE ) ); | 479 | actionFilter->setOn( filterByCategory( TRUE ) ); |
448 | } | 480 | } |
449 | } | 481 | } |
450 | 482 | ||
451 | bool MainWindow :: filterByCategory( bool val ) | 483 | bool MainWindow :: filterByCategory( bool val ) |
452 | { | 484 | { |
453 | if ( val ) | 485 | if ( val ) |
454 | { | 486 | { |
455 | if ( categoryFilter == "" ) | 487 | if ( categoryFilter == "" ) |
456 | { | 488 | { |
457 | if ( !setFilterCategory() ) | 489 | if ( !setFilterCategory() ) |
458 | return false; | 490 | return false; |
459 | } | 491 | } |
460 | 492 | ||
461 | categoryFilterEnabled = true; | 493 | categoryFilterEnabled = true; |
462 | serverSelected( -1 ); | 494 | serverSelected( -1 ); |
463 | return true; | 495 | return true; |
464 | } | 496 | } |
465 | else | 497 | else |
466 | { | 498 | { |
467 | // Turn off filter | 499 | // Turn off filter |
468 | categoryFilterEnabled = false; | 500 | categoryFilterEnabled = false; |
469 | serverSelected( -1 ); | 501 | serverSelected( -1 ); |
470 | return false; | 502 | return false; |
471 | } | 503 | } |
472 | } | 504 | } |
473 | 505 | ||
474 | void MainWindow :: raiseMainWidget() | 506 | void MainWindow :: raiseMainWidget() |
475 | { | 507 | { |
476 | stack->raiseWidget( networkPkgWindow ); | 508 | stack->raiseWidget( networkPkgWindow ); |
477 | } | 509 | } |
478 | 510 | ||
479 | void MainWindow :: raiseProgressWidget() | 511 | void MainWindow :: raiseProgressWidget() |
480 | { | 512 | { |
481 | stack->raiseWidget( progressWindow ); | 513 | stack->raiseWidget( progressWindow ); |
482 | } | 514 | } |
483 | 515 | ||
484 | void MainWindow :: enableUpgrade( bool enabled ) | 516 | void MainWindow :: enableUpgrade( bool enabled ) |
485 | { | 517 | { |
486 | actionUpgrade->setEnabled( enabled ); | 518 | actionUpgrade->setEnabled( enabled ); |
487 | } | 519 | } |
488 | 520 | ||
489 | void MainWindow :: enableDownload( bool enabled ) | 521 | void MainWindow :: enableDownload( bool enabled ) |
490 | { | 522 | { |
491 | if ( enabled ) | 523 | if ( enabled ) |
492 | { | 524 | { |
493 | actionDownload->setIconSet( iconDownload ); | 525 | actionDownload->setIconSet( iconDownload ); |
494 | actionDownload->setText( tr( "Download" ) ); | 526 | actionDownload->setText( tr( "Download" ) ); |
495 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 527 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
496 | } | 528 | } |
497 | else | 529 | else |
498 | { | 530 | { |
499 | actionDownload->setIconSet( iconRemove ); | 531 | actionDownload->setIconSet( iconRemove ); |
500 | actionDownload->setText( tr( "Remove" ) ); | 532 | actionDownload->setText( tr( "Remove" ) ); |
501 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 533 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
502 | } | 534 | } |
503 | } | 535 | } |
504 | 536 | ||
505 | void MainWindow :: setProgressSteps( int numsteps ) | 537 | void MainWindow :: setProgressSteps( int numsteps ) |
506 | { | 538 | { |
507 | m_progress->setTotalSteps( numsteps ); | 539 | m_progress->setTotalSteps( numsteps ); |
508 | } | 540 | } |
509 | 541 | ||
510 | void MainWindow :: setProgressMessage( const QString &msg ) | 542 | void MainWindow :: setProgressMessage( const QString &msg ) |
511 | { | 543 | { |
512 | m_status->setText( msg ); | 544 | m_status->setText( msg ); |
513 | } | 545 | } |
514 | 546 | ||
515 | void MainWindow :: updateProgress( int progress ) | 547 | void MainWindow :: updateProgress( int progress ) |
516 | { | 548 | { |
517 | m_progress->setProgress( progress ); | 549 | m_progress->setProgress( progress ); |
518 | } | 550 | } |
519 | 551 | ||
520 | void MainWindow :: updateData() | 552 | void MainWindow :: updateData() |
521 | { | 553 | { |
522 | m_progress->setTotalSteps( mgr->getServerList().size() ); | 554 | m_progress->setTotalSteps( mgr->getServerList().size() ); |
523 | 555 | ||
524 | serversList->clear(); | 556 | serversList->clear(); |
525 | packagesList->clear(); | 557 | packagesList->clear(); |
526 | 558 | ||
527 | vector<Server>::iterator it; | 559 | vector<Server>::iterator it; |
528 | int activeItem = -1; | 560 | int activeItem = -1; |
529 | int i; | 561 | int i; |
530 | QString serverName; | 562 | QString serverName; |
531 | for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i ) | 563 | for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i ) |
532 | { | 564 | { |
533 | serverName = it->getServerName(); | 565 | serverName = it->getServerName(); |
534 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); | 566 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); |
535 | m_progress->setProgress( i ); | 567 | m_progress->setProgress( i ); |
536 | qApp->processEvents(); | 568 | qApp->processEvents(); |
537 | 569 | ||
538 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; | 570 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; |
539 | if ( !it->isServerActive() ) | 571 | if ( !it->isServerActive() ) |
540 | { | 572 | { |
541 | // cout << serverName << " is not active" << endl; | 573 | // cout << serverName << " is not active" << endl; |
542 | i--; | 574 | i--; |
543 | continue; | 575 | continue; |
544 | } | 576 | } |
545 | 577 | ||
546 | serversList->insertItem( serverName ); | 578 | serversList->insertItem( serverName ); |
547 | if ( serverName == currentlySelectedServer ) | 579 | if ( serverName == currentlySelectedServer ) |
548 | activeItem = i; | 580 | activeItem = i; |
549 | } | 581 | } |
550 | 582 | ||
551 | // set selected server to be active server | 583 | // set selected server to be active server |
552 | if ( activeItem != -1 ) | 584 | if ( activeItem != -1 ) |
553 | serversList->setCurrentItem( activeItem ); | 585 | serversList->setCurrentItem( activeItem ); |
554 | serverSelected( 0, FALSE ); | 586 | serverSelected( 0, FALSE ); |
555 | } | 587 | } |
556 | 588 | ||
557 | void MainWindow :: serverSelected( int index ) | 589 | void MainWindow :: serverSelected( int index ) |
558 | { | 590 | { |
559 | serverSelected( index, TRUE ); | 591 | serverSelected( index, TRUE ); |
560 | } | 592 | } |
561 | 593 | ||
562 | void MainWindow :: serverSelected( int, bool raiseProgress ) | 594 | void MainWindow :: serverSelected( int, bool raiseProgress ) |
563 | { | 595 | { |
564 | QPixmap nullIcon( installedIcon.size() ); | 596 | QPixmap nullIcon( installedIcon.size() ); |
565 | nullIcon.fill( colorGroup().base() ); | 597 | nullIcon.fill( colorGroup().base() ); |
566 | 598 | ||
567 | // display packages | 599 | // display packages |
568 | QString serverName = serversList->currentText(); | 600 | QString serverName = serversList->currentText(); |
569 | currentlySelectedServer = serverName; | 601 | currentlySelectedServer = serverName; |
570 | 602 | ||
571 | vector<Server>::iterator s = mgr->getServer( serverName ); | 603 | vector<Server>::iterator s = mgr->getServer( serverName ); |
572 | 604 | ||
573 | vector<Package> &list = s->getPackageList(); | 605 | vector<Package> &list = s->getPackageList(); |
574 | vector<Package>::iterator it; | 606 | vector<Package>::iterator it; |
575 | 607 | ||
576 | // Display progress widget while loading list | 608 | // Display progress widget while loading list |
577 | bool doProgress = ( list.size() > 200 ); | 609 | bool doProgress = ( list.size() > 200 ); |
578 | if ( doProgress ) | 610 | if ( doProgress ) |
579 | { | 611 | { |
580 | if ( raiseProgress ) | 612 | if ( raiseProgress ) |
581 | { | 613 | { |
582 | stack->raiseWidget( progressWindow ); | 614 | stack->raiseWidget( progressWindow ); |
583 | } | 615 | } |
584 | m_progress->setTotalSteps( list.size() ); | 616 | m_progress->setTotalSteps( list.size() ); |
585 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 617 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
586 | } | 618 | } |
587 | 619 | ||
588 | packagesList->clear(); | 620 | packagesList->clear(); |
589 | 621 | ||
590 | #ifdef QWS | 622 | #ifdef QWS |
591 | // read download directory from config file | 623 | // read download directory from config file |
592 | Config cfg( "aqpkg" ); | 624 | Config cfg( "aqpkg" ); |
593 | cfg.setGroup( "settings" ); | 625 | cfg.setGroup( "settings" ); |
594 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 626 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
595 | #endif | 627 | #endif |
596 | 628 | ||
597 | int i = 0; | 629 | int i = 0; |
598 | for ( it = list.begin() ; it != list.end() ; ++it ) | 630 | for ( it = list.begin() ; it != list.end() ; ++it ) |
599 | { | 631 | { |
600 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 632 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
601 | i++; | 633 | i++; |
602 | if ( ( i % 100 ) == 0 ) | 634 | if ( ( i % 100 ) == 0 ) |
603 | { | 635 | { |
604 | if ( doProgress ) | 636 | if ( doProgress ) |
605 | { | 637 | { |
606 | m_progress->setProgress( i ); | 638 | m_progress->setProgress( i ); |
607 | } | 639 | } |
608 | qApp->processEvents(); | 640 | qApp->processEvents(); |
609 | } | 641 | } |
610 | 642 | ||
611 | QString text = ""; | 643 | QString text = ""; |
612 | 644 | ||
613 | // Apply show only uninstalled packages filter | 645 | // Apply show only uninstalled packages filter |
614 | if ( showUninstalledPkgs && it->isInstalled() ) | 646 | if ( showUninstalledPkgs && it->isInstalled() ) |
615 | continue; | 647 | continue; |
616 | 648 | ||
617 | // Apply show only installed packages filter | 649 | // Apply show only installed packages filter |
618 | if ( showInstalledPkgs && !it->isInstalled() ) | 650 | if ( showInstalledPkgs && !it->isInstalled() ) |
619 | continue; | 651 | continue; |
620 | 652 | ||
621 | // Apply show only new installed packages filter | 653 | // Apply show only new installed packages filter |
622 | if ( showUpgradedPkgs ) | 654 | if ( showUpgradedPkgs ) |
623 | { | 655 | { |
624 | if ( !it->isInstalled() || | 656 | if ( !it->isInstalled() || |
625 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) | 657 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) |
626 | continue; | 658 | continue; |
627 | } | 659 | } |
628 | 660 | ||
629 | // Apply the section filter | 661 | // Apply the section filter |
630 | if ( categoryFilterEnabled && categoryFilter != "" ) | 662 | if ( categoryFilterEnabled && categoryFilter != "" ) |
631 | { | 663 | { |
632 | if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) | 664 | if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) |
633 | continue; | 665 | continue; |
634 | } | 666 | } |
635 | 667 | ||
636 | // If the local server, only display installed packages | 668 | // If the local server, only display installed packages |
637 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 669 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) |
638 | continue; | 670 | continue; |
639 | 671 | ||
640 | 672 | ||
641 | QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox ); | 673 | QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox ); |
642 | 674 | ||
643 | if ( it->isInstalled() ) | 675 | if ( it->isInstalled() ) |
644 | { | 676 | { |
645 | // If a different version of package is available, show update available icon | 677 | // If a different version of package is available, show update available icon |
646 | // Otherwise, show installed icon | 678 | // Otherwise, show installed icon |
647 | if ( it->getVersion() != it->getInstalledVersion() && | 679 | if ( it->getVersion() != it->getInstalledVersion() && |
648 | compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1) | 680 | compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1) |
649 | { | 681 | { |
650 | 682 | ||
651 | item->setPixmap( 0, updatedIcon ); | 683 | item->setPixmap( 0, updatedIcon ); |
652 | } | 684 | } |
653 | else | 685 | else |
654 | { | 686 | { |
655 | item->setPixmap( 0, installedIcon ); | 687 | item->setPixmap( 0, installedIcon ); |
656 | } | 688 | } |
657 | 689 | ||
658 | QString destName = ""; | 690 | QString destName = ""; |
659 | if ( it->getLocalPackage() ) | 691 | if ( it->getLocalPackage() ) |
660 | { | 692 | { |
661 | if ( it->getLocalPackage()->getInstalledTo() ) | 693 | if ( it->getLocalPackage()->getInstalledTo() ) |
662 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | 694 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); |
663 | } | 695 | } |
664 | else | 696 | else |
665 | { | 697 | { |
666 | if ( it->getInstalledTo() ) | 698 | if ( it->getInstalledTo() ) |
667 | destName = it->getInstalledTo()->getDestinationName(); | 699 | destName = it->getInstalledTo()->getDestinationName(); |
668 | } | 700 | } |
669 | if ( destName != "" ) | 701 | if ( destName != "" ) |
670 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); | 702 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); |
671 | } | 703 | } |
672 | else | 704 | else |
673 | { | 705 | { |
674 | item->setPixmap( 0, nullIcon ); | 706 | item->setPixmap( 0, nullIcon ); |
675 | } | 707 | } |
676 | 708 | ||
677 | if ( !it->isPackageStoredLocally() ) | 709 | if ( !it->isPackageStoredLocally() ) |
678 | { | 710 | { |
679 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); | 711 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); |
680 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); | 712 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); |
681 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); | 713 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); |
682 | } | 714 | } |
683 | else | 715 | else |
684 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) ); | 716 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) ); |
685 | 717 | ||
686 | if ( serverName == LOCAL_SERVER ) | 718 | if ( serverName == LOCAL_SERVER ) |
687 | { | 719 | { |
688 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) ); | 720 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) ); |
689 | } | 721 | } |
690 | else | 722 | else |
691 | { | 723 | { |
692 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) ); | 724 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) ); |
693 | if ( it->getLocalPackage() ) | 725 | if ( it->getLocalPackage() ) |
694 | { | 726 | { |
695 | if ( it->isInstalled() ) | 727 | if ( it->isInstalled() ) |
696 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) ); | 728 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) ); |
697 | } | 729 | } |
698 | } | 730 | } |
699 | 731 | ||
700 | packagesList->insertItem( item ); | 732 | packagesList->insertItem( item ); |
701 | } | 733 | } |
702 | 734 | ||
703 | // If the local server or the local ipkgs server disable the download button | 735 | // If the local server or the local ipkgs server disable the download button |
704 | if ( serverName == LOCAL_SERVER ) | 736 | if ( serverName == LOCAL_SERVER ) |
705 | { | 737 | { |
706 | downloadEnabled = TRUE; | 738 | downloadEnabled = TRUE; |
707 | actionUpgrade->setEnabled( FALSE ); | 739 | actionUpgrade->setEnabled( FALSE ); |
708 | } | 740 | } |
709 | else if ( serverName == LOCAL_IPKGS ) | 741 | else if ( serverName == LOCAL_IPKGS ) |
710 | { | 742 | { |
711 | downloadEnabled = FALSE; | 743 | downloadEnabled = FALSE; |
712 | actionUpgrade->setEnabled( FALSE ); | 744 | actionUpgrade->setEnabled( FALSE ); |
713 | } | 745 | } |
714 | else | 746 | else |
715 | { | 747 | { |
716 | downloadEnabled = TRUE; | 748 | downloadEnabled = TRUE; |
717 | actionUpgrade->setEnabled( TRUE ); | 749 | actionUpgrade->setEnabled( TRUE ); |
718 | } | 750 | } |
719 | enableDownload( downloadEnabled ); | 751 | enableDownload( downloadEnabled ); |
720 | 752 | ||
721 | // Display this widget once everything is done | 753 | // Display this widget once everything is done |
722 | if ( doProgress && raiseProgress ) | 754 | if ( doProgress && raiseProgress ) |
723 | { | 755 | { |
724 | stack->raiseWidget( networkPkgWindow ); | 756 | stack->raiseWidget( networkPkgWindow ); |
725 | } | 757 | } |
726 | } | 758 | } |
727 | 759 | ||
728 | void MainWindow :: searchForPackage( const QString &text ) | 760 | void MainWindow :: searchForPackage( const QString &text ) |
729 | { | 761 | { |
730 | if ( !text.isEmpty() ) | 762 | if ( !text.isEmpty() ) |
731 | { | 763 | { |
732 | // cout << "searching for " << text << endl; | 764 | // cout << "searching for " << text << endl; |
733 | // look through package list for text startng at current position | 765 | // look through package list for text startng at current position |
734 | vector<InstallData> workingPackages; | 766 | vector<InstallData> workingPackages; |
735 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 767 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
736 | // if ( start != 0 ) | 768 | // if ( start != 0 ) |
737 | // start = (QCheckListItem *)start->nextSibling(); | 769 | // start = (QCheckListItem *)start->nextSibling(); |
738 | 770 | ||
739 | if ( start == 0 ) | 771 | if ( start == 0 ) |
740 | start = (QCheckListItem *)packagesList->firstChild(); | 772 | start = (QCheckListItem *)packagesList->firstChild(); |
741 | 773 | ||
742 | for ( QCheckListItem *item = start; item != 0 ; | 774 | for ( QCheckListItem *item = start; item != 0 ; |
743 | item = (QCheckListItem *)item->nextSibling() ) | 775 | item = (QCheckListItem *)item->nextSibling() ) |
744 | { | 776 | { |
745 | // cout << "checking " << item->text().lower() << endl; | 777 | // cout << "checking " << item->text().lower() << endl; |
746 | if ( item->text().lower().find( text ) != -1 ) | 778 | if ( item->text().lower().find( text ) != -1 ) |
747 | { | 779 | { |
748 | // cout << "matched " << item->text() << endl; | 780 | // cout << "matched " << item->text() << endl; |
749 | packagesList->ensureItemVisible( item ); | 781 | packagesList->ensureItemVisible( item ); |
750 | packagesList->setCurrentItem( item ); | 782 | packagesList->setCurrentItem( item ); |
751 | break; | 783 | break; |
752 | } | 784 | } |
753 | } | 785 | } |
754 | } | 786 | } |
755 | } | 787 | } |
756 | 788 | ||
757 | void MainWindow :: updateServer() | 789 | void MainWindow :: updateServer() |
758 | { | 790 | { |
759 | QString serverName = serversList->currentText(); | 791 | QString serverName = serversList->currentText(); |
760 | 792 | ||
761 | // Update the current server | 793 | // Update the current server |
762 | // Display dialog | 794 | // Display dialog |
763 | 795 | ||
764 | // Disable buttons to stop silly people clicking lots on them :) | 796 | // Disable buttons to stop silly people clicking lots on them :) |
765 | 797 | ||
766 | // First, write out ipkg_conf file so that ipkg can use it | 798 | // First, write out ipkg_conf file so that ipkg can use it |
767 | mgr->writeOutIpkgConf(); | 799 | mgr->writeOutIpkgConf(); |
768 | 800 | ||
769 | Ipkg ipkg; | 801 | Ipkg ipkg; |
770 | ipkg.setOption( "update" ); | 802 | ipkg.setOption( "update" ); |
771 | 803 | ||
772 | InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true ); | 804 | InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true ); |
773 | dlg.showDlg(); | 805 | dlg.showDlg(); |
774 | 806 | ||
775 | reloadData(); | 807 | reloadData(); |
776 | 808 | ||
777 | // delete progDlg; | 809 | // delete progDlg; |
778 | } | 810 | } |
779 | 811 | ||
780 | void MainWindow :: upgradePackages() | 812 | void MainWindow :: upgradePackages() |
781 | { | 813 | { |
782 | // We're gonna do an upgrade of all packages | 814 | // We're gonna do an upgrade of all packages |
783 | // First warn user that this isn't recommended | 815 | // First warn user that this isn't recommended |
784 | // TODO - ODevice???? | 816 | // TODO - ODevice???? |
785 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); | 817 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); |
786 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, | 818 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, |
787 | QMessageBox::Yes, | 819 | QMessageBox::Yes, |
788 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 820 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
789 | 0, this ); | 821 | 0, this ); |
790 | warn.adjustSize(); | 822 | warn.adjustSize(); |
791 | 823 | ||
792 | if ( warn.exec() == QMessageBox::Yes ) | 824 | if ( warn.exec() == QMessageBox::Yes ) |
793 | { | 825 | { |
794 | // First, write out ipkg_conf file so that ipkg can use it | 826 | // First, write out ipkg_conf file so that ipkg can use it |
795 | mgr->writeOutIpkgConf(); | 827 | mgr->writeOutIpkgConf(); |
796 | 828 | ||
797 | // Now run upgrade | 829 | // Now run upgrade |
798 | Ipkg ipkg; | 830 | Ipkg ipkg; |
799 | ipkg.setOption( "upgrade" ); | 831 | ipkg.setOption( "upgrade" ); |
800 | 832 | ||
801 | InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true ); | 833 | InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true ); |
802 | dlg.showDlg(); | 834 | dlg.showDlg(); |
803 | 835 | ||
804 | reloadData(); | 836 | reloadData(); |
805 | } | 837 | } |
806 | } | 838 | } |
807 | void MainWindow :: downloadPackage() | 839 | void MainWindow :: downloadPackage() |
808 | { | 840 | { |
809 | bool doUpdate = true; | 841 | bool doUpdate = true; |
810 | if ( downloadEnabled ) | 842 | if ( downloadEnabled ) |
811 | { | 843 | { |
812 | // See if any packages are selected | 844 | // See if any packages are selected |
813 | bool found = false; | 845 | bool found = false; |
814 | if ( serversList->currentText() != LOCAL_SERVER ) | 846 | if ( serversList->currentText() != LOCAL_SERVER ) |
815 | { | 847 | { |
816 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 848 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
817 | item != 0 && !found; | 849 | item != 0 && !found; |
818 | item = (QCheckListItem *)item->nextSibling() ) | 850 | item = (QCheckListItem *)item->nextSibling() ) |
819 | { | 851 | { |
820 | if ( item->isOn() ) | 852 | if ( item->isOn() ) |
821 | found = true; | 853 | found = true; |
822 | } | 854 | } |
823 | } | 855 | } |
824 | 856 | ||
825 | // If user selected some packages then download the and store the locally | 857 | // If user selected some packages then download the and store the locally |
826 | // otherwise, display dialog asking user what package to download from an http server | 858 | // otherwise, display dialog asking user what package to download from an http server |
827 | // and whether to install it | 859 | // and whether to install it |
828 | if ( found ) | 860 | if ( found ) |
829 | downloadSelectedPackages(); | 861 | downloadSelectedPackages(); |
830 | else | 862 | else |
831 | downloadRemotePackage(); | 863 | downloadRemotePackage(); |
832 | 864 | ||
833 | } | 865 | } |
834 | else | 866 | else |
835 | { | 867 | { |
836 | doUpdate = false; | 868 | doUpdate = false; |
837 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 869 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
838 | item != 0 ; | 870 | item != 0 ; |
839 | item = (QCheckListItem *)item->nextSibling() ) | 871 | item = (QCheckListItem *)item->nextSibling() ) |
840 | { | 872 | { |
841 | if ( item->isOn() ) | 873 | if ( item->isOn() ) |
842 | { | 874 | { |
843 | QString name = item->text(); | 875 | QString name = item->text(); |
844 | int pos = name.find( "*" ); | 876 | int pos = name.find( "*" ); |
845 | name.truncate( pos ); | 877 | name.truncate( pos ); |
846 | 878 | ||
847 | // if (there is a (installed), remove it | 879 | // if (there is a (installed), remove it |
848 | pos = name.find( "(installed)" ); | 880 | pos = name.find( "(installed)" ); |
849 | if ( pos > 0 ) | 881 | if ( pos > 0 ) |
850 | name.truncate( pos - 1 ); | 882 | name.truncate( pos - 1 ); |
851 | 883 | ||
852 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); | 884 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); |
853 | 885 | ||
854 | QString msgtext; | 886 | QString msgtext; |
855 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); | 887 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); |
856 | if ( QMessageBox::information( this, tr( "Are you sure?" ), | 888 | if ( QMessageBox::information( this, tr( "Are you sure?" ), |
857 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) | 889 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) |
858 | { | 890 | { |
859 | doUpdate = true; | 891 | doUpdate = true; |
860 | QFile f( p->getFilename() ); | 892 | QFile f( p->getFilename() ); |
861 | f.remove(); | 893 | f.remove(); |
862 | } | 894 | } |
863 | } | 895 | } |
864 | } | 896 | } |
865 | } | 897 | } |
866 | 898 | ||
867 | if ( doUpdate ) | 899 | if ( doUpdate ) |
868 | { | 900 | { |
869 | reloadData(); | 901 | reloadData(); |
870 | } | 902 | } |
871 | } | 903 | } |
872 | 904 | ||
873 | void MainWindow :: downloadSelectedPackages() | 905 | void MainWindow :: downloadSelectedPackages() |
874 | { | 906 | { |
875 | // First, write out ipkg_conf file so that ipkg can use it | 907 | // First, write out ipkg_conf file so that ipkg can use it |
876 | mgr->writeOutIpkgConf(); | 908 | mgr->writeOutIpkgConf(); |
877 | 909 | ||
878 | // Display dialog to user asking where to download the files to | 910 | // Display dialog to user asking where to download the files to |
879 | bool ok = FALSE; | 911 | bool ok = FALSE; |
880 | QString dir = ""; | 912 | QString dir = ""; |
881 | #ifdef QWS | 913 | #ifdef QWS |
882 | // read download directory from config file | 914 | // read download directory from config file |
883 | Config cfg( "aqpkg" ); | 915 | Config cfg( "aqpkg" ); |
884 | cfg.setGroup( "settings" ); | 916 | cfg.setGroup( "settings" ); |
885 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 917 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
886 | #endif | 918 | #endif |
887 | 919 | ||
888 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 920 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
889 | if ( ok && !text.isEmpty() ) | 921 | if ( ok && !text.isEmpty() ) |
890 | dir = text; // user entered something and pressed ok | 922 | dir = text; // user entered something and pressed ok |
891 | else | 923 | else |
892 | return; // user entered nothing or pressed cancel | 924 | return; // user entered nothing or pressed cancel |
893 | 925 | ||
894 | #ifdef QWS | 926 | #ifdef QWS |
895 | // Store download directory in config file | 927 | // Store download directory in config file |
896 | cfg.writeEntry( "downloadDir", dir ); | 928 | cfg.writeEntry( "downloadDir", dir ); |
897 | #endif | 929 | #endif |
898 | 930 | ||
899 | // Get starting directory | 931 | // Get starting directory |
900 | char initDir[PATH_MAX]; | 932 | char initDir[PATH_MAX]; |
901 | getcwd( initDir, PATH_MAX ); | 933 | getcwd( initDir, PATH_MAX ); |
902 | 934 | ||
903 | // Download each package | 935 | // Download each package |
904 | Ipkg ipkg; | 936 | Ipkg ipkg; |
905 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 937 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
906 | 938 | ||
907 | ipkg.setOption( "download" ); | 939 | ipkg.setOption( "download" ); |
908 | ipkg.setRuntimeDirectory( dir ); | 940 | ipkg.setRuntimeDirectory( dir ); |
909 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 941 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
910 | item != 0 ; | 942 | item != 0 ; |
911 | item = (QCheckListItem *)item->nextSibling() ) | 943 | item = (QCheckListItem *)item->nextSibling() ) |
912 | { | 944 | { |
913 | if ( item->isOn() ) | 945 | if ( item->isOn() ) |
914 | { | 946 | { |
915 | ipkg.setPackage( item->text() ); | 947 | ipkg.setPackage( item->text() ); |
916 | ipkg.runIpkg( ); | 948 | ipkg.runIpkg( ); |
917 | } | 949 | } |
918 | } | 950 | } |
919 | } | 951 | } |
920 | 952 | ||
921 | void MainWindow :: downloadRemotePackage() | 953 | void MainWindow :: downloadRemotePackage() |
922 | { | 954 | { |
923 | // Display dialog | 955 | // Display dialog |
924 | bool ok; | 956 | bool ok; |
925 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); | 957 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); |
926 | if ( !ok || package.isEmpty() ) | 958 | if ( !ok || package.isEmpty() ) |
927 | return; | 959 | return; |
928 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 960 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
929 | // if ( dlg.exec() == QDialog::Rejected ) | 961 | // if ( dlg.exec() == QDialog::Rejected ) |
930 | // return; | 962 | // return; |
931 | 963 | ||
932 | // grab details from dialog | 964 | // grab details from dialog |
933 | // QString package = dlg.getPackageLocation(); | 965 | // QString package = dlg.getPackageLocation(); |
934 | 966 | ||
935 | InstallData item; | 967 | InstallData item; |
936 | item.option = "I"; | 968 | item.option = "I"; |
937 | item.packageName = package; | 969 | item.packageName = package; |
938 | vector<InstallData> workingPackages; | 970 | vector<InstallData> workingPackages; |
939 | workingPackages.push_back( item ); | 971 | workingPackages.push_back( item ); |
940 | 972 | ||
941 | InstallDlgImpl dlg2( workingPackages, mgr, this, "Install", true ); | 973 | InstallDlgImpl dlg2( workingPackages, mgr, this, "Install", true ); |
942 | dlg2.showDlg(); | 974 | dlg2.showDlg(); |
943 | 975 | ||
944 | reloadData(); | 976 | reloadData(); |
945 | 977 | ||
946 | #ifdef QWS | 978 | #ifdef QWS |
947 | // Finally let the main system update itself | 979 | // Finally let the main system update itself |
948 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 980 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
949 | QString lf = QString::null; | 981 | QString lf = QString::null; |
950 | e << lf; | 982 | e << lf; |
951 | #endif | 983 | #endif |
952 | } | 984 | } |
953 | 985 | ||
954 | 986 | ||
955 | void MainWindow :: applyChanges() | 987 | void MainWindow :: applyChanges() |
956 | { | 988 | { |
957 | stickyOption = ""; | 989 | stickyOption = ""; |
958 | 990 | ||
959 | // First, write out ipkg_conf file so that ipkg can use it | 991 | // First, write out ipkg_conf file so that ipkg can use it |
960 | mgr->writeOutIpkgConf(); | 992 | mgr->writeOutIpkgConf(); |
961 | 993 | ||
962 | // Now for each selected item | 994 | // Now for each selected item |
963 | // deal with it | 995 | // deal with it |
964 | 996 | ||
965 | vector<InstallData> workingPackages; | 997 | vector<InstallData> workingPackages; |
966 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 998 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
967 | item != 0 ; | 999 | item != 0 ; |
968 | item = (QCheckListItem *)item->nextSibling() ) | 1000 | item = (QCheckListItem *)item->nextSibling() ) |
969 | { | 1001 | { |
970 | if ( item->isOn() ) | 1002 | if ( item->isOn() ) |
971 | { | 1003 | { |
972 | InstallData data = dealWithItem( item ); | 1004 | InstallData data = dealWithItem( item ); |
973 | workingPackages.push_back( data ); | 1005 | workingPackages.push_back( data ); |
974 | } | 1006 | } |
975 | } | 1007 | } |
976 | 1008 | ||
977 | if ( workingPackages.size() == 0 ) | 1009 | if ( workingPackages.size() == 0 ) |
978 | { | 1010 | { |
979 | // Nothing to do | 1011 | // Nothing to do |
980 | QMessageBox::information( this, tr( "Nothing to do" ), | 1012 | QMessageBox::information( this, tr( "Nothing to do" ), |
981 | tr( "No packages selected" ), tr( "OK" ) ); | 1013 | tr( "No packages selected" ), tr( "OK" ) ); |
982 | 1014 | ||
983 | return; | 1015 | return; |
984 | } | 1016 | } |
985 | 1017 | ||
986 | // do the stuff | 1018 | // do the stuff |
987 | InstallDlgImpl dlg( workingPackages, mgr, this, "Install", true ); | 1019 | InstallDlgImpl dlg( workingPackages, mgr, this, "Install", true ); |
988 | dlg.showDlg(); | 1020 | dlg.showDlg(); |
989 | 1021 | ||
990 | reloadData(); | 1022 | reloadData(); |
991 | 1023 | ||
992 | #ifdef QWS | 1024 | #ifdef QWS |
993 | // Finally let the main system update itself | 1025 | // Finally let the main system update itself |
994 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 1026 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
995 | QString lf = QString::null; | 1027 | QString lf = QString::null; |
996 | e << lf; | 1028 | e << lf; |
997 | #endif | 1029 | #endif |
998 | } | 1030 | } |
999 | 1031 | ||
1000 | // decide what to do - either remove, upgrade or install | 1032 | // decide what to do - either remove, upgrade or install |
1001 | // Current rules: | 1033 | // Current rules: |
1002 | // If not installed - install | 1034 | // If not installed - install |
1003 | // If installed and different version available - upgrade | 1035 | // If installed and different version available - upgrade |
1004 | // If installed and version up to date - remove | 1036 | // If installed and version up to date - remove |
1005 | InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | 1037 | InstallData MainWindow :: dealWithItem( QCheckListItem *item ) |
1006 | { | 1038 | { |
1007 | QString name = item->text(); | 1039 | QString name = item->text(); |
1008 | 1040 | ||
1009 | // Get package | 1041 | // Get package |
1010 | vector<Server>::iterator s = mgr->getServer( serversList->currentText() ); | 1042 | vector<Server>::iterator s = mgr->getServer( serversList->currentText() ); |
1011 | Package *p = s->getPackage( name ); | 1043 | Package *p = s->getPackage( name ); |
1012 | 1044 | ||
1013 | // If the package has a filename then it is a local file | 1045 | // If the package has a filename then it is a local file |
1014 | if ( p->isPackageStoredLocally() ) | 1046 | if ( p->isPackageStoredLocally() ) |
1015 | name = p->getFilename(); | 1047 | name = p->getFilename(); |
1016 | 1048 | ||
1017 | QString option; | 1049 | QString option; |
1018 | QString dest = "root"; | 1050 | QString dest = "root"; |
1019 | if ( !p->isInstalled() ) | 1051 | if ( !p->isInstalled() ) |
1020 | { | 1052 | { |
1021 | InstallData item; | 1053 | InstallData item; |
1022 | item.option = "I"; | 1054 | item.option = "I"; |
1023 | item.packageName = name; | 1055 | item.packageName = name; |
1024 | return item; | 1056 | return item; |
1025 | } | 1057 | } |
1026 | else | 1058 | else |
1027 | { | 1059 | { |
1028 | InstallData item; | 1060 | InstallData item; |
1029 | item.option = "D"; | 1061 | item.option = "D"; |
1030 | if ( !p->isPackageStoredLocally() ) | 1062 | if ( !p->isPackageStoredLocally() ) |
1031 | item.packageName = p->getInstalledPackageName(); | 1063 | item.packageName = p->getInstalledPackageName(); |
1032 | else | 1064 | else |
1033 | item.packageName = name; | 1065 | item.packageName = name; |
1034 | 1066 | ||
1035 | if ( p->getInstalledTo() ) | 1067 | if ( p->getInstalledTo() ) |
1036 | { | 1068 | { |
1037 | item.destination = p->getInstalledTo(); | 1069 | item.destination = p->getInstalledTo(); |
1038 | // cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; | 1070 | // cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; |
1039 | // cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; | 1071 | // cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; |
1040 | } | 1072 | } |
1041 | else | 1073 | else |
1042 | { | 1074 | { |
1043 | item.destination = p->getLocalPackage()->getInstalledTo(); | 1075 | item.destination = p->getLocalPackage()->getInstalledTo(); |
1044 | } | 1076 | } |
1045 | 1077 | ||
1046 | // Now see if version is newer or not | 1078 | // Now see if version is newer or not |
1047 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 1079 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
1048 | 1080 | ||
1049 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 1081 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
1050 | if ( p->isPackageStoredLocally() && val == -1 ) | 1082 | if ( p->isPackageStoredLocally() && val == -1 ) |
1051 | val = 0; | 1083 | val = 0; |
1052 | 1084 | ||
1053 | if ( val == -2 ) | 1085 | if ( val == -2 ) |
1054 | { | 1086 | { |
1055 | // Error - should handle | 1087 | // Error - should handle |
1056 | } | 1088 | } |
1057 | else if ( val == -1 ) | 1089 | else if ( val == -1 ) |
1058 | { | 1090 | { |
1059 | // Version available is older - remove only | 1091 | // Version available is older - remove only |
1060 | item.option = "D"; | 1092 | item.option = "D"; |
1061 | } | 1093 | } |
1062 | else | 1094 | else |
1063 | { | 1095 | { |
1064 | QString caption; | 1096 | QString caption; |
1065 | QString text; | 1097 | QString text; |
1066 | QString secondButton; | 1098 | QString secondButton; |
1067 | QString secondOption; | 1099 | QString secondOption; |
1068 | if ( val == 0 ) | 1100 | if ( val == 0 ) |
1069 | { | 1101 | { |
1070 | // Version available is the same - option to remove or reinstall | 1102 | // Version available is the same - option to remove or reinstall |
1071 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | 1103 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); |
1072 | text = tr( "Remove or ReInstall" ); | 1104 | text = tr( "Remove or ReInstall" ); |
1073 | secondButton = tr( "ReInstall" ); | 1105 | secondButton = tr( "ReInstall" ); |
1074 | secondOption = tr( "R" ); | 1106 | secondOption = tr( "R" ); |
1075 | } | 1107 | } |
1076 | else if ( val == 1 ) | 1108 | else if ( val == 1 ) |
1077 | { | 1109 | { |
1078 | // Version available is newer - option to remove or upgrade | 1110 | // Version available is newer - option to remove or upgrade |
1079 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | 1111 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); |
1080 | text = tr( "Remove or Upgrade" ); | 1112 | text = tr( "Remove or Upgrade" ); |
1081 | secondButton = tr( "Upgrade" ); | 1113 | secondButton = tr( "Upgrade" ); |
1082 | secondOption = tr( "U" ); | 1114 | secondOption = tr( "U" ); |
1083 | } | 1115 | } |
1084 | 1116 | ||
1085 | // Sticky option not implemented yet, but will eventually allow | 1117 | // Sticky option not implemented yet, but will eventually allow |
1086 | // the user to say something like 'remove all' | 1118 | // the user to say something like 'remove all' |
1087 | if ( stickyOption == "" ) | 1119 | if ( stickyOption == "" ) |
1088 | { | 1120 | { |
1089 | QString msgtext; | 1121 | QString msgtext; |
1090 | msgtext = caption.arg( ( const char * )name ); | 1122 | msgtext = caption.arg( ( const char * )name ); |
1091 | switch( QMessageBox::information( this, text, | 1123 | switch( QMessageBox::information( this, text, |
1092 | msgtext, tr( "Remove" ), secondButton ) ) | 1124 | msgtext, tr( "Remove" ), secondButton ) ) |
1093 | { | 1125 | { |
1094 | case 0: // Try again or Enter | 1126 | case 0: // Try again or Enter |
1095 | // option 0 = Remove | 1127 | // option 0 = Remove |
1096 | item.option = "D"; | 1128 | item.option = "D"; |
1097 | break; | 1129 | break; |
1098 | case 1: // Quit or Escape | 1130 | case 1: // Quit or Escape |
1099 | item.option = secondOption; | 1131 | item.option = secondOption; |
1100 | break; | 1132 | break; |
1101 | } | 1133 | } |
1102 | } | 1134 | } |
1103 | else | 1135 | else |
1104 | { | 1136 | { |
1105 | // item.option = stickyOption; | 1137 | // item.option = stickyOption; |
1106 | } | 1138 | } |
1107 | } | 1139 | } |
1108 | 1140 | ||
1109 | 1141 | ||
1110 | // Check if we are reinstalling the same version | 1142 | // Check if we are reinstalling the same version |
1111 | if ( item.option != "R" ) | 1143 | if ( item.option != "R" ) |
1112 | item.recreateLinks = true; | 1144 | item.recreateLinks = true; |
1113 | else | 1145 | else |
1114 | item.recreateLinks = false; | 1146 | item.recreateLinks = false; |
1115 | 1147 | ||
1116 | // User hit cancel (on dlg - assume remove) | 1148 | // User hit cancel (on dlg - assume remove) |
1117 | return item; | 1149 | return item; |
1118 | } | 1150 | } |
1119 | } | 1151 | } |
1120 | 1152 | ||
1121 | void MainWindow :: reloadData() | 1153 | void MainWindow :: reloadData() |
1122 | { | 1154 | { |
1123 | stack->raiseWidget( progressWindow ); | 1155 | stack->raiseWidget( progressWindow ); |
1124 | mgr->reloadServerData(); | 1156 | mgr->reloadServerData(); |
1125 | serverSelected( -1, FALSE ); | 1157 | serverSelected( -1, FALSE ); |
1126 | stack->raiseWidget( networkPkgWindow ); | 1158 | stack->raiseWidget( networkPkgWindow ); |
1127 | } | 1159 | } |
1128 | 1160 | ||
1129 | void MainWindow :: letterPushed( QString t ) | 1161 | void MainWindow :: letterPushed( QString t ) |
1130 | { | 1162 | { |
1131 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 1163 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
1132 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 1164 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
1133 | if ( packagesList->firstChild() == 0 ) | 1165 | if ( packagesList->firstChild() == 0 ) |
1134 | return; | 1166 | return; |
1135 | 1167 | ||
1136 | QCheckListItem *item; | 1168 | QCheckListItem *item; |
1137 | if ( start == 0 ) | 1169 | if ( start == 0 ) |
1138 | { | 1170 | { |
1139 | item = (QCheckListItem *)packagesList->firstChild(); | 1171 | item = (QCheckListItem *)packagesList->firstChild(); |
1140 | start = top; | 1172 | start = top; |
1141 | } | 1173 | } |
1142 | else | 1174 | else |
1143 | item = (QCheckListItem *)start->nextSibling(); | 1175 | item = (QCheckListItem *)start->nextSibling(); |
1144 | 1176 | ||
1145 | if ( item == 0 ) | 1177 | if ( item == 0 ) |
1146 | item = (QCheckListItem *)packagesList->firstChild(); | 1178 | item = (QCheckListItem *)packagesList->firstChild(); |
1147 | do | 1179 | do |
1148 | { | 1180 | { |
1149 | if ( item->text().lower().startsWith( t.lower() ) ) | 1181 | if ( item->text().lower().startsWith( t.lower() ) ) |
1150 | { | 1182 | { |
1151 | packagesList->setSelected( item, true ); | 1183 | packagesList->setSelected( item, true ); |
1152 | packagesList->ensureItemVisible( item ); | 1184 | packagesList->ensureItemVisible( item ); |
1153 | break; | 1185 | break; |
1154 | } | 1186 | } |
1155 | 1187 | ||
1156 | item = (QCheckListItem *)item->nextSibling(); | 1188 | item = (QCheckListItem *)item->nextSibling(); |
1157 | if ( !item ) | 1189 | if ( !item ) |
1158 | item = (QCheckListItem *)packagesList->firstChild(); | 1190 | item = (QCheckListItem *)packagesList->firstChild(); |
1159 | } while ( item != start); | 1191 | } while ( item != start); |
1160 | } | 1192 | } |
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index be30668..b49c819 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h | |||
@@ -1,134 +1,137 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | mainwin.h - description | 2 | mainwin.h - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 13:32:30 BST 2002 | 4 | begin : Mon Aug 26 13:32:30 BST 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #ifndef MAINWIN_H | 18 | #ifndef MAINWIN_H |
19 | #define MAINWIN_H | 19 | #define MAINWIN_H |
20 | 20 | ||
21 | #include <qmainwindow.h> | 21 | #include <qmainwindow.h> |
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | 23 | ||
24 | class DataManager; | 24 | class DataManager; |
25 | class InstallData; | 25 | class InstallData; |
26 | 26 | ||
27 | class QAction; | 27 | class QAction; |
28 | class QCheckListItem; | 28 | class QCheckListItem; |
29 | class QComboBox; | 29 | class QComboBox; |
30 | class QLabel; | 30 | class QLabel; |
31 | class QLineEdit; | 31 | class QLineEdit; |
32 | class QListView; | 32 | class QListView; |
33 | class QPEToolBar; | 33 | class QPEToolBar; |
34 | class QProgressBar; | 34 | class QProgressBar; |
35 | class QWidgetStack; | 35 | class QWidgetStack; |
36 | 36 | ||
37 | class MainWindow :public QMainWindow | 37 | class MainWindow :public QMainWindow |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | 41 | ||
42 | MainWindow(); | 42 | MainWindow(); |
43 | ~MainWindow(); | 43 | ~MainWindow(); |
44 | 44 | ||
45 | private: | 45 | private: |
46 | DataManager *mgr; | 46 | DataManager *mgr; |
47 | 47 | ||
48 | QWidgetStack *stack; | 48 | QWidgetStack *stack; |
49 | 49 | ||
50 | QPEToolBar *findBar; | 50 | QPEToolBar *findBar; |
51 | QPEToolBar *jumpBar; | ||
51 | QLineEdit *findEdit; | 52 | QLineEdit *findEdit; |
52 | QAction *actionFindNext; | 53 | QAction *actionFindNext; |
53 | QAction *actionFilter; | 54 | QAction *actionFilter; |
54 | QAction *actionUpgrade; | 55 | QAction *actionUpgrade; |
55 | QAction *actionDownload; | 56 | QAction *actionDownload; |
56 | QAction *actionUninstalled; | 57 | QAction *actionUninstalled; |
57 | QAction *actionInstalled; | 58 | QAction *actionInstalled; |
58 | QAction *actionUpdated; | 59 | QAction *actionUpdated; |
59 | 60 | ||
60 | QPixmap iconDownload; | 61 | QPixmap iconDownload; |
61 | QPixmap iconRemove; | 62 | QPixmap iconRemove; |
62 | 63 | ||
63 | int mnuShowUninstalledPkgsId; | 64 | int mnuShowUninstalledPkgsId; |
64 | int mnuShowInstalledPkgsId; | 65 | int mnuShowInstalledPkgsId; |
65 | int mnuShowUpgradedPkgsId; | 66 | int mnuShowUpgradedPkgsId; |
66 | int mnuFilterByCategory; | 67 | int mnuFilterByCategory; |
67 | int mnuSetFilterCategory; | 68 | int mnuSetFilterCategory; |
68 | 69 | ||
69 | // Main package list widget | 70 | // Main package list widget |
70 | QWidget *networkPkgWindow; | 71 | QWidget *networkPkgWindow; |
71 | QComboBox *serversList; | 72 | QComboBox *serversList; |
72 | QListView *packagesList; | 73 | QListView *packagesList; |
73 | QPixmap installedIcon; | 74 | QPixmap installedIcon; |
74 | QPixmap updatedIcon; | 75 | QPixmap updatedIcon; |
75 | QString currentlySelectedServer; | 76 | QString currentlySelectedServer; |
76 | QString categoryFilter; | 77 | QString categoryFilter; |
77 | QString stickyOption; | 78 | QString stickyOption; |
78 | 79 | ||
79 | bool categoryFilterEnabled; | 80 | bool categoryFilterEnabled; |
80 | bool showJumpTo; | 81 | bool showJumpTo; |
81 | bool showUninstalledPkgs; | 82 | bool showUninstalledPkgs; |
82 | bool showInstalledPkgs; | 83 | bool showInstalledPkgs; |
83 | bool showUpgradedPkgs; | 84 | bool showUpgradedPkgs; |
84 | bool downloadEnabled; | 85 | bool downloadEnabled; |
85 | 86 | ||
86 | void initMainWidget(); | 87 | void initMainWidget(); |
87 | void updateData(); | 88 | void updateData(); |
88 | void serverSelected( int index, bool showProgress ); | 89 | void serverSelected( int index, bool showProgress ); |
89 | void searchForPackage( const QString & ); | 90 | void searchForPackage( const QString & ); |
90 | bool filterByCategory( bool val ); | 91 | bool filterByCategory( bool val ); |
91 | void downloadSelectedPackages(); | 92 | void downloadSelectedPackages(); |
92 | void downloadRemotePackage(); | 93 | void downloadRemotePackage(); |
93 | InstallData dealWithItem( QCheckListItem *item ); | 94 | InstallData dealWithItem( QCheckListItem *item ); |
94 | void reloadData(); | 95 | void reloadData(); |
95 | 96 | ||
96 | // Progress widget | 97 | // Progress widget |
97 | QWidget *progressWindow; | 98 | QWidget *progressWindow; |
98 | QLabel *m_status; | 99 | QLabel *m_status; |
99 | QProgressBar *m_progress; | 100 | QProgressBar *m_progress; |
100 | 101 | ||
101 | void initProgressWidget(); | 102 | void initProgressWidget(); |
102 | 103 | ||
103 | public slots: | 104 | public slots: |
104 | // void setDocument( const QString &doc ); | 105 | // void setDocument( const QString &doc ); |
105 | void displayHelp(); | 106 | void displayHelp(); |
106 | void displayFindBar(); | 107 | void displayFindBar(); |
108 | void displayJumpBar(); | ||
107 | void repeatFind(); | 109 | void repeatFind(); |
108 | void findPackage( const QString & ); | 110 | void findPackage( const QString & ); |
109 | void hideFindBar(); | 111 | void hideFindBar(); |
112 | void hideJumpBar(); | ||
110 | void displayAbout(); | 113 | void displayAbout(); |
111 | void displaySettings(); | 114 | void displaySettings(); |
112 | void filterUninstalledPackages(); | 115 | void filterUninstalledPackages(); |
113 | void filterInstalledPackages(); | 116 | void filterInstalledPackages(); |
114 | void filterUpgradedPackages(); | 117 | void filterUpgradedPackages(); |
115 | void filterCategory(); | 118 | void filterCategory(); |
116 | bool setFilterCategory(); | 119 | bool setFilterCategory(); |
117 | void raiseMainWidget(); | 120 | void raiseMainWidget(); |
118 | void raiseProgressWidget(); | 121 | void raiseProgressWidget(); |
119 | void enableUpgrade( bool ); | 122 | void enableUpgrade( bool ); |
120 | void enableDownload( bool ); | 123 | void enableDownload( bool ); |
121 | 124 | ||
122 | private slots: | 125 | private slots: |
123 | void init(); | 126 | void init(); |
124 | void setProgressSteps( int ); | 127 | void setProgressSteps( int ); |
125 | void setProgressMessage( const QString & ); | 128 | void setProgressMessage( const QString & ); |
126 | void updateProgress( int ); | 129 | void updateProgress( int ); |
127 | void serverSelected( int index ); | 130 | void serverSelected( int index ); |
128 | void updateServer(); | 131 | void updateServer(); |
129 | void upgradePackages(); | 132 | void upgradePackages(); |
130 | void downloadPackage(); | 133 | void downloadPackage(); |
131 | void applyChanges(); | 134 | void applyChanges(); |
132 | void letterPushed( QString t ); | 135 | void letterPushed( QString t ); |
133 | }; | 136 | }; |
134 | #endif | 137 | #endif |