summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/aqpkg.pro2
-rw-r--r--noncore/settings/aqpkg/main.cpp9
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp5
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp85
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h4
5 files changed, 47 insertions, 58 deletions
diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro
index 5fc323a..b69bae4 100644
--- a/noncore/settings/aqpkg/aqpkg.pro
+++ b/noncore/settings/aqpkg/aqpkg.pro
@@ -1,51 +1,51 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on debug 2 CONFIG = qt warn_on release
3 HEADERS = global.h \ 3 HEADERS = global.h \
4 mainwin.h \ 4 mainwin.h \
5 datamgr.h \ 5 datamgr.h \
6 settingsimpl.h \ 6 settingsimpl.h \
7 ipkg.h \ 7 ipkg.h \
8 networkpkgmgr.h \ 8 networkpkgmgr.h \
9 package.h \ 9 package.h \
10 progresswidget.h \ 10 progresswidget.h \
11 installdlgimpl.h \ 11 installdlgimpl.h \
12 instoptionsimpl.h \ 12 instoptionsimpl.h \
13 destination.h \ 13 destination.h \
14 utils.h \ 14 utils.h \
15 server.h \ 15 server.h \
16 helpwindow.h \ 16 helpwindow.h \
17 letterpushbutton.h \ 17 letterpushbutton.h \
18 inputdlg.h \ 18 inputdlg.h \
19 categoryfilterimpl.h 19 categoryfilterimpl.h
20 SOURCES = mainwin.cpp \ 20 SOURCES = mainwin.cpp \
21 datamgr.cpp \ 21 datamgr.cpp \
22 mem.cpp \ 22 mem.cpp \
23 settingsimpl.cpp \ 23 settingsimpl.cpp \
24 ipkg.cpp \ 24 ipkg.cpp \
25 networkpkgmgr.cpp \ 25 networkpkgmgr.cpp \
26 main.cpp \ 26 main.cpp \
27 package.cpp \ 27 package.cpp \
28 progresswidget.cpp \ 28 progresswidget.cpp \
29 installdlgimpl.cpp \ 29 installdlgimpl.cpp \
30 instoptionsimpl.cpp \ 30 instoptionsimpl.cpp \
31 destination.cpp \ 31 destination.cpp \
32 utils.cpp \ 32 utils.cpp \
33 server.cpp \ 33 server.cpp \
34 helpwindow.cpp \ 34 helpwindow.cpp \
35 letterpushbutton.cpp \ 35 letterpushbutton.cpp \
36 inputdlg.cpp \ 36 inputdlg.cpp \
37 version.cpp \ 37 version.cpp \
38 categoryfilterimpl.cpp 38 categoryfilterimpl.cpp
39 INTERFACES= settings.ui \ 39 INTERFACES= settings.ui \
40 install.ui \ 40 install.ui \
41 instoptions.ui \ 41 instoptions.ui \
42 categoryfilter.ui 42 categoryfilter.ui
43 TARGET = aqpkg 43 TARGET = aqpkg
44INCLUDEPATH += $(OPIEDIR)/include 44INCLUDEPATH += $(OPIEDIR)/include
45DEPENDPATH += $(OPIEDIR)/include 45DEPENDPATH += $(OPIEDIR)/include
46LIBS += -lqpe -lopie -lstdc++ 46LIBS += -lqpe -lopie -lstdc++
47DESTDIR = $(OPIEDIR)/bin 47DESTDIR = $(OPIEDIR)/bin
48 48
49 49
50 50
51include ( ../../../include.pro ) 51include ( ../../../include.pro )
diff --git a/noncore/settings/aqpkg/main.cpp b/noncore/settings/aqpkg/main.cpp
index 53c392e..15ef9d6 100644
--- a/noncore/settings/aqpkg/main.cpp
+++ b/noncore/settings/aqpkg/main.cpp
@@ -1,65 +1,62 @@
1/*************************************************************************** 1/***************************************************************************
2 main.cpp - description 2 main.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <iostream>
19using namespace std;
20
21#ifdef QWS 18#ifdef QWS
22#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
23#include <qpe/qcopenvelope_qws.h> 20#include <qpe/qcopenvelope_qws.h>
24#else 21#else
25#include <qapplication.h> 22#include <qapplication.h>
26#endif 23#endif
27 24
28#include <qobjectdefs.h> 25#include <qobjectdefs.h>
29 26
30#include "mainwin.h" 27#include "mainwin.h"
31#include "server.h" 28#include "server.h"
32 29
33#include "global.h" 30#include "global.h"
34 31
35 32
36int main(int argc, char *argv[]) 33int main(int argc, char *argv[])
37{ 34{
38 cout << "Root dir = " << ROOT << endl; 35// cout << "Root dir = " << ROOT << endl;
39#ifdef QWS 36#ifdef QWS
40 QPEApplication a( argc, argv ); 37 QPEApplication a( argc, argv );
41#else 38#else
42 QApplication a( argc, argv ); 39 QApplication a( argc, argv );
43#endif 40#endif
44 41
45#ifdef QWS 42#ifdef QWS
46 // Disable suspend mode 43 // Disable suspend mode
47 cout << "Disabling suspend mode" << endl; 44// cout << "Disabling suspend mode" << endl;
48 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; 45 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend;
49#endif 46#endif
50 47
51 MainWindow *win = new MainWindow(); 48 MainWindow *win = new MainWindow();
52 a.setMainWidget(win); 49 a.setMainWidget(win);
53 win->showMaximized(); 50 win->showMaximized();
54 51
55 a.exec(); 52 a.exec();
56 53
57#ifdef QWS 54#ifdef QWS
58 // Reenable suspend mode 55 // Reenable suspend mode
59 cout << "Enabling suspend mode" << endl; 56// cout << "Enabling suspend mode" << endl;
60 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 57 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
61#endif 58#endif
62 #ifdef _DEBUG 59 #ifdef _DEBUG
63 DumpUnfreed(); 60 DumpUnfreed();
64 #endif 61 #endif
65} 62}
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 1a2ac37..d79673f 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,341 +1,338 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.cpp - description 2 mainwin.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <iostream>
19using namespace std;
20
21#include <qpe/qpemenubar.h> 18#include <qpe/qpemenubar.h>
22#include <qpe/qpetoolbar.h> 19#include <qpe/qpetoolbar.h>
23#include <qpe/resource.h> 20#include <qpe/resource.h>
24 21
25#include <qaction.h> 22#include <qaction.h>
26#include <qlineedit.h> 23#include <qlineedit.h>
27#include <qmenubar.h> 24#include <qmenubar.h>
28#include <qmessagebox.h> 25#include <qmessagebox.h>
29#include <qpopupmenu.h> 26#include <qpopupmenu.h>
30#include <qtimer.h> 27#include <qtimer.h>
31#include <qwhatsthis.h> 28#include <qwhatsthis.h>
32#include <qwidgetstack.h> 29#include <qwidgetstack.h>
33 30
34#include "mainwin.h" 31#include "mainwin.h"
35#include "progresswidget.h" 32#include "progresswidget.h"
36#include "datamgr.h" 33#include "datamgr.h"
37#include "networkpkgmgr.h" 34#include "networkpkgmgr.h"
38#include "settingsimpl.h" 35#include "settingsimpl.h"
39#include "helpwindow.h" 36#include "helpwindow.h"
40#include "utils.h" 37#include "utils.h"
41#include "global.h" 38#include "global.h"
42 39
43MainWindow :: MainWindow() 40MainWindow :: MainWindow()
44 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) 41 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
45{ 42{
46 setCaption( tr( "AQPkg - Package Manager" ) ); 43 setCaption( tr( "AQPkg - Package Manager" ) );
47 44
48 // Create UI widgets 45 // Create UI widgets
49 progressWindow = new ProgressWidget( this ); 46 progressWindow = new ProgressWidget( this );
50 networkPkgWindow = new NetworkPackageManager( this ); 47 networkPkgWindow = new NetworkPackageManager( this );
51 48
52 // Build menu and tool bars 49 // Build menu and tool bars
53 setToolBarsMovable( FALSE ); 50 setToolBarsMovable( FALSE );
54 51
55 QPEToolBar *bar = new QPEToolBar( this ); 52 QPEToolBar *bar = new QPEToolBar( this );
56 bar->setHorizontalStretchable( TRUE ); 53 bar->setHorizontalStretchable( TRUE );
57 QPEMenuBar *mb = new QPEMenuBar( bar ); 54 QPEMenuBar *mb = new QPEMenuBar( bar );
58 mb->setMargin( 0 ); 55 mb->setMargin( 0 );
59 bar = new QPEToolBar( this ); 56 bar = new QPEToolBar( this );
60 57
61 // Find toolbar 58 // Find toolbar
62 findBar = new QPEToolBar( this ); 59 findBar = new QPEToolBar( this );
63 addToolBar( findBar, QMainWindow::Top, true ); 60 addToolBar( findBar, QMainWindow::Top, true );
64 findBar->setHorizontalStretchable( true ); 61 findBar->setHorizontalStretchable( true );
65 findEdit = new QLineEdit( findBar ); 62 findEdit = new QLineEdit( findBar );
66 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); 63 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
67 findBar->setStretchableWidget( findEdit ); 64 findBar->setStretchableWidget( findEdit );
68 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); 65 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) );
69 66
70 // Packages menu 67 // Packages menu
71 QPopupMenu *popup = new QPopupMenu( this ); 68 QPopupMenu *popup = new QPopupMenu( this );
72 69
73 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); 70 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
74 a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); 71 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
75 connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( updateServer() ) ); 72 connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( updateServer() ) );
76 a->addTo( popup ); 73 a->addTo( popup );
77 a->addTo( bar ); 74 a->addTo( bar );
78 75
79 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); 76 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
80 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); 77 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
81 connect( actionUpgrade, SIGNAL( activated() ), networkPkgWindow, SLOT( upgradePackages() ) ); 78 connect( actionUpgrade, SIGNAL( activated() ), networkPkgWindow, SLOT( upgradePackages() ) );
82 actionUpgrade->addTo( popup ); 79 actionUpgrade->addTo( popup );
83 actionUpgrade->addTo( bar ); 80 actionUpgrade->addTo( bar );
84 81
85 iconDownload = Resource::loadPixmap( "aqpkg/download" ); 82 iconDownload = Resource::loadPixmap( "aqpkg/download" );
86 iconRemove = Resource::loadPixmap( "aqpkg/remove" ); 83 iconRemove = Resource::loadPixmap( "aqpkg/remove" );
87 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 84 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
88 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 85 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
89 connect( actionDownload, SIGNAL( activated() ), networkPkgWindow, SLOT( downloadPackage() ) ); 86 connect( actionDownload, SIGNAL( activated() ), networkPkgWindow, SLOT( downloadPackage() ) );
90 actionDownload->addTo( popup ); 87 actionDownload->addTo( popup );
91 actionDownload->addTo( bar ); 88 actionDownload->addTo( bar );
92 89
93 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); 90 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
94 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); 91 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
95 connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( applyChanges() ) ); 92 connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( applyChanges() ) );
96 a->addTo( popup ); 93 a->addTo( popup );
97 a->addTo( bar ); 94 a->addTo( bar );
98 95
99 mb->insertItem( tr( "Actions" ), popup ); 96 mb->insertItem( tr( "Actions" ), popup );
100 97
101 // View menu 98 // View menu
102 popup = new QPopupMenu( this ); 99 popup = new QPopupMenu( this );
103 100
104 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 101 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
105 actionUninstalled->setToggleAction( TRUE ); 102 actionUninstalled->setToggleAction( TRUE );
106 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); 103 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
107 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); 104 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
108 actionUninstalled->addTo( popup ); 105 actionUninstalled->addTo( popup );
109 106
110 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 107 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
111 actionInstalled->setToggleAction( TRUE ); 108 actionInstalled->setToggleAction( TRUE );
112 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); 109 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
113 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); 110 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
114 actionInstalled->addTo( popup ); 111 actionInstalled->addTo( popup );
115 112
116 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 113 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
117 actionUpdated->setToggleAction( TRUE ); 114 actionUpdated->setToggleAction( TRUE );
118 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); 115 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
119 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); 116 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
120 actionUpdated->addTo( popup ); 117 actionUpdated->addTo( popup );
121 118
122 popup->insertSeparator(); 119 popup->insertSeparator();
123 120
124 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); 121 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
125 actionFilter->setToggleAction( TRUE ); 122 actionFilter->setToggleAction( TRUE );
126 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); 123 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
127 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); 124 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
128 actionFilter->addTo( popup ); 125 actionFilter->addTo( popup );
129 126
130 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); 127 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
131 a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); 128 a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
132 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); 129 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
133 a->addTo( popup ); 130 a->addTo( popup );
134 131
135 popup->insertSeparator(); 132 popup->insertSeparator();
136 133
137 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 134 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
138 a->setWhatsThis( tr( "Click here to search for text in package names." ) ); 135 a->setWhatsThis( tr( "Click here to search for text in package names." ) );
139 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); 136 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) );
140 a->addTo( popup ); 137 a->addTo( popup );
141 138
142 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 139 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
143 actionFindNext->setEnabled( FALSE ); 140 actionFindNext->setEnabled( FALSE );
144 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); 141 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
145 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); 142 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) );
146 actionFindNext->addTo( popup ); 143 actionFindNext->addTo( popup );
147 actionFindNext->addTo( findBar ); 144 actionFindNext->addTo( findBar );
148 145
149 mb->insertItem( tr( "View" ), popup ); 146 mb->insertItem( tr( "View" ), popup );
150 147
151 148
152 // Options menu 149 // Options menu
153 popup = new QPopupMenu( this ); 150 popup = new QPopupMenu( this );
154 151
155 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 ); 152 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 );
156 a->setWhatsThis( tr( "Click here to configure this application." ) ); 153 a->setWhatsThis( tr( "Click here to configure this application." ) );
157 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); 154 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
158 a->addTo( popup ); 155 a->addTo( popup );
159 156
160 popup->insertSeparator(); 157 popup->insertSeparator();
161 158
162 a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 ); 159 a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 );
163 a->setWhatsThis( tr( "Click here for help." ) ); 160 a->setWhatsThis( tr( "Click here for help." ) );
164 connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) ); 161 connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) );
165 a->addTo( popup ); 162 a->addTo( popup );
166 163
167 a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 ); 164 a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 );
168 a->setWhatsThis( tr( "Click here for software version information." ) ); 165 a->setWhatsThis( tr( "Click here for software version information." ) );
169 connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) ); 166 connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) );
170 a->addTo( popup ); 167 a->addTo( popup );
171 168
172 mb->insertItem( tr( "Options" ), popup ); 169 mb->insertItem( tr( "Options" ), popup );
173 170
174 // Finish find toolbar creation 171 // Finish find toolbar creation
175 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 172 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
176 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); 173 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
177 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); 174 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) );
178 a->addTo( findBar ); 175 a->addTo( findBar );
179 findBar->hide(); 176 findBar->hide();
180 177
181 178
182 // Create widget stack and add UI widgets 179 // Create widget stack and add UI widgets
183 stack = new QWidgetStack( this ); 180 stack = new QWidgetStack( this );
184 stack->addWidget( progressWindow, 2 ); 181 stack->addWidget( progressWindow, 2 );
185 stack->addWidget( networkPkgWindow, 1 ); 182 stack->addWidget( networkPkgWindow, 1 );
186 setCentralWidget( stack ); 183 setCentralWidget( stack );
187 stack->raiseWidget( progressWindow ); 184 stack->raiseWidget( progressWindow );
188 185
189 // Delayed call to finish initialization 186 // Delayed call to finish initialization
190 QTimer::singleShot( 100, this, SLOT( init() ) ); 187 QTimer::singleShot( 100, this, SLOT( init() ) );
191} 188}
192 189
193MainWindow :: ~MainWindow() 190MainWindow :: ~MainWindow()
194{ 191{
195 delete mgr; 192 delete mgr;
196} 193}
197 194
198void MainWindow :: init() 195void MainWindow :: init()
199{ 196{
200 stack->raiseWidget( progressWindow ); 197 stack->raiseWidget( progressWindow );
201 198
202 mgr = new DataManager(); 199 mgr = new DataManager();
203 connect( mgr, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) ); 200 connect( mgr, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) );
204 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 201 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
205 progressWindow, SLOT( setMessage( const QString & ) ) ); 202 progressWindow, SLOT( setMessage( const QString & ) ) );
206 connect( mgr, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) ); 203 connect( mgr, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) );
207 mgr->loadServers(); 204 mgr->loadServers();
208 205
209 networkPkgWindow->setDataManager( mgr ); 206 networkPkgWindow->setDataManager( mgr );
210 networkPkgWindow->updateData(); 207 networkPkgWindow->updateData();
211 connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) ); 208 connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) );
212 connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) ); 209 connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) );
213 connect( networkPkgWindow, SIGNAL( appEnableUpgrade( bool ) ), this, SLOT( enableUpgrade( bool ) ) ); 210 connect( networkPkgWindow, SIGNAL( appEnableUpgrade( bool ) ), this, SLOT( enableUpgrade( bool ) ) );
214 connect( networkPkgWindow, SIGNAL( appEnableDownload( bool ) ), this, SLOT( enableDownload( bool ) ) ); 211 connect( networkPkgWindow, SIGNAL( appEnableDownload( bool ) ), this, SLOT( enableDownload( bool ) ) );
215 connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) ); 212 connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) );
216 connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ), 213 connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ),
217 progressWindow, SLOT( setMessage( const QString & ) ) ); 214 progressWindow, SLOT( setMessage( const QString & ) ) );
218 connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) ); 215 connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) );
219 216
220 stack->raiseWidget( networkPkgWindow ); 217 stack->raiseWidget( networkPkgWindow );
221} 218}
222 219
223void MainWindow :: setDocument( const QString &doc ) 220void MainWindow :: setDocument( const QString &doc )
224{ 221{
225 // Remove path from package 222 // Remove path from package
226 QString package = Utils::getPackageNameFromIpkFilename( doc ); 223 QString package = Utils::getPackageNameFromIpkFilename( doc );
227 std::cout << "Selecting package " << package << std::endl; 224// std::cout << "Selecting package " << package << std::endl;
228 networkPkgWindow->selectLocalPackage( package ); 225 networkPkgWindow->selectLocalPackage( package );
229} 226}
230 227
231void MainWindow :: displaySettings() 228void MainWindow :: displaySettings()
232{ 229{
233 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 230 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
234 if ( dlg->showDlg( 0 ) ) 231 if ( dlg->showDlg( 0 ) )
235 networkPkgWindow->updateData(); 232 networkPkgWindow->updateData();
236 delete dlg; 233 delete dlg;
237} 234}
238 235
239void MainWindow :: displayHelp() 236void MainWindow :: displayHelp()
240{ 237{
241 HelpWindow *dlg = new HelpWindow( this ); 238 HelpWindow *dlg = new HelpWindow( this );
242 dlg->exec(); 239 dlg->exec();
243 delete dlg; 240 delete dlg;
244} 241}
245 242
246void MainWindow :: displayFindBar() 243void MainWindow :: displayFindBar()
247{ 244{
248 findBar->show(); 245 findBar->show();
249 findEdit->setFocus(); 246 findEdit->setFocus();
250} 247}
251 248
252void MainWindow :: repeatFind() 249void MainWindow :: repeatFind()
253{ 250{
254 networkPkgWindow->searchForPackage( findEdit->text() ); 251 networkPkgWindow->searchForPackage( findEdit->text() );
255} 252}
256 253
257void MainWindow :: findPackage( const QString &text ) 254void MainWindow :: findPackage( const QString &text )
258{ 255{
259 actionFindNext->setEnabled( !text.isEmpty() ); 256 actionFindNext->setEnabled( !text.isEmpty() );
260 networkPkgWindow->searchForPackage( text ); 257 networkPkgWindow->searchForPackage( text );
261} 258}
262 259
263void MainWindow :: hideFindBar() 260void MainWindow :: hideFindBar()
264{ 261{
265 findBar->hide(); 262 findBar->hide();
266} 263}
267 264
268void MainWindow :: displayAbout() 265void MainWindow :: displayAbout()
269{ 266{
270 QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) ); 267 QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) );
271} 268}
272 269
273void MainWindow :: filterUninstalledPackages() 270void MainWindow :: filterUninstalledPackages()
274{ 271{
275 networkPkgWindow->showOnlyUninstalledPackages( actionUninstalled->isOn() ); 272 networkPkgWindow->showOnlyUninstalledPackages( actionUninstalled->isOn() );
276 actionInstalled->setOn( FALSE ); 273 actionInstalled->setOn( FALSE );
277 actionUpdated->setOn( FALSE ); 274 actionUpdated->setOn( FALSE );
278} 275}
279 276
280void MainWindow :: filterInstalledPackages() 277void MainWindow :: filterInstalledPackages()
281{ 278{
282 actionUninstalled->setOn( FALSE ); 279 actionUninstalled->setOn( FALSE );
283 networkPkgWindow->showOnlyInstalledPackages( actionInstalled->isOn() ); 280 networkPkgWindow->showOnlyInstalledPackages( actionInstalled->isOn() );
284 actionUpdated->setOn( FALSE ); 281 actionUpdated->setOn( FALSE );
285} 282}
286 283
287void MainWindow :: filterUpgradedPackages() 284void MainWindow :: filterUpgradedPackages()
288{ 285{
289 actionUninstalled->setOn( FALSE ); 286 actionUninstalled->setOn( FALSE );
290 actionInstalled->setOn( FALSE ); 287 actionInstalled->setOn( FALSE );
291 networkPkgWindow->showUpgradedPackages( actionUpdated->isOn() ); 288 networkPkgWindow->showUpgradedPackages( actionUpdated->isOn() );
292} 289}
293 290
294void MainWindow :: setFilterCategory() 291void MainWindow :: setFilterCategory()
295{ 292{
296 if ( networkPkgWindow->setFilterCategory() ) 293 if ( networkPkgWindow->setFilterCategory() )
297 actionFilter->setOn( TRUE ); 294 actionFilter->setOn( TRUE );
298} 295}
299 296
300void MainWindow :: filterCategory() 297void MainWindow :: filterCategory()
301{ 298{
302 if ( !actionFilter->isOn() ) 299 if ( !actionFilter->isOn() )
303 { 300 {
304 networkPkgWindow->filterByCategory( FALSE ); 301 networkPkgWindow->filterByCategory( FALSE );
305 } 302 }
306 else 303 else
307 { 304 {
308 actionFilter->setOn( networkPkgWindow->filterByCategory( TRUE ) ); 305 actionFilter->setOn( networkPkgWindow->filterByCategory( TRUE ) );
309 } 306 }
310} 307}
311 308
312void MainWindow :: raiseMainWidget() 309void MainWindow :: raiseMainWidget()
313{ 310{
314 stack->raiseWidget( networkPkgWindow ); 311 stack->raiseWidget( networkPkgWindow );
315} 312}
316 313
317void MainWindow :: raiseProgressWidget() 314void MainWindow :: raiseProgressWidget()
318{ 315{
319 stack->raiseWidget( progressWindow ); 316 stack->raiseWidget( progressWindow );
320} 317}
321 318
322void MainWindow :: enableUpgrade( bool enabled ) 319void MainWindow :: enableUpgrade( bool enabled )
323{ 320{
324 actionUpgrade->setEnabled( enabled ); 321 actionUpgrade->setEnabled( enabled );
325} 322}
326 323
327void MainWindow :: enableDownload( bool enabled ) 324void MainWindow :: enableDownload( bool enabled )
328{ 325{
329 if ( enabled ) 326 if ( enabled )
330 { 327 {
331 actionDownload->setIconSet( iconDownload ); 328 actionDownload->setIconSet( iconDownload );
332 actionDownload->setText( tr( "Download" ) ); 329 actionDownload->setText( tr( "Download" ) );
333 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 330 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
334 } 331 }
335 else 332 else
336 { 333 {
337 actionDownload->setIconSet( iconRemove ); 334 actionDownload->setIconSet( iconRemove );
338 actionDownload->setText( tr( "Remove" ) ); 335 actionDownload->setText( tr( "Remove" ) );
339 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); 336 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) );
340 } 337 }
341} 338}
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index c209589..b4b6475 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -1,879 +1,870 @@
1/*************************************************************************** 1/***************************************************************************
2 networkpkgmgr.cpp - description 2 networkpkgmgr.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <fstream>
19#include <iostream>
20using namespace std;
21
22#include <unistd.h> 18#include <unistd.h>
23#include <stdlib.h>
24#include <linux/limits.h>
25 19
26#ifdef QWS 20#ifdef QWS
27#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
28#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
29#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/resource.h>
30#else 25#else
31#include <qapplication.h> 26#include <qapplication.h>
32#endif 27#endif
33#include <qlabel.h> 28#include <qlabel.h>
34#include <qfile.h> 29#include <qfile.h>
35#include <qmessagebox.h> 30#include <qmessagebox.h>
31#include <qwhatsthis.h>
36 32
37#include "datamgr.h" 33#include "datamgr.h"
38#include "networkpkgmgr.h" 34#include "networkpkgmgr.h"
39#include "installdlgimpl.h" 35#include "installdlgimpl.h"
40#include "ipkg.h" 36#include "ipkg.h"
41#include "inputdlg.h" 37#include "inputdlg.h"
42#include "letterpushbutton.h" 38#include "letterpushbutton.h"
43#include "categoryfilterimpl.h" 39#include "categoryfilterimpl.h"
44 40
45#include "global.h" 41#include "global.h"
46 42
47extern int compareVersions( const char *v1, const char *v2 ); 43extern int compareVersions( const char *v1, const char *v2 );
48 44
49NetworkPackageManager::NetworkPackageManager( QWidget *parent, const char *name ) 45NetworkPackageManager::NetworkPackageManager( QWidget *parent, const char *name )
50 : QWidget(parent, name) 46 : QWidget(parent, name)
51{ 47{
52 48
53#ifdef QWS 49#ifdef QWS
54 // read download directory from config file 50 // read download directory from config file
55 Config cfg( "aqpkg" ); 51 Config cfg( "aqpkg" );
56 cfg.setGroup( "settings" ); 52 cfg.setGroup( "settings" );
57 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 53 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
58 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 54 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
59 55
60#endif 56#endif
61 57
62 showUninstalledPkgs = false; 58 showUninstalledPkgs = false;
63 showInstalledPkgs = false; 59 showInstalledPkgs = false;
64 showUpgradedPkgs = false; 60 showUpgradedPkgs = false;
65 categoryFilterEnabled = false; 61 categoryFilterEnabled = false;
66 62
67 initGui(); 63 initGui();
68} 64}
69 65
70NetworkPackageManager::~NetworkPackageManager() 66NetworkPackageManager::~NetworkPackageManager()
71{ 67{
72} 68}
73 69
74void NetworkPackageManager :: setDataManager( DataManager *dm ) 70void NetworkPackageManager :: setDataManager( DataManager *dm )
75{ 71{
76 dataMgr = dm; 72 dataMgr = dm;
77} 73}
78 74
79void NetworkPackageManager :: updateData() 75void NetworkPackageManager :: updateData()
80{ 76{
81 emit progressSetSteps( dataMgr->getServerList().size() ); 77 emit progressSetSteps( dataMgr->getServerList().size() );
82 78
83 serversList->clear(); 79 serversList->clear();
84 packagesList->clear(); 80 packagesList->clear();
85 81
86 vector<Server>::iterator it; 82 vector<Server>::iterator it;
87 int activeItem = -1; 83 int activeItem = -1;
88 int i; 84 int i;
89 QString serverName; 85 QString serverName;
90 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 86 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
91 { 87 {
92 serverName = it->getServerName(); 88 serverName = it->getServerName();
93 emit progressSetMessage( tr( "Building server list:\n\t%1" ).arg( serverName ) ); 89 emit progressSetMessage( tr( "Building server list:\n\t%1" ).arg( serverName ) );
94 emit progressUpdate( i ); 90 emit progressUpdate( i );
95 qApp->processEvents(); 91 qApp->processEvents();
96 92
97// cout << "Adding " << it->getServerName() << " to combobox" << endl; 93// cout << "Adding " << it->getServerName() << " to combobox" << endl;
98 if ( !it->isServerActive() ) 94 if ( !it->isServerActive() )
99 { 95 {
100 cout << serverName << " is not active" << endl; 96// cout << serverName << " is not active" << endl;
101 i--; 97 i--;
102 continue; 98 continue;
103 } 99 }
104 100
105 serversList->insertItem( serverName ); 101 serversList->insertItem( serverName );
106 if ( serverName == currentlySelectedServer ) 102 if ( serverName == currentlySelectedServer )
107 activeItem = i; 103 activeItem = i;
108 } 104 }
109 105
110 // set selected server to be active server 106 // set selected server to be active server
111 if ( activeItem != -1 ) 107 if ( activeItem != -1 )
112 serversList->setCurrentItem( activeItem ); 108 serversList->setCurrentItem( activeItem );
113 serverSelected( 0, FALSE ); 109 serverSelected( 0, FALSE );
114} 110}
115 111
116void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) 112void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
117{ 113{
118 // First select local server 114 // First select local server
119 for ( int i = 0 ; i < serversList->count() ; ++i ) 115 for ( int i = 0 ; i < serversList->count() ; ++i )
120 { 116 {
121 if ( serversList->text( i ) == LOCAL_IPKGS ) 117 if ( serversList->text( i ) == LOCAL_IPKGS )
122 { 118 {
123 serversList->setCurrentItem( i ); 119 serversList->setCurrentItem( i );
124 break; 120 break;
125 } 121 }
126 } 122 }
127 serverSelected( 0 ); 123 serverSelected( 0 );
128 124
129 // Now set the check box of the selected package 125 // Now set the check box of the selected package
130 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 126 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
131 item != 0 ; 127 item != 0 ;
132 item = (QCheckListItem *)item->nextSibling() ) 128 item = (QCheckListItem *)item->nextSibling() )
133 { 129 {
134 if ( item->text().startsWith( pkg ) ) 130 if ( item->text().startsWith( pkg ) )
135 { 131 {
136 item->setOn( true ); 132 item->setOn( true );
137 break; 133 break;
138 } 134 }
139 } 135 }
140} 136}
141 137
142 138
143void NetworkPackageManager :: initGui() 139void NetworkPackageManager :: initGui()
144{ 140{
145 QLabel *l = new QLabel( tr( "Servers" ), this ); 141 QLabel *l = new QLabel( tr( "Servers" ), this );
146 serversList = new QComboBox( this ); 142 serversList = new QComboBox( this );
147 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 143 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
144 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) );
145
146 installedIcon = Resource::loadPixmap( "aqpkg/installed" );
147 updatedIcon = Resource::loadPixmap( "aqpkg/updated" );
148 148
149 packagesList = new QListView( this ); 149 packagesList = new QListView( this );
150 packagesList->addColumn( tr( "Packages" ), 225 );
151 QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) );
150 152
151 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1 ); 153 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1 );
152 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); 154 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
153 hbox1->addWidget( l ); 155 hbox1->addWidget( l );
154 hbox1->addWidget( serversList ); 156 hbox1->addWidget( serversList );
155 157
156 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); 158 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 );
157 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); 159 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 );
158 160
159 161
160 if ( showJumpTo ) 162 if ( showJumpTo )
161 { 163 {
162 char text[2]; 164 char text[2];
163 text[1] = '\0'; 165 text[1] = '\0';
164 for ( int i = 0 ; i < 26 ; ++i ) 166 for ( int i = 0 ; i < 26 ; ++i )
165 { 167 {
166 text[0] = 'A' + i; 168 text[0] = 'A' + i;
167 LetterPushButton *b = new LetterPushButton( text, this ); 169 LetterPushButton *b = new LetterPushButton( text, this );
168 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 170 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
169 if ( i < 13 ) 171 if ( i < 13 )
170 hbox3->addWidget( b ); 172 hbox3->addWidget( b );
171 else 173 else
172 hbox4->addWidget( b ); 174 hbox4->addWidget( b );
173 } 175 }
174 } 176 }
175 177
176 vbox->addWidget( packagesList ); 178 vbox->addWidget( packagesList );
177 packagesList->addColumn( tr( "Packages" ) ); 179
178
179 downloadEnabled = TRUE; 180 downloadEnabled = TRUE;
180} 181}
181 182
182void NetworkPackageManager :: serverSelected( int index ) 183void NetworkPackageManager :: serverSelected( int index )
183{ 184{
184 serverSelected( index, TRUE ); 185 serverSelected( index, TRUE );
185} 186}
186 187
187void NetworkPackageManager :: serverSelected( int, bool raiseProgress ) 188void NetworkPackageManager :: serverSelected( int, bool raiseProgress )
188{ 189{
190 QPixmap nullIcon( installedIcon.size() );
191 nullIcon.fill( colorGroup().base() );
192
189 // display packages 193 // display packages
190 QString serverName = serversList->currentText(); 194 QString serverName = serversList->currentText();
191 currentlySelectedServer = serverName; 195 currentlySelectedServer = serverName;
192 196
193 vector<Server>::iterator s = dataMgr->getServer( serverName ); 197 vector<Server>::iterator s = dataMgr->getServer( serverName );
194 198
195 vector<Package> &list = s->getPackageList(); 199 vector<Package> &list = s->getPackageList();
196 vector<Package>::iterator it; 200 vector<Package>::iterator it;
197 201
198 // Display progress widget while loading list 202 // Display progress widget while loading list
199 bool doProgress = ( list.size() > 200 ); 203 bool doProgress = ( list.size() > 200 );
200 if ( doProgress ) 204 if ( doProgress )
201 { 205 {
202 if ( raiseProgress ) 206 if ( raiseProgress )
203 { 207 {
204 emit appRaiseProgressWidget(); 208 emit appRaiseProgressWidget();
205 } 209 }
206 emit progressSetSteps( list.size() ); 210 emit progressSetSteps( list.size() );
207 emit progressSetMessage( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); 211 emit progressSetMessage( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
208 } 212 }
209 213
210 packagesList->clear(); 214 packagesList->clear();
211 215
212#ifdef QWS 216#ifdef QWS
213 // read download directory from config file 217 // read download directory from config file
214 Config cfg( "aqpkg" ); 218 Config cfg( "aqpkg" );
215 cfg.setGroup( "settings" ); 219 cfg.setGroup( "settings" );
216 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 220 cfg.writeEntry( "selectedServer", currentlySelectedServer );
217#endif 221#endif
218 222
219 int i = 0; 223 int i = 0;
220 for ( it = list.begin() ; it != list.end() ; ++it ) 224 for ( it = list.begin() ; it != list.end() ; ++it )
221 { 225 {
222 // Update progress after every 100th package (arbitrary value, seems to give good balance) 226 // Update progress after every 100th package (arbitrary value, seems to give good balance)
223 i++; 227 i++;
224 if ( ( i % 100 ) == 0 ) 228 if ( ( i % 100 ) == 0 )
225 { 229 {
226 if ( doProgress ) 230 if ( doProgress )
227 { 231 {
228 emit progressUpdate( i ); 232 emit progressUpdate( i );
229 } 233 }
230 qApp->processEvents(); 234 qApp->processEvents();
231 } 235 }
232 236
233 QString text = ""; 237 QString text = "";
234 238
235 // Apply show only uninstalled packages filter 239 // Apply show only uninstalled packages filter
236 if ( showUninstalledPkgs && it->isInstalled() ) 240 if ( showUninstalledPkgs && it->isInstalled() )
237 continue; 241 continue;
238 242
239 // Apply show only installed packages filter 243 // Apply show only installed packages filter
240 if ( showInstalledPkgs && !it->isInstalled() ) 244 if ( showInstalledPkgs && !it->isInstalled() )
241 continue; 245 continue;
242 246
243 // Apply show only new installed packages filter 247 // Apply show only new installed packages filter
244 if ( showUpgradedPkgs ) 248 if ( showUpgradedPkgs )
245 { 249 {
246 if ( !it->isInstalled() || 250 if ( !it->isInstalled() ||
247 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) 251 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 )
248 continue; 252 continue;
249 } 253 }
250 254
251 // Apply the section filter 255 // Apply the section filter
252 if ( categoryFilterEnabled && categoryFilter != "" ) 256 if ( categoryFilterEnabled && categoryFilter != "" )
253 { 257 {
254 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) 258 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 )
255 continue; 259 continue;
256 } 260 }
257 261
258 // If the local server, only display installed packages 262 // If the local server, only display installed packages
259 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 263 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
260 continue; 264 continue;
261 265
262 266
263 text.append( it->getPackageName() ); 267 QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox );
268
264 if ( it->isInstalled() ) 269 if ( it->isInstalled() )
265 { 270 {
266 text.append( " (installed)" ); 271 // If a different version of package is available, show update available icon
267 272 // Otherwise, show installed icon
268 // If a different version of package is available, postfix it with an * 273 if ( it->getVersion() != it->getInstalledVersion() &&
269 if ( it->getVersion() != it->getInstalledVersion() ) 274 compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1)
270 { 275 {
271 276
272 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) 277 item->setPixmap( 0, updatedIcon );
273 text.append( "*" );
274 } 278 }
275 } 279 else
276 280 {
277 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 281 item->setPixmap( 0, installedIcon );
278 282 }
279 if ( it->isInstalled() ) 283
280 {
281 QString destName = ""; 284 QString destName = "";
282 if ( it->getLocalPackage() ) 285 if ( it->getLocalPackage() )
283 { 286 {
284 if ( it->getLocalPackage()->getInstalledTo() ) 287 if ( it->getLocalPackage()->getInstalledTo() )
285 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); 288 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
286 } 289 }
287 else 290 else
288 { 291 {
289 if ( it->getInstalledTo() ) 292 if ( it->getInstalledTo() )
290 destName = it->getInstalledTo()->getDestinationName(); 293 destName = it->getInstalledTo()->getDestinationName();
291 } 294 }
292 if ( destName != "" ) 295 if ( destName != "" )
293 new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); 296 new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) );
294 } 297 }
298 else
299 {
300 item->setPixmap( 0, nullIcon );
301 }
295 302
296 if ( !it->isPackageStoredLocally() ) 303 if ( !it->isPackageStoredLocally() )
297 { 304 {
298 new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); 305 new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) );
299 new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); 306 new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) );
300 new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); 307 new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) );
301 } 308 }
302 else 309 else
303 new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) ); 310 new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) );
304 311
305 if ( serverName == LOCAL_SERVER ) 312 if ( serverName == LOCAL_SERVER )
306 { 313 {
307 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) ); 314 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) );
308 } 315 }
309 else 316 else
310 { 317 {
311 new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) ); 318 new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) );
312 if ( it->getLocalPackage() ) 319 if ( it->getLocalPackage() )
313 { 320 {
314 if ( it->isInstalled() ) 321 if ( it->isInstalled() )
315 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) ); 322 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) );
316 } 323 }
317 } 324 }
318 325
319 packagesList->insertItem( item ); 326 packagesList->insertItem( item );
320 } 327 }
321 328
322 // If the local server or the local ipkgs server disable the download button 329 // If the local server or the local ipkgs server disable the download button
323 if ( serverName == LOCAL_SERVER ) 330 if ( serverName == LOCAL_SERVER )
324 { 331 {
325 downloadEnabled = TRUE; 332 downloadEnabled = TRUE;
326 emit appEnableUpgrade( FALSE ); 333 emit appEnableUpgrade( FALSE );
327 } 334 }
328 else if ( serverName == LOCAL_IPKGS ) 335 else if ( serverName == LOCAL_IPKGS )
329 { 336 {
330 downloadEnabled = FALSE; 337 downloadEnabled = FALSE;
331 emit appEnableUpgrade( FALSE ); 338 emit appEnableUpgrade( FALSE );
332 } 339 }
333 else 340 else
334 { 341 {
335 downloadEnabled = TRUE; 342 downloadEnabled = TRUE;
336 emit appEnableUpgrade( TRUE ); 343 emit appEnableUpgrade( TRUE );
337 } 344 }
338 emit appEnableDownload( downloadEnabled ); 345 emit appEnableDownload( downloadEnabled );
339 346
340 // Display this widget once everything is done 347 // Display this widget once everything is done
341 if ( doProgress && raiseProgress ) 348 if ( doProgress && raiseProgress )
342 { 349 {
343 emit appRaiseMainWidget(); 350 emit appRaiseMainWidget();
344 } 351 }
345} 352}
346 353
347void NetworkPackageManager :: updateServer() 354void NetworkPackageManager :: updateServer()
348{ 355{
349 QString serverName = serversList->currentText(); 356 QString serverName = serversList->currentText();
350 357
351 // Update the current server 358 // Update the current server
352 // Display dialog 359 // Display dialog
353 360
354 // Disable buttons to stop silly people clicking lots on them :) 361 // Disable buttons to stop silly people clicking lots on them :)
355 362
356 // First, write out ipkg_conf file so that ipkg can use it 363 // First, write out ipkg_conf file so that ipkg can use it
357 dataMgr->writeOutIpkgConf(); 364 dataMgr->writeOutIpkgConf();
358 365
359 Ipkg ipkg; 366 Ipkg ipkg;
360 ipkg.setOption( "update" ); 367 ipkg.setOption( "update" );
361 368
362 InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true ); 369 InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true );
363 dlg.showDlg(); 370 dlg.showDlg();
364 371
365 // Reload data 372 // Reload data
366 dataMgr->reloadServerData(); 373 dataMgr->reloadServerData();
367 serverSelected(-1); 374 serverSelected(-1);
368// delete progDlg; 375// delete progDlg;
369} 376}
370 377
371void NetworkPackageManager :: upgradePackages() 378void NetworkPackageManager :: upgradePackages()
372{ 379{
373 // We're gonna do an upgrade of all packages 380 // We're gonna do an upgrade of all packages
374 // First warn user that this isn't recommended 381 // First warn user that this isn't recommended
375 // TODO - ODevice???? 382 // TODO - ODevice????
376 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); 383 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
377 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, 384 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
378 QMessageBox::Yes, 385 QMessageBox::Yes,
379 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 386 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
380 0, this ); 387 0, this );
381 warn.adjustSize(); 388 warn.adjustSize();
382 389
383 if ( warn.exec() == QMessageBox::Yes ) 390 if ( warn.exec() == QMessageBox::Yes )
384 { 391 {
385 // First, write out ipkg_conf file so that ipkg can use it 392 // First, write out ipkg_conf file so that ipkg can use it
386 dataMgr->writeOutIpkgConf(); 393 dataMgr->writeOutIpkgConf();
387 394
388 // Now run upgrade 395 // Now run upgrade
389 Ipkg ipkg; 396 Ipkg ipkg;
390 ipkg.setOption( "upgrade" ); 397 ipkg.setOption( "upgrade" );
391 398
392 InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true ); 399 InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true );
393 dlg.showDlg(); 400 dlg.showDlg();
394 401
395 // Reload data 402 // Reload data
396 dataMgr->reloadServerData(); 403 dataMgr->reloadServerData();
397 serverSelected(-1); 404 serverSelected(-1);
398 } 405 }
399} 406}
400 407
401 408
402void NetworkPackageManager :: downloadPackage() 409void NetworkPackageManager :: downloadPackage()
403{ 410{
404 bool doUpdate = true; 411 bool doUpdate = true;
405 if ( downloadEnabled ) 412 if ( downloadEnabled )
406 { 413 {
407 // See if any packages are selected 414 // See if any packages are selected
408 bool found = false; 415 bool found = false;
409 if ( serversList->currentText() != LOCAL_SERVER ) 416 if ( serversList->currentText() != LOCAL_SERVER )
410 { 417 {
411 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 418 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
412 item != 0 && !found; 419 item != 0 && !found;
413 item = (QCheckListItem *)item->nextSibling() ) 420 item = (QCheckListItem *)item->nextSibling() )
414 { 421 {
415 if ( item->isOn() ) 422 if ( item->isOn() )
416 found = true; 423 found = true;
417 } 424 }
418 } 425 }
419 426
420 // If user selected some packages then download the and store the locally 427 // If user selected some packages then download the and store the locally
421 // otherwise, display dialog asking user what package to download from an http server 428 // otherwise, display dialog asking user what package to download from an http server
422 // and whether to install it 429 // and whether to install it
423 if ( found ) 430 if ( found )
424 downloadSelectedPackages(); 431 downloadSelectedPackages();
425 else 432 else
426 downloadRemotePackage(); 433 downloadRemotePackage();
427 434
428 } 435 }
429 else 436 else
430 { 437 {
431 doUpdate = false; 438 doUpdate = false;
432 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 439 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
433 item != 0 ; 440 item != 0 ;
434 item = (QCheckListItem *)item->nextSibling() ) 441 item = (QCheckListItem *)item->nextSibling() )
435 { 442 {
436 if ( item->isOn() ) 443 if ( item->isOn() )
437 { 444 {
438 QString name = item->text(); 445 QString name = item->text();
439 int pos = name.find( "*" ); 446 int pos = name.find( "*" );
440 name.truncate( pos ); 447 name.truncate( pos );
441 448
442 // if (there is a (installed), remove it 449 // if (there is a (installed), remove it
443 pos = name.find( "(installed)" ); 450 pos = name.find( "(installed)" );
444 if ( pos > 0 ) 451 if ( pos > 0 )
445 name.truncate( pos - 1 ); 452 name.truncate( pos - 1 );
446 453
447 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 454 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
448 455
449 QString msgtext; 456 QString msgtext;
450 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); 457 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
451 if ( QMessageBox::information( this, tr( "Are you sure?" ), 458 if ( QMessageBox::information( this, tr( "Are you sure?" ),
452 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) 459 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
453 { 460 {
454 doUpdate = true; 461 doUpdate = true;
455 QFile f( p->getFilename() ); 462 QFile f( p->getFilename() );
456 f.remove(); 463 f.remove();
457 } 464 }
458 } 465 }
459 } 466 }
460 } 467 }
461 468
462 if ( doUpdate ) 469 if ( doUpdate )
463 { 470 {
464 dataMgr->reloadServerData(); 471 dataMgr->reloadServerData();
465 serverSelected( -1 ); 472 serverSelected( -1 );
466 } 473 }
467} 474}
468 475
469void NetworkPackageManager :: downloadSelectedPackages() 476void NetworkPackageManager :: downloadSelectedPackages()
470{ 477{
471 // First, write out ipkg_conf file so that ipkg can use it 478 // First, write out ipkg_conf file so that ipkg can use it
472 dataMgr->writeOutIpkgConf(); 479 dataMgr->writeOutIpkgConf();
473 480
474 // Display dialog to user asking where to download the files to 481 // Display dialog to user asking where to download the files to
475 bool ok = FALSE; 482 bool ok = FALSE;
476 QString dir = ""; 483 QString dir = "";
477#ifdef QWS 484#ifdef QWS
478 // read download directory from config file 485 // read download directory from config file
479 Config cfg( "aqpkg" ); 486 Config cfg( "aqpkg" );
480 cfg.setGroup( "settings" ); 487 cfg.setGroup( "settings" );
481 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 488 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
482#endif 489#endif
483 490
484 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 491 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
485 if ( ok && !text.isEmpty() ) 492 if ( ok && !text.isEmpty() )
486 dir = text; // user entered something and pressed ok 493 dir = text; // user entered something and pressed ok
487 else 494 else
488 return; // user entered nothing or pressed cancel 495 return; // user entered nothing or pressed cancel
489 496
490#ifdef QWS 497#ifdef QWS
491 // Store download directory in config file 498 // Store download directory in config file
492 cfg.writeEntry( "downloadDir", dir ); 499 cfg.writeEntry( "downloadDir", dir );
493#endif 500#endif
494 501
495 // Get starting directory 502 // Get starting directory
496 char initDir[PATH_MAX]; 503 char initDir[PATH_MAX];
497 getcwd( initDir, PATH_MAX ); 504 getcwd( initDir, PATH_MAX );
498 505
499 // Download each package 506 // Download each package
500 Ipkg ipkg; 507 Ipkg ipkg;
501 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 508 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
502 509
503 ipkg.setOption( "download" ); 510 ipkg.setOption( "download" );
504 ipkg.setRuntimeDirectory( dir ); 511 ipkg.setRuntimeDirectory( dir );
505 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 512 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
506 item != 0 ; 513 item != 0 ;
507 item = (QCheckListItem *)item->nextSibling() ) 514 item = (QCheckListItem *)item->nextSibling() )
508 { 515 {
509 if ( item->isOn() ) 516 if ( item->isOn() )
510 { 517 {
511 QString name = item->text(); 518 ipkg.setPackage( item->text() );
512 int pos = name.find( "*" );
513 name.truncate( pos );
514
515 // if (there is a (installed), remove it
516 pos = name.find( "(installed)" );
517 if ( pos > 0 )
518 name.truncate( pos - 1 );
519
520 ipkg.setPackage( name );
521 ipkg.runIpkg( ); 519 ipkg.runIpkg( );
522 } 520 }
523 } 521 }
524} 522}
525 523
526void NetworkPackageManager :: downloadRemotePackage() 524void NetworkPackageManager :: downloadRemotePackage()
527{ 525{
528 // Display dialog 526 // Display dialog
529 bool ok; 527 bool ok;
530 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); 528 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
531 if ( !ok || package.isEmpty() ) 529 if ( !ok || package.isEmpty() )
532 return; 530 return;
533// DownloadRemoteDlgImpl dlg( this, "Install", true ); 531// DownloadRemoteDlgImpl dlg( this, "Install", true );
534// if ( dlg.exec() == QDialog::Rejected ) 532// if ( dlg.exec() == QDialog::Rejected )
535// return; 533// return;
536 534
537 // grab details from dialog 535 // grab details from dialog
538// QString package = dlg.getPackageLocation(); 536// QString package = dlg.getPackageLocation();
539 537
540 InstallData item; 538 InstallData item;
541 item.option = "I"; 539 item.option = "I";
542 item.packageName = package; 540 item.packageName = package;
543 vector<InstallData> workingPackages; 541 vector<InstallData> workingPackages;
544 workingPackages.push_back( item ); 542 workingPackages.push_back( item );
545 543
546 InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true ); 544 InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true );
547 dlg2.showDlg(); 545 dlg2.showDlg();
548 546
549 // Reload data 547 // Reload data
550 dataMgr->reloadServerData(); 548 dataMgr->reloadServerData();
551 serverSelected(-1); 549 serverSelected(-1);
552 550
553#ifdef QWS 551#ifdef QWS
554 // Finally let the main system update itself 552 // Finally let the main system update itself
555 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 553 QCopEnvelope e("QPE/System", "linkChanged(QString)");
556 QString lf = QString::null; 554 QString lf = QString::null;
557 e << lf; 555 e << lf;
558#endif 556#endif
559} 557}
560 558
561 559
562void NetworkPackageManager :: applyChanges() 560void NetworkPackageManager :: applyChanges()
563{ 561{
564 stickyOption = ""; 562 stickyOption = "";
565 563
566 // First, write out ipkg_conf file so that ipkg can use it 564 // First, write out ipkg_conf file so that ipkg can use it
567 dataMgr->writeOutIpkgConf(); 565 dataMgr->writeOutIpkgConf();
568 566
569 // Now for each selected item 567 // Now for each selected item
570 // deal with it 568 // deal with it
571 569
572 vector<InstallData> workingPackages; 570 vector<InstallData> workingPackages;
573 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 571 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
574 item != 0 ; 572 item != 0 ;
575 item = (QCheckListItem *)item->nextSibling() ) 573 item = (QCheckListItem *)item->nextSibling() )
576 { 574 {
577 if ( item->isOn() ) 575 if ( item->isOn() )
578 { 576 {
579 InstallData data = dealWithItem( item ); 577 InstallData data = dealWithItem( item );
580 workingPackages.push_back( data ); 578 workingPackages.push_back( data );
581 } 579 }
582 } 580 }
583 581
584 if ( workingPackages.size() == 0 ) 582 if ( workingPackages.size() == 0 )
585 { 583 {
586 // Nothing to do 584 // Nothing to do
587 QMessageBox::information( this, tr( "Nothing to do" ), 585 QMessageBox::information( this, tr( "Nothing to do" ),
588 tr( "No packages selected" ), tr( "OK" ) ); 586 tr( "No packages selected" ), tr( "OK" ) );
589 587
590 return; 588 return;
591 } 589 }
592 590
593 // do the stuff 591 // do the stuff
594 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 592 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
595 dlg.showDlg(); 593 dlg.showDlg();
596 594
597 // Reload data 595 // Reload data
598 dataMgr->reloadServerData(); 596 dataMgr->reloadServerData();
599 serverSelected(-1); 597 serverSelected(-1);
600 598
601#ifdef QWS 599#ifdef QWS
602 // Finally let the main system update itself 600 // Finally let the main system update itself
603 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 601 QCopEnvelope e("QPE/System", "linkChanged(QString)");
604 QString lf = QString::null; 602 QString lf = QString::null;
605 e << lf; 603 e << lf;
606#endif 604#endif
607} 605}
608 606
609// decide what to do - either remove, upgrade or install 607// decide what to do - either remove, upgrade or install
610// Current rules: 608// Current rules:
611// If not installed - install 609// If not installed - install
612// If installed and different version available - upgrade 610// If installed and different version available - upgrade
613// If installed and version up to date - remove 611// If installed and version up to date - remove
614InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 612InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
615{ 613{
616 QString name = item->text(); 614 QString name = item->text();
617 int pos = name.find( "*" );
618 name.truncate( pos );
619
620 // if (there is a (installed), remove it
621 pos = name.find( "(installed)" );
622 if ( pos > 0 )
623 name.truncate( pos - 1 );
624 615
625 // Get package 616 // Get package
626 vector<Server>::iterator s = dataMgr->getServer( serversList->currentText() ); 617 vector<Server>::iterator s = dataMgr->getServer( serversList->currentText() );
627 Package *p = s->getPackage( name ); 618 Package *p = s->getPackage( name );
628 619
629 // If the package has a filename then it is a local file 620 // If the package has a filename then it is a local file
630 if ( p->isPackageStoredLocally() ) 621 if ( p->isPackageStoredLocally() )
631 name = p->getFilename(); 622 name = p->getFilename();
632 623
633 QString option; 624 QString option;
634 QString dest = "root"; 625 QString dest = "root";
635 if ( !p->isInstalled() ) 626 if ( !p->isInstalled() )
636 { 627 {
637 InstallData item; 628 InstallData item;
638 item.option = "I"; 629 item.option = "I";
639 item.packageName = name; 630 item.packageName = name;
640 return item; 631 return item;
641 } 632 }
642 else 633 else
643 { 634 {
644 InstallData item; 635 InstallData item;
645 item.option = "D"; 636 item.option = "D";
646 if ( !p->isPackageStoredLocally() ) 637 if ( !p->isPackageStoredLocally() )
647 item.packageName = p->getInstalledPackageName(); 638 item.packageName = p->getInstalledPackageName();
648 else 639 else
649 item.packageName = name; 640 item.packageName = name;
650 641
651 if ( p->getInstalledTo() ) 642 if ( p->getInstalledTo() )
652 { 643 {
653 item.destination = p->getInstalledTo(); 644 item.destination = p->getInstalledTo();
654 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 645// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
655 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 646// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
656 } 647 }
657 else 648 else
658 { 649 {
659 item.destination = p->getLocalPackage()->getInstalledTo(); 650 item.destination = p->getLocalPackage()->getInstalledTo();
660 } 651 }
661 652
662 // Now see if version is newer or not 653 // Now see if version is newer or not
663 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 654 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
664 655
665 // If the version requested is older and user selected a local ipk file, then reinstall the file 656 // If the version requested is older and user selected a local ipk file, then reinstall the file
666 if ( p->isPackageStoredLocally() && val == -1 ) 657 if ( p->isPackageStoredLocally() && val == -1 )
667 val = 0; 658 val = 0;
668 659
669 if ( val == -2 ) 660 if ( val == -2 )
670 { 661 {
671 // Error - should handle 662 // Error - should handle
672 } 663 }
673 else if ( val == -1 ) 664 else if ( val == -1 )
674 { 665 {
675 // Version available is older - remove only 666 // Version available is older - remove only
676 item.option = "D"; 667 item.option = "D";
677 } 668 }
678 else 669 else
679 { 670 {
680 QString caption; 671 QString caption;
681 QString text; 672 QString text;
682 QString secondButton; 673 QString secondButton;
683 QString secondOption; 674 QString secondOption;
684 if ( val == 0 ) 675 if ( val == 0 )
685 { 676 {
686 // Version available is the same - option to remove or reinstall 677 // Version available is the same - option to remove or reinstall
687 caption = tr( "Do you wish to remove or reinstall\n%1?" ); 678 caption = tr( "Do you wish to remove or reinstall\n%1?" );
688 text = tr( "Remove or ReInstall" ); 679 text = tr( "Remove or ReInstall" );
689 secondButton = tr( "ReInstall" ); 680 secondButton = tr( "ReInstall" );
690 secondOption = tr( "R" ); 681 secondOption = tr( "R" );
691 } 682 }
692 else if ( val == 1 ) 683 else if ( val == 1 )
693 { 684 {
694 // Version available is newer - option to remove or upgrade 685 // Version available is newer - option to remove or upgrade
695 caption = tr( "Do you wish to remove or upgrade\n%1?" ); 686 caption = tr( "Do you wish to remove or upgrade\n%1?" );
696 text = tr( "Remove or Upgrade" ); 687 text = tr( "Remove or Upgrade" );
697 secondButton = tr( "Upgrade" ); 688 secondButton = tr( "Upgrade" );
698 secondOption = tr( "U" ); 689 secondOption = tr( "U" );
699 } 690 }
700 691
701 // Sticky option not implemented yet, but will eventually allow 692 // Sticky option not implemented yet, but will eventually allow
702 // the user to say something like 'remove all' 693 // the user to say something like 'remove all'
703 if ( stickyOption == "" ) 694 if ( stickyOption == "" )
704 { 695 {
705 QString msgtext; 696 QString msgtext;
706 msgtext = caption.arg( ( const char * )name ); 697 msgtext = caption.arg( ( const char * )name );
707 switch( QMessageBox::information( this, text, 698 switch( QMessageBox::information( this, text,
708 msgtext, tr( "Remove" ), secondButton ) ) 699 msgtext, tr( "Remove" ), secondButton ) )
709 { 700 {
710 case 0: // Try again or Enter 701 case 0: // Try again or Enter
711 // option 0 = Remove 702 // option 0 = Remove
712 item.option = "D"; 703 item.option = "D";
713 break; 704 break;
714 case 1: // Quit or Escape 705 case 1: // Quit or Escape
715 item.option = secondOption; 706 item.option = secondOption;
716 break; 707 break;
717 } 708 }
718 } 709 }
719 else 710 else
720 { 711 {
721// item.option = stickyOption; 712// item.option = stickyOption;
722 } 713 }
723 } 714 }
724 715
725 716
726 // Check if we are reinstalling the same version 717 // Check if we are reinstalling the same version
727 if ( item.option != "R" ) 718 if ( item.option != "R" )
728 item.recreateLinks = true; 719 item.recreateLinks = true;
729 else 720 else
730 item.recreateLinks = false; 721 item.recreateLinks = false;
731 722
732 // User hit cancel (on dlg - assume remove) 723 // User hit cancel (on dlg - assume remove)
733 return item; 724 return item;
734 } 725 }
735} 726}
736 727
737void NetworkPackageManager :: displayText( const QString &t ) 728void NetworkPackageManager :: displayText( const QString &/*t*/ )
738{ 729{
739 cout << t << endl; 730// cout << t << endl;
740} 731}
741 732
742 733
743void NetworkPackageManager :: letterPushed( QString t ) 734void NetworkPackageManager :: letterPushed( QString t )
744{ 735{
745 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 736 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
746 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 737 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
747 if ( packagesList->firstChild() == 0 ) 738 if ( packagesList->firstChild() == 0 )
748 return; 739 return;
749 740
750 QCheckListItem *item; 741 QCheckListItem *item;
751 if ( start == 0 ) 742 if ( start == 0 )
752 { 743 {
753 item = (QCheckListItem *)packagesList->firstChild(); 744 item = (QCheckListItem *)packagesList->firstChild();
754 start = top; 745 start = top;
755 } 746 }
756 else 747 else
757 item = (QCheckListItem *)start->nextSibling(); 748 item = (QCheckListItem *)start->nextSibling();
758 749
759 if ( item == 0 ) 750 if ( item == 0 )
760 item = (QCheckListItem *)packagesList->firstChild(); 751 item = (QCheckListItem *)packagesList->firstChild();
761 do 752 do
762 { 753 {
763 if ( item->text().lower().startsWith( t.lower() ) ) 754 if ( item->text().lower().startsWith( t.lower() ) )
764 { 755 {
765 packagesList->setSelected( item, true ); 756 packagesList->setSelected( item, true );
766 packagesList->ensureItemVisible( item ); 757 packagesList->ensureItemVisible( item );
767 break; 758 break;
768 } 759 }
769 760
770 item = (QCheckListItem *)item->nextSibling(); 761 item = (QCheckListItem *)item->nextSibling();
771 if ( !item ) 762 if ( !item )
772 item = (QCheckListItem *)packagesList->firstChild(); 763 item = (QCheckListItem *)packagesList->firstChild();
773 } while ( item != start); 764 } while ( item != start);
774} 765}
775 766
776 767
777void NetworkPackageManager :: searchForPackage( const QString &text ) 768void NetworkPackageManager :: searchForPackage( const QString &text )
778{ 769{
779 if ( !text.isEmpty() ) 770 if ( !text.isEmpty() )
780 { 771 {
781 cout << "searching for " << text << endl; 772// cout << "searching for " << text << endl;
782 // look through package list for text startng at current position 773 // look through package list for text startng at current position
783 vector<InstallData> workingPackages; 774 vector<InstallData> workingPackages;
784 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 775 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
785 if ( start != 0 ) 776 if ( start != 0 )
786 start = (QCheckListItem *)start->nextSibling(); 777 start = (QCheckListItem *)start->nextSibling();
787 778
788 if ( start == 0 ) 779 if ( start == 0 )
789 start = (QCheckListItem *)packagesList->firstChild(); 780 start = (QCheckListItem *)packagesList->firstChild();
790 781
791 for ( QCheckListItem *item = start; item != 0 ; 782 for ( QCheckListItem *item = start; item != 0 ;
792 item = (QCheckListItem *)item->nextSibling() ) 783 item = (QCheckListItem *)item->nextSibling() )
793 { 784 {
794 cout << "checking " << item->text().lower() << endl; 785// cout << "checking " << item->text().lower() << endl;
795 if ( item->text().lower().find( text ) != -1 ) 786 if ( item->text().lower().find( text ) != -1 )
796 { 787 {
797 cout << "matched " << item->text() << endl; 788// cout << "matched " << item->text() << endl;
798 packagesList->ensureItemVisible( item ); 789 packagesList->ensureItemVisible( item );
799 packagesList->setCurrentItem( item ); 790 packagesList->setCurrentItem( item );
800 break; 791 break;
801 } 792 }
802 } 793 }
803 } 794 }
804} 795}
805 796
806void NetworkPackageManager :: showOnlyUninstalledPackages( bool val ) 797void NetworkPackageManager :: showOnlyUninstalledPackages( bool val )
807{ 798{
808 showUninstalledPkgs = val; 799 showUninstalledPkgs = val;
809 if ( val ) 800 if ( val )
810 { 801 {
811 showInstalledPkgs = FALSE; 802 showInstalledPkgs = FALSE;
812 showUpgradedPkgs = FALSE; 803 showUpgradedPkgs = FALSE;
813 } 804 }
814 serverSelected( -1 ); 805 serverSelected( -1 );
815} 806}
816 807
817void NetworkPackageManager :: showOnlyInstalledPackages( bool val ) 808void NetworkPackageManager :: showOnlyInstalledPackages( bool val )
818{ 809{
819 showInstalledPkgs = val; 810 showInstalledPkgs = val;
820 if ( val ) 811 if ( val )
821 { 812 {
822 showUninstalledPkgs = FALSE; 813 showUninstalledPkgs = FALSE;
823 showUpgradedPkgs = FALSE; 814 showUpgradedPkgs = FALSE;
824 } 815 }
825 serverSelected( -1 ); 816 serverSelected( -1 );
826} 817}
827 818
828void NetworkPackageManager :: showUpgradedPackages( bool val ) 819void NetworkPackageManager :: showUpgradedPackages( bool val )
829{ 820{
830 showUpgradedPkgs = val; 821 showUpgradedPkgs = val;
831 if ( val ) 822 if ( val )
832 { 823 {
833 showUninstalledPkgs = FALSE; 824 showUninstalledPkgs = FALSE;
834 showInstalledPkgs = FALSE; 825 showInstalledPkgs = FALSE;
835 } 826 }
836 serverSelected( -1 ); 827 serverSelected( -1 );
837} 828}
838 829
839bool NetworkPackageManager :: filterByCategory( bool val ) 830bool NetworkPackageManager :: filterByCategory( bool val )
840{ 831{
841 if ( val ) 832 if ( val )
842 { 833 {
843 if ( categoryFilter == "" ) 834 if ( categoryFilter == "" )
844 { 835 {
845 if ( !setFilterCategory() ) 836 if ( !setFilterCategory() )
846 return false; 837 return false;
847 } 838 }
848 839
849 categoryFilterEnabled = true; 840 categoryFilterEnabled = true;
850 serverSelected( -1 ); 841 serverSelected( -1 );
851 return true; 842 return true;
852 } 843 }
853 else 844 else
854 { 845 {
855 // Turn off filter 846 // Turn off filter
856 categoryFilterEnabled = false; 847 categoryFilterEnabled = false;
857 serverSelected( -1 ); 848 serverSelected( -1 );
858 return false; 849 return false;
859 } 850 }
860} 851}
861 852
862bool NetworkPackageManager :: setFilterCategory( ) 853bool NetworkPackageManager :: setFilterCategory( )
863{ 854{
864 // Get categories; 855 // Get categories;
865 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); 856 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
866 if ( dlg.exec() == QDialog::Accepted ) 857 if ( dlg.exec() == QDialog::Accepted )
867 { 858 {
868 categoryFilter = dlg.getSelectedFilter(); 859 categoryFilter = dlg.getSelectedFilter();
869 860
870 if ( categoryFilter == "" ) 861 if ( categoryFilter == "" )
871 return false; 862 return false;
872 863
873 categoryFilterEnabled = true; 864 categoryFilterEnabled = true;
874 serverSelected( -1 ); 865 serverSelected( -1 );
875 return true; 866 return true;
876 } 867 }
877 868
878 return false; 869 return false;
879} 870}
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h
index bd005e2..99eff2e 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.h
+++ b/noncore/settings/aqpkg/networkpkgmgr.h
@@ -1,96 +1,100 @@
1/*************************************************************************** 1/***************************************************************************
2 networkpkgmgr.h - description 2 networkpkgmgr.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef NETWORKPKGMGR_H 18#ifndef NETWORKPKGMGR_H
19#define NETWORKPKGMGR_H 19#define NETWORKPKGMGR_H
20 20
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qpixmap.h>
22#include <qpushbutton.h> 23#include <qpushbutton.h>
23#include <qwidget.h> 24#include <qwidget.h>
24#include <qcombobox.h> 25#include <qcombobox.h>
25#include <qlistview.h> 26#include <qlistview.h>
26 27
27#include "datamgr.h" 28#include "datamgr.h"
28 29
29class InstallData; 30class InstallData;
30 31
31/** NetworkPackageManager is the base class of the project */ 32/** NetworkPackageManager is the base class of the project */
32class NetworkPackageManager : public QWidget 33class NetworkPackageManager : public QWidget
33{ 34{
34 Q_OBJECT 35 Q_OBJECT
35public: 36public:
36 /** construtor */ 37 /** construtor */
37 NetworkPackageManager( QWidget* parent=0, const char *name=0 ); 38 NetworkPackageManager( QWidget* parent=0, const char *name=0 );
38 /** destructor */ 39 /** destructor */
39 ~NetworkPackageManager(); 40 ~NetworkPackageManager();
40 41
41 void setDataManager( DataManager *dm ); 42 void setDataManager( DataManager *dm );
42 void selectLocalPackage( const QString &pkg ); 43 void selectLocalPackage( const QString &pkg );
43 void updateData(); 44 void updateData();
44 void searchForPackage( const QString & ); 45 void searchForPackage( const QString & );
45 void showOnlyUninstalledPackages( bool val ); 46 void showOnlyUninstalledPackages( bool val );
46 void showOnlyInstalledPackages( bool val ); 47 void showOnlyInstalledPackages( bool val );
47 void showUpgradedPackages( bool val ); 48 void showUpgradedPackages( bool val );
48 bool filterByCategory( bool val ); 49 bool filterByCategory( bool val );
49 bool setFilterCategory(); 50 bool setFilterCategory();
50 51
51private: 52private:
52 DataManager *dataMgr; 53 DataManager *dataMgr;
53 54
54 QComboBox *serversList; 55 QComboBox *serversList;
55 QListView *packagesList; 56 QListView *packagesList;
57
58 QPixmap installedIcon;
59 QPixmap updatedIcon;
56 60
57 QString currentlySelectedServer; 61 QString currentlySelectedServer;
58 QString categoryFilter; 62 QString categoryFilter;
59 63
60 bool categoryFilterEnabled; 64 bool categoryFilterEnabled;
61 bool showJumpTo; 65 bool showJumpTo;
62 bool showUninstalledPkgs; 66 bool showUninstalledPkgs;
63 bool showInstalledPkgs; 67 bool showInstalledPkgs;
64 bool showUpgradedPkgs; 68 bool showUpgradedPkgs;
65 69
66 bool downloadEnabled; 70 bool downloadEnabled;
67 71
68 void initGui(); 72 void initGui();
69 void showProgressDialog( char *initialText ); 73 void showProgressDialog( char *initialText );
70 void downloadSelectedPackages(); 74 void downloadSelectedPackages();
71 void downloadRemotePackage(); 75 void downloadRemotePackage();
72 void serverSelected( int index, bool showProgress ); 76 void serverSelected( int index, bool showProgress );
73 77
74 InstallData dealWithItem( QCheckListItem *item ); 78 InstallData dealWithItem( QCheckListItem *item );
75 QString stickyOption; 79 QString stickyOption;
76 80
77signals: 81signals:
78 void appRaiseMainWidget(); 82 void appRaiseMainWidget();
79 void appRaiseProgressWidget(); 83 void appRaiseProgressWidget();
80 void appEnableUpgrade( bool ); 84 void appEnableUpgrade( bool );
81 void appEnableDownload( bool ); 85 void appEnableDownload( bool );
82 void progressSetSteps( int ); 86 void progressSetSteps( int );
83 void progressSetMessage( const QString & ); 87 void progressSetMessage( const QString & );
84 void progressUpdate( int ); 88 void progressUpdate( int );
85 89
86public slots: 90public slots:
87 void applyChanges(); 91 void applyChanges();
88 void upgradePackages(); 92 void upgradePackages();
89 void downloadPackage(); 93 void downloadPackage();
90 void updateServer(); 94 void updateServer();
91 void displayText( const QString &t ); 95 void displayText( const QString &t );
92 void letterPushed( QString t ); 96 void letterPushed( QString t );
93 void serverSelected( int index ); 97 void serverSelected( int index );
94}; 98};
95 99
96#endif 100#endif