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