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