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