Changeset 7541802
- Timestamp:
- Apr 25, 2013 10:28:25 AM (3 weeks ago)
- Branches:
- master, 9.1-release
- Children:
- 48831cd
- Parents:
- 47e969a
- Location:
- src-qt4/pc-pkgmanager
- Files:
-
- 3 added
- 3 edited
-
dialogConfirm.cpp (added)
-
dialogConfirm.h (added)
-
dialogConfirm.ui (added)
-
mainWin.cpp (modified) (4 diffs)
-
mainWin.h (modified) (3 diffs)
-
pc-pkgmanager.pro (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src-qt4/pc-pkgmanager/mainWin.cpp
r47e969a r7541802 92 92 if ( stackedPkgView->currentIndex() == 0 ) 93 93 { 94 saveMetaPkgs();94 saveMetaPkgs(); 95 95 } else { 96 // Running in advanced mode97 96 // Running in advanced mode 97 applyNGChanges(); 98 98 } 99 99 … … 455 455 disconnect(treeNGPkgs, SIGNAL(itemChanged(QTreeWidgetItem *, int)), 0, 0); 456 456 pkgList.clear(); 457 selPkgList.clear(); 457 458 458 459 // Start the process to get meta-pkg info … … 482 483 483 484 void mainWin::slotGetNGInstalledPkgs() { 485 486 qDebug() << "Building dependancy lists..."; 487 QProcess p; 488 pkgDepList.clear(); 489 if ( wDir.isEmpty() ) 490 p.start("pkg", QStringList() << "rquery" << "-a" << "%n-%v:::%dn-%dv"); 491 else 492 p.start("chroot", QStringList() << wDir << "pkg" "rquery" << "-a" << "%n-%v:::%dn-%dv" ); 493 while(p.state() == QProcess::Starting || p.state() == QProcess::Running) { 494 p.waitForFinished(200); 495 QCoreApplication::processEvents(); 496 } 497 while (p.canReadLine()) { 498 pkgDepList << p.readLine().simplified(); 499 } 500 501 qDebug() << "Building reverse dependancy lists..."; 502 pkgRDepList.clear(); 503 if ( wDir.isEmpty() ) 504 p.start("pkg", QStringList() << "rquery" << "-a" << "%n-%v:::%rn-%rv"); 505 else 506 p.start("chroot", QStringList() << wDir << "pkg" "rquery" << "-a" << "%n-%v:::%rn-%rv" ); 507 while(p.state() == QProcess::Starting || p.state() == QProcess::Running) { 508 p.waitForFinished(200); 509 QCoreApplication::processEvents(); 510 } 511 while (p.canReadLine()) { 512 pkgRDepList << p.readLine().simplified(); 513 } 484 514 485 515 getNGProc = new QProcess(); … … 543 573 pkgItem->setToolTip(0, desc); 544 574 545 if ( pkgList.indexOf(pkgname) != -1 ) 575 if ( pkgList.indexOf(pkgname) != -1 ) { 546 576 pkgItem->setCheckState(0, Qt::Checked); 547 else 577 selPkgList << pkgname; 578 } else 548 579 pkgItem->setCheckState(0, Qt::Unchecked); 549 580 550 581 catItem->addChild(pkgItem); 551 582 } 583 584 } 585 586 // Lets prompt user, and do it! 587 void mainWin::applyNGChanges() 588 { 589 QString tmp; 590 QStringList curPkgChecked; 591 QStringList newPkgs; 592 QStringList rmPkgs; 593 594 QTreeWidgetItemIterator it(treeNGPkgs); 595 while (*it) { 596 if ((*it)->checkState(0) == Qt::Checked) { 597 tmp = (*it)->text(0).section("(", 1, 1).section(")", 0, 0); 598 curPkgChecked << tmp; 599 if (pkgList.indexOf(tmp) == -1 ) 600 newPkgs << tmp; 601 } 602 ++it; 603 } 604 605 for ( int i=0; i < pkgList.size(); ++i) 606 // Has this package been unchecked? 607 if (curPkgChecked.indexOf(pkgList.at(i)) == -1 ) { 608 // Make sure this is a package in the repo 609 // This filters out any custom packages the user may have loaded which may not exist in our repo 610 QRegExp rx("*" + pkgList.at(i) + "*"); 611 rx.setPatternSyntax(QRegExp::Wildcard); 612 if ( tmpPkgList.indexOf(rx) != -1 ) 613 rmPkgs << pkgList.at(i); 614 } 615 616 if ( rmPkgs.isEmpty() && newPkgs.isEmpty() ) { 617 QMessageBox::warning(this, tr("No changes"), 618 tr("No changes to make!"), 619 QMessageBox::Ok, 620 QMessageBox::Ok); 621 return; 622 } 623 624 qDebug() << "Added packages" << newPkgs; 625 qDebug() << "Removed packages" << rmPkgs; 626 pkgRemoveList = rmPkgs; 627 pkgAddList = newPkgs; 628 629 QString confirmText; 630 631 // Lets start creating our confirmation text 632 if ( ! rmPkgs.isEmpty() ) { 633 confirmText+=tr("The following packages will be removed:") + "\n"; 634 confirmText+= "------------------------------------------\n"; 635 confirmText+=rmPkgs.join("\n"); 636 confirmText+= "\n\n" + tr("The following packages that require the above packages will also removed:") + "\n"; 637 confirmText+= "------------------------------------------\n"; 638 for ( int i=0; i < rmPkgs.size(); ++i) { 639 QRegExp rx(rmPkgs.at(i) + ":::*"); 640 rx.setPatternSyntax(QRegExp::Wildcard); 641 QStringList rDeps = pkgRDepList.filter(rx); 642 for ( int r=0; r < rDeps.size(); ++r) { 643 QString pName = rDeps.at(r).section(":::", 1, 1); 644 // Is this package installed? 645 if ( pkgList.indexOf(pName) != -1 ) 646 confirmText+= pName + " "; 647 } 648 } 649 } 650 651 if ( ! newPkgs.isEmpty() ) { 652 if ( ! rmPkgs.isEmpty() ) 653 confirmText+= "\n\n"; 654 confirmText+=tr("The following packages will be installed:") + "\n"; 655 confirmText+= "------------------------------------------\n"; 656 confirmText+=newPkgs.join("\n"); 657 confirmText+= "\n\n" + tr("The following dependances will also be installed:") + "\n"; 658 confirmText+= "------------------------------------------\n"; 659 for ( int i=0; i < newPkgs.size(); ++i) { 660 QRegExp rx(newPkgs.at(i) + ":::*"); 661 rx.setPatternSyntax(QRegExp::Wildcard); 662 QStringList aDeps = pkgDepList.filter(rx); 663 for ( int r=0; r < aDeps.size(); ++r) { 664 QString pName = aDeps.at(r).section(":::", 1, 1); 665 // Is this package installed? 666 if ( pkgList.indexOf(pName) == -1 ) 667 confirmText+= pName + " "; 668 } 669 } 670 } 671 672 // Launch our AddPartitionDialog to add a new device 673 askUserConfirm = new dialogConfirm(); 674 connect(askUserConfirm, SIGNAL(ok()),this, SLOT(slotStartNGChanges()) ); 675 askUserConfirm->programInit(tr("Confirm package changes")); 676 askUserConfirm->setInfoText(QString(confirmText)); 677 askUserConfirm->exec(); 678 679 } 680 681 682 // Time to start doing our NG changes! 683 void mainWin::slotStartNGChanges() 684 { 552 685 553 686 } -
src-qt4/pc-pkgmanager/mainWin.h
r47e969a r7541802 15 15 #include <pcbsd-utils.h> 16 16 #include <pcbsd-ui.h> 17 #include "dialogConfirm.h" 17 18 #include "ui_mainWin.h" 18 19 #include "../config.h" … … 67 68 void slotGetNGInstalledPkgs(); 68 69 void slotEnableApply(); 70 void slotStartNGChanges(); 69 71 70 72 private: … … 121 123 void populateNGPkgs(); 122 124 void addNGItems(); 125 void applyNGChanges(); 123 126 QStringList tmpPkgList; 124 127 QStringList pkgList; 128 QStringList pkgDepList; 129 QStringList pkgRDepList; 130 QStringList selPkgList; 131 QStringList pkgRemoveList; 132 QStringList pkgAddList; 125 133 QProcess *getNGProc; 134 dialogConfirm *askUserConfirm; 126 135 127 136 -
src-qt4/pc-pkgmanager/pc-pkgmanager.pro
r4b9e67a r7541802 7 7 INCLUDEPATH += ../libpcbsd/utils ../libpcbsd/ui /usr/local/include 8 8 9 HEADERS += mainWin.h 9 HEADERS += mainWin.h dialogConfirm.h 10 10 11 SOURCES += main.cpp mainWin.cpp 11 SOURCES += main.cpp mainWin.cpp dialogConfirm.cpp 12 12 13 FORMS = mainWin.ui 13 FORMS = mainWin.ui dialogConfirm.ui 14 14 15 15 RESOURCES = pc-pkgmanager.qrc
Note: See TracChangeset
for help on using the changeset viewer.
