author | andyq <andyq> | 2002-10-17 23:24:27 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-10-17 23:24:27 (UTC) |
commit | 30b26ed0dbbbee829f16ab8ea1e531b89938232d (patch) (unidiff) | |
tree | 89f2639cfc97e74fa15c50cd360acba25e9a2cab | |
parent | cd48ed3935f1baa6392afee5764d0927abcf62cc (diff) | |
download | opie-30b26ed0dbbbee829f16ab8ea1e531b89938232d.zip opie-30b26ed0dbbbee829f16ab8ea1e531b89938232d.tar.gz opie-30b26ed0dbbbee829f16ab8ea1e531b89938232d.tar.bz2 |
Fixed bug which caused links to be recreated even if same version of package was reinstalled
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index bbb0be75..e122064 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp | |||
@@ -1,240 +1,236 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | installdlgimpl.cpp - description | 2 | installdlgimpl.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 2002 | 4 | begin : Mon Aug 26 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 | #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 | ||
35 | InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 35 | InstallDlgImpl::InstallDlgImpl( vector<InstallData> &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 | upgradePackages = false; |
39 | dataMgr = dataManager; | 39 | dataMgr = dataManager; |
40 | vector<Destination>::iterator dit; | 40 | vector<Destination>::iterator dit; |
41 | 41 | ||
42 | QString defaultDest = "root"; | 42 | QString defaultDest = "root"; |
43 | #ifdef QWS | 43 | #ifdef QWS |
44 | Config cfg( "aqpkg" ); | 44 | Config cfg( "aqpkg" ); |
45 | cfg.setGroup( "settings" ); | 45 | cfg.setGroup( "settings" ); |
46 | defaultDest = cfg.readEntry( "dest", "root" ); | 46 | defaultDest = cfg.readEntry( "dest", "root" ); |
47 | 47 | ||
48 | // 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) |
49 | // flags = cfg.readNumEntry( "installFlags", MAKE_LINKS ); | 49 | // flags = cfg.readNumEntry( "installFlags", MAKE_LINKS ); |
50 | flags = 0; | 50 | flags = 0; |
51 | #else | 51 | #else |
52 | flags = 0; | 52 | flags = 0; |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | // Output text is read only | 55 | // Output text is read only |
56 | output->setReadOnly( true ); | 56 | output->setReadOnly( true ); |
57 | QFont f( "helvetica" ); | 57 | QFont f( "helvetica" ); |
58 | f.setPointSize( 10 ); | 58 | f.setPointSize( 10 ); |
59 | output->setFont( f ); | 59 | output->setFont( f ); |
60 | 60 | ||
61 | 61 | ||
62 | // setup destination data | 62 | // setup destination data |
63 | int defIndex = 0; | 63 | int defIndex = 0; |
64 | int i; | 64 | int i; |
65 | for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) | 65 | for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) |
66 | { | 66 | { |
67 | destination->insertItem( dit->getDestinationName() ); | 67 | destination->insertItem( dit->getDestinationName() ); |
68 | if ( dit->getDestinationName() == defaultDest ) | 68 | if ( dit->getDestinationName() == defaultDest ) |
69 | defIndex = i; | 69 | defIndex = i; |
70 | } | 70 | } |
71 | 71 | ||
72 | destination->setCurrentItem( defIndex ); | 72 | destination->setCurrentItem( defIndex ); |
73 | 73 | ||
74 | vector<InstallData>::iterator it; | 74 | vector<InstallData>::iterator it; |
75 | // setup package data | 75 | // setup package data |
76 | QString remove = "Remove\n"; | 76 | QString remove = "Remove\n"; |
77 | QString install = "\nInstall\n"; | 77 | QString install = "\nInstall\n"; |
78 | QString upgrade = "\nUpgrade\n"; | 78 | QString upgrade = "\nUpgrade\n"; |
79 | for ( it = packageList.begin() ; it != packageList.end() ; ++it ) | 79 | for ( it = packageList.begin() ; it != packageList.end() ; ++it ) |
80 | { | 80 | { |
81 | InstallData item = *it; | 81 | InstallData item = *it; |
82 | if ( item.option == "I" ) | 82 | if ( item.option == "I" ) |
83 | { | 83 | { |
84 | installList.push_back( item ); | 84 | installList.push_back( item ); |
85 | install += " " + item.packageName + "\n"; | 85 | install += " " + item.packageName + "\n"; |
86 | } | 86 | } |
87 | else if ( item.option == "D" ) | 87 | else if ( item.option == "D" ) |
88 | { | 88 | { |
89 | removeList.push_back( item ); | 89 | removeList.push_back( item ); |
90 | remove += " " + item.packageName + "\n"; | 90 | remove += " " + item.packageName + "\n"; |
91 | } | 91 | } |
92 | else if ( item.option == "U" ) | 92 | else if ( item.option == "U" ) |
93 | { | 93 | { |
94 | updateList.push_back( item ); | 94 | updateList.push_back( item ); |
95 | upgrade += " " + item.packageName + "\n"; | 95 | upgrade += " " + item.packageName + "\n"; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | output->setText( remove + install + upgrade ); | 99 | output->setText( remove + install + upgrade ); |
100 | 100 | ||
101 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 101 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
102 | } | 102 | } |
103 | 103 | ||
104 | InstallDlgImpl::InstallDlgImpl( QWidget *parent, const char *name, bool modal, WFlags fl ) | 104 | InstallDlgImpl::InstallDlgImpl( QWidget *parent, const char *name, bool modal, WFlags fl ) |
105 | : InstallDlg( parent, name, modal, fl ) | 105 | : InstallDlg( parent, name, modal, fl ) |
106 | { | 106 | { |
107 | upgradePackages = true; | 107 | upgradePackages = true; |
108 | output->setText( "Upgrading installed packages" ); | 108 | output->setText( "Upgrading installed packages" ); |
109 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 109 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | InstallDlgImpl::~InstallDlgImpl() | 113 | InstallDlgImpl::~InstallDlgImpl() |
114 | { | 114 | { |
115 | } | 115 | } |
116 | 116 | ||
117 | bool InstallDlgImpl :: showDlg() | 117 | bool InstallDlgImpl :: showDlg() |
118 | { | 118 | { |
119 | showMaximized(); | 119 | showMaximized(); |
120 | bool ret = exec(); | 120 | bool ret = exec(); |
121 | 121 | ||
122 | return ret; | 122 | return ret; |
123 | } | 123 | } |
124 | 124 | ||
125 | void InstallDlgImpl :: optionsSelected() | 125 | void InstallDlgImpl :: optionsSelected() |
126 | { | 126 | { |
127 | InstallOptionsDlgImpl opt( flags, this, "Option", true ); | 127 | InstallOptionsDlgImpl opt( flags, this, "Option", true ); |
128 | opt.exec(); | 128 | opt.exec(); |
129 | 129 | ||
130 | // set options selected from dialog | 130 | // set options selected from dialog |
131 | flags = 0; | 131 | flags = 0; |
132 | if ( opt.forceDepends->isChecked() ) | 132 | if ( opt.forceDepends->isChecked() ) |
133 | flags |= FORCE_DEPENDS; | 133 | flags |= FORCE_DEPENDS; |
134 | if ( opt.forceReinstall->isChecked() ) | 134 | if ( opt.forceReinstall->isChecked() ) |
135 | flags |= FORCE_REINSTALL; | 135 | flags |= FORCE_REINSTALL; |
136 | if ( opt.forceRemove->isChecked() ) | 136 | if ( opt.forceRemove->isChecked() ) |
137 | flags |= FORCE_REMOVE; | 137 | flags |= FORCE_REMOVE; |
138 | if ( opt.forceOverwrite->isChecked() ) | 138 | if ( opt.forceOverwrite->isChecked() ) |
139 | flags |= FORCE_OVERWRITE; | 139 | flags |= FORCE_OVERWRITE; |
140 | 140 | ||
141 | #ifdef QWS | 141 | #ifdef QWS |
142 | Config cfg( "aqpkg" ); | 142 | Config cfg( "aqpkg" ); |
143 | cfg.setGroup( "settings" ); | 143 | cfg.setGroup( "settings" ); |
144 | cfg.writeEntry( "installFlags", flags ); | 144 | cfg.writeEntry( "installFlags", flags ); |
145 | #endif | 145 | #endif |
146 | } | 146 | } |
147 | 147 | ||
148 | void InstallDlgImpl :: installSelected() | 148 | void InstallDlgImpl :: installSelected() |
149 | { | 149 | { |
150 | if ( btnInstall->text() == "Close" ) | 150 | if ( btnInstall->text() == "Close" ) |
151 | { | 151 | { |
152 | done( 1 ); | 152 | done( 1 ); |
153 | return; | 153 | return; |
154 | } | 154 | } |
155 | 155 | ||
156 | btnInstall->setEnabled( false ); | 156 | btnInstall->setEnabled( false ); |
157 | 157 | ||
158 | if ( upgradePackages ) | 158 | if ( upgradePackages ) |
159 | { | 159 | { |
160 | output->setText( "" ); | 160 | output->setText( "" ); |
161 | 161 | ||
162 | Ipkg ipkg; | 162 | Ipkg ipkg; |
163 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 163 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
164 | ipkg.setOption( "upgrade" ); | 164 | ipkg.setOption( "upgrade" ); |
165 | ipkg.runIpkg(); | 165 | ipkg.runIpkg(); |
166 | } | 166 | } |
167 | else | 167 | else |
168 | { | 168 | { |
169 | output->setText( "" ); | 169 | output->setText( "" ); |
170 | Destination *d = dataMgr->getDestination( destination->currentText() ); | 170 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
171 | QString dest = d->getDestinationName(); | 171 | QString dest = d->getDestinationName(); |
172 | QString destDir = d->getDestinationPath(); | 172 | QString destDir = d->getDestinationPath(); |
173 | int instFlags = 0; | 173 | int instFlags = flags; |
174 | if ( d->linkToRoot() ) | 174 | if ( d->linkToRoot() ) |
175 | instFlags = MAKE_LINKS; | 175 | instFlags |= MAKE_LINKS; |
176 | 176 | ||
177 | #ifdef QWS | 177 | #ifdef QWS |
178 | // Save settings | 178 | // Save settings |
179 | Config cfg( "aqpkg" ); | 179 | Config cfg( "aqpkg" ); |
180 | cfg.setGroup( "settings" ); | 180 | cfg.setGroup( "settings" ); |
181 | cfg.writeEntry( "dest", dest ); | 181 | cfg.writeEntry( "dest", dest ); |
182 | #endif | 182 | #endif |
183 | 183 | ||
184 | // First run through the remove list, then the install list then the upgrade list | 184 | // First run through the remove list, then the install list then the upgrade list |
185 | vector<InstallData>::iterator it; | 185 | vector<InstallData>::iterator it; |
186 | ipkg.setOption( "remove" ); | 186 | ipkg.setOption( "remove" ); |
187 | for ( it = removeList.begin() ; it != removeList.end() ; ++it ) | 187 | for ( it = removeList.begin() ; it != removeList.end() ; ++it ) |
188 | { | 188 | { |
189 | ipkg.setDestination( it->destination->getDestinationName() ); | 189 | ipkg.setDestination( it->destination->getDestinationName() ); |
190 | ipkg.setDestinationDir( it->destination->getDestinationPath() ); | 190 | ipkg.setDestinationDir( it->destination->getDestinationPath() ); |
191 | ipkg.setPackage( it->packageName ); | 191 | ipkg.setPackage( it->packageName ); |
192 | 192 | ||
193 | int tmpFlags = flags; | 193 | int tmpFlags = flags; |
194 | if ( it->destination->linkToRoot() ) | 194 | if ( it->destination->linkToRoot() ) |
195 | tmpFlags |= MAKE_LINKS; | 195 | tmpFlags |= MAKE_LINKS; |
196 | else | ||
197 | tmpFlags ^= MAKE_LINKS; | ||
198 | 196 | ||
199 | ipkg.setFlags( tmpFlags ); | 197 | ipkg.setFlags( tmpFlags ); |
200 | ipkg.runIpkg(); | 198 | ipkg.runIpkg(); |
201 | } | 199 | } |
202 | 200 | ||
203 | ipkg.setOption( "install" ); | 201 | ipkg.setOption( "install" ); |
204 | ipkg.setDestination( dest ); | 202 | ipkg.setDestination( dest ); |
205 | ipkg.setDestinationDir( destDir ); | 203 | ipkg.setDestinationDir( destDir ); |
206 | ipkg.setFlags( instFlags ); | 204 | ipkg.setFlags( instFlags ); |
207 | for ( it = installList.begin() ; it != installList.end() ; ++it ) | 205 | for ( it = installList.begin() ; it != installList.end() ; ++it ) |
208 | { | 206 | { |
209 | ipkg.setPackage( it->packageName ); | 207 | ipkg.setPackage( it->packageName ); |
210 | ipkg.runIpkg(); | 208 | ipkg.runIpkg(); |
211 | } | 209 | } |
212 | 210 | ||
213 | flags |= FORCE_REINSTALL; | 211 | flags |= FORCE_REINSTALL; |
214 | ipkg.setOption( "reinstall" ); | 212 | ipkg.setOption( "reinstall" ); |
215 | for ( it = updateList.begin() ; it != updateList.end() ; ++it ) | 213 | for ( it = updateList.begin() ; it != updateList.end() ; ++it ) |
216 | { | 214 | { |
217 | ipkg.setDestination( it->destination->getDestinationName() ); | 215 | ipkg.setDestination( it->destination->getDestinationName() ); |
218 | ipkg.setDestinationDir( it->destination->getDestinationPath() ); | 216 | ipkg.setDestinationDir( it->destination->getDestinationPath() ); |
219 | ipkg.setPackage( it->packageName ); | 217 | ipkg.setPackage( it->packageName ); |
220 | 218 | ||
221 | int tmpFlags = flags; | 219 | int tmpFlags = flags; |
222 | if ( it->destination->linkToRoot() && it->recreateLinks ) | 220 | if ( it->destination->linkToRoot() && it->recreateLinks ) |
223 | tmpFlags |= MAKE_LINKS; | 221 | tmpFlags |= MAKE_LINKS; |
224 | else | ||
225 | tmpFlags ^= MAKE_LINKS; | ||
226 | ipkg.setFlags( tmpFlags ); | 222 | ipkg.setFlags( tmpFlags ); |
227 | ipkg.runIpkg(); | 223 | ipkg.runIpkg(); |
228 | } | 224 | } |
229 | } | 225 | } |
230 | 226 | ||
231 | btnInstall->setEnabled( true ); | 227 | btnInstall->setEnabled( true ); |
232 | btnInstall->setText( tr( "Close" ) ); | 228 | btnInstall->setText( tr( "Close" ) ); |
233 | } | 229 | } |
234 | 230 | ||
235 | void InstallDlgImpl :: displayText(const QString &text ) | 231 | void InstallDlgImpl :: displayText(const QString &text ) |
236 | { | 232 | { |
237 | QString t = output->text() + "\n" + text; | 233 | QString t = output->text() + "\n" + text; |
238 | output->setText( t ); | 234 | output->setText( t ); |
239 | output->setCursorPosition( output->numLines(), 0 ); | 235 | output->setCursorPosition( output->numLines(), 0 ); |
240 | } | 236 | } |