-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 7fa311d..b597e03 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,398 +1,393 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | mainwin.cpp - description | 2 | mainwin.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 13:32:30 BST 2002 | 4 | begin : Mon Aug 26 13:32:30 BST 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include <linux/limits.h> | 18 | #include <linux/limits.h> |
19 | #include <unistd.h> | 19 | #include <unistd.h> |
20 | 20 | ||
21 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
22 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | 27 | ||
28 | #include <qaction.h> | 28 | #include <qaction.h> |
29 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | #include <qmenubar.h> | 35 | #include <qmenubar.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | #include <qwhatsthis.h> | 40 | #include <qwhatsthis.h> |
41 | #include <qwidgetstack.h> | 41 | #include <qwidgetstack.h> |
42 | 42 | ||
43 | #include "categoryfilterimpl.h" | 43 | #include "categoryfilterimpl.h" |
44 | #include "datamgr.h" | 44 | #include "datamgr.h" |
45 | #include "global.h" | 45 | #include "global.h" |
46 | #include "inputdlg.h" | 46 | #include "inputdlg.h" |
47 | #include "ipkg.h" | 47 | #include "ipkg.h" |
48 | #include "installdlgimpl.h" | 48 | #include "installdlgimpl.h" |
49 | #include "letterpushbutton.h" | 49 | #include "letterpushbutton.h" |
50 | #include "mainwin.h" | 50 | #include "mainwin.h" |
51 | #include "settingsimpl.h" | 51 | #include "settingsimpl.h" |
52 | #include "utils.h" | 52 | #include "utils.h" |
53 | 53 | ||
54 | extern int compareVersions( const char *v1, const char *v2 ); | 54 | extern int compareVersions( const char *v1, const char *v2 ); |
55 | 55 | ||
56 | MainWindow :: MainWindow() | 56 | MainWindow :: MainWindow() |
57 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 57 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) |
58 | { | 58 | { |
59 | setCaption( tr( "AQPkg - Package Manager" ) ); | 59 | setCaption( tr( "AQPkg - Package Manager" ) ); |
60 | 60 | ||
61 | // Create UI widgets | 61 | // Create UI widgets |
62 | initMainWidget(); | 62 | initMainWidget(); |
63 | initProgressWidget(); | 63 | initProgressWidget(); |
64 | 64 | ||
65 | // Build menu and tool bars | 65 | // Build menu and tool bars |
66 | setToolBarsMovable( FALSE ); | 66 | setToolBarsMovable( FALSE ); |
67 | 67 | ||
68 | QPEToolBar *bar = new QPEToolBar( this ); | 68 | QPEToolBar *bar = new QPEToolBar( this ); |
69 | bar->setHorizontalStretchable( TRUE ); | 69 | bar->setHorizontalStretchable( TRUE ); |
70 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 70 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
71 | mb->setMargin( 0 ); | 71 | mb->setMargin( 0 ); |
72 | bar = new QPEToolBar( this ); | 72 | bar = new QPEToolBar( this ); |
73 | 73 | ||
74 | // Find toolbar | 74 | // Find toolbar |
75 | findBar = new QPEToolBar( this ); | 75 | findBar = new QPEToolBar( this ); |
76 | addToolBar( findBar, QMainWindow::Top, true ); | 76 | addToolBar( findBar, QMainWindow::Top, true ); |
77 | findBar->setHorizontalStretchable( true ); | 77 | findBar->setHorizontalStretchable( true ); |
78 | findEdit = new QLineEdit( findBar ); | 78 | findEdit = new QLineEdit( findBar ); |
79 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); | 79 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); |
80 | findBar->setStretchableWidget( findEdit ); | 80 | findBar->setStretchableWidget( findEdit ); |
81 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); | 81 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); |
82 | 82 | ||
83 | // Quick jump toolbar | 83 | // Quick jump toolbar |
84 | jumpBar = new QPEToolBar( this ); | 84 | jumpBar = new QPEToolBar( this ); |
85 | addToolBar( jumpBar, QMainWindow::Top, true ); | 85 | addToolBar( jumpBar, QMainWindow::Top, true ); |
86 | jumpBar->setHorizontalStretchable( true ); | 86 | jumpBar->setHorizontalStretchable( true ); |
87 | QWidget *w = new QWidget( jumpBar ); | 87 | QWidget *w = new QWidget( jumpBar ); |
88 | jumpBar->setStretchableWidget( w ); | 88 | jumpBar->setStretchableWidget( w ); |
89 | 89 | ||
90 | QGridLayout *layout = new QGridLayout( w ); | 90 | QGridLayout *layout = new QGridLayout( w ); |
91 | 91 | ||
92 | char text[2]; | 92 | char text[2]; |
93 | text[1] = '\0'; | 93 | text[1] = '\0'; |
94 | for ( int i = 0 ; i < 26 ; ++i ) | 94 | for ( int i = 0 ; i < 26 ; ++i ) |
95 | { | 95 | { |
96 | text[0] = 'A' + i; | 96 | text[0] = 'A' + i; |
97 | LetterPushButton *b = new LetterPushButton( text, w ); | 97 | LetterPushButton *b = new LetterPushButton( text, w ); |
98 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 98 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
99 | layout->addWidget( b, i / 13, i % 13); | 99 | layout->addWidget( b, i / 13, i % 13); |
100 | } | 100 | } |
101 | 101 | ||
102 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); | 102 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); |
103 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); | 103 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); |
104 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); | 104 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); |
105 | a->addTo( jumpBar ); | 105 | a->addTo( jumpBar ); |
106 | jumpBar->hide(); | 106 | jumpBar->hide(); |
107 | 107 | ||
108 | // Packages menu | 108 | // Packages menu |
109 | QPopupMenu *popup = new QPopupMenu( this ); | 109 | QPopupMenu *popup = new QPopupMenu( this ); |
110 | 110 | ||
111 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | 111 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); |
112 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 112 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
113 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); | 113 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); |
114 | a->addTo( popup ); | 114 | a->addTo( popup ); |
115 | a->addTo( bar ); | 115 | a->addTo( bar ); |
116 | 116 | ||
117 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | 117 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); |
118 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 118 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
119 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); | 119 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); |
120 | actionUpgrade->addTo( popup ); | 120 | actionUpgrade->addTo( popup ); |
121 | actionUpgrade->addTo( bar ); | 121 | actionUpgrade->addTo( bar ); |
122 | 122 | ||
123 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | 123 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); |
124 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | 124 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); |
125 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 125 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
126 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 126 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
127 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); | 127 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); |
128 | actionDownload->addTo( popup ); | 128 | actionDownload->addTo( popup ); |
129 | actionDownload->addTo( bar ); | 129 | actionDownload->addTo( bar ); |
130 | 130 | ||
131 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | 131 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); |
132 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 132 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
133 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); | 133 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); |
134 | a->addTo( popup ); | 134 | a->addTo( popup ); |
135 | a->addTo( bar ); | 135 | a->addTo( bar ); |
136 | 136 | ||
137 | popup->insertSeparator(); | ||
138 | |||
139 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | ||
140 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | ||
141 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | ||
142 | a->addTo( popup ); | ||
137 | mb->insertItem( tr( "Actions" ), popup ); | 143 | mb->insertItem( tr( "Actions" ), popup ); |
138 | 144 | ||
139 | // View menu | 145 | // View menu |
140 | popup = new QPopupMenu( this ); | 146 | popup = new QPopupMenu( this ); |
141 | 147 | ||
142 | 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 ); |
143 | actionUninstalled->setToggleAction( TRUE ); | 149 | actionUninstalled->setToggleAction( TRUE ); |
144 | 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." ) ); |
145 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | 151 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); |
146 | actionUninstalled->addTo( popup ); | 152 | actionUninstalled->addTo( popup ); |
147 | 153 | ||
148 | 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 ); |
149 | actionInstalled->setToggleAction( TRUE ); | 155 | actionInstalled->setToggleAction( TRUE ); |
150 | 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." ) ); |
151 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | 157 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); |
152 | actionInstalled->addTo( popup ); | 158 | actionInstalled->addTo( popup ); |
153 | 159 | ||
154 | 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 ); |
155 | actionUpdated->setToggleAction( TRUE ); | 161 | actionUpdated->setToggleAction( TRUE ); |
156 | 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." ) ); |
157 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); | 163 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); |
158 | actionUpdated->addTo( popup ); | 164 | actionUpdated->addTo( popup ); |
159 | 165 | ||
160 | popup->insertSeparator(); | 166 | popup->insertSeparator(); |
161 | 167 | ||
162 | 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 ); |
163 | actionFilter->setToggleAction( TRUE ); | 169 | actionFilter->setToggleAction( TRUE ); |
164 | 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." ) ); |
165 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | 171 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); |
166 | actionFilter->addTo( popup ); | 172 | actionFilter->addTo( popup ); |
167 | 173 | ||
168 | 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 ); |
169 | 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." ) ); |
170 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | 176 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); |
171 | a->addTo( popup ); | 177 | a->addTo( popup ); |
172 | 178 | ||
173 | popup->insertSeparator(); | 179 | popup->insertSeparator(); |
174 | 180 | ||
175 | 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 ); |
176 | 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." ) ); |
177 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); | 183 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); |
178 | a->addTo( popup ); | 184 | a->addTo( popup ); |
179 | 185 | ||
180 | 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 ); |
181 | actionFindNext->setEnabled( FALSE ); | 187 | actionFindNext->setEnabled( FALSE ); |
182 | 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." ) ); |
183 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); | 189 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); |
184 | actionFindNext->addTo( popup ); | 190 | actionFindNext->addTo( popup ); |
185 | actionFindNext->addTo( findBar ); | 191 | actionFindNext->addTo( findBar ); |
186 | 192 | ||
187 | 193 | ||
188 | popup->insertSeparator(); | 194 | popup->insertSeparator(); |
189 | 195 | ||
190 | 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 ); |
191 | 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." ) ); |
192 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); | 198 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); |
193 | a->addTo( popup ); | 199 | a->addTo( popup ); |
194 | 200 | ||
195 | mb->insertItem( tr( "View" ), popup ); | 201 | mb->insertItem( tr( "View" ), popup ); |
196 | |||
197 | |||
198 | // Options menu | ||
199 | popup = new QPopupMenu( this ); | ||
200 | |||
201 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | ||
202 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | ||
203 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | ||
204 | a->addTo( popup ); | ||
205 | |||
206 | mb->insertItem( tr( "Options" ), popup ); | ||
207 | 202 | ||
208 | // Finish find toolbar creation | 203 | // Finish find toolbar creation |
209 | 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 ); |
210 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 205 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
211 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 206 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
212 | a->addTo( findBar ); | 207 | a->addTo( findBar ); |
213 | findBar->hide(); | 208 | findBar->hide(); |
214 | 209 | ||
215 | // Create widget stack and add UI widgets | 210 | // Create widget stack and add UI widgets |
216 | stack = new QWidgetStack( this ); | 211 | stack = new QWidgetStack( this ); |
217 | stack->addWidget( progressWindow, 2 ); | 212 | stack->addWidget( progressWindow, 2 ); |
218 | stack->addWidget( networkPkgWindow, 1 ); | 213 | stack->addWidget( networkPkgWindow, 1 ); |
219 | setCentralWidget( stack ); | 214 | setCentralWidget( stack ); |
220 | stack->raiseWidget( progressWindow ); | 215 | stack->raiseWidget( progressWindow ); |
221 | 216 | ||
222 | // Delayed call to finish initialization | 217 | // Delayed call to finish initialization |
223 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 218 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
224 | } | 219 | } |
225 | 220 | ||
226 | MainWindow :: ~MainWindow() | 221 | MainWindow :: ~MainWindow() |
227 | { | 222 | { |
228 | delete mgr; | 223 | delete mgr; |
229 | } | 224 | } |
230 | 225 | ||
231 | void MainWindow :: initMainWidget() | 226 | void MainWindow :: initMainWidget() |
232 | { | 227 | { |
233 | networkPkgWindow = new QWidget( this ); | 228 | networkPkgWindow = new QWidget( this ); |
234 | 229 | ||
235 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 230 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
236 | 231 | ||
237 | serversList = new QComboBox( networkPkgWindow ); | 232 | serversList = new QComboBox( networkPkgWindow ); |
238 | connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); | 233 | connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); |
239 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 234 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
240 | 235 | ||
241 | installedIcon = Resource::loadPixmap( "installed" ); | 236 | installedIcon = Resource::loadPixmap( "installed" ); |
242 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 237 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); |
243 | 238 | ||
244 | packagesList = new QListView( networkPkgWindow ); | 239 | packagesList = new QListView( networkPkgWindow ); |
245 | packagesList->addColumn( tr( "Packages" ), 225 ); | 240 | packagesList->addColumn( tr( "Packages" ), 225 ); |
246 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | 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." ) ); |
247 | 242 | ||
248 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 243 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
249 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 244 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
250 | hbox1->addWidget( l ); | 245 | hbox1->addWidget( l ); |
251 | hbox1->addWidget( serversList ); | 246 | hbox1->addWidget( serversList ); |
252 | 247 | ||
253 | vbox->addWidget( packagesList ); | 248 | vbox->addWidget( packagesList ); |
254 | 249 | ||
255 | downloadEnabled = TRUE; | 250 | downloadEnabled = TRUE; |
256 | } | 251 | } |
257 | 252 | ||
258 | void MainWindow :: initProgressWidget() | 253 | void MainWindow :: initProgressWidget() |
259 | { | 254 | { |
260 | progressWindow = new QWidget( this ); | 255 | progressWindow = new QWidget( this ); |
261 | 256 | ||
262 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | 257 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); |
263 | 258 | ||
264 | m_status = new QLabel( progressWindow ); | 259 | m_status = new QLabel( progressWindow ); |
265 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 260 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
266 | layout->addWidget( m_status ); | 261 | layout->addWidget( m_status ); |
267 | 262 | ||
268 | m_progress = new QProgressBar( progressWindow ); | 263 | m_progress = new QProgressBar( progressWindow ); |
269 | layout->addWidget( m_progress ); | 264 | layout->addWidget( m_progress ); |
270 | } | 265 | } |
271 | 266 | ||
272 | void MainWindow :: init() | 267 | void MainWindow :: init() |
273 | { | 268 | { |
274 | #ifdef QWS | 269 | #ifdef QWS |
275 | // read download directory from config file | 270 | // read download directory from config file |
276 | Config cfg( "aqpkg" ); | 271 | Config cfg( "aqpkg" ); |
277 | cfg.setGroup( "settings" ); | 272 | cfg.setGroup( "settings" ); |
278 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 273 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
279 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 274 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
280 | 275 | ||
281 | #endif | 276 | #endif |
282 | 277 | ||
283 | stack->raiseWidget( progressWindow ); | 278 | stack->raiseWidget( progressWindow ); |
284 | 279 | ||
285 | mgr = new DataManager(); | 280 | mgr = new DataManager(); |
286 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); | 281 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); |
287 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 282 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), |
288 | this, SLOT( setProgressMessage( const QString & ) ) ); | 283 | this, SLOT( setProgressMessage( const QString & ) ) ); |
289 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); | 284 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); |
290 | mgr->loadServers(); | 285 | mgr->loadServers(); |
291 | 286 | ||
292 | showUninstalledPkgs = false; | 287 | showUninstalledPkgs = false; |
293 | showInstalledPkgs = false; | 288 | showInstalledPkgs = false; |
294 | showUpgradedPkgs = false; | 289 | showUpgradedPkgs = false; |
295 | categoryFilterEnabled = false; | 290 | categoryFilterEnabled = false; |
296 | 291 | ||
297 | updateData(); | 292 | updateData(); |
298 | 293 | ||
299 | stack->raiseWidget( networkPkgWindow ); | 294 | stack->raiseWidget( networkPkgWindow ); |
300 | } | 295 | } |
301 | /* | 296 | /* |
302 | void MainWindow :: setDocument( const QString &doc ) | 297 | void MainWindow :: setDocument( const QString &doc ) |
303 | { | 298 | { |
304 | // Remove path from package | 299 | // Remove path from package |
305 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 300 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
306 | // std::cout << "Selecting package " << package << std::endl; | 301 | // std::cout << "Selecting package " << package << std::endl; |
307 | 302 | ||
308 | // First select local server | 303 | // First select local server |
309 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 304 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
310 | { | 305 | { |
311 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 306 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
312 | { | 307 | { |
313 | serversList->setCurrentItem( i ); | 308 | serversList->setCurrentItem( i ); |
314 | break; | 309 | break; |
315 | } | 310 | } |
316 | } | 311 | } |
317 | serverSelected( 0 ); | 312 | serverSelected( 0 ); |
318 | 313 | ||
319 | // Now set the check box of the selected package | 314 | // Now set the check box of the selected package |
320 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 315 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
321 | item != 0 ; | 316 | item != 0 ; |
322 | item = (QCheckListItem *)item->nextSibling() ) | 317 | item = (QCheckListItem *)item->nextSibling() ) |
323 | { | 318 | { |
324 | if ( item->text().startsWith( package ) ) | 319 | if ( item->text().startsWith( package ) ) |
325 | { | 320 | { |
326 | item->setOn( true ); | 321 | item->setOn( true ); |
327 | break; | 322 | break; |
328 | } | 323 | } |
329 | } | 324 | } |
330 | } | 325 | } |
331 | */ | 326 | */ |
332 | void MainWindow :: displaySettings() | 327 | void MainWindow :: displaySettings() |
333 | { | 328 | { |
334 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 329 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
335 | if ( dlg->showDlg() ) | 330 | if ( dlg->showDlg() ) |
336 | { | 331 | { |
337 | stack->raiseWidget( progressWindow ); | 332 | stack->raiseWidget( progressWindow ); |
338 | updateData(); | 333 | updateData(); |
339 | stack->raiseWidget( networkPkgWindow ); | 334 | stack->raiseWidget( networkPkgWindow ); |
340 | } | 335 | } |
341 | delete dlg; | 336 | delete dlg; |
342 | } | 337 | } |
343 | 338 | ||
344 | void MainWindow :: closeEvent( QCloseEvent *e ) | 339 | void MainWindow :: closeEvent( QCloseEvent *e ) |
345 | { | 340 | { |
346 | // 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 |
347 | QWidget *widget = stack->visibleWidget(); | 342 | QWidget *widget = stack->visibleWidget(); |
348 | 343 | ||
349 | if ( widget != networkPkgWindow && widget != progressWindow ) | 344 | if ( widget != networkPkgWindow && widget != progressWindow ) |
350 | { | 345 | { |
351 | if ( widget ) delete widget; | 346 | if ( widget ) delete widget; |
352 | stack->raiseWidget( networkPkgWindow ); | 347 | stack->raiseWidget( networkPkgWindow ); |
353 | e->ignore(); | 348 | e->ignore(); |
354 | } | 349 | } |
355 | else | 350 | else |
356 | { | 351 | { |
357 | e->accept(); | 352 | e->accept(); |
358 | } | 353 | } |
359 | } | 354 | } |
360 | 355 | ||
361 | void MainWindow :: displayFindBar() | 356 | void MainWindow :: displayFindBar() |
362 | { | 357 | { |
363 | findBar->show(); | 358 | findBar->show(); |
364 | findEdit->setFocus(); | 359 | findEdit->setFocus(); |
365 | } | 360 | } |
366 | 361 | ||
367 | void MainWindow :: displayJumpBar() | 362 | void MainWindow :: displayJumpBar() |
368 | { | 363 | { |
369 | jumpBar->show(); | 364 | jumpBar->show(); |
370 | } | 365 | } |
371 | 366 | ||
372 | void MainWindow :: repeatFind() | 367 | void MainWindow :: repeatFind() |
373 | { | 368 | { |
374 | searchForPackage( findEdit->text() ); | 369 | searchForPackage( findEdit->text() ); |
375 | } | 370 | } |
376 | 371 | ||
377 | void MainWindow :: findPackage( const QString &text ) | 372 | void MainWindow :: findPackage( const QString &text ) |
378 | { | 373 | { |
379 | actionFindNext->setEnabled( !text.isEmpty() ); | 374 | actionFindNext->setEnabled( !text.isEmpty() ); |
380 | searchForPackage( text ); | 375 | searchForPackage( text ); |
381 | } | 376 | } |
382 | 377 | ||
383 | void MainWindow :: hideFindBar() | 378 | void MainWindow :: hideFindBar() |
384 | { | 379 | { |
385 | findBar->hide(); | 380 | findBar->hide(); |
386 | } | 381 | } |
387 | 382 | ||
388 | void MainWindow :: hideJumpBar() | 383 | void MainWindow :: hideJumpBar() |
389 | { | 384 | { |
390 | jumpBar->hide(); | 385 | jumpBar->hide(); |
391 | } | 386 | } |
392 | 387 | ||
393 | void MainWindow :: filterUninstalledPackages() | 388 | void MainWindow :: filterUninstalledPackages() |
394 | { | 389 | { |
395 | showUninstalledPkgs = actionUninstalled->isOn(); | 390 | showUninstalledPkgs = actionUninstalled->isOn(); |
396 | if ( showUninstalledPkgs ) | 391 | if ( showUninstalledPkgs ) |
397 | { | 392 | { |
398 | showInstalledPkgs = FALSE; | 393 | showInstalledPkgs = FALSE; |