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