From ab2a4e6479e790556b7b113e005db1c00be697a7 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Wed, 9 Jan 2013 16:25:45 +0100 Subject: [PATCH] Rewrite EditDialog using Qt Designer Create a Qt Designer form file for the edit dialog. Clean up the edit dialog code removing some not working and not used functionality e.g. for blob editing. --- src/EditDialog.cpp | 158 +++++++++++++++++++++++++ src/EditDialog.h | 46 ++++++++ src/EditDialog.ui | 218 ++++++++++++++++++++++++++++++++++ src/EditForm.cpp | 235 ------------------------------------- src/EditForm.h | 283 --------------------------------------------- src/MainWindow.cpp | 10 +- src/MainWindow.h | 6 +- src/src.pro | 11 +- 8 files changed, 434 insertions(+), 533 deletions(-) create mode 100644 src/EditDialog.cpp create mode 100644 src/EditDialog.h create mode 100644 src/EditDialog.ui delete mode 100644 src/EditForm.cpp delete mode 100644 src/EditForm.h diff --git a/src/EditDialog.cpp b/src/EditDialog.cpp new file mode 100644 index 00000000..b0c9b491 --- /dev/null +++ b/src/EditDialog.cpp @@ -0,0 +1,158 @@ +#include "EditDialog.h" +#include "ui_EditDialog.h" +#include +#include +#include +#include "sqlitedb.h" + +EditDialog::EditDialog(QWidget* parent) + : QDialog(parent), + ui(new Ui::EditDialog) +{ + ui->setupUi(this); + reset(); +} + +EditDialog::~EditDialog() +{ + delete ui; +} + +void EditDialog::reset() +{ + curRow = -1; + curCol = -1; + ui->editData->setPlainText(""); + ui->editData->setFocus(); + setDataType(kSQLiteMediaType_Void, 0); +} + +void EditDialog::enableExport(bool enabled) +{ + ui->buttonExport->setEnabled(enabled); +} + +void EditDialog::setDataType(int type, int size) +{ + dataType = type; + dataSize = size; + QString charstr; + switch(dataType) + { + case kSQLiteMediaType_String: + ui->labelType->setText(tr("Type of data currently in cell: Text / Numeric")); + if(ui->editData->toPlainText().length() == 1) charstr = QString("char"); else charstr = QString("chars"); + ui->labelSize->setText(QString("%1 %2").arg(ui->editData->toPlainText().length()).arg(charstr)); + enableExport(true); + break; + case kSQLiteMediaType_Void: + ui->labelType->setText("Type of data currently in cell: Empty"); + ui->labelSize->setText(""); + enableExport(false); + break; + } +} + +void EditDialog::closeEvent(QCloseEvent*) +{ + emit goingAway(); +} + +void EditDialog::loadText(QString text, int row, int col) +{ + ui->editData->setPlainText(text); + ui->editData->setFocus(); + ui->editData->selectAll(); + curRow = row; + curCol = col; + if(ui->editData->toPlainText().length() > 0) + setDataType(kSQLiteMediaType_String, 0); + else + setDataType(kSQLiteMediaType_Void, 0); +} + +void EditDialog::importData() +{ + int type = kSQLiteMediaType_Void; + QString fileName = QFileDialog::getOpenFileName( + this, + tr("Choose a file"), + defaultlocation, + QString("Text files(*.txt);;All files(*)")); + if(QFile::exists(fileName)) + { + type = kSQLiteMediaType_String; + QFile file(fileName); + if(file.open(QIODevice::ReadOnly)) + { + QTextStream stream(&file); + ui->editData->setPlainText(stream.readAll()); + file.close(); + } + setDataType(type, ui->editData->toPlainText().length()); + } +} + +void EditDialog::exportData() +{ + QString filter; + switch (dataType) + { + case kSQLiteMediaType_String: + filter = "Text files(*.txt)"; + break; + default: + return; + } + + QString fileName = QFileDialog::getSaveFileName( + this, + "Choose a filename to export data", + defaultlocation, + filter); + + if(fileName.size() > 0) + { + switch (dataType) + { + case kSQLiteMediaType_String: + { + QFile file(fileName); + if(file.open(QIODevice::WriteOnly)) + { + QTextStream stream(&file); + stream << ui->editData->toPlainText(); + file.close(); + } + } + break; + default: + return; + } + } +} + +void EditDialog::clearData() +{ + ui->editData->setPlainText(""); + setDataType(kSQLiteMediaType_Void, 0); +} + +void EditDialog::accept() +{ + if(dataType == kSQLiteMediaType_String) + emit updateRecordText(curRow, curCol, ui->editData->toPlainText()); + + if (dataType == kSQLiteMediaType_Void) + emit updateRecordText(curRow, curCol, QString("")); + + emit goingAway(); +} + +void EditDialog::editTextChanged() +{ + int newtype = kSQLiteMediaType_String; + if(ui->editData->toPlainText().length() == 0) + newtype = kSQLiteMediaType_Void; + setDataType(newtype, ui->editData->toPlainText().length()); +} diff --git a/src/EditDialog.h b/src/EditDialog.h new file mode 100644 index 00000000..33dc6d1e --- /dev/null +++ b/src/EditDialog.h @@ -0,0 +1,46 @@ +#ifndef __EDITDIALOG_H__ +#define __EDITDIALOG_H__ + +#include + +namespace Ui { +class EditDialog; +} + +class EditDialog : public QDialog +{ + Q_OBJECT + +public: + EditDialog(QWidget* parent = 0); + ~EditDialog(); + + int curCol; + int curRow; + QString defaultlocation; + +public slots: + virtual void reset(); + virtual void enableExport(bool enabled); + virtual void setDataType(int type, int size); + virtual void closeEvent(QCloseEvent*); + virtual void loadText(QString text, int row, int col); + virtual void importData(); + virtual void exportData(); + virtual void clearData(); + virtual void accept(); + virtual void editTextChanged(); + +signals: + void goingAway(); + void updateRecordText(int, int, QString); + +protected: + int dataType; + int dataSize; + +private: + Ui::EditDialog* ui; +}; + +#endif diff --git a/src/EditDialog.ui b/src/EditDialog.ui new file mode 100644 index 00000000..545df0bf --- /dev/null +++ b/src/EditDialog.ui @@ -0,0 +1,218 @@ + + + EditDialog + + + + 0 + 0 + 372 + 375 + + + + Edit database cell + + + + + + + + Import text + + + Opens a file dialog used to import text to this database cell. + + + &Import + + + + + + + Export text + + + Opens a file dialog used to export the contents of this database cell to a text file. + + + &Export + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Clear cell data + + + Erases the contents of the cell + + + &Clear + + + + + + + + + This area displays information about the data present in this database cell + + + + + + + Type of data currently in cell + + + + + + + Size of data currently in table + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + buttomImport + buttonExport + buttonClear + editData + buttonBox + + + + + buttonBox + accepted() + EditDialog + accept() + + + 262 + 370 + + + 157 + 274 + + + + + buttonBox + rejected() + EditDialog + reject() + + + 326 + 350 + + + 286 + 274 + + + + + buttomImport + clicked() + EditDialog + importData() + + + 41 + 16 + + + 60 + 0 + + + + + buttonExport + clicked() + EditDialog + exportData() + + + 100 + 20 + + + 162 + 17 + + + + + buttonClear + clicked() + EditDialog + clearData() + + + 321 + 13 + + + 290 + 12 + + + + + editData + textChanged() + EditDialog + editTextChanged() + + + 234 + 218 + + + 362 + 309 + + + + + + importData() + exportData() + clearData() + editTextChanged() + + diff --git a/src/EditForm.cpp b/src/EditForm.cpp deleted file mode 100644 index 77553eaf..00000000 --- a/src/EditForm.cpp +++ /dev/null @@ -1,235 +0,0 @@ -#include "EditForm.h" -#include -#include -#include -#include "sqlitedb.h" - -/* - * Constructs a editForm 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. - */ -editForm::editForm(QWidget* parent, Qt::WindowFlags fl) - : QDialog(parent, fl) -{ - setupUi(this); - - init(); -} - -/* - * Destroys the object and frees any allocated resources - */ -editForm::~editForm() -{ - destroy(); - // no need to delete child widgets, Qt does it all for us -} - -/* - * Sets the strings of the subwidgets using the current - * language. - */ -void editForm::languageChange() -{ - retranslateUi(this); -} - -void editForm::init() -{ - setModified(false); - dataType = kSQLiteMediaType_Void; - dataSize = 0; - dataDepth = 0; - curRow = -1; - curCol = -1; - textEditor->setPlainText(""); - textEditor->setFocus(); - setDataType(kSQLiteMediaType_Void, 0); -} - -void editForm::destroy() -{ - -} - -void editForm::reset() -{ - init(); -} - -void editForm::setModified(bool modifiedstate) -{ - modified = modifiedstate; - saveChangesButton->setEnabled(modified); -} - -void editForm::enableExport(bool enabled) -{ - exportButton->setEnabled(enabled); -} - -void editForm::enableTextEditor(bool enabled) -{ - textEditor->setReadOnly(!enabled); -} - -void editForm::setTextFormat(QString format) -{ -// if (format=="Auto") -// { -// textEditor->setTextFormat(Qt::AutoText); -// } else { -// textEditor->setTextFormat(Qt::PlainText); -// } -} - -void editForm::setDataType(int type, int size) -{ - dataType = type; - dataSize = size; - QString charstr; - switch (dataType ) { - case kSQLiteMediaType_String: - currentTypeLabel->setText("Type of data currently in cell: Text / Numeric"); - if (textEditor->toPlainText().length()>1) charstr = QString("chars"); else charstr = QString("char"); - currentDataInfo->setText(QString("%1 %2").arg(textEditor->toPlainText().length()).arg(charstr)); - editWidgetStack->setCurrentIndex(0); - enableExport(true); - enableTextEditor(true); - break; - case kSQLiteMediaType_Void: - currentTypeLabel->setText("Type of data currently in cell: Empty"); - currentDataInfo->setText(""); - editWidgetStack->setCurrentIndex(0); - enableExport(false); - enableTextEditor(true); - break; - } -} - -void editForm::closeEvent( QCloseEvent * ) -{ - emit goingAway(); -} - -void editForm::loadText(QString text, int row, int col) -{ - textEditor->setPlainText(text); - textEditor->setFocus(); - textEditor->selectAll(); - curRow = row; - curCol = col; - if (textEditor->toPlainText().length() > 0) - { - setDataType(kSQLiteMediaType_String, 0); -} else { - setDataType(kSQLiteMediaType_Void, 0); -} - setModified(false); -} - - -void editForm::importData() -{ - int type = kSQLiteMediaType_Void; - QString fileName = QFileDialog::getOpenFileName( - this, - "Choose an image file", - QString(), - QString( "Text files (*.txt);;All files (*.*);;")); - if (QFile::exists(fileName) ) - { - type = kSQLiteMediaType_String; - - QFile file( fileName ); - if ( file.open( QIODevice::ReadOnly ) ) { - QTextStream stream( &file ); - textEditor->setPlainText(stream.readAll()); - file.close(); - } - - setModified(true); - } -} - - -void editForm::exportData() -{ - QString filter; - switch (dataType) - { - case kSQLiteMediaType_String: - filter = "Text files (*.txt)"; - break; - - default: - return; - } - - - QString fileName = QFileDialog::getSaveFileName( - this, - "Choose a filename to export data", - defaultlocation, - filter); - - if (fileName.size() > 0) - { - switch (dataType) - { - case kSQLiteMediaType_String: - { - QFile file(fileName); - if ( file.open( QIODevice::WriteOnly ) ) { - QTextStream stream( &file ); - stream << textEditor->toPlainText(); - file.close(); - } - } - break; - - default: - return; - } - } -} - - -void editForm::clearData() -{ - textEditor->setPlainText(""); - setDataType(kSQLiteMediaType_Void, 0); - setModified(true); -} - - -void editForm::saveChanges() -{ - if (dataType==kSQLiteMediaType_String) - emit updateRecordText(curRow, curCol, textEditor->toPlainText()); - - if (dataType==kSQLiteMediaType_Void) - emit updateRecordText(curRow, curCol, QString("")); - - setModified(false); - emit goingAway(); -} - - - -void editForm::editTextChanged() -{ - int newtype = kSQLiteMediaType_String; - if (textEditor->toPlainText().length() == 0) - { - newtype = kSQLiteMediaType_Void; - } - if (newtype!=dataType) - { - setDataType(newtype, 0); -} - setModified(true); -} diff --git a/src/EditForm.h b/src/EditForm.h deleted file mode 100644 index 89a755ba..00000000 --- a/src/EditForm.h +++ /dev/null @@ -1,283 +0,0 @@ -#ifndef EDITFORM_H -#define EDITFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class Ui_editForm -{ -public: - QVBoxLayout *vboxLayout; - QHBoxLayout *hboxLayout; - QToolButton *importButton; - QToolButton *exportButton; - QSpacerItem *spacer11_2; - QToolButton *clearButton; - QStackedWidget *editWidgetStack; - QWidget *WStackPage; - QGridLayout *gridLayout; - QTextEdit *textEditor; - QWidget *WStackPage1; - QGridLayout *gridLayout1; - QLabel *editPixmap; - QFrame *frame9; - QVBoxLayout *vboxLayout1; - QLabel *currentTypeLabel; - QLabel *currentDataInfo; - QHBoxLayout *hboxLayout1; - QSpacerItem *spacer11; - QPushButton *closeButton; - QPushButton *saveChangesButton; - - void setupUi(QDialog *editForm) - { - if (editForm->objectName().isEmpty()) - editForm->setObjectName(QString::fromUtf8("editForm")); - editForm->resize(366, 431); - editForm->setModal(true); - vboxLayout = new QVBoxLayout(editForm); - 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")); - importButton = new QToolButton(editForm); - importButton->setObjectName(QString::fromUtf8("importButton")); - QSizePolicy sizePolicy(static_cast(1), static_cast(0)); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - sizePolicy.setHeightForWidth(importButton->sizePolicy().hasHeightForWidth()); - importButton->setSizePolicy(sizePolicy); - - hboxLayout->addWidget(importButton); - - exportButton = new QToolButton(editForm); - exportButton->setObjectName(QString::fromUtf8("exportButton")); - sizePolicy.setHeightForWidth(exportButton->sizePolicy().hasHeightForWidth()); - exportButton->setSizePolicy(sizePolicy); - - hboxLayout->addWidget(exportButton); - - spacer11_2 = new QSpacerItem(81, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - hboxLayout->addItem(spacer11_2); - - clearButton = new QToolButton(editForm); - clearButton->setObjectName(QString::fromUtf8("clearButton")); - sizePolicy.setHeightForWidth(clearButton->sizePolicy().hasHeightForWidth()); - clearButton->setSizePolicy(sizePolicy); - - hboxLayout->addWidget(clearButton); - - - vboxLayout->addLayout(hboxLayout); - - editWidgetStack = new QStackedWidget(editForm); - editWidgetStack->setObjectName(QString::fromUtf8("editWidgetStack")); - WStackPage = new QWidget(editWidgetStack); - WStackPage->setObjectName(QString::fromUtf8("WStackPage")); - gridLayout = new QGridLayout(WStackPage); - gridLayout->setSpacing(6); - gridLayout->setContentsMargins(11, 11, 11, 11); - gridLayout->setObjectName(QString::fromUtf8("gridLayout")); - gridLayout->setContentsMargins(0, 0, 0, 0); - textEditor = new QTextEdit(WStackPage); - textEditor->setObjectName(QString::fromUtf8("textEditor")); - - gridLayout->addWidget(textEditor, 0, 0, 1, 1); - - editWidgetStack->addWidget(WStackPage); - WStackPage1 = new QWidget(editWidgetStack); - WStackPage1->setObjectName(QString::fromUtf8("WStackPage1")); - gridLayout1 = new QGridLayout(WStackPage1); - gridLayout1->setSpacing(6); - gridLayout1->setContentsMargins(11, 11, 11, 11); - gridLayout1->setObjectName(QString::fromUtf8("gridLayout1")); - gridLayout1->setContentsMargins(0, 0, 0, 0); - editPixmap = new QLabel(WStackPage1); - editPixmap->setObjectName(QString::fromUtf8("editPixmap")); - editPixmap->setMaximumSize(QSize(320, 240)); - editPixmap->setScaledContents(true); - editPixmap->setAlignment(Qt::AlignCenter); - editPixmap->setWordWrap(false); - - gridLayout1->addWidget(editPixmap, 0, 0, 1, 1); - - editWidgetStack->addWidget(WStackPage1); - - vboxLayout->addWidget(editWidgetStack); - - frame9 = new QFrame(editForm); - frame9->setObjectName(QString::fromUtf8("frame9")); - frame9->setFrameShape(QFrame::Box); - frame9->setFrameShadow(QFrame::Sunken); - vboxLayout1 = new QVBoxLayout(frame9); - vboxLayout1->setSpacing(6); - vboxLayout1->setMargin(11); - vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1")); - currentTypeLabel = new QLabel(frame9); - currentTypeLabel->setObjectName(QString::fromUtf8("currentTypeLabel")); - currentTypeLabel->setAlignment(Qt::AlignVCenter|Qt::AlignLeft); - currentTypeLabel->setWordWrap(false); - - vboxLayout1->addWidget(currentTypeLabel); - - currentDataInfo = new QLabel(frame9); - currentDataInfo->setObjectName(QString::fromUtf8("currentDataInfo")); - currentDataInfo->setAlignment(Qt::AlignVCenter|Qt::AlignLeft); - currentDataInfo->setWordWrap(true); - - vboxLayout1->addWidget(currentDataInfo); - - - vboxLayout->addWidget(frame9); - - hboxLayout1 = new QHBoxLayout(); - hboxLayout1->setSpacing(6); - hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1")); - spacer11 = new QSpacerItem(90, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - hboxLayout1->addItem(spacer11); - - closeButton = new QPushButton(editForm); - closeButton->setObjectName(QString::fromUtf8("closeButton")); - closeButton->setDefault(true); - - hboxLayout1->addWidget(closeButton); - - saveChangesButton = new QPushButton(editForm); - saveChangesButton->setObjectName(QString::fromUtf8("saveChangesButton")); - saveChangesButton->setEnabled(false); - saveChangesButton->setDefault(false); - - hboxLayout1->addWidget(saveChangesButton); - - - vboxLayout->addLayout(hboxLayout1); - - - retranslateUi(editForm); - QObject::connect(importButton, SIGNAL(clicked()), editForm, SLOT(importData())); - QObject::connect(exportButton, SIGNAL(clicked()), editForm, SLOT(exportData())); - QObject::connect(saveChangesButton, SIGNAL(clicked()), editForm, SLOT(saveChanges())); - QObject::connect(clearButton, SIGNAL(clicked()), editForm, SLOT(clearData())); - QObject::connect(textEditor, SIGNAL(textChanged()), editForm, SLOT(editTextChanged())); - QObject::connect(closeButton, SIGNAL(clicked()), editForm, SLOT(close())); - - QMetaObject::connectSlotsByName(editForm); - } // setupUi - - void retranslateUi(QDialog *editForm) - { - editForm->setWindowTitle(QApplication::translate("editForm", "Edit database cell", 0, QApplication::UnicodeUTF8)); - importButton->setText(QApplication::translate("editForm", "Import", 0, QApplication::UnicodeUTF8)); -#ifndef QT_NO_TOOLTIP - importButton->setProperty("toolTip", QVariant(QApplication::translate("editForm", "Import text", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS - importButton->setProperty("whatsThis", QVariant(QApplication::translate("editForm", "Opens a file dialog used to import text to this database cell.", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_WHATSTHIS - exportButton->setText(QApplication::translate("editForm", "Export", 0, QApplication::UnicodeUTF8)); -#ifndef QT_NO_TOOLTIP - exportButton->setProperty("toolTip", QVariant(QApplication::translate("editForm", "Export text", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS - exportButton->setProperty("whatsThis", QVariant(QApplication::translate("editForm", "Opens a file dialog used to export the contents of this database cell to a text file.", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_WHATSTHIS - clearButton->setText(QApplication::translate("editForm", "Clear", 0, QApplication::UnicodeUTF8)); -#ifndef QT_NO_TOOLTIP - clearButton->setProperty("toolTip", QVariant(QApplication::translate("editForm", "Clear cell data", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS - clearButton->setProperty("whatsThis", QVariant(QApplication::translate("editForm", "Erases the contents of the cell", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_WHATSTHIS -#ifndef QT_NO_TOOLTIP - frame9->setProperty("toolTip", QVariant(QString())); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS - frame9->setProperty("whatsThis", QVariant(QApplication::translate("editForm", "This area displays information about the data present in this database cell", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_WHATSTHIS - currentTypeLabel->setText(QApplication::translate("editForm", "Type of data currently in cell: Empty", 0, QApplication::UnicodeUTF8)); - currentDataInfo->setText(QApplication::translate("editForm", "Data information", 0, QApplication::UnicodeUTF8)); - closeButton->setText(QApplication::translate("editForm", "Close", 0, QApplication::UnicodeUTF8)); -#ifndef QT_NO_TOOLTIP - closeButton->setProperty("toolTip", QVariant(QApplication::translate("editForm", "Close", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS - closeButton->setProperty("whatsThis", QVariant(QApplication::translate("editForm", "Close the window without saving changes", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_WHATSTHIS - saveChangesButton->setText(QApplication::translate("editForm", "Apply Changes", 0, QApplication::UnicodeUTF8)); -#ifndef QT_NO_TOOLTIP - saveChangesButton->setProperty("toolTip", QVariant(QApplication::translate("editForm", "Save changes to database", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS - saveChangesButton->setProperty("whatsThis", QVariant(QApplication::translate("editForm", "Close this window saving changes to the database", 0, QApplication::UnicodeUTF8))); -#endif // QT_NO_WHATSTHIS - } // retranslateUi - -}; - -namespace Ui { - class editForm: public Ui_editForm {}; -} // namespace Ui - -class editForm : public QDialog, public Ui::editForm -{ - Q_OBJECT - -public: - editForm(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window); - ~editForm(); - - int curCol; - int curRow; - QString defaultlocation; - -public slots: - virtual void reset(); - virtual void setModified( bool modifiedstate ); - virtual void enableExport( bool enabled ); - virtual void enableTextEditor( bool enabled ); - virtual void setTextFormat( QString format ); - virtual void setDataType( int type, int size ); - virtual void closeEvent( QCloseEvent * ); - virtual void loadText( QString text, int row, int col ); - virtual void importData(); - virtual void exportData(); - virtual void clearData(); - virtual void saveChanges(); - virtual void editTextChanged(); - -signals: - void goingAway(); - void updateRecordText(int, int, QString); - void updateRecordBinary(int, int, unsigned char *); - -protected: - bool modified; - int dataType; - int dataSize; - int dataDepth; - -protected slots: - virtual void languageChange(); - -private: - void init(); - void destroy(); - -}; - -#endif // EDITFORM_H diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index ec0e39e4..3addbc07 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -18,7 +18,7 @@ #include "ImportCSVForm.h" #include "ExportTableCSVForm.h" #include "PreferencesDialog.h" -#include "EditForm.h" +#include "EditDialog.h" #include "FindDialog.h" #include "SQLLogDock.h" #include "SQLiteSyntaxHighlighter.h" @@ -26,7 +26,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow), - editWin(new editForm(this)), + editWin(new EditDialog(this)), clipboard(QApplication::clipboard()), findWin(0) { @@ -39,9 +39,6 @@ MainWindow::MainWindow(QWidget* parent) updateRecentFileActions(); } -/* - * Destroys the object and frees any allocated resources - */ MainWindow::~MainWindow() { delete gotoValidator; @@ -719,7 +716,7 @@ void MainWindow::editText(int row, int col) QString cv = rt[col+1];//must account for rowid editWin->loadText(cv , row, col); - editWin ->show(); + editWin->show(); } void MainWindow::doubleClickTable( int row, int col ) @@ -1029,7 +1026,6 @@ void MainWindow::updatePreferences() db.setDefaultNewData(prefs.defaultnewdata); defaultlocation= prefs.defaultlocation; editWin->defaultlocation = defaultlocation; - editWin->setTextFormat(prefs.defaulttext); } //****************************************************************** diff --git a/src/MainWindow.h b/src/MainWindow.h index 1e5c3010..c4c74811 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -9,7 +9,7 @@ class QDragEnterEvent; class SQLLogDock; -class editForm; +class EditDialog; class FindDialog; class SQLiteSyntaxHighlighter; class QStandardItemModel; @@ -45,8 +45,8 @@ public: MainWindow(QWidget* parent = 0); ~MainWindow(); - editForm * editWin; - QClipboard * clipboard; + EditDialog* editWin; + QClipboard* clipboard; FindDialog* findWin; QIntValidator * gotoValidator; QString defaultlocation; diff --git a/src/src.pro b/src/src.pro index 3792f709..2528e713 100644 --- a/src/src.pro +++ b/src/src.pro @@ -14,7 +14,6 @@ HEADERS += \ sqlitedb.h \ sqlbrowser_util.h \ SQLLogDock.h \ - EditForm.h \ ExportTableCSVForm.h \ ImportCSVForm.h \ MainWindow.h \ @@ -24,14 +23,14 @@ HEADERS += \ AboutDialog.h \ EditTableDialog.h \ PreferencesDialog.h \ - FindDialog.h + FindDialog.h \ + EditDialog.h SOURCES += \ sqlitedb.cpp \ sqlbrowser_util.c \ SQLLogDock.cpp \ main.cpp \ - EditForm.cpp \ ExportTableCSVForm.cpp \ ImportCSVForm.cpp \ MainWindow.cpp \ @@ -41,7 +40,8 @@ SOURCES += \ EditTableDialog.cpp \ PreferencesDialog.cpp \ AboutDialog.cpp \ - FindDialog.cpp + FindDialog.cpp \ + EditDialog.cpp QMAKE_CXXFLAGS += -DAPP_VERSION=\\\"`cd $$PWD;git log -n1 --format=%h_git`\\\" @@ -69,4 +69,5 @@ FORMS += \ EditFieldDialog.ui \ EditTableDialog.ui \ PreferencesDialog.ui \ - FindDialog.ui + FindDialog.ui \ + EditDialog.ui