author | tille <tille> | 2002-04-27 21:02:53 (UTC) |
---|---|---|
committer | tille <tille> | 2002-04-27 21:02:53 (UTC) |
commit | 69e271e44d23befc74a96a98708ddb6ec754a4b6 (patch) (unidiff) | |
tree | 6f8300d8858d2c7659eb90066b58b302a2863e43 /noncore/unsupported/oipkg/pmipkg.cpp | |
parent | acdc33336307e48ac7089b146006fe7b36e321a5 (diff) | |
download | opie-69e271e44d23befc74a96a98708ddb6ec754a4b6.zip opie-69e271e44d23befc74a96a98708ddb6ec754a4b6.tar.gz opie-69e271e44d23befc74a96a98708ddb6ec754a4b6.tar.bz2 |
setDocument working and some changes in install gui
Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 134 |
1 files changed, 86 insertions, 48 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 45c89c5..f0992f5 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp | |||
@@ -1,5 +1,4 @@ | |||
1 | #include "pmipkg.h" | 1 | #include "pmipkg.h" |
2 | #include "pkdesc.h" | ||
3 | #include "pksettings.h" | 2 | #include "pksettings.h" |
4 | #include "package.h" | 3 | #include "package.h" |
5 | #include "packagelistitem.h" | 4 | #include "packagelistitem.h" |
@@ -12,6 +11,7 @@ | |||
12 | #include <qfile.h> | 11 | #include <qfile.h> |
13 | #include <qmultilineedit.h> | 12 | #include <qmultilineedit.h> |
14 | #include <qstring.h> | 13 | #include <qstring.h> |
14 | #include <qcheckbox.h> | ||
15 | #include <qtextstream.h> | 15 | #include <qtextstream.h> |
16 | #include <qtextview.h> | 16 | #include <qtextview.h> |
17 | 17 | ||
@@ -57,6 +57,9 @@ int PmIpkg::runIpkg(const QString& args, const QString& dest ) | |||
57 | 57 | ||
58 | cmd += " -force-defaults "; | 58 | cmd += " -force-defaults "; |
59 | 59 | ||
60 | // if (runwindow->forcedepends->isChecked()) | ||
61 | // cmd += " -force-depends "; | ||
62 | |||
60 | out( "<hr><br>Starting to "+ args+"<br>\n"); | 63 | out( "<hr><br>Starting to "+ args+"<br>\n"); |
61 | cmd += args; | 64 | cmd += args; |
62 | int r = 0; | 65 | int r = 0; |
@@ -71,7 +74,7 @@ int PmIpkg::runIpkg(const QString& args, const QString& dest ) | |||
71 | #ifdef SYSTEM | 74 | #ifdef SYSTEM |
72 | out( "running:<br>\n"+cmd+"<br>\n" ); | 75 | out( "running:<br>\n"+cmd+"<br>\n" ); |
73 | QString redirect = "/tmp/oipkg.pipe"; | 76 | QString redirect = "/tmp/oipkg.pipe"; |
74 | cmd += " | tee "+redirect+" 2>&1"; | 77 | cmd += " 2>&1 | tee "+redirect+" 2>&1"; |
75 | pvDebug(2, "running >"+cmd+"<"); | 78 | pvDebug(2, "running >"+cmd+"<"); |
76 | r = system(cmd.latin1()); | 79 | r = system(cmd.latin1()); |
77 | QFile f( redirect ); | 80 | QFile f( redirect ); |
@@ -103,8 +106,6 @@ void PmIpkg::makeLinks(Package *pack) | |||
103 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); | 106 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); |
104 | QString dest = settings->getDestinationUrlByName( pack->dest() ); | 107 | QString dest = settings->getDestinationUrlByName( pack->dest() ); |
105 | if (dest == "/" ) return; | 108 | if (dest == "/" ) return; |
106 | out( "<br>creating links<br>" ); | ||
107 | out("for package "+pack->name()+" in "+dest+"<br>"); | ||
108 | { | 109 | { |
109 | Config cfg( "oipkg", Config::User ); | 110 | Config cfg( "oipkg", Config::User ); |
110 | cfg.setGroup( "Common" ); | 111 | cfg.setGroup( "Common" ); |
@@ -122,6 +123,8 @@ void PmIpkg::linkPackage( QString packFileName, QString dest ) | |||
122 | out( "<b>Panik!</b> Could not open:<br>"+packFileName ); | 123 | out( "<b>Panik!</b> Could not open:<br>"+packFileName ); |
123 | return; | 124 | return; |
124 | }; | 125 | }; |
126 | out( "<br>creating links<br>" ); | ||
127 | out("for package "+packFileName+" in "+dest+"<br>"); | ||
125 | QTextStream t( &f ); | 128 | QTextStream t( &f ); |
126 | QString fp; | 129 | QString fp; |
127 | while ( !t.eof() ) | 130 | while ( !t.eof() ) |
@@ -134,6 +137,7 @@ void PmIpkg::linkPackage( QString packFileName, QString dest ) | |||
134 | 137 | ||
135 | void PmIpkg::processLinkDir( QString file, QString dest ) | 138 | void PmIpkg::processLinkDir( QString file, QString dest ) |
136 | { | 139 | { |
140 | pvDebug( 7,"PmIpkg::processLinkDir "+file+" to "+ dest); | ||
137 | if ( dest == "???" ) return; | 141 | if ( dest == "???" ) return; |
138 | QString destFile = file; | 142 | QString destFile = file; |
139 | file = dest+"/"+file; | 143 | file = dest+"/"+file; |
@@ -167,15 +171,11 @@ void PmIpkg::processLinkDir( QString file, QString dest ) | |||
167 | 171 | ||
168 | void PmIpkg::commit( PackageList pl ) | 172 | void PmIpkg::commit( PackageList pl ) |
169 | { | 173 | { |
170 | show( false ); | 174 | int sizecount = 0; |
171 | runwindow->outPut->setText(""); | ||
172 | out( "<h1>"+tr("Todo")+"</h1>\n"); | ||
173 | |||
174 | to_install.clear(); | 175 | to_install.clear(); |
175 | to_remove.clear(); | 176 | to_remove.clear(); |
176 | int sizecount = 0; | 177 | QString rem="<b>"+tr("To remove:")+"</b><br>\n"; |
177 | QString rem="<b>To remove:</b><br>\n"; | 178 | QString inst="<b>"+tr("To install:")+"</b><br>\n"; |
178 | QString inst="<b>To install:</b><br>\n";; | ||
179 | pl.allPackages(); | 179 | pl.allPackages(); |
180 | for( Package *pack = pl.first();pack ; (pack = pl.next()) ) | 180 | for( Package *pack = pl.first();pack ; (pack = pl.next()) ) |
181 | { | 181 | { |
@@ -185,7 +185,7 @@ void PmIpkg::commit( PackageList pl ) | |||
185 | { | 185 | { |
186 | to_install.append( pack ); | 186 | to_install.append( pack ); |
187 | sizecount += pack->size().toInt(); | 187 | sizecount += pack->size().toInt(); |
188 | inst += pack->name()+"\t(on "+pack->dest()+")<br>"; | 188 | inst += pack->name()+"\t("+tr("on ")+pack->dest()+")<br>"; |
189 | } | 189 | } |
190 | if ( pack->toRemove() ) | 190 | if ( pack->toRemove() ) |
191 | { | 191 | { |
@@ -196,23 +196,77 @@ void PmIpkg::commit( PackageList pl ) | |||
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | out("<p>"+inst+"</p>"+"<p>"+rem+"</p><hl>"); | 199 | startDialog(); |
200 | |||
201 | qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count()); | ||
202 | 200 | ||
203 | runwindow->progress->setTotalSteps( sizecount ); | 201 | } |
204 | 202 | ||
205 | connect( runwindow->doItButton, SIGNAL( clicked() ), | 203 | void PmIpkg::startDialog() |
206 | SLOT( doIt() ) ); | 204 | { |
207 | connect( runwindow->installButton, SIGNAL( clicked() ), | 205 | QDialog *d = new QDialog(); |
206 | QGridLayout *RunWindowLayout = new QGridLayout( d ); | ||
207 | RunWindowLayout->setSpacing( 2 ); | ||
208 | RunWindowLayout->setMargin( 2 ); | ||
209 | |||
210 | QHBoxLayout *buttons = new QHBoxLayout; | ||
211 | buttons->setSpacing( 6 ); | ||
212 | buttons->setMargin( 0 ); | ||
213 | |||
214 | PackageListView *plv = new PackageListView(d, "install",settings); | ||
215 | RunWindowLayout->addWidget( plv, 1, 0 ); | ||
216 | for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) | ||
217 | { | ||
218 | plv->insertItem( new PackageListItem(plv, it,settings) ); | ||
219 | } | ||
220 | for (Package *it=to_install.first(); it != 0; it=to_install.next() ) | ||
221 | { | ||
222 | plv->insertItem( new PackageListItem(plv, it,settings) ); | ||
223 | } | ||
224 | QPushButton *doItButton = new QPushButton( d, "doItButton" ); | ||
225 | doItButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, doItButton->sizePolicy().hasHeightForWidth() ) ); | ||
226 | QFont doItButton_font( doItButton->font() ); | ||
227 | doItButton_font.setPointSize( 8 ); | ||
228 | doItButton->setFont( doItButton_font ); | ||
229 | doItButton->setText( tr( "Do all " ) ); | ||
230 | doItButton->setAutoResize( FALSE ); | ||
231 | buttons->addWidget( doItButton ); | ||
232 | |||
233 | QPushButton *installButton = new QPushButton( d, "installButton" ); | ||
234 | QFont installButton_font( installButton->font() ); | ||
235 | installButton_font.setPointSize( 8 ); | ||
236 | installButton->setFont( installButton_font ); | ||
237 | installButton->setText( tr( "Install" ) ); | ||
238 | installButton->setAutoResize( TRUE ); | ||
239 | buttons->addWidget( installButton ); | ||
240 | |||
241 | QPushButton *removeButton = new QPushButton( d, "removeButton" ); | ||
242 | QFont removeButton_font( removeButton->font() ); | ||
243 | removeButton_font.setPointSize( 7 ); | ||
244 | removeButton->setFont( removeButton_font ); | ||
245 | removeButton->setText( tr( "Remove" ) ); | ||
246 | removeButton->setAutoResize( TRUE ); | ||
247 | buttons->addWidget( removeButton ); | ||
248 | |||
249 | QPushButton *cancelButton = new QPushButton( d, "cancelButton" ); | ||
250 | QFont cancelButton_font( cancelButton->font() ); | ||
251 | cancelButton_font.setPointSize( 8 ); | ||
252 | cancelButton->setFont( cancelButton_font ); | ||
253 | cancelButton->setText( tr( "Cancel" ) ); | ||
254 | cancelButton->setAutoResize( TRUE ); | ||
255 | buttons->addWidget( cancelButton ); | ||
256 | |||
257 | RunWindowLayout->addLayout( buttons, 3, 0 ); | ||
258 | |||
259 | connect( doItButton, SIGNAL( clicked() ), | ||
260 | this, SLOT( doIt() ) ); | ||
261 | connect( installButton, SIGNAL( clicked() ), | ||
208 | this, SLOT( install() ) ); | 262 | this, SLOT( install() ) ); |
209 | connect( runwindow->removeButton, SIGNAL( clicked() ), | 263 | connect( removeButton, SIGNAL( clicked() ), |
210 | this, SLOT( remove() ) ); | 264 | this, SLOT( remove() ) ); |
211 | connect( runwindow->cancelButton, SIGNAL( clicked() ), | 265 | connect( cancelButton, SIGNAL( clicked() ), |
212 | runwindow, SLOT( close() ) ); | 266 | d, SLOT( close() ) ); |
213 | 267 | d->showMaximized(); | |
214 | runwindow->exec(); | 268 | d->exec(); |
215 | out("<h1>"+tr("Its now save to close this window")+"<h1>"); | 269 | // d->close(); |
216 | } | 270 | } |
217 | 271 | ||
218 | void PmIpkg::doIt() | 272 | void PmIpkg::doIt() |
@@ -251,7 +305,7 @@ void PmIpkg::install() | |||
251 | for (Package *it=to_install.first(); it != 0; it=to_install.next() ) | 305 | for (Package *it=to_install.first(); it != 0; it=to_install.next() ) |
252 | { | 306 | { |
253 | 307 | ||
254 | if ( runIpkg("install " + it->name(), it->dest() ) == 0 ) | 308 | if ( runIpkg("install " + it->getPackageName(), it->dest() ) == 0 ) |
255 | { | 309 | { |
256 | runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); | 310 | runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); |
257 | if ( it->link() ) | 311 | if ( it->link() ) |
@@ -314,7 +368,7 @@ void PmIpkg::show(bool b) | |||
314 | if (!runwindow->isVisible()) | 368 | if (!runwindow->isVisible()) |
315 | runwindow->showMaximized(); | 369 | runwindow->showMaximized(); |
316 | showButtons(b); | 370 | showButtons(b); |
317 | if ( b ) | 371 | if ( !b ) |
318 | runwindow->progress->hide(); | 372 | runwindow->progress->hide(); |
319 | else | 373 | else |
320 | runwindow->progress->show(); | 374 | runwindow->progress->show(); |
@@ -322,27 +376,11 @@ void PmIpkg::show(bool b) | |||
322 | 376 | ||
323 | void PmIpkg::installFile(const QString &fileName) | 377 | void PmIpkg::installFile(const QString &fileName) |
324 | { | 378 | { |
379 | |||
380 | to_install.clear(); | ||
381 | to_remove.clear(); | ||
325 | pvDebug( 2,"PmIpkg::installFile "+ fileName); | 382 | pvDebug( 2,"PmIpkg::installFile "+ fileName); |
326 | show( false ); | 383 | to_install.append( new Package(fileName,settings) ); |
327 | runwindow->outPut->setText(""); | 384 | startDialog(); |
328 | fileNameToInstall = fileName; | ||
329 | runwindow->doItButton->hide(); | ||
330 | runwindow->removeButton->hide(); | ||
331 | out("<b>"+tr("Install: ")+fileName); | ||
332 | connect( runwindow->installButton, SIGNAL( clicked() ), | ||
333 | this, SLOT( installFileName() ) ); | ||
334 | connect( runwindow->cancelButton, SIGNAL( clicked() ), | ||
335 | runwindow, SLOT( close() ) ); | ||
336 | |||
337 | runwindow->exec(); | ||
338 | } | 385 | } |
339 | 386 | ||
340 | void PmIpkg::installFileName() | ||
341 | { | ||
342 | if ( !QFile::exists( fileNameToInstall ) ) return; | ||
343 | out(tr("Installing pacakge ")+fileNameToInstall+"<br>"+tr("please wait")+"</b><br>"); | ||
344 | runIpkg("install " + fileNameToInstall ); | ||
345 | if ( settings->createLinks() ) | ||
346 | linkPackage( fileNameToInstall, settings->getDestinationUrl() ); | ||
347 | out("<h1>"+tr("Its now save to close this window")+"<h1>"); | ||
348 | } \ No newline at end of file | ||