summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/mainwin.cpp
Unidiff
Diffstat (limited to 'noncore/settings/aqpkg/mainwin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index dfe6d9c..7fa311d 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -319,48 +319,65 @@ void MainWindow :: setDocument( const QString &doc )
319 // Now set the check box of the selected package 319 // Now set the check box of the selected package
320 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 320 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
321 item != 0 ; 321 item != 0 ;
322 item = (QCheckListItem *)item->nextSibling() ) 322 item = (QCheckListItem *)item->nextSibling() )
323 { 323 {
324 if ( item->text().startsWith( package ) ) 324 if ( item->text().startsWith( package ) )
325 { 325 {
326 item->setOn( true ); 326 item->setOn( true );
327 break; 327 break;
328 } 328 }
329 } 329 }
330} 330}
331*/ 331*/
332void MainWindow :: displaySettings() 332void MainWindow :: displaySettings()
333{ 333{
334 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 334 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
335 if ( dlg->showDlg() ) 335 if ( dlg->showDlg() )
336 { 336 {
337 stack->raiseWidget( progressWindow ); 337 stack->raiseWidget( progressWindow );
338 updateData(); 338 updateData();
339 stack->raiseWidget( networkPkgWindow ); 339 stack->raiseWidget( networkPkgWindow );
340 } 340 }
341 delete dlg; 341 delete dlg;
342} 342}
343
344void MainWindow :: closeEvent( QCloseEvent *e )
345{
346 // If install dialog is visible, return to main view, otherwise close app
347 QWidget *widget = stack->visibleWidget();
348
349 if ( widget != networkPkgWindow && widget != progressWindow )
350 {
351 if ( widget ) delete widget;
352 stack->raiseWidget( networkPkgWindow );
353 e->ignore();
354 }
355 else
356 {
357 e->accept();
358 }
359}
343 360
344void MainWindow :: displayFindBar() 361void MainWindow :: displayFindBar()
345{ 362{
346 findBar->show(); 363 findBar->show();
347 findEdit->setFocus(); 364 findEdit->setFocus();
348} 365}
349 366
350void MainWindow :: displayJumpBar() 367void MainWindow :: displayJumpBar()
351{ 368{
352 jumpBar->show(); 369 jumpBar->show();
353} 370}
354 371
355void MainWindow :: repeatFind() 372void MainWindow :: repeatFind()
356{ 373{
357 searchForPackage( findEdit->text() ); 374 searchForPackage( findEdit->text() );
358} 375}
359 376
360void MainWindow :: findPackage( const QString &text ) 377void MainWindow :: findPackage( const QString &text )
361{ 378{
362 actionFindNext->setEnabled( !text.isEmpty() ); 379 actionFindNext->setEnabled( !text.isEmpty() );
363 searchForPackage( text ); 380 searchForPackage( text );
364} 381}
365 382
366void MainWindow :: hideFindBar() 383void MainWindow :: hideFindBar()
@@ -758,78 +775,80 @@ void MainWindow :: searchForPackage( const QString &text )
758 break; 775 break;
759 } 776 }
760 } 777 }
761 } 778 }
762} 779}
763 780
764void MainWindow :: updateServer() 781void MainWindow :: updateServer()
765{ 782{
766 QString serverName = serversList->currentText(); 783 QString serverName = serversList->currentText();
767 784
768 // Update the current server 785 // Update the current server
769 // Display dialog 786 // Display dialog
770 787
771 // Disable buttons to stop silly people clicking lots on them :) 788 // Disable buttons to stop silly people clicking lots on them :)
772 789
773 // First, write out ipkg_conf file so that ipkg can use it 790 // First, write out ipkg_conf file so that ipkg can use it
774 mgr->writeOutIpkgConf(); 791 mgr->writeOutIpkgConf();
775 792
776 Ipkg *ipkg = new Ipkg; 793 Ipkg *ipkg = new Ipkg;
777 ipkg->setOption( "update" ); 794 ipkg->setOption( "update" );
778 795
779 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), 796 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
780 tr( "Update lists" ) ); 797 tr( "Update lists" ) );
781 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 798 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
782 dlg->showMaximized(); 799 stack->addWidget( dlg, 3 );
800 stack->raiseWidget( dlg );
783 801
784// delete progDlg; 802// delete progDlg;
785} 803}
786 804
787void MainWindow :: upgradePackages() 805void MainWindow :: upgradePackages()
788{ 806{
789 // We're gonna do an upgrade of all packages 807 // We're gonna do an upgrade of all packages
790 // First warn user that this isn't recommended 808 // First warn user that this isn't recommended
791 // TODO - ODevice???? 809 // TODO - ODevice????
792 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); 810 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
793 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, 811 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
794 QMessageBox::Yes, 812 QMessageBox::Yes,
795 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 813 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
796 0, this ); 814 0, this );
797 warn.adjustSize(); 815 warn.adjustSize();
798 816
799 if ( warn.exec() == QMessageBox::Yes ) 817 if ( warn.exec() == QMessageBox::Yes )
800 { 818 {
801 // First, write out ipkg_conf file so that ipkg can use it 819 // First, write out ipkg_conf file so that ipkg can use it
802 mgr->writeOutIpkgConf(); 820 mgr->writeOutIpkgConf();
803 821
804 // Now run upgrade 822 // Now run upgrade
805 Ipkg *ipkg = new Ipkg; 823 Ipkg *ipkg = new Ipkg;
806 ipkg->setOption( "upgrade" ); 824 ipkg->setOption( "upgrade" );
807 825
808 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), 826 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ),
809 tr ( "Upgrade" ) ); 827 tr ( "Upgrade" ) );
810 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 828 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
811 dlg->showMaximized(); 829 stack->addWidget( dlg, 3 );
830 stack->raiseWidget( dlg );
812 } 831 }
813} 832}
814 833
815void MainWindow :: downloadPackage() 834void MainWindow :: downloadPackage()
816{ 835{
817 bool doUpdate = true; 836 bool doUpdate = true;
818 if ( downloadEnabled ) 837 if ( downloadEnabled )
819 { 838 {
820 // See if any packages are selected 839 // See if any packages are selected
821 bool found = false; 840 bool found = false;
822 if ( serversList->currentText() != LOCAL_SERVER ) 841 if ( serversList->currentText() != LOCAL_SERVER )
823 { 842 {
824 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 843 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
825 item != 0 && !found; 844 item != 0 && !found;
826 item = (QCheckListItem *)item->nextSibling() ) 845 item = (QCheckListItem *)item->nextSibling() )
827 { 846 {
828 if ( item->isOn() ) 847 if ( item->isOn() )
829 found = true; 848 found = true;
830 } 849 }
831 } 850 }
832 851
833 // If user selected some packages then download the and store the locally 852 // If user selected some packages then download the and store the locally
834 // otherwise, display dialog asking user what package to download from an http server 853 // otherwise, display dialog asking user what package to download from an http server
835 // and whether to install it 854 // and whether to install it
@@ -928,87 +947,89 @@ void MainWindow :: downloadSelectedPackages()
928 947
929void MainWindow :: downloadRemotePackage() 948void MainWindow :: downloadRemotePackage()
930{ 949{
931 // Display dialog 950 // Display dialog
932 bool ok; 951 bool ok;
933 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); 952 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
934 if ( !ok || package.isEmpty() ) 953 if ( !ok || package.isEmpty() )
935 return; 954 return;
936// DownloadRemoteDlgImpl dlg( this, "Install", true ); 955// DownloadRemoteDlgImpl dlg( this, "Install", true );
937// if ( dlg.exec() == QDialog::Rejected ) 956// if ( dlg.exec() == QDialog::Rejected )
938// return; 957// return;
939 958
940 // grab details from dialog 959 // grab details from dialog
941// QString package = dlg.getPackageLocation(); 960// QString package = dlg.getPackageLocation();
942 961
943 InstallData *item = new InstallData(); 962 InstallData *item = new InstallData();
944 item->option = "I"; 963 item->option = "I";
945 item->packageName = package; 964 item->packageName = package;
946 QList<InstallData> workingPackages; 965 QList<InstallData> workingPackages;
947 workingPackages.setAutoDelete( TRUE ); 966 workingPackages.setAutoDelete( TRUE );
948 workingPackages.append( item ); 967 workingPackages.append( item );
949 968
950 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); 969 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
951 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 970 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
952 dlg->showMaximized(); 971 stack->addWidget( dlg, 3 );
972 stack->raiseWidget( dlg );
953} 973}
954 974
955 975
956void MainWindow :: applyChanges() 976void MainWindow :: applyChanges()
957{ 977{
958 stickyOption = ""; 978 stickyOption = "";
959 979
960 // First, write out ipkg_conf file so that ipkg can use it 980 // First, write out ipkg_conf file so that ipkg can use it
961 mgr->writeOutIpkgConf(); 981 mgr->writeOutIpkgConf();
962 982
963 // Now for each selected item 983 // Now for each selected item
964 // deal with it 984 // deal with it
965 985
966 QList<InstallData> workingPackages; 986 QList<InstallData> workingPackages;
967 workingPackages.setAutoDelete( TRUE ); 987 workingPackages.setAutoDelete( TRUE );
968 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 988 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
969 item != 0 ; 989 item != 0 ;
970 item = (QCheckListItem *)item->nextSibling() ) 990 item = (QCheckListItem *)item->nextSibling() )
971 { 991 {
972 if ( item->isOn() ) 992 if ( item->isOn() )
973 { 993 {
974 workingPackages.append( dealWithItem( item ) ); 994 workingPackages.append( dealWithItem( item ) );
975 } 995 }
976 } 996 }
977 997
978 if ( workingPackages.count() == 0 ) 998 if ( workingPackages.count() == 0 )
979 { 999 {
980 // Nothing to do 1000 // Nothing to do
981 QMessageBox::information( this, tr( "Nothing to do" ), 1001 QMessageBox::information( this, tr( "Nothing to do" ),
982 tr( "No packages selected" ), tr( "OK" ) ); 1002 tr( "No packages selected" ), tr( "OK" ) );
983 1003
984 return; 1004 return;
985 } 1005 }
986 1006
987 // do the stuff 1007 // do the stuff
988 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); 1008 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
989 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 1009 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
990 dlg->showMaximized(); 1010 stack->addWidget( dlg, 3 );
1011 stack->raiseWidget( dlg );
991} 1012}
992 1013
993// decide what to do - either remove, upgrade or install 1014// decide what to do - either remove, upgrade or install
994// Current rules: 1015// Current rules:
995// If not installed - install 1016// If not installed - install
996// If installed and different version available - upgrade 1017// If installed and different version available - upgrade
997// If installed and version up to date - remove 1018// If installed and version up to date - remove
998InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) 1019InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
999{ 1020{
1000 QString name = item->text(); 1021 QString name = item->text();
1001 1022
1002 // Get package 1023 // Get package
1003 Server *s = mgr->getServer( serversList->currentText() ); 1024 Server *s = mgr->getServer( serversList->currentText() );
1004 Package *p = s->getPackage( name ); 1025 Package *p = s->getPackage( name );
1005 1026
1006 // If the package has a filename then it is a local file 1027 // If the package has a filename then it is a local file
1007 if ( p->isPackageStoredLocally() ) 1028 if ( p->isPackageStoredLocally() )
1008 name = p->getFilename(); 1029 name = p->getFilename();
1009 1030
1010 QString option; 1031 QString option;
1011 QString dest = "root"; 1032 QString dest = "root";
1012 if ( !p->isInstalled() ) 1033 if ( !p->isInstalled() )
1013 { 1034 {
1014 InstallData *newitem = new InstallData();; 1035 InstallData *newitem = new InstallData();;