-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 8090646..ae073ef 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,529 +1,530 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | mainwin.cpp - description | 2 | mainwin.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 13:32:30 BST 2002 | 4 | begin : Mon Aug 26 13:32:30 BST 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include <linux/limits.h> | ||
18 | #include <unistd.h> | 19 | #include <unistd.h> |
19 | 20 | ||
20 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
21 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
23 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
25 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
26 | 27 | ||
27 | #include <qaction.h> | 28 | #include <qaction.h> |
28 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
29 | #include <qfile.h> | 30 | #include <qfile.h> |
30 | #include <qlabel.h> | 31 | #include <qlabel.h> |
31 | #include <qlayout.h> | 32 | #include <qlayout.h> |
32 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
33 | #include <qlistview.h> | 34 | #include <qlistview.h> |
34 | #include <qmenubar.h> | 35 | #include <qmenubar.h> |
35 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
36 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
37 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
38 | #include <qtimer.h> | 39 | #include <qtimer.h> |
39 | #include <qwhatsthis.h> | 40 | #include <qwhatsthis.h> |
40 | #include <qwidgetstack.h> | 41 | #include <qwidgetstack.h> |
41 | 42 | ||
42 | #include "categoryfilterimpl.h" | 43 | #include "categoryfilterimpl.h" |
43 | #include "datamgr.h" | 44 | #include "datamgr.h" |
44 | #include "global.h" | 45 | #include "global.h" |
45 | #include "helpwindow.h" | 46 | #include "helpwindow.h" |
46 | #include "inputdlg.h" | 47 | #include "inputdlg.h" |
47 | #include "installdlgimpl.h" | 48 | #include "installdlgimpl.h" |
48 | #include "letterpushbutton.h" | 49 | #include "letterpushbutton.h" |
49 | #include "mainwin.h" | 50 | #include "mainwin.h" |
50 | #include "settingsimpl.h" | 51 | #include "settingsimpl.h" |
51 | #include "utils.h" | 52 | #include "utils.h" |
52 | 53 | ||
53 | extern int compareVersions( const char *v1, const char *v2 ); | 54 | extern int compareVersions( const char *v1, const char *v2 ); |
54 | 55 | ||
55 | MainWindow :: MainWindow() | 56 | MainWindow :: MainWindow() |
56 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 57 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) |
57 | { | 58 | { |
58 | setCaption( tr( "AQPkg - Package Manager" ) ); | 59 | setCaption( tr( "AQPkg - Package Manager" ) ); |
59 | 60 | ||
60 | #ifdef QWS | 61 | #ifdef QWS |
61 | // read download directory from config file | 62 | // read download directory from config file |
62 | Config cfg( "aqpkg" ); | 63 | Config cfg( "aqpkg" ); |
63 | cfg.setGroup( "settings" ); | 64 | cfg.setGroup( "settings" ); |
64 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 65 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
65 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 66 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
66 | 67 | ||
67 | #endif | 68 | #endif |
68 | 69 | ||
69 | // Create UI widgets | 70 | // Create UI widgets |
70 | initMainWidget(); | 71 | initMainWidget(); |
71 | initProgressWidget(); | 72 | initProgressWidget(); |
72 | 73 | ||
73 | // Build menu and tool bars | 74 | // Build menu and tool bars |
74 | setToolBarsMovable( FALSE ); | 75 | setToolBarsMovable( FALSE ); |
75 | 76 | ||
76 | QPEToolBar *bar = new QPEToolBar( this ); | 77 | QPEToolBar *bar = new QPEToolBar( this ); |
77 | bar->setHorizontalStretchable( TRUE ); | 78 | bar->setHorizontalStretchable( TRUE ); |
78 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 79 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
79 | mb->setMargin( 0 ); | 80 | mb->setMargin( 0 ); |
80 | bar = new QPEToolBar( this ); | 81 | bar = new QPEToolBar( this ); |
81 | 82 | ||
82 | // Find toolbar | 83 | // Find toolbar |
83 | findBar = new QPEToolBar( this ); | 84 | findBar = new QPEToolBar( this ); |
84 | addToolBar( findBar, QMainWindow::Top, true ); | 85 | addToolBar( findBar, QMainWindow::Top, true ); |
85 | findBar->setHorizontalStretchable( true ); | 86 | findBar->setHorizontalStretchable( true ); |
86 | findEdit = new QLineEdit( findBar ); | 87 | findEdit = new QLineEdit( findBar ); |
87 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); | 88 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); |
88 | findBar->setStretchableWidget( findEdit ); | 89 | findBar->setStretchableWidget( findEdit ); |
89 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); | 90 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); |
90 | 91 | ||
91 | // Packages menu | 92 | // Packages menu |
92 | QPopupMenu *popup = new QPopupMenu( this ); | 93 | QPopupMenu *popup = new QPopupMenu( this ); |
93 | 94 | ||
94 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | 95 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); |
95 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 96 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
96 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); | 97 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); |
97 | a->addTo( popup ); | 98 | a->addTo( popup ); |
98 | a->addTo( bar ); | 99 | a->addTo( bar ); |
99 | 100 | ||
100 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | 101 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); |
101 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 102 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
102 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); | 103 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); |
103 | actionUpgrade->addTo( popup ); | 104 | actionUpgrade->addTo( popup ); |
104 | actionUpgrade->addTo( bar ); | 105 | actionUpgrade->addTo( bar ); |
105 | 106 | ||
106 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | 107 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); |
107 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | 108 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); |
108 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 109 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
109 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 110 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
110 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); | 111 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); |
111 | actionDownload->addTo( popup ); | 112 | actionDownload->addTo( popup ); |
112 | actionDownload->addTo( bar ); | 113 | actionDownload->addTo( bar ); |
113 | 114 | ||
114 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | 115 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); |
115 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 116 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
116 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); | 117 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); |
117 | a->addTo( popup ); | 118 | a->addTo( popup ); |
118 | a->addTo( bar ); | 119 | a->addTo( bar ); |
119 | 120 | ||
120 | mb->insertItem( tr( "Actions" ), popup ); | 121 | mb->insertItem( tr( "Actions" ), popup ); |
121 | 122 | ||
122 | // View menu | 123 | // View menu |
123 | popup = new QPopupMenu( this ); | 124 | popup = new QPopupMenu( this ); |
124 | 125 | ||
125 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 126 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
126 | actionUninstalled->setToggleAction( TRUE ); | 127 | actionUninstalled->setToggleAction( TRUE ); |
127 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 128 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
128 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | 129 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); |
129 | actionUninstalled->addTo( popup ); | 130 | actionUninstalled->addTo( popup ); |
130 | 131 | ||
131 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 132 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
132 | actionInstalled->setToggleAction( TRUE ); | 133 | actionInstalled->setToggleAction( TRUE ); |
133 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 134 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
134 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | 135 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); |
135 | actionInstalled->addTo( popup ); | 136 | actionInstalled->addTo( popup ); |
136 | 137 | ||
137 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 138 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
138 | actionUpdated->setToggleAction( TRUE ); | 139 | actionUpdated->setToggleAction( TRUE ); |
139 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 140 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); |
140 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); | 141 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); |
141 | actionUpdated->addTo( popup ); | 142 | actionUpdated->addTo( popup ); |
142 | 143 | ||
143 | popup->insertSeparator(); | 144 | popup->insertSeparator(); |
144 | 145 | ||
145 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); | 146 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); |
146 | actionFilter->setToggleAction( TRUE ); | 147 | actionFilter->setToggleAction( TRUE ); |
147 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); | 148 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); |
148 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | 149 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); |
149 | actionFilter->addTo( popup ); | 150 | actionFilter->addTo( popup ); |
150 | 151 | ||
151 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); | 152 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); |
152 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); | 153 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); |
153 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | 154 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); |
154 | a->addTo( popup ); | 155 | a->addTo( popup ); |
155 | 156 | ||
156 | popup->insertSeparator(); | 157 | popup->insertSeparator(); |
157 | 158 | ||
158 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
159 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); | 160 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
160 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); | 161 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); |
161 | a->addTo( popup ); | 162 | a->addTo( popup ); |
162 | 163 | ||
163 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 164 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
164 | actionFindNext->setEnabled( FALSE ); | 165 | actionFindNext->setEnabled( FALSE ); |
165 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 166 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); |
166 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); | 167 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); |
167 | actionFindNext->addTo( popup ); | 168 | actionFindNext->addTo( popup ); |
168 | actionFindNext->addTo( findBar ); | 169 | actionFindNext->addTo( findBar ); |
169 | 170 | ||
170 | mb->insertItem( tr( "View" ), popup ); | 171 | mb->insertItem( tr( "View" ), popup ); |
171 | 172 | ||
172 | 173 | ||
173 | // Options menu | 174 | // Options menu |
174 | popup = new QPopupMenu( this ); | 175 | popup = new QPopupMenu( this ); |
175 | 176 | ||
176 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 ); | 177 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 ); |
177 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 178 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
178 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | 179 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); |
179 | a->addTo( popup ); | 180 | a->addTo( popup ); |
180 | 181 | ||
181 | popup->insertSeparator(); | 182 | popup->insertSeparator(); |
182 | 183 | ||
183 | a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 ); | 184 | a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 ); |
184 | a->setWhatsThis( tr( "Click here for help." ) ); | 185 | a->setWhatsThis( tr( "Click here for help." ) ); |
185 | connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) ); | 186 | connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) ); |
186 | a->addTo( popup ); | 187 | a->addTo( popup ); |
187 | 188 | ||
188 | a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 ); | 189 | a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 ); |
189 | a->setWhatsThis( tr( "Click here for software version information." ) ); | 190 | a->setWhatsThis( tr( "Click here for software version information." ) ); |
190 | connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) ); | 191 | connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) ); |
191 | a->addTo( popup ); | 192 | a->addTo( popup ); |
192 | 193 | ||
193 | mb->insertItem( tr( "Options" ), popup ); | 194 | mb->insertItem( tr( "Options" ), popup ); |
194 | 195 | ||
195 | // Finish find toolbar creation | 196 | // Finish find toolbar creation |
196 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 197 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
197 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 198 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
198 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 199 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
199 | a->addTo( findBar ); | 200 | a->addTo( findBar ); |
200 | findBar->hide(); | 201 | findBar->hide(); |
201 | 202 | ||
202 | // Create widget stack and add UI widgets | 203 | // Create widget stack and add UI widgets |
203 | stack = new QWidgetStack( this ); | 204 | stack = new QWidgetStack( this ); |
204 | stack->addWidget( progressWindow, 2 ); | 205 | stack->addWidget( progressWindow, 2 ); |
205 | stack->addWidget( networkPkgWindow, 1 ); | 206 | stack->addWidget( networkPkgWindow, 1 ); |
206 | setCentralWidget( stack ); | 207 | setCentralWidget( stack ); |
207 | stack->raiseWidget( progressWindow ); | 208 | stack->raiseWidget( progressWindow ); |
208 | 209 | ||
209 | // Delayed call to finish initialization | 210 | // Delayed call to finish initialization |
210 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 211 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
211 | } | 212 | } |
212 | 213 | ||
213 | MainWindow :: ~MainWindow() | 214 | MainWindow :: ~MainWindow() |
214 | { | 215 | { |
215 | delete mgr; | 216 | delete mgr; |
216 | } | 217 | } |
217 | 218 | ||
218 | void MainWindow :: initMainWidget() | 219 | void MainWindow :: initMainWidget() |
219 | { | 220 | { |
220 | networkPkgWindow = new QWidget( this ); | 221 | networkPkgWindow = new QWidget( this ); |
221 | 222 | ||
222 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 223 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
223 | 224 | ||
224 | serversList = new QComboBox( networkPkgWindow ); | 225 | serversList = new QComboBox( networkPkgWindow ); |
225 | connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); | 226 | connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); |
226 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 227 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
227 | 228 | ||
228 | installedIcon = Resource::loadPixmap( "aqpkg/installed" ); | 229 | installedIcon = Resource::loadPixmap( "aqpkg/installed" ); |
229 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 230 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); |
230 | 231 | ||
231 | packagesList = new QListView( networkPkgWindow ); | 232 | packagesList = new QListView( networkPkgWindow ); |
232 | packagesList->addColumn( tr( "Packages" ), 225 ); | 233 | packagesList->addColumn( tr( "Packages" ), 225 ); |
233 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | 234 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); |
234 | 235 | ||
235 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 236 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
236 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 237 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
237 | hbox1->addWidget( l ); | 238 | hbox1->addWidget( l ); |
238 | hbox1->addWidget( serversList ); | 239 | hbox1->addWidget( serversList ); |
239 | 240 | ||
240 | 241 | ||
241 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); | 242 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); |
242 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); | 243 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); |
243 | 244 | ||
244 | if ( showJumpTo ) | 245 | if ( showJumpTo ) |
245 | { | 246 | { |
246 | char text[2]; | 247 | char text[2]; |
247 | text[1] = '\0'; | 248 | text[1] = '\0'; |
248 | for ( int i = 0 ; i < 26 ; ++i ) | 249 | for ( int i = 0 ; i < 26 ; ++i ) |
249 | { | 250 | { |
250 | text[0] = 'A' + i; | 251 | text[0] = 'A' + i; |
251 | LetterPushButton *b = new LetterPushButton( text, networkPkgWindow ); | 252 | LetterPushButton *b = new LetterPushButton( text, networkPkgWindow ); |
252 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 253 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
253 | if ( i < 13 ) | 254 | if ( i < 13 ) |
254 | hbox3->addWidget( b ); | 255 | hbox3->addWidget( b ); |
255 | else | 256 | else |
256 | hbox4->addWidget( b ); | 257 | hbox4->addWidget( b ); |
257 | } | 258 | } |
258 | } | 259 | } |
259 | 260 | ||
260 | vbox->addWidget( packagesList ); | 261 | vbox->addWidget( packagesList ); |
261 | 262 | ||
262 | downloadEnabled = TRUE; | 263 | downloadEnabled = TRUE; |
263 | } | 264 | } |
264 | 265 | ||
265 | void MainWindow :: initProgressWidget() | 266 | void MainWindow :: initProgressWidget() |
266 | { | 267 | { |
267 | progressWindow = new QWidget( this ); | 268 | progressWindow = new QWidget( this ); |
268 | 269 | ||
269 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | 270 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); |
270 | 271 | ||
271 | m_status = new QLabel( progressWindow ); | 272 | m_status = new QLabel( progressWindow ); |
272 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 273 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
273 | layout->addWidget( m_status ); | 274 | layout->addWidget( m_status ); |
274 | 275 | ||
275 | m_progress = new QProgressBar( progressWindow ); | 276 | m_progress = new QProgressBar( progressWindow ); |
276 | layout->addWidget( m_progress ); | 277 | layout->addWidget( m_progress ); |
277 | } | 278 | } |
278 | 279 | ||
279 | void MainWindow :: init() | 280 | void MainWindow :: init() |
280 | { | 281 | { |
281 | stack->raiseWidget( progressWindow ); | 282 | stack->raiseWidget( progressWindow ); |
282 | 283 | ||
283 | mgr = new DataManager(); | 284 | mgr = new DataManager(); |
284 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); | 285 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); |
285 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 286 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), |
286 | this, SLOT( setProgressMessage( const QString & ) ) ); | 287 | this, SLOT( setProgressMessage( const QString & ) ) ); |
287 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); | 288 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); |
288 | mgr->loadServers(); | 289 | mgr->loadServers(); |
289 | 290 | ||
290 | showUninstalledPkgs = false; | 291 | showUninstalledPkgs = false; |
291 | showInstalledPkgs = false; | 292 | showInstalledPkgs = false; |
292 | showUpgradedPkgs = false; | 293 | showUpgradedPkgs = false; |
293 | categoryFilterEnabled = false; | 294 | categoryFilterEnabled = false; |
294 | 295 | ||
295 | updateData(); | 296 | updateData(); |
296 | 297 | ||
297 | stack->raiseWidget( networkPkgWindow ); | 298 | stack->raiseWidget( networkPkgWindow ); |
298 | } | 299 | } |
299 | /* | 300 | /* |
300 | void MainWindow :: setDocument( const QString &doc ) | 301 | void MainWindow :: setDocument( const QString &doc ) |
301 | { | 302 | { |
302 | // Remove path from package | 303 | // Remove path from package |
303 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 304 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
304 | // std::cout << "Selecting package " << package << std::endl; | 305 | // std::cout << "Selecting package " << package << std::endl; |
305 | 306 | ||
306 | // First select local server | 307 | // First select local server |
307 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 308 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
308 | { | 309 | { |
309 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 310 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
310 | { | 311 | { |
311 | serversList->setCurrentItem( i ); | 312 | serversList->setCurrentItem( i ); |
312 | break; | 313 | break; |
313 | } | 314 | } |
314 | } | 315 | } |
315 | serverSelected( 0 ); | 316 | serverSelected( 0 ); |
316 | 317 | ||
317 | // Now set the check box of the selected package | 318 | // Now set the check box of the selected package |
318 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 319 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
319 | item != 0 ; | 320 | item != 0 ; |
320 | item = (QCheckListItem *)item->nextSibling() ) | 321 | item = (QCheckListItem *)item->nextSibling() ) |
321 | { | 322 | { |
322 | if ( item->text().startsWith( package ) ) | 323 | if ( item->text().startsWith( package ) ) |
323 | { | 324 | { |
324 | item->setOn( true ); | 325 | item->setOn( true ); |
325 | break; | 326 | break; |
326 | } | 327 | } |
327 | } | 328 | } |
328 | } | 329 | } |
329 | */ | 330 | */ |
330 | void MainWindow :: displaySettings() | 331 | void MainWindow :: displaySettings() |
331 | { | 332 | { |
332 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 333 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
333 | if ( dlg->showDlg( 0 ) ) | 334 | if ( dlg->showDlg( 0 ) ) |
334 | { | 335 | { |
335 | stack->raiseWidget( progressWindow ); | 336 | stack->raiseWidget( progressWindow ); |
336 | updateData(); | 337 | updateData(); |
337 | stack->raiseWidget( networkPkgWindow ); | 338 | stack->raiseWidget( networkPkgWindow ); |
338 | } | 339 | } |
339 | delete dlg; | 340 | delete dlg; |
340 | } | 341 | } |
341 | 342 | ||
342 | void MainWindow :: displayHelp() | 343 | void MainWindow :: displayHelp() |
343 | { | 344 | { |
344 | HelpWindow *dlg = new HelpWindow( this ); | 345 | HelpWindow *dlg = new HelpWindow( this ); |
345 | dlg->exec(); | 346 | dlg->exec(); |
346 | delete dlg; | 347 | delete dlg; |
347 | } | 348 | } |
348 | 349 | ||
349 | void MainWindow :: displayFindBar() | 350 | void MainWindow :: displayFindBar() |
350 | { | 351 | { |
351 | findBar->show(); | 352 | findBar->show(); |
352 | findEdit->setFocus(); | 353 | findEdit->setFocus(); |
353 | } | 354 | } |
354 | 355 | ||
355 | void MainWindow :: repeatFind() | 356 | void MainWindow :: repeatFind() |
356 | { | 357 | { |
357 | searchForPackage( findEdit->text() ); | 358 | searchForPackage( findEdit->text() ); |
358 | } | 359 | } |
359 | 360 | ||
360 | void MainWindow :: findPackage( const QString &text ) | 361 | void MainWindow :: findPackage( const QString &text ) |
361 | { | 362 | { |
362 | actionFindNext->setEnabled( !text.isEmpty() ); | 363 | actionFindNext->setEnabled( !text.isEmpty() ); |
363 | searchForPackage( text ); | 364 | searchForPackage( text ); |
364 | } | 365 | } |
365 | 366 | ||
366 | void MainWindow :: hideFindBar() | 367 | void MainWindow :: hideFindBar() |
367 | { | 368 | { |
368 | findBar->hide(); | 369 | findBar->hide(); |
369 | } | 370 | } |
370 | 371 | ||
371 | void MainWindow :: displayAbout() | 372 | void MainWindow :: displayAbout() |
372 | { | 373 | { |
373 | QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) ); | 374 | QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) ); |
374 | } | 375 | } |
375 | 376 | ||
376 | void MainWindow :: filterUninstalledPackages() | 377 | void MainWindow :: filterUninstalledPackages() |
377 | { | 378 | { |
378 | showUninstalledPkgs = actionUninstalled->isOn(); | 379 | showUninstalledPkgs = actionUninstalled->isOn(); |
379 | if ( showUninstalledPkgs ) | 380 | if ( showUninstalledPkgs ) |
380 | { | 381 | { |
381 | showInstalledPkgs = FALSE; | 382 | showInstalledPkgs = FALSE; |
382 | showUpgradedPkgs = FALSE; | 383 | showUpgradedPkgs = FALSE; |
383 | } | 384 | } |
384 | serverSelected( -1 ); | 385 | serverSelected( -1 ); |
385 | 386 | ||
386 | actionInstalled->setOn( FALSE ); | 387 | actionInstalled->setOn( FALSE ); |
387 | actionUpdated->setOn( FALSE ); | 388 | actionUpdated->setOn( FALSE ); |
388 | } | 389 | } |
389 | 390 | ||
390 | void MainWindow :: filterInstalledPackages() | 391 | void MainWindow :: filterInstalledPackages() |
391 | { | 392 | { |
392 | showInstalledPkgs = actionInstalled->isOn(); | 393 | showInstalledPkgs = actionInstalled->isOn(); |
393 | if ( showInstalledPkgs ) | 394 | if ( showInstalledPkgs ) |
394 | { | 395 | { |
395 | showUninstalledPkgs = FALSE; | 396 | showUninstalledPkgs = FALSE; |
396 | showUpgradedPkgs = FALSE; | 397 | showUpgradedPkgs = FALSE; |
397 | } | 398 | } |
398 | serverSelected( -1 ); | 399 | serverSelected( -1 ); |
399 | 400 | ||
400 | actionUninstalled->setOn( FALSE ); | 401 | actionUninstalled->setOn( FALSE ); |
401 | actionUpdated->setOn( FALSE ); | 402 | actionUpdated->setOn( FALSE ); |
402 | } | 403 | } |
403 | 404 | ||
404 | void MainWindow :: filterUpgradedPackages() | 405 | void MainWindow :: filterUpgradedPackages() |
405 | { | 406 | { |
406 | showUpgradedPkgs = actionUpdated->isOn(); | 407 | showUpgradedPkgs = actionUpdated->isOn(); |
407 | if ( showUpgradedPkgs ) | 408 | if ( showUpgradedPkgs ) |
408 | { | 409 | { |
409 | showUninstalledPkgs = FALSE; | 410 | showUninstalledPkgs = FALSE; |
410 | showInstalledPkgs = FALSE; | 411 | showInstalledPkgs = FALSE; |
411 | } | 412 | } |
412 | serverSelected( -1 ); | 413 | serverSelected( -1 ); |
413 | 414 | ||
414 | actionUninstalled->setOn( FALSE ); | 415 | actionUninstalled->setOn( FALSE ); |
415 | actionInstalled->setOn( FALSE ); | 416 | actionInstalled->setOn( FALSE ); |
416 | } | 417 | } |
417 | 418 | ||
418 | bool MainWindow :: setFilterCategory() | 419 | bool MainWindow :: setFilterCategory() |
419 | { | 420 | { |
420 | // Get categories; | 421 | // Get categories; |
421 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); | 422 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); |
422 | if ( dlg.exec() == QDialog::Accepted ) | 423 | if ( dlg.exec() == QDialog::Accepted ) |
423 | { | 424 | { |
424 | categoryFilter = dlg.getSelectedFilter(); | 425 | categoryFilter = dlg.getSelectedFilter(); |
425 | 426 | ||
426 | if ( categoryFilter == "" ) | 427 | if ( categoryFilter == "" ) |
427 | return false; | 428 | return false; |
428 | 429 | ||
429 | categoryFilterEnabled = true; | 430 | categoryFilterEnabled = true; |
430 | serverSelected( -1 ); | 431 | serverSelected( -1 ); |
431 | actionFilter->setOn( TRUE ); | 432 | actionFilter->setOn( TRUE ); |
432 | return true; | 433 | return true; |
433 | } | 434 | } |
434 | 435 | ||
435 | return false; | 436 | return false; |
436 | } | 437 | } |
437 | 438 | ||
438 | void MainWindow :: filterCategory() | 439 | void MainWindow :: filterCategory() |
439 | { | 440 | { |
440 | if ( !actionFilter->isOn() ) | 441 | if ( !actionFilter->isOn() ) |
441 | { | 442 | { |
442 | filterByCategory( FALSE ); | 443 | filterByCategory( FALSE ); |
443 | } | 444 | } |
444 | else | 445 | else |
445 | { | 446 | { |
446 | actionFilter->setOn( filterByCategory( TRUE ) ); | 447 | actionFilter->setOn( filterByCategory( TRUE ) ); |
447 | } | 448 | } |
448 | } | 449 | } |
449 | 450 | ||
450 | bool MainWindow :: filterByCategory( bool val ) | 451 | bool MainWindow :: filterByCategory( bool val ) |
451 | { | 452 | { |
452 | if ( val ) | 453 | if ( val ) |
453 | { | 454 | { |
454 | if ( categoryFilter == "" ) | 455 | if ( categoryFilter == "" ) |
455 | { | 456 | { |
456 | if ( !setFilterCategory() ) | 457 | if ( !setFilterCategory() ) |
457 | return false; | 458 | return false; |
458 | } | 459 | } |
459 | 460 | ||
460 | categoryFilterEnabled = true; | 461 | categoryFilterEnabled = true; |
461 | serverSelected( -1 ); | 462 | serverSelected( -1 ); |
462 | return true; | 463 | return true; |
463 | } | 464 | } |
464 | else | 465 | else |
465 | { | 466 | { |
466 | // Turn off filter | 467 | // Turn off filter |
467 | categoryFilterEnabled = false; | 468 | categoryFilterEnabled = false; |
468 | serverSelected( -1 ); | 469 | serverSelected( -1 ); |
469 | return false; | 470 | return false; |
470 | } | 471 | } |
471 | } | 472 | } |
472 | 473 | ||
473 | void MainWindow :: raiseMainWidget() | 474 | void MainWindow :: raiseMainWidget() |
474 | { | 475 | { |
475 | stack->raiseWidget( networkPkgWindow ); | 476 | stack->raiseWidget( networkPkgWindow ); |
476 | } | 477 | } |
477 | 478 | ||
478 | void MainWindow :: raiseProgressWidget() | 479 | void MainWindow :: raiseProgressWidget() |
479 | { | 480 | { |
480 | stack->raiseWidget( progressWindow ); | 481 | stack->raiseWidget( progressWindow ); |
481 | } | 482 | } |
482 | 483 | ||
483 | void MainWindow :: enableUpgrade( bool enabled ) | 484 | void MainWindow :: enableUpgrade( bool enabled ) |
484 | { | 485 | { |
485 | actionUpgrade->setEnabled( enabled ); | 486 | actionUpgrade->setEnabled( enabled ); |
486 | } | 487 | } |
487 | 488 | ||
488 | void MainWindow :: enableDownload( bool enabled ) | 489 | void MainWindow :: enableDownload( bool enabled ) |
489 | { | 490 | { |
490 | if ( enabled ) | 491 | if ( enabled ) |
491 | { | 492 | { |
492 | actionDownload->setIconSet( iconDownload ); | 493 | actionDownload->setIconSet( iconDownload ); |
493 | actionDownload->setText( tr( "Download" ) ); | 494 | actionDownload->setText( tr( "Download" ) ); |
494 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 495 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
495 | } | 496 | } |
496 | else | 497 | else |
497 | { | 498 | { |
498 | actionDownload->setIconSet( iconRemove ); | 499 | actionDownload->setIconSet( iconRemove ); |
499 | actionDownload->setText( tr( "Remove" ) ); | 500 | actionDownload->setText( tr( "Remove" ) ); |
500 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 501 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
501 | } | 502 | } |
502 | } | 503 | } |
503 | 504 | ||
504 | void MainWindow :: setProgressSteps( int numsteps ) | 505 | void MainWindow :: setProgressSteps( int numsteps ) |
505 | { | 506 | { |
506 | m_progress->setTotalSteps( numsteps ); | 507 | m_progress->setTotalSteps( numsteps ); |
507 | } | 508 | } |
508 | 509 | ||
509 | void MainWindow :: setProgressMessage( const QString &msg ) | 510 | void MainWindow :: setProgressMessage( const QString &msg ) |
510 | { | 511 | { |
511 | m_status->setText( msg ); | 512 | m_status->setText( msg ); |
512 | } | 513 | } |
513 | 514 | ||
514 | void MainWindow :: updateProgress( int progress ) | 515 | void MainWindow :: updateProgress( int progress ) |
515 | { | 516 | { |
516 | m_progress->setProgress( progress ); | 517 | m_progress->setProgress( progress ); |
517 | } | 518 | } |
518 | 519 | ||
519 | void MainWindow :: updateData() | 520 | void MainWindow :: updateData() |
520 | { | 521 | { |
521 | m_progress->setTotalSteps( mgr->getServerList().size() ); | 522 | m_progress->setTotalSteps( mgr->getServerList().size() ); |
522 | 523 | ||
523 | serversList->clear(); | 524 | serversList->clear(); |
524 | packagesList->clear(); | 525 | packagesList->clear(); |
525 | 526 | ||
526 | vector<Server>::iterator it; | 527 | vector<Server>::iterator it; |
527 | int activeItem = -1; | 528 | int activeItem = -1; |
528 | int i; | 529 | int i; |
529 | QString serverName; | 530 | QString serverName; |