-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 | |||
@@ -944,33 +944,37 @@ void MainWindow :: applyChanges() | |||
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; |
@@ -1054,40 +1058,45 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) | |||
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; |
@@ -1151,16 +1160,64 @@ void MainWindow :: letterPushed( QString t ) | |||
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 | |||
@@ -33,32 +33,33 @@ | |||
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 | ||
@@ -138,17 +139,37 @@ public slots: | |||
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 |