comparison ui/mainwindow.cpp @ 1106:6f7b7d88f048

(issue115) Rework CertificateListWidgets to have a ToolButton instead of a combobox
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 15 Sep 2014 17:43:56 +0200
parents a7a72353d6d2
children 51d3b361f17a
comparison
equal deleted inserted replaced
1105:0c60ec9c2461 1106:6f7b7d88f048
1129 // No new list available, add old certificates. 1129 // No new list available, add old certificates.
1130 foreach (const Certificate &cert, mInstalledList.getCertificates()) { 1130 foreach (const Certificate &cert, mInstalledList.getCertificates()) {
1131 bool state = !mPreviouslyUnselected.contains(cert.base64Line()); 1131 bool state = !mPreviouslyUnselected.contains(cert.base64Line());
1132 if (cert.isInstallCert()) { 1132 if (cert.isInstallCert()) {
1133 oldInstallCerts.append(cert); 1133 oldInstallCerts.append(cert);
1134 mInstallList->addCertificate(cert, state); 1134 QToolButton* actionBtn = new QToolButton();
1135 QIcon btnIcon;
1136 if (!state) {
1137 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1138 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1139 } else {
1140 btnIcon.addFile(":/img/security-high.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1141 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1142 }
1143 actionBtn->setIcon(btnIcon);
1144 mInstallList->addCertificate(cert, state, actionBtn);
1135 } 1145 }
1136 else { 1146 else {
1137 oldRemoveCerts.append(cert); 1147 oldRemoveCerts.append(cert);
1138 mRemoveList->addCertificate(cert, state, !state); 1148 QToolButton* actionBtn = new QToolButton();
1149 QIcon btnIcon;
1150 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1151 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1152 btnIcon.addFile(":/img/trash-empty.png", QSize(48, 48), QIcon::Disabled, QIcon::Off);
1153 actionBtn->setIcon(btnIcon);
1154 if (state) {
1155 actionBtn->setEnabled(false);
1156 }
1157 mRemoveList->addCertificate(cert, state, actionBtn);
1139 } 1158 }
1140 } 1159 }
1141 } 1160 }
1142 else { 1161 else {
1143 // Sort and filter both lists. 1162 // Sort and filter both lists.
1146 if (cert.isInstallCert()) { 1165 if (cert.isInstallCert()) {
1147 // Certificate with status "install". 1166 // Certificate with status "install".
1148 if (mInstalledList.getCertificates().contains(cert)) { 1167 if (mInstalledList.getCertificates().contains(cert)) {
1149 // Was in the old list. 1168 // Was in the old list.
1150 oldInstallCerts.append(cert); 1169 oldInstallCerts.append(cert);
1151 mInstallList->addCertificate(cert, state); 1170 QToolButton* actionBtn = new QToolButton();
1171 QIcon btnIcon;
1172 btnIcon.addFile(":/img/security-high.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1173 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1174 actionBtn->setIcon(btnIcon);
1175 mInstallList->addCertificate(cert, state, actionBtn);
1152 } 1176 }
1153 else { 1177 else {
1154 // Is a brand new certificate 1178 // Is a brand new certificate
1155 newInstallCerts.append(cert); 1179 newInstallCerts.append(cert);
1156 mUpdatesNew->addCertificate(cert, state, true, 1180 QToolButton* actionBtn = new QToolButton();
1157 tr("install"), tr("ignore")); 1181 QIcon btnIcon;
1182 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1183 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1184 actionBtn->setIcon(btnIcon);
1185 mUpdatesNew->addCertificate(cert, state, actionBtn);
1158 } 1186 }
1159 } 1187 }
1160 else { 1188 else {
1161 // Certificate with status "remove". 1189 // Certificate with status "remove".
1162 if (mInstalledList.getCertificates().contains(cert)) { 1190 if (mInstalledList.getCertificates().contains(cert)) {
1163 // Was in the old list. 1191 // Was in the old list.
1164 oldRemoveCerts.append(cert); 1192 oldRemoveCerts.append(cert);
1165 // Is removed, so set editable to false. 1193 // Is removed, so set editable to false.
1166 mRemoveList->addCertificate(cert, state, !state); 1194 QToolButton* actionBtn = new QToolButton();
1195 QIcon btnIcon;
1196 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1197 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1198 btnIcon.addFile(":/img/trash-empty.png", QSize(48, 48), QIcon::Disabled, QIcon::Off);
1199 actionBtn->setIcon(btnIcon);
1200 if (state) {
1201 actionBtn->setEnabled(false);
1202 }
1203 mRemoveList->addCertificate(cert, state, actionBtn);
1167 } 1204 }
1168 else { 1205 else {
1169 // Was in the old list with status "install" and now has the 1206 // Was in the old list with status "install" and now has the
1170 // status "remove". 1207 // status "remove".
1171 newRemoveCerts.append(cert); 1208 newRemoveCerts.append(cert);
1172 mUpdatesRemove->addCertificate(cert, state); 1209 QToolButton* actionBtn = new QToolButton();
1210 QIcon btnIcon;
1211 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1212 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1213 actionBtn->setIcon(btnIcon);
1214 mUpdatesRemove->addCertificate(cert, state, actionBtn);
1173 } 1215 }
1174 } 1216 }
1175 } 1217 }
1176 } 1218 }
1177 1219
1336 } 1378 }
1337 1379
1338 void MainWindow::toggleInManual(bool state, const Certificate &cert) 1380 void MainWindow::toggleInManual(bool state, const Certificate &cert)
1339 { 1381 {
1340 if (!mUpdatesManual->contains(cert)) { 1382 if (!mUpdatesManual->contains(cert)) {
1341 mUpdatesManual->addCertificate(cert, state); 1383 QToolButton* actionBtn = new QToolButton();
1384 QIcon btnIcon;
1385 if (cert.isInstallCert()) {
1386 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1387 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1388 } else {
1389 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1390 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1391 }
1392 actionBtn->setIcon(btnIcon);
1393 mUpdatesManual->addCertificate(cert, state, actionBtn);
1342 } 1394 }
1343 else { 1395 else {
1344 if (cert.isActive()) { 1396 if (cert.isActive()) {
1345 mUpdatesManual->deactivateCertificate(cert); 1397 mUpdatesManual->deactivateCertificate(cert);
1346 } else { 1398 } else {

http://wald.intevation.org/projects/trustbridge/