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