From 88ee12a1ab3d46d9a5bda57d961fd0bf1dbdd6da Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Fri, 4 Jan 2013 17:41:26 +0100 Subject: [PATCH] Delete the DeleteIndexForm Delete the DeleteIndexForm as it is no longer needed. Since the last commit an index can be deleted directly via the popup menu. --- src/DeleteIndexForm.cpp | 56 ----------------- src/DeleteIndexForm.h | 131 ---------------------------------------- src/MainWindow.cpp | 31 +--------- src/MainWindow.h | 1 - src/MainWindow.ui | 37 +----------- src/src.pro | 2 - 6 files changed, 6 insertions(+), 252 deletions(-) delete mode 100644 src/DeleteIndexForm.cpp delete mode 100644 src/DeleteIndexForm.h diff --git a/src/DeleteIndexForm.cpp b/src/DeleteIndexForm.cpp deleted file mode 100644 index 54b698d2..00000000 --- a/src/DeleteIndexForm.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "DeleteIndexForm.h" -#include -/* - * Constructs a deleteIndexForm as a child of 'parent', with the - * name 'name' and widget flags set to 'f'. - * - * The dialog will by default be modeless, unless you set 'modal' to - * true to construct a modal dialog. - */ -deleteIndexForm::deleteIndexForm(QWidget* parent, Qt::WindowFlags fl) - : QDialog(parent, fl) -{ - setupUi(this); - -} - -/* - * Destroys the object and frees any allocated resources - */ -deleteIndexForm::~deleteIndexForm() -{ - // no need to delete child widgets, Qt does it all for us -} - -/* - * Sets the strings of the subwidgets using the current - * language. - */ -void deleteIndexForm::languageChange() -{ - retranslateUi(this); -} - -void deleteIndexForm::confirmDelete() -{ - QString msg = "Are you sure you want to delete index "; - msg.append(comboOptions->currentText()); - msg.append("?"); - - if (QMessageBox::warning( this, QApplication::applicationName(), - msg, - QMessageBox::Yes | QMessageBox::Default, - QMessageBox::No | QMessageBox::Escape ) - == QMessageBox::Yes ){ - option = comboOptions->currentText(); - accept(); - } -} - -void deleteIndexForm::populateOptions(QStringList entries) -{ - comboOptions->clear(); - comboOptions->addItems(entries); -} - - diff --git a/src/DeleteIndexForm.h b/src/DeleteIndexForm.h deleted file mode 100644 index 21ad791b..00000000 --- a/src/DeleteIndexForm.h +++ /dev/null @@ -1,131 +0,0 @@ -#ifndef DELETEINDEXFORM_H -#define DELETEINDEXFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class Ui_deleteIndexForm -{ -public: - QVBoxLayout *vboxLayout; - QHBoxLayout *hboxLayout; - QLabel *textLabel2; - QComboBox *comboOptions; - QSpacerItem *spacer13; - QHBoxLayout *hboxLayout1; - QSpacerItem *spacer11; - QPushButton *buttonDelete; - QPushButton *buttonCancel; - - void setupUi(QDialog *deleteIndexForm) - { - if (deleteIndexForm->objectName().isEmpty()) - deleteIndexForm->setObjectName(QString::fromUtf8("deleteIndexForm")); - deleteIndexForm->resize(236, 137); - vboxLayout = new QVBoxLayout(deleteIndexForm); - vboxLayout->setSpacing(6); - vboxLayout->setContentsMargins(11, 11, 11, 11); - vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); - hboxLayout = new QHBoxLayout(); - hboxLayout->setSpacing(6); - hboxLayout->setObjectName(QString::fromUtf8("hboxLayout")); - textLabel2 = new QLabel(deleteIndexForm); - textLabel2->setObjectName(QString::fromUtf8("textLabel2")); - textLabel2->setWordWrap(false); - - hboxLayout->addWidget(textLabel2); - - comboOptions = new QComboBox(deleteIndexForm); - comboOptions->setObjectName(QString::fromUtf8("comboOptions")); - - hboxLayout->addWidget(comboOptions); - - - vboxLayout->addLayout(hboxLayout); - - spacer13 = new QSpacerItem(20, 41, QSizePolicy::Minimum, QSizePolicy::Expanding); - - vboxLayout->addItem(spacer13); - - hboxLayout1 = new QHBoxLayout(); - hboxLayout1->setSpacing(6); - hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1")); - spacer11 = new QSpacerItem(31, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - hboxLayout1->addItem(spacer11); - - buttonDelete = new QPushButton(deleteIndexForm); - buttonDelete->setObjectName(QString::fromUtf8("buttonDelete")); - - hboxLayout1->addWidget(buttonDelete); - - buttonCancel = new QPushButton(deleteIndexForm); - buttonCancel->setObjectName(QString::fromUtf8("buttonCancel")); - buttonCancel->setDefault(true); - - hboxLayout1->addWidget(buttonCancel); - - - vboxLayout->addLayout(hboxLayout1); - - - retranslateUi(deleteIndexForm); - QObject::connect(buttonDelete, SIGNAL(clicked()), deleteIndexForm, SLOT(confirmDelete())); - QObject::connect(buttonCancel, SIGNAL(clicked()), deleteIndexForm, SLOT(reject())); - - QMetaObject::connectSlotsByName(deleteIndexForm); - } // setupUi - - void retranslateUi(QDialog *deleteIndexForm) - { - deleteIndexForm->setWindowTitle(QApplication::translate("deleteIndexForm", "Delete Index", 0, QApplication::UnicodeUTF8)); - textLabel2->setText(QApplication::translate("deleteIndexForm", "Index name:", 0, QApplication::UnicodeUTF8)); -#ifndef QT_NO_TOOLTIP - comboOptions->setProperty("toolTip", QVariant(QApplication::translate("deleteIndexForm", "Choose the index to delete", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS - comboOptions->setProperty("whatsThis", QVariant(QApplication::translate("deleteIndexForm", "Use this control to select the name of the index to be deleted", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_WHATSTHIS - buttonDelete->setText(QApplication::translate("deleteIndexForm", "Delete", 0, QApplication::UnicodeUTF8)); -#ifndef QT_NO_TOOLTIP - buttonDelete->setProperty("toolTip", QVariant(QApplication::translate("deleteIndexForm", "Delete the selected index", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_TOOLTIP - buttonCancel->setText(QApplication::translate("deleteIndexForm", "Cancel", 0, QApplication::UnicodeUTF8)); -#ifndef QT_NO_TOOLTIP - buttonCancel->setProperty("toolTip", QVariant(QApplication::translate("deleteIndexForm", "Cancel and close dialog box", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_TOOLTIP - } // retranslateUi - -}; - -namespace Ui { - class deleteIndexForm: public Ui_deleteIndexForm {}; -} // namespace Ui - -class deleteIndexForm : public QDialog, public Ui::deleteIndexForm -{ - Q_OBJECT - -public: - deleteIndexForm(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window); - ~deleteIndexForm(); - - QString option; - -public slots: - virtual void confirmDelete(); - virtual void populateOptions( QStringList entries ); - -protected slots: - virtual void languageChange(); - -}; - -#endif // DELETEINDEXFORM_H diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 7f513c53..d9fbd035 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -12,7 +12,6 @@ #include #include #include "CreateIndexForm.h" -#include "DeleteIndexForm.h" #include "DialogAbout.h" #include "EditTableForm.h" #include "EditFieldForm.h" @@ -640,31 +639,6 @@ void MainWindow::editTable() } } -void MainWindow::deleteIndex() -{ - if (!db.isOpen()){ - QMessageBox::information( this, QApplication::applicationName(), "There is no database opened." ); - return; - } - deleteIndexForm dialog(this); - dialog.populateOptions(db.getIndexNames()); - if(dialog.exec()) - { - QString statement = "DROP INDEX "; - statement.append(dialog.option); - statement.append(";"); - if (!db.executeSQL( statement)){ - QString error = "Error: could not delete the index. Message from database engine: "; - error.append(db.lastErrorMessage); - QMessageBox::warning( this, QApplication::applicationName(), error ); - } else { - populateStructure(); - resetBrowser(); - } - } - -} - void MainWindow::copy() { QWidget * t = ui->dataTable->cellWidget(ui->dataTable->currentRow(), ui->dataTable->currentColumn()); @@ -1083,13 +1057,15 @@ void MainWindow::on_tree_selection_changed() return; // Change the text of the actions - ui->editDeleteObjectAction->setText(tr("Delete Table")); + ui->editDeleteObjectAction->setIcon(QIcon(QString(":icons/%1_delete").arg(ui->dbTreeWidget->currentItem()->text(1)))); if(ui->dbTreeWidget->currentItem()->text(1) == "view") ui->editDeleteObjectAction->setText(tr("Delete View")); else if(ui->dbTreeWidget->currentItem()->text(1) == "trigger") ui->editDeleteObjectAction->setText(tr("Delete Trigger")); else if(ui->dbTreeWidget->currentItem()->text(1) == "index") ui->editDeleteObjectAction->setText(tr("Delete Index")); + else + ui->editDeleteObjectAction->setText(tr("Delete Table")); // Activate actions if(ui->dbTreeWidget->currentItem()->text(1) == "table") @@ -1217,7 +1193,6 @@ void MainWindow::activateFields(bool enable) ui->fileImportCSVAction->setEnabled(enable); ui->editCreateTableAction->setEnabled(enable); ui->editCreateIndexAction->setEnabled(enable); - ui->editDeleteIndexAction->setEnabled(enable); ui->buttonNext->setEnabled(enable); ui->buttonPrevious->setEnabled(enable); ui->executeQueryButton->setEnabled(enable); diff --git a/src/MainWindow.h b/src/MainWindow.h index 3a54c110..c76f0c0e 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -94,7 +94,6 @@ public slots: virtual void compact(); virtual void deleteObject(); virtual void editTable(); - virtual void deleteIndex(); virtual void copy(); virtual void paste(); virtual void helpWhatsThis(); diff --git a/src/MainWindow.ui b/src/MainWindow.ui index af824852..82312e17 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -294,7 +294,7 @@ 0 0 - 763 + 354 653 @@ -972,11 +972,11 @@ &Edit - + + - @@ -1252,21 +1252,6 @@ Open the Create Index wizard, where it is possible to define a new index on an existing database table. - - - false - - - - :/icons/index_delete:/icons/index_delete - - - Delete Index - - - Open the Delete Index wizard, where you can select a database index to be dropped. - - @@ -1822,22 +1807,6 @@ - - editDeleteIndexAction - activated() - MainWindow - deleteIndex() - - - -1 - -1 - - - 399 - 299 - - - editCreateIndexAction activated() diff --git a/src/src.pro b/src/src.pro index cc62274d..3d57c0ab 100644 --- a/src/src.pro +++ b/src/src.pro @@ -16,7 +16,6 @@ HEADERS += \ sqlite_source/sqlite3.h \ SQLLogDock.h \ CreateIndexForm.h \ - DeleteIndexForm.h \ DialogAbout.h \ EditFieldForm.h \ EditForm.h \ @@ -35,7 +34,6 @@ SOURCES += \ SQLLogDock.cpp \ main.cpp \ CreateIndexForm.cpp \ - DeleteIndexForm.cpp \ DialogAbout.cpp \ EditFieldForm.cpp \ EditForm.cpp \