-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 991cc81..807bddd 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp | |||
@@ -1,719 +1,729 @@ | |||
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) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
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 "mainwindow.h" | 30 | #include "mainwindow.h" |
31 | #include "installdlg.h" | 31 | #include "installdlg.h" |
32 | #include "filterdlg.h" | 32 | #include "filterdlg.h" |
33 | #include "promptdlg.h" | 33 | #include "promptdlg.h" |
34 | #include "entrydlg.h" | 34 | #include "entrydlg.h" |
35 | #include "packageinfodlg.h" | 35 | #include "packageinfodlg.h" |
36 | 36 | ||
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qaction.h> | 41 | #include <qaction.h> |
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
45 | #include <qmenubar.h> | 45 | #include <qmenubar.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | #include <qpopupmenu.h> | 47 | #include <qpopupmenu.h> |
48 | #include <qtimer.h> | 48 | #include <qtimer.h> |
49 | #include <qtoolbar.h> | 49 | #include <qtoolbar.h> |
50 | #include <qwhatsthis.h> | 50 | #include <qwhatsthis.h> |
51 | 51 | ||
52 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) | 52 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) |
53 | : QMainWindow( parent, name, WStyle_ContextHelp ) | 53 | : QMainWindow( parent, name, WStyle_ContextHelp ) |
54 | , m_config( "packman" ) | 54 | , m_config( "packman" ) |
55 | , m_packman( &m_config, this ) | 55 | , m_packman( &m_config, this ) |
56 | , m_menuBar( this ) | 56 | , m_menuBar( this ) |
57 | , m_toolBar( this ) | 57 | , m_toolBar( this ) |
58 | , m_findBar( this ) | 58 | , m_findBar( this ) |
59 | , m_widgetStack( this ) | 59 | , m_widgetStack( this ) |
60 | , m_packageList( this ) | 60 | , m_packageList( this ) |
61 | , m_statusWidget( this ) | 61 | , m_statusWidget( this ) |
62 | , m_statusText( &m_statusWidget ) | 62 | , m_statusText( &m_statusWidget ) |
63 | , m_statusBar( &m_statusWidget ) | 63 | , m_statusBar( &m_statusWidget ) |
64 | , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) | 64 | , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) |
65 | , m_iconInstalled( Resource::loadPixmap( "installed" ) ) | 65 | , m_iconInstalled( Resource::loadPixmap( "installed" ) ) |
66 | , m_iconNull( m_iconUpdated.size() ) | 66 | , m_iconNull( m_iconUpdated.size() ) |
67 | , m_filterName( QString::null ) | 67 | , m_filterName( QString::null ) |
68 | , m_filterServer( QString::null ) | 68 | , m_filterServer( QString::null ) |
69 | , m_filterDest( QString::null ) | 69 | , m_filterDest( QString::null ) |
70 | , m_filterStatus( OPackageManager::NotDefined ) | 70 | , m_filterStatus( OPackageManager::NotDefined ) |
71 | , m_filterCategory( QString::null ) | 71 | , m_filterCategory( QString::null ) |
72 | 72 | ||
73 | { | 73 | { |
74 | // setCaption( tr( "Package Manager" ) ); | 74 | // setCaption( tr( "Package Manager" ) ); |
75 | 75 | ||
76 | m_iconNull.fill( colorGroup().base() ); | 76 | m_iconNull.fill( colorGroup().base() ); |
77 | 77 | ||
78 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); | 78 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); |
79 | 79 | ||
80 | // Initialize widget stack, package list and status widget | 80 | // Initialize widget stack, package list and status widget |
81 | initStatusWidget(); | 81 | initStatusWidget(); |
82 | initPackageList(); | 82 | initPackageList(); |
83 | 83 | ||
84 | m_widgetStack.addWidget( &m_statusWidget, 2 ); | 84 | m_widgetStack.addWidget( &m_statusWidget, 2 ); |
85 | m_widgetStack.addWidget( &m_packageList, 1 ); | 85 | m_widgetStack.addWidget( &m_packageList, 1 ); |
86 | setCentralWidget( &m_widgetStack ); | 86 | setCentralWidget( &m_widgetStack ); |
87 | 87 | ||
88 | // Initialize remaining user interface items | 88 | // Initialize remaining user interface items |
89 | initUI(); | 89 | initUI(); |
90 | 90 | ||
91 | // Initialize package information | 91 | // Initialize package information |
92 | QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); | 92 | QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); |
93 | } | 93 | } |
94 | 94 | ||
95 | void MainWindow::closeEvent( QCloseEvent *event ) | 95 | void MainWindow::closeEvent( QCloseEvent *event ) |
96 | { | 96 | { |
97 | // Close app only if either the package or status widgets are currently active | 97 | // Close app only if either the package or status widgets are currently active |
98 | bool close = m_widgetStack.visibleWidget() == &m_packageList || | 98 | bool close = m_widgetStack.visibleWidget() == &m_packageList || |
99 | m_widgetStack.visibleWidget() == &m_statusWidget; | 99 | m_widgetStack.visibleWidget() == &m_statusWidget; |
100 | if ( close ) | 100 | if ( close ) |
101 | { | 101 | { |
102 | // TODO - write out application configuration settings | 102 | // TODO - write out application configuration settings |
103 | 103 | ||
104 | // Write out package manager configuration settings | 104 | // Write out package manager configuration settings |
105 | m_packman.saveSettings(); | 105 | m_packman.saveSettings(); |
106 | event->accept(); | 106 | event->accept(); |
107 | } | 107 | } |
108 | else | 108 | else |
109 | { | 109 | { |
110 | delete m_widgetStack.visibleWidget(); | 110 | delete m_widgetStack.visibleWidget(); |
111 | m_widgetStack.raiseWidget( &m_packageList ); | 111 | m_widgetStack.raiseWidget( &m_packageList ); |
112 | event->ignore(); | 112 | event->ignore(); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | void MainWindow::initPackageList() | 116 | void MainWindow::initPackageList() |
117 | { | 117 | { |
118 | m_packageList.addColumn( tr( "Packages" ) ); | 118 | m_packageList.addColumn( tr( "Packages" ) ); |
119 | QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\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\nTap inside the box at the left to select a package. Tap and hold to view package details." ) ); | 119 | QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\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\nTap inside the box at the left to select a package. Tap and hold to view package details." ) ); |
120 | QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); | 120 | QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); |
121 | connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), | 121 | connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), |
122 | this, SLOT(slotDisplayPackageInfo(QListViewItem*)) ); | 122 | this, SLOT(slotDisplayPackageInfo(QListViewItem*)) ); |
123 | } | 123 | } |
124 | 124 | ||
125 | void MainWindow::initStatusWidget() | 125 | void MainWindow::initStatusWidget() |
126 | { | 126 | { |
127 | QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); | 127 | QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); |
128 | 128 | ||
129 | m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 129 | m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
130 | layout->addWidget( &m_statusText ); | 130 | layout->addWidget( &m_statusText ); |
131 | 131 | ||
132 | connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); | 132 | connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); |
133 | connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) ); | 133 | connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) ); |
134 | connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); | 134 | connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); |
135 | 135 | ||
136 | layout->addWidget( &m_statusBar ); | 136 | layout->addWidget( &m_statusBar ); |
137 | } | 137 | } |
138 | 138 | ||
139 | void MainWindow::initUI() | 139 | void MainWindow::initUI() |
140 | { | 140 | { |
141 | // Build menu and tool bars | 141 | // Build menu and tool bars |
142 | setToolBarsMovable( false ); | 142 | setToolBarsMovable( false ); |
143 | 143 | ||
144 | m_menuBar.setHorizontalStretchable( true ); | 144 | m_menuBar.setHorizontalStretchable( true ); |
145 | QMenuBar *mb = new QMenuBar( &m_menuBar ); | 145 | QMenuBar *mb = new QMenuBar( &m_menuBar ); |
146 | mb->setMargin( 0 ); | 146 | mb->setMargin( 0 ); |
147 | 147 | ||
148 | // Find toolbar | 148 | // Find toolbar |
149 | addToolBar( &m_findBar, QMainWindow::Top, true ); | 149 | addToolBar( &m_findBar, QMainWindow::Top, true ); |
150 | m_findBar.setHorizontalStretchable( true ); | 150 | m_findBar.setHorizontalStretchable( true ); |
151 | m_findEdit = new QLineEdit( &m_findBar ); | 151 | m_findEdit = new QLineEdit( &m_findBar ); |
152 | QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); | 152 | QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); |
153 | m_findBar.setStretchableWidget( m_findEdit ); | 153 | m_findBar.setStretchableWidget( m_findEdit ); |
154 | connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); | 154 | connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); |
155 | 155 | ||
156 | // Packages menu | 156 | // Packages menu |
157 | QPopupMenu *popup = new QPopupMenu( this ); | 157 | QPopupMenu *popup = new QPopupMenu( this ); |
158 | 158 | ||
159 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); | 159 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); |
160 | a->setWhatsThis( tr( "Tap here to update package lists from servers." ) ); | 160 | a->setWhatsThis( tr( "Tap here to update package lists from servers." ) ); |
161 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); | 161 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); |
162 | a->addTo( popup ); | 162 | a->addTo( popup ); |
163 | a->addTo( &m_toolBar ); | 163 | a->addTo( &m_toolBar ); |
164 | 164 | ||
165 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); | 165 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); |
166 | actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) ); | 166 | actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) ); |
167 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); | 167 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); |
168 | actionUpgrade->addTo( popup ); | 168 | actionUpgrade->addTo( popup ); |
169 | actionUpgrade->addTo( &m_toolBar ); | 169 | actionUpgrade->addTo( &m_toolBar ); |
170 | 170 | ||
171 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); | 171 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); |
172 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); | 172 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); |
173 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 173 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
174 | actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) ); | 174 | actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) ); |
175 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); | 175 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); |
176 | actionDownload->addTo( popup ); | 176 | actionDownload->addTo( popup ); |
177 | actionDownload->addTo( &m_toolBar ); | 177 | actionDownload->addTo( &m_toolBar ); |
178 | 178 | ||
179 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); | 179 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); |
180 | a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) ); | 180 | a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) ); |
181 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); | 181 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); |
182 | a->addTo( popup ); | 182 | a->addTo( popup ); |
183 | a->addTo( &m_toolBar ); | 183 | a->addTo( &m_toolBar ); |
184 | 184 | ||
185 | popup->insertSeparator(); | 185 | popup->insertSeparator(); |
186 | 186 | ||
187 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 187 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
188 | a->setWhatsThis( tr( "Tap here to configure this application." ) ); | 188 | a->setWhatsThis( tr( "Tap here to configure this application." ) ); |
189 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); | 189 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); |
190 | a->addTo( popup ); | 190 | a->addTo( popup ); |
191 | mb->insertItem( tr( "Actions" ), popup ); | 191 | mb->insertItem( tr( "Actions" ), popup ); |
192 | 192 | ||
193 | // View menu | 193 | // View menu |
194 | popup = new QPopupMenu( this ); | 194 | popup = new QPopupMenu( this ); |
195 | 195 | ||
196 | m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 196 | m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
197 | m_actionShowNotInstalled->setToggleAction( true ); | 197 | m_actionShowNotInstalled->setToggleAction( true ); |
198 | m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) ); | 198 | m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) ); |
199 | connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); | 199 | connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); |
200 | m_actionShowNotInstalled->addTo( popup ); | 200 | m_actionShowNotInstalled->addTo( popup ); |
201 | 201 | ||
202 | m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 202 | m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
203 | m_actionShowInstalled->setToggleAction( true ); | 203 | m_actionShowInstalled->setToggleAction( true ); |
204 | m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) ); | 204 | m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) ); |
205 | connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); | 205 | connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); |
206 | m_actionShowInstalled->addTo( popup ); | 206 | m_actionShowInstalled->addTo( popup ); |
207 | 207 | ||
208 | m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 208 | m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
209 | m_actionShowUpdated->setToggleAction( true ); | 209 | m_actionShowUpdated->setToggleAction( true ); |
210 | m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) ); | 210 | m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) ); |
211 | connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); | 211 | connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); |
212 | m_actionShowUpdated->addTo( popup ); | 212 | m_actionShowUpdated->addTo( popup ); |
213 | 213 | ||
214 | popup->insertSeparator(); | 214 | popup->insertSeparator(); |
215 | 215 | ||
216 | m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), | 216 | m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), |
217 | QString::null, 0, this, 0 ); | 217 | QString::null, 0, this, 0 ); |
218 | m_actionFilter->setToggleAction( true ); | 218 | m_actionFilter->setToggleAction( true ); |
219 | m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) ); | 219 | m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) ); |
220 | connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); | 220 | connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); |
221 | m_actionFilter->addTo( popup ); | 221 | m_actionFilter->addTo( popup ); |
222 | 222 | ||
223 | a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); | 223 | a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); |
224 | a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) ); | 224 | a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) ); |
225 | connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); | 225 | connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); |
226 | a->addTo( popup ); | 226 | a->addTo( popup ); |
227 | 227 | ||
228 | popup->insertSeparator(); | 228 | popup->insertSeparator(); |
229 | 229 | ||
230 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 230 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
231 | a->setWhatsThis( tr( "Tap here to search for text in package names." ) ); | 231 | a->setWhatsThis( tr( "Tap here to search for text in package names." ) ); |
232 | connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); | 232 | connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); |
233 | a->addTo( popup ); | 233 | a->addTo( popup ); |
234 | 234 | ||
235 | m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 235 | m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
236 | m_actionFindNext->setEnabled( false ); | 236 | m_actionFindNext->setEnabled( false ); |
237 | m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) ); | 237 | m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) ); |
238 | connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); | 238 | connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); |
239 | m_actionFindNext->addTo( popup ); | 239 | m_actionFindNext->addTo( popup ); |
240 | m_actionFindNext->addTo( &m_findBar ); | 240 | m_actionFindNext->addTo( &m_findBar ); |
241 | 241 | ||
242 | mb->insertItem( tr( "View" ), popup ); | 242 | mb->insertItem( tr( "View" ), popup ); |
243 | 243 | ||
244 | // Finish find toolbar creation | 244 | // Finish find toolbar creation |
245 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 245 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
246 | a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) ); | 246 | a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) ); |
247 | connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); | 247 | connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); |
248 | a->addTo( &m_findBar ); | 248 | a->addTo( &m_findBar ); |
249 | m_findBar.hide(); | 249 | m_findBar.hide(); |
250 | } | 250 | } |
251 | 251 | ||
252 | void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) | 252 | void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) |
253 | { | 253 | { |
254 | if ( clearList ) | 254 | if ( clearList ) |
255 | m_packageList.clear(); | 255 | m_packageList.clear(); |
256 | 256 | ||
257 | if ( packages ) | 257 | if ( packages ) |
258 | { | 258 | { |
259 | for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) | 259 | for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) |
260 | { | 260 | { |
261 | OPackage *package = packageIt.current(); | 261 | OPackage *package = packageIt.current(); |
262 | QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), | 262 | QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), |
263 | QCheckListItem::CheckBox ); | 263 | QCheckListItem::CheckBox ); |
264 | m_packageList.insertItem( item ); | 264 | m_packageList.insertItem( item ); |
265 | 265 | ||
266 | // If a different version of package is available, show update available icon | 266 | // If a different version of package is available, show update available icon |
267 | // Otherwise, show installed icon | 267 | // Otherwise, show installed icon |
268 | if ( !package->versionInstalled().isNull() ) | 268 | if ( !package->versionInstalled().isNull() ) |
269 | { | 269 | { |
270 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) | 270 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) |
271 | item->setPixmap( 0, m_iconUpdated ); | 271 | item->setPixmap( 0, m_iconUpdated ); |
272 | else | 272 | else |
273 | item->setPixmap( 0, m_iconInstalled ); | 273 | item->setPixmap( 0, m_iconInstalled ); |
274 | } | 274 | } |
275 | else | 275 | else |
276 | item->setPixmap( 0, m_iconNull ); | 276 | item->setPixmap( 0, m_iconNull ); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | void MainWindow::searchForPackage( const QString &text ) | 281 | void MainWindow::searchForPackage( const QString &text ) |
282 | { | 282 | { |
283 | if ( !text.isEmpty() ) | 283 | if ( !text.isEmpty() ) |
284 | { | 284 | { |
285 | // look through package list for text startng at current position | 285 | // look through package list for text startng at current position |
286 | QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); | 286 | QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); |
287 | if ( start == 0 ) | 287 | if ( start == 0 ) |
288 | start = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 288 | start = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
289 | 289 | ||
290 | // for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; | 290 | // for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; |
291 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; | 291 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; |
292 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 292 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
293 | { | 293 | { |
294 | if ( item->text().lower().find( text ) != -1 ) | 294 | if ( item->text().lower().find( text ) != -1 ) |
295 | { | 295 | { |
296 | m_packageList.ensureItemVisible( item ); | 296 | m_packageList.ensureItemVisible( item ); |
297 | m_packageList.setCurrentItem( item ); | 297 | m_packageList.setCurrentItem( item ); |
298 | break; | 298 | break; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | void MainWindow::initPackageInfo() | 304 | void MainWindow::initPackageInfo() |
305 | { | 305 | { |
306 | m_widgetStack.raiseWidget( &m_statusWidget ); | 306 | m_widgetStack.raiseWidget( &m_statusWidget ); |
307 | 307 | ||
308 | // Load package list | 308 | // Load package list |
309 | m_packman.loadAvailablePackages(); | 309 | m_packman.loadAvailablePackages(); |
310 | m_packman.loadInstalledPackages(); | 310 | m_packman.loadInstalledPackages(); |
311 | 311 | ||
312 | OPackageList *packageList = m_packman.packages(); | 312 | OPackageList *packageList = m_packman.packages(); |
313 | if ( packageList ) | 313 | if ( packageList ) |
314 | { | 314 | { |
315 | loadPackageList( packageList, true ); | 315 | loadPackageList( packageList, true ); |
316 | delete packageList; | 316 | delete packageList; |
317 | } | 317 | } |
318 | 318 | ||
319 | m_widgetStack.raiseWidget( &m_packageList ); | 319 | m_widgetStack.raiseWidget( &m_packageList ); |
320 | } | 320 | } |
321 | 321 | ||
322 | void MainWindow::slotWidgetStackShow( QWidget *widget ) | 322 | void MainWindow::slotWidgetStackShow( QWidget *widget ) |
323 | { | 323 | { |
324 | if ( widget == &m_packageList ) | 324 | if ( widget == &m_packageList ) |
325 | { | 325 | { |
326 | setCaption( tr( "Package Manager" ) ); | 326 | setCaption( tr( "Package Manager" ) ); |
327 | 327 | ||
328 | m_menuBar.show(); | 328 | m_menuBar.show(); |
329 | m_toolBar.show(); | 329 | m_toolBar.show(); |
330 | } | 330 | } |
331 | else | 331 | else |
332 | { | 332 | { |
333 | m_menuBar.hide(); | 333 | m_menuBar.hide(); |
334 | m_toolBar.hide(); | 334 | m_toolBar.hide(); |
335 | } | 335 | } |
336 | } | 336 | } |
337 | 337 | ||
338 | void MainWindow::slotInitStatusBar( int numSteps ) | 338 | void MainWindow::slotInitStatusBar( int numSteps ) |
339 | { | 339 | { |
340 | m_statusBar.setTotalSteps( numSteps ); | 340 | m_statusBar.setTotalSteps( numSteps ); |
341 | } | 341 | } |
342 | 342 | ||
343 | void MainWindow::slotStatusText( const QString &status ) | 343 | void MainWindow::slotStatusText( const QString &status ) |
344 | { | 344 | { |
345 | m_statusText.setText( status ); | 345 | m_statusText.setText( status ); |
346 | } | 346 | } |
347 | 347 | ||
348 | void MainWindow::slotStatusBar( int currStep ) | 348 | void MainWindow::slotStatusBar( int currStep ) |
349 | { | 349 | { |
350 | m_statusBar.setProgress( currStep ); | 350 | m_statusBar.setProgress( currStep ); |
351 | } | 351 | } |
352 | 352 | ||
353 | void MainWindow::slotUpdate() | 353 | void MainWindow::slotUpdate() |
354 | { | 354 | { |
355 | // Create package manager output widget | 355 | // Create package manager output widget |
356 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, | 356 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, |
357 | OPackage::Update ); | 357 | OPackage::Update ); |
358 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 358 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
359 | 359 | ||
360 | // Display widget | 360 | // Display widget |
361 | m_widgetStack.addWidget( dlg, 3 ); | 361 | m_widgetStack.addWidget( dlg, 3 ); |
362 | m_widgetStack.raiseWidget( dlg ); | 362 | m_widgetStack.raiseWidget( dlg ); |
363 | } | 363 | } |
364 | 364 | ||
365 | void MainWindow::slotUpgrade() | 365 | void MainWindow::slotUpgrade() |
366 | { | 366 | { |
367 | // Create package manager output widget | 367 | // Create package manager output widget |
368 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, | 368 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, |
369 | OPackage::Upgrade ); | 369 | OPackage::Upgrade ); |
370 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 370 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
371 | 371 | ||
372 | // Display widget | 372 | // Display widget |
373 | m_widgetStack.addWidget( dlg, 3 ); | 373 | m_widgetStack.addWidget( dlg, 3 ); |
374 | m_widgetStack.raiseWidget( dlg ); | 374 | m_widgetStack.raiseWidget( dlg ); |
375 | } | 375 | } |
376 | 376 | ||
377 | void MainWindow::slotDownload() | 377 | void MainWindow::slotDownload() |
378 | { | 378 | { |
379 | // Retrieve list of packages selected for download (if any) | 379 | // Retrieve list of packages selected for download (if any) |
380 | QStringList *workingPackages = new QStringList(); | 380 | QStringList *workingPackages = new QStringList(); |
381 | 381 | ||
382 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 382 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
383 | item != 0 ; | 383 | item != 0 ; |
384 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 384 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
385 | { | 385 | { |
386 | if ( item->isOn() ) | 386 | if ( item->isOn() ) |
387 | workingPackages->append( item->text() ); | 387 | workingPackages->append( item->text() ); |
388 | } | 388 | } |
389 | 389 | ||
390 | if ( workingPackages->isEmpty() ) | 390 | if ( workingPackages->isEmpty() ) |
391 | { | 391 | { |
392 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); | 392 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); |
393 | return; | 393 | return; |
394 | } | 394 | } |
395 | else | 395 | else |
396 | { | 396 | { |
397 | // Download selected packages | 397 | // Download selected packages |
398 | m_config.setGroup( "settings" ); | 398 | m_config.setGroup( "settings" ); |
399 | QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); | 399 | QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); |
400 | 400 | ||
401 | bool ok = false; | 401 | bool ok = false; |
402 | QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); | 402 | QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); |
403 | if ( ok && !text.isEmpty() ) | 403 | if ( ok && !text.isEmpty() ) |
404 | workingDir = text; // user entered something and pressed ok | 404 | workingDir = text; // user entered something and pressed ok |
405 | else | 405 | else |
406 | return; // user entered nothing or pressed cancel | 406 | return; // user entered nothing or pressed cancel |
407 | 407 | ||
408 | // Store download directory in config file | 408 | // Store download directory in config file |
409 | m_config.writeEntry( "DownloadDir", workingDir ); | 409 | m_config.writeEntry( "DownloadDir", workingDir ); |
410 | 410 | ||
411 | // Get starting directory | 411 | // Get starting directory |
412 | QDir::setCurrent( workingDir ); | 412 | QDir::setCurrent( workingDir ); |
413 | 413 | ||
414 | // Create package manager output widget | 414 | // Create package manager output widget |
415 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, | 415 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, |
416 | OPackage::Download, workingPackages ); | 416 | OPackage::Download, workingPackages ); |
417 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 417 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
418 | 418 | ||
419 | // Display widget | 419 | // Display widget |
420 | m_widgetStack.addWidget( dlg, 3 ); | 420 | m_widgetStack.addWidget( dlg, 3 ); |
421 | m_widgetStack.raiseWidget( dlg ); | 421 | m_widgetStack.raiseWidget( dlg ); |
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | void MainWindow::slotApply() | 425 | void MainWindow::slotApply() |
426 | { | 426 | { |
427 | QStringList *removeList = 0x0; | 427 | QStringList *removeList = 0x0; |
428 | QStringList *installList = 0x0; | 428 | QStringList *installList = 0x0; |
429 | QStringList *upgradeList = 0x0; | 429 | QStringList *upgradeList = 0x0; |
430 | 430 | ||
431 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 431 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
432 | item != 0 ; | 432 | item != 0 ; |
433 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 433 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
434 | { | 434 | { |
435 | if ( item->isOn() ) | 435 | if ( item->isOn() ) |
436 | { | 436 | { |
437 | OPackage *package = m_packman.findPackage( item->text() ); | 437 | OPackage *package = m_packman.findPackage( item->text() ); |
438 | if ( package ) | 438 | if ( package ) |
439 | { | 439 | { |
440 | if ( !package->versionInstalled().isNull() ) | 440 | if ( !package->versionInstalled().isNull() ) |
441 | { | 441 | { |
442 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) | 442 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) |
443 | { | 443 | { |
444 | // Remove/upgrade package | 444 | // Remove/upgrade package |
445 | int answer = PromptDlg::ask( tr( "Remove or upgrade" ), | 445 | int answer = PromptDlg::ask( tr( "Remove or upgrade" ), |
446 | tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), | 446 | tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), |
447 | tr( "Remove" ), tr( "Upgrade" ), this ); | 447 | tr( "Remove" ), tr( "Upgrade" ), this ); |
448 | if ( answer == 1 ) // Remove | 448 | if ( answer == 1 ) // Remove |
449 | { | 449 | { |
450 | if ( !removeList ) | 450 | if ( !removeList ) |
451 | removeList = new QStringList(); | 451 | removeList = new QStringList(); |
452 | removeList->append( item->text() ); | 452 | removeList->append( item->text() ); |
453 | } | 453 | } |
454 | else if ( answer == 2 ) // Upgrade | 454 | else if ( answer == 2 ) // Upgrade |
455 | { | 455 | { |
456 | if ( !upgradeList ) | 456 | if ( !upgradeList ) |
457 | upgradeList = new QStringList(); | 457 | upgradeList = new QStringList(); |
458 | upgradeList->append( item->text() ); | 458 | upgradeList->append( item->text() ); |
459 | } | 459 | } |
460 | } | 460 | } |
461 | else | 461 | else |
462 | { | 462 | { |
463 | // Remove/reinstall package | 463 | // Remove/reinstall package |
464 | int answer = PromptDlg::ask( tr( "Remove or reinstall" ), | 464 | int answer = PromptDlg::ask( tr( "Remove or reinstall" ), |
465 | tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), | 465 | tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), |
466 | tr( "Remove" ), tr( "Reinstall" ), this ); | 466 | tr( "Remove" ), tr( "Reinstall" ), this ); |
467 | if ( answer == 1 ) // Remove | 467 | if ( answer == 1 ) // Remove |
468 | { | 468 | { |
469 | if ( !removeList ) | 469 | if ( !removeList ) |
470 | removeList = new QStringList(); | 470 | removeList = new QStringList(); |
471 | removeList->append( item->text() ); | 471 | removeList->append( item->text() ); |
472 | } | 472 | } |
473 | else if ( answer == 2 ) // Reinstall | 473 | else if ( answer == 2 ) // Reinstall |
474 | { | 474 | { |
475 | if ( !installList ) | 475 | if ( !installList ) |
476 | installList = new QStringList(); | 476 | installList = new QStringList(); |
477 | installList->append( item->text() ); | 477 | installList->append( item->text() ); |
478 | } | 478 | } |
479 | } | 479 | } |
480 | } | 480 | } |
481 | else | 481 | else |
482 | { | 482 | { |
483 | // Install package | 483 | // Install package |
484 | if ( !installList ) | 484 | if ( !installList ) |
485 | installList = new QStringList(); | 485 | installList = new QStringList(); |
486 | installList->append( item->text() ); | 486 | installList->append( item->text() ); |
487 | } | 487 | } |
488 | } | 488 | } |
489 | } | 489 | } |
490 | } | 490 | } |
491 | 491 | ||
492 | // If nothing is selected, display message and exit | 492 | // If nothing is selected, display message and exit |
493 | if ( !removeList && !installList && !upgradeList ) | 493 | if ( !removeList && !installList && !upgradeList ) |
494 | { | 494 | { |
495 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); | 495 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); |
496 | return; | 496 | return; |
497 | } | 497 | } |
498 | 498 | ||
499 | // Send command only if there are packages to process | 499 | // Send command only if there are packages to process |
500 | OPackage::Command removeCmd = OPackage::NotDefined; | 500 | OPackage::Command removeCmd = OPackage::NotDefined; |
501 | if ( removeList && !removeList->isEmpty() ) | 501 | if ( removeList && !removeList->isEmpty() ) |
502 | removeCmd = OPackage::Remove; | 502 | removeCmd = OPackage::Remove; |
503 | OPackage::Command installCmd = OPackage::NotDefined; | 503 | OPackage::Command installCmd = OPackage::NotDefined; |
504 | if ( installList && !installList->isEmpty() ) | 504 | if ( installList && !installList->isEmpty() ) |
505 | installCmd = OPackage::Install; | 505 | installCmd = OPackage::Install; |
506 | OPackage::Command upgradeCmd = OPackage::NotDefined; | 506 | OPackage::Command upgradeCmd = OPackage::NotDefined; |
507 | if ( upgradeList && !upgradeList->isEmpty() ) | 507 | if ( upgradeList && !upgradeList->isEmpty() ) |
508 | upgradeCmd = OPackage::Upgrade; | 508 | upgradeCmd = OPackage::Upgrade; |
509 | 509 | ||
510 | // Create package manager output widget | 510 | // Create package manager output widget |
511 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, | 511 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, |
512 | removeCmd, removeList, | 512 | removeCmd, removeList, |
513 | installCmd, installList, | 513 | installCmd, installList, |
514 | upgradeCmd, upgradeList ); | 514 | upgradeCmd, upgradeList ); |
515 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 515 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
516 | 516 | ||
517 | // Display widget | 517 | // Display widget |
518 | m_widgetStack.addWidget( dlg, 3 ); | 518 | m_widgetStack.addWidget( dlg, 3 ); |
519 | m_widgetStack.raiseWidget( dlg ); | 519 | m_widgetStack.raiseWidget( dlg ); |
520 | } | 520 | } |
521 | 521 | ||
522 | void MainWindow::slotCloseDlg() | 522 | void MainWindow::slotCloseDlg() |
523 | { | 523 | { |
524 | // Close install dialog | 524 | // Close install dialog |
525 | delete m_widgetStack.visibleWidget(); | 525 | delete m_widgetStack.visibleWidget(); |
526 | 526 | ||
527 | // Reload package list | 527 | // Reload package list |
528 | initPackageInfo(); | 528 | initPackageInfo(); |
529 | 529 | ||
530 | // Update Opie launcher links | 530 | // Update Opie launcher links |
531 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 531 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
532 | QString lf = QString::null; | 532 | QString lf = QString::null; |
533 | e << lf; | 533 | e << lf; |
534 | |||
535 | // Reapply any filters previously set | ||
536 | if ( m_actionShowNotInstalled->isOn() ) | ||
537 | slotShowNotInstalled(); | ||
538 | else if ( m_actionShowInstalled->isOn() ) | ||
539 | slotShowInstalled(); | ||
540 | else if ( m_actionShowUpdated->isOn() ) | ||
541 | slotShowUpdated(); | ||
542 | else if ( m_actionFilter->isOn() ) | ||
543 | slotFilter( true ); | ||
534 | } | 544 | } |
535 | 545 | ||
536 | void MainWindow::slotConfigure() | 546 | void MainWindow::slotConfigure() |
537 | { | 547 | { |
538 | if ( m_packman.configureDlg( false ) ) | 548 | if ( m_packman.configureDlg( false ) ) |
539 | { | 549 | { |
540 | if ( PromptDlg::ask( tr( "Config updated" ), | 550 | if ( PromptDlg::ask( tr( "Config updated" ), |
541 | tr( "The configuration has been updated. Do you want to update server and package information now?" ), | 551 | tr( "The configuration has been updated. Do you want to update server and package information now?" ), |
542 | tr( "Yes" ), tr( "No" ), this ) == 1 ) | 552 | tr( "Yes" ), tr( "No" ), this ) == 1 ) |
543 | { | 553 | { |
544 | // Update package list and reload package info | 554 | // Update package list and reload package info |
545 | slotUpdate(); | 555 | slotUpdate(); |
546 | } | 556 | } |
547 | } | 557 | } |
548 | } | 558 | } |
549 | 559 | ||
550 | void MainWindow::slotShowNotInstalled() | 560 | void MainWindow::slotShowNotInstalled() |
551 | { | 561 | { |
552 | OPackageList *packageList; | 562 | OPackageList *packageList; |
553 | if ( m_actionShowNotInstalled->isOn() ) | 563 | if ( m_actionShowNotInstalled->isOn() ) |
554 | { | 564 | { |
555 | m_actionShowInstalled->setOn( false ); | 565 | m_actionShowInstalled->setOn( false ); |
556 | m_actionShowUpdated->setOn( false ); | 566 | m_actionShowUpdated->setOn( false ); |
557 | m_actionFilter->setOn( false ); | 567 | m_actionFilter->setOn( false ); |
558 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, | 568 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, |
559 | OPackageManager::NotInstalled, QString::null ); | 569 | OPackageManager::NotInstalled, QString::null ); |
560 | } | 570 | } |
561 | else | 571 | else |
562 | packageList = m_packman.packages(); | 572 | packageList = m_packman.packages(); |
563 | 573 | ||
564 | if ( packageList ) | 574 | if ( packageList ) |
565 | { | 575 | { |
566 | loadPackageList( packageList, true ); | 576 | loadPackageList( packageList, true ); |
567 | delete packageList; | 577 | delete packageList; |
568 | } | 578 | } |
569 | } | 579 | } |
570 | 580 | ||
571 | void MainWindow::slotShowInstalled() | 581 | void MainWindow::slotShowInstalled() |
572 | { | 582 | { |
573 | OPackageList *packageList; | 583 | OPackageList *packageList; |
574 | if ( m_actionShowInstalled->isOn() ) | 584 | if ( m_actionShowInstalled->isOn() ) |
575 | { | 585 | { |
576 | m_actionShowNotInstalled->setOn( false ); | 586 | m_actionShowNotInstalled->setOn( false ); |
577 | m_actionShowUpdated->setOn( false ); | 587 | m_actionShowUpdated->setOn( false ); |
578 | m_actionFilter->setOn( false ); | 588 | m_actionFilter->setOn( false ); |
579 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, | 589 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, |
580 | OPackageManager::Installed, QString::null ); | 590 | OPackageManager::Installed, QString::null ); |
581 | } | 591 | } |
582 | else | 592 | else |
583 | packageList = m_packman.packages(); | 593 | packageList = m_packman.packages(); |
584 | 594 | ||
585 | if ( packageList ) | 595 | if ( packageList ) |
586 | { | 596 | { |
587 | loadPackageList( packageList, true ); | 597 | loadPackageList( packageList, true ); |
588 | delete packageList; | 598 | delete packageList; |
589 | } | 599 | } |
590 | } | 600 | } |
591 | 601 | ||
592 | void MainWindow::slotShowUpdated() | 602 | void MainWindow::slotShowUpdated() |
593 | { | 603 | { |
594 | OPackageList *packageList; | 604 | OPackageList *packageList; |
595 | if ( m_actionShowUpdated->isOn() ) | 605 | if ( m_actionShowUpdated->isOn() ) |
596 | { | 606 | { |
597 | m_actionShowInstalled->setOn( false ); | 607 | m_actionShowInstalled->setOn( false ); |
598 | m_actionShowNotInstalled->setOn( false ); | 608 | m_actionShowNotInstalled->setOn( false ); |
599 | m_actionFilter->setOn( false ); | 609 | m_actionFilter->setOn( false ); |
600 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, | 610 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, |
601 | OPackageManager::Updated, QString::null ); | 611 | OPackageManager::Updated, QString::null ); |
602 | } | 612 | } |
603 | else | 613 | else |
604 | packageList = m_packman.packages(); | 614 | packageList = m_packman.packages(); |
605 | 615 | ||
606 | if ( packageList ) | 616 | if ( packageList ) |
607 | { | 617 | { |
608 | loadPackageList( packageList, true ); | 618 | loadPackageList( packageList, true ); |
609 | delete packageList; | 619 | delete packageList; |
610 | } | 620 | } |
611 | } | 621 | } |
612 | 622 | ||
613 | void MainWindow::slotFilterChange() | 623 | void MainWindow::slotFilterChange() |
614 | { | 624 | { |
615 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, | 625 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, |
616 | m_filterCategory ); | 626 | m_filterCategory ); |
617 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 627 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
618 | { | 628 | { |
619 | m_filterName = dlg.name(); | 629 | m_filterName = dlg.name(); |
620 | m_filterServer = dlg.server(); | 630 | m_filterServer = dlg.server(); |
621 | m_filterDest = dlg.destination(); | 631 | m_filterDest = dlg.destination(); |
622 | m_filterStatus = dlg.status(); | 632 | m_filterStatus = dlg.status(); |
623 | m_filterCategory = dlg.category(); | 633 | m_filterCategory = dlg.category(); |
624 | m_actionFilter->setOn( true ); | 634 | m_actionFilter->setOn( true ); |
625 | slotFilter( true ); | 635 | slotFilter( true ); |
626 | } | 636 | } |
627 | else | 637 | else |
628 | { | 638 | { |
629 | m_actionFilter->setOn( false ); | 639 | m_actionFilter->setOn( false ); |
630 | slotFilter( false ); | 640 | slotFilter( false ); |
631 | } | 641 | } |
632 | } | 642 | } |
633 | 643 | ||
634 | void MainWindow::slotFilter( bool isOn ) | 644 | void MainWindow::slotFilter( bool isOn ) |
635 | { | 645 | { |
636 | OPackageList *packageList; | 646 | OPackageList *packageList; |
637 | if ( isOn ) | 647 | if ( isOn ) |
638 | { | 648 | { |
639 | // Turn off other filtering options | 649 | // Turn off other filtering options |
640 | m_actionShowNotInstalled->setOn( false ); | 650 | m_actionShowNotInstalled->setOn( false ); |
641 | m_actionShowInstalled->setOn( false ); | 651 | m_actionShowInstalled->setOn( false ); |
642 | m_actionShowUpdated->setOn( false ); | 652 | m_actionShowUpdated->setOn( false ); |
643 | 653 | ||
644 | // If the filter settings have not been set yet, display filter dialog | 654 | // If the filter settings have not been set yet, display filter dialog |
645 | if ( m_filterName.isNull() && m_filterServer.isNull() && m_filterDest.isNull() && | 655 | if ( m_filterName.isNull() && m_filterServer.isNull() && m_filterDest.isNull() && |
646 | m_filterStatus == OPackageManager::NotDefined && m_filterCategory.isNull() ) | 656 | m_filterStatus == OPackageManager::NotDefined && m_filterCategory.isNull() ) |
647 | { | 657 | { |
648 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, | 658 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, |
649 | m_filterCategory ); | 659 | m_filterCategory ); |
650 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 660 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
651 | { | 661 | { |
652 | m_filterName = dlg.name(); | 662 | m_filterName = dlg.name(); |
653 | m_filterServer = dlg.server(); | 663 | m_filterServer = dlg.server(); |
654 | m_filterDest = dlg.destination(); | 664 | m_filterDest = dlg.destination(); |
655 | m_filterStatus = dlg.status(); | 665 | m_filterStatus = dlg.status(); |
656 | m_filterCategory = dlg.category(); | 666 | m_filterCategory = dlg.category(); |
657 | m_actionFilter->setOn( true ); | 667 | m_actionFilter->setOn( true ); |
658 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, | 668 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, |
659 | m_filterStatus, m_filterCategory ); | 669 | m_filterStatus, m_filterCategory ); |
660 | } | 670 | } |
661 | else | 671 | else |
662 | { | 672 | { |
663 | m_actionFilter->setOn( false ); | 673 | m_actionFilter->setOn( false ); |
664 | packageList = m_packman.packages(); | 674 | packageList = m_packman.packages(); |
665 | } | 675 | } |
666 | } | 676 | } |
667 | else | 677 | else |
668 | { | 678 | { |
669 | m_actionFilter->setOn( true ); | 679 | m_actionFilter->setOn( true ); |
670 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, | 680 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, |
671 | m_filterStatus, m_filterCategory ); | 681 | m_filterStatus, m_filterCategory ); |
672 | } | 682 | } |
673 | 683 | ||
674 | 684 | ||
675 | } | 685 | } |
676 | else | 686 | else |
677 | packageList = m_packman.packages(); | 687 | packageList = m_packman.packages(); |
678 | 688 | ||
679 | if ( packageList ) | 689 | if ( packageList ) |
680 | { | 690 | { |
681 | loadPackageList( packageList, true ); | 691 | loadPackageList( packageList, true ); |
682 | delete packageList; | 692 | delete packageList; |
683 | } | 693 | } |
684 | } | 694 | } |
685 | 695 | ||
686 | void MainWindow::slotFindShowToolbar() | 696 | void MainWindow::slotFindShowToolbar() |
687 | { | 697 | { |
688 | m_findBar.show(); | 698 | m_findBar.show(); |
689 | m_findEdit->setFocus(); | 699 | m_findEdit->setFocus(); |
690 | } | 700 | } |
691 | 701 | ||
692 | void MainWindow::slotFindHideToolbar() | 702 | void MainWindow::slotFindHideToolbar() |
693 | { | 703 | { |
694 | m_findBar.hide(); | 704 | m_findBar.hide(); |
695 | } | 705 | } |
696 | 706 | ||
697 | void MainWindow::slotFindChanged( const QString &findText ) | 707 | void MainWindow::slotFindChanged( const QString &findText ) |
698 | { | 708 | { |
699 | 709 | ||
700 | m_actionFindNext->setEnabled( !findText.isEmpty() ); | 710 | m_actionFindNext->setEnabled( !findText.isEmpty() ); |
701 | searchForPackage( findText ); | 711 | searchForPackage( findText ); |
702 | } | 712 | } |
703 | 713 | ||
704 | void MainWindow::slotFindNext() | 714 | void MainWindow::slotFindNext() |
705 | { | 715 | { |
706 | searchForPackage( m_findEdit->text() ); | 716 | searchForPackage( m_findEdit->text() ); |
707 | } | 717 | } |
708 | 718 | ||
709 | void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem ) | 719 | void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem ) |
710 | { | 720 | { |
711 | QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() ); | 721 | QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() ); |
712 | 722 | ||
713 | // Create package manager output widget | 723 | // Create package manager output widget |
714 | PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName ); | 724 | PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName ); |
715 | 725 | ||
716 | // Display widget | 726 | // Display widget |
717 | m_widgetStack.addWidget( dlg, 3 ); | 727 | m_widgetStack.addWidget( dlg, 3 ); |
718 | m_widgetStack.raiseWidget( dlg ); | 728 | m_widgetStack.raiseWidget( dlg ); |
719 | } | 729 | } |