Delete the ChooseTableForm and DeleteTableForm dialogs

Delete those two dialog, the only use of which is to make it possible to
select a table which is totally pointless because the user can do this
in the main window and would probably do so intuitively anyway.
This commit is contained in:
Martin Kleusberg
2013-01-02 20:03:33 +01:00
parent 547e8d9964
commit 0180017dbd
8 changed files with 13 additions and 520 deletions

View File

@@ -1,45 +0,0 @@
#include "ChooseTableForm.h"
/*
* Constructs a chooseTableForm 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.
*/
chooseTableForm::chooseTableForm(QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
chooseTableForm::~chooseTableForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void chooseTableForm::languageChange()
{
retranslateUi(this);
}
void chooseTableForm::editPressed()
{
option = comboOptions->currentText();
accept();
}
void chooseTableForm::populateOptions(QStringList entries)
{
comboOptions->clear();
comboOptions->addItems(entries);
}

View File

@@ -1,130 +0,0 @@
#ifndef CHOOSETABLEFORM_H
#define CHOOSETABLEFORM_H
#include <QtGui/QApplication>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
class Ui_chooseTableForm
{
public:
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
QLabel *textLabel2;
QComboBox *comboOptions;
QSpacerItem *spacer13;
QHBoxLayout *hboxLayout1;
QSpacerItem *spacer11;
QPushButton *buttonEdit;
QPushButton *buttonCancel;
void setupUi(QDialog *chooseTableForm)
{
if (chooseTableForm->objectName().isEmpty())
chooseTableForm->setObjectName(QString::fromUtf8("chooseTableForm"));
chooseTableForm->resize(256, 163);
vboxLayout = new QVBoxLayout(chooseTableForm);
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(chooseTableForm);
textLabel2->setObjectName(QString::fromUtf8("textLabel2"));
textLabel2->setWordWrap(false);
hboxLayout->addWidget(textLabel2);
comboOptions = new QComboBox(chooseTableForm);
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);
buttonEdit = new QPushButton(chooseTableForm);
buttonEdit->setObjectName(QString::fromUtf8("buttonEdit"));
hboxLayout1->addWidget(buttonEdit);
buttonCancel = new QPushButton(chooseTableForm);
buttonCancel->setObjectName(QString::fromUtf8("buttonCancel"));
buttonCancel->setDefault(true);
hboxLayout1->addWidget(buttonCancel);
vboxLayout->addLayout(hboxLayout1);
retranslateUi(chooseTableForm);
QObject::connect(buttonCancel, SIGNAL(clicked()), chooseTableForm, SLOT(reject()));
QObject::connect(buttonEdit, SIGNAL(clicked()), chooseTableForm, SLOT(editPressed()));
QMetaObject::connectSlotsByName(chooseTableForm);
} // setupUi
void retranslateUi(QDialog *chooseTableForm)
{
chooseTableForm->setWindowTitle(QApplication::translate("chooseTableForm", "Select table to edit", 0, QApplication::UnicodeUTF8));
textLabel2->setText(QApplication::translate("chooseTableForm", "Table name:", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
comboOptions->setProperty("toolTip", QVariant(QApplication::translate("chooseTableForm", "Choose the table to delete", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
comboOptions->setProperty("whatsThis", QVariant(QApplication::translate("chooseTableForm", "Use this control to select the name of the table to be edited", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
buttonEdit->setText(QApplication::translate("chooseTableForm", "Edit", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonEdit->setProperty("toolTip", QVariant(QApplication::translate("chooseTableForm", "Edit table", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
buttonCancel->setText(QApplication::translate("chooseTableForm", "Cancel", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonCancel->setProperty("toolTip", QVariant(QApplication::translate("chooseTableForm", "Cancel and close dialog box", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
} // retranslateUi
};
namespace Ui {
class chooseTableForm: public Ui_chooseTableForm {};
} // namespace Ui
class chooseTableForm : public QDialog, public Ui::chooseTableForm
{
Q_OBJECT
public:
chooseTableForm(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
~chooseTableForm();
QString option;
public slots:
virtual void editPressed();
virtual void populateOptions( QStringList entries );
protected slots:
virtual void languageChange();
};
#endif // CHOOSETABLEFORM_H

View File

@@ -1,57 +0,0 @@
#include "DeleteTableForm.h"
#include <QMessageBox>
/*
* Constructs a deleteTableForm 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.
*/
deleteTableForm::deleteTableForm(QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
deleteTableForm::~deleteTableForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void deleteTableForm::languageChange()
{
retranslateUi(this);
}
void deleteTableForm::confirmDelete()
{
QString msg = "Are you sure you want to delete table ";
msg.append(comboOptions->currentText());
msg.append("? \n All data in the table will be lost");
if (QMessageBox::warning( this, QApplication::applicationName(),
msg,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape )
== QMessageBox::Yes ){
option = comboOptions->currentText();
accept();
}
}
void deleteTableForm::populateOptions(QStringList entries)
{
comboOptions->clear();
comboOptions->addItems(entries);
}

View File

@@ -1,131 +0,0 @@
#ifndef DELETETABLEFORM_H
#define DELETETABLEFORM_H
#include <QtGui/QApplication>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include <QtCore/QStringList>
class Ui_deleteTableForm
{
public:
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
QLabel *textLabel2;
QComboBox *comboOptions;
QSpacerItem *spacer13;
QHBoxLayout *hboxLayout1;
QSpacerItem *spacer11;
QPushButton *buttonDelete;
QPushButton *buttonCancel;
void setupUi(QDialog *deleteTableForm)
{
if (deleteTableForm->objectName().isEmpty())
deleteTableForm->setObjectName(QString::fromUtf8("deleteTableForm"));
deleteTableForm->resize(236, 137);
vboxLayout = new QVBoxLayout(deleteTableForm);
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(deleteTableForm);
textLabel2->setObjectName(QString::fromUtf8("textLabel2"));
textLabel2->setWordWrap(false);
hboxLayout->addWidget(textLabel2);
comboOptions = new QComboBox(deleteTableForm);
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(deleteTableForm);
buttonDelete->setObjectName(QString::fromUtf8("buttonDelete"));
hboxLayout1->addWidget(buttonDelete);
buttonCancel = new QPushButton(deleteTableForm);
buttonCancel->setObjectName(QString::fromUtf8("buttonCancel"));
buttonCancel->setDefault(true);
hboxLayout1->addWidget(buttonCancel);
vboxLayout->addLayout(hboxLayout1);
retranslateUi(deleteTableForm);
QObject::connect(buttonCancel, SIGNAL(clicked()), deleteTableForm, SLOT(reject()));
QObject::connect(buttonDelete, SIGNAL(clicked()), deleteTableForm, SLOT(confirmDelete()));
QMetaObject::connectSlotsByName(deleteTableForm);
} // setupUi
void retranslateUi(QDialog *deleteTableForm)
{
deleteTableForm->setWindowTitle(QApplication::translate("deleteTableForm", "Delete Table", 0, QApplication::UnicodeUTF8));
textLabel2->setText(QApplication::translate("deleteTableForm", "Table name:", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
comboOptions->setProperty("toolTip", QVariant(QApplication::translate("deleteTableForm", "Choose the table to delete", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
comboOptions->setProperty("whatsThis", QVariant(QApplication::translate("deleteTableForm", "Use this control to select the name of the table to be deleted", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
buttonDelete->setText(QApplication::translate("deleteTableForm", "Delete", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonDelete->setProperty("toolTip", QVariant(QApplication::translate("deleteTableForm", "Delete the selected table", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
buttonCancel->setText(QApplication::translate("deleteTableForm", "Cancel", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonCancel->setProperty("toolTip", QVariant(QApplication::translate("deleteTableForm", "Cancel and close dialog box", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
} // retranslateUi
};
namespace Ui {
class deleteTableForm: public Ui_deleteTableForm {};
} // namespace Ui
class deleteTableForm : public QDialog, public Ui::deleteTableForm
{
Q_OBJECT
public:
deleteTableForm(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
~deleteTableForm();
QString option;
public slots:
virtual void confirmDelete();
virtual void populateOptions( QStringList entries );
protected slots:
virtual void languageChange();
};
#endif // DELETETABLEFORM_H

View File

@@ -13,9 +13,7 @@
#include <QScrollBar>
#include "CreateIndexForm.h"
#include "DeleteIndexForm.h"
#include "DeleteTableForm.h"
#include "DialogAbout.h"
#include "ChooseTableForm.h"
#include "EditTableForm.h"
#include "EditFieldForm.h"
#include "ImportCSVForm.h"
@@ -55,10 +53,10 @@ void MainWindow::setupUi()
// Create popup menus
popupTableMenu = new QMenu(this);
popupTableMenu->addAction(ui->editModifyTableActionPopup);
popupTableMenu->addAction(ui->editModifyTableAction);
popupTableMenu->addAction(ui->editAddFieldActionPopup);
popupTableMenu->addSeparator();
popupTableMenu->addAction(ui->editDeleteTableActionPopup);
popupTableMenu->addAction(ui->editDeleteTableAction);
popupFieldMenu = new QMenu(this);
popupFieldMenu->addAction(ui->editModifyFieldActionPopup);
popupFieldMenu->addAction(ui->editDeleteFieldActionPopup);
@@ -653,62 +651,6 @@ void MainWindow::compact()
void MainWindow::deleteTable()
{
if (!db.isOpen()){
QMessageBox::information( this, QApplication::applicationName(), "There is no database opened." );
return;
}
deleteTableForm * tableForm = new deleteTableForm( this );
tableForm->setModal(true);
tableForm->populateOptions( db.getTableNames());
if ( tableForm->exec() ) {
QString statement = "DROP TABLE ";
statement.append(tableForm->option);
statement.append(";");
if (!db.executeSQL( statement)){
QString error = "Error: could not delete the table. Message from database engine: ";
error.append(db.lastErrorMessage);
QMessageBox::warning( this, QApplication::applicationName(), error );
} else {
populateStructure();
resetBrowser();
}
}
}
//*****************************************
//** Edit Table
void MainWindow::editTable()
{
if (!db.isOpen()){
QMessageBox::information( this, QApplication::applicationName(), "There is no database opened." );
return;
}
chooseTableForm * tableForm = new chooseTableForm( this );
tableForm->setModal(true);
QStringList tablelist = db.getTableNames();
if (tablelist.empty()){
QMessageBox::information( this, QApplication::applicationName(), "There are no tables to edit in this database." );
return;
}
tableForm->populateOptions( tablelist );
if ( tableForm->exec() ) {
//statement.append(tableForm->option);
editTableForm * edTableForm = new editTableForm( this );
edTableForm->setModal(true);
//send table name ? or handle it all from here?
edTableForm->setActiveTable(&db, tableForm->option);
edTableForm->exec();
//check modified status
if (edTableForm->modified)
{
populateStructure();
resetBrowser();
}
}
}
void MainWindow::deleteTablePopup()
{
// Get name of table to delete
QString table = ui->dbTreeWidget->currentItem()->text(0);
@@ -729,7 +671,7 @@ void MainWindow::deleteTablePopup()
}
}
void MainWindow::editTablePopup()
void MainWindow::editTable()
{
if (!db.isOpen()){
QMessageBox::information( this, QApplication::applicationName(), "There is no database opened." );
@@ -1215,8 +1157,8 @@ void MainWindow::on_tree_context_menu(const QPoint &qPoint){
QTreeWidgetItem *cItem = ui->dbTreeWidget->currentItem();
if(cItem->text(1) == "table"){
ui->editDeleteTableActionPopup->setDisabled(false);
ui->editModifyTableActionPopup->setDisabled(false);
ui->editDeleteTableAction->setDisabled(false);
ui->editModifyTableAction->setDisabled(false);
popupTableMenu->exec( ui->dbTreeWidget->mapToGlobal(qPoint) );
}else if(cItem->text(1) == "field"){
@@ -1226,8 +1168,8 @@ void MainWindow::on_tree_context_menu(const QPoint &qPoint){
//** Tree selection changed
void MainWindow::on_tree_selection_changed(){
if (!ui->dbTreeWidget->selectionModel()->hasSelection()){
ui->editDeleteTableActionPopup->setEnabled(false);
ui->editModifyTableActionPopup->setEnabled(false);
ui->editDeleteTableAction->setEnabled(false);
ui->editModifyTableAction->setEnabled(false);
ui->editAddFieldActionPopup->setEnabled(false);
ui->editModifyFieldActionPopup->setEnabled(false);
ui->editDeleteFieldActionPopup->setEnabled(false);
@@ -1235,16 +1177,16 @@ void MainWindow::on_tree_selection_changed(){
}
if(ui->dbTreeWidget->currentItem()->text(1) == "table"){
ui->editDeleteTableActionPopup->setEnabled(true);
ui->editModifyTableActionPopup->setEnabled(true);
ui->editDeleteTableAction->setEnabled(true);
ui->editModifyTableAction->setEnabled(true);
ui->editAddFieldActionPopup->setEnabled(true);
ui->editModifyFieldActionPopup->setEnabled(false);
ui->editDeleteFieldActionPopup->setEnabled(false);
}else if(ui->dbTreeWidget->currentItem()->text(1) == "field"){
ui->editAddFieldActionPopup->setEnabled(false);
ui->editDeleteTableActionPopup->setEnabled(false);
ui->editModifyTableActionPopup->setEnabled(false);
ui->editDeleteTableAction->setEnabled(false);
ui->editModifyTableAction->setEnabled(false);
ui->editModifyFieldActionPopup->setEnabled(true);
ui->editDeleteFieldActionPopup->setEnabled(true);
}
@@ -1363,8 +1305,6 @@ void MainWindow::activateFields(bool enable)
ui->fileCloseAction->setEnabled(enable);
ui->fileCompactAction->setEnabled(enable);
ui->editCreateTableAction->setEnabled(enable);
ui->editDeleteTableAction->setEnabled(enable);
ui->editModifyTableAction->setEnabled(enable);
ui->editCreateIndexAction->setEnabled(enable);
ui->editDeleteIndexAction->setEnabled(enable);
ui->buttonNext->setEnabled(enable);

View File

@@ -125,8 +125,6 @@ protected:
void resizeEvent(QResizeEvent *event);
protected slots:
virtual void deleteTablePopup();
virtual void editTablePopup();
virtual void mainTabSelected( int tabindex );
virtual void browseTableHeaderClicked(int logicalindex);

View File

@@ -31,8 +31,8 @@
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<addaction name="editCreateTableAction"/>
<addaction name="editModifyTableActionPopup"/>
<addaction name="editDeleteTableActionPopup"/>
<addaction name="editModifyTableAction"/>
<addaction name="editDeleteTableAction"/>
<addaction name="separator"/>
<addaction name="editAddFieldActionPopup"/>
<addaction name="editModifyFieldActionPopup"/>
@@ -805,36 +805,6 @@
<string>Delete Field</string>
</property>
</action>
<action name="editModifyTableActionPopup">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="icons/icons.qrc">
<normaloff>:/icons/table_modify</normaloff>:/icons/table_modify</iconset>
</property>
<property name="text">
<string>Modify Table</string>
</property>
<property name="toolTip">
<string>Modify Table</string>
</property>
</action>
<action name="editDeleteTableActionPopup">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="icons/icons.qrc">
<normaloff>:/icons/table_delete</normaloff>:/icons/table_delete</iconset>
</property>
<property name="text">
<string>Delete Table</string>
</property>
<property name="toolTip">
<string>Delete Table</string>
</property>
</action>
<action name="editModifyFieldActionPopup">
<property name="enabled">
<bool>false</bool>
@@ -1305,22 +1275,6 @@
</hint>
</hints>
</connection>
<connection>
<sender>editDeleteTableAction</sender>
<signal>activated()</signal>
<receiver>MainWindow</receiver>
<slot>createTable()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>editDeleteTableAction</sender>
<signal>activated()</signal>
@@ -1353,38 +1307,6 @@
</hint>
</hints>
</connection>
<connection>
<sender>editDeleteTableActionPopup</sender>
<signal>activated()</signal>
<receiver>MainWindow</receiver>
<slot>deleteTablePopup()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>editModifyTableActionPopup</sender>
<signal>activated()</signal>
<receiver>MainWindow</receiver>
<slot>editTablePopup()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>editAddFieldActionPopup</sender>
<signal>activated()</signal>

View File

@@ -16,10 +16,8 @@ HEADERS += \
sqlbrowser_util.h \
sqlite_source/sqlite3.h \
SQLLogDock.h \
ChooseTableForm.h \
CreateIndexForm.h \
DeleteIndexForm.h \
DeleteTableForm.h \
DialogAbout.h \
EditFieldForm.h \
EditForm.h \
@@ -37,10 +35,8 @@ SOURCES += \
sqlite_source/sqlite3.c \
SQLLogDock.cpp \
main.cpp \
ChooseTableForm.cpp \
CreateIndexForm.cpp \
DeleteIndexForm.cpp \
DeleteTableForm.cpp \
DialogAbout.cpp \
EditFieldForm.cpp \
EditForm.cpp \