summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index bfb4f62..80c06ba 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -52,223 +52,237 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d
52 52
53 // Grab flags - Turn MAKE_LINKS on by default (if no flags found) 53 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
54 flags = cfg.readNumEntry( "installFlags", 0 ); 54 flags = cfg.readNumEntry( "installFlags", 0 );
55#else 55#else
56 flags = 0; 56 flags = 0;
57#endif 57#endif
58 58
59 // Output text is read only 59 // Output text is read only
60 output->setReadOnly( true ); 60 output->setReadOnly( true );
61 QFont f( "helvetica" ); 61 QFont f( "helvetica" );
62 f.setPointSize( 10 ); 62 f.setPointSize( 10 );
63 output->setFont( f ); 63 output->setFont( f );
64 64
65 65
66 // setup destination data 66 // setup destination data
67 int defIndex = 0; 67 int defIndex = 0;
68 int i; 68 int i;
69 for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) 69 for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i )
70 { 70 {
71 destination->insertItem( dit->getDestinationName() ); 71 destination->insertItem( dit->getDestinationName() );
72 if ( dit->getDestinationName() == defaultDest ) 72 if ( dit->getDestinationName() == defaultDest )
73 defIndex = i; 73 defIndex = i;
74 } 74 }
75 75
76 destination->setCurrentItem( defIndex ); 76 destination->setCurrentItem( defIndex );
77 77
78 vector<InstallData>::iterator it; 78 vector<InstallData>::iterator it;
79 // setup package data 79 // setup package data
80 QString remove = "Remove\n"; 80 QString remove = "Remove\n";
81 QString install = "\nInstall\n"; 81 QString install = "\nInstall\n";
82 QString upgrade = "\nUpgrade\n"; 82 QString upgrade = "\nUpgrade\n";
83 for ( it = packageList.begin() ; it != packageList.end() ; ++it ) 83 for ( it = packageList.begin() ; it != packageList.end() ; ++it )
84 { 84 {
85 InstallData item = *it; 85 InstallData item = *it;
86 if ( item.option == "I" ) 86 if ( item.option == "I" )
87 { 87 {
88 installList.push_back( item ); 88 installList.push_back( item );
89 install += " " + item.packageName + "\n"; 89 install += " " + item.packageName + "\n";
90 } 90 }
91 else if ( item.option == "D" ) 91 else if ( item.option == "D" )
92 { 92 {
93 removeList.push_back( item ); 93 removeList.push_back( item );
94 remove += " " + item.packageName + "\n"; 94 remove += " " + item.packageName + "\n";
95 } 95 }
96 else if ( item.option == "U" || item.option == "R" ) 96 else if ( item.option == "U" || item.option == "R" )
97 { 97 {
98 updateList.push_back( item ); 98 updateList.push_back( item );
99 QString type = " (Upgrade)"; 99 QString type = " (Upgrade)";
100 if ( item.option == "R" ) 100 if ( item.option == "R" )
101 type = " (ReInstall)"; 101 type = " (ReInstall)";
102 upgrade += " " + item.packageName + type + "\n"; 102 upgrade += " " + item.packageName + type + "\n";
103 } 103 }
104 } 104 }
105 105
106 output->setText( remove + install + upgrade ); 106 output->setText( remove + install + upgrade );
107 107
108 displayAvailableSpace( destination->currentText() ); 108 displayAvailableSpace( destination->currentText() );
109} 109}
110 110
111InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) 111InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl )
112 : InstallDlg( parent, name, modal, fl ) 112 : InstallDlg( parent, name, modal, fl )
113{ 113{
114 pIpkg = ipkg; 114 pIpkg = ipkg;
115 output->setText( initialText ); 115 output->setText( initialText );
116} 116}
117 117
118 118
119InstallDlgImpl::~InstallDlgImpl() 119InstallDlgImpl::~InstallDlgImpl()
120{ 120{
121} 121}
122 122
123bool InstallDlgImpl :: showDlg() 123bool InstallDlgImpl :: showDlg()
124{ 124{
125 showMaximized(); 125 showMaximized();
126 bool ret = exec(); 126 bool ret = exec();
127 127
128 return ret; 128 return ret;
129} 129}
130 130
131void InstallDlgImpl :: optionsSelected() 131void InstallDlgImpl :: optionsSelected()
132{ 132{
133 InstallOptionsDlgImpl opt( flags, this, "Option", true ); 133 InstallOptionsDlgImpl opt( flags, this, "Option", true );
134 opt.exec(); 134 opt.exec();
135 135
136 // set options selected from dialog 136 // set options selected from dialog
137 flags = opt.getFlags(); 137 flags = opt.getFlags();
138 138
139#ifdef QWS 139#ifdef QWS
140 Config cfg( "aqpkg" ); 140 Config cfg( "aqpkg" );
141 cfg.setGroup( "settings" ); 141 cfg.setGroup( "settings" );
142 cfg.writeEntry( "installFlags", flags ); 142 cfg.writeEntry( "installFlags", flags );
143#endif 143#endif
144} 144}
145 145
146void InstallDlgImpl :: installSelected() 146void InstallDlgImpl :: installSelected()
147{ 147{
148 148 if ( btnInstall->text() == "Abort" )
149 if ( btnInstall->text() == "Close" ) 149 {
150 if ( pIpkg )
151 {
152 displayText( "\n**** User Clicked ABORT ***" );
153 pIpkg->abort();
154 displayText( "**** Process Aborted ****" );
155 }
156
157 btnInstall->setText( tr( "Close" ) );
158 return;
159 }
160 else if ( btnInstall->text() == "Close" )
150 { 161 {
151 done( 1 ); 162 done( 1 );
152 return; 163 return;
153 } 164 }
154 165
155 // Disable buttons 166 // Disable buttons
156 btnOptions->setEnabled( false ); 167 btnOptions->setEnabled( false );
157 btnInstall->setEnabled( false ); 168// btnInstall->setEnabled( false );
169
170 btnInstall->setText( "Abort" );
158 171
159 if ( pIpkg ) 172 if ( pIpkg )
160 { 173 {
161 output->setText( "" ); 174 output->setText( "" );
162 175
163 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 176 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
164 pIpkg->runIpkg(); 177 pIpkg->runIpkg();
165 } 178 }
166 else 179 else
167 { 180 {
168 output->setText( "" ); 181 output->setText( "" );
169 vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() ); 182 vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() );
170 QString dest = d->getDestinationName(); 183 QString dest = d->getDestinationName();
171 QString destDir = d->getDestinationPath(); 184 QString destDir = d->getDestinationPath();
172 int instFlags = flags; 185 int instFlags = flags;
173 if ( d->linkToRoot() ) 186 if ( d->linkToRoot() )
174 instFlags |= MAKE_LINKS; 187 instFlags |= MAKE_LINKS;
175 188
176#ifdef QWS 189#ifdef QWS
177 // Save settings 190 // Save settings
178 Config cfg( "aqpkg" ); 191 Config cfg( "aqpkg" );
179 cfg.setGroup( "settings" ); 192 cfg.setGroup( "settings" );
180 cfg.writeEntry( "dest", dest ); 193 cfg.writeEntry( "dest", dest );
181#endif 194#endif
182 195
183 pIpkg = new Ipkg; 196 pIpkg = new Ipkg;
184 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 197 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
185 198
186 // First run through the remove list, then the install list then the upgrade list 199 // First run through the remove list, then the install list then the upgrade list
187 vector<InstallData>::iterator it; 200 vector<InstallData>::iterator it;
188 pIpkg->setOption( "remove" ); 201 pIpkg->setOption( "remove" );
189 for ( it = removeList.begin() ; it != removeList.end() ; ++it ) 202 for ( it = removeList.begin() ; it != removeList.end() ; ++it )
190 { 203 {
191 pIpkg->setDestination( it->destination->getDestinationName() ); 204 pIpkg->setDestination( it->destination->getDestinationName() );
192 pIpkg->setDestinationDir( it->destination->getDestinationPath() ); 205 pIpkg->setDestinationDir( it->destination->getDestinationPath() );
193 pIpkg->setPackage( it->packageName ); 206 pIpkg->setPackage( it->packageName );
194 207
195 int tmpFlags = flags; 208 int tmpFlags = flags;
196 if ( it->destination->linkToRoot() ) 209 if ( it->destination->linkToRoot() )
197 tmpFlags |= MAKE_LINKS; 210 tmpFlags |= MAKE_LINKS;
198 211
199 pIpkg->setFlags( tmpFlags ); 212 pIpkg->setFlags( tmpFlags );
200 pIpkg->runIpkg(); 213 pIpkg->runIpkg();
201 } 214 }
202 215
203 pIpkg->setOption( "install" ); 216 pIpkg->setOption( "install" );
204 pIpkg->setDestination( dest ); 217 pIpkg->setDestination( dest );
205 pIpkg->setDestinationDir( destDir ); 218 pIpkg->setDestinationDir( destDir );
206 pIpkg->setFlags( instFlags ); 219 pIpkg->setFlags( instFlags );
207 for ( it = installList.begin() ; it != installList.end() ; ++it ) 220 for ( it = installList.begin() ; it != installList.end() ; ++it )
208 { 221 {
209 pIpkg->setPackage( it->packageName ); 222 pIpkg->setPackage( it->packageName );
210 pIpkg->runIpkg(); 223 pIpkg->runIpkg();
211 } 224 }
212 225
213 flags |= FORCE_REINSTALL; 226 flags |= FORCE_REINSTALL;
214 for ( it = updateList.begin() ; it != updateList.end() ; ++it ) 227 for ( it = updateList.begin() ; it != updateList.end() ; ++it )
215 { 228 {
216 if ( it->option == "R" ) 229 if ( it->option == "R" )
217 pIpkg->setOption( "reinstall" ); 230 pIpkg->setOption( "reinstall" );
218 else 231 else
219 pIpkg->setOption( "upgrade" ); 232 pIpkg->setOption( "upgrade" );
220 pIpkg->setDestination( it->destination->getDestinationName() ); 233 pIpkg->setDestination( it->destination->getDestinationName() );
221 pIpkg->setDestinationDir( it->destination->getDestinationPath() ); 234 pIpkg->setDestinationDir( it->destination->getDestinationPath() );
222 pIpkg->setPackage( it->packageName ); 235 pIpkg->setPackage( it->packageName );
223 236
224 int tmpFlags = flags; 237 int tmpFlags = flags;
225 if ( it->destination->linkToRoot() && it->recreateLinks ) 238 if ( it->destination->linkToRoot() && it->recreateLinks )
226 tmpFlags |= MAKE_LINKS; 239 tmpFlags |= MAKE_LINKS;
227 pIpkg->setFlags( tmpFlags ); 240 pIpkg->setFlags( tmpFlags );
228 pIpkg->runIpkg(); 241 pIpkg->runIpkg();
229 } 242 }
230 243
231 delete pIpkg; 244 delete pIpkg;
232 } 245 }
233 246
234 btnOptions->setEnabled( true ); 247 btnOptions->setEnabled( true );
235 btnInstall->setEnabled( true ); 248// btnInstall->setEnabled( true );
236 btnInstall->setText( tr( "Close" ) ); 249 btnInstall->setText( tr( "Close" ) );
237} 250}
238 251
252
239void InstallDlgImpl :: displayText(const QString &text ) 253void InstallDlgImpl :: displayText(const QString &text )
240{ 254{
241 QString t = output->text() + "\n" + text; 255 QString t = output->text() + "\n" + text;
242 output->setText( t ); 256 output->setText( t );
243 output->setCursorPosition( output->numLines(), 0 ); 257 output->setCursorPosition( output->numLines(), 0 );
244} 258}
245 259
246 260
247void InstallDlgImpl :: displayAvailableSpace( const QString &text ) 261void InstallDlgImpl :: displayAvailableSpace( const QString &text )
248{ 262{
249 vector<Destination>::iterator d = dataMgr->getDestination( text ); 263 vector<Destination>::iterator d = dataMgr->getDestination( text );
250 QString destDir = d->getDestinationPath(); 264 QString destDir = d->getDestinationPath();
251 265
252 long blockSize = 0; 266 long blockSize = 0;
253 long totalBlocks = 0; 267 long totalBlocks = 0;
254 long availBlocks = 0; 268 long availBlocks = 0;
255 QString space; 269 QString space;
256 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) 270 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
257 { 271 {
258 long mult = blockSize / 1024; 272 long mult = blockSize / 1024;
259 long div = 1024 / blockSize; 273 long div = 1024 / blockSize;
260 274
261 if ( !mult ) mult = 1; 275 if ( !mult ) mult = 1;
262 if ( !div ) div = 1; 276 if ( !div ) div = 1;
263// long total = totalBlocks * mult / div; 277// long total = totalBlocks * mult / div;
264 long avail = availBlocks * mult / div; 278 long avail = availBlocks * mult / div;
265// long used = total - avail; 279// long used = total - avail;
266 280
267 space.sprintf( "%ld Kb", avail ); 281 space.sprintf( "%ld Kb", avail );
268 } 282 }
269 else 283 else
270 space = "Unknown"; 284 space = "Unknown";
271 285
272 txtAvailableSpace->setText( space ); 286 txtAvailableSpace->setText( space );
273} 287}
274 288