summaryrefslogtreecommitdiff
path: root/noncore/settings
Unidiff
Diffstat (limited to 'noncore/settings') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp86
1 files changed, 54 insertions, 32 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index d4f751c..b92a245 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -14,48 +14,49 @@
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifdef QWS 18#ifdef QWS
19#include <qpe/config.h> 19#include <qpe/config.h>
20#endif 20#endif
21 21
22#include <qmultilineedit.h> 22#include <qmultilineedit.h>
23#include <qdialog.h> 23#include <qdialog.h>
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qcheckbox.h> 25#include <qcheckbox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27 27
28 28
29#include "datamgr.h" 29#include "datamgr.h"
30#include "instoptionsimpl.h" 30#include "instoptionsimpl.h"
31#include "destination.h" 31#include "destination.h"
32#include "installdlgimpl.h" 32#include "installdlgimpl.h"
33#include "global.h" 33#include "global.h"
34 34
35InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) 35InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
36 : InstallDlg( parent, name, modal, fl ) 36 : InstallDlg( parent, name, modal, fl )
37{ 37{
38 upgradePackages = false;
38 dataMgr = dataManager; 39 dataMgr = dataManager;
39 vector<Destination>::iterator dit; 40 vector<Destination>::iterator dit;
40 41
41 QString defaultDest = "root"; 42 QString defaultDest = "root";
42#ifdef QWS 43#ifdef QWS
43 Config cfg( "aqpkg" ); 44 Config cfg( "aqpkg" );
44 cfg.setGroup( "settings" ); 45 cfg.setGroup( "settings" );
45 defaultDest = cfg.readEntry( "dest", "root" ); 46 defaultDest = cfg.readEntry( "dest", "root" );
46 47
47 // Grab flags - Turn MAKE_LINKS on by default (if no flags found) 48 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
48 flags = cfg.readNumEntry( "installFlags", MAKE_LINKS ); 49 flags = cfg.readNumEntry( "installFlags", MAKE_LINKS );
49#else 50#else
50 flags = 0; 51 flags = 0;
51#endif 52#endif
52 53
53 // Output text is read only 54 // Output text is read only
54 output->setReadOnly( true ); 55 output->setReadOnly( true );
55 QFont f( "helvetica" ); 56 QFont f( "helvetica" );
56 f.setPointSize( 10 ); 57 f.setPointSize( 10 );
57 output->setFont( f ); 58 output->setFont( f );
58 59
59 60
60 // setup destination data 61 // setup destination data
61 int defIndex = 0; 62 int defIndex = 0;
@@ -78,120 +79,141 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM
78 { 79 {
79 QString name = *it; 80 QString name = *it;
80 if ( name.startsWith( "I" ) ) 81 if ( name.startsWith( "I" ) )
81 { 82 {
82 installList.push_back( name.mid(1) ); 83 installList.push_back( name.mid(1) );
83 install += " " + name.mid(1) + "\n"; 84 install += " " + name.mid(1) + "\n";
84 } 85 }
85 else if ( name.startsWith( "D" ) ) 86 else if ( name.startsWith( "D" ) )
86 { 87 {
87 removeList.push_back( name.mid(1) ); 88 removeList.push_back( name.mid(1) );
88 remove += " " + name.mid(1) + "\n"; 89 remove += " " + name.mid(1) + "\n";
89 } 90 }
90 else if ( name.startsWith( "U" ) ) 91 else if ( name.startsWith( "U" ) )
91 { 92 {
92 updateList.push_back( name.mid(1) ); 93 updateList.push_back( name.mid(1) );
93 upgrade += " " + name.mid(1) + "\n"; 94 upgrade += " " + name.mid(1) + "\n";
94 } 95 }
95 } 96 }
96 97
97 output->setText( remove + install + upgrade ); 98 output->setText( remove + install + upgrade );
98 99
99 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 100 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
100} 101}
101 102
103InstallDlgImpl::InstallDlgImpl( QWidget *parent, const char *name, bool modal, WFlags fl )
104 : InstallDlg( parent, name, modal, fl )
105{
106 upgradePackages = true;
107 output->setText( "Upgrading installed packages" );
108 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
109}
110
111
102InstallDlgImpl::~InstallDlgImpl() 112InstallDlgImpl::~InstallDlgImpl()
103{ 113{
104} 114}
105 115
106bool InstallDlgImpl :: showDlg() 116bool InstallDlgImpl :: showDlg()
107{ 117{
108 showMaximized(); 118 showMaximized();
109 bool ret = exec(); 119 bool ret = exec();
110 120
111 return ret; 121 return ret;
112} 122}
113 123
114void InstallDlgImpl :: optionsSelected() 124void InstallDlgImpl :: optionsSelected()
115{ 125{
116 InstallOptionsDlgImpl opt( flags, this, "Option", true ); 126 InstallOptionsDlgImpl opt( flags, this, "Option", true );
117 opt.exec(); 127 opt.exec();
118 128
119 // set options selected from dialog 129 // set options selected from dialog
120 flags = 0; 130 flags = 0;
121 if ( opt.forceDepends->isChecked() ) 131 if ( opt.forceDepends->isChecked() )
122 flags |= FORCE_DEPENDS; 132 flags |= FORCE_DEPENDS;
123 if ( opt.forceReinstall->isChecked() ) 133 if ( opt.forceReinstall->isChecked() )
124 flags |= FORCE_REINSTALL; 134 flags |= FORCE_REINSTALL;
125 if ( opt.forceRemove->isChecked() ) 135 if ( opt.forceRemove->isChecked() )
126 flags |= FORCE_REMOVE; 136 flags |= FORCE_REMOVE;
127 if ( opt.forceOverwrite->isChecked() ) 137 if ( opt.forceOverwrite->isChecked() )
128 flags |= FORCE_OVERWRITE; 138 flags |= FORCE_OVERWRITE;
129 if ( opt.makeLinks->isChecked() ) 139 if ( opt.makeLinks->isChecked() )
130 flags |= MAKE_LINKS; 140 flags |= MAKE_LINKS;
131 141
132#ifdef QWS 142#ifdef QWS
133 Config cfg( "aqpkg" ); 143 Config cfg( "aqpkg" );
134 cfg.setGroup( "settings" ); 144 cfg.setGroup( "settings" );
135 cfg.writeEntry( "installFlags", flags ); 145 cfg.writeEntry( "installFlags", flags );
136#endif 146#endif
137} 147}
138 148
139void InstallDlgImpl :: installSelected() 149void InstallDlgImpl :: installSelected()
140{ 150{
141 if ( btnInstall->text() == "Close" ) 151 if ( btnInstall->text() == "Close" )
142 { 152 {
143 done( 1 ); 153 done( 1 );
144 return; 154 return;
145 } 155 }
146 156
147 btnInstall->setEnabled( false ); 157 btnInstall->setEnabled( false );
148 158
149 output->setText( "" ); 159 if ( upgradePackages )
150 Destination *d = dataMgr->getDestination( destination->currentText() );
151 QString dest = d->getDestinationName();
152 QString destDir = d->getDestinationPath();
153
154#ifdef QWS
155 // Save settings
156 Config cfg( "aqpkg" );
157 cfg.setGroup( "settings" );
158 cfg.writeEntry( "dest", dest );
159#endif
160
161 // First run through the remove list, then the install list then the upgrade list
162 vector<QString>::iterator it;
163 ipkg.setOption( "remove" );
164 ipkg.setDestination( dest );
165 ipkg.setDestinationDir( destDir );
166 ipkg.setFlags( flags );
167 for ( it = removeList.begin() ; it != removeList.end() ; ++it )
168 { 160 {
169 ipkg.setPackage( *it ); 161 output->setText( "" );
162
163 Ipkg ipkg;
164 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
165 ipkg.setOption( "upgrade" );
170 ipkg.runIpkg(); 166 ipkg.runIpkg();
171 } 167 }
172 168 else
173 ipkg.setOption( "install" );
174 for ( it = installList.begin() ; it != installList.end() ; ++it )
175 { 169 {
176 ipkg.setPackage( *it ); 170 output->setText( "" );
177 ipkg.runIpkg(); 171 Destination *d = dataMgr->getDestination( destination->currentText() );
178 } 172 QString dest = d->getDestinationName();
173 QString destDir = d->getDestinationPath();
179 174
180 flags |= FORCE_REINSTALL; 175#ifdef QWS
181 ipkg.setFlags( flags ); 176 // Save settings
182 for ( it = updateList.begin() ; it != updateList.end() ; ++it ) 177 Config cfg( "aqpkg" );
183 { 178 cfg.setGroup( "settings" );
184 ipkg.setPackage( *it ); 179 cfg.writeEntry( "dest", dest );
185 ipkg.runIpkg(); 180#endif
181
182 // First run through the remove list, then the install list then the upgrade list
183 vector<QString>::iterator it;
184 ipkg.setOption( "remove" );
185 ipkg.setDestination( dest );
186 ipkg.setDestinationDir( destDir );
187 ipkg.setFlags( flags );
188 for ( it = removeList.begin() ; it != removeList.end() ; ++it )
189 {
190 ipkg.setPackage( *it );
191 ipkg.runIpkg();
192 }
193
194 ipkg.setOption( "install" );
195 for ( it = installList.begin() ; it != installList.end() ; ++it )
196 {
197 ipkg.setPackage( *it );
198 ipkg.runIpkg();
199 }
200
201 flags |= FORCE_REINSTALL;
202 ipkg.setFlags( flags );
203 for ( it = updateList.begin() ; it != updateList.end() ; ++it )
204 {
205 ipkg.setPackage( *it );
206 ipkg.runIpkg();
207 }
186 } 208 }
187 209
188 btnInstall->setEnabled( true ); 210 btnInstall->setEnabled( true );
189 btnInstall->setText( tr( "Close" ) ); 211 btnInstall->setText( tr( "Close" ) );
190} 212}
191 213
192void InstallDlgImpl :: displayText(const QString &text ) 214void InstallDlgImpl :: displayText(const QString &text )
193{ 215{
194 QString t = output->text() + "\n" + text; 216 QString t = output->text() + "\n" + text;
195 output->setText( t ); 217 output->setText( t );
196 output->setCursorPosition( output->numLines(), 0 ); 218 output->setCursorPosition( output->numLines(), 0 );
197} 219}