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.
This commit is contained in:
Martin Kleusberg
2013-01-09 16:25:45 +01:00
parent 065cb3682a
commit ab2a4e6479
8 changed files with 434 additions and 533 deletions

158
src/EditDialog.cpp Normal file
View File

@@ -0,0 +1,158 @@
#include "EditDialog.h"
#include "ui_EditDialog.h"
#include <QTextStream>
#include <QMessageBox>
#include <QFileDialog>
#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());
}

46
src/EditDialog.h Normal file
View File

@@ -0,0 +1,46 @@
#ifndef __EDITDIALOG_H__
#define __EDITDIALOG_H__
#include <QDialog>
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

218
src/EditDialog.ui Normal file
View File

@@ -0,0 +1,218 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditDialog</class>
<widget class="QDialog" name="EditDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>372</width>
<height>375</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit database cell</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="buttomImport">
<property name="toolTip">
<string>Import text</string>
</property>
<property name="whatsThis">
<string>Opens a file dialog used to import text to this database cell.</string>
</property>
<property name="text">
<string>&amp;Import</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonExport">
<property name="toolTip">
<string>Export text</string>
</property>
<property name="whatsThis">
<string>Opens a file dialog used to export the contents of this database cell to a text file.</string>
</property>
<property name="text">
<string>&amp;Export</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonClear">
<property name="toolTip">
<string>Clear cell data</string>
</property>
<property name="whatsThis">
<string>Erases the contents of the cell</string>
</property>
<property name="text">
<string>&amp;Clear</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="editData">
<property name="whatsThis">
<string>This area displays information about the data present in this database cell</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelType">
<property name="text">
<string>Type of data currently in cell</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelSize">
<property name="text">
<string>Size of data currently in table</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>buttomImport</tabstop>
<tabstop>buttonExport</tabstop>
<tabstop>buttonClear</tabstop>
<tabstop>editData</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>EditDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>262</x>
<y>370</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>EditDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>326</x>
<y>350</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttomImport</sender>
<signal>clicked()</signal>
<receiver>EditDialog</receiver>
<slot>importData()</slot>
<hints>
<hint type="sourcelabel">
<x>41</x>
<y>16</y>
</hint>
<hint type="destinationlabel">
<x>60</x>
<y>0</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonExport</sender>
<signal>clicked()</signal>
<receiver>EditDialog</receiver>
<slot>exportData()</slot>
<hints>
<hint type="sourcelabel">
<x>100</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>162</x>
<y>17</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonClear</sender>
<signal>clicked()</signal>
<receiver>EditDialog</receiver>
<slot>clearData()</slot>
<hints>
<hint type="sourcelabel">
<x>321</x>
<y>13</y>
</hint>
<hint type="destinationlabel">
<x>290</x>
<y>12</y>
</hint>
</hints>
</connection>
<connection>
<sender>editData</sender>
<signal>textChanged()</signal>
<receiver>EditDialog</receiver>
<slot>editTextChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>234</x>
<y>218</y>
</hint>
<hint type="destinationlabel">
<x>362</x>
<y>309</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>importData()</slot>
<slot>exportData()</slot>
<slot>clearData()</slot>
<slot>editTextChanged()</slot>
</slots>
</ui>

View File

@@ -1,235 +0,0 @@
#include "EditForm.h"
#include <QTextStream>
#include <QMessageBox>
#include <QFileDialog>
#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);
}

View File

@@ -1,283 +0,0 @@
#ifndef EDITFORM_H
#define EDITFORM_H
#include <QFrame>
#include <QTextEdit>
#include <QtGui/QDialog>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QToolButton>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
#include <QtGui/QApplication>
#include <QtGui/QStackedWidget>
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<QSizePolicy::Policy>(1), static_cast<QSizePolicy::Policy>(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

View File

@@ -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);
}
//******************************************************************

View File

@@ -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;

View File

@@ -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