Convert no longer supported Qt3 .ui files and merge ui.h contents. This makes it easier to debug in QtCreator, but we loose Designer support

This commit is contained in:
tabuleiro
2009-09-17 19:39:52 +00:00
parent 55842bee06
commit c4ff08ab72
50 changed files with 6230 additions and 1516 deletions
+45
View File
@@ -0,0 +1,45 @@
#include "aboutform.h"
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.h>
#include "sqlitedb.h"
/*
* Constructs a aboutForm 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.
*/
aboutForm::aboutForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
init();
}
/*
* Destroys the object and frees any allocated resources
*/
aboutForm::~aboutForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void aboutForm::languageChange()
{
retranslateUi(this);
}
void aboutForm::init()
{
this->setCaption(applicationName);
//aboutBrowser->setText(aboutText);
}
+112
View File
@@ -0,0 +1,112 @@
#ifndef ABOUTFORM_H
#define ABOUTFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
QT_BEGIN_NAMESPACE
class Ui_aboutForm
{
public:
QVBoxLayout *vboxLayout;
QLabel *textLabel1;
QHBoxLayout *hboxLayout;
QSpacerItem *spacer5;
QPushButton *okButton;
void setupUi(QDialog *aboutForm)
{
if (aboutForm->objectName().isEmpty())
aboutForm->setObjectName(QString::fromUtf8("aboutForm"));
aboutForm->resize(514, 191);
vboxLayout = new QVBoxLayout(aboutForm);
vboxLayout->setSpacing(6);
vboxLayout->setMargin(11);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
textLabel1 = new QLabel(aboutForm);
textLabel1->setObjectName(QString::fromUtf8("textLabel1"));
QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(7), static_cast<QSizePolicy::Policy>(7));
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(textLabel1->sizePolicy().hasHeightForWidth());
textLabel1->setSizePolicy(sizePolicy);
textLabel1->setAlignment(Qt::AlignVCenter);
textLabel1->setWordWrap(true);
vboxLayout->addWidget(textLabel1);
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
spacer5 = new QSpacerItem(141, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacer5);
okButton = new QPushButton(aboutForm);
okButton->setObjectName(QString::fromUtf8("okButton"));
okButton->setDefault(true);
hboxLayout->addWidget(okButton);
vboxLayout->addLayout(hboxLayout);
retranslateUi(aboutForm);
QObject::connect(okButton, SIGNAL(clicked()), aboutForm, SLOT(close()));
QMetaObject::connectSlotsByName(aboutForm);
} // setupUi
void retranslateUi(QDialog *aboutForm)
{
aboutForm->setWindowTitle(QApplication::translate("aboutForm", "About", 0, QApplication::UnicodeUTF8));
textLabel1->setText(QApplication::translate("aboutForm", "Version 1.3\n"
"\n"
"SQLite Database Browser is an open source, public domain, freeware visual tool used to create, design and edit SQLite 3.x database files.\n"
"This program was built with version 3.3.5 of the SQLite engine.\n"
"\n"
"More information at http://sqlitebrowser.sourceforge.net.", 0, QApplication::UnicodeUTF8));
okButton->setText(QApplication::translate("aboutForm", "Close", 0, QApplication::UnicodeUTF8));
Q_UNUSED(aboutForm);
} // retranslateUi
};
namespace Ui {
class aboutForm: public Ui_aboutForm {};
} // namespace Ui
QT_END_NAMESPACE
class aboutForm : public QDialog, public Ui::aboutForm
{
Q_OBJECT
public:
aboutForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~aboutForm();
protected slots:
virtual void languageChange();
private:
void init();
};
#endif // ABOUTFORM_H
@@ -1,14 +0,0 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void aboutForm::init()
{
this->setCaption(applicationName);
//aboutBrowser->setText(aboutText);
}
@@ -1,11 +1,43 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
#include "addfieldform.h"
#include <qvariant.h>
#include <qmessagebox.h>
#include <qimage.h>
#include <qpixmap.h>
#include "sqlitedb.h"
#include "addfieldtypeform.h"
/*
* Constructs a addFieldForm 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.
*/
addFieldForm::addFieldForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
addFieldForm::~addFieldForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void addFieldForm::languageChange()
{
retranslateUi(this);
}
void addFieldForm::setInitialValues(QString name, QString type)
{
nameLineEdit->setText(name);
+190
View File
@@ -0,0 +1,190 @@
#ifndef ADDFIELDFORM_H
#define ADDFIELDFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QToolButton>
#include <QtGui/QVBoxLayout>
QT_BEGIN_NAMESPACE
class Ui_addFieldForm
{
public:
QGridLayout *gridLayout;
QSpacerItem *spacer17;
QHBoxLayout *hboxLayout;
QSpacerItem *spacer15;
QPushButton *cancelButton;
QPushButton *createButton;
QVBoxLayout *vboxLayout;
QLabel *textLabel1;
QLabel *textLabel2;
QVBoxLayout *vboxLayout1;
QLineEdit *nameLineEdit;
QHBoxLayout *hboxLayout1;
QComboBox *typeBox;
QToolButton *typeButton;
void setupUi(QDialog *addFieldForm)
{
if (addFieldForm->objectName().isEmpty())
addFieldForm->setObjectName(QString::fromUtf8("addFieldForm"));
addFieldForm->resize(338, 136);
gridLayout = new QGridLayout(addFieldForm);
gridLayout->setSpacing(6);
gridLayout->setMargin(11);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
spacer17 = new QSpacerItem(20, 16, QSizePolicy::Minimum, QSizePolicy::Expanding);
gridLayout->addItem(spacer17, 1, 1, 1, 1);
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
spacer15 = new QSpacerItem(41, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacer15);
cancelButton = new QPushButton(addFieldForm);
cancelButton->setObjectName(QString::fromUtf8("cancelButton"));
hboxLayout->addWidget(cancelButton);
createButton = new QPushButton(addFieldForm);
createButton->setObjectName(QString::fromUtf8("createButton"));
createButton->setDefault(true);
hboxLayout->addWidget(createButton);
gridLayout->addLayout(hboxLayout, 2, 0, 1, 2);
vboxLayout = new QVBoxLayout();
vboxLayout->setSpacing(6);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
textLabel1 = new QLabel(addFieldForm);
textLabel1->setObjectName(QString::fromUtf8("textLabel1"));
textLabel1->setWordWrap(false);
vboxLayout->addWidget(textLabel1);
textLabel2 = new QLabel(addFieldForm);
textLabel2->setObjectName(QString::fromUtf8("textLabel2"));
textLabel2->setWordWrap(false);
vboxLayout->addWidget(textLabel2);
gridLayout->addLayout(vboxLayout, 0, 0, 1, 1);
vboxLayout1 = new QVBoxLayout();
vboxLayout1->setSpacing(6);
vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1"));
nameLineEdit = new QLineEdit(addFieldForm);
nameLineEdit->setObjectName(QString::fromUtf8("nameLineEdit"));
vboxLayout1->addWidget(nameLineEdit);
hboxLayout1 = new QHBoxLayout();
hboxLayout1->setSpacing(6);
hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
typeBox = new QComboBox(addFieldForm);
typeBox->setObjectName(QString::fromUtf8("typeBox"));
hboxLayout1->addWidget(typeBox);
typeButton = new QToolButton(addFieldForm);
typeButton->setObjectName(QString::fromUtf8("typeButton"));
QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(0), static_cast<QSizePolicy::Policy>(0));
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(typeButton->sizePolicy().hasHeightForWidth());
typeButton->setSizePolicy(sizePolicy);
hboxLayout1->addWidget(typeButton);
vboxLayout1->addLayout(hboxLayout1);
gridLayout->addLayout(vboxLayout1, 0, 1, 1, 1);
retranslateUi(addFieldForm);
QObject::connect(cancelButton, SIGNAL(clicked()), addFieldForm, SLOT(reject()));
QObject::connect(createButton, SIGNAL(clicked()), addFieldForm, SLOT(confirmAddField()));
QObject::connect(typeButton, SIGNAL(clicked()), addFieldForm, SLOT(getCustomType()));
QMetaObject::connectSlotsByName(addFieldForm);
} // setupUi
void retranslateUi(QDialog *addFieldForm)
{
addFieldForm->setWindowTitle(QApplication::translate("addFieldForm", "Add database field", 0, QApplication::UnicodeUTF8));
cancelButton->setText(QApplication::translate("addFieldForm", "Cancel", 0, QApplication::UnicodeUTF8));
createButton->setText(QApplication::translate("addFieldForm", "Create", 0, QApplication::UnicodeUTF8));
textLabel1->setText(QApplication::translate("addFieldForm", "Field name:", 0, QApplication::UnicodeUTF8));
textLabel2->setText(QApplication::translate("addFieldForm", "Field type:", 0, QApplication::UnicodeUTF8));
typeBox->clear();
typeBox->insertItems(0, QStringList()
<< QString()
<< QApplication::translate("addFieldForm", "text", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("addFieldForm", "integer", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("addFieldForm", "blob", 0, QApplication::UnicodeUTF8)
);
typeButton->setText(QApplication::translate("addFieldForm", "...", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
typeButton->setProperty("toolTip", QVariant(QApplication::translate("addFieldForm", "Custom type", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
typeButton->setProperty("whatsThis", QVariant(QApplication::translate("addFieldForm", "Click this button to enter a new type for the field", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
Q_UNUSED(addFieldForm);
} // retranslateUi
};
namespace Ui {
class addFieldForm: public Ui_addFieldForm {};
} // namespace Ui
QT_END_NAMESPACE
class addFieldForm : public QDialog, public Ui::addFieldForm
{
Q_OBJECT
public:
addFieldForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~addFieldForm();
QString fname;
QString ftype;
public slots:
virtual void setInitialValues( QString name, QString type );
virtual void confirmAddField();
virtual void getCustomType();
protected slots:
virtual void languageChange();
};
#endif // ADDFIELDFORM_H
@@ -0,0 +1,39 @@
#include "addfieldtypeform.h"
#include <qvariant.h>
#include <qmessagebox.h>
#include <qimage.h>
#include <qpixmap.h>
#include "sqlitedb.h"
/*
* Constructs a addFieldTypeForm 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.
*/
addFieldTypeForm::addFieldTypeForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
addFieldTypeForm::~addFieldTypeForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void addFieldTypeForm::languageChange()
{
retranslateUi(this);
}
@@ -0,0 +1,104 @@
#ifndef ADDFIELDTYPEFORM_H
#define ADDFIELDTYPEFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
QT_BEGIN_NAMESPACE
class Ui_addFieldTypeForm
{
public:
QGridLayout *gridLayout;
QLineEdit *typeNameEdit;
QHBoxLayout *hboxLayout;
QSpacerItem *spacer5;
QPushButton *cancelButton;
QPushButton *okButton;
void setupUi(QDialog *addFieldTypeForm)
{
if (addFieldTypeForm->objectName().isEmpty())
addFieldTypeForm->setObjectName(QString::fromUtf8("addFieldTypeForm"));
addFieldTypeForm->resize(294, 98);
gridLayout = new QGridLayout(addFieldTypeForm);
gridLayout->setSpacing(6);
gridLayout->setMargin(11);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
typeNameEdit = new QLineEdit(addFieldTypeForm);
typeNameEdit->setObjectName(QString::fromUtf8("typeNameEdit"));
gridLayout->addWidget(typeNameEdit, 0, 0, 1, 1);
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
spacer5 = new QSpacerItem(31, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacer5);
cancelButton = new QPushButton(addFieldTypeForm);
cancelButton->setObjectName(QString::fromUtf8("cancelButton"));
hboxLayout->addWidget(cancelButton);
okButton = new QPushButton(addFieldTypeForm);
okButton->setObjectName(QString::fromUtf8("okButton"));
okButton->setDefault(true);
hboxLayout->addWidget(okButton);
gridLayout->addLayout(hboxLayout, 1, 0, 1, 1);
retranslateUi(addFieldTypeForm);
QObject::connect(okButton, SIGNAL(clicked()), addFieldTypeForm, SLOT(accept()));
QObject::connect(cancelButton, SIGNAL(clicked()), addFieldTypeForm, SLOT(reject()));
QMetaObject::connectSlotsByName(addFieldTypeForm);
} // setupUi
void retranslateUi(QDialog *addFieldTypeForm)
{
addFieldTypeForm->setWindowTitle(QApplication::translate("addFieldTypeForm", "Enter field type", 0, QApplication::UnicodeUTF8));
cancelButton->setText(QApplication::translate("addFieldTypeForm", "Cancel", 0, QApplication::UnicodeUTF8));
okButton->setText(QApplication::translate("addFieldTypeForm", "OK", 0, QApplication::UnicodeUTF8));
Q_UNUSED(addFieldTypeForm);
} // retranslateUi
};
namespace Ui {
class addFieldTypeForm: public Ui_addFieldTypeForm {};
} // namespace Ui
QT_END_NAMESPACE
class addFieldTypeForm : public QDialog, public Ui::addFieldTypeForm
{
Q_OBJECT
public:
addFieldTypeForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~addFieldTypeForm();
protected slots:
virtual void languageChange();
};
#endif // ADDFIELDTYPEFORM_H
@@ -0,0 +1,51 @@
#include "choosetableform.h"
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.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, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, 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();
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
comboOptions->insertItem(*ct,-1);
}
}
@@ -0,0 +1,143 @@
#ifndef CHOOSETABLEFORM_H
#define CHOOSETABLEFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
QT_BEGIN_NAMESPACE
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->setMargin(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
Q_UNUSED(chooseTableForm);
} // retranslateUi
};
namespace Ui {
class chooseTableForm: public Ui_chooseTableForm {};
} // namespace Ui
QT_END_NAMESPACE
class chooseTableForm : public QDialog, public Ui::chooseTableForm
{
Q_OBJECT
public:
chooseTableForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~chooseTableForm();
QString option;
public slots:
virtual void editPressed();
virtual void populateOptions( QStringList entries );
protected slots:
virtual void languageChange();
};
#endif // CHOOSETABLEFORM_H
@@ -1,21 +0,0 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void chooseTableForm::editPressed()
{
option = comboOptions->currentText();
accept();
}
void chooseTableForm::populateOptions(QStringList entries)
{
comboOptions->clear();
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
comboOptions->insertItem(*ct,-1);
}
}
@@ -0,0 +1,112 @@
#include "createindexform.h"
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.h>
#include "qmessagebox.h"
/*
* Constructs a createIndexForm 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.
*/
createIndexForm::createIndexForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
createIndexForm::~createIndexForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void createIndexForm::languageChange()
{
retranslateUi(this);
}
void createIndexForm::tableSelected( const QString & entry )
{
tableMap::Iterator it;
for ( it = mtablemap.begin(); it != mtablemap.end(); ++it ) {
QString tname = it.data().getname() ;
//populate the fields with first table name
if ((tname.compare(entry)==0)){
comboFields->clear();
fieldMap::Iterator fit;
fieldMap fmap = it.data().fldmap;
for ( fit = fmap.begin(); fit != fmap.end(); ++fit ) {
comboFields->insertItem( fit.data().getname(), -1 );
}
}
}
}
void createIndexForm::confirmCreate()
{
bool ok = true;
QString idxname = indexLineEdit->text();
if (idxname.isEmpty()) {
ok = false;
QMessageBox::information( this, applicationName, "Please select a name for the index" );
return;
}
if (idxname.contains(" ")>0) {
ok = false;
QMessageBox::warning( this, applicationName, "Spaces are not allowed in the index name" );
return;
}
if (ok){
createStatement = "CREATE ";
if (comboUnique->currentItem()==1){
createStatement.append("UNIQUE ");
}
createStatement.append("INDEX ");
createStatement.append(indexLineEdit->text());
createStatement.append(" ON ");
createStatement.append(comboTables->currentText());
createStatement.append("(");
createStatement.append(comboFields->currentText());
createStatement.append(" ");
if (comboOrder->currentItem()==0){
createStatement.append("ASC");
} else {
createStatement.append("DESC");
}
createStatement.append(");");
accept();
}
}
void createIndexForm::populateTable(tableMap rmap)
{
mtablemap = rmap;
tableMap::Iterator it;
for ( it = mtablemap.begin(); it != mtablemap.end(); ++it ) {
comboTables->insertItem( it.data().getname() , -1);
//populate the fields with first table name
if (it==mtablemap.begin()){
fieldMap::Iterator fit;
fieldMap fmap = it.data().fldmap;
for ( fit = fmap.begin(); fit != fmap.end(); ++fit ) {
comboFields->insertItem( fit.data().getname(), -1 );
}
}
}
}
@@ -0,0 +1,271 @@
#ifndef CREATEINDEXFORM_H
#define CREATEINDEXFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3GroupBox>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include "sqlitedb.h"
QT_BEGIN_NAMESPACE
class Ui_createIndexForm
{
public:
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
QLabel *textLabel2;
QLineEdit *indexLineEdit;
Q3GroupBox *groupBox2;
QGridLayout *gridLayout;
QVBoxLayout *vboxLayout1;
QComboBox *comboTables;
QComboBox *comboFields;
QComboBox *comboOrder;
QComboBox *comboUnique;
QVBoxLayout *vboxLayout2;
QLabel *textLabel3;
QLabel *textLabel4;
QLabel *textLabel5;
QLabel *textLabel6;
QHBoxLayout *hboxLayout1;
QSpacerItem *spacer8;
QPushButton *buttonCreate;
QPushButton *buttonCancel;
void setupUi(QDialog *createIndexForm)
{
if (createIndexForm->objectName().isEmpty())
createIndexForm->setObjectName(QString::fromUtf8("createIndexForm"));
createIndexForm->resize(300, 258);
vboxLayout = new QVBoxLayout(createIndexForm);
vboxLayout->setSpacing(6);
vboxLayout->setMargin(11);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
textLabel2 = new QLabel(createIndexForm);
textLabel2->setObjectName(QString::fromUtf8("textLabel2"));
textLabel2->setWordWrap(false);
hboxLayout->addWidget(textLabel2);
indexLineEdit = new QLineEdit(createIndexForm);
indexLineEdit->setObjectName(QString::fromUtf8("indexLineEdit"));
hboxLayout->addWidget(indexLineEdit);
vboxLayout->addLayout(hboxLayout);
groupBox2 = new Q3GroupBox(createIndexForm);
groupBox2->setObjectName(QString::fromUtf8("groupBox2"));
groupBox2->setColumnLayout(0, Qt::Vertical);
groupBox2->layout()->setSpacing(6);
groupBox2->layout()->setMargin(11);
gridLayout = new QGridLayout();
QBoxLayout *boxlayout = qobject_cast<QBoxLayout *>(groupBox2->layout());
if (boxlayout)
boxlayout->addLayout(gridLayout);
gridLayout->setAlignment(Qt::AlignTop);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
vboxLayout1 = new QVBoxLayout();
vboxLayout1->setSpacing(6);
vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1"));
comboTables = new QComboBox(groupBox2);
comboTables->setObjectName(QString::fromUtf8("comboTables"));
vboxLayout1->addWidget(comboTables);
comboFields = new QComboBox(groupBox2);
comboFields->setObjectName(QString::fromUtf8("comboFields"));
vboxLayout1->addWidget(comboFields);
comboOrder = new QComboBox(groupBox2);
comboOrder->setObjectName(QString::fromUtf8("comboOrder"));
vboxLayout1->addWidget(comboOrder);
comboUnique = new QComboBox(groupBox2);
comboUnique->setObjectName(QString::fromUtf8("comboUnique"));
vboxLayout1->addWidget(comboUnique);
gridLayout->addLayout(vboxLayout1, 0, 1, 1, 1);
vboxLayout2 = new QVBoxLayout();
vboxLayout2->setSpacing(6);
vboxLayout2->setObjectName(QString::fromUtf8("vboxLayout2"));
textLabel3 = new QLabel(groupBox2);
textLabel3->setObjectName(QString::fromUtf8("textLabel3"));
textLabel3->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
textLabel3->setWordWrap(false);
vboxLayout2->addWidget(textLabel3);
textLabel4 = new QLabel(groupBox2);
textLabel4->setObjectName(QString::fromUtf8("textLabel4"));
textLabel4->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
textLabel4->setWordWrap(false);
vboxLayout2->addWidget(textLabel4);
textLabel5 = new QLabel(groupBox2);
textLabel5->setObjectName(QString::fromUtf8("textLabel5"));
textLabel5->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
textLabel5->setWordWrap(false);
vboxLayout2->addWidget(textLabel5);
textLabel6 = new QLabel(groupBox2);
textLabel6->setObjectName(QString::fromUtf8("textLabel6"));
textLabel6->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
textLabel6->setWordWrap(false);
vboxLayout2->addWidget(textLabel6);
gridLayout->addLayout(vboxLayout2, 0, 0, 1, 1);
vboxLayout->addWidget(groupBox2);
hboxLayout1 = new QHBoxLayout();
hboxLayout1->setSpacing(6);
hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
spacer8 = new QSpacerItem(51, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout1->addItem(spacer8);
buttonCreate = new QPushButton(createIndexForm);
buttonCreate->setObjectName(QString::fromUtf8("buttonCreate"));
hboxLayout1->addWidget(buttonCreate);
buttonCancel = new QPushButton(createIndexForm);
buttonCancel->setObjectName(QString::fromUtf8("buttonCancel"));
buttonCancel->setDefault(true);
hboxLayout1->addWidget(buttonCancel);
vboxLayout->addLayout(hboxLayout1);
retranslateUi(createIndexForm);
QObject::connect(buttonCreate, SIGNAL(clicked()), createIndexForm, SLOT(confirmCreate()));
QObject::connect(buttonCancel, SIGNAL(clicked()), createIndexForm, SLOT(reject()));
QObject::connect(comboTables, SIGNAL(activated(QString)), createIndexForm, SLOT(tableSelected(QString)));
QMetaObject::connectSlotsByName(createIndexForm);
} // setupUi
void retranslateUi(QDialog *createIndexForm)
{
createIndexForm->setWindowTitle(QApplication::translate("createIndexForm", "Create Index", 0, QApplication::UnicodeUTF8));
textLabel2->setText(QApplication::translate("createIndexForm", "Index name:", 0, QApplication::UnicodeUTF8));
indexLineEdit->setText(QString());
#ifndef QT_NO_TOOLTIP
indexLineEdit->setProperty("toolTip", QVariant(QApplication::translate("createIndexForm", "Enter the name for the new index", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
indexLineEdit->setProperty("whatsThis", QVariant(QApplication::translate("createIndexForm", "This area contains the name of the index to be created", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
groupBox2->setTitle(QApplication::translate("createIndexForm", "Define properties:", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
comboTables->setProperty("toolTip", QVariant(QApplication::translate("createIndexForm", "Choose the table to index", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
comboTables->setProperty("whatsThis", QVariant(QApplication::translate("createIndexForm", "This control is used to select the table to be indexed. Changing the selected table will automatically update the fields available in the control below", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
#ifndef QT_NO_TOOLTIP
comboFields->setProperty("toolTip", QVariant(QApplication::translate("createIndexForm", "Choose the field to be indexed", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
comboFields->setProperty("whatsThis", QVariant(QApplication::translate("createIndexForm", "This control specifies the field to be used as an index", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
comboOrder->clear();
comboOrder->insertItems(0, QStringList()
<< QApplication::translate("createIndexForm", "Ascending", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("createIndexForm", "Descending", 0, QApplication::UnicodeUTF8)
);
#ifndef QT_NO_TOOLTIP
comboOrder->setProperty("toolTip", QVariant(QApplication::translate("createIndexForm", "Choose the index order", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
comboOrder->setProperty("whatsThis", QVariant(QApplication::translate("createIndexForm", "This option controls the ordering of the index. Ascending is the recommended ordering", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
comboUnique->clear();
comboUnique->insertItems(0, QStringList()
<< QApplication::translate("createIndexForm", "Allowed", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("createIndexForm", "Not allowed", 0, QApplication::UnicodeUTF8)
);
#ifndef QT_NO_TOOLTIP
comboUnique->setProperty("toolTip", QVariant(QApplication::translate("createIndexForm", "Allow duplicate values in the index field", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
comboUnique->setProperty("whatsThis", QVariant(QApplication::translate("createIndexForm", "This control determines if the indexed field allows duplicate values to be inserted into the database. Attempting to insert a duplicate value in an indexed fiield that does not allow this option will generate an error", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
textLabel3->setText(QApplication::translate("createIndexForm", "Table to index:", 0, QApplication::UnicodeUTF8));
textLabel4->setText(QApplication::translate("createIndexForm", "Field to index:", 0, QApplication::UnicodeUTF8));
textLabel5->setText(QApplication::translate("createIndexForm", "Indexing order:", 0, QApplication::UnicodeUTF8));
textLabel6->setText(QApplication::translate("createIndexForm", "Duplicate values:", 0, QApplication::UnicodeUTF8));
buttonCreate->setText(QApplication::translate("createIndexForm", "Create", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonCreate->setProperty("toolTip", QVariant(QApplication::translate("createIndexForm", "Create Index", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
buttonCancel->setText(QApplication::translate("createIndexForm", "Cancel", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonCancel->setProperty("toolTip", QVariant(QApplication::translate("createIndexForm", "Cancel and close dialog box", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
Q_UNUSED(createIndexForm);
} // retranslateUi
};
namespace Ui {
class createIndexForm: public Ui_createIndexForm {};
} // namespace Ui
QT_END_NAMESPACE
class createIndexForm : public QDialog, public Ui::createIndexForm
{
Q_OBJECT
public:
createIndexForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~createIndexForm();
tableMap mtablemap;
QString createStatement;
public slots:
virtual void tableSelected( const QString & entry );
virtual void confirmCreate();
virtual void populateTable( tableMap rmap );
protected slots:
virtual void languageChange();
};
#endif // CREATEINDEXFORM_H
@@ -1,81 +0,0 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void createIndexForm::tableSelected( const QString & entry )
{
tableMap::Iterator it;
for ( it = mtablemap.begin(); it != mtablemap.end(); ++it ) {
QString tname = it.data().getname() ;
//populate the fields with first table name
if ((tname.compare(entry)==0)){
comboFields->clear();
fieldMap::Iterator fit;
fieldMap fmap = it.data().fldmap;
for ( fit = fmap.begin(); fit != fmap.end(); ++fit ) {
comboFields->insertItem( fit.data().getname(), -1 );
}
}
}
}
void createIndexForm::confirmCreate()
{
bool ok = true;
QString idxname = indexLineEdit->text();
if (idxname.isEmpty()) {
ok = false;
QMessageBox::information( this, applicationName, "Please select a name for the index" );
return;
}
if (idxname.contains(" ")>0) {
ok = false;
QMessageBox::warning( this, applicationName, "Spaces are not allowed in the index name" );
return;
}
if (ok){
createStatement = "CREATE ";
if (comboUnique->currentItem()==1){
createStatement.append("UNIQUE ");
}
createStatement.append("INDEX ");
createStatement.append(indexLineEdit->text());
createStatement.append(" ON ");
createStatement.append(comboTables->currentText());
createStatement.append("(");
createStatement.append(comboFields->currentText());
createStatement.append(" ");
if (comboOrder->currentItem()==0){
createStatement.append("ASC");
} else {
createStatement.append("DESC");
}
createStatement.append(");");
accept();
}
}
void createIndexForm::populateTable(tableMap rmap)
{
mtablemap = rmap;
tableMap::Iterator it;
for ( it = mtablemap.begin(); it != mtablemap.end(); ++it ) {
comboTables->insertItem( it.data().getname() , -1);
//populate the fields with first table name
if (it==mtablemap.begin()){
fieldMap::Iterator fit;
fieldMap fmap = it.data().fldmap;
for ( fit = fmap.begin(); fit != fmap.end(); ++fit ) {
comboFields->insertItem( fit.data().getname(), -1 );
}
}
}
}
@@ -0,0 +1,155 @@
#include "createtableform.h"
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.h>
#include "qmessagebox.h"
#include "addfieldform.h"
/*
* Constructs a createTableForm 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.
*/
createTableForm::createTableForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
init();
}
/*
* Destroys the object and frees any allocated resources
*/
createTableForm::~createTableForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void createTableForm::languageChange()
{
retranslateUi(this);
}
void createTableForm::init()
{
fieldListView->clear();
}
void createTableForm::confirmCreate()
{
bool ok = true;
QString tabname = tablenameLineEdit->text();
if (tabname.isEmpty()) {
ok = false;
QMessageBox::information( this, applicationName, "Please select a name for the table" );
return;
}
if (tabname.contains(" ")>0) {
ok = false;
QMessageBox::warning( this, applicationName, "Spaces are not allowed in the table name" );
return;
}
if (fieldListView->firstChild()==0) {
ok = false;
QMessageBox::information( this, applicationName, "No fields defined" );
return;
}
/*check field names for empty or illegal names
TODO: move to add
for (int r=0; r<fieldsTable->numRows();r++){
QString rowname = fieldsTable->text(r, 0);
if (rowname.isEmpty()) {
ok = false;
QMessageBox::warning( this, applicationName, "Empty field names are not allowed" );
break;
}
if (rowname.contains(" ")>0) {
ok = false;
QMessageBox::warning( this, applicationName, "Spaces are not allowed in the field names" );
break;
}
}*/
if (!ok){
return;
}
if (ok){
createStatement = "CREATE TABLE ";
createStatement.append(tabname);
createStatement.append(" (");
Q3ListViewItemIterator it( fieldListView );
Q3ListViewItem * item;
while ( it.current() ) {
item = it.current();
createStatement.append(item->text(0));
createStatement.append(" ");
createStatement.append(item->text(1));
if (item->nextSibling() != 0)
{
createStatement.append(", ");
}
++it;
}
/*for (int r=0; r<fieldsTable->numRows();r++){
createStatement.append(fieldsTable->text(r, 0));
createStatement.append(" ");
createStatement.append(fieldsTable->text(r, 1));
if (r<(fieldsTable->numRows() - 1))
createStatement.append(", ");
}*/
createStatement.append(");");
accept();
}
}
void createTableForm::addField()
{
addFieldForm * addForm = new addFieldForm( this, "addfield", TRUE );
addForm->setInitialValues(QString(""),QString(""));
if (addForm->exec())
{
//qDebug(addForm->fname + addForm->ftype);
Q3ListViewItem * tbitem = new Q3ListViewItem( fieldListView);
tbitem->setText( 0, addForm->fname );
tbitem->setText( 1, addForm->ftype );
}
}
void createTableForm::deleteField()
{
Q3ListViewItem * item = fieldListView->selectedItem();
if (item==0) {
//should never happen, the button would not be active, but...
return;
} else {
delete item;
}
}
void createTableForm::fieldSelectionChanged()
{
Q3ListViewItem * item = fieldListView->selectedItem();
if (item==0) {
buttonDeleteField->setEnabled(false);
} else {
buttonDeleteField->setEnabled(true);
}
}
@@ -0,0 +1,230 @@
#ifndef CREATETABLEFORM_H
#define CREATETABLEFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3GroupBox>
#include <Qt3Support/Q3Header>
#include <Qt3Support/Q3ListView>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include "sqlitedb.h"
QT_BEGIN_NAMESPACE
class Ui_createTableForm
{
public:
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
QLabel *textLabel1;
QLineEdit *tablenameLineEdit;
Q3GroupBox *groupBox1;
QVBoxLayout *vboxLayout1;
Q3ListView *fieldListView;
QHBoxLayout *hboxLayout1;
QSpacerItem *spacer4;
QPushButton *buttonAddField;
QPushButton *buttonDeleteField;
QHBoxLayout *hboxLayout2;
QSpacerItem *spacer6;
QPushButton *buttonCreate;
QPushButton *buttonCancel;
void setupUi(QDialog *createTableForm)
{
if (createTableForm->objectName().isEmpty())
createTableForm->setObjectName(QString::fromUtf8("createTableForm"));
createTableForm->resize(309, 320);
vboxLayout = new QVBoxLayout(createTableForm);
vboxLayout->setSpacing(6);
vboxLayout->setMargin(11);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
textLabel1 = new QLabel(createTableForm);
textLabel1->setObjectName(QString::fromUtf8("textLabel1"));
textLabel1->setWordWrap(false);
hboxLayout->addWidget(textLabel1);
tablenameLineEdit = new QLineEdit(createTableForm);
tablenameLineEdit->setObjectName(QString::fromUtf8("tablenameLineEdit"));
hboxLayout->addWidget(tablenameLineEdit);
vboxLayout->addLayout(hboxLayout);
groupBox1 = new Q3GroupBox(createTableForm);
groupBox1->setObjectName(QString::fromUtf8("groupBox1"));
groupBox1->setColumnLayout(0, Qt::Vertical);
groupBox1->layout()->setSpacing(6);
groupBox1->layout()->setMargin(11);
vboxLayout1 = new QVBoxLayout();
QBoxLayout *boxlayout = qobject_cast<QBoxLayout *>(groupBox1->layout());
if (boxlayout)
boxlayout->addLayout(vboxLayout1);
vboxLayout1->setAlignment(Qt::AlignTop);
vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1"));
fieldListView = new Q3ListView(groupBox1);
fieldListView->addColumn(QApplication::translate("createTableForm", "Field name", 0, QApplication::UnicodeUTF8));
fieldListView->header()->setClickEnabled(true, fieldListView->header()->count() - 1);
fieldListView->header()->setResizeEnabled(true, fieldListView->header()->count() - 1);
fieldListView->addColumn(QApplication::translate("createTableForm", "Field type", 0, QApplication::UnicodeUTF8));
fieldListView->header()->setClickEnabled(true, fieldListView->header()->count() - 1);
fieldListView->header()->setResizeEnabled(true, fieldListView->header()->count() - 1);
fieldListView->setObjectName(QString::fromUtf8("fieldListView"));
fieldListView->setResizePolicy(Q3ScrollView::Manual);
fieldListView->setResizeMode(Q3ListView::AllColumns);
vboxLayout1->addWidget(fieldListView);
hboxLayout1 = new QHBoxLayout();
hboxLayout1->setSpacing(6);
hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
spacer4 = new QSpacerItem(111, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout1->addItem(spacer4);
buttonAddField = new QPushButton(groupBox1);
buttonAddField->setObjectName(QString::fromUtf8("buttonAddField"));
hboxLayout1->addWidget(buttonAddField);
buttonDeleteField = new QPushButton(groupBox1);
buttonDeleteField->setObjectName(QString::fromUtf8("buttonDeleteField"));
buttonDeleteField->setEnabled(false);
hboxLayout1->addWidget(buttonDeleteField);
vboxLayout1->addLayout(hboxLayout1);
vboxLayout->addWidget(groupBox1);
hboxLayout2 = new QHBoxLayout();
hboxLayout2->setSpacing(6);
hboxLayout2->setObjectName(QString::fromUtf8("hboxLayout2"));
spacer6 = new QSpacerItem(91, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout2->addItem(spacer6);
buttonCreate = new QPushButton(createTableForm);
buttonCreate->setObjectName(QString::fromUtf8("buttonCreate"));
hboxLayout2->addWidget(buttonCreate);
buttonCancel = new QPushButton(createTableForm);
buttonCancel->setObjectName(QString::fromUtf8("buttonCancel"));
buttonCancel->setDefault(true);
hboxLayout2->addWidget(buttonCancel);
vboxLayout->addLayout(hboxLayout2);
retranslateUi(createTableForm);
QObject::connect(buttonCancel, SIGNAL(clicked()), createTableForm, SLOT(reject()));
QObject::connect(buttonCreate, SIGNAL(clicked()), createTableForm, SLOT(confirmCreate()));
QObject::connect(buttonAddField, SIGNAL(clicked()), createTableForm, SLOT(addField()));
QObject::connect(buttonDeleteField, SIGNAL(clicked()), createTableForm, SLOT(deleteField()));
QObject::connect(fieldListView, SIGNAL(selectionChanged()), createTableForm, SLOT(fieldSelectionChanged()));
QMetaObject::connectSlotsByName(createTableForm);
} // setupUi
void retranslateUi(QDialog *createTableForm)
{
createTableForm->setWindowTitle(QApplication::translate("createTableForm", "Create Table", 0, QApplication::UnicodeUTF8));
textLabel1->setText(QApplication::translate("createTableForm", "Table name:", 0, QApplication::UnicodeUTF8));
tablenameLineEdit->setText(QString());
#ifndef QT_NO_TOOLTIP
tablenameLineEdit->setProperty("toolTip", QVariant(QApplication::translate("createTableForm", "Enter the name for the new table", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
tablenameLineEdit->setProperty("whatsThis", QVariant(QApplication::translate("createTableForm", "Use this control to enter the name of the table to be created.", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
groupBox1->setTitle(QApplication::translate("createTableForm", "Define fields:", 0, QApplication::UnicodeUTF8));
fieldListView->header()->setLabel(0, QApplication::translate("createTableForm", "Field name", 0, QApplication::UnicodeUTF8));
fieldListView->header()->setLabel(1, QApplication::translate("createTableForm", "Field type", 0, QApplication::UnicodeUTF8));
fieldListView->clear();
Q3ListViewItem *__item = new Q3ListViewItem(fieldListView);
__item->setText(0, QApplication::translate("createTableForm", "New Item", 0, QApplication::UnicodeUTF8));
__item->setText(1, QString());
__item->setPixmap(0, QPixmap());
__item->setPixmap(1, QPixmap());
buttonAddField->setText(QApplication::translate("createTableForm", "Add", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonAddField->setProperty("toolTip", QVariant(QApplication::translate("createTableForm", "Add a new field definition", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
buttonAddField->setProperty("whatsThis", QVariant(QApplication::translate("createTableForm", "This button is used to add a new field definition to your table", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
buttonDeleteField->setText(QApplication::translate("createTableForm", "Delete", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonDeleteField->setProperty("toolTip", QVariant(QApplication::translate("createTableForm", "Delete current field definition", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
buttonDeleteField->setProperty("whatsThis", QVariant(QApplication::translate("createTableForm", "This button is used to delete the currently selected field definition from your table", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
buttonCreate->setText(QApplication::translate("createTableForm", "Create", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonCreate->setProperty("toolTip", QVariant(QApplication::translate("createTableForm", "Create the table", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
buttonCancel->setText(QApplication::translate("createTableForm", "Cancel", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonCancel->setProperty("toolTip", QVariant(QApplication::translate("createTableForm", "Cancel and close dialog box", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
Q_UNUSED(createTableForm);
} // retranslateUi
};
namespace Ui {
class createTableForm: public Ui_createTableForm {};
} // namespace Ui
QT_END_NAMESPACE
class createTableForm : public QDialog, public Ui::createTableForm
{
Q_OBJECT
public:
createTableForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~createTableForm();
QString createStatement;
public slots:
virtual void confirmCreate();
virtual void addField();
virtual void deleteField();
virtual void fieldSelectionChanged();
protected slots:
virtual void languageChange();
private:
void init();
};
#endif // CREATETABLEFORM_H
@@ -1,122 +0,0 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void createTableForm::init()
{
fieldListView->clear();
}
void createTableForm::confirmCreate()
{
bool ok = true;
QString tabname = tablenameLineEdit->text();
if (tabname.isEmpty()) {
ok = false;
QMessageBox::information( this, applicationName, "Please select a name for the table" );
return;
}
if (tabname.contains(" ")>0) {
ok = false;
QMessageBox::warning( this, applicationName, "Spaces are not allowed in the table name" );
return;
}
if (fieldListView->firstChild()==0) {
ok = false;
QMessageBox::information( this, applicationName, "No fields defined" );
return;
}
/*check field names for empty or illegal names
TODO: move to add
for (int r=0; r<fieldsTable->numRows();r++){
QString rowname = fieldsTable->text(r, 0);
if (rowname.isEmpty()) {
ok = false;
QMessageBox::warning( this, applicationName, "Empty field names are not allowed" );
break;
}
if (rowname.contains(" ")>0) {
ok = false;
QMessageBox::warning( this, applicationName, "Spaces are not allowed in the field names" );
break;
}
}*/
if (!ok){
return;
}
if (ok){
createStatement = "CREATE TABLE ";
createStatement.append(tabname);
createStatement.append(" (");
Q3ListViewItemIterator it( fieldListView );
Q3ListViewItem * item;
while ( it.current() ) {
item = it.current();
createStatement.append(item->text(0));
createStatement.append(" ");
createStatement.append(item->text(1));
if (item->nextSibling() != 0)
{
createStatement.append(", ");
}
++it;
}
/*for (int r=0; r<fieldsTable->numRows();r++){
createStatement.append(fieldsTable->text(r, 0));
createStatement.append(" ");
createStatement.append(fieldsTable->text(r, 1));
if (r<(fieldsTable->numRows() - 1))
createStatement.append(", ");
}*/
createStatement.append(");");
accept();
}
}
void createTableForm::addField()
{
addFieldForm * addForm = new addFieldForm( this, "addfield", TRUE );
addForm->setInitialValues(QString(""),QString(""));
if (addForm->exec())
{
//qDebug(addForm->fname + addForm->ftype);
Q3ListViewItem * tbitem = new Q3ListViewItem( fieldListView);
tbitem->setText( 0, addForm->fname );
tbitem->setText( 1, addForm->ftype );
}
}
void createTableForm::deleteField()
{
Q3ListViewItem * item = fieldListView->selectedItem();
if (item==0) {
//should never happen, the button would not be active, but...
return;
} else {
delete item;
}
}
void createTableForm::fieldSelectionChanged()
{
Q3ListViewItem * item = fieldListView->selectedItem();
if (item==0) {
buttonDeleteField->setEnabled(false);
} else {
buttonDeleteField->setEnabled(true);
}
}
@@ -0,0 +1,63 @@
#include "deleteindexform.h"
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.h>
#include "qmessagebox.h"
/*
* 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, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, 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, applicationName,
msg,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape )
== QMessageBox::Yes ){
option = comboOptions->currentText();
accept();
}
}
void deleteIndexForm::populateOptions(QStringList entries)
{
comboOptions->clear();
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
comboOptions->insertItem(*ct,-1);
}
}
@@ -0,0 +1,146 @@
#ifndef DELETEINDEXFORM_H
#define DELETEINDEXFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include "QtCore/QStringRef"
#include "QtCore/QStringList"
#include "sqlitedb.h"
QT_BEGIN_NAMESPACE
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->setMargin(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
Q_UNUSED(deleteIndexForm);
} // retranslateUi
};
namespace Ui {
class deleteIndexForm: public Ui_deleteIndexForm {};
} // namespace Ui
QT_END_NAMESPACE
class deleteIndexForm : public QDialog, public Ui::deleteIndexForm
{
Q_OBJECT
public:
deleteIndexForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~deleteIndexForm();
QString option;
public slots:
virtual void confirmDelete();
virtual void populateOptions( QStringList entries );
protected slots:
virtual void languageChange();
};
#endif // DELETEINDEXFORM_H
@@ -1,32 +0,0 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void deleteIndexForm::confirmDelete()
{
QString msg = "Are you sure you want to delete index ";
msg.append(comboOptions->currentText());
msg.append("?");
if (QMessageBox::warning( this, applicationName,
msg,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape )
== QMessageBox::Yes ){
option = comboOptions->currentText();
accept();
}
}
void deleteIndexForm::populateOptions(QStringList entries)
{
comboOptions->clear();
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
comboOptions->insertItem(*ct,-1);
}
}
@@ -0,0 +1,63 @@
#include "deletetableform.h"
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.h>
#include "qmessagebox.h"
/*
* 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, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, 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, applicationName,
msg,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape )
== QMessageBox::Yes ){
option = comboOptions->currentText();
accept();
}
}
void deleteTableForm::populateOptions(QStringList entries)
{
comboOptions->clear();
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
comboOptions->insertItem(*ct,-1);
}
}
@@ -0,0 +1,146 @@
#ifndef DELETETABLEFORM_H
#define DELETETABLEFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include "QtCore/QStringRef"
#include "QtCore/QStringList"
#include "sqlitedb.h"
QT_BEGIN_NAMESPACE
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->setMargin(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
Q_UNUSED(deleteTableForm);
} // retranslateUi
};
namespace Ui {
class deleteTableForm: public Ui_deleteTableForm {};
} // namespace Ui
QT_END_NAMESPACE
class deleteTableForm : public QDialog, public Ui::deleteTableForm
{
Q_OBJECT
public:
deleteTableForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~deleteTableForm();
QString option;
public slots:
virtual void confirmDelete();
virtual void populateOptions( QStringList entries );
protected slots:
virtual void languageChange();
};
#endif // DELETETABLEFORM_H
@@ -1,33 +0,0 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
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, applicationName,
msg,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape )
== QMessageBox::Yes ){
option = comboOptions->currentText();
accept();
}
}
void deleteTableForm::populateOptions(QStringList entries)
{
comboOptions->clear();
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
comboOptions->insertItem(*ct,-1);
}
}
@@ -1,11 +1,44 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
#include "editfieldform.h"
#include <qvariant.h>
#include <qmessagebox.h>
#include <qimage.h>
#include <qpixmap.h>
#include "sqlitedb.h"
#include "addfieldtypeform.h"
/*
* Constructs a editFieldForm 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.
*/
editFieldForm::editFieldForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
editFieldForm::~editFieldForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void editFieldForm::languageChange()
{
retranslateUi(this);
}
void editFieldForm::setInitialValues(QString name, QString type)
{
nameLineEdit->setText(name);
@@ -28,11 +61,11 @@ void editFieldForm::confirmEdit()
QString fieldname = nameLineEdit->text();
if (fieldname.isEmpty()) {
QMessageBox::information( this, applicationName, "Field name can not be empty" );
return;
return;
}
if (fieldname.contains(" ")>0) {
QMessageBox::warning( this, applicationName, "Spaces are not allowed in the field name" );
return;
QMessageBox::warning( this, applicationName, "Spaces are not allowed in the field name" );
return;
}
name = fieldname;
type = typeBox->currentText();
@@ -49,8 +82,8 @@ void editFieldForm::getCustomType()
addFieldTypeForm * addForm = new addFieldTypeForm( this, "addfieldtype", TRUE );
if (addForm->exec())
{
QString nospaces = addForm->typeNameEdit->text().remove(" ");
setInitialValues(nameLineEdit->text(),nospaces );
enableSave();
QString nospaces = addForm->typeNameEdit->text().remove(" ");
setInitialValues(nameLineEdit->text(),nospaces );
enableSave();
}
}
+193
View File
@@ -0,0 +1,193 @@
#ifndef EDITFIELDFORM_H
#define EDITFIELDFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QToolButton>
#include <QtGui/QVBoxLayout>
QT_BEGIN_NAMESPACE
class Ui_editFieldForm
{
public:
QGridLayout *gridLayout;
QVBoxLayout *vboxLayout;
QLabel *textLabel1;
QLabel *textLabel2;
QSpacerItem *spacer17;
QHBoxLayout *hboxLayout;
QSpacerItem *spacer15;
QPushButton *cancelButton;
QPushButton *saveButton;
QGridLayout *gridLayout1;
QHBoxLayout *hboxLayout1;
QComboBox *typeBox;
QToolButton *typeButton;
QLineEdit *nameLineEdit;
void setupUi(QDialog *editFieldForm)
{
if (editFieldForm->objectName().isEmpty())
editFieldForm->setObjectName(QString::fromUtf8("editFieldForm"));
editFieldForm->resize(352, 140);
gridLayout = new QGridLayout(editFieldForm);
gridLayout->setSpacing(6);
gridLayout->setMargin(11);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
vboxLayout = new QVBoxLayout();
vboxLayout->setSpacing(6);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
textLabel1 = new QLabel(editFieldForm);
textLabel1->setObjectName(QString::fromUtf8("textLabel1"));
textLabel1->setWordWrap(false);
vboxLayout->addWidget(textLabel1);
textLabel2 = new QLabel(editFieldForm);
textLabel2->setObjectName(QString::fromUtf8("textLabel2"));
textLabel2->setWordWrap(false);
vboxLayout->addWidget(textLabel2);
gridLayout->addLayout(vboxLayout, 0, 0, 1, 1);
spacer17 = new QSpacerItem(20, 14, QSizePolicy::Minimum, QSizePolicy::Expanding);
gridLayout->addItem(spacer17, 1, 1, 1, 1);
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
spacer15 = new QSpacerItem(41, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacer15);
cancelButton = new QPushButton(editFieldForm);
cancelButton->setObjectName(QString::fromUtf8("cancelButton"));
hboxLayout->addWidget(cancelButton);
saveButton = new QPushButton(editFieldForm);
saveButton->setObjectName(QString::fromUtf8("saveButton"));
saveButton->setEnabled(false);
saveButton->setDefault(true);
hboxLayout->addWidget(saveButton);
gridLayout->addLayout(hboxLayout, 2, 0, 1, 2);
gridLayout1 = new QGridLayout();
gridLayout1->setSpacing(6);
gridLayout1->setObjectName(QString::fromUtf8("gridLayout1"));
hboxLayout1 = new QHBoxLayout();
hboxLayout1->setSpacing(6);
hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
typeBox = new QComboBox(editFieldForm);
typeBox->setObjectName(QString::fromUtf8("typeBox"));
hboxLayout1->addWidget(typeBox);
typeButton = new QToolButton(editFieldForm);
typeButton->setObjectName(QString::fromUtf8("typeButton"));
QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(0), static_cast<QSizePolicy::Policy>(0));
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(typeButton->sizePolicy().hasHeightForWidth());
typeButton->setSizePolicy(sizePolicy);
hboxLayout1->addWidget(typeButton);
gridLayout1->addLayout(hboxLayout1, 1, 0, 1, 1);
nameLineEdit = new QLineEdit(editFieldForm);
nameLineEdit->setObjectName(QString::fromUtf8("nameLineEdit"));
gridLayout1->addWidget(nameLineEdit, 0, 0, 1, 1);
gridLayout->addLayout(gridLayout1, 0, 1, 1, 1);
retranslateUi(editFieldForm);
QObject::connect(cancelButton, SIGNAL(clicked()), editFieldForm, SLOT(reject()));
QObject::connect(saveButton, SIGNAL(clicked()), editFieldForm, SLOT(confirmEdit()));
QObject::connect(nameLineEdit, SIGNAL(textChanged(QString)), editFieldForm, SLOT(enableSave()));
QObject::connect(typeButton, SIGNAL(clicked()), editFieldForm, SLOT(getCustomType()));
QMetaObject::connectSlotsByName(editFieldForm);
} // setupUi
void retranslateUi(QDialog *editFieldForm)
{
editFieldForm->setWindowTitle(QApplication::translate("editFieldForm", "Edit field name and type", 0, QApplication::UnicodeUTF8));
textLabel1->setText(QApplication::translate("editFieldForm", "Field name:", 0, QApplication::UnicodeUTF8));
textLabel2->setText(QApplication::translate("editFieldForm", "Field type:", 0, QApplication::UnicodeUTF8));
cancelButton->setText(QApplication::translate("editFieldForm", "Cancel", 0, QApplication::UnicodeUTF8));
saveButton->setText(QApplication::translate("editFieldForm", "Apply Changes", 0, QApplication::UnicodeUTF8));
typeBox->clear();
typeBox->insertItems(0, QStringList()
<< QString()
<< QApplication::translate("editFieldForm", "text", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("editFieldForm", "integer", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("editFieldForm", "blob", 0, QApplication::UnicodeUTF8)
);
typeButton->setText(QApplication::translate("editFieldForm", "...", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
typeButton->setProperty("toolTip", QVariant(QApplication::translate("editFieldForm", "Custom type", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
typeButton->setProperty("whatsThis", QVariant(QApplication::translate("editFieldForm", "Click this button to enter a new type for the field", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
Q_UNUSED(editFieldForm);
} // retranslateUi
};
namespace Ui {
class editFieldForm: public Ui_editFieldForm {};
} // namespace Ui
QT_END_NAMESPACE
class editFieldForm : public QDialog, public Ui::editFieldForm
{
Q_OBJECT
public:
editFieldForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~editFieldForm();
QString name;
QString type;
public slots:
virtual void setInitialValues( QString name, QString type );
virtual void confirmEdit();
virtual void enableSave();
virtual void getCustomType();
protected slots:
virtual void languageChange();
};
#endif // EDITFIELDFORM_H
+236
View File
@@ -0,0 +1,236 @@
#include "editform.h"
#include <qvariant.h>
#include <q3filedialog.h>
#include <qmessagebox.h>
#include <qimage.h>
#include <qpixmap.h>
#include <Q3TextStream>
#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, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, 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->setText("");
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::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->length()>1) charstr = QString("chars"); else charstr = QString("char");
currentDataInfo->setText(QString("%1 %2").arg(textEditor->length()).arg(charstr));
editWidgetStack->raiseWidget(0);
enableExport(true);
enableTextEditor(true);
break;
case kSQLiteMediaType_Void:
currentTypeLabel->setText("Type of data currently in cell: Empty");
currentDataInfo->setText("");
editWidgetStack->raiseWidget(0);
enableExport(false);
enableTextEditor(true);
break;
}
}
void editForm::closeEvent( QCloseEvent * )
{
emit goingAway();
}
void editForm::loadText(QString text, int row, int col)
{
textEditor->setText(text);
curRow = row;
curCol = col;
if (textEditor->length() > 0)
{
setDataType(kSQLiteMediaType_String, 0);
} else {
setDataType(kSQLiteMediaType_Void, 0);
}
setModified(false);
}
void editForm::importData()
{
int type = kSQLiteMediaType_Void;
QString fileName = Q3FileDialog::getOpenFileName(
"",
QString( "Text files (*.txt);;"
"All files (*.*);;"),
this,
"open file dialog"
"Choose an image file" );
if (QFile::exists(fileName) )
{
type = kSQLiteMediaType_String;
QFile file( fileName );
if ( file.open( QIODevice::ReadOnly ) ) {
Q3TextStream stream( &file );
textEditor->setText(stream.read());
file.close();
}
setModified(true);
}
}
void editForm::exportData()
{
QString filter;
switch (dataType)
{
case kSQLiteMediaType_String:
filter = "Text files (*.txt)";
break;
default:
return;
}
QString fileName = Q3FileDialog::getSaveFileName(
"",
filter,
this,
"save file dialog"
"Choose a filename to export data" );
if (fileName.size() > 0)
{
switch (dataType)
{
case kSQLiteMediaType_String:
{
QFile file(fileName);
if ( file.open( QIODevice::WriteOnly ) ) {
Q3TextStream stream( &file );
stream << textEditor->text();
file.close();
}
}
break;
default:
return;
}
}
}
void editForm::clearData()
{
textEditor->setText("");
setDataType(kSQLiteMediaType_Void, 0);
setModified(true);
}
void editForm::saveChanges()
{
if (dataType==kSQLiteMediaType_String)
emit updateRecordText(curRow, curCol, textEditor->text());
if (dataType==kSQLiteMediaType_Void)
emit updateRecordText(curRow, curCol, QString(""));
setModified(false);
emit goingAway();
}
void editForm::editTextChanged()
{
int newtype = kSQLiteMediaType_String;
if (textEditor->length() == 0)
{
newtype = kSQLiteMediaType_Void;
}
if (newtype!=dataType)
{
setDataType(newtype, 0);
}
setModified(true);
}
void editForm::editorClicked()
{
enableTextEditor(true);
}
+300
View File
@@ -0,0 +1,300 @@
#ifndef EDITFORM_H
#define EDITFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3Frame>
#include <Qt3Support/Q3MimeSourceFactory>
#include <Qt3Support/Q3TextEdit>
#include <Qt3Support/Q3WidgetStack>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QToolButton>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
#include <QtGui/QApplication>
#include <QtCore/QFile>
#include <QtGui/QImage>
#include <stdlib.h>
QT_BEGIN_NAMESPACE
class Ui_editForm
{
public:
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
QToolButton *importButton;
QToolButton *exportButton;
QSpacerItem *spacer11_2;
QToolButton *clearButton;
Q3WidgetStack *editWidgetStack;
QWidget *WStackPage;
QGridLayout *gridLayout;
Q3TextEdit *textEditor;
QWidget *WStackPage1;
QGridLayout *gridLayout1;
QLabel *editPixmap;
Q3Frame *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->setMargin(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 Q3WidgetStack(editForm);
editWidgetStack->setObjectName(QString::fromUtf8("editWidgetStack"));
WStackPage = new QWidget(editWidgetStack);
WStackPage->setObjectName(QString::fromUtf8("WStackPage"));
gridLayout = new QGridLayout(WStackPage);
gridLayout->setSpacing(6);
gridLayout->setMargin(11);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
gridLayout->setContentsMargins(0, 0, 0, 0);
textEditor = new Q3TextEdit(WStackPage);
textEditor->setObjectName(QString::fromUtf8("textEditor"));
gridLayout->addWidget(textEditor, 0, 0, 1, 1);
editWidgetStack->addWidget(WStackPage, 0);
WStackPage1 = new QWidget(editWidgetStack);
WStackPage1->setObjectName(QString::fromUtf8("WStackPage1"));
gridLayout1 = new QGridLayout(WStackPage1);
gridLayout1->setSpacing(6);
gridLayout1->setMargin(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, 1);
vboxLayout->addWidget(editWidgetStack);
frame9 = new Q3Frame(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()));
QObject::connect(textEditor, SIGNAL(clicked(int,int)), editForm, SLOT(editorClicked()));
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
Q_UNUSED(editForm);
} // retranslateUi
};
namespace Ui {
class editForm: public Ui_editForm {};
} // namespace Ui
QT_END_NAMESPACE
class editForm : public QDialog, public Ui::editForm
{
Q_OBJECT
public:
editForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~editForm();
int curCol;
int curRow;
public slots:
virtual void reset();
virtual void setModified( bool modifiedstate );
virtual void enableExport( bool enabled );
virtual void enableTextEditor( 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 saveChanges();
virtual void editTextChanged();
virtual void editorClicked();
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
-203
View File
@@ -1,203 +0,0 @@
//Added by qt3to4:
#include <QCloseEvent>
#include <Q3TextStream>
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void editForm::init()
{
setModified(false);
dataType = kSQLiteMediaType_Void;
dataSize = 0;
dataDepth = 0;
curRow = -1;
curCol = -1;
textEditor->setText("");
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::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->length()>1) charstr = QString("chars"); else charstr = QString("char");
currentDataInfo->setText(QString("%1 %2").arg(textEditor->length()).arg(charstr));
editWidgetStack->raiseWidget(0);
enableExport(true);
enableTextEditor(true);
break;
case kSQLiteMediaType_Void:
currentTypeLabel->setText("Type of data currently in cell: Empty");
currentDataInfo->setText("");
editWidgetStack->raiseWidget(0);
enableExport(false);
enableTextEditor(true);
break;
}
}
void editForm::closeEvent( QCloseEvent * )
{
emit goingAway();
}
void editForm::loadText(QString text, int row, int col)
{
textEditor->setText(text);
curRow = row;
curCol = col;
if (textEditor->length() > 0)
{
setDataType(kSQLiteMediaType_String, 0);
} else {
setDataType(kSQLiteMediaType_Void, 0);
}
setModified(false);
}
void editForm::importData()
{
int type = kSQLiteMediaType_Void;
QString fileName = Q3FileDialog::getOpenFileName(
"",
QString( "Text files (*.txt);;"
"All files (*.*);;"),
this,
"open file dialog"
"Choose an image file" );
if (QFile::exists(fileName) )
{
type = kSQLiteMediaType_String;
QFile file( fileName );
if ( file.open( QIODevice::ReadOnly ) ) {
Q3TextStream stream( &file );
textEditor->setText(stream.read());
file.close();
}
setModified(true);
}
}
void editForm::exportData()
{
QString filter;
switch (dataType)
{
case kSQLiteMediaType_String:
filter = "Text files (*.txt)";
break;
default:
return;
}
QString fileName = Q3FileDialog::getSaveFileName(
"",
filter,
this,
"save file dialog"
"Choose a filename to export data" );
if (fileName.size() > 0)
{
switch (dataType)
{
case kSQLiteMediaType_String:
{
QFile file(fileName);
if ( file.open( QIODevice::WriteOnly ) ) {
Q3TextStream stream( &file );
stream << textEditor->text();
file.close();
}
}
break;
default:
return;
}
}
}
void editForm::clearData()
{
textEditor->setText("");
setDataType(kSQLiteMediaType_Void, 0);
setModified(true);
}
void editForm::saveChanges()
{
if (dataType==kSQLiteMediaType_String)
emit updateRecordText(curRow, curCol, textEditor->text());
if (dataType==kSQLiteMediaType_Void)
emit updateRecordText(curRow, curCol, QString(""));
setModified(false);
emit goingAway();
}
void editForm::editTextChanged()
{
int newtype = kSQLiteMediaType_String;
if (textEditor->length() == 0)
{
newtype = kSQLiteMediaType_Void;
}
if (newtype!=dataType)
{
setDataType(newtype, 0);
}
setModified(true);
}
void editForm::editorClicked()
{
enableTextEditor(true);
}
@@ -0,0 +1,111 @@
#include "editformwindow.h"
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.h>
/*
* Constructs a editFormWindow as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
*/
editFormWindow::editFormWindow(QWidget* parent, const char* name, Qt::WindowFlags fl)
: Q3MainWindow(parent, name, fl)
{
setupUi(this);
(void)statusBar();
}
/*
* Destroys the object and frees any allocated resources
*/
editFormWindow::~editFormWindow()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void editFormWindow::languageChange()
{
retranslateUi(this);
}
void editFormWindow::fileNew()
{
qWarning("editFormWindow::fileNew(): Not implemented yet");
}
void editFormWindow::fileOpen()
{
qWarning("editFormWindow::fileOpen(): Not implemented yet");
}
void editFormWindow::fileSave()
{
qWarning("editFormWindow::fileSave(): Not implemented yet");
}
void editFormWindow::fileSaveAs()
{
qWarning("editFormWindow::fileSaveAs(): Not implemented yet");
}
void editFormWindow::filePrint()
{
qWarning("editFormWindow::filePrint(): Not implemented yet");
}
void editFormWindow::fileExit()
{
qWarning("editFormWindow::fileExit(): Not implemented yet");
}
void editFormWindow::editUndo()
{
qWarning("editFormWindow::editUndo(): Not implemented yet");
}
void editFormWindow::editRedo()
{
qWarning("editFormWindow::editRedo(): Not implemented yet");
}
void editFormWindow::editCut()
{
qWarning("editFormWindow::editCut(): Not implemented yet");
}
void editFormWindow::editCopy()
{
qWarning("editFormWindow::editCopy(): Not implemented yet");
}
void editFormWindow::editPaste()
{
qWarning("editFormWindow::editPaste(): Not implemented yet");
}
void editFormWindow::editFind()
{
qWarning("editFormWindow::editFind(): Not implemented yet");
}
void editFormWindow::helpIndex()
{
qWarning("editFormWindow::helpIndex(): Not implemented yet");
}
void editFormWindow::helpContents()
{
qWarning("editFormWindow::helpContents(): Not implemented yet");
}
void editFormWindow::helpAbout()
{
qWarning("editFormWindow::helpAbout(): Not implemented yet");
}
@@ -0,0 +1,259 @@
#ifndef EDITFORMWINDOW_H
#define EDITFORMWINDOW_H
#include <qvariant.h>
#include <Qt3Support/Q3MainWindow>
#include <Qt3Support/Q3MimeSourceFactory>
#include <Qt3Support/Q3ToolBar>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_editFormWindow
{
public:
QAction *fileNewAction;
QAction *fileOpenAction;
QAction *fileSaveAction;
QAction *fileSaveAsAction;
QAction *filePrintAction;
QAction *fileExitAction;
QAction *editUndoAction;
QAction *editRedoAction;
QAction *editCutAction;
QAction *editCopyAction;
QAction *editPasteAction;
QAction *editFindAction;
QAction *helpContentsAction;
QAction *helpIndexAction;
QAction *helpAboutAction;
QWidget *widget;
QVBoxLayout *vboxLayout;
Q3ToolBar *toolBar;
QMenuBar *MenuBar;
QMenu *fileMenu;
QMenu *editMenu;
QMenu *helpMenu;
void setupUi(Q3MainWindow *editFormWindow)
{
if (editFormWindow->objectName().isEmpty())
editFormWindow->setObjectName(QString::fromUtf8("editFormWindow"));
editFormWindow->resize(331, 435);
editFormWindow->setDockWindowsMovable(true);
fileNewAction = new QAction(editFormWindow);
fileNewAction->setObjectName(QString::fromUtf8("fileNewAction"));
fileNewAction->setName("fileNewAction");
const QIcon icon = QIcon(qPixmapFromMimeSource("filenew"));
fileNewAction->setIcon(icon);
fileOpenAction = new QAction(editFormWindow);
fileOpenAction->setObjectName(QString::fromUtf8("fileOpenAction"));
fileOpenAction->setName("fileOpenAction");
const QIcon icon1 = QIcon(qPixmapFromMimeSource("fileopen"));
fileOpenAction->setIcon(icon1);
fileSaveAction = new QAction(editFormWindow);
fileSaveAction->setObjectName(QString::fromUtf8("fileSaveAction"));
fileSaveAction->setName("fileSaveAction");
const QIcon icon2 = QIcon(qPixmapFromMimeSource("filesave"));
fileSaveAction->setIcon(icon2);
fileSaveAsAction = new QAction(editFormWindow);
fileSaveAsAction->setObjectName(QString::fromUtf8("fileSaveAsAction"));
fileSaveAsAction->setName("fileSaveAsAction");
filePrintAction = new QAction(editFormWindow);
filePrintAction->setObjectName(QString::fromUtf8("filePrintAction"));
filePrintAction->setName("filePrintAction");
const QIcon icon3 = QIcon(qPixmapFromMimeSource("print"));
filePrintAction->setIcon(icon3);
fileExitAction = new QAction(editFormWindow);
fileExitAction->setObjectName(QString::fromUtf8("fileExitAction"));
fileExitAction->setName("fileExitAction");
editUndoAction = new QAction(editFormWindow);
editUndoAction->setObjectName(QString::fromUtf8("editUndoAction"));
editUndoAction->setName("editUndoAction");
const QIcon icon4 = QIcon(qPixmapFromMimeSource("undo"));
editUndoAction->setIcon(icon4);
editRedoAction = new QAction(editFormWindow);
editRedoAction->setObjectName(QString::fromUtf8("editRedoAction"));
editRedoAction->setName("editRedoAction");
const QIcon icon5 = QIcon(qPixmapFromMimeSource("redo"));
editRedoAction->setIcon(icon5);
editCutAction = new QAction(editFormWindow);
editCutAction->setObjectName(QString::fromUtf8("editCutAction"));
editCutAction->setName("editCutAction");
const QIcon icon6 = QIcon(qPixmapFromMimeSource("editcut"));
editCutAction->setIcon(icon6);
editCopyAction = new QAction(editFormWindow);
editCopyAction->setObjectName(QString::fromUtf8("editCopyAction"));
editCopyAction->setName("editCopyAction");
const QIcon icon7 = QIcon(qPixmapFromMimeSource("editcopy"));
editCopyAction->setIcon(icon7);
editPasteAction = new QAction(editFormWindow);
editPasteAction->setObjectName(QString::fromUtf8("editPasteAction"));
editPasteAction->setName("editPasteAction");
const QIcon icon8 = QIcon(qPixmapFromMimeSource("editpaste"));
editPasteAction->setIcon(icon8);
editFindAction = new QAction(editFormWindow);
editFindAction->setObjectName(QString::fromUtf8("editFindAction"));
editFindAction->setName("editFindAction");
const QIcon icon9 = QIcon(qPixmapFromMimeSource("searchfind"));
editFindAction->setIcon(icon9);
helpContentsAction = new QAction(editFormWindow);
helpContentsAction->setObjectName(QString::fromUtf8("helpContentsAction"));
helpContentsAction->setName("helpContentsAction");
helpIndexAction = new QAction(editFormWindow);
helpIndexAction->setObjectName(QString::fromUtf8("helpIndexAction"));
helpIndexAction->setName("helpIndexAction");
helpAboutAction = new QAction(editFormWindow);
helpAboutAction->setObjectName(QString::fromUtf8("helpAboutAction"));
helpAboutAction->setName("helpAboutAction");
widget = new QWidget(editFormWindow);
widget->setObjectName(QString::fromUtf8("widget"));
vboxLayout = new QVBoxLayout(widget);
vboxLayout->setSpacing(6);
vboxLayout->setMargin(11);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
vboxLayout->setContentsMargins(0, 0, 0, 0);
editFormWindow->setCentralWidget(widget);
toolBar = new Q3ToolBar(editFormWindow);
toolBar->setObjectName(QString::fromUtf8("toolBar"));
MenuBar = new QMenuBar(editFormWindow);
MenuBar->setObjectName(QString::fromUtf8("MenuBar"));
fileMenu = new QMenu(MenuBar);
fileMenu->setObjectName(QString::fromUtf8("fileMenu"));
editMenu = new QMenu(MenuBar);
editMenu->setObjectName(QString::fromUtf8("editMenu"));
helpMenu = new QMenu(MenuBar);
helpMenu->setObjectName(QString::fromUtf8("helpMenu"));
toolBar->addAction(fileOpenAction);
toolBar->addAction(fileSaveAction);
toolBar->addAction(filePrintAction);
toolBar->addSeparator();
toolBar->addAction(editCutAction);
toolBar->addAction(editCopyAction);
toolBar->addAction(editPasteAction);
toolBar->addAction(helpContentsAction);
MenuBar->addAction(fileMenu->menuAction());
MenuBar->addAction(editMenu->menuAction());
MenuBar->addAction(helpMenu->menuAction());
fileMenu->addAction(fileOpenAction);
fileMenu->addAction(fileSaveAction);
fileMenu->addSeparator();
fileMenu->addAction(filePrintAction);
fileMenu->addSeparator();
editMenu->addAction(editUndoAction);
editMenu->addAction(editRedoAction);
editMenu->addSeparator();
editMenu->addAction(editCutAction);
editMenu->addAction(editCopyAction);
editMenu->addAction(editPasteAction);
helpMenu->addAction(helpAboutAction);
retranslateUi(editFormWindow);
QMetaObject::connectSlotsByName(editFormWindow);
} // setupUi
void retranslateUi(Q3MainWindow *editFormWindow)
{
editFormWindow->setWindowTitle(QApplication::translate("editFormWindow", "Edit database cell", 0, QApplication::UnicodeUTF8));
fileNewAction->setIconText(QApplication::translate("editFormWindow", "New", 0, QApplication::UnicodeUTF8));
fileNewAction->setText(QApplication::translate("editFormWindow", "&New", 0, QApplication::UnicodeUTF8));
fileNewAction->setShortcut(QApplication::translate("editFormWindow", "Ctrl+N", 0, QApplication::UnicodeUTF8));
fileOpenAction->setIconText(QApplication::translate("editFormWindow", "&Import", 0, QApplication::UnicodeUTF8));
fileOpenAction->setText(QApplication::translate("editFormWindow", "&Import", 0, QApplication::UnicodeUTF8));
fileOpenAction->setShortcut(QApplication::translate("editFormWindow", "Ctrl+I", 0, QApplication::UnicodeUTF8));
fileSaveAction->setIconText(QApplication::translate("editFormWindow", "&Export", 0, QApplication::UnicodeUTF8));
fileSaveAction->setText(QApplication::translate("editFormWindow", "&Export", 0, QApplication::UnicodeUTF8));
fileSaveAction->setShortcut(QApplication::translate("editFormWindow", "Ctrl+E", 0, QApplication::UnicodeUTF8));
fileSaveAsAction->setIconText(QApplication::translate("editFormWindow", "Save As", 0, QApplication::UnicodeUTF8));
fileSaveAsAction->setText(QApplication::translate("editFormWindow", "Save &As...", 0, QApplication::UnicodeUTF8));
fileSaveAsAction->setShortcut(QString());
filePrintAction->setIconText(QApplication::translate("editFormWindow", "Print", 0, QApplication::UnicodeUTF8));
filePrintAction->setText(QApplication::translate("editFormWindow", "&Print...", 0, QApplication::UnicodeUTF8));
filePrintAction->setShortcut(QApplication::translate("editFormWindow", "Ctrl+P", 0, QApplication::UnicodeUTF8));
fileExitAction->setIconText(QApplication::translate("editFormWindow", "Exit", 0, QApplication::UnicodeUTF8));
fileExitAction->setText(QApplication::translate("editFormWindow", "E&xit", 0, QApplication::UnicodeUTF8));
fileExitAction->setShortcut(QString());
editUndoAction->setIconText(QApplication::translate("editFormWindow", "Undo", 0, QApplication::UnicodeUTF8));
editUndoAction->setText(QApplication::translate("editFormWindow", "&Undo", 0, QApplication::UnicodeUTF8));
editUndoAction->setShortcut(QApplication::translate("editFormWindow", "Ctrl+Z", 0, QApplication::UnicodeUTF8));
editRedoAction->setIconText(QApplication::translate("editFormWindow", "Redo", 0, QApplication::UnicodeUTF8));
editRedoAction->setText(QApplication::translate("editFormWindow", "&Redo", 0, QApplication::UnicodeUTF8));
editRedoAction->setShortcut(QApplication::translate("editFormWindow", "Ctrl+Y", 0, QApplication::UnicodeUTF8));
editCutAction->setIconText(QApplication::translate("editFormWindow", "Cut", 0, QApplication::UnicodeUTF8));
editCutAction->setText(QApplication::translate("editFormWindow", "&Cut", 0, QApplication::UnicodeUTF8));
editCutAction->setShortcut(QApplication::translate("editFormWindow", "Ctrl+X", 0, QApplication::UnicodeUTF8));
editCopyAction->setIconText(QApplication::translate("editFormWindow", "Copy", 0, QApplication::UnicodeUTF8));
editCopyAction->setText(QApplication::translate("editFormWindow", "C&opy", 0, QApplication::UnicodeUTF8));
editCopyAction->setShortcut(QApplication::translate("editFormWindow", "Ctrl+C", 0, QApplication::UnicodeUTF8));
editPasteAction->setIconText(QApplication::translate("editFormWindow", "Paste", 0, QApplication::UnicodeUTF8));
editPasteAction->setText(QApplication::translate("editFormWindow", "&Paste", 0, QApplication::UnicodeUTF8));
editPasteAction->setShortcut(QApplication::translate("editFormWindow", "Ctrl+V", 0, QApplication::UnicodeUTF8));
editFindAction->setIconText(QApplication::translate("editFormWindow", "Find", 0, QApplication::UnicodeUTF8));
editFindAction->setText(QApplication::translate("editFormWindow", "&Find...", 0, QApplication::UnicodeUTF8));
editFindAction->setShortcut(QApplication::translate("editFormWindow", "Ctrl+F", 0, QApplication::UnicodeUTF8));
helpContentsAction->setIconText(QApplication::translate("editFormWindow", "Contents", 0, QApplication::UnicodeUTF8));
helpContentsAction->setText(QApplication::translate("editFormWindow", "&Contents...", 0, QApplication::UnicodeUTF8));
helpContentsAction->setShortcut(QString());
helpIndexAction->setIconText(QApplication::translate("editFormWindow", "Index", 0, QApplication::UnicodeUTF8));
helpIndexAction->setText(QApplication::translate("editFormWindow", "&Index...", 0, QApplication::UnicodeUTF8));
helpIndexAction->setShortcut(QString());
helpAboutAction->setIconText(QApplication::translate("editFormWindow", "&What is", 0, QApplication::UnicodeUTF8));
helpAboutAction->setText(QApplication::translate("editFormWindow", "&What is", 0, QApplication::UnicodeUTF8));
helpAboutAction->setShortcut(QString());
toolBar->setLabel(QApplication::translate("editFormWindow", "Tools", 0, QApplication::UnicodeUTF8));
fileMenu->setTitle(QApplication::translate("editFormWindow", "&File", 0, QApplication::UnicodeUTF8));
editMenu->setTitle(QApplication::translate("editFormWindow", "&Edit", 0, QApplication::UnicodeUTF8));
helpMenu->setTitle(QApplication::translate("editFormWindow", "&Help", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class editFormWindow: public Ui_editFormWindow {};
} // namespace Ui
QT_END_NAMESPACE
class editFormWindow : public Q3MainWindow, public Ui::editFormWindow
{
Q_OBJECT
public:
editFormWindow(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::WType_TopLevel);
~editFormWindow();
public slots:
virtual void fileNew();
virtual void fileOpen();
virtual void fileSave();
virtual void fileSaveAs();
virtual void filePrint();
virtual void fileExit();
virtual void editUndo();
virtual void editRedo();
virtual void editCut();
virtual void editCopy();
virtual void editPaste();
virtual void editFind();
virtual void helpIndex();
virtual void helpContents();
virtual void helpAbout();
protected slots:
virtual void languageChange();
};
#endif // EDITFORMWINDOW_H
@@ -0,0 +1,565 @@
#include "edittableform.h"
#include <qvariant.h>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qimage.h>
#include <qpixmap.h>
#include "renametableform.h"
#include "addfieldform.h"
#include "editfieldform.h"
/*
* Constructs a editTableForm 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.
*/
editTableForm::editTableForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
init();
}
/*
* Destroys the object and frees any allocated resources
*/
editTableForm::~editTableForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void editTableForm::languageChange()
{
retranslateUi(this);
}
void editTableForm::init()
{
pdb = NULL;
modified = false;
}
void editTableForm::setActiveTable(DBBrowserDB * thedb, QString tableName)
{
pdb = thedb;
curTable = tableName;
populateFields();
tableLine->setText(curTable);
}
void editTableForm::populateFields()
{
if (!pdb) return;
//make sure we are not using cached information
pdb->updateSchema();
fields= pdb->getTableFields(curTable);
types= pdb->getTableTypes(curTable);
fieldListView->clear();
fieldListView->setSorting (-1, FALSE);
Q3ListViewItem * lasttbitem = 0;
QStringList::Iterator tt = types.begin();
for ( QStringList::Iterator ct = fields.begin(); ct != fields.end(); ++ct ) {
Q3ListViewItem * tbitem = new Q3ListViewItem( fieldListView, lasttbitem);
tbitem->setText( 0, *ct );
tbitem->setText( 1, *tt );
lasttbitem = tbitem;
++tt;
}
}
void editTableForm::renameTable()
{
renameTableForm * renTableForm = new renameTableForm( this, "renametable", TRUE );
renTableForm->setTableName(curTable);
if (renTableForm->exec())
{
QApplication::setOverrideCursor( Qt::waitCursor ); // this might take time
modified = true;
QString newName = renTableForm->getTableName();
qDebug(newName);
QString sql;
//do the sql rename here
//if (!pdb->executeSQL(QString("BEGIN TRANSACTION;"))) goto rollback;
sql = "CREATE TEMPORARY TABLE TEMP_TABLE(";
Q3ListViewItemIterator it( fieldListView );
Q3ListViewItem * item;
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO TEMP_TABLE SELECT ";
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(" FROM ");
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "DROP TABLE ";
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "CREATE TABLE ";
sql.append(newName);
sql.append(" (");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO ";
sql.append(newName);
sql.append(" SELECT ");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(" FROM TEMP_TABLE;");
if (!pdb->executeSQL(sql)) goto rollback;
if (!pdb->executeSQL(QString("DROP TABLE TEMP_TABLE;"))) goto rollback;
//if (!pdb->executeSQL(QString("COMMIT;"))) goto rollback;
setActiveTable(pdb, newName);
}
//everything ok, just return
QApplication::restoreOverrideCursor(); // restore original cursor
return;
rollback:
QApplication::restoreOverrideCursor(); // restore original cursor
QString error = "Error renaming table. Message from database engine: ";
error.append(pdb->lastErrorMessage);
QMessageBox::warning( this, applicationName, error );
pdb->executeSQL(QString("DROP TABLE TEMP_TABLE;"));
//pdb->executeSQL(QString("ROLLBACK;"));
setActiveTable(pdb, curTable);
}
void editTableForm::editField()
{
Q3ListViewItem * item = fieldListView->selectedItem();
if (item==0) {
//should never happen, the button would not be active, but...
return;
} else {
editFieldForm * fieldForm = new editFieldForm( this, "editfield", TRUE );
fieldForm->setInitialValues(item->text(0),item->text(1));
if (fieldForm->exec())
{
modified = true;
//do the sql rename here
//qDebug(fieldForm->name + fieldForm->type);
item->setText(0,fieldForm->name);
item->setText(1,fieldForm->type);
//not until nested transaction are supported
//if (!pdb->executeSQL(QString("BEGIN TRANSACTION;"))) goto rollback;
QString sql = "CREATE TEMPORARY TABLE TEMP_TABLE(";
Q3ListViewItemIterator it( fieldListView );
Q3ListViewItem * item;
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO TEMP_TABLE SELECT ";
for ( QStringList::Iterator ct = fields.begin(); ct != fields.end(); ++ct ) {
sql.append( *ct );
if (*ct != fields.last())
{
sql.append(", ");
}
}
sql.append(" FROM ");
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "DROP TABLE ";
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "CREATE TABLE ";
sql.append(curTable);
sql.append(" (");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO ";
sql.append(curTable);
sql.append(" SELECT ");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(" FROM TEMP_TABLE;");
if (!pdb->executeSQL(sql)) goto rollback;
if (!pdb->executeSQL(QString("DROP TABLE TEMP_TABLE;"))) goto rollback;
//not until nested transaction are supported
//if (!pdb->executeSQL(QString("COMMIT;"))) goto rollback;
setActiveTable(pdb, curTable);
}
//everything ok, just return
QApplication::restoreOverrideCursor(); // restore original cursor
return;
rollback:
QApplication::restoreOverrideCursor(); // restore original cursor
QString error = "Error editing field. Message from database engine: ";
error.append(pdb->lastErrorMessage);
QMessageBox::warning( this, applicationName, error );
//not until nested transaction are supported
//pdb->executeSQL(QString("ROLLBACK;"));
setActiveTable(pdb, curTable);
}
}
void editTableForm::addField()
{
addFieldForm * addForm = new addFieldForm( this, "addfield", TRUE );
addForm->setInitialValues(QString(""),QString(""));
if (addForm->exec())
{
modified = true;
Q3ListViewItem * tbitem = new Q3ListViewItem( fieldListView);
tbitem->setText( 0, addForm->fname);
tbitem->setText( 1, addForm->ftype);
//do the sql creation here
modified = true;
//do the sql rename here
//qDebug(fieldForm->name + fieldForm->type);
QString sql = "CREATE TEMPORARY TABLE TEMP_TABLE(";
Q3ListViewItemIterator it( fieldListView );
Q3ListViewItem * item;
//not until nested transaction are supported
//if (!pdb->executeSQL(QString("BEGIN TRANSACTION;"))) goto rollback;
{//nest for MSVC support
for ( QStringList::Iterator ct = fields.begin(); ct != fields.end(); ++ct ) {
sql.append( *ct );
if (*ct != fields.last())
{
sql.append(", ");
}
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO TEMP_TABLE SELECT ";
for ( QStringList::Iterator ct1 = fields.begin(); ct1 != fields.end(); ++ct1 ) {
sql.append( *ct1 );
if (*ct1 != fields.last())
{
sql.append(", ");
}
}
}
sql.append(" FROM ");
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "DROP TABLE ";
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "CREATE TABLE ";
sql.append(curTable);
sql.append(" (");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
{//nest for MSVC support
sql = "INSERT INTO ";
sql.append(curTable);
sql.append("(");
for ( QStringList::Iterator ct2 = fields.begin(); ct2 != fields.end(); ++ct2 ) {
sql.append( *ct2 );
if (*ct2 != fields.last())
{
sql.append(", ");
}
}
}
{//nest for MSVC support
sql.append(") SELECT ");
for ( QStringList::Iterator ct3 = fields.begin(); ct3 != fields.end(); ++ct3 ) {
sql.append( *ct3 );
if (*ct3 != fields.last())
{
sql.append(", ");
}
}
}
sql.append(" FROM TEMP_TABLE;");
if (!pdb->executeSQL(sql)) goto rollback;
if (!pdb->executeSQL(QString("DROP TABLE TEMP_TABLE;"))) goto rollback;
//not until nested transaction are supported
//if (!pdb->executeSQL(QString("COMMIT;"))) goto rollback;
setActiveTable(pdb, curTable);
QApplication::restoreOverrideCursor(); // restore original cursor
return;
rollback:
QApplication::restoreOverrideCursor(); // restore original cursor
QString error = "Error adding field. Message from database engine: ";
error.append(pdb->lastErrorMessage);
QMessageBox::warning( this, applicationName, error );
//not until nested transaction are supported
//pdb->executeSQL(QString("ROLLBACK;"));
setActiveTable(pdb, curTable);
}
}
void editTableForm::removeField()
{
Q3ListViewItem * remitem = fieldListView->selectedItem();
if (remitem==0) {
//should never happen, the button would not be active, but...
return;
} else {
QString msg = "Are you sure you want to delete field ";
msg.append(remitem->text(0));
msg.append("? \n All data currently stored in this field will be lost");
if (QMessageBox::warning( this, applicationName,
msg,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape )
== QMessageBox::Yes ){
//delete field here
/*fields= pdb->getTableFields(curTable);
types= pdb->getTableTypes(curTable);*/
modified = true;
delete remitem;
QString sql = "CREATE TEMPORARY TABLE TEMP_TABLE(";
Q3ListViewItemIterator it( fieldListView );
Q3ListViewItem * item;
//not until nested transaction are supported
// if (!pdb->executeSQL(QString("BEGIN TRANSACTION;"))) goto rollback;
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO TEMP_TABLE SELECT ";
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(" FROM ");
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "DROP TABLE ";
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "CREATE TABLE ";
sql.append(curTable);
sql.append(" (");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO ";
sql.append(curTable);
sql.append("(");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(") SELECT ");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(" FROM TEMP_TABLE;");
if (!pdb->executeSQL(sql)) goto rollback;
if (!pdb->executeSQL(QString("DROP TABLE TEMP_TABLE;"))) goto rollback;
//not until nested transaction are supported
//if (!pdb->executeSQL(QString("COMMIT;"))) goto rollback;
setActiveTable(pdb, curTable);
QApplication::restoreOverrideCursor(); // restore original cursor
return;
rollback:
QApplication::restoreOverrideCursor(); // restore original cursor
QString error = "Error removing field. Message from database engine: ";
error.append(pdb->lastErrorMessage);
QMessageBox::warning( this, applicationName, error );
//not until nested transaction are supported
//pdb->executeSQL(QString("ROLLBACK;"));
setActiveTable(pdb, curTable);
}
}
}
void editTableForm::fieldSelectionChanged()
{
Q3ListViewItem * item = fieldListView->selectedItem();
if (item==0) {
renameFieldButton->setEnabled(false);
removeFieldButton->setEnabled(false);
} else {
renameFieldButton->setEnabled(true);
removeFieldButton->setEnabled(true);
}
}
+198
View File
@@ -0,0 +1,198 @@
#ifndef EDITTABLEFORM_H
#define EDITTABLEFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3Header>
#include <Qt3Support/Q3ListView>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include "sqlitedb.h"
QT_BEGIN_NAMESPACE
class Ui_editTableForm
{
public:
QGridLayout *gridLayout;
QVBoxLayout *vboxLayout;
QLineEdit *tableLine;
Q3ListView *fieldListView;
QVBoxLayout *vboxLayout1;
QPushButton *renameTableButton;
QSpacerItem *spacer31;
QPushButton *renameFieldButton;
QPushButton *removeFieldButton;
QPushButton *addFieldButton;
QHBoxLayout *hboxLayout;
QSpacerItem *spacer34;
QPushButton *closeButton;
void setupUi(QDialog *editTableForm)
{
if (editTableForm->objectName().isEmpty())
editTableForm->setObjectName(QString::fromUtf8("editTableForm"));
editTableForm->resize(428, 266);
gridLayout = new QGridLayout(editTableForm);
gridLayout->setSpacing(6);
gridLayout->setMargin(11);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
vboxLayout = new QVBoxLayout();
vboxLayout->setSpacing(6);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
tableLine = new QLineEdit(editTableForm);
tableLine->setObjectName(QString::fromUtf8("tableLine"));
tableLine->setFocusPolicy(Qt::NoFocus);
tableLine->setReadOnly(true);
vboxLayout->addWidget(tableLine);
fieldListView = new Q3ListView(editTableForm);
fieldListView->addColumn(QApplication::translate("editTableForm", "Field name", 0, QApplication::UnicodeUTF8));
fieldListView->header()->setClickEnabled(true, fieldListView->header()->count() - 1);
fieldListView->header()->setResizeEnabled(true, fieldListView->header()->count() - 1);
fieldListView->addColumn(QApplication::translate("editTableForm", "Field type", 0, QApplication::UnicodeUTF8));
fieldListView->header()->setClickEnabled(true, fieldListView->header()->count() - 1);
fieldListView->header()->setResizeEnabled(true, fieldListView->header()->count() - 1);
fieldListView->setObjectName(QString::fromUtf8("fieldListView"));
fieldListView->setResizePolicy(Q3ScrollView::Manual);
fieldListView->setResizeMode(Q3ListView::AllColumns);
vboxLayout->addWidget(fieldListView);
gridLayout->addLayout(vboxLayout, 0, 0, 1, 1);
vboxLayout1 = new QVBoxLayout();
vboxLayout1->setSpacing(6);
vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1"));
renameTableButton = new QPushButton(editTableForm);
renameTableButton->setObjectName(QString::fromUtf8("renameTableButton"));
vboxLayout1->addWidget(renameTableButton);
spacer31 = new QSpacerItem(20, 23, QSizePolicy::Minimum, QSizePolicy::Expanding);
vboxLayout1->addItem(spacer31);
renameFieldButton = new QPushButton(editTableForm);
renameFieldButton->setObjectName(QString::fromUtf8("renameFieldButton"));
renameFieldButton->setEnabled(false);
vboxLayout1->addWidget(renameFieldButton);
removeFieldButton = new QPushButton(editTableForm);
removeFieldButton->setObjectName(QString::fromUtf8("removeFieldButton"));
removeFieldButton->setEnabled(false);
vboxLayout1->addWidget(removeFieldButton);
addFieldButton = new QPushButton(editTableForm);
addFieldButton->setObjectName(QString::fromUtf8("addFieldButton"));
vboxLayout1->addWidget(addFieldButton);
gridLayout->addLayout(vboxLayout1, 0, 1, 1, 1);
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
spacer34 = new QSpacerItem(161, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacer34);
closeButton = new QPushButton(editTableForm);
closeButton->setObjectName(QString::fromUtf8("closeButton"));
hboxLayout->addWidget(closeButton);
gridLayout->addLayout(hboxLayout, 1, 0, 1, 2);
retranslateUi(editTableForm);
QObject::connect(closeButton, SIGNAL(clicked()), editTableForm, SLOT(accept()));
QObject::connect(renameTableButton, SIGNAL(clicked()), editTableForm, SLOT(renameTable()));
QObject::connect(removeFieldButton, SIGNAL(clicked()), editTableForm, SLOT(removeField()));
QObject::connect(addFieldButton, SIGNAL(clicked()), editTableForm, SLOT(addField()));
QObject::connect(renameFieldButton, SIGNAL(clicked()), editTableForm, SLOT(editField()));
QObject::connect(fieldListView, SIGNAL(selectionChanged()), editTableForm, SLOT(fieldSelectionChanged()));
QMetaObject::connectSlotsByName(editTableForm);
} // setupUi
void retranslateUi(QDialog *editTableForm)
{
editTableForm->setWindowTitle(QApplication::translate("editTableForm", "Edit table definition", 0, QApplication::UnicodeUTF8));
fieldListView->header()->setLabel(0, QApplication::translate("editTableForm", "Field name", 0, QApplication::UnicodeUTF8));
fieldListView->header()->setLabel(1, QApplication::translate("editTableForm", "Field type", 0, QApplication::UnicodeUTF8));
fieldListView->clear();
Q3ListViewItem *__item = new Q3ListViewItem(fieldListView);
__item->setText(0, QApplication::translate("editTableForm", "New Item", 0, QApplication::UnicodeUTF8));
__item->setText(1, QString());
__item->setPixmap(0, QPixmap());
__item->setPixmap(1, QPixmap());
renameTableButton->setText(QApplication::translate("editTableForm", "Rename table", 0, QApplication::UnicodeUTF8));
renameFieldButton->setText(QApplication::translate("editTableForm", "Edit field", 0, QApplication::UnicodeUTF8));
removeFieldButton->setText(QApplication::translate("editTableForm", "Remove field", 0, QApplication::UnicodeUTF8));
addFieldButton->setText(QApplication::translate("editTableForm", "Add field", 0, QApplication::UnicodeUTF8));
closeButton->setText(QApplication::translate("editTableForm", "Close", 0, QApplication::UnicodeUTF8));
Q_UNUSED(editTableForm);
} // retranslateUi
};
namespace Ui {
class editTableForm: public Ui_editTableForm {};
} // namespace Ui
QT_END_NAMESPACE
class editTableForm : public QDialog, public Ui::editTableForm
{
Q_OBJECT
public:
editTableForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~editTableForm();
bool modified;
QString curTable;
public slots:
virtual void setActiveTable( DBBrowserDB * thedb, QString tableName );
virtual void populateFields();
virtual void renameTable();
virtual void editField();
virtual void addField();
virtual void removeField();
virtual void fieldSelectionChanged();
protected:
QStringList types;
QStringList fields;
DBBrowserDB * pdb;
protected slots:
virtual void languageChange();
private:
void init();
};
#endif // EDITTABLEFORM_H
@@ -1,530 +0,0 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void editTableForm::init()
{
pdb = NULL;
modified = false;
}
void editTableForm::setActiveTable(DBBrowserDB * thedb, QString tableName)
{
pdb = thedb;
curTable = tableName;
populateFields();
tableLine->setText(curTable);
}
void editTableForm::populateFields()
{
if (!pdb) return;
//make sure we are not using cached information
pdb->updateSchema();
fields= pdb->getTableFields(curTable);
types= pdb->getTableTypes(curTable);
fieldListView->clear();
fieldListView->setSorting (-1, FALSE);
Q3ListViewItem * lasttbitem = 0;
QStringList::Iterator tt = types.begin();
for ( QStringList::Iterator ct = fields.begin(); ct != fields.end(); ++ct ) {
Q3ListViewItem * tbitem = new Q3ListViewItem( fieldListView, lasttbitem);
tbitem->setText( 0, *ct );
tbitem->setText( 1, *tt );
lasttbitem = tbitem;
++tt;
}
}
void editTableForm::renameTable()
{
renameTableForm * renTableForm = new renameTableForm( this, "renametable", TRUE );
renTableForm->setTableName(curTable);
if (renTableForm->exec())
{
QApplication::setOverrideCursor( Qt::waitCursor ); // this might take time
modified = true;
QString newName = renTableForm->getTableName();
qDebug(newName);
QString sql;
//do the sql rename here
//if (!pdb->executeSQL(QString("BEGIN TRANSACTION;"))) goto rollback;
sql = "CREATE TEMPORARY TABLE TEMP_TABLE(";
Q3ListViewItemIterator it( fieldListView );
Q3ListViewItem * item;
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO TEMP_TABLE SELECT ";
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(" FROM ");
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "DROP TABLE ";
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "CREATE TABLE ";
sql.append(newName);
sql.append(" (");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO ";
sql.append(newName);
sql.append(" SELECT ");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(" FROM TEMP_TABLE;");
if (!pdb->executeSQL(sql)) goto rollback;
if (!pdb->executeSQL(QString("DROP TABLE TEMP_TABLE;"))) goto rollback;
//if (!pdb->executeSQL(QString("COMMIT;"))) goto rollback;
setActiveTable(pdb, newName);
}
//everything ok, just return
QApplication::restoreOverrideCursor(); // restore original cursor
return;
rollback:
QApplication::restoreOverrideCursor(); // restore original cursor
QString error = "Error renaming table. Message from database engine: ";
error.append(pdb->lastErrorMessage);
QMessageBox::warning( this, applicationName, error );
pdb->executeSQL(QString("DROP TABLE TEMP_TABLE;"));
//pdb->executeSQL(QString("ROLLBACK;"));
setActiveTable(pdb, curTable);
}
void editTableForm::editField()
{
Q3ListViewItem * item = fieldListView->selectedItem();
if (item==0) {
//should never happen, the button would not be active, but...
return;
} else {
editFieldForm * fieldForm = new editFieldForm( this, "editfield", TRUE );
fieldForm->setInitialValues(item->text(0),item->text(1));
if (fieldForm->exec())
{
modified = true;
//do the sql rename here
//qDebug(fieldForm->name + fieldForm->type);
item->setText(0,fieldForm->name);
item->setText(1,fieldForm->type);
//not until nested transaction are supported
//if (!pdb->executeSQL(QString("BEGIN TRANSACTION;"))) goto rollback;
QString sql = "CREATE TEMPORARY TABLE TEMP_TABLE(";
Q3ListViewItemIterator it( fieldListView );
Q3ListViewItem * item;
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO TEMP_TABLE SELECT ";
for ( QStringList::Iterator ct = fields.begin(); ct != fields.end(); ++ct ) {
sql.append( *ct );
if (*ct != fields.last())
{
sql.append(", ");
}
}
sql.append(" FROM ");
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "DROP TABLE ";
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "CREATE TABLE ";
sql.append(curTable);
sql.append(" (");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO ";
sql.append(curTable);
sql.append(" SELECT ");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(" FROM TEMP_TABLE;");
if (!pdb->executeSQL(sql)) goto rollback;
if (!pdb->executeSQL(QString("DROP TABLE TEMP_TABLE;"))) goto rollback;
//not until nested transaction are supported
//if (!pdb->executeSQL(QString("COMMIT;"))) goto rollback;
setActiveTable(pdb, curTable);
}
//everything ok, just return
QApplication::restoreOverrideCursor(); // restore original cursor
return;
rollback:
QApplication::restoreOverrideCursor(); // restore original cursor
QString error = "Error editing field. Message from database engine: ";
error.append(pdb->lastErrorMessage);
QMessageBox::warning( this, applicationName, error );
//not until nested transaction are supported
//pdb->executeSQL(QString("ROLLBACK;"));
setActiveTable(pdb, curTable);
}
}
void editTableForm::addField()
{
addFieldForm * addForm = new addFieldForm( this, "addfield", TRUE );
addForm->setInitialValues(QString(""),QString(""));
if (addForm->exec())
{
modified = true;
Q3ListViewItem * tbitem = new Q3ListViewItem( fieldListView);
tbitem->setText( 0, addForm->fname);
tbitem->setText( 1, addForm->ftype);
//do the sql creation here
modified = true;
//do the sql rename here
//qDebug(fieldForm->name + fieldForm->type);
QString sql = "CREATE TEMPORARY TABLE TEMP_TABLE(";
Q3ListViewItemIterator it( fieldListView );
Q3ListViewItem * item;
//not until nested transaction are supported
//if (!pdb->executeSQL(QString("BEGIN TRANSACTION;"))) goto rollback;
{//nest for MSVC support
for ( QStringList::Iterator ct = fields.begin(); ct != fields.end(); ++ct ) {
sql.append( *ct );
if (*ct != fields.last())
{
sql.append(", ");
}
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO TEMP_TABLE SELECT ";
for ( QStringList::Iterator ct1 = fields.begin(); ct1 != fields.end(); ++ct1 ) {
sql.append( *ct1 );
if (*ct1 != fields.last())
{
sql.append(", ");
}
}
}
sql.append(" FROM ");
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "DROP TABLE ";
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "CREATE TABLE ";
sql.append(curTable);
sql.append(" (");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
{//nest for MSVC support
sql = "INSERT INTO ";
sql.append(curTable);
sql.append("(");
for ( QStringList::Iterator ct2 = fields.begin(); ct2 != fields.end(); ++ct2 ) {
sql.append( *ct2 );
if (*ct2 != fields.last())
{
sql.append(", ");
}
}
}
{//nest for MSVC support
sql.append(") SELECT ");
for ( QStringList::Iterator ct3 = fields.begin(); ct3 != fields.end(); ++ct3 ) {
sql.append( *ct3 );
if (*ct3 != fields.last())
{
sql.append(", ");
}
}
}
sql.append(" FROM TEMP_TABLE;");
if (!pdb->executeSQL(sql)) goto rollback;
if (!pdb->executeSQL(QString("DROP TABLE TEMP_TABLE;"))) goto rollback;
//not until nested transaction are supported
//if (!pdb->executeSQL(QString("COMMIT;"))) goto rollback;
setActiveTable(pdb, curTable);
QApplication::restoreOverrideCursor(); // restore original cursor
return;
rollback:
QApplication::restoreOverrideCursor(); // restore original cursor
QString error = "Error adding field. Message from database engine: ";
error.append(pdb->lastErrorMessage);
QMessageBox::warning( this, applicationName, error );
//not until nested transaction are supported
//pdb->executeSQL(QString("ROLLBACK;"));
setActiveTable(pdb, curTable);
}
}
void editTableForm::removeField()
{
Q3ListViewItem * remitem = fieldListView->selectedItem();
if (remitem==0) {
//should never happen, the button would not be active, but...
return;
} else {
QString msg = "Are you sure you want to delete field ";
msg.append(remitem->text(0));
msg.append("? \n All data currently stored in this field will be lost");
if (QMessageBox::warning( this, applicationName,
msg,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape )
== QMessageBox::Yes ){
//delete field here
/*fields= pdb->getTableFields(curTable);
types= pdb->getTableTypes(curTable);*/
modified = true;
delete remitem;
QString sql = "CREATE TEMPORARY TABLE TEMP_TABLE(";
Q3ListViewItemIterator it( fieldListView );
Q3ListViewItem * item;
//not until nested transaction are supported
// if (!pdb->executeSQL(QString("BEGIN TRANSACTION;"))) goto rollback;
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO TEMP_TABLE SELECT ";
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(" FROM ");
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "DROP TABLE ";
sql.append(curTable);
sql.append(";");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "CREATE TABLE ";
sql.append(curTable);
sql.append(" (");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
sql.append(" ");
sql.append(item->text(1));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(");");
if (!pdb->executeSQL(sql)) goto rollback;
sql = "INSERT INTO ";
sql.append(curTable);
sql.append("(");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(") SELECT ");
it = Q3ListViewItemIterator( fieldListView );
while ( it.current() ) {
item = it.current();
sql.append(item->text(0));
if (item->nextSibling() != 0)
{
sql.append(", ");
}
++it;
}
sql.append(" FROM TEMP_TABLE;");
if (!pdb->executeSQL(sql)) goto rollback;
if (!pdb->executeSQL(QString("DROP TABLE TEMP_TABLE;"))) goto rollback;
//not until nested transaction are supported
//if (!pdb->executeSQL(QString("COMMIT;"))) goto rollback;
setActiveTable(pdb, curTable);
QApplication::restoreOverrideCursor(); // restore original cursor
return;
rollback:
QApplication::restoreOverrideCursor(); // restore original cursor
QString error = "Error removing field. Message from database engine: ";
error.append(pdb->lastErrorMessage);
QMessageBox::warning( this, applicationName, error );
//not until nested transaction are supported
//pdb->executeSQL(QString("ROLLBACK;"));
setActiveTable(pdb, curTable);
}
}
}
void editTableForm::fieldSelectionChanged()
{
Q3ListViewItem * item = fieldListView->selectedItem();
if (item==0) {
renameFieldButton->setEnabled(false);
removeFieldButton->setEnabled(false);
} else {
renameFieldButton->setEnabled(true);
removeFieldButton->setEnabled(true);
}
}
@@ -0,0 +1,50 @@
#include "exporttablecsvform.h"
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.h>
/*
* Constructs a exportTableCSVForm 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.
*/
exportTableCSVForm::exportTableCSVForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
exportTableCSVForm::~exportTableCSVForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void exportTableCSVForm::languageChange()
{
retranslateUi(this);
}
void exportTableCSVForm::exportPressed()
{
option = comboOptions->currentText();
accept();
}
void exportTableCSVForm::populateOptions(QStringList entries)
{
comboOptions->clear();
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
comboOptions->insertItem(*ct,-1);
}
}
@@ -0,0 +1,143 @@
#ifndef EXPORTTABLECSVFORM_H
#define EXPORTTABLECSVFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
QT_BEGIN_NAMESPACE
class Ui_exportTableCSVForm
{
public:
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
QLabel *textLabel2;
QComboBox *comboOptions;
QSpacerItem *spacer13;
QHBoxLayout *hboxLayout1;
QSpacerItem *spacer11;
QPushButton *buttonCancel;
QPushButton *buttonExport;
void setupUi(QDialog *exportTableCSVForm)
{
if (exportTableCSVForm->objectName().isEmpty())
exportTableCSVForm->setObjectName(QString::fromUtf8("exportTableCSVForm"));
exportTableCSVForm->resize(365, 150);
vboxLayout = new QVBoxLayout(exportTableCSVForm);
vboxLayout->setSpacing(6);
vboxLayout->setMargin(11);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
textLabel2 = new QLabel(exportTableCSVForm);
textLabel2->setObjectName(QString::fromUtf8("textLabel2"));
textLabel2->setWordWrap(false);
hboxLayout->addWidget(textLabel2);
comboOptions = new QComboBox(exportTableCSVForm);
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(29, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout1->addItem(spacer11);
buttonCancel = new QPushButton(exportTableCSVForm);
buttonCancel->setObjectName(QString::fromUtf8("buttonCancel"));
buttonCancel->setDefault(false);
hboxLayout1->addWidget(buttonCancel);
buttonExport = new QPushButton(exportTableCSVForm);
buttonExport->setObjectName(QString::fromUtf8("buttonExport"));
hboxLayout1->addWidget(buttonExport);
vboxLayout->addLayout(hboxLayout1);
retranslateUi(exportTableCSVForm);
QObject::connect(buttonExport, SIGNAL(clicked()), exportTableCSVForm, SLOT(exportPressed()));
QObject::connect(buttonCancel, SIGNAL(clicked()), exportTableCSVForm, SLOT(reject()));
QMetaObject::connectSlotsByName(exportTableCSVForm);
} // setupUi
void retranslateUi(QDialog *exportTableCSVForm)
{
exportTableCSVForm->setWindowTitle(QApplication::translate("exportTableCSVForm", "Choose table to export as CSV text", 0, QApplication::UnicodeUTF8));
textLabel2->setText(QApplication::translate("exportTableCSVForm", "Table name:", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
comboOptions->setProperty("toolTip", QVariant(QApplication::translate("exportTableCSVForm", "Choose the table to delete", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
comboOptions->setProperty("whatsThis", QVariant(QApplication::translate("exportTableCSVForm", "Use this control to select the name of the table to be deleted", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
buttonCancel->setText(QApplication::translate("exportTableCSVForm", "Cancel", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonCancel->setProperty("toolTip", QVariant(QApplication::translate("exportTableCSVForm", "Cancel and close dialog box", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
buttonExport->setText(QApplication::translate("exportTableCSVForm", "Export", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonExport->setProperty("toolTip", QVariant(QApplication::translate("exportTableCSVForm", "Delete the selected table", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
Q_UNUSED(exportTableCSVForm);
} // retranslateUi
};
namespace Ui {
class exportTableCSVForm: public Ui_exportTableCSVForm {};
} // namespace Ui
QT_END_NAMESPACE
class exportTableCSVForm : public QDialog, public Ui::exportTableCSVForm
{
Q_OBJECT
public:
exportTableCSVForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~exportTableCSVForm();
QString option;
public slots:
virtual void exportPressed();
virtual void populateOptions( QStringList entries );
protected slots:
virtual void languageChange();
};
#endif // EXPORTTABLECSVFORM_H
@@ -1,21 +0,0 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void exportTableCSVForm::exportPressed()
{
option = comboOptions->currentText();
accept();
}
void exportTableCSVForm::populateOptions(QStringList entries)
{
comboOptions->clear();
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
comboOptions->insertItem(*ct,-1);
}
}
+96
View File
@@ -0,0 +1,96 @@
#include "findform.h"
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.h>
/*
* Constructs a findForm 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.
*/
findForm::findForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
findForm::~findForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void findForm::languageChange()
{
retranslateUi(this);
}
void findForm::showResults(resultMap rmap)
{
findListView->clear();
findListView->setSorting(-1);
resultMap::Iterator it;
Q3ListViewItem * lasttbitem = 0;
for ( it = rmap.begin(); it != rmap.end(); ++it ) {
Q3ListViewItem * tbitem = new Q3ListViewItem( findListView, lasttbitem );
//tbitem->setOpen( TRUE );
tbitem->setText( 0, QString::number(it.key() + 1,10) ); //increase from index 0
QString firstline = it.data().section( '\n', 0,0 );
if (firstline.length()>MAX_DISPLAY_LENGTH)
{
firstline.truncate(MAX_DISPLAY_LENGTH);
firstline.append("...");
}
tbitem->setText( 1, firstline );
lasttbitem = tbitem;
}
QString results = "Found: ";
results.append(QString::number(findListView->childCount()));
resultsLabel->setText(results);
}
void findForm::find()
{
emit lookfor( findFieldCombobox->currentText(), findOperatorComboBox->currentText(),searchLine->text() );
}
void findForm::resetFields(QStringList fieldlist)
{
findFieldCombobox->clear();
for ( QStringList::Iterator ct = fieldlist.begin(); ct != fieldlist.end(); ++ct ) {
findFieldCombobox->insertItem(*ct,-1);
}
}
void findForm::resetResults()
{
findListView->clear();
resultsLabel->setText("Found: 0");
}
void findForm::recordSelected( Q3ListViewItem * witem)
{
if (witem) {
int recNum = (witem->text(0)).toInt() ;
emit showrecord(recNum);
}
}
void findForm::closeEvent( QCloseEvent * )
{
emit goingAway();
}
+204
View File
@@ -0,0 +1,204 @@
#ifndef FINDFORM_H
#define FINDFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3Header>
#include <Qt3Support/Q3ListView>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include "sqlitedb.h"
QT_BEGIN_NAMESPACE
class Ui_findForm
{
public:
QVBoxLayout *vboxLayout;
QGridLayout *gridLayout;
QPushButton *searchButton;
QComboBox *findFieldCombobox;
QLineEdit *searchLine;
QComboBox *findOperatorComboBox;
Q3ListView *findListView;
QHBoxLayout *hboxLayout;
QLabel *resultsLabel;
QSpacerItem *spacer10;
void setupUi(QDialog *findForm)
{
if (findForm->objectName().isEmpty())
findForm->setObjectName(QString::fromUtf8("findForm"));
findForm->resize(239, 319);
vboxLayout = new QVBoxLayout(findForm);
vboxLayout->setSpacing(6);
vboxLayout->setMargin(11);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
gridLayout = new QGridLayout();
gridLayout->setSpacing(6);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
searchButton = new QPushButton(findForm);
searchButton->setObjectName(QString::fromUtf8("searchButton"));
gridLayout->addWidget(searchButton, 1, 2, 1, 1);
findFieldCombobox = new QComboBox(findForm);
findFieldCombobox->setObjectName(QString::fromUtf8("findFieldCombobox"));
gridLayout->addWidget(findFieldCombobox, 0, 0, 1, 1);
searchLine = new QLineEdit(findForm);
searchLine->setObjectName(QString::fromUtf8("searchLine"));
gridLayout->addWidget(searchLine, 1, 0, 1, 2);
findOperatorComboBox = new QComboBox(findForm);
findOperatorComboBox->setObjectName(QString::fromUtf8("findOperatorComboBox"));
gridLayout->addWidget(findOperatorComboBox, 0, 1, 1, 2);
vboxLayout->addLayout(gridLayout);
findListView = new Q3ListView(findForm);
findListView->addColumn(QApplication::translate("findForm", "Record", 0, QApplication::UnicodeUTF8));
findListView->header()->setClickEnabled(true, findListView->header()->count() - 1);
findListView->header()->setResizeEnabled(true, findListView->header()->count() - 1);
findListView->addColumn(QApplication::translate("findForm", "Data", 0, QApplication::UnicodeUTF8));
findListView->header()->setClickEnabled(true, findListView->header()->count() - 1);
findListView->header()->setResizeEnabled(true, findListView->header()->count() - 1);
findListView->setObjectName(QString::fromUtf8("findListView"));
findListView->setMidLineWidth(30);
findListView->setResizePolicy(Q3ScrollView::Manual);
findListView->setResizeMode(Q3ListView::LastColumn);
vboxLayout->addWidget(findListView);
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
resultsLabel = new QLabel(findForm);
resultsLabel->setObjectName(QString::fromUtf8("resultsLabel"));
QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(7), static_cast<QSizePolicy::Policy>(5));
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(resultsLabel->sizePolicy().hasHeightForWidth());
resultsLabel->setSizePolicy(sizePolicy);
resultsLabel->setWordWrap(false);
hboxLayout->addWidget(resultsLabel);
spacer10 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacer10);
vboxLayout->addLayout(hboxLayout);
retranslateUi(findForm);
QObject::connect(searchButton, SIGNAL(clicked()), findForm, SLOT(find()));
QObject::connect(findListView, SIGNAL(clicked(Q3ListViewItem*)), findForm, SLOT(recordSelected(Q3ListViewItem*)));
QMetaObject::connectSlotsByName(findForm);
} // setupUi
void retranslateUi(QDialog *findForm)
{
findForm->setWindowTitle(QApplication::translate("findForm", "Find", 0, QApplication::UnicodeUTF8));
searchButton->setText(QApplication::translate("findForm", "Search", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
searchButton->setProperty("toolTip", QVariant(QApplication::translate("findForm", "Perform the search", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
searchButton->setProperty("whatsThis", QVariant(QApplication::translate("findForm", "This button starts the search process", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
findFieldCombobox->clear();
findFieldCombobox->insertItems(0, QStringList()
<< QApplication::translate("findForm", "user", 0, QApplication::UnicodeUTF8)
);
#ifndef QT_NO_TOOLTIP
findFieldCombobox->setProperty("toolTip", QVariant(QApplication::translate("findForm", "Field to be searched", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
findFieldCombobox->setProperty("whatsThis", QVariant(QApplication::translate("findForm", "Use this control to select the field to be searched in the current table", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
#ifndef QT_NO_TOOLTIP
searchLine->setProperty("toolTip", QVariant(QApplication::translate("findForm", "Enter values or words to search", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
searchLine->setProperty("whatsThis", QVariant(QApplication::translate("findForm", "This is a place to enter the word or number to be searched in the database", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
findOperatorComboBox->clear();
findOperatorComboBox->insertItems(0, QStringList()
<< QApplication::translate("findForm", "=", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("findForm", "contains", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("findForm", ">", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("findForm", ">=", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("findForm", "<=", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("findForm", "<", 0, QApplication::UnicodeUTF8)
);
#ifndef QT_NO_TOOLTIP
findOperatorComboBox->setProperty("toolTip", QVariant(QApplication::translate("findForm", "Search criteria: use 'contains' for partial matches", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
findOperatorComboBox->setProperty("whatsThis", QVariant(QApplication::translate("findForm", "This control is used to select the search criteria used to look for the search term in the database. Use '=' or 'contains' to find words, and the comparison symbols to filter numeric data.", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
findListView->header()->setLabel(0, QApplication::translate("findForm", "Record", 0, QApplication::UnicodeUTF8));
findListView->header()->setLabel(1, QApplication::translate("findForm", "Data", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_WHATSTHIS
findListView->setProperty("whatsThis", QVariant(QApplication::translate("findForm", "Results of the search will appear in this area. Click on a result to select the corresponding record in the database", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
resultsLabel->setText(QApplication::translate("findForm", "Found:", 0, QApplication::UnicodeUTF8));
Q_UNUSED(findForm);
} // retranslateUi
};
namespace Ui {
class findForm: public Ui_findForm {};
} // namespace Ui
QT_END_NAMESPACE
class findForm : public QDialog, public Ui::findForm
{
Q_OBJECT
public:
findForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~findForm();
public slots:
virtual void showResults( resultMap rmap );
virtual void find();
virtual void resetFields( QStringList fieldlist );
virtual void resetResults();
virtual void recordSelected( Q3ListViewItem * witem );
virtual void closeEvent( QCloseEvent * );
signals:
void lookfor(const QString&, const QString&, const QString&);
void showrecord(int);
void goingAway();
protected slots:
virtual void languageChange();
};
#endif // FINDFORM_H
-68
View File
@@ -1,68 +0,0 @@
//Added by qt3to4:
#include <QCloseEvent>
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void findForm::showResults(resultMap rmap)
{
findListView->clear();
findListView->setSorting(-1);
resultMap::Iterator it;
Q3ListViewItem * lasttbitem = 0;
for ( it = rmap.begin(); it != rmap.end(); ++it ) {
Q3ListViewItem * tbitem = new Q3ListViewItem( findListView, lasttbitem );
//tbitem->setOpen( TRUE );
tbitem->setText( 0, QString::number(it.key() + 1,10) ); //increase from index 0
QString firstline = it.data().section( '\n', 0,0 );
if (firstline.length()>MAX_DISPLAY_LENGTH)
{
firstline.truncate(MAX_DISPLAY_LENGTH);
firstline.append("...");
}
tbitem->setText( 1, firstline );
lasttbitem = tbitem;
}
QString results = "Found: ";
results.append(QString::number(findListView->childCount()));
resultsLabel->setText(results);
}
void findForm::find()
{
emit lookfor( findFieldCombobox->currentText(), findOperatorComboBox->currentText(),searchLine->text() );
}
void findForm::resetFields(QStringList fieldlist)
{
findFieldCombobox->clear();
for ( QStringList::Iterator ct = fieldlist.begin(); ct != fieldlist.end(); ++ct ) {
findFieldCombobox->insertItem(*ct,-1);
}
}
void findForm::resetResults()
{
findListView->clear();
resultsLabel->setText("Found: 0");
}
void findForm::recordSelected( Q3ListViewItem * witem)
{
if (witem) {
int recNum = (witem->text(0)).toInt() ;
emit showrecord(recNum);
}
}
void findForm::closeEvent( QCloseEvent * )
{
emit goingAway();
}
+54 -12
View File
@@ -1,20 +1,60 @@
//Added by qt3to4:
#include <q3mimefactory.h>
#include <QCloseEvent>
#include "form1.h"
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.h>
#include <Q3TextStream>
#include <Q3WhatsThis>
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
#include "qmessagebox.h"
#include "q3filedialog.h"
#include "qfile.h"
#include "qapplication.h"
#include "createtableform.h"
#include "createindexform.h"
#include "deletetableform.h"
#include "deleteindexform.h"
#include "aboutform.h"
#include "choosetableform.h"
#include "edittableform.h"
#include "importcsvform.h"
#include "exporttablecsvform.h"
/*
* Constructs a mainForm as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
*/
mainForm::mainForm(QWidget* parent, const char* name, Qt::WindowFlags fl)
: Q3MainWindow(parent, name, fl)
{
setupUi(this);
(void)statusBar();
init();
}
/*
* Destroys the object and frees any allocated resources
*/
mainForm::~mainForm()
{
destroy();
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void mainForm::languageChange()
{
retranslateUi(this);
}
void mainForm::init()
{
findWin = 0;
findWin = 0;
editWin = 0;
logWin = 0;
@@ -1093,3 +1133,5 @@ void mainForm::importDatabaseFromSQL()
resetBrowser();
}
}
+888
View File
@@ -0,0 +1,888 @@
#ifndef MAINFORM_H
#define MAINFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3Header>
#include <Qt3Support/Q3ListView>
#include <Qt3Support/Q3MainWindow>
#include <Qt3Support/Q3MimeSourceFactory>
#include <Qt3Support/Q3Table>
#include <Qt3Support/Q3TextEdit>
#include <Qt3Support/Q3ToolBar>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QTabWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
#include "editform.h"
#include "findform.h"
#include "QtGui/QClipboard"
#include "QtGui/QRegExpValidator"
#include "sqlitedb.h"
#include "sqllogform.h"
QT_BEGIN_NAMESPACE
class Ui_mainForm
{
public:
QAction *fileNewAction;
QAction *fileOpenAction;
QAction *fileExitAction;
QAction *editCopyAction;
QAction *editPasteAction;
QAction *editFindAction;
QAction *helpContentsAction;
QAction *helpIndexAction;
QAction *helpAboutAction;
QAction *fileCloseAction;
QAction *newRecordAction;
QAction *fileCompactAction;
QAction *helpWhatsThisAction;
QAction *sqlLogAction;
QAction *fileImportCSVAction;
QAction *fileExportCSVAction;
QAction *fileSaveAction;
QAction *fileRevertAction;
QAction *fileImportAction;
QAction *fileExportAction;
QAction *editCreateTableAction;
QAction *editDeleteTableAction;
QAction *editModifyTableAction;
QAction *editCreateIndexAction;
QAction *editDeleteIndexAction;
QAction *fileImportSQLAction;
QAction *fileExportSQLAction;
QWidget *widget;
QVBoxLayout *vboxLayout;
QTabWidget *mainTab;
QWidget *structure;
QVBoxLayout *vboxLayout1;
Q3ListView *dblistView;
QWidget *browser;
QVBoxLayout *vboxLayout2;
QHBoxLayout *hboxLayout;
QLabel *textLabel1;
QComboBox *comboBrowseTable;
QPushButton *buttonFind;
QSpacerItem *spacer1;
QPushButton *buttonNewRecord;
QPushButton *buttonDeleteRecord;
Q3Table *dataTable;
QHBoxLayout *hboxLayout1;
QPushButton *buttonPrevious;
QLabel *labelRecordset;
QPushButton *buttonNext;
QSpacerItem *spacer4;
QPushButton *buttonGoto;
QLineEdit *editGoto;
QWidget *query;
QVBoxLayout *vboxLayout3;
QLabel *textLabel1_2;
Q3TextEdit *sqlTextEdit;
QHBoxLayout *hboxLayout2;
QPushButton *executeQueryButton;
QSpacerItem *spacer4_2;
QLabel *textLabel2;
QLineEdit *queryErrorLineEdit;
QLabel *textLabel3;
Q3ListView *queryResultListView;
Q3ToolBar *Toolbar;
QMenuBar *menubar;
QMenu *fileMenu;
QMenu *PopupMenuEditor_9;
QMenu *PopupMenuEditor_12;
QMenu *EditMenu;
QMenu *ViewMenu;
QMenu *PopupMenu;
void setupUi(Q3MainWindow *mainForm)
{
if (mainForm->objectName().isEmpty())
mainForm->setObjectName(QString::fromUtf8("mainForm"));
mainForm->resize(702, 552);
fileNewAction = new QAction(mainForm);
fileNewAction->setObjectName(QString::fromUtf8("fileNewAction"));
fileNewAction->setName("fileNewAction");
const QIcon icon = QIcon(qPixmapFromMimeSource("new.png"));
fileNewAction->setIcon(icon);
fileOpenAction = new QAction(mainForm);
fileOpenAction->setObjectName(QString::fromUtf8("fileOpenAction"));
fileOpenAction->setName("fileOpenAction");
const QIcon icon1 = QIcon(qPixmapFromMimeSource("open.png"));
fileOpenAction->setIcon(icon1);
fileExitAction = new QAction(mainForm);
fileExitAction->setObjectName(QString::fromUtf8("fileExitAction"));
fileExitAction->setName("fileExitAction");
editCopyAction = new QAction(mainForm);
editCopyAction->setObjectName(QString::fromUtf8("editCopyAction"));
editCopyAction->setName("editCopyAction");
editPasteAction = new QAction(mainForm);
editPasteAction->setObjectName(QString::fromUtf8("editPasteAction"));
editPasteAction->setName("editPasteAction");
editFindAction = new QAction(mainForm);
editFindAction->setObjectName(QString::fromUtf8("editFindAction"));
editFindAction->setName("editFindAction");
const QIcon icon2 = QIcon(qPixmapFromMimeSource("searchfind.png"));
editFindAction->setIcon(icon2);
helpContentsAction = new QAction(mainForm);
helpContentsAction->setObjectName(QString::fromUtf8("helpContentsAction"));
helpContentsAction->setName("helpContentsAction");
helpIndexAction = new QAction(mainForm);
helpIndexAction->setObjectName(QString::fromUtf8("helpIndexAction"));
helpIndexAction->setName("helpIndexAction");
helpAboutAction = new QAction(mainForm);
helpAboutAction->setObjectName(QString::fromUtf8("helpAboutAction"));
helpAboutAction->setName("helpAboutAction");
fileCloseAction = new QAction(mainForm);
fileCloseAction->setObjectName(QString::fromUtf8("fileCloseAction"));
fileCloseAction->setName("fileCloseAction");
fileCloseAction->setEnabled(false);
newRecordAction = new QAction(mainForm);
newRecordAction->setObjectName(QString::fromUtf8("newRecordAction"));
newRecordAction->setName("newRecordAction");
fileCompactAction = new QAction(mainForm);
fileCompactAction->setObjectName(QString::fromUtf8("fileCompactAction"));
fileCompactAction->setName("fileCompactAction");
fileCompactAction->setEnabled(false);
helpWhatsThisAction = new QAction(mainForm);
helpWhatsThisAction->setObjectName(QString::fromUtf8("helpWhatsThisAction"));
helpWhatsThisAction->setName("helpWhatsThisAction");
const QIcon icon3 = QIcon(qPixmapFromMimeSource("whatis.png"));
helpWhatsThisAction->setIcon(icon3);
sqlLogAction = new QAction(mainForm);
sqlLogAction->setObjectName(QString::fromUtf8("sqlLogAction"));
sqlLogAction->setName("sqlLogAction");
sqlLogAction->setCheckable(true);
const QIcon icon4 = QIcon(qPixmapFromMimeSource("log.png"));
sqlLogAction->setIcon(icon4);
fileImportCSVAction = new QAction(mainForm);
fileImportCSVAction->setObjectName(QString::fromUtf8("fileImportCSVAction"));
fileImportCSVAction->setName("fileImportCSVAction");
fileExportCSVAction = new QAction(mainForm);
fileExportCSVAction->setObjectName(QString::fromUtf8("fileExportCSVAction"));
fileExportCSVAction->setName("fileExportCSVAction");
fileSaveAction = new QAction(mainForm);
fileSaveAction->setObjectName(QString::fromUtf8("fileSaveAction"));
fileSaveAction->setName("fileSaveAction");
fileSaveAction->setEnabled(false);
const QIcon icon5 = QIcon(qPixmapFromMimeSource("save.png"));
fileSaveAction->setIcon(icon5);
fileRevertAction = new QAction(mainForm);
fileRevertAction->setObjectName(QString::fromUtf8("fileRevertAction"));
fileRevertAction->setName("fileRevertAction");
fileRevertAction->setEnabled(false);
const QIcon icon6 = QIcon(qPixmapFromMimeSource("revert.png"));
fileRevertAction->setIcon(icon6);
fileImportAction = new QAction(mainForm);
fileImportAction->setObjectName(QString::fromUtf8("fileImportAction"));
fileImportAction->setName("fileImportAction");
fileExportAction = new QAction(mainForm);
fileExportAction->setObjectName(QString::fromUtf8("fileExportAction"));
fileExportAction->setName("fileExportAction");
editCreateTableAction = new QAction(mainForm);
editCreateTableAction->setObjectName(QString::fromUtf8("editCreateTableAction"));
editCreateTableAction->setName("editCreateTableAction");
editCreateTableAction->setEnabled(false);
const QIcon icon7 = QIcon(qPixmapFromMimeSource("create_table.png"));
editCreateTableAction->setIcon(icon7);
editDeleteTableAction = new QAction(mainForm);
editDeleteTableAction->setObjectName(QString::fromUtf8("editDeleteTableAction"));
editDeleteTableAction->setName("editDeleteTableAction");
editDeleteTableAction->setEnabled(false);
const QIcon icon8 = QIcon(qPixmapFromMimeSource("delete_table.png"));
editDeleteTableAction->setIcon(icon8);
editModifyTableAction = new QAction(mainForm);
editModifyTableAction->setObjectName(QString::fromUtf8("editModifyTableAction"));
editModifyTableAction->setName("editModifyTableAction");
editModifyTableAction->setEnabled(false);
const QIcon icon9 = QIcon(qPixmapFromMimeSource("modify_table.png"));
editModifyTableAction->setIcon(icon9);
editCreateIndexAction = new QAction(mainForm);
editCreateIndexAction->setObjectName(QString::fromUtf8("editCreateIndexAction"));
editCreateIndexAction->setName("editCreateIndexAction");
editCreateIndexAction->setEnabled(false);
const QIcon icon10 = QIcon(qPixmapFromMimeSource("create_index.png"));
editCreateIndexAction->setIcon(icon10);
editDeleteIndexAction = new QAction(mainForm);
editDeleteIndexAction->setObjectName(QString::fromUtf8("editDeleteIndexAction"));
editDeleteIndexAction->setName("editDeleteIndexAction");
editDeleteIndexAction->setEnabled(false);
const QIcon icon11 = QIcon(qPixmapFromMimeSource("delete_index.png"));
editDeleteIndexAction->setIcon(icon11);
fileImportSQLAction = new QAction(mainForm);
fileImportSQLAction->setObjectName(QString::fromUtf8("fileImportSQLAction"));
fileImportSQLAction->setName("fileImportSQLAction");
fileExportSQLAction = new QAction(mainForm);
fileExportSQLAction->setObjectName(QString::fromUtf8("fileExportSQLAction"));
fileExportSQLAction->setName("fileExportSQLAction");
widget = new QWidget(mainForm);
widget->setObjectName(QString::fromUtf8("widget"));
vboxLayout = new QVBoxLayout(widget);
vboxLayout->setSpacing(6);
vboxLayout->setMargin(11);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
vboxLayout->setContentsMargins(0, 0, 0, 0);
mainTab = new QTabWidget(widget);
mainTab->setObjectName(QString::fromUtf8("mainTab"));
structure = new QWidget();
structure->setObjectName(QString::fromUtf8("structure"));
vboxLayout1 = new QVBoxLayout(structure);
vboxLayout1->setSpacing(6);
vboxLayout1->setMargin(11);
vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1"));
dblistView = new Q3ListView(structure);
dblistView->addColumn(QApplication::translate("mainForm", "Name", 0, QApplication::UnicodeUTF8));
dblistView->header()->setClickEnabled(false, dblistView->header()->count() - 1);
dblistView->header()->setResizeEnabled(true, dblistView->header()->count() - 1);
dblistView->addColumn(QApplication::translate("mainForm", "Object", 0, QApplication::UnicodeUTF8));
dblistView->header()->setClickEnabled(false, dblistView->header()->count() - 1);
dblistView->header()->setResizeEnabled(true, dblistView->header()->count() - 1);
dblistView->addColumn(QApplication::translate("mainForm", "Type", 0, QApplication::UnicodeUTF8));
dblistView->header()->setClickEnabled(false, dblistView->header()->count() - 1);
dblistView->header()->setResizeEnabled(true, dblistView->header()->count() - 1);
dblistView->addColumn(QApplication::translate("mainForm", "Schema", 0, QApplication::UnicodeUTF8));
dblistView->header()->setClickEnabled(false, dblistView->header()->count() - 1);
dblistView->header()->setResizeEnabled(true, dblistView->header()->count() - 1);
dblistView->setObjectName(QString::fromUtf8("dblistView"));
dblistView->setResizePolicy(Q3ScrollView::Manual);
dblistView->setSelectionMode(Q3ListView::NoSelection);
dblistView->setRootIsDecorated(true);
dblistView->setResizeMode(Q3ListView::LastColumn);
vboxLayout1->addWidget(dblistView);
mainTab->addTab(structure, QString());
browser = new QWidget();
browser->setObjectName(QString::fromUtf8("browser"));
vboxLayout2 = new QVBoxLayout(browser);
vboxLayout2->setSpacing(6);
vboxLayout2->setMargin(11);
vboxLayout2->setObjectName(QString::fromUtf8("vboxLayout2"));
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
textLabel1 = new QLabel(browser);
textLabel1->setObjectName(QString::fromUtf8("textLabel1"));
textLabel1->setWordWrap(false);
hboxLayout->addWidget(textLabel1);
comboBrowseTable = new QComboBox(browser);
comboBrowseTable->setObjectName(QString::fromUtf8("comboBrowseTable"));
comboBrowseTable->setMinimumSize(QSize(115, 0));
hboxLayout->addWidget(comboBrowseTable);
buttonFind = new QPushButton(browser);
buttonFind->setObjectName(QString::fromUtf8("buttonFind"));
buttonFind->setIcon(QPixmap(qPixmapFromMimeSource("searchfind.png")));
buttonFind->setCheckable(true);
hboxLayout->addWidget(buttonFind);
spacer1 = new QSpacerItem(51, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacer1);
buttonNewRecord = new QPushButton(browser);
buttonNewRecord->setObjectName(QString::fromUtf8("buttonNewRecord"));
hboxLayout->addWidget(buttonNewRecord);
buttonDeleteRecord = new QPushButton(browser);
buttonDeleteRecord->setObjectName(QString::fromUtf8("buttonDeleteRecord"));
hboxLayout->addWidget(buttonDeleteRecord);
vboxLayout2->addLayout(hboxLayout);
dataTable = new Q3Table(browser);
dataTable->setObjectName(QString::fromUtf8("dataTable"));
dataTable->setAcceptDrops(true);
dataTable->setResizePolicy(Q3Table::Default);
dataTable->setVScrollBarMode(Q3Table::Auto);
dataTable->setNumRows(0);
dataTable->setNumCols(0);
dataTable->setReadOnly(true);
dataTable->setSelectionMode(Q3Table::Single);
dataTable->setFocusStyle(Q3Table::FollowStyle);
vboxLayout2->addWidget(dataTable);
hboxLayout1 = new QHBoxLayout();
hboxLayout1->setSpacing(6);
hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
buttonPrevious = new QPushButton(browser);
buttonPrevious->setObjectName(QString::fromUtf8("buttonPrevious"));
QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(0), static_cast<QSizePolicy::Policy>(0));
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(buttonPrevious->sizePolicy().hasHeightForWidth());
buttonPrevious->setSizePolicy(sizePolicy);
hboxLayout1->addWidget(buttonPrevious);
labelRecordset = new QLabel(browser);
labelRecordset->setObjectName(QString::fromUtf8("labelRecordset"));
labelRecordset->setWordWrap(false);
hboxLayout1->addWidget(labelRecordset);
buttonNext = new QPushButton(browser);
buttonNext->setObjectName(QString::fromUtf8("buttonNext"));
sizePolicy.setHeightForWidth(buttonNext->sizePolicy().hasHeightForWidth());
buttonNext->setSizePolicy(sizePolicy);
hboxLayout1->addWidget(buttonNext);
spacer4 = new QSpacerItem(50, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout1->addItem(spacer4);
buttonGoto = new QPushButton(browser);
buttonGoto->setObjectName(QString::fromUtf8("buttonGoto"));
hboxLayout1->addWidget(buttonGoto);
editGoto = new QLineEdit(browser);
editGoto->setObjectName(QString::fromUtf8("editGoto"));
sizePolicy.setHeightForWidth(editGoto->sizePolicy().hasHeightForWidth());
editGoto->setSizePolicy(sizePolicy);
hboxLayout1->addWidget(editGoto);
vboxLayout2->addLayout(hboxLayout1);
mainTab->addTab(browser, QString());
query = new QWidget();
query->setObjectName(QString::fromUtf8("query"));
vboxLayout3 = new QVBoxLayout(query);
vboxLayout3->setSpacing(6);
vboxLayout3->setMargin(11);
vboxLayout3->setObjectName(QString::fromUtf8("vboxLayout3"));
textLabel1_2 = new QLabel(query);
textLabel1_2->setObjectName(QString::fromUtf8("textLabel1_2"));
textLabel1_2->setWordWrap(false);
vboxLayout3->addWidget(textLabel1_2);
sqlTextEdit = new Q3TextEdit(query);
sqlTextEdit->setObjectName(QString::fromUtf8("sqlTextEdit"));
QSizePolicy sizePolicy1(static_cast<QSizePolicy::Policy>(7), static_cast<QSizePolicy::Policy>(5));
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(sqlTextEdit->sizePolicy().hasHeightForWidth());
sqlTextEdit->setSizePolicy(sizePolicy1);
vboxLayout3->addWidget(sqlTextEdit);
hboxLayout2 = new QHBoxLayout();
hboxLayout2->setSpacing(6);
hboxLayout2->setObjectName(QString::fromUtf8("hboxLayout2"));
executeQueryButton = new QPushButton(query);
executeQueryButton->setObjectName(QString::fromUtf8("executeQueryButton"));
hboxLayout2->addWidget(executeQueryButton);
spacer4_2 = new QSpacerItem(325, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout2->addItem(spacer4_2);
vboxLayout3->addLayout(hboxLayout2);
textLabel2 = new QLabel(query);
textLabel2->setObjectName(QString::fromUtf8("textLabel2"));
textLabel2->setWordWrap(false);
vboxLayout3->addWidget(textLabel2);
queryErrorLineEdit = new QLineEdit(query);
queryErrorLineEdit->setObjectName(QString::fromUtf8("queryErrorLineEdit"));
queryErrorLineEdit->setReadOnly(true);
vboxLayout3->addWidget(queryErrorLineEdit);
textLabel3 = new QLabel(query);
textLabel3->setObjectName(QString::fromUtf8("textLabel3"));
textLabel3->setWordWrap(false);
vboxLayout3->addWidget(textLabel3);
queryResultListView = new Q3ListView(query);
queryResultListView->setObjectName(QString::fromUtf8("queryResultListView"));
queryResultListView->setResizePolicy(Q3ScrollView::Default);
queryResultListView->setSelectionMode(Q3ListView::NoSelection);
queryResultListView->setResizeMode(Q3ListView::AllColumns);
vboxLayout3->addWidget(queryResultListView);
mainTab->addTab(query, QString());
vboxLayout->addWidget(mainTab);
mainForm->setCentralWidget(widget);
Toolbar = new Q3ToolBar(mainForm);
Toolbar->setObjectName(QString::fromUtf8("Toolbar"));
menubar = new QMenuBar(mainForm);
menubar->setObjectName(QString::fromUtf8("menubar"));
fileMenu = new QMenu(menubar);
fileMenu->setObjectName(QString::fromUtf8("fileMenu"));
PopupMenuEditor_9 = new QMenu(fileMenu);
PopupMenuEditor_9->setObjectName(QString::fromUtf8("PopupMenuEditor_9"));
PopupMenuEditor_12 = new QMenu(fileMenu);
PopupMenuEditor_12->setObjectName(QString::fromUtf8("PopupMenuEditor_12"));
EditMenu = new QMenu(menubar);
EditMenu->setObjectName(QString::fromUtf8("EditMenu"));
ViewMenu = new QMenu(menubar);
ViewMenu->setObjectName(QString::fromUtf8("ViewMenu"));
PopupMenu = new QMenu(menubar);
PopupMenu->setObjectName(QString::fromUtf8("PopupMenu"));
Toolbar->addAction(fileNewAction);
Toolbar->addAction(fileOpenAction);
Toolbar->addAction(fileSaveAction);
Toolbar->addAction(fileRevertAction);
Toolbar->addSeparator();
Toolbar->addAction(editCreateTableAction);
Toolbar->addAction(editDeleteTableAction);
Toolbar->addAction(editModifyTableAction);
Toolbar->addAction(editCreateIndexAction);
Toolbar->addAction(editDeleteIndexAction);
Toolbar->addSeparator();
Toolbar->addAction(sqlLogAction);
Toolbar->addSeparator();
Toolbar->addAction(helpWhatsThisAction);
menubar->addAction(fileMenu->menuAction());
menubar->addAction(EditMenu->menuAction());
menubar->addAction(ViewMenu->menuAction());
menubar->addAction(PopupMenu->menuAction());
fileMenu->addAction(fileNewAction);
fileMenu->addAction(fileOpenAction);
fileMenu->addAction(fileCloseAction);
fileMenu->addSeparator();
fileMenu->addAction(fileSaveAction);
fileMenu->addAction(fileRevertAction);
fileMenu->addAction(fileCompactAction);
fileMenu->addSeparator();
fileMenu->addAction(fileImportAction);
fileMenu->addAction(PopupMenuEditor_9->menuAction());
fileMenu->addAction(fileExportAction);
fileMenu->addAction(PopupMenuEditor_12->menuAction());
fileMenu->addSeparator();
fileMenu->addAction(fileExitAction);
PopupMenuEditor_9->addAction(fileImportSQLAction);
PopupMenuEditor_9->addAction(fileImportCSVAction);
PopupMenuEditor_12->addAction(fileExportSQLAction);
PopupMenuEditor_12->addAction(fileExportCSVAction);
EditMenu->addAction(editCreateTableAction);
EditMenu->addAction(editDeleteTableAction);
EditMenu->addAction(editModifyTableAction);
EditMenu->addSeparator();
EditMenu->addAction(editCreateIndexAction);
EditMenu->addAction(editDeleteIndexAction);
ViewMenu->addAction(sqlLogAction);
PopupMenu->addAction(helpWhatsThisAction);
PopupMenu->addAction(helpAboutAction);
retranslateUi(mainForm);
QObject::connect(fileExitAction, SIGNAL(activated()), mainForm, SLOT(fileExit()));
QObject::connect(fileOpenAction, SIGNAL(activated()), mainForm, SLOT(fileOpen()));
QObject::connect(fileNewAction, SIGNAL(activated()), mainForm, SLOT(fileNew()));
QObject::connect(fileCloseAction, SIGNAL(activated()), mainForm, SLOT(fileClose()));
QObject::connect(comboBrowseTable, SIGNAL(activated(QString)), mainForm, SLOT(populateTable(QString)));
QObject::connect(buttonNewRecord, SIGNAL(clicked()), mainForm, SLOT(addRecord()));
QObject::connect(buttonDeleteRecord, SIGNAL(clicked()), mainForm, SLOT(deleteRecord()));
QObject::connect(buttonPrevious, SIGNAL(clicked()), mainForm, SLOT(navigatePrevious()));
QObject::connect(buttonNext, SIGNAL(clicked()), mainForm, SLOT(navigateNext()));
QObject::connect(editGoto, SIGNAL(returnPressed()), mainForm, SLOT(navigateGoto()));
QObject::connect(buttonGoto, SIGNAL(clicked()), mainForm, SLOT(navigateGoto()));
QObject::connect(buttonFind, SIGNAL(toggled(bool)), mainForm, SLOT(browseFind(bool)));
QObject::connect(fileCompactAction, SIGNAL(activated()), mainForm, SLOT(compact()));
QObject::connect(editCopyAction, SIGNAL(activated()), mainForm, SLOT(copy()));
QObject::connect(editPasteAction, SIGNAL(activated()), mainForm, SLOT(paste()));
QObject::connect(helpWhatsThisAction, SIGNAL(activated()), mainForm, SLOT(helpWhatsThis()));
QObject::connect(helpAboutAction, SIGNAL(activated()), mainForm, SLOT(helpAbout()));
QObject::connect(dataTable, SIGNAL(doubleClicked(int,int,int,QPoint)), mainForm, SLOT(doubleClickTable(int,int,int,QPoint)));
QObject::connect(mainTab, SIGNAL(selected(QString)), mainForm, SLOT(mainTabSelected(QString)));
QObject::connect(sqlLogAction, SIGNAL(toggled(bool)), mainForm, SLOT(toggleLogWindow(bool)));
QObject::connect(executeQueryButton, SIGNAL(clicked()), mainForm, SLOT(executeQuery()));
QObject::connect(fileImportCSVAction, SIGNAL(activated()), mainForm, SLOT(importTableFromCSV()));
QObject::connect(fileExportCSVAction, SIGNAL(activated()), mainForm, SLOT(exportTableToCSV()));
QObject::connect(fileRevertAction, SIGNAL(activated()), mainForm, SLOT(fileRevert()));
QObject::connect(fileSaveAction, SIGNAL(activated()), mainForm, SLOT(fileSave()));
QObject::connect(editDeleteIndexAction, SIGNAL(activated()), mainForm, SLOT(deleteIndex()));
QObject::connect(editCreateIndexAction, SIGNAL(activated()), mainForm, SLOT(createIndex()));
QObject::connect(editCreateTableAction, SIGNAL(activated()), mainForm, SLOT(createTable()));
QObject::connect(editDeleteTableAction, SIGNAL(activated()), mainForm, SLOT(deleteTable()));
QObject::connect(editModifyTableAction, SIGNAL(activated()), mainForm, SLOT(editTable()));
QObject::connect(fileExportSQLAction, SIGNAL(activated()), mainForm, SLOT(exportDatabaseToSQL()));
QObject::connect(fileImportSQLAction, SIGNAL(activated()), mainForm, SLOT(importDatabaseFromSQL()));
QMetaObject::connectSlotsByName(mainForm);
} // setupUi
void retranslateUi(Q3MainWindow *mainForm)
{
mainForm->setWindowTitle(QApplication::translate("mainForm", "Browser", 0, QApplication::UnicodeUTF8));
fileNewAction->setIconText(QApplication::translate("mainForm", "New Database", 0, QApplication::UnicodeUTF8));
fileNewAction->setText(QApplication::translate("mainForm", "&New Database", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
fileNewAction->setToolTip(QApplication::translate("mainForm", "Create a new database file", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
fileNewAction->setWhatsThis(QApplication::translate("mainForm", "This option is used to create a new database file.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
fileNewAction->setShortcut(QApplication::translate("mainForm", "Ctrl+N", 0, QApplication::UnicodeUTF8));
fileOpenAction->setIconText(QApplication::translate("mainForm", "Open Database", 0, QApplication::UnicodeUTF8));
fileOpenAction->setText(QApplication::translate("mainForm", "&Open Database", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
fileOpenAction->setToolTip(QApplication::translate("mainForm", "Open an existing database file", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
fileOpenAction->setWhatsThis(QApplication::translate("mainForm", "This option is used to open an existing database file.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
fileOpenAction->setShortcut(QApplication::translate("mainForm", "Ctrl+O", 0, QApplication::UnicodeUTF8));
fileExitAction->setIconText(QApplication::translate("mainForm", "Exit", 0, QApplication::UnicodeUTF8));
fileExitAction->setText(QApplication::translate("mainForm", "E&xit", 0, QApplication::UnicodeUTF8));
fileExitAction->setShortcut(QString());
editCopyAction->setIconText(QApplication::translate("mainForm", "Copy", 0, QApplication::UnicodeUTF8));
editCopyAction->setText(QApplication::translate("mainForm", "&Copy", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_WHATSTHIS
editCopyAction->setWhatsThis(QApplication::translate("mainForm", "Copies the selected text to the clipboard", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
editCopyAction->setShortcut(QApplication::translate("mainForm", "Ctrl+C", 0, QApplication::UnicodeUTF8));
editPasteAction->setIconText(QApplication::translate("mainForm", "Paste", 0, QApplication::UnicodeUTF8));
editPasteAction->setText(QApplication::translate("mainForm", "&Paste", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_WHATSTHIS
editPasteAction->setWhatsThis(QApplication::translate("mainForm", "Pastes text from the clipboard into the current text insertion point", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
editPasteAction->setShortcut(QApplication::translate("mainForm", "Ctrl+V", 0, QApplication::UnicodeUTF8));
editFindAction->setIconText(QApplication::translate("mainForm", "Find", 0, QApplication::UnicodeUTF8));
editFindAction->setText(QApplication::translate("mainForm", "&Find...", 0, QApplication::UnicodeUTF8));
editFindAction->setShortcut(QApplication::translate("mainForm", "F", 0, QApplication::UnicodeUTF8));
helpContentsAction->setIconText(QApplication::translate("mainForm", "Contents", 0, QApplication::UnicodeUTF8));
helpContentsAction->setText(QApplication::translate("mainForm", "&Contents...", 0, QApplication::UnicodeUTF8));
helpContentsAction->setShortcut(QString());
helpIndexAction->setIconText(QApplication::translate("mainForm", "Index", 0, QApplication::UnicodeUTF8));
helpIndexAction->setText(QApplication::translate("mainForm", "&Index...", 0, QApplication::UnicodeUTF8));
helpIndexAction->setShortcut(QString());
helpAboutAction->setIconText(QApplication::translate("mainForm", "About", 0, QApplication::UnicodeUTF8));
helpAboutAction->setText(QApplication::translate("mainForm", "&About", 0, QApplication::UnicodeUTF8));
helpAboutAction->setShortcut(QString());
fileCloseAction->setIconText(QApplication::translate("mainForm", "Close Database", 0, QApplication::UnicodeUTF8));
fileCloseAction->setText(QApplication::translate("mainForm", "Close Database", 0, QApplication::UnicodeUTF8));
newRecordAction->setIconText(QApplication::translate("mainForm", "New Record", 0, QApplication::UnicodeUTF8));
newRecordAction->setText(QApplication::translate("mainForm", "New Record", 0, QApplication::UnicodeUTF8));
fileCompactAction->setIconText(QApplication::translate("mainForm", "Compact Database", 0, QApplication::UnicodeUTF8));
fileCompactAction->setText(QApplication::translate("mainForm", "Compact Database", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_STATUSTIP
fileCompactAction->setStatusTip(QApplication::translate("mainForm", "Compact the database file, removing space wasted by deleted records.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_STATUSTIP
#ifndef QT_NO_WHATSTHIS
fileCompactAction->setWhatsThis(QApplication::translate("mainForm", "Compact the database file, removing space wasted by deleted records.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
helpWhatsThisAction->setIconText(QApplication::translate("mainForm", "What's This?", 0, QApplication::UnicodeUTF8));
helpWhatsThisAction->setText(QApplication::translate("mainForm", "What's This?", 0, QApplication::UnicodeUTF8));
helpWhatsThisAction->setShortcut(QApplication::translate("mainForm", "Shift+F1", 0, QApplication::UnicodeUTF8));
sqlLogAction->setIconText(QApplication::translate("mainForm", "SQL Log", 0, QApplication::UnicodeUTF8));
sqlLogAction->setText(QApplication::translate("mainForm", "SQL Log", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_WHATSTHIS
sqlLogAction->setWhatsThis(QApplication::translate("mainForm", "Display or hide the SQL log window, which stores all SQL commands issued by the user or the application.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
fileImportCSVAction->setIconText(QApplication::translate("mainForm", "Table from CSV file", 0, QApplication::UnicodeUTF8));
fileImportCSVAction->setText(QApplication::translate("mainForm", "Table from CSV file", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
fileImportCSVAction->setToolTip(QApplication::translate("mainForm", "Open a wizard that lets you import data from a comma separated text file into a database table.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
fileImportCSVAction->setWhatsThis(QApplication::translate("mainForm", "Open a wizard that lets you import data from a comma separated text file into a database table. CSV files can be created on most database and spreadsheet applications.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
fileExportCSVAction->setIconText(QApplication::translate("mainForm", "Table as CSV file", 0, QApplication::UnicodeUTF8));
fileExportCSVAction->setText(QApplication::translate("mainForm", "Table as CSV file", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
fileExportCSVAction->setToolTip(QApplication::translate("mainForm", "Export a database table as a comma separated text file.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
fileExportCSVAction->setWhatsThis(QApplication::translate("mainForm", "Export a database table as a comma separated text file, ready to be imported into other database or spreadsheet applications.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
fileSaveAction->setIconText(QApplication::translate("mainForm", "Save Database", 0, QApplication::UnicodeUTF8));
fileSaveAction->setText(QApplication::translate("mainForm", "Save Database", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
fileSaveAction->setToolTip(QApplication::translate("mainForm", "Save changes to the database file", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
fileSaveAction->setWhatsThis(QApplication::translate("mainForm", "This option is used to save changes to the database file.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
fileRevertAction->setIconText(QApplication::translate("mainForm", "Revert Database", 0, QApplication::UnicodeUTF8));
fileRevertAction->setText(QApplication::translate("mainForm", "Revert Database", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
fileRevertAction->setToolTip(QApplication::translate("mainForm", "Revert database to last saved state", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
fileRevertAction->setWhatsThis(QApplication::translate("mainForm", "This option is used to revert the current database file to its last saved state. All changes made since the last save operation are lost.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
fileImportAction->setIconText(QApplication::translate("mainForm", "Import", 0, QApplication::UnicodeUTF8));
fileImportAction->setText(QApplication::translate("mainForm", "Import", 0, QApplication::UnicodeUTF8));
fileExportAction->setIconText(QApplication::translate("mainForm", "Export", 0, QApplication::UnicodeUTF8));
fileExportAction->setText(QApplication::translate("mainForm", "Export", 0, QApplication::UnicodeUTF8));
editCreateTableAction->setIconText(QApplication::translate("mainForm", "Create Table", 0, QApplication::UnicodeUTF8));
editCreateTableAction->setText(QApplication::translate("mainForm", "Create Table", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_WHATSTHIS
editCreateTableAction->setWhatsThis(QApplication::translate("mainForm", "Open the Create Table wizard, where it is possible to define the name and fields for a new table in the database", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
editDeleteTableAction->setIconText(QApplication::translate("mainForm", "Delete Table", 0, QApplication::UnicodeUTF8));
editDeleteTableAction->setText(QApplication::translate("mainForm", "Delete Table", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_WHATSTHIS
editDeleteTableAction->setWhatsThis(QApplication::translate("mainForm", "Open the Delete Table wizard, where you can select a database table to be dropped.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
editModifyTableAction->setIconText(QApplication::translate("mainForm", "Modify Table", 0, QApplication::UnicodeUTF8));
editModifyTableAction->setText(QApplication::translate("mainForm", "Modify Table", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_WHATSTHIS
editModifyTableAction->setWhatsThis(QApplication::translate("mainForm", "Open the Modify Table wizard, where it is possible to rename an existing table. It is also possible to add or delete fields form a table, as well as modify field names and types.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
editCreateIndexAction->setIconText(QApplication::translate("mainForm", "Create Index", 0, QApplication::UnicodeUTF8));
editCreateIndexAction->setText(QApplication::translate("mainForm", "Create Index", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_WHATSTHIS
editCreateIndexAction->setWhatsThis(QApplication::translate("mainForm", "Open the Create Index wizard, where it is possible to define a new index on an existing database table.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
editDeleteIndexAction->setIconText(QApplication::translate("mainForm", "Delete Index", 0, QApplication::UnicodeUTF8));
editDeleteIndexAction->setText(QApplication::translate("mainForm", "Delete Index", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_WHATSTHIS
editDeleteIndexAction->setWhatsThis(QApplication::translate("mainForm", "Open the Delete Index wizard, where you can select a database index to be dropped.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
fileImportSQLAction->setIconText(QApplication::translate("mainForm", "Database from SQL file", 0, QApplication::UnicodeUTF8));
fileImportSQLAction->setText(QApplication::translate("mainForm", "Database from SQL file", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
fileImportSQLAction->setToolTip(QApplication::translate("mainForm", "Import data from an .sql dump text file into a new or existing database.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
fileImportSQLAction->setWhatsThis(QApplication::translate("mainForm", "This option lets you import data from an .sql dump text file into a new or existing database. SQL dump files can be created on most database engines, including MySQL and PostgreSQL.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
fileExportSQLAction->setIconText(QApplication::translate("mainForm", "Database to SQL file", 0, QApplication::UnicodeUTF8));
fileExportSQLAction->setText(QApplication::translate("mainForm", "Database to SQL file", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
fileExportSQLAction->setToolTip(QApplication::translate("mainForm", "Export a database to a .sql dump text file.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
fileExportSQLAction->setWhatsThis(QApplication::translate("mainForm", "This option lets you export a database to a .sql dump text file. SQL dump files contain all data necessary to recreate the database on most database engines, including MySQL and PostgreSQL.", 0, QApplication::UnicodeUTF8));
#endif // QT_NO_WHATSTHIS
#ifndef QT_NO_TOOLTIP
mainTab->setProperty("toolTip", QVariant(QString()));
#endif // QT_NO_TOOLTIP
dblistView->header()->setLabel(0, QApplication::translate("mainForm", "Name", 0, QApplication::UnicodeUTF8));
dblistView->header()->setLabel(1, QApplication::translate("mainForm", "Object", 0, QApplication::UnicodeUTF8));
dblistView->header()->setLabel(2, QApplication::translate("mainForm", "Type", 0, QApplication::UnicodeUTF8));
dblistView->header()->setLabel(3, QApplication::translate("mainForm", "Schema", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_WHATSTHIS
dblistView->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "This area shows the structure of your database, including all tables and indexes.", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
mainTab->setTabText(mainTab->indexOf(structure), QApplication::translate("mainForm", "Database Structure", 0, QApplication::UnicodeUTF8));
textLabel1->setText(QApplication::translate("mainForm", "Table:", 0, QApplication::UnicodeUTF8));
comboBrowseTable->clear();
comboBrowseTable->insertItems(0, QStringList()
<< QApplication::translate("mainForm", "select", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("mainForm", "users", 0, QApplication::UnicodeUTF8)
);
#ifndef QT_NO_TOOLTIP
comboBrowseTable->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Select a table to browse data", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
comboBrowseTable->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "Use this list to select a table to be displayed in the database view", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
buttonFind->setText(QString());
#ifndef QT_NO_TOOLTIP
buttonFind->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Open or close the floating find window", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
buttonFind->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "This button toggles the appearance of the Find window, used to search records in the database view", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
buttonNewRecord->setText(QApplication::translate("mainForm", "New Record", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonNewRecord->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Insert a new record in the current table", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
buttonNewRecord->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "This button creates a new, empty record in the database", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
buttonDeleteRecord->setText(QApplication::translate("mainForm", "Delete Record", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonDeleteRecord->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Delete the current record", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
buttonDeleteRecord->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "This button deletes the record currently selected in the database", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
#ifndef QT_NO_TOOLTIP
dataTable->setProperty("toolTip", QVariant(QString()));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
dataTable->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "This is the database view. You can double-click any record to edit its contents in the cell editor window.", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
buttonPrevious->setText(QApplication::translate("mainForm", "<", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonPrevious->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Go to previous record set page", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
buttonPrevious->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "This button is used to navigate to the previous set of 1000 records in the database view", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
labelRecordset->setText(QApplication::translate("mainForm", "1000 - 2000 of 100000", 0, QApplication::UnicodeUTF8));
buttonNext->setText(QApplication::translate("mainForm", ">", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonNext->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Go to next record set page", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
buttonNext->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "This button is used to navigate to the next 1000 records set in the database view", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
buttonGoto->setText(QApplication::translate("mainForm", "Go to:", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
buttonGoto->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Click here to browse the specified record ", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
buttonGoto->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "This button is used to navigate to the record number specied in the Go to: area.", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
editGoto->setText(QApplication::translate("mainForm", "0", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
editGoto->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Enter record number to browse", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
editGoto->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "Type a record number in this area and click the Go to: button to display the record in the database view", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
mainTab->setTabText(mainTab->indexOf(browser), QApplication::translate("mainForm", "Browse Data", 0, QApplication::UnicodeUTF8));
textLabel1_2->setText(QApplication::translate("mainForm", "SQL string:", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
sqlTextEdit->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Type SQL string here", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
sqlTextEdit->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "Type the SQL query in this area, and press the button below to execute it. Results and error messages will be shown in the fields at the bottom of this form.", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
executeQueryButton->setText(QApplication::translate("mainForm", "Execute query", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
executeQueryButton->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Execute SQL query", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
executeQueryButton->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "This button is used to execute the SQL query entered in the text area above.", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
textLabel2->setText(QApplication::translate("mainForm", "Error message from database engine:", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
queryErrorLineEdit->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Error messages", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
queryErrorLineEdit->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "Messages returned from the database engine when the SQL query is executed are displayed in this area.", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
textLabel3->setText(QApplication::translate("mainForm", "Data returned:", 0, QApplication::UnicodeUTF8));
#ifndef QT_NO_TOOLTIP
queryResultListView->setProperty("toolTip", QVariant(QApplication::translate("mainForm", "Query generated data", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_WHATSTHIS
queryResultListView->setProperty("whatsThis", QVariant(QApplication::translate("mainForm", "This table displays data returned from the database engine as a result of the SQL query. You can not modify data directly on this view, only consult it.", 0, QApplication::UnicodeUTF8)));
#endif // QT_NO_WHATSTHIS
mainTab->setTabText(mainTab->indexOf(query), QApplication::translate("mainForm", "Execute SQL", 0, QApplication::UnicodeUTF8));
Toolbar->setLabel(QApplication::translate("mainForm", "Toolbar", 0, QApplication::UnicodeUTF8));
fileMenu->setTitle(QApplication::translate("mainForm", "&File", 0, QApplication::UnicodeUTF8));
PopupMenuEditor_9->setTitle(QApplication::translate("mainForm", "Import", 0, QApplication::UnicodeUTF8));
PopupMenuEditor_12->setTitle(QApplication::translate("mainForm", "Export", 0, QApplication::UnicodeUTF8));
EditMenu->setTitle(QApplication::translate("mainForm", "Edit", 0, QApplication::UnicodeUTF8));
ViewMenu->setTitle(QApplication::translate("mainForm", "View", 0, QApplication::UnicodeUTF8));
PopupMenu->setTitle(QApplication::translate("mainForm", "Help", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class mainForm: public Ui_mainForm {};
} // namespace Ui
QT_END_NAMESPACE
class mainForm : public Q3MainWindow, public Ui::mainForm
{
Q_OBJECT
public:
mainForm(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::WType_TopLevel);
~mainForm();
sqlLogForm * logWin;
editForm * editWin;
QClipboard * clipboard;
findForm * findWin;
int recAtTop;
int recsPerView;
QIntValidator * gotoValidator;
public slots:
virtual void fileOpen( const QString & fileName );
virtual void fileOpen();
virtual void fileNew();
virtual void populateStructure();
virtual void populateTable( const QString & tablename );
virtual void resetBrowser();
virtual void fileClose();
virtual void fileExit();
virtual void closeEvent( QCloseEvent * );
virtual void addRecord();
virtual void deleteRecord();
virtual void updateTableView( int lineToSelect );
virtual void selectTableLine( int lineToSelect );
virtual void navigatePrevious();
virtual void navigateNext();
virtual void navigateGoto();
virtual void setRecordsetLabel();
virtual void browseFind( bool open );
virtual void browseFindAway();
virtual void lookfor( const QString & wfield, const QString & woperator, const QString & wsearchterm );
virtual void showrecord( int dec );
virtual void createTable();
virtual void createIndex();
virtual void compact();
virtual void deleteTable();
virtual void editTable();
virtual void deleteIndex();
virtual void copy();
virtual void paste();
virtual void helpWhatsThis();
virtual void helpAbout();
virtual void updateRecordText( int row, int col, QString newtext );
virtual void logWinAway();
virtual void editWinAway();
virtual void editText( int row, int col );
virtual void doubleClickTable( int row, int col, int button, const QPoint & mousepoint );
virtual void executeQuery();
virtual void mainTabSelected( const QString & tabname );
virtual void toggleLogWindow( bool enable );
virtual void importTableFromCSV();
virtual void exportTableToCSV();
virtual void dbState( bool dirty );
virtual void fileSave();
virtual void fileRevert();
virtual void exportDatabaseToSQL();
virtual void importDatabaseFromSQL();
protected:
DBBrowserDB db;
protected slots:
virtual void languageChange();
private:
void init();
void destroy();
};
#endif // MAINFORM_H
@@ -0,0 +1,251 @@
#include "importcsvform.h"
#include <qvariant.h>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qimage.h>
#include <qpixmap.h>
/*
* Constructs a importCSVForm 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.
*/
importCSVForm::importCSVForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
init();
}
/*
* Destroys the object and frees any allocated resources
*/
importCSVForm::~importCSVForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void importCSVForm::languageChange()
{
retranslateUi(this);
}
void importCSVForm::init()
{
pdb = 0;
sep=',';
quote='"';
}
void importCSVForm::initialize(QString & csvfile, DBBrowserDB * db)
{
pdb = db;
csvfilename = csvfile;
preview();
}
void importCSVForm::createButtonPressed()
{
QString tabname;
QStringList fieldList;
QString sql;
//minimun validation for tabname
tabname = tableNameEdit->text();
if (tabname.isEmpty()) {
QMessageBox::information( this, applicationName, "Please choose a name for the new table that will hold the csv data" );
return;
}
tabname.replace(" ", "");
tabname.replace('"', "");
tabname.replace("'","");
tabname.replace(",","");
tabname.replace(";","");
if (tabname.isEmpty()) {
tabname = "tempTable";
}
//parse all csv data
curList = pdb->decodeCSV(csvfilename, sep, quote, -1, &numfields);
//can not operate on an empty result
if (numfields==0) return;
if (extractFieldNamesCheckbox->isChecked())
{
int cfieldnum = 0;
for ( QStringList::Iterator ct = curList.begin(); ct != curList.end(); ++ct ) {
QString thisfield = *ct;
//basic conforming
thisfield.replace(" ", "");
thisfield.replace('"', "");
thisfield.replace("'","");
thisfield.replace(",","");
thisfield.replace(";","");
if (thisfield.isEmpty()) thisfield.append("field");
fieldList << thisfield;
cfieldnum++;
if (cfieldnum==numfields) break;
}
//pop the fieldnames
for (int e=0; e<numfields; e++)
{
curList.pop_front();
}
} else {
//generate temp fieldnames
for (int e=0; e<numfields; e++)
{
fieldList << QString("field").append(QString::number(e+1,10));
}
}
sql = "CREATE TABLE ";
sql.append(tabname);
sql.append(" (");
for (int r=0; r<numfields;r++){
sql.append(*fieldList.at(r));
//createStatement.append(" text");
if (r<(numfields - 1))
sql.append(", ");
}
sql.append(");");
//declare local variables we will need before the rollback jump
int rowNum = 0;
int colNum = 0;
//begin a transaction, so we can rollback in case of any errors during importing
//db needs to be saved or an error will occur
if (!pdb->executeSQLDirect(QString("BEGIN TRANSACTION RESTOREPOINT;"))) goto rollback;
//execute the create table statement
if (!pdb->executeSQLDirect(sql)) goto rollback;
{//avoid error on MSVC due to rollback label
//now lets import all data, one row at a time
for ( QStringList::Iterator ct = curList .begin(); ct != curList .end(); ++ct ) {
if (colNum==0)
{
sql = "INSERT INTO ";
sql.append(tabname);
sql.append(" VALUES(");
}
//need to mprintf here
//sql.append(*ct);
char * formSQL = sqlite3_mprintf("%Q",(*ct).latin1());
sql.append(formSQL);
if (formSQL) sqlite3_free(formSQL);
colNum++;
if (colNum<numfields)
{
sql.append(",");
} else {
colNum = 0;
sql.append(");");
if (!pdb->executeSQLDirect(sql)) goto rollback;
}
}
}
//everything ok, just return
//if (!pdb->executeSQL(QString("COMMIT TRANSACTION RESTOREPOINT;"))) goto rollback;
pdb->setDirtyDirect(true);
QApplication::restoreOverrideCursor(); // restore original cursor
accept();
return;
rollback:
QApplication::restoreOverrideCursor(); // restore original cursor
QString error = "Error importing data. Message from database engine: ";
error.append(pdb->lastErrorMessage);
QMessageBox::warning( this, applicationName, error );
//we will uncomment this when SQLite support nested transactions
pdb->executeSQLDirect(QString("ROLLBACK TRANSACTION RESTOREPOINT;"));
}
void importCSVForm::preview()
{
//get only 20 lines, for preview
int maxrecs = 20;
curList = pdb->decodeCSV(csvfilename, sep, quote, maxrecs, &numfields);
//qDebug("count = %d, numfields = %d", curList .count(), numfields);
previewTable->setNumRows(0);
previewTable->setNumCols(0);
previewTable->setNumCols(numfields);
int cheadnum = 0;
//can not operate on an empty result
if (numfields==0) return;
if (extractFieldNamesCheckbox->isChecked())
{
for ( QStringList::Iterator ct = curList.begin(); ct != curList.end(); ++ct ) {
previewTable->horizontalHeader()->setLabel( cheadnum, *ct );
cheadnum++;
if (cheadnum==numfields) break;
}
//pop the fieldnames
for (int e=0; e<numfields; e++)
{
curList.pop_front();
}
}
previewTable->setNumRows(curList.count()/numfields);
int rowNum = 0;
int colNum = 0;
for ( QStringList::Iterator ct = curList .begin(); ct != curList .end(); ++ct ) {
if (colNum==0) previewTable->verticalHeader()->setLabel( rowNum, QString::number(rowNum,10) );
previewTable->setText( rowNum, colNum,*ct);
colNum++;
if (colNum==numfields)
{
colNum = 0;
rowNum ++;
}
}
}
void importCSVForm::fieldSeparatorChanged()
{
QString curText =fieldBox->currentText();
if (curText.compare(QString("TAB"))==0)
{
sep = 9;
} else {
QChar qsep = curText.at(0);
sep = (char) qsep.ascii();
}
preview();
}
void importCSVForm::textQuoteChanged()
{
QString curText = quoteBox->currentText();
QChar qquote = curText.at(0);
quote = (char) qquote.ascii();
preview();
}
void importCSVForm::extractFieldNamesChanged( bool enabled )
{
preview();
}
+239
View File
@@ -0,0 +1,239 @@
#ifndef IMPORTCSVFORM_H
#define IMPORTCSVFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3Header>
#include <Qt3Support/Q3MimeSourceFactory>
#include <Qt3Support/Q3Table>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QCheckBox>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include <QtCore/QStringRef>
#include <QtCore/QStringList>
#include "sqlitedb.h"
QT_BEGIN_NAMESPACE
class Ui_importCSVForm
{
public:
QVBoxLayout *vboxLayout;
QGridLayout *gridLayout;
QLabel *textLabel3;
QLineEdit *tableNameEdit;
QCheckBox *extractFieldNamesCheckbox;
QHBoxLayout *hboxLayout;
QVBoxLayout *vboxLayout1;
QLabel *textLabel1;
QLabel *textLabel2;
QSpacerItem *spacer15;
QVBoxLayout *vboxLayout2;
QComboBox *fieldBox;
QComboBox *quoteBox;
QSpacerItem *spacer14;
Q3Table *previewTable;
QHBoxLayout *hboxLayout1;
QSpacerItem *spacer13;
QPushButton *cancelButton;
QPushButton *createButton;
void setupUi(QDialog *importCSVForm)
{
if (importCSVForm->objectName().isEmpty())
importCSVForm->setObjectName(QString::fromUtf8("importCSVForm"));
importCSVForm->resize(372, 382);
importCSVForm->setModal(true);
vboxLayout = new QVBoxLayout(importCSVForm);
vboxLayout->setSpacing(6);
vboxLayout->setMargin(11);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
gridLayout = new QGridLayout();
gridLayout->setSpacing(6);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
textLabel3 = new QLabel(importCSVForm);
textLabel3->setObjectName(QString::fromUtf8("textLabel3"));
textLabel3->setWordWrap(false);
gridLayout->addWidget(textLabel3, 0, 0, 1, 1);
tableNameEdit = new QLineEdit(importCSVForm);
tableNameEdit->setObjectName(QString::fromUtf8("tableNameEdit"));
gridLayout->addWidget(tableNameEdit, 0, 1, 1, 1);
extractFieldNamesCheckbox = new QCheckBox(importCSVForm);
extractFieldNamesCheckbox->setObjectName(QString::fromUtf8("extractFieldNamesCheckbox"));
gridLayout->addWidget(extractFieldNamesCheckbox, 2, 0, 1, 2);
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
vboxLayout1 = new QVBoxLayout();
vboxLayout1->setSpacing(6);
vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1"));
textLabel1 = new QLabel(importCSVForm);
textLabel1->setObjectName(QString::fromUtf8("textLabel1"));
textLabel1->setWordWrap(false);
vboxLayout1->addWidget(textLabel1);
textLabel2 = new QLabel(importCSVForm);
textLabel2->setObjectName(QString::fromUtf8("textLabel2"));
textLabel2->setWordWrap(false);
vboxLayout1->addWidget(textLabel2);
hboxLayout->addLayout(vboxLayout1);
spacer15 = new QSpacerItem(81, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacer15);
vboxLayout2 = new QVBoxLayout();
vboxLayout2->setSpacing(6);
vboxLayout2->setObjectName(QString::fromUtf8("vboxLayout2"));
fieldBox = new QComboBox(importCSVForm);
fieldBox->setObjectName(QString::fromUtf8("fieldBox"));
vboxLayout2->addWidget(fieldBox);
quoteBox = new QComboBox(importCSVForm);
quoteBox->setObjectName(QString::fromUtf8("quoteBox"));
vboxLayout2->addWidget(quoteBox);
hboxLayout->addLayout(vboxLayout2);
gridLayout->addLayout(hboxLayout, 1, 0, 1, 2);
vboxLayout->addLayout(gridLayout);
spacer14 = new QSpacerItem(138, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
vboxLayout->addItem(spacer14);
previewTable = new Q3Table(importCSVForm);
previewTable->setObjectName(QString::fromUtf8("previewTable"));
previewTable->setNumRows(0);
previewTable->setNumCols(0);
previewTable->setReadOnly(true);
previewTable->setSelectionMode(Q3Table::NoSelection);
vboxLayout->addWidget(previewTable);
hboxLayout1 = new QHBoxLayout();
hboxLayout1->setSpacing(6);
hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
spacer13 = new QSpacerItem(41, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout1->addItem(spacer13);
cancelButton = new QPushButton(importCSVForm);
cancelButton->setObjectName(QString::fromUtf8("cancelButton"));
hboxLayout1->addWidget(cancelButton);
createButton = new QPushButton(importCSVForm);
createButton->setObjectName(QString::fromUtf8("createButton"));
hboxLayout1->addWidget(createButton);
vboxLayout->addLayout(hboxLayout1);
retranslateUi(importCSVForm);
QObject::connect(cancelButton, SIGNAL(clicked()), importCSVForm, SLOT(reject()));
QObject::connect(createButton, SIGNAL(clicked()), importCSVForm, SLOT(createButtonPressed()));
QObject::connect(fieldBox, SIGNAL(activated(int)), importCSVForm, SLOT(fieldSeparatorChanged()));
QObject::connect(quoteBox, SIGNAL(activated(int)), importCSVForm, SLOT(textQuoteChanged()));
QObject::connect(extractFieldNamesCheckbox, SIGNAL(toggled(bool)), importCSVForm, SLOT(extractFieldNamesChanged(bool)));
QMetaObject::connectSlotsByName(importCSVForm);
} // setupUi
void retranslateUi(QDialog *importCSVForm)
{
importCSVForm->setWindowTitle(QApplication::translate("importCSVForm", "Create table from CSV file", 0, QApplication::UnicodeUTF8));
textLabel3->setText(QApplication::translate("importCSVForm", "New table name:", 0, QApplication::UnicodeUTF8));
extractFieldNamesCheckbox->setText(QApplication::translate("importCSVForm", "Extract field names from first line", 0, QApplication::UnicodeUTF8));
textLabel1->setText(QApplication::translate("importCSVForm", "Field separator:", 0, QApplication::UnicodeUTF8));
textLabel2->setText(QApplication::translate("importCSVForm", "Text quote character:", 0, QApplication::UnicodeUTF8));
fieldBox->clear();
fieldBox->insertItems(0, QStringList()
<< QApplication::translate("importCSVForm", ",", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("importCSVForm", ";", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("importCSVForm", "TAB", 0, QApplication::UnicodeUTF8)
);
quoteBox->clear();
quoteBox->insertItems(0, QStringList()
<< QApplication::translate("importCSVForm", "\"", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("importCSVForm", "'", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("importCSVForm", "\\", 0, QApplication::UnicodeUTF8)
<< QString()
);
cancelButton->setText(QApplication::translate("importCSVForm", "Cancel", 0, QApplication::UnicodeUTF8));
createButton->setText(QApplication::translate("importCSVForm", "Create", 0, QApplication::UnicodeUTF8));
Q_UNUSED(importCSVForm);
} // retranslateUi
};
namespace Ui {
class importCSVForm: public Ui_importCSVForm {};
} // namespace Ui
QT_END_NAMESPACE
class importCSVForm : public QDialog, public Ui::importCSVForm
{
Q_OBJECT
public:
importCSVForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~importCSVForm();
public slots:
virtual void initialize( QString & csvfile, DBBrowserDB * db );
virtual void createButtonPressed();
virtual void preview();
virtual void fieldSeparatorChanged();
virtual void textQuoteChanged();
virtual void extractFieldNamesChanged( bool enabled );
protected:
QStringList curList;
char quote;
char sep;
int numfields;
QString csvfilename;
DBBrowserDB * pdb;
protected slots:
virtual void languageChange();
private:
void init();
};
#endif // IMPORTCSVFORM_H
@@ -1,217 +0,0 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void importCSVForm::init()
{
pdb = 0;
sep=',';
quote='"';
}
void importCSVForm::initialize(QString & csvfile, DBBrowserDB * db)
{
pdb = db;
csvfilename = csvfile;
preview();
}
void importCSVForm::createButtonPressed()
{
QString tabname;
QStringList fieldList;
QString sql;
//minimun validation for tabname
tabname = tableNameEdit->text();
if (tabname.isEmpty()) {
QMessageBox::information( this, applicationName, "Please choose a name for the new table that will hold the csv data" );
return;
}
tabname.replace(" ", "");
tabname.replace('"', "");
tabname.replace("'","");
tabname.replace(",","");
tabname.replace(";","");
if (tabname.isEmpty()) {
tabname = "tempTable";
}
//parse all csv data
curList = pdb->decodeCSV(csvfilename, sep, quote, -1, &numfields);
//can not operate on an empty result
if (numfields==0) return;
if (extractFieldNamesCheckbox->isChecked())
{
int cfieldnum = 0;
for ( QStringList::Iterator ct = curList.begin(); ct != curList.end(); ++ct ) {
QString thisfield = *ct;
//basic conforming
thisfield.replace(" ", "");
thisfield.replace('"', "");
thisfield.replace("'","");
thisfield.replace(",","");
thisfield.replace(";","");
if (thisfield.isEmpty()) thisfield.append("field");
fieldList << thisfield;
cfieldnum++;
if (cfieldnum==numfields) break;
}
//pop the fieldnames
for (int e=0; e<numfields; e++)
{
curList.pop_front();
}
} else {
//generate temp fieldnames
for (int e=0; e<numfields; e++)
{
fieldList << QString("field").append(QString::number(e+1,10));
}
}
sql = "CREATE TABLE ";
sql.append(tabname);
sql.append(" (");
for (int r=0; r<numfields;r++){
sql.append(*fieldList.at(r));
//createStatement.append(" text");
if (r<(numfields - 1))
sql.append(", ");
}
sql.append(");");
//declare local variables we will need before the rollback jump
int rowNum = 0;
int colNum = 0;
//begin a transaction, so we can rollback in case of any errors during importing
//db needs to be saved or an error will occur
if (!pdb->executeSQLDirect(QString("BEGIN TRANSACTION RESTOREPOINT;"))) goto rollback;
//execute the create table statement
if (!pdb->executeSQLDirect(sql)) goto rollback;
{//avoid error on MSVC due to rollback label
//now lets import all data, one row at a time
for ( QStringList::Iterator ct = curList .begin(); ct != curList .end(); ++ct ) {
if (colNum==0)
{
sql = "INSERT INTO ";
sql.append(tabname);
sql.append(" VALUES(");
}
//need to mprintf here
//sql.append(*ct);
char * formSQL = sqlite3_mprintf("%Q",(*ct).latin1());
sql.append(formSQL);
if (formSQL) sqlite3_free(formSQL);
colNum++;
if (colNum<numfields)
{
sql.append(",");
} else {
colNum = 0;
sql.append(");");
if (!pdb->executeSQLDirect(sql)) goto rollback;
}
}
}
//everything ok, just return
//if (!pdb->executeSQL(QString("COMMIT TRANSACTION RESTOREPOINT;"))) goto rollback;
pdb->setDirtyDirect(true);
QApplication::restoreOverrideCursor(); // restore original cursor
accept();
return;
rollback:
QApplication::restoreOverrideCursor(); // restore original cursor
QString error = "Error importing data. Message from database engine: ";
error.append(pdb->lastErrorMessage);
QMessageBox::warning( this, applicationName, error );
//we will uncomment this when SQLite support nested transactions
pdb->executeSQLDirect(QString("ROLLBACK TRANSACTION RESTOREPOINT;"));
}
void importCSVForm::preview()
{
//get only 20 lines, for preview
int maxrecs = 20;
curList = pdb->decodeCSV(csvfilename, sep, quote, maxrecs, &numfields);
//qDebug("count = %d, numfields = %d", curList .count(), numfields);
previewTable->setNumRows(0);
previewTable->setNumCols(0);
previewTable->setNumCols(numfields);
int cheadnum = 0;
//can not operate on an empty result
if (numfields==0) return;
if (extractFieldNamesCheckbox->isChecked())
{
for ( QStringList::Iterator ct = curList.begin(); ct != curList.end(); ++ct ) {
previewTable->horizontalHeader()->setLabel( cheadnum, *ct );
cheadnum++;
if (cheadnum==numfields) break;
}
//pop the fieldnames
for (int e=0; e<numfields; e++)
{
curList.pop_front();
}
}
previewTable->setNumRows(curList.count()/numfields);
int rowNum = 0;
int colNum = 0;
for ( QStringList::Iterator ct = curList .begin(); ct != curList .end(); ++ct ) {
if (colNum==0) previewTable->verticalHeader()->setLabel( rowNum, QString::number(rowNum,10) );
previewTable->setText( rowNum, colNum,*ct);
colNum++;
if (colNum==numfields)
{
colNum = 0;
rowNum ++;
}
}
}
void importCSVForm::fieldSeparatorChanged()
{
QString curText =fieldBox->currentText();
if (curText.compare(QString("TAB"))==0)
{
sep = 9;
} else {
QChar qsep = curText.at(0);
sep = (char) qsep.ascii();
}
preview();
}
void importCSVForm::textQuoteChanged()
{
QString curText = quoteBox->currentText();
QChar qquote = curText.at(0);
quote = (char) qquote.ascii();
preview();
}
void importCSVForm::extractFieldNamesChanged( bool enabled )
{
preview();
}
@@ -0,0 +1,62 @@
#include "renametableform.h"
#include <qvariant.h>
#include <qmessagebox.h>
#include <qimage.h>
#include <qpixmap.h>
#include "sqlitedb.h"
/*
* Constructs a renameTableForm 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.
*/
renameTableForm::renameTableForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
renameTableForm::~renameTableForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void renameTableForm::languageChange()
{
retranslateUi(this);
}
void renameTableForm::renameClicked()
{
QString tabname = tablenameLineEdit->text();
if (tabname.isEmpty()) {
QMessageBox::information( this, applicationName, "Table name can not be empty" );
return;
}
if (tabname.contains(" ")>0) {
QMessageBox::warning( this, applicationName, "Spaces are not allowed in the table name" );
return;
}
accept();
}
QString renameTableForm::getTableName()
{
return tablenameLineEdit->text();
}
void renameTableForm::setTableName(QString name)
{
tablenameLineEdit->setText(name);
}
@@ -0,0 +1,115 @@
#ifndef RENAMETABLEFORM_H
#define RENAMETABLEFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3MimeSourceFactory>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
QT_BEGIN_NAMESPACE
class Ui_renameTableForm
{
public:
QVBoxLayout *vboxLayout;
QLineEdit *tablenameLineEdit;
QSpacerItem *spacer27;
QHBoxLayout *hboxLayout;
QSpacerItem *spacer26;
QPushButton *closeButton;
QPushButton *renameButton;
void setupUi(QDialog *renameTableForm)
{
if (renameTableForm->objectName().isEmpty())
renameTableForm->setObjectName(QString::fromUtf8("renameTableForm"));
renameTableForm->resize(313, 101);
vboxLayout = new QVBoxLayout(renameTableForm);
vboxLayout->setSpacing(6);
vboxLayout->setMargin(11);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
tablenameLineEdit = new QLineEdit(renameTableForm);
tablenameLineEdit->setObjectName(QString::fromUtf8("tablenameLineEdit"));
vboxLayout->addWidget(tablenameLineEdit);
spacer27 = new QSpacerItem(20, 21, QSizePolicy::Minimum, QSizePolicy::Expanding);
vboxLayout->addItem(spacer27);
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
spacer26 = new QSpacerItem(31, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacer26);
closeButton = new QPushButton(renameTableForm);
closeButton->setObjectName(QString::fromUtf8("closeButton"));
hboxLayout->addWidget(closeButton);
renameButton = new QPushButton(renameTableForm);
renameButton->setObjectName(QString::fromUtf8("renameButton"));
renameButton->setDefault(true);
hboxLayout->addWidget(renameButton);
vboxLayout->addLayout(hboxLayout);
retranslateUi(renameTableForm);
QObject::connect(closeButton, SIGNAL(clicked()), renameTableForm, SLOT(reject()));
QObject::connect(renameButton, SIGNAL(clicked()), renameTableForm, SLOT(renameClicked()));
QMetaObject::connectSlotsByName(renameTableForm);
} // setupUi
void retranslateUi(QDialog *renameTableForm)
{
renameTableForm->setWindowTitle(QApplication::translate("renameTableForm", "Rename table", 0, QApplication::UnicodeUTF8));
closeButton->setText(QApplication::translate("renameTableForm", "Cancel", 0, QApplication::UnicodeUTF8));
renameButton->setText(QApplication::translate("renameTableForm", "Rename", 0, QApplication::UnicodeUTF8));
Q_UNUSED(renameTableForm);
} // retranslateUi
};
namespace Ui {
class renameTableForm: public Ui_renameTableForm {};
} // namespace Ui
QT_END_NAMESPACE
class renameTableForm : public QDialog, public Ui::renameTableForm
{
Q_OBJECT
public:
renameTableForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~renameTableForm();
virtual QString getTableName();
public slots:
virtual void renameClicked();
virtual void setTableName( QString name );
protected slots:
virtual void languageChange();
};
#endif // RENAMETABLEFORM_H
@@ -1,33 +0,0 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void renameTableForm::renameClicked()
{
QString tabname = tablenameLineEdit->text();
if (tabname.isEmpty()) {
QMessageBox::information( this, applicationName, "Table name can not be empty" );
return;
}
if (tabname.contains(" ")>0) {
QMessageBox::warning( this, applicationName, "Spaces are not allowed in the table name" );
return;
}
accept();
}
QString renameTableForm::getTableName()
{
return tablenameLineEdit->text();
}
void renameTableForm::setTableName(QString name)
{
tablenameLineEdit->setText(name);
}
+74 -67
View File
@@ -1,72 +1,79 @@
QT += qt3support
TEMPLATE = app
LANGUAGE = C++
CONFIG += qt \
warn_on \
release
HEADERS += extendedmainform.h \
sqlitebrowsertypes.h \
sqlitedb.h \
sqlbrowser_util.h \
sqlite_source/sqlite3.h \
aboutform.h \
addfieldform.h \
addfieldtypeform.h \
choosetableform.h \
createindexform.h \
createtableform.h \
deleteindexform.h \
deletetableform.h \
editfieldform.h \
editform.h \
editformwindow.h \
edittableform.h \
exporttablecsvform.h \
findform.h \
form1.h \
importcsvform.h \
renametableform.h \
sqllogform.h
SOURCES += extendedmainform.cpp \
browsermain.cpp \
sqlitedb.cpp \
sqlbrowser_util.c \
sqlite_source/sqlite3.c \
aboutform.cpp \
addfieldform.cpp \
addfieldtypeform.cpp \
choosetableform.cpp \
createindexform.cpp \
createtableform.cpp \
deleteindexform.cpp \
deletetableform.cpp \
editfieldform.cpp \
editform.cpp \
editformwindow.cpp \
edittableform.cpp \
exporttablecsvform.cpp \
findform.cpp \
form1.cpp \
importcsvform.cpp \
renametableform.cpp \
sqllogform.cpp
TEMPLATE = app
LANGUAGE = C++
CONFIG += qt warn_on release
HEADERS += extendedmainform.h \
sqlitebrowsertypes.h \
sqlitedb.h \
sqlbrowser_util.h \
sqlite_source/sqlite3.h
SOURCES += extendedmainform.cpp \
browsermain.cpp \
sqlitedb.cpp \
sqlbrowser_util.c \
sqlite_source/sqlite3.c
#The following line was changed from FORMS to FORMS3 by qt3to4
FORMS3 = aboutform.ui \
addfieldform.ui \
addfieldtypeform.ui \
choosetableform.ui \
createindexform.ui \
createtableform.ui \
deleteindexform.ui \
deletetableform.ui \
editfieldform.ui \
editform.ui \
edittableform.ui \
exporttablecsvform.ui \
findform.ui \
form1.ui \
importcsvform.ui \
renametableform.ui \
sqllogform.ui
IMAGES = images/create_index.png \
images/create_table.png \
images/delete_index.png \
images/delete_table.png \
images/icone16.png \
images/log.png \
images/modify_table.png \
images/new.png \
images/open.png \
images/revert.png \
images/save.png \
images/searchfind.png \
images/whatis.png
unix {
UI_DIR = .ui
MOC_DIR = .moc
OBJECTS_DIR = .obj
IMAGES = images/create_index.png \
images/create_table.png \
images/delete_index.png \
images/delete_table.png \
images/icone16.png \
images/log.png \
images/modify_table.png \
images/new.png \
images/open.png \
images/revert.png \
images/save.png \
images/searchfind.png \
images/whatis.png
unix {
UI_DIR = .ui
MOC_DIR = .moc
OBJECTS_DIR = .obj
}
win32 {
RC_FILE = winapp.rc
}
mac {
RC_FILE = macapp.icns
LIBS += -framework Carbon
QMAKE_INFO_PLIST = app.plist
win32:RC_FILE = winapp.rc
mac {
RC_FILE = macapp.icns
LIBS += -framework \
Carbon
QMAKE_INFO_PLIST = app.plist
}
#The following line was inserted by qt3to4
QT +=
#The following line was inserted by qt3to4
CONFIG += uic3
@@ -0,0 +1,69 @@
#include "sqllogform.h"
#include <qvariant.h>
#include <qimage.h>
#include <qpixmap.h>
#include "sqlitedb.h"
/*
* Constructs a sqlLogForm 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.
*/
sqlLogForm::sqlLogForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, name, modal, fl)
{
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
sqlLogForm::~sqlLogForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void sqlLogForm::languageChange()
{
retranslateUi(this);
}
void sqlLogForm::closeEvent( QCloseEvent * )
{
emit goingAway();
}
void sqlLogForm::log( QString & statement, int msgtype)
{
if (msgtype==kLogMsg_User)
{
userLogText->setText(userLogText->text()+statement+"\n");
} else {
appLogText->setText(appLogText->text()+statement+"\n");
}
}
void sqlLogForm::msgDBDirtyState( bool dirty)
{
emit dbState(dirty);
}
void sqlLogForm::clearLog()
{
if (logStack->id(logStack->visibleWidget())==kLogMsg_User)
{
userLogText->clear();
} else {
appLogText->clear();
}
}
+166
View File
@@ -0,0 +1,166 @@
#ifndef SQLLOGFORM_H
#define SQLLOGFORM_H
#include <qvariant.h>
#include <Qt3Support/Q3MimeSourceFactory>
#include <Qt3Support/Q3TextEdit>
#include <Qt3Support/Q3WidgetStack>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_sqlLogForm
{
public:
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
QLabel *textLabel1;
QComboBox *comboBox3;
QSpacerItem *spacer10;
QPushButton *clearButton;
Q3WidgetStack *logStack;
QWidget *WStackPage;
QGridLayout *gridLayout;
Q3TextEdit *userLogText;
QWidget *WStackPage1;
QVBoxLayout *vboxLayout1;
Q3TextEdit *appLogText;
void setupUi(QDialog *sqlLogForm)
{
if (sqlLogForm->objectName().isEmpty())
sqlLogForm->setObjectName(QString::fromUtf8("sqlLogForm"));
sqlLogForm->resize(547, 203);
vboxLayout = new QVBoxLayout(sqlLogForm);
vboxLayout->setSpacing(6);
vboxLayout->setMargin(11);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
textLabel1 = new QLabel(sqlLogForm);
textLabel1->setObjectName(QString::fromUtf8("textLabel1"));
textLabel1->setWordWrap(false);
hboxLayout->addWidget(textLabel1);
comboBox3 = new QComboBox(sqlLogForm);
comboBox3->setObjectName(QString::fromUtf8("comboBox3"));
hboxLayout->addWidget(comboBox3);
spacer10 = new QSpacerItem(150, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacer10);
clearButton = new QPushButton(sqlLogForm);
clearButton->setObjectName(QString::fromUtf8("clearButton"));
hboxLayout->addWidget(clearButton);
vboxLayout->addLayout(hboxLayout);
logStack = new Q3WidgetStack(sqlLogForm);
logStack->setObjectName(QString::fromUtf8("logStack"));
WStackPage = new QWidget(logStack);
WStackPage->setObjectName(QString::fromUtf8("WStackPage"));
gridLayout = new QGridLayout(WStackPage);
gridLayout->setSpacing(6);
gridLayout->setMargin(11);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
gridLayout->setContentsMargins(0, 0, 0, 0);
userLogText = new Q3TextEdit(WStackPage);
userLogText->setObjectName(QString::fromUtf8("userLogText"));
userLogText->setTextFormat(Qt::PlainText);
userLogText->setReadOnly(true);
gridLayout->addWidget(userLogText, 0, 0, 1, 1);
logStack->addWidget(WStackPage, 0);
WStackPage1 = new QWidget(logStack);
WStackPage1->setObjectName(QString::fromUtf8("WStackPage1"));
vboxLayout1 = new QVBoxLayout(WStackPage1);
vboxLayout1->setSpacing(6);
vboxLayout1->setMargin(11);
vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1"));
vboxLayout1->setContentsMargins(0, 0, 0, 0);
appLogText = new Q3TextEdit(WStackPage1);
appLogText->setObjectName(QString::fromUtf8("appLogText"));
appLogText->setTextFormat(Qt::PlainText);
appLogText->setReadOnly(true);
vboxLayout1->addWidget(appLogText);
logStack->addWidget(WStackPage1, 1);
vboxLayout->addWidget(logStack);
retranslateUi(sqlLogForm);
QObject::connect(clearButton, SIGNAL(clicked()), sqlLogForm, SLOT(clearLog()));
QObject::connect(comboBox3, SIGNAL(activated(int)), logStack, SLOT(raiseWidget(int)));
QMetaObject::connectSlotsByName(sqlLogForm);
} // setupUi
void retranslateUi(QDialog *sqlLogForm)
{
sqlLogForm->setWindowTitle(QApplication::translate("sqlLogForm", "SQL Log", 0, QApplication::UnicodeUTF8));
textLabel1->setText(QApplication::translate("sqlLogForm", "Show SQL submitted by:", 0, QApplication::UnicodeUTF8));
comboBox3->clear();
comboBox3->insertItems(0, QStringList()
<< QApplication::translate("sqlLogForm", "User", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("sqlLogForm", "Application", 0, QApplication::UnicodeUTF8)
);
clearButton->setText(QApplication::translate("sqlLogForm", "Clear", 0, QApplication::UnicodeUTF8));
Q_UNUSED(sqlLogForm);
} // retranslateUi
};
namespace Ui {
class sqlLogForm: public Ui_sqlLogForm {};
} // namespace Ui
QT_END_NAMESPACE
class sqlLogForm : public QDialog, public Ui::sqlLogForm
{
Q_OBJECT
public:
sqlLogForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
~sqlLogForm();
public slots:
virtual void closeEvent( QCloseEvent * );
virtual void log( QString & statement, int msgtype );
virtual void msgDBDirtyState( bool dirty );
virtual void clearLog();
signals:
void goingAway();
void dbState(bool dirty);
protected slots:
virtual void languageChange();
};
#endif // SQLLOGFORM_H
@@ -1,40 +0,0 @@
//Added by qt3to4:
#include <QCloseEvent>
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void sqlLogForm::closeEvent( QCloseEvent * )
{
emit goingAway();
}
void sqlLogForm::log( QString & statement, int msgtype)
{
if (msgtype==kLogMsg_User)
{
userLogText->setText(userLogText->text()+statement+"\n");
} else {
appLogText->setText(appLogText->text()+statement+"\n");
}
}
void sqlLogForm::msgDBDirtyState( bool dirty)
{
emit dbState(dirty);
}
void sqlLogForm::clearLog()
{
if (logStack->id(logStack->visibleWidget())==kLogMsg_User)
{
userLogText->clear();
} else {
appLogText->clear();
}
}