Diffstat (limited to 'noncore/settings/aqpkg/mainwin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 42093cf..dbe694e 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,35 +1,35 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/limits.h> | 30 | #include <linux/limits.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | 32 | ||
33 | #include <qpe/qcopenvelope_qws.h> | 33 | #include <qpe/qcopenvelope_qws.h> |
34 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
@@ -37,67 +37,73 @@ | |||
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <qaction.h> | 40 | #include <qaction.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qlineedit.h> | 45 | #include <qlineedit.h> |
46 | #include <qlistview.h> | 46 | #include <qlistview.h> |
47 | #include <qmenubar.h> | 47 | #include <qmenubar.h> |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qpopupmenu.h> | 49 | #include <qpopupmenu.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qtimer.h> | 51 | #include <qtimer.h> |
52 | #include <qwhatsthis.h> | 52 | #include <qwhatsthis.h> |
53 | #include <qwidgetstack.h> | 53 | #include <qwidgetstack.h> |
54 | 54 | ||
55 | #include "categoryfilterimpl.h" | 55 | #include "categoryfilterimpl.h" |
56 | #include "datamgr.h" | 56 | #include "datamgr.h" |
57 | #include "global.h" | 57 | #include "global.h" |
58 | #include "inputdlg.h" | 58 | #include "inputdlg.h" |
59 | #include "ipkg.h" | 59 | #include "ipkg.h" |
60 | #include "installdlgimpl.h" | 60 | #include "installdlgimpl.h" |
61 | #include "letterpushbutton.h" | 61 | #include "letterpushbutton.h" |
62 | #include "mainwin.h" | 62 | #include "mainwin.h" |
63 | #include "packagewin.h" | 63 | #include "packagewin.h" |
64 | #include "settingsimpl.h" | 64 | #include "settingsimpl.h" |
65 | #include "utils.h" | 65 | #include "utils.h" |
66 | 66 | ||
67 | extern int compareVersions( const char *v1, const char *v2 ); | 67 | extern int compareVersions( const char *v1, const char *v2 ); |
68 | 68 | ||
69 | MainWindow :: MainWindow() | 69 | MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) |
70 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 70 | :QMainWindow( parent, name, fl || WStyle_ContextHelp ) |
71 | { | 71 | { |
72 | // Disable suspend mode | ||
73 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | ||
74 | |||
75 | LOCAL_SERVER = QObject::tr( "Installed packages" ); | ||
76 | LOCAL_IPKGS = QObject::tr( "Local packages" ); | ||
77 | |||
72 | setCaption( tr( "AQPkg - Package Manager" ) ); | 78 | setCaption( tr( "AQPkg - Package Manager" ) ); |
73 | 79 | ||
74 | // Create UI widgets | 80 | // Create UI widgets |
75 | initMainWidget(); | 81 | initMainWidget(); |
76 | initProgressWidget(); | 82 | initProgressWidget(); |
77 | 83 | ||
78 | // Build menu and tool bars | 84 | // Build menu and tool bars |
79 | setToolBarsMovable( FALSE ); | 85 | setToolBarsMovable( FALSE ); |
80 | 86 | ||
81 | QToolBar *bar = new QToolBar( this ); | 87 | QToolBar *bar = new QToolBar( this ); |
82 | bar->setHorizontalStretchable( TRUE ); | 88 | bar->setHorizontalStretchable( TRUE ); |
83 | QMenuBar *mb = new QMenuBar( bar ); | 89 | QMenuBar *mb = new QMenuBar( bar ); |
84 | mb->setMargin( 0 ); | 90 | mb->setMargin( 0 ); |
85 | bar = new QToolBar( this ); | 91 | bar = new QToolBar( this ); |
86 | 92 | ||
87 | // Find toolbar | 93 | // Find toolbar |
88 | findBar = new QToolBar( this ); | 94 | findBar = new QToolBar( this ); |
89 | addToolBar( findBar, QMainWindow::Top, true ); | 95 | addToolBar( findBar, QMainWindow::Top, true ); |
90 | findBar->setHorizontalStretchable( true ); | 96 | findBar->setHorizontalStretchable( true ); |
91 | findEdit = new QLineEdit( findBar ); | 97 | findEdit = new QLineEdit( findBar ); |
92 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); | 98 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); |
93 | findBar->setStretchableWidget( findEdit ); | 99 | findBar->setStretchableWidget( findEdit ); |
94 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); | 100 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); |
95 | 101 | ||
96 | // Quick jump toolbar | 102 | // Quick jump toolbar |
97 | jumpBar = new QToolBar( this ); | 103 | jumpBar = new QToolBar( this ); |
98 | addToolBar( jumpBar, QMainWindow::Top, true ); | 104 | addToolBar( jumpBar, QMainWindow::Top, true ); |
99 | jumpBar->setHorizontalStretchable( true ); | 105 | jumpBar->setHorizontalStretchable( true ); |
100 | QWidget *w = new QWidget( jumpBar ); | 106 | QWidget *w = new QWidget( jumpBar ); |
101 | jumpBar->setStretchableWidget( w ); | 107 | jumpBar->setStretchableWidget( w ); |
102 | 108 | ||
103 | QGridLayout *layout = new QGridLayout( w ); | 109 | QGridLayout *layout = new QGridLayout( w ); |
@@ -205,64 +211,67 @@ MainWindow :: MainWindow() | |||
205 | 211 | ||
206 | 212 | ||
207 | popup->insertSeparator(); | 213 | popup->insertSeparator(); |
208 | 214 | ||
209 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); | 215 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); |
210 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); | 216 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); |
211 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); | 217 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); |
212 | a->addTo( popup ); | 218 | a->addTo( popup ); |
213 | 219 | ||
214 | mb->insertItem( tr( "View" ), popup ); | 220 | mb->insertItem( tr( "View" ), popup ); |
215 | 221 | ||
216 | // Finish find toolbar creation | 222 | // Finish find toolbar creation |
217 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 223 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
218 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 224 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
219 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 225 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
220 | a->addTo( findBar ); | 226 | a->addTo( findBar ); |
221 | findBar->hide(); | 227 | findBar->hide(); |
222 | 228 | ||
223 | // Create widget stack and add UI widgets | 229 | // Create widget stack and add UI widgets |
224 | stack = new QWidgetStack( this ); | 230 | stack = new QWidgetStack( this ); |
225 | stack->addWidget( progressWindow, 2 ); | 231 | stack->addWidget( progressWindow, 2 ); |
226 | stack->addWidget( networkPkgWindow, 1 ); | 232 | stack->addWidget( networkPkgWindow, 1 ); |
227 | setCentralWidget( stack ); | 233 | setCentralWidget( stack ); |
228 | stack->raiseWidget( progressWindow ); | 234 | stack->raiseWidget( progressWindow ); |
229 | 235 | ||
230 | // Delayed call to finish initialization | 236 | // Delayed call to finish initialization |
231 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 237 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
232 | } | 238 | } |
233 | 239 | ||
234 | MainWindow :: ~MainWindow() | 240 | MainWindow :: ~MainWindow() |
235 | { | 241 | { |
236 | delete mgr; | 242 | delete mgr; |
243 | |||
244 | // Reenable suspend mode | ||
245 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | ||
237 | } | 246 | } |
238 | 247 | ||
239 | void MainWindow :: initMainWidget() | 248 | void MainWindow :: initMainWidget() |
240 | { | 249 | { |
241 | networkPkgWindow = new QWidget( this ); | 250 | networkPkgWindow = new QWidget( this ); |
242 | 251 | ||
243 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 252 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
244 | 253 | ||
245 | serversList = new QComboBox( networkPkgWindow ); | 254 | serversList = new QComboBox( networkPkgWindow ); |
246 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); | 255 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); |
247 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 256 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
248 | 257 | ||
249 | installedIcon = Resource::loadPixmap( "installed" ); | 258 | installedIcon = Resource::loadPixmap( "installed" ); |
250 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 259 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); |
251 | 260 | ||
252 | packagesList = new QListView( networkPkgWindow ); | 261 | packagesList = new QListView( networkPkgWindow ); |
253 | packagesList->addColumn( tr( "Packages" ), 225 ); | 262 | packagesList->addColumn( tr( "Packages" ), 225 ); |
254 | 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." ) ); | 263 | 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." ) ); |
255 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); | 264 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); |
256 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), | 265 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), |
257 | this, SLOT(slotDisplayPackage(QListViewItem *)) ); | 266 | this, SLOT(slotDisplayPackage(QListViewItem *)) ); |
258 | 267 | ||
259 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 268 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
260 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 269 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
261 | hbox1->addWidget( l ); | 270 | hbox1->addWidget( l ); |
262 | hbox1->addWidget( serversList ); | 271 | hbox1->addWidget( serversList ); |
263 | 272 | ||
264 | vbox->addWidget( packagesList ); | 273 | vbox->addWidget( packagesList ); |
265 | 274 | ||
266 | downloadEnabled = TRUE; | 275 | downloadEnabled = TRUE; |
267 | } | 276 | } |
268 | 277 | ||
@@ -983,99 +992,97 @@ void MainWindow :: applyChanges() | |||
983 | } | 992 | } |
984 | 993 | ||
985 | // decide what to do - either remove, upgrade or install | 994 | // decide what to do - either remove, upgrade or install |
986 | // Current rules: | 995 | // Current rules: |
987 | // If not installed - install | 996 | // If not installed - install |
988 | // If installed and different version available - upgrade | 997 | // If installed and different version available - upgrade |
989 | // If installed and version up to date - remove | 998 | // If installed and version up to date - remove |
990 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) | 999 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) |
991 | { | 1000 | { |
992 | QString name = item->text(); | 1001 | QString name = item->text(); |
993 | 1002 | ||
994 | // Get package | 1003 | // Get package |
995 | Server *s = mgr->getServer( serversList->currentText() ); | 1004 | Server *s = mgr->getServer( serversList->currentText() ); |
996 | Package *p = s->getPackage( name ); | 1005 | Package *p = s->getPackage( name ); |
997 | 1006 | ||
998 | // If the package has a filename then it is a local file | 1007 | // If the package has a filename then it is a local file |
999 | if ( p->isPackageStoredLocally() ) | 1008 | if ( p->isPackageStoredLocally() ) |
1000 | name = p->getFilename(); | 1009 | name = p->getFilename(); |
1001 | 1010 | ||
1002 | QString option; | 1011 | QString option; |
1003 | QString dest = "root"; | 1012 | QString dest = "root"; |
1004 | if ( !p->isInstalled() ) | 1013 | if ( !p->isInstalled() ) |
1005 | { | 1014 | { |
1006 | InstallData *newitem = new InstallData(); | 1015 | InstallData *newitem = new InstallData(); |
1007 | newitem->option = "I"; | 1016 | newitem->option = "I"; |
1008 | newitem->packageName = name; | 1017 | newitem->packageName = name; |
1009 | return newitem; | 1018 | return newitem; |
1010 | } | 1019 | } |
1011 | else | 1020 | else |
1012 | { | 1021 | { |
1013 | InstallData *newitem = new InstallData(); | 1022 | InstallData *newitem = new InstallData(); |
1014 | newitem->option = "D"; | 1023 | newitem->option = "D"; |
1015 | |||
1016 | // If local file, remove using package name, not filename | 1024 | // If local file, remove using package name, not filename |
1017 | if ( p->isPackageStoredLocally() ) | 1025 | if ( p->isPackageStoredLocally() ) |
1018 | name = item->text(); | 1026 | name = item->text(); |
1019 | 1027 | ||
1020 | if ( !p->isPackageStoredLocally() ) | 1028 | if ( !p->isPackageStoredLocally() ) |
1021 | newitem->packageName = p->getInstalledPackageName(); | 1029 | newitem->packageName = p->getInstalledPackageName(); |
1022 | else | 1030 | else |
1023 | newitem->packageName = name; | 1031 | newitem->packageName = name; |
1024 | 1032 | ||
1025 | if ( p->getInstalledTo() ) | 1033 | if ( p->getInstalledTo() ) |
1026 | { | 1034 | { |
1027 | newitem->destination = p->getInstalledTo(); | 1035 | newitem->destination = p->getInstalledTo(); |
1028 | } | 1036 | } |
1029 | else | 1037 | else |
1030 | { | 1038 | { |
1031 | newitem->destination = p->getLocalPackage()->getInstalledTo(); | 1039 | newitem->destination = p->getLocalPackage()->getInstalledTo(); |
1032 | } | 1040 | } |
1033 | 1041 | ||
1034 | // Now see if version is newer or not | 1042 | // Now see if version is newer or not |
1035 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 1043 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
1036 | 1044 | ||
1037 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 1045 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
1038 | if ( p->isPackageStoredLocally() && val == -1 ) | 1046 | if ( p->isPackageStoredLocally() && val == -1 ) |
1039 | val = 0; | 1047 | val = 0; |
1040 | 1048 | ||
1041 | if ( val == -2 ) | 1049 | if ( val == -2 ) |
1042 | { | 1050 | { |
1043 | // Error - should handle | 1051 | // Error - should handle |
1044 | } | 1052 | } |
1045 | else if ( val == -1 ) | 1053 | else if ( val == -1 ) |
1046 | { | 1054 | { |
1047 | // Version available is older - remove only | 1055 | // Version available is older - remove only |
1048 | newitem->option = "D"; | 1056 | newitem->option = "D"; |
1049 | |||
1050 | // If local file, remove using package name, not filename | 1057 | // If local file, remove using package name, not filename |
1051 | if ( p->isPackageStoredLocally() ) | 1058 | if ( p->isPackageStoredLocally() ) |
1052 | name = item->text(); | 1059 | name = item->text(); |
1053 | } | 1060 | } |
1054 | else | 1061 | else |
1055 | { | 1062 | { |
1056 | QString caption; | 1063 | QString caption; |
1057 | QString text; | 1064 | QString text; |
1058 | QString secondButton; | 1065 | QString secondButton; |
1059 | QString secondOption; | 1066 | QString secondOption; |
1060 | if ( val == 0 ) | 1067 | if ( val == 0 ) |
1061 | { | 1068 | { |
1062 | // Version available is the same - option to remove or reinstall | 1069 | // Version available is the same - option to remove or reinstall |
1063 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | 1070 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); |
1064 | text = tr( "Remove or ReInstall" ); | 1071 | text = tr( "Remove or ReInstall" ); |
1065 | secondButton = tr( "ReInstall" ); | 1072 | secondButton = tr( "ReInstall" ); |
1066 | secondOption = "R"; // Internal action code, do not translate | 1073 | secondOption = "R"; // Internal action code, do not translate |
1067 | } | 1074 | } |
1068 | else if ( val == 1 ) | 1075 | else if ( val == 1 ) |
1069 | { | 1076 | { |
1070 | // Version available is newer - option to remove or upgrade | 1077 | // Version available is newer - option to remove or upgrade |
1071 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | 1078 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); |
1072 | text = tr( "Remove or Upgrade" ); | 1079 | text = tr( "Remove or Upgrade" ); |
1073 | secondButton = tr( "Upgrade" ); | 1080 | secondButton = tr( "Upgrade" ); |
1074 | secondOption = "U"; // Internal action code, do not translate | 1081 | secondOption = "U"; // Internal action code, do not translate |
1075 | } | 1082 | } |
1076 | 1083 | ||
1077 | // Sticky option not implemented yet, but will eventually allow | 1084 | // Sticky option not implemented yet, but will eventually allow |
1078 | // the user to say something like 'remove all' | 1085 | // the user to say something like 'remove all' |
1079 | if ( stickyOption == "" ) | 1086 | if ( stickyOption == "" ) |
1080 | { | 1087 | { |
1081 | QString msgtext; | 1088 | QString msgtext; |
@@ -1160,74 +1167,74 @@ void MainWindow :: letterPushed( QString t ) | |||
1160 | else | 1167 | else |
1161 | item = (QCheckListItem *)start->nextSibling(); | 1168 | item = (QCheckListItem *)start->nextSibling(); |
1162 | 1169 | ||
1163 | if ( item == 0 ) | 1170 | if ( item == 0 ) |
1164 | item = (QCheckListItem *)packagesList->firstChild(); | 1171 | item = (QCheckListItem *)packagesList->firstChild(); |
1165 | do | 1172 | do |
1166 | { | 1173 | { |
1167 | if ( item->text().lower().startsWith( t.lower() ) ) | 1174 | if ( item->text().lower().startsWith( t.lower() ) ) |
1168 | { | 1175 | { |
1169 | packagesList->setSelected( item, true ); | 1176 | packagesList->setSelected( item, true ); |
1170 | packagesList->ensureItemVisible( item ); | 1177 | packagesList->ensureItemVisible( item ); |
1171 | break; | 1178 | break; |
1172 | } | 1179 | } |
1173 | 1180 | ||
1174 | item = (QCheckListItem *)item->nextSibling(); | 1181 | item = (QCheckListItem *)item->nextSibling(); |
1175 | if ( !item ) | 1182 | if ( !item ) |
1176 | item = (QCheckListItem *)packagesList->firstChild(); | 1183 | item = (QCheckListItem *)packagesList->firstChild(); |
1177 | } while ( item != start); | 1184 | } while ( item != start); |
1178 | } | 1185 | } |
1179 | 1186 | ||
1180 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) | 1187 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) |
1181 | { | 1188 | { |
1182 | QString itemstr( ((QCheckListItem*)item)->text() ); | 1189 | QString itemstr( ((QCheckListItem*)item)->text() ); |
1183 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); | 1190 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); |
1184 | p->showMaximized(); | 1191 | p->showMaximized(); |
1185 | } | 1192 | } |
1186 | 1193 | ||
1187 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) | 1194 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) |
1188 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) | 1195 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) |
1189 | { | 1196 | { |
1190 | setCaption( caption ); | 1197 | setCaption( caption ); |
1191 | resize( 175, 100 ); | 1198 | resize( 175, 100 ); |
1192 | 1199 | ||
1193 | QGridLayout *layout = new QGridLayout( this ); | 1200 | QGridLayout *layout = new QGridLayout( this ); |
1194 | 1201 | ||
1195 | QLabel *l = new QLabel( text, this ); | 1202 | QLabel *l = new QLabel( text, this ); |
1196 | l->setAlignment( AlignCenter | WordBreak ); | 1203 | l->setAlignment( AlignCenter | WordBreak ); |
1197 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); | 1204 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); |
1198 | 1205 | ||
1199 | btn1 = new QPushButton( tr( "Remove" ), this ); | 1206 | btn1 = new QPushButton( tr( "Remove" ), this ); |
1200 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1207 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1201 | layout->addWidget( btn1, 1, 0 ); | 1208 | layout->addWidget( btn1, 1, 0 ); |
1202 | 1209 | ||
1203 | btn2 = new QPushButton( secondbtn, this ); | 1210 | btn2 = new QPushButton( secondbtn, this ); |
1204 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1211 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1205 | layout->addWidget( btn2, 1, 1 ); | 1212 | layout->addWidget( btn2, 1, 1 ); |
1206 | 1213 | ||
1207 | executing = FALSE; | 1214 | executing = FALSE; |
1208 | } | 1215 | } |
1209 | 1216 | ||
1210 | int QuestionDlg::exec() | 1217 | int QuestionDlg::exec() |
1211 | { | 1218 | { |
1212 | show(); | 1219 | show(); |
1213 | 1220 | ||
1214 | if ( !executing ) | 1221 | if ( !executing ) |
1215 | { | 1222 | { |
1216 | executing = TRUE; | 1223 | executing = TRUE; |
1217 | qApp->enter_loop(); | 1224 | qApp->enter_loop(); |
1218 | } | 1225 | } |
1219 | 1226 | ||
1220 | return buttonpressed; | 1227 | return buttonpressed; |
1221 | } | 1228 | } |
1222 | 1229 | ||
1223 | void QuestionDlg::slotButtonPressed() | 1230 | void QuestionDlg::slotButtonPressed() |
1224 | { | 1231 | { |
1225 | if ( sender() == btn1 ) | 1232 | if ( sender() == btn1 ) |
1226 | buttonpressed = 1; | 1233 | buttonpressed = 1; |
1227 | else if ( sender() == btn2 ) | 1234 | else if ( sender() == btn2 ) |
1228 | buttonpressed = 2; | 1235 | buttonpressed = 2; |
1229 | else | 1236 | else |
1230 | buttonpressed = 0; | 1237 | buttonpressed = 0; |
1231 | 1238 | ||
1232 | qApp->exit_loop(); | 1239 | qApp->exit_loop(); |
1233 | } | 1240 | } |