author | drw <drw> | 2003-05-16 23:17:49 (UTC) |
---|---|---|
committer | drw <drw> | 2003-05-16 23:17:49 (UTC) |
commit | eac84192decbd60ecb680b82c92b55e70b5fd015 (patch) (unidiff) | |
tree | 3e47155aff48679a971bccb82b58c6b89fe4c358 | |
parent | db67960cfab97f9897e0fdc1cb9c8e8794f4a2ba (diff) | |
download | opie-eac84192decbd60ecb680b82c92b55e70b5fd015.zip opie-eac84192decbd60ecb680b82c92b55e70b5fd015.tar.gz opie-eac84192decbd60ecb680b82c92b55e70b5fd015.tar.bz2 |
Fix for bug #914 (correct dialog cancel behaviour)
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 69 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.h | 21 |
2 files changed, 84 insertions, 6 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 0102292..0efa1e0 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -832,335 +832,392 @@ void MainWindow :: downloadPackage() | |||
832 | { | 832 | { |
833 | if ( item->isOn() ) | 833 | if ( item->isOn() ) |
834 | { | 834 | { |
835 | QString name = item->text(); | 835 | QString name = item->text(); |
836 | int pos = name.find( "*" ); | 836 | int pos = name.find( "*" ); |
837 | name.truncate( pos ); | 837 | name.truncate( pos ); |
838 | 838 | ||
839 | // if (there is a (installed), remove it | 839 | // if (there is a (installed), remove it |
840 | pos = name.find( "(installed)" ); | 840 | pos = name.find( "(installed)" ); |
841 | if ( pos > 0 ) | 841 | if ( pos > 0 ) |
842 | name.truncate( pos - 1 ); | 842 | name.truncate( pos - 1 ); |
843 | 843 | ||
844 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); | 844 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); |
845 | 845 | ||
846 | QString msgtext; | 846 | QString msgtext; |
847 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); | 847 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); |
848 | if ( QMessageBox::information( this, tr( "Are you sure?" ), | 848 | if ( QMessageBox::information( this, tr( "Are you sure?" ), |
849 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) | 849 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) |
850 | { | 850 | { |
851 | doUpdate = true; | 851 | doUpdate = true; |
852 | QFile f( p->getFilename() ); | 852 | QFile f( p->getFilename() ); |
853 | f.remove(); | 853 | f.remove(); |
854 | } | 854 | } |
855 | } | 855 | } |
856 | } | 856 | } |
857 | } | 857 | } |
858 | 858 | ||
859 | if ( doUpdate ) | 859 | if ( doUpdate ) |
860 | { | 860 | { |
861 | reloadData( 0x0 ); | 861 | reloadData( 0x0 ); |
862 | } | 862 | } |
863 | } | 863 | } |
864 | 864 | ||
865 | void MainWindow :: downloadSelectedPackages() | 865 | void MainWindow :: downloadSelectedPackages() |
866 | { | 866 | { |
867 | // First, write out ipkg_conf file so that ipkg can use it | 867 | // First, write out ipkg_conf file so that ipkg can use it |
868 | mgr->writeOutIpkgConf(); | 868 | mgr->writeOutIpkgConf(); |
869 | 869 | ||
870 | // Display dialog to user asking where to download the files to | 870 | // Display dialog to user asking where to download the files to |
871 | bool ok = FALSE; | 871 | bool ok = FALSE; |
872 | QString dir = ""; | 872 | QString dir = ""; |
873 | #ifdef QWS | 873 | #ifdef QWS |
874 | // read download directory from config file | 874 | // read download directory from config file |
875 | Config cfg( "aqpkg" ); | 875 | Config cfg( "aqpkg" ); |
876 | cfg.setGroup( "settings" ); | 876 | cfg.setGroup( "settings" ); |
877 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 877 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
878 | #endif | 878 | #endif |
879 | 879 | ||
880 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 880 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
881 | if ( ok && !text.isEmpty() ) | 881 | if ( ok && !text.isEmpty() ) |
882 | dir = text; // user entered something and pressed ok | 882 | dir = text; // user entered something and pressed ok |
883 | else | 883 | else |
884 | return; // user entered nothing or pressed cancel | 884 | return; // user entered nothing or pressed cancel |
885 | 885 | ||
886 | #ifdef QWS | 886 | #ifdef QWS |
887 | // Store download directory in config file | 887 | // Store download directory in config file |
888 | cfg.writeEntry( "downloadDir", dir ); | 888 | cfg.writeEntry( "downloadDir", dir ); |
889 | #endif | 889 | #endif |
890 | 890 | ||
891 | // Get starting directory | 891 | // Get starting directory |
892 | char initDir[PATH_MAX]; | 892 | char initDir[PATH_MAX]; |
893 | getcwd( initDir, PATH_MAX ); | 893 | getcwd( initDir, PATH_MAX ); |
894 | 894 | ||
895 | // Download each package | 895 | // Download each package |
896 | Ipkg ipkg; | 896 | Ipkg ipkg; |
897 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 897 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
898 | 898 | ||
899 | ipkg.setOption( "download" ); | 899 | ipkg.setOption( "download" ); |
900 | ipkg.setRuntimeDirectory( dir ); | 900 | ipkg.setRuntimeDirectory( dir ); |
901 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 901 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
902 | item != 0 ; | 902 | item != 0 ; |
903 | item = (QCheckListItem *)item->nextSibling() ) | 903 | item = (QCheckListItem *)item->nextSibling() ) |
904 | { | 904 | { |
905 | if ( item->isOn() ) | 905 | if ( item->isOn() ) |
906 | { | 906 | { |
907 | ipkg.setPackage( item->text() ); | 907 | ipkg.setPackage( item->text() ); |
908 | ipkg.runIpkg( ); | 908 | ipkg.runIpkg( ); |
909 | } | 909 | } |
910 | } | 910 | } |
911 | } | 911 | } |
912 | 912 | ||
913 | void MainWindow :: downloadRemotePackage() | 913 | void MainWindow :: downloadRemotePackage() |
914 | { | 914 | { |
915 | // Display dialog | 915 | // Display dialog |
916 | bool ok; | 916 | bool ok; |
917 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); | 917 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); |
918 | if ( !ok || package.isEmpty() ) | 918 | if ( !ok || package.isEmpty() ) |
919 | return; | 919 | return; |
920 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 920 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
921 | // if ( dlg.exec() == QDialog::Rejected ) | 921 | // if ( dlg.exec() == QDialog::Rejected ) |
922 | // return; | 922 | // return; |
923 | 923 | ||
924 | // grab details from dialog | 924 | // grab details from dialog |
925 | // QString package = dlg.getPackageLocation(); | 925 | // QString package = dlg.getPackageLocation(); |
926 | 926 | ||
927 | InstallData *item = new InstallData(); | 927 | InstallData *item = new InstallData(); |
928 | item->option = "I"; | 928 | item->option = "I"; |
929 | item->packageName = package; | 929 | item->packageName = package; |
930 | QList<InstallData> workingPackages; | 930 | QList<InstallData> workingPackages; |
931 | workingPackages.setAutoDelete( TRUE ); | 931 | workingPackages.setAutoDelete( TRUE ); |
932 | workingPackages.append( item ); | 932 | workingPackages.append( item ); |
933 | 933 | ||
934 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); | 934 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); |
935 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 935 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
936 | reloadDocuments = TRUE; | 936 | reloadDocuments = TRUE; |
937 | stack->addWidget( dlg, 3 ); | 937 | stack->addWidget( dlg, 3 ); |
938 | stack->raiseWidget( dlg ); | 938 | stack->raiseWidget( dlg ); |
939 | } | 939 | } |
940 | 940 | ||
941 | 941 | ||
942 | void MainWindow :: applyChanges() | 942 | void MainWindow :: applyChanges() |
943 | { | 943 | { |
944 | stickyOption = ""; | 944 | stickyOption = ""; |
945 | 945 | ||
946 | // First, write out ipkg_conf file so that ipkg can use it | 946 | // First, write out ipkg_conf file so that ipkg can use it |
947 | mgr->writeOutIpkgConf(); | 947 | mgr->writeOutIpkgConf(); |
948 | 948 | ||
949 | // Now for each selected item | 949 | // Now for each selected item |
950 | // deal with it | 950 | // deal with it |
951 | 951 | ||
952 | QList<InstallData> workingPackages; | 952 | QList<InstallData> workingPackages; |
953 | workingPackages.setAutoDelete( TRUE ); | 953 | workingPackages.setAutoDelete( TRUE ); |
954 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 954 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
955 | item != 0 ; | 955 | item != 0 ; |
956 | item = (QCheckListItem *)item->nextSibling() ) | 956 | item = (QCheckListItem *)item->nextSibling() ) |
957 | { | 957 | { |
958 | if ( item->isOn() ) | 958 | if ( item->isOn() ) |
959 | { | 959 | { |
960 | workingPackages.append( dealWithItem( item ) ); | 960 | InstallData *instdata = dealWithItem( item ); |
961 | if ( instdata ) | ||
962 | workingPackages.append( instdata ); | ||
963 | else | ||
964 | return; | ||
961 | } | 965 | } |
962 | } | 966 | } |
963 | 967 | ||
964 | if ( workingPackages.count() == 0 ) | 968 | if ( workingPackages.count() == 0 ) |
965 | { | 969 | { |
966 | // Nothing to do | 970 | // Nothing to do |
967 | QMessageBox::information( this, tr( "Nothing to do" ), | 971 | QMessageBox::information( this, tr( "Nothing to do" ), |
968 | tr( "No packages selected" ), tr( "OK" ) ); | 972 | tr( "No packages selected" ), tr( "OK" ) ); |
969 | 973 | ||
970 | return; | 974 | return; |
971 | } | 975 | } |
972 | 976 | ||
973 | // do the stuff | 977 | // do the stuff |
974 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); | 978 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); |
975 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 979 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
976 | reloadDocuments = TRUE; | 980 | reloadDocuments = TRUE; |
977 | stack->addWidget( dlg, 3 ); | 981 | stack->addWidget( dlg, 3 ); |
978 | stack->raiseWidget( dlg ); | 982 | stack->raiseWidget( dlg ); |
979 | } | 983 | } |
980 | 984 | ||
981 | // decide what to do - either remove, upgrade or install | 985 | // decide what to do - either remove, upgrade or install |
982 | // Current rules: | 986 | // Current rules: |
983 | // If not installed - install | 987 | // If not installed - install |
984 | // If installed and different version available - upgrade | 988 | // If installed and different version available - upgrade |
985 | // If installed and version up to date - remove | 989 | // If installed and version up to date - remove |
986 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) | 990 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) |
987 | { | 991 | { |
988 | QString name = item->text(); | 992 | QString name = item->text(); |
989 | 993 | ||
990 | // Get package | 994 | // Get package |
991 | Server *s = mgr->getServer( serversList->currentText() ); | 995 | Server *s = mgr->getServer( serversList->currentText() ); |
992 | Package *p = s->getPackage( name ); | 996 | Package *p = s->getPackage( name ); |
993 | 997 | ||
994 | // If the package has a filename then it is a local file | 998 | // If the package has a filename then it is a local file |
995 | if ( p->isPackageStoredLocally() ) | 999 | if ( p->isPackageStoredLocally() ) |
996 | name = p->getFilename(); | 1000 | name = p->getFilename(); |
997 | 1001 | ||
998 | QString option; | 1002 | QString option; |
999 | QString dest = "root"; | 1003 | QString dest = "root"; |
1000 | if ( !p->isInstalled() ) | 1004 | if ( !p->isInstalled() ) |
1001 | { | 1005 | { |
1002 | InstallData *newitem = new InstallData(); | 1006 | InstallData *newitem = new InstallData(); |
1003 | newitem->option = "I"; | 1007 | newitem->option = "I"; |
1004 | newitem->packageName = name; | 1008 | newitem->packageName = name; |
1005 | return newitem; | 1009 | return newitem; |
1006 | } | 1010 | } |
1007 | else | 1011 | else |
1008 | { | 1012 | { |
1009 | InstallData *newitem = new InstallData(); | 1013 | InstallData *newitem = new InstallData(); |
1010 | newitem->option = "D"; | 1014 | newitem->option = "D"; |
1011 | if ( !p->isPackageStoredLocally() ) | 1015 | if ( !p->isPackageStoredLocally() ) |
1012 | newitem->packageName = p->getInstalledPackageName(); | 1016 | newitem->packageName = p->getInstalledPackageName(); |
1013 | else | 1017 | else |
1014 | newitem->packageName = name; | 1018 | newitem->packageName = name; |
1015 | 1019 | ||
1016 | if ( p->getInstalledTo() ) | 1020 | if ( p->getInstalledTo() ) |
1017 | { | 1021 | { |
1018 | newitem->destination = p->getInstalledTo(); | 1022 | newitem->destination = p->getInstalledTo(); |
1019 | } | 1023 | } |
1020 | else | 1024 | else |
1021 | { | 1025 | { |
1022 | newitem->destination = p->getLocalPackage()->getInstalledTo(); | 1026 | newitem->destination = p->getLocalPackage()->getInstalledTo(); |
1023 | } | 1027 | } |
1024 | 1028 | ||
1025 | // Now see if version is newer or not | 1029 | // Now see if version is newer or not |
1026 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 1030 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
1027 | 1031 | ||
1028 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 1032 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
1029 | if ( p->isPackageStoredLocally() && val == -1 ) | 1033 | if ( p->isPackageStoredLocally() && val == -1 ) |
1030 | val = 0; | 1034 | val = 0; |
1031 | 1035 | ||
1032 | if ( val == -2 ) | 1036 | if ( val == -2 ) |
1033 | { | 1037 | { |
1034 | // Error - should handle | 1038 | // Error - should handle |
1035 | } | 1039 | } |
1036 | else if ( val == -1 ) | 1040 | else if ( val == -1 ) |
1037 | { | 1041 | { |
1038 | // Version available is older - remove only | 1042 | // Version available is older - remove only |
1039 | newitem->option = "D"; | 1043 | newitem->option = "D"; |
1040 | } | 1044 | } |
1041 | else | 1045 | else |
1042 | { | 1046 | { |
1043 | QString caption; | 1047 | QString caption; |
1044 | QString text; | 1048 | QString text; |
1045 | QString secondButton; | 1049 | QString secondButton; |
1046 | QString secondOption; | 1050 | QString secondOption; |
1047 | if ( val == 0 ) | 1051 | if ( val == 0 ) |
1048 | { | 1052 | { |
1049 | // Version available is the same - option to remove or reinstall | 1053 | // Version available is the same - option to remove or reinstall |
1050 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | 1054 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); |
1051 | text = tr( "Remove or ReInstall" ); | 1055 | text = tr( "Remove or ReInstall" ); |
1052 | secondButton = tr( "ReInstall" ); | 1056 | secondButton = tr( "ReInstall" ); |
1053 | secondOption = tr( "R" ); | 1057 | secondOption = tr( "R" ); |
1054 | } | 1058 | } |
1055 | else if ( val == 1 ) | 1059 | else if ( val == 1 ) |
1056 | { | 1060 | { |
1057 | // Version available is newer - option to remove or upgrade | 1061 | // Version available is newer - option to remove or upgrade |
1058 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | 1062 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); |
1059 | text = tr( "Remove or Upgrade" ); | 1063 | text = tr( "Remove or Upgrade" ); |
1060 | secondButton = tr( "Upgrade" ); | 1064 | secondButton = tr( "Upgrade" ); |
1061 | secondOption = tr( "U" ); | 1065 | secondOption = tr( "U" ); |
1062 | } | 1066 | } |
1063 | 1067 | ||
1064 | // Sticky option not implemented yet, but will eventually allow | 1068 | // Sticky option not implemented yet, but will eventually allow |
1065 | // the user to say something like 'remove all' | 1069 | // the user to say something like 'remove all' |
1066 | if ( stickyOption == "" ) | 1070 | if ( stickyOption == "" ) |
1067 | { | 1071 | { |
1068 | QString msgtext; | 1072 | QString msgtext; |
1069 | msgtext = caption.arg( ( const char * )name ); | 1073 | msgtext = caption.arg( ( const char * )name ); |
1070 | switch( QMessageBox::information( this, text, | 1074 | // switch( QMessageBox::information( this, text, |
1071 | msgtext, tr( "Remove" ), secondButton ) ) | 1075 | // msgtext, tr( "Remove" ), secondButton ) ) |
1076 | QuestionDlg dlg( text, msgtext, secondButton ); | ||
1077 | switch( dlg.exec() ) | ||
1072 | { | 1078 | { |
1073 | case 0: // Try again or Enter | 1079 | case 0: // Cancel |
1074 | // option 0 = Remove | 1080 | delete newitem; |
1081 | return 0x0; | ||
1082 | break; | ||
1083 | case 1: // Remove | ||
1075 | newitem->option = "D"; | 1084 | newitem->option = "D"; |
1076 | break; | 1085 | break; |
1077 | case 1: // Quit or Escape | 1086 | case 2: // Reinstall or Upgrade |
1078 | newitem->option = secondOption; | 1087 | newitem->option = secondOption; |
1079 | break; | 1088 | break; |
1080 | } | 1089 | } |
1081 | } | 1090 | } |
1082 | else | 1091 | else |
1083 | { | 1092 | { |
1084 | // newitem->option = stickyOption; | 1093 | // newitem->option = stickyOption; |
1085 | } | 1094 | } |
1086 | } | 1095 | } |
1087 | 1096 | ||
1088 | 1097 | ||
1089 | // Check if we are reinstalling the same version | 1098 | // Check if we are reinstalling the same version |
1090 | if ( newitem->option != "R" ) | 1099 | if ( newitem->option != "R" ) |
1091 | newitem->recreateLinks = true; | 1100 | newitem->recreateLinks = true; |
1092 | else | 1101 | else |
1093 | newitem->recreateLinks = false; | 1102 | newitem->recreateLinks = false; |
1094 | 1103 | ||
1095 | // User hit cancel (on dlg - assume remove) | 1104 | // User hit cancel (on dlg - assume remove) |
1096 | return newitem; | 1105 | return newitem; |
1097 | } | 1106 | } |
1098 | } | 1107 | } |
1099 | 1108 | ||
1100 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) | 1109 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) |
1101 | { | 1110 | { |
1102 | stack->raiseWidget( progressWindow ); | 1111 | stack->raiseWidget( progressWindow ); |
1103 | 1112 | ||
1104 | if ( dlg ) | 1113 | if ( dlg ) |
1105 | { | 1114 | { |
1106 | dlg->close(); | 1115 | dlg->close(); |
1107 | delete dlg; | 1116 | delete dlg; |
1108 | } | 1117 | } |
1109 | 1118 | ||
1110 | mgr->reloadServerData(); | 1119 | mgr->reloadServerData(); |
1111 | serverSelected( -1, FALSE ); | 1120 | serverSelected( -1, FALSE ); |
1112 | 1121 | ||
1113 | #ifdef QWS | 1122 | #ifdef QWS |
1114 | if ( reloadDocuments ) | 1123 | if ( reloadDocuments ) |
1115 | { | 1124 | { |
1116 | m_status->setText( tr( "Updating Launcher..." ) ); | 1125 | m_status->setText( tr( "Updating Launcher..." ) ); |
1117 | 1126 | ||
1118 | // Finally let the main system update itself | 1127 | // Finally let the main system update itself |
1119 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 1128 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
1120 | QString lf = QString::null; | 1129 | QString lf = QString::null; |
1121 | e << lf; | 1130 | e << lf; |
1122 | } | 1131 | } |
1123 | #endif | 1132 | #endif |
1124 | 1133 | ||
1125 | stack->raiseWidget( networkPkgWindow ); | 1134 | stack->raiseWidget( networkPkgWindow ); |
1126 | } | 1135 | } |
1127 | 1136 | ||
1128 | void MainWindow :: letterPushed( QString t ) | 1137 | void MainWindow :: letterPushed( QString t ) |
1129 | { | 1138 | { |
1130 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 1139 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
1131 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 1140 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
1132 | if ( packagesList->firstChild() == 0 ) | 1141 | if ( packagesList->firstChild() == 0 ) |
1133 | return; | 1142 | return; |
1134 | 1143 | ||
1135 | QCheckListItem *item; | 1144 | QCheckListItem *item; |
1136 | if ( start == 0 ) | 1145 | if ( start == 0 ) |
1137 | { | 1146 | { |
1138 | item = (QCheckListItem *)packagesList->firstChild(); | 1147 | item = (QCheckListItem *)packagesList->firstChild(); |
1139 | start = top; | 1148 | start = top; |
1140 | } | 1149 | } |
1141 | else | 1150 | else |
1142 | item = (QCheckListItem *)start->nextSibling(); | 1151 | item = (QCheckListItem *)start->nextSibling(); |
1143 | 1152 | ||
1144 | if ( item == 0 ) | 1153 | if ( item == 0 ) |
1145 | item = (QCheckListItem *)packagesList->firstChild(); | 1154 | item = (QCheckListItem *)packagesList->firstChild(); |
1146 | do | 1155 | do |
1147 | { | 1156 | { |
1148 | if ( item->text().lower().startsWith( t.lower() ) ) | 1157 | if ( item->text().lower().startsWith( t.lower() ) ) |
1149 | { | 1158 | { |
1150 | packagesList->setSelected( item, true ); | 1159 | packagesList->setSelected( item, true ); |
1151 | packagesList->ensureItemVisible( item ); | 1160 | packagesList->ensureItemVisible( item ); |
1152 | break; | 1161 | break; |
1153 | } | 1162 | } |
1154 | 1163 | ||
1155 | item = (QCheckListItem *)item->nextSibling(); | 1164 | item = (QCheckListItem *)item->nextSibling(); |
1156 | if ( !item ) | 1165 | if ( !item ) |
1157 | item = (QCheckListItem *)packagesList->firstChild(); | 1166 | item = (QCheckListItem *)packagesList->firstChild(); |
1158 | } while ( item != start); | 1167 | } while ( item != start); |
1159 | } | 1168 | } |
1160 | 1169 | ||
1161 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) | 1170 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) |
1162 | { | 1171 | { |
1163 | QString itemstr( ((QCheckListItem*)item)->text() ); | 1172 | QString itemstr( ((QCheckListItem*)item)->text() ); |
1164 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); | 1173 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); |
1165 | p->showMaximized(); | 1174 | p->showMaximized(); |
1166 | } | 1175 | } |
1176 | |||
1177 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) | ||
1178 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) | ||
1179 | { | ||
1180 | setCaption( caption ); | ||
1181 | resize( 175, 100 ); | ||
1182 | |||
1183 | QGridLayout *layout = new QGridLayout( this ); | ||
1184 | |||
1185 | QLabel *l = new QLabel( text, this ); | ||
1186 | l->setAlignment( AlignCenter | WordBreak ); | ||
1187 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); | ||
1188 | |||
1189 | btn1 = new QPushButton( tr( "Remove" ), this ); | ||
1190 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | ||
1191 | layout->addWidget( btn1, 1, 0 ); | ||
1192 | |||
1193 | btn2 = new QPushButton( secondbtn, this ); | ||
1194 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | ||
1195 | layout->addWidget( btn2, 1, 1 ); | ||
1196 | |||
1197 | executing = FALSE; | ||
1198 | } | ||
1199 | |||
1200 | int QuestionDlg::exec() | ||
1201 | { | ||
1202 | show(); | ||
1203 | |||
1204 | if ( !executing ) | ||
1205 | { | ||
1206 | executing = TRUE; | ||
1207 | qApp->enter_loop(); | ||
1208 | } | ||
1209 | |||
1210 | return buttonpressed; | ||
1211 | } | ||
1212 | |||
1213 | void QuestionDlg::slotButtonPressed() | ||
1214 | { | ||
1215 | if ( sender() == btn1 ) | ||
1216 | buttonpressed = 1; | ||
1217 | else if ( sender() == btn2 ) | ||
1218 | buttonpressed = 2; | ||
1219 | else | ||
1220 | buttonpressed = 0; | ||
1221 | |||
1222 | qApp->exit_loop(); | ||
1223 | } | ||
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index 9f48321..615ff8b 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h | |||
@@ -1,154 +1,175 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef MAINWIN_H | 30 | #ifndef MAINWIN_H |
31 | #define MAINWIN_H | 31 | #define MAINWIN_H |
32 | 32 | ||
33 | #include <qmainwindow.h> | 33 | #include <qmainwindow.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | 35 | ||
36 | class DataManager; | 36 | class DataManager; |
37 | class InstallData; | 37 | class InstallData; |
38 | class InstallDlgImpl; | 38 | class InstallDlgImpl; |
39 | 39 | ||
40 | class QAction; | 40 | class QAction; |
41 | class QCheckListItem; | 41 | class QCheckListItem; |
42 | class QComboBox; | 42 | class QComboBox; |
43 | class QLabel; | 43 | class QLabel; |
44 | class QLineEdit; | 44 | class QLineEdit; |
45 | class QListView; | 45 | class QListView; |
46 | class QListViewItem; | 46 | class QListViewItem; |
47 | class QToolBar; | 47 | class QToolBar; |
48 | class QProgressBar; | 48 | class QProgressBar; |
49 | class QPushButton; | ||
49 | class QWidgetStack; | 50 | class QWidgetStack; |
50 | 51 | ||
51 | class MainWindow :public QMainWindow | 52 | class MainWindow :public QMainWindow |
52 | { | 53 | { |
53 | Q_OBJECT | 54 | Q_OBJECT |
54 | public: | 55 | public: |
55 | 56 | ||
56 | MainWindow(); | 57 | MainWindow(); |
57 | ~MainWindow(); | 58 | ~MainWindow(); |
58 | 59 | ||
59 | protected: | 60 | protected: |
60 | void closeEvent( QCloseEvent* e ); | 61 | void closeEvent( QCloseEvent* e ); |
61 | 62 | ||
62 | private: | 63 | private: |
63 | DataManager *mgr; | 64 | DataManager *mgr; |
64 | 65 | ||
65 | QWidgetStack *stack; | 66 | QWidgetStack *stack; |
66 | 67 | ||
67 | QToolBar *findBar; | 68 | QToolBar *findBar; |
68 | QToolBar *jumpBar; | 69 | QToolBar *jumpBar; |
69 | QLineEdit *findEdit; | 70 | QLineEdit *findEdit; |
70 | QAction *actionFindNext; | 71 | QAction *actionFindNext; |
71 | QAction *actionFilter; | 72 | QAction *actionFilter; |
72 | QAction *actionUpgrade; | 73 | QAction *actionUpgrade; |
73 | QAction *actionDownload; | 74 | QAction *actionDownload; |
74 | QAction *actionUninstalled; | 75 | QAction *actionUninstalled; |
75 | QAction *actionInstalled; | 76 | QAction *actionInstalled; |
76 | QAction *actionUpdated; | 77 | QAction *actionUpdated; |
77 | 78 | ||
78 | QPixmap iconDownload; | 79 | QPixmap iconDownload; |
79 | QPixmap iconRemove; | 80 | QPixmap iconRemove; |
80 | 81 | ||
81 | int mnuShowUninstalledPkgsId; | 82 | int mnuShowUninstalledPkgsId; |
82 | int mnuShowInstalledPkgsId; | 83 | int mnuShowInstalledPkgsId; |
83 | int mnuShowUpgradedPkgsId; | 84 | int mnuShowUpgradedPkgsId; |
84 | int mnuFilterByCategory; | 85 | int mnuFilterByCategory; |
85 | int mnuSetFilterCategory; | 86 | int mnuSetFilterCategory; |
86 | 87 | ||
87 | // Main package list widget | 88 | // Main package list widget |
88 | QWidget *networkPkgWindow; | 89 | QWidget *networkPkgWindow; |
89 | QComboBox *serversList; | 90 | QComboBox *serversList; |
90 | QListView *packagesList; | 91 | QListView *packagesList; |
91 | QPixmap installedIcon; | 92 | QPixmap installedIcon; |
92 | QPixmap updatedIcon; | 93 | QPixmap updatedIcon; |
93 | QString currentlySelectedServer; | 94 | QString currentlySelectedServer; |
94 | QString categoryFilter; | 95 | QString categoryFilter; |
95 | QString stickyOption; | 96 | QString stickyOption; |
96 | 97 | ||
97 | bool categoryFilterEnabled; | 98 | bool categoryFilterEnabled; |
98 | bool showJumpTo; | 99 | bool showJumpTo; |
99 | bool showUninstalledPkgs; | 100 | bool showUninstalledPkgs; |
100 | bool showInstalledPkgs; | 101 | bool showInstalledPkgs; |
101 | bool showUpgradedPkgs; | 102 | bool showUpgradedPkgs; |
102 | bool downloadEnabled; | 103 | bool downloadEnabled; |
103 | bool reloadDocuments; | 104 | bool reloadDocuments; |
104 | 105 | ||
105 | void initMainWidget(); | 106 | void initMainWidget(); |
106 | void updateData(); | 107 | void updateData(); |
107 | void serverSelected( int index, bool showProgress ); | 108 | void serverSelected( int index, bool showProgress ); |
108 | void searchForPackage( const QString & ); | 109 | void searchForPackage( const QString & ); |
109 | bool filterByCategory( bool val ); | 110 | bool filterByCategory( bool val ); |
110 | void downloadSelectedPackages(); | 111 | void downloadSelectedPackages(); |
111 | void downloadRemotePackage(); | 112 | void downloadRemotePackage(); |
112 | InstallData *dealWithItem( QCheckListItem *item ); | 113 | InstallData *dealWithItem( QCheckListItem *item ); |
113 | 114 | ||
114 | // Progress widget | 115 | // Progress widget |
115 | QWidget *progressWindow; | 116 | QWidget *progressWindow; |
116 | QLabel *m_status; | 117 | QLabel *m_status; |
117 | QProgressBar *m_progress; | 118 | QProgressBar *m_progress; |
118 | 119 | ||
119 | void initProgressWidget(); | 120 | void initProgressWidget(); |
120 | 121 | ||
121 | public slots: | 122 | public slots: |
122 | void setDocument( const QString &doc ); | 123 | void setDocument( const QString &doc ); |
123 | void displayFindBar(); | 124 | void displayFindBar(); |
124 | void displayJumpBar(); | 125 | void displayJumpBar(); |
125 | void repeatFind(); | 126 | void repeatFind(); |
126 | void findPackage( const QString & ); | 127 | void findPackage( const QString & ); |
127 | void hideFindBar(); | 128 | void hideFindBar(); |
128 | void hideJumpBar(); | 129 | void hideJumpBar(); |
129 | void displaySettings(); | 130 | void displaySettings(); |
130 | void filterUninstalledPackages(); | 131 | void filterUninstalledPackages(); |
131 | void filterInstalledPackages(); | 132 | void filterInstalledPackages(); |
132 | void filterUpgradedPackages(); | 133 | void filterUpgradedPackages(); |
133 | void filterCategory(); | 134 | void filterCategory(); |
134 | bool setFilterCategory(); | 135 | bool setFilterCategory(); |
135 | void raiseMainWidget(); | 136 | void raiseMainWidget(); |
136 | void raiseProgressWidget(); | 137 | void raiseProgressWidget(); |
137 | void enableUpgrade( bool ); | 138 | void enableUpgrade( bool ); |
138 | void enableDownload( bool ); | 139 | void enableDownload( bool ); |
139 | void reloadData( InstallDlgImpl * ); | 140 | void reloadData( InstallDlgImpl * ); |
140 | 141 | ||
141 | private slots: | 142 | private slots: |
142 | void init(); | 143 | void init(); |
143 | void setProgressSteps( int ); | 144 | void setProgressSteps( int ); |
144 | void setProgressMessage( const QString & ); | 145 | void setProgressMessage( const QString & ); |
145 | void updateProgress( int ); | 146 | void updateProgress( int ); |
146 | void serverSelected( int index ); | 147 | void serverSelected( int index ); |
147 | void updateServer(); | 148 | void updateServer(); |
148 | void upgradePackages(); | 149 | void upgradePackages(); |
149 | void downloadPackage(); | 150 | void downloadPackage(); |
150 | void applyChanges(); | 151 | void applyChanges(); |
151 | void letterPushed( QString t ); | 152 | void letterPushed( QString t ); |
152 | void slotDisplayPackage( QListViewItem * ); | 153 | void slotDisplayPackage( QListViewItem * ); |
153 | }; | 154 | }; |
155 | |||
156 | class QuestionDlg : public QWidget | ||
157 | { | ||
158 | Q_OBJECT | ||
159 | public: | ||
160 | QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ); | ||
161 | |||
162 | int exec(); | ||
163 | |||
164 | private: | ||
165 | QPushButton *btn1; | ||
166 | QPushButton *btn2; | ||
167 | |||
168 | bool executing; | ||
169 | int buttonpressed; | ||
170 | |||
171 | private slots: | ||
172 | void slotButtonPressed(); | ||
173 | }; | ||
174 | |||
154 | #endif | 175 | #endif |