mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-19 18:40:13 -06:00
Qt3Support was completely removed
While testing some of my changes I noticed there are a lot of broken things. So still a lot of work.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
QT += qt3support
|
||||
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS = src
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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)
|
||||
aboutForm::aboutForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -39,7 +39,6 @@ void aboutForm::languageChange()
|
||||
|
||||
void aboutForm::init()
|
||||
{
|
||||
this->setCaption(applicationName);
|
||||
//aboutBrowser->setText(aboutText);
|
||||
this->setWindowTitle(applicationName);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~aboutForm();
|
||||
|
||||
protected slots:
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* 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)
|
||||
addFieldForm::addFieldForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -42,17 +42,17 @@ void addFieldForm::setInitialValues(QString name, QString type)
|
||||
{
|
||||
nameLineEdit->setText(name);
|
||||
typeBox->clear();
|
||||
typeBox->insertItem(type);
|
||||
typeBox->addItem(type);
|
||||
QString tString = "";
|
||||
if (type.compare(tString)!=0) typeBox->insertItem(tString);
|
||||
if (type.compare(tString)!=0) typeBox->addItem(tString);
|
||||
tString = "TEXT";
|
||||
if (type.compare(tString)!=0) typeBox->insertItem(tString);
|
||||
if (type.compare(tString)!=0) typeBox->addItem(tString);
|
||||
tString = "NUMERIC";
|
||||
if (type.compare(tString)!=0) typeBox->insertItem(tString);
|
||||
if (type.compare(tString)!=0) typeBox->addItem(tString);
|
||||
tString = "BLOB";
|
||||
if (type.compare(tString)!=0) typeBox->insertItem(tString);
|
||||
if (type.compare(tString)!=0) typeBox->addItem(tString);
|
||||
tString = "INTEGER PRIMARY KEY";
|
||||
if (type.compare(tString)!=0) typeBox->insertItem(tString);
|
||||
if (type.compare(tString)!=0) typeBox->addItem(tString);
|
||||
}
|
||||
|
||||
void addFieldForm::confirmAddField()
|
||||
@@ -73,11 +73,12 @@ void addFieldForm::confirmAddField()
|
||||
|
||||
void addFieldForm::getCustomType()
|
||||
{
|
||||
addFieldTypeForm * addForm = new addFieldTypeForm( this, "addfieldtype", TRUE );
|
||||
addFieldTypeForm * addForm = new addFieldTypeForm( this );
|
||||
addForm->setModal(true);
|
||||
if (addForm->exec())
|
||||
{
|
||||
//QString nospaces = addForm->typeNameEdit->text().remove(" ");
|
||||
QString nospaces = addForm->typeNameEdit->text();
|
||||
setInitialValues(nameLineEdit->text(),nospaces );
|
||||
}
|
||||
{
|
||||
//QString nospaces = addForm->typeNameEdit->text().remove(" ");
|
||||
QString nospaces = addForm->typeNameEdit->text();
|
||||
setInitialValues(nameLineEdit->text(),nospaces );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~addFieldForm();
|
||||
|
||||
QString fname;
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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)
|
||||
addFieldTypeForm::addFieldTypeForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~addFieldTypeForm();
|
||||
|
||||
protected slots:
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
* 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)
|
||||
chooseTableForm::chooseTableForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -44,8 +44,6 @@ void chooseTableForm::editPressed()
|
||||
void chooseTableForm::populateOptions(QStringList entries)
|
||||
{
|
||||
comboOptions->clear();
|
||||
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
|
||||
comboOptions->insertItem(*ct,-1);
|
||||
}
|
||||
comboOptions->addItems(entries);
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~chooseTableForm();
|
||||
|
||||
QString option;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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)
|
||||
createIndexForm::createIndexForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -41,15 +41,15 @@ void createIndexForm::tableSelected( const QString & entry )
|
||||
{
|
||||
tableMap::Iterator it;
|
||||
for ( it = mtablemap.begin(); it != mtablemap.end(); ++it ) {
|
||||
QString tname = it.data().getname() ;
|
||||
QString tname = it.value().getname() ;
|
||||
|
||||
//populate the fields with first table name
|
||||
if ((tname.compare(entry)==0)){
|
||||
comboFields->clear();
|
||||
fieldMap::Iterator fit;
|
||||
fieldMap fmap = it.data().fldmap;
|
||||
fieldMap fmap = it.value().fldmap;
|
||||
for ( fit = fmap.begin(); fit != fmap.end(); ++fit ) {
|
||||
comboFields->insertItem( fit.data().getname(), -1 );
|
||||
comboFields->addItem( fit.value().getname() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ void createIndexForm::confirmCreate()
|
||||
}
|
||||
if (ok){
|
||||
createStatement = "CREATE ";
|
||||
if (comboUnique->currentItem()==1){
|
||||
if (comboUnique->currentIndex()==1){
|
||||
createStatement.append("UNIQUE ");
|
||||
}
|
||||
createStatement.append("INDEX ");
|
||||
@@ -81,7 +81,7 @@ void createIndexForm::confirmCreate()
|
||||
createStatement.append("(");
|
||||
createStatement.append(comboFields->currentText());
|
||||
createStatement.append(" ");
|
||||
if (comboOrder->currentItem()==0){
|
||||
if (comboOrder->currentIndex()==0){
|
||||
createStatement.append("ASC");
|
||||
} else {
|
||||
createStatement.append("DESC");
|
||||
@@ -96,14 +96,14 @@ void createIndexForm::populateTable(tableMap rmap)
|
||||
mtablemap = rmap;
|
||||
tableMap::Iterator it;
|
||||
for ( it = mtablemap.begin(); it != mtablemap.end(); ++it ) {
|
||||
comboTables->insertItem( it.data().getname() , -1);
|
||||
comboTables->addItem( it.value().getname() );
|
||||
|
||||
//populate the fields with first table name
|
||||
if (it==mtablemap.begin()){
|
||||
fieldMap::Iterator fit;
|
||||
fieldMap fmap = it.data().fldmap;
|
||||
fieldMap fmap = it.value().fldmap;
|
||||
for ( fit = fmap.begin(); fit != fmap.end(); ++fit ) {
|
||||
comboFields->insertItem( fit.data().getname(), -1 );
|
||||
comboFields->addItem( fit.value().getname() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~createIndexForm();
|
||||
|
||||
tableMap mtablemap;
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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)
|
||||
createTableForm::createTableForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -113,7 +113,8 @@ void createTableForm::confirmCreate()
|
||||
void createTableForm::addField()
|
||||
{
|
||||
//TODO maybe embedd locally
|
||||
addFieldForm * addForm = new addFieldForm( this, "addfield", TRUE );
|
||||
addFieldForm * addForm = new addFieldForm( this );
|
||||
addForm->setModal(true);
|
||||
addForm->setInitialValues(QString(""),QString(""));
|
||||
if (addForm->exec())
|
||||
{
|
||||
|
||||
@@ -215,7 +215,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~createTableForm();
|
||||
|
||||
QString createStatement;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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)
|
||||
deleteIndexForm::deleteIndexForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -55,9 +55,7 @@ void deleteIndexForm::confirmDelete()
|
||||
void deleteIndexForm::populateOptions(QStringList entries)
|
||||
{
|
||||
comboOptions->clear();
|
||||
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
|
||||
comboOptions->insertItem(*ct,-1);
|
||||
}
|
||||
comboOptions->addItems(entries);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~deleteIndexForm();
|
||||
|
||||
QString option;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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)
|
||||
deleteTableForm::deleteTableForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -55,9 +55,7 @@ void deleteTableForm::confirmDelete()
|
||||
void deleteTableForm::populateOptions(QStringList entries)
|
||||
{
|
||||
comboOptions->clear();
|
||||
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
|
||||
comboOptions->insertItem(*ct,-1);
|
||||
}
|
||||
comboOptions->addItems(entries);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~deleteTableForm();
|
||||
|
||||
QString option;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* 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)
|
||||
editFieldForm::editFieldForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -88,7 +88,7 @@ void editFieldForm::confirmEdit()
|
||||
field_type = groupRadioTypes->checkedButton()->property("field_type").toString();
|
||||
bool ok = pdb.createColumn(table_name, field_name, field_type);
|
||||
if(!ok){
|
||||
qDebug(pdb.lastErrorMessage);
|
||||
qDebug(pdb.lastErrorMessage.toUtf8());
|
||||
return;
|
||||
}
|
||||
//qDebug("");
|
||||
@@ -106,14 +106,14 @@ void editFieldForm::enableSave()
|
||||
|
||||
void editFieldForm::getCustomType()
|
||||
{
|
||||
addFieldTypeForm * addForm = new addFieldTypeForm( this, "addfieldtype", TRUE );
|
||||
addFieldTypeForm * addForm = new addFieldTypeForm( this );
|
||||
if (addForm->exec())
|
||||
{
|
||||
//QString nospaces = addForm->typeNameEdit->text().remove(" ");
|
||||
QString nospaces = addForm->typeNameEdit->text();
|
||||
{
|
||||
//QString nospaces = addForm->typeNameEdit->text().remove(" ");
|
||||
QString nospaces = addForm->typeNameEdit->text();
|
||||
//setInitialValues( nameLineEdit->text(), nospaces );
|
||||
enableSave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~editFieldForm();
|
||||
|
||||
void setDB(DBBrowserDB &db);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "editform.h"
|
||||
|
||||
#include <QTextStream>
|
||||
#include <qvariant.h>
|
||||
#include <q3filedialog.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qimage.h>
|
||||
#include <qpixmap.h>
|
||||
#include <Q3TextStream>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "sqlitedb.h"
|
||||
/*
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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)
|
||||
editForm::editForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -49,7 +49,7 @@ void editForm::init()
|
||||
dataDepth = 0;
|
||||
curRow = -1;
|
||||
curCol = -1;
|
||||
textEditor->setText("");
|
||||
textEditor->setPlainText("");
|
||||
setDataType(kSQLiteMediaType_Void, 0);
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ void editForm::enableTextEditor(bool enabled)
|
||||
|
||||
void editForm::setTextFormat(QString format)
|
||||
{
|
||||
if (format=="Auto")
|
||||
{
|
||||
textEditor->setTextFormat(Qt::AutoText);
|
||||
} else {
|
||||
textEditor->setTextFormat(Qt::PlainText);
|
||||
}
|
||||
// if (format=="Auto")
|
||||
// {
|
||||
// textEditor->setTextFormat(Qt::AutoText);
|
||||
// } else {
|
||||
// textEditor->setTextFormat(Qt::PlainText);
|
||||
// }
|
||||
}
|
||||
|
||||
void editForm::setDataType(int type, int size)
|
||||
@@ -120,7 +120,7 @@ void editForm::closeEvent( QCloseEvent * )
|
||||
|
||||
void editForm::loadText(QString text, int row, int col)
|
||||
{
|
||||
textEditor->setText(text);
|
||||
textEditor->setPlainText(text);
|
||||
curRow = row;
|
||||
curCol = col;
|
||||
if (textEditor->toPlainText().length() > 0)
|
||||
@@ -136,21 +136,19 @@ void editForm::loadText(QString text, int row, int col)
|
||||
void editForm::importData()
|
||||
{
|
||||
int type = kSQLiteMediaType_Void;
|
||||
QString fileName = Q3FileDialog::getOpenFileName(
|
||||
"",
|
||||
QString( "Text files (*.txt);;"
|
||||
"All files (*.*);;"),
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
"open file dialog"
|
||||
"Choose an image file" );
|
||||
"Choose an image file",
|
||||
QString(),
|
||||
QString( "Text files (*.txt);;All files (*.*);;"));
|
||||
if (QFile::exists(fileName) )
|
||||
{
|
||||
type = kSQLiteMediaType_String;
|
||||
|
||||
QFile file( fileName );
|
||||
if ( file.open( QIODevice::ReadOnly ) ) {
|
||||
Q3TextStream stream( &file );
|
||||
textEditor->setText(stream.read());
|
||||
QTextStream stream( &file );
|
||||
textEditor->setPlainText(stream.readAll());
|
||||
file.close();
|
||||
}
|
||||
|
||||
@@ -173,12 +171,11 @@ void editForm::exportData()
|
||||
}
|
||||
|
||||
|
||||
QString fileName = Q3FileDialog::getSaveFileName(
|
||||
defaultlocation,
|
||||
filter,
|
||||
this,
|
||||
"save file dialog"
|
||||
"Choose a filename to export data" );
|
||||
QString fileName = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
"Choose a filename to export data",
|
||||
defaultlocation,
|
||||
filter);
|
||||
|
||||
if (fileName.size() > 0)
|
||||
{
|
||||
@@ -188,8 +185,8 @@ void editForm::exportData()
|
||||
{
|
||||
QFile file(fileName);
|
||||
if ( file.open( QIODevice::WriteOnly ) ) {
|
||||
Q3TextStream stream( &file );
|
||||
stream << textEditor->text();
|
||||
QTextStream stream( &file );
|
||||
stream << textEditor->toPlainText();
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
@@ -204,7 +201,7 @@ void editForm::exportData()
|
||||
|
||||
void editForm::clearData()
|
||||
{
|
||||
textEditor->setText("");
|
||||
textEditor->setPlainText("");
|
||||
setDataType(kSQLiteMediaType_Void, 0);
|
||||
setModified(true);
|
||||
}
|
||||
@@ -213,7 +210,7 @@ void editForm::clearData()
|
||||
void editForm::saveChanges()
|
||||
{
|
||||
if (dataType==kSQLiteMediaType_String)
|
||||
emit updateRecordText(curRow, curCol, textEditor->text());
|
||||
emit updateRecordText(curRow, curCol, textEditor->toPlainText());
|
||||
|
||||
if (dataType==kSQLiteMediaType_Void)
|
||||
emit updateRecordText(curRow, curCol, QString(""));
|
||||
|
||||
@@ -116,7 +116,6 @@ public:
|
||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||
textEditor = new QTextEdit(WStackPage);
|
||||
textEditor->setObjectName(QString::fromUtf8("textEditor"));
|
||||
textEditor->setTextFormat(Qt::PlainText);
|
||||
|
||||
gridLayout->addWidget(textEditor, 0, 0, 1, 1);
|
||||
|
||||
@@ -263,7 +262,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~editForm();
|
||||
|
||||
int curCol;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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)
|
||||
editTableForm::editTableForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -79,11 +79,12 @@ void editTableForm::populateFields()
|
||||
|
||||
void editTableForm::renameTable()
|
||||
{
|
||||
renameTableForm * renTableForm = new renameTableForm( this, "renametable", TRUE );
|
||||
renameTableForm * renTableForm = new renameTableForm( this );
|
||||
renTableForm->setModal(true);
|
||||
renTableForm->setTableName(curTable);
|
||||
if (renTableForm->exec())
|
||||
{
|
||||
QApplication::setOverrideCursor( Qt::waitCursor ); // this might take time
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor ); // this might take time
|
||||
modified = true;
|
||||
QString newName = renTableForm->getTableName();
|
||||
//qDebug(newName);
|
||||
@@ -226,7 +227,8 @@ void editTableForm::editField()
|
||||
//should never happen, the button would not be active, but...
|
||||
// return;
|
||||
// } else {
|
||||
editFieldForm * fieldForm = new editFieldForm( this, "editfield", TRUE );
|
||||
editFieldForm * fieldForm = new editFieldForm( this );
|
||||
fieldForm->setModal(true);
|
||||
fieldForm->setInitialValues(false, "TABLE_NAME", item->text(0), item->text(1));
|
||||
if (fieldForm->exec())
|
||||
{
|
||||
@@ -333,7 +335,8 @@ void editTableForm::editField()
|
||||
|
||||
void editTableForm::addField()
|
||||
{
|
||||
addFieldForm * addForm = new addFieldForm( this, "addfield", TRUE );
|
||||
addFieldForm * addForm = new addFieldForm( this );
|
||||
addForm->setModal(true);
|
||||
addForm->setInitialValues(QString(""),QString(""));
|
||||
if (addForm->exec())
|
||||
{
|
||||
|
||||
@@ -186,7 +186,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~editTableForm();
|
||||
|
||||
bool modified;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
* 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)
|
||||
exportTableCSVForm::exportTableCSVForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -44,7 +44,5 @@ void exportTableCSVForm::exportPressed()
|
||||
void exportTableCSVForm::populateOptions(QStringList entries)
|
||||
{
|
||||
comboOptions->clear();
|
||||
for ( QStringList::Iterator ct = entries.begin(); ct != entries.end(); ++ct ) {
|
||||
comboOptions->insertItem(*ct,-1);
|
||||
}
|
||||
comboOptions->addItems(entries);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~exportTableCSVForm();
|
||||
|
||||
QString option;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "extendedmainform.h"
|
||||
#include <QUrl>
|
||||
|
||||
ExtendedMainForm::ExtendedMainForm(QWidget* parent, const char* name, Qt::WindowFlags fl) : mainForm( parent, name, fl )
|
||||
ExtendedMainForm::ExtendedMainForm(QWidget* parent) : mainForm( parent )
|
||||
{
|
||||
setAcceptDrops(true); // Enable the drop feature on this form
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
class ExtendedMainForm : public mainForm
|
||||
{
|
||||
public:
|
||||
ExtendedMainForm(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::WType_TopLevel);
|
||||
ExtendedMainForm(QWidget* parent = 0);
|
||||
~ExtendedMainForm(void);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
* 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)
|
||||
findForm::findForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -42,7 +42,7 @@ void findForm::showResults(resultMap rmap)
|
||||
resultMap::Iterator it;
|
||||
findTableWidget->setRowCount(rmap.size());
|
||||
for ( it = rmap.begin(); it != rmap.end(); ++it ) {
|
||||
QString firstline = it.data().section( '\n', 0,0 );
|
||||
QString firstline = it.value().section( '\n', 0,0 );
|
||||
if (firstline.length()>MAX_DISPLAY_LENGTH)
|
||||
{
|
||||
firstline.truncate(MAX_DISPLAY_LENGTH);
|
||||
@@ -66,9 +66,7 @@ void findForm::find()
|
||||
void findForm::resetFields(QStringList fieldlist)
|
||||
{
|
||||
findFieldCombobox->clear();
|
||||
for ( QStringList::Iterator ct = fieldlist.begin(); ct != fieldlist.end(); ++ct ) {
|
||||
findFieldCombobox->insertItem(*ct,-1);
|
||||
}
|
||||
findFieldCombobox->addItems(fieldlist);
|
||||
}
|
||||
|
||||
void findForm::resetResults()
|
||||
|
||||
@@ -182,7 +182,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~findForm();
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* 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)
|
||||
importCSVForm::importCSVForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -146,7 +146,7 @@ void importCSVForm::createButtonPressed()
|
||||
}
|
||||
//need to mprintf here
|
||||
//sql.append(*ct);
|
||||
char * formSQL = sqlite3_mprintf("%Q",(const char *) curList[i]);
|
||||
char * formSQL = sqlite3_mprintf("%Q",(const char *) curList[i].toUtf8());
|
||||
sql.append(formSQL);
|
||||
if (formSQL) sqlite3_free(formSQL);
|
||||
|
||||
@@ -191,33 +191,27 @@ void importCSVForm::preview()
|
||||
|
||||
//qDebug("count = %d, numfields = %d", curList .count(), numfields);
|
||||
|
||||
previewTable->setNumRows(0);
|
||||
previewTable->setNumCols(0);
|
||||
previewTable->setNumCols(numfields);
|
||||
int cheadnum = 0;
|
||||
previewTable->clear();
|
||||
previewTable->setColumnCount(curList.size());
|
||||
|
||||
//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;
|
||||
}
|
||||
previewTable->setHorizontalHeaderLabels(curList);
|
||||
//pop the fieldnames
|
||||
for (int e=0; e<numfields; e++)
|
||||
{
|
||||
curList.pop_front();
|
||||
}
|
||||
}
|
||||
previewTable->setNumRows(curList.count()/numfields);
|
||||
previewTable->setRowCount(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);
|
||||
if (colNum==0) previewTable->setVerticalHeaderItem( rowNum, new QTableWidgetItem( QString::number(rowNum) ) );
|
||||
previewTable->setItem(rowNum, colNum, new QTableWidgetItem( *ct ) );
|
||||
colNum++;
|
||||
if (colNum==numfields)
|
||||
{
|
||||
@@ -236,7 +230,7 @@ void importCSVForm::fieldSeparatorChanged()
|
||||
sep = 9;
|
||||
} else {
|
||||
QChar qsep = curText.at(0);
|
||||
sep = (char) qsep.ascii();
|
||||
sep = (char) qsep.toAscii();
|
||||
}
|
||||
preview();
|
||||
}
|
||||
@@ -245,8 +239,11 @@ void importCSVForm::fieldSeparatorChanged()
|
||||
void importCSVForm::textQuoteChanged()
|
||||
{
|
||||
QString curText = quoteBox->currentText();
|
||||
QChar qquote = curText.at(0);
|
||||
quote = (char) qquote.ascii();
|
||||
if(curText.length() > 0)
|
||||
{
|
||||
QChar qquote = curText.at(0);
|
||||
quote = (char) qquote.toAscii();
|
||||
}
|
||||
preview();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
#define QT_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
#include <Qt3Support/Q3Header>
|
||||
#include <Qt3Support/Q3Table>
|
||||
#include <QTableWidget>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QApplication>
|
||||
@@ -52,7 +51,7 @@ public:
|
||||
QComboBox *fieldBox;
|
||||
QComboBox *quoteBox;
|
||||
QSpacerItem *spacer14;
|
||||
Q3Table *previewTable;
|
||||
QTableWidget *previewTable;
|
||||
QHBoxLayout *hboxLayout1;
|
||||
QSpacerItem *spacer13;
|
||||
QPushButton *cancelButton;
|
||||
@@ -138,12 +137,11 @@ public:
|
||||
|
||||
vboxLayout->addItem(spacer14);
|
||||
|
||||
previewTable = new Q3Table(importCSVForm);
|
||||
previewTable = new QTableWidget(importCSVForm);
|
||||
previewTable->setObjectName(QString::fromUtf8("previewTable"));
|
||||
previewTable->setNumRows(0);
|
||||
previewTable->setNumCols(0);
|
||||
previewTable->setReadOnly(true);
|
||||
previewTable->setSelectionMode(Q3Table::NoSelection);
|
||||
previewTable->setRowCount(0);
|
||||
previewTable->setColumnCount(0);
|
||||
previewTable->setSelectionMode(QTableWidget::NoSelection);
|
||||
|
||||
vboxLayout->addWidget(previewTable);
|
||||
|
||||
@@ -215,7 +213,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~importCSVForm();
|
||||
|
||||
public slots:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -149,19 +149,19 @@ public:
|
||||
//** New DB File
|
||||
fileNewAction = new QAction(mainForm);
|
||||
fileNewAction->setObjectName(QString::fromUtf8("fileNewAction"));
|
||||
fileNewAction->setName("fileNewAction");
|
||||
fileNewAction->setText("fileNewAction");
|
||||
fileNewAction->setIcon(QIcon(":/icons/db_new"));
|
||||
|
||||
//** Open DB File
|
||||
fileOpenAction = new QAction(mainForm);
|
||||
fileOpenAction->setObjectName(QString::fromUtf8("fileOpenAction"));
|
||||
fileOpenAction->setName("fileOpenAction");
|
||||
fileOpenAction->setText("fileOpenAction");
|
||||
fileOpenAction->setIcon(QIcon(":/icons/db_open"));
|
||||
|
||||
//** Save DB Action
|
||||
fileSaveAction = new QAction(mainForm);
|
||||
fileSaveAction->setObjectName(QString::fromUtf8("fileSaveAction"));
|
||||
fileSaveAction->setName("fileSaveAction");
|
||||
fileSaveAction->setText("fileSaveAction");
|
||||
fileSaveAction->setEnabled(false);
|
||||
fileSaveAction->setIcon(QIcon(":/icons/db_save"));
|
||||
QFont fntS = fileSaveAction->font();
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
//** Db Revert
|
||||
fileRevertAction = new QAction(mainForm);
|
||||
fileRevertAction->setObjectName(QString::fromUtf8("fileRevertAction"));
|
||||
fileRevertAction->setName("fileRevertAction");
|
||||
fileRevertAction->setText("fileRevertAction");
|
||||
fileRevertAction->setEnabled(false);
|
||||
fileRevertAction->setIcon(QIcon(":/icons/db_revert"));
|
||||
QFont fntR = fileRevertAction->font();
|
||||
@@ -182,50 +182,50 @@ public:
|
||||
//** Exit
|
||||
fileExitAction = new QAction(mainForm);
|
||||
fileExitAction->setObjectName(QString::fromUtf8("fileExitAction"));
|
||||
fileExitAction->setName("fileExitAction");
|
||||
fileExitAction->setText("fileExitAction");
|
||||
|
||||
editCopyAction = new QAction(mainForm);
|
||||
editCopyAction->setObjectName(QString::fromUtf8("editCopyAction"));
|
||||
editCopyAction->setName("editCopyAction");
|
||||
editCopyAction->setText("editCopyAction");
|
||||
editPasteAction = new QAction(mainForm);
|
||||
editPasteAction->setObjectName(QString::fromUtf8("editPasteAction"));
|
||||
editPasteAction->setName("editPasteAction");
|
||||
editPasteAction->setText("editPasteAction");
|
||||
editFindAction = new QAction(mainForm);
|
||||
editFindAction->setObjectName(QString::fromUtf8("editFindAction"));
|
||||
editFindAction->setName("editFindAction");
|
||||
editFindAction->setText("editFindAction");
|
||||
editFindAction->setIcon(QIcon(":/oldimages/searchfind"));
|
||||
editFindAction->setIconVisibleInMenu(true);
|
||||
helpContentsAction = new QAction(mainForm);
|
||||
helpContentsAction->setObjectName(QString::fromUtf8("helpContentsAction"));
|
||||
helpContentsAction->setName("helpContentsAction");
|
||||
helpContentsAction->setText("helpContentsAction");
|
||||
helpIndexAction = new QAction(mainForm);
|
||||
helpIndexAction->setObjectName(QString::fromUtf8("helpIndexAction"));
|
||||
helpIndexAction->setName("helpIndexAction");
|
||||
helpIndexAction->setText("helpIndexAction");
|
||||
helpAboutAction = new QAction(mainForm);
|
||||
helpAboutAction->setObjectName(QString::fromUtf8("helpAboutAction"));
|
||||
helpAboutAction->setName("helpAboutAction");
|
||||
helpAboutAction->setText("helpAboutAction");
|
||||
|
||||
//** Close Database ??
|
||||
fileCloseAction = new QAction(mainForm);
|
||||
fileCloseAction->setObjectName(QString::fromUtf8("fileCloseAction"));
|
||||
fileCloseAction->setName("fileCloseAction");
|
||||
fileCloseAction->setText("fileCloseAction");
|
||||
fileCloseAction->setEnabled(false);
|
||||
|
||||
newRecordAction = new QAction(mainForm);
|
||||
newRecordAction->setObjectName(QString::fromUtf8("newRecordAction"));
|
||||
newRecordAction->setName("newRecordAction");
|
||||
newRecordAction->setText("newRecordAction");
|
||||
fileCompactAction = new QAction(mainForm);
|
||||
fileCompactAction->setObjectName(QString::fromUtf8("fileCompactAction"));
|
||||
fileCompactAction->setName("fileCompactAction");
|
||||
fileCompactAction->setText("fileCompactAction");
|
||||
fileCompactAction->setEnabled(false);
|
||||
helpWhatsThisAction = new QAction(mainForm);
|
||||
helpWhatsThisAction->setObjectName(QString::fromUtf8("helpWhatsThisAction"));
|
||||
helpWhatsThisAction->setName("helpWhatsThisAction");
|
||||
helpWhatsThisAction->setText("helpWhatsThisAction");
|
||||
helpWhatsThisAction->setIcon(QIcon(":/oldimages/whatis"));
|
||||
helpWhatsThisAction->setIconVisibleInMenu(true);
|
||||
sqlLogAction = new QAction(mainForm);
|
||||
sqlLogAction->setObjectName(QString::fromUtf8("sqlLogAction"));
|
||||
sqlLogAction->setName("sqlLogAction");
|
||||
sqlLogAction->setText("sqlLogAction");
|
||||
sqlLogAction->setCheckable(true);
|
||||
sqlLogAction->setIcon(QIcon(":/oldimages/log"));
|
||||
sqlLogAction->setIconVisibleInMenu(true);
|
||||
@@ -233,10 +233,10 @@ public:
|
||||
|
||||
fileImportCSVAction = new QAction(mainForm);
|
||||
fileImportCSVAction->setObjectName(QString::fromUtf8("fileImportCSVAction"));
|
||||
fileImportCSVAction->setName("fileImportCSVAction");
|
||||
fileImportCSVAction->setText("fileImportCSVAction");
|
||||
fileExportCSVAction = new QAction(mainForm);
|
||||
fileExportCSVAction->setObjectName(QString::fromUtf8("fileExportCSVAction"));
|
||||
fileExportCSVAction->setName("fileExportCSVAction");
|
||||
fileExportCSVAction->setText("fileExportCSVAction");
|
||||
|
||||
|
||||
|
||||
@@ -251,14 +251,14 @@ public:
|
||||
//** Create Table
|
||||
editCreateTableAction = new QAction(mainForm);
|
||||
editCreateTableAction->setObjectName(QString::fromUtf8("editCreateTableAction"));
|
||||
editCreateTableAction->setName("editCreateTableAction");
|
||||
editCreateTableAction->setText("editCreateTableAction");
|
||||
editCreateTableAction->setEnabled(false);
|
||||
editCreateTableAction->setIcon(QIcon(":/icons/table_create"));
|
||||
|
||||
//** Delete table
|
||||
editDeleteTableAction = new QAction(mainForm);
|
||||
editDeleteTableAction->setObjectName(QString::fromUtf8("editDeleteTableAction"));
|
||||
editDeleteTableAction->setName("editDeleteTableAction");
|
||||
editDeleteTableAction->setText("editDeleteTableAction");
|
||||
editDeleteTableAction->setEnabled(false);
|
||||
editDeleteTableAction->setIcon(QIcon(":/icons/table_delete"));
|
||||
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
//** Modify Table
|
||||
editModifyTableAction = new QAction(mainForm);
|
||||
editModifyTableAction->setObjectName(QString::fromUtf8("editModifyTableAction"));
|
||||
editModifyTableAction->setName("editModifyTableAction");
|
||||
editModifyTableAction->setText("editModifyTableAction");
|
||||
editModifyTableAction->setEnabled(false);
|
||||
editModifyTableAction->setIcon(QIcon(":/icons/table_modify"));
|
||||
|
||||
@@ -299,25 +299,25 @@ public:
|
||||
//** Create/Delete Index
|
||||
editCreateIndexAction = new QAction(mainForm);
|
||||
editCreateIndexAction->setObjectName(QString::fromUtf8("editCreateIndexAction"));
|
||||
editCreateIndexAction->setName("editCreateIndexAction");
|
||||
editCreateIndexAction->setText("editCreateIndexAction");
|
||||
editCreateIndexAction->setEnabled(false);
|
||||
editCreateIndexAction->setIcon(QIcon(":/icons/index_create"));
|
||||
|
||||
editDeleteIndexAction = new QAction(mainForm);
|
||||
editDeleteIndexAction->setObjectName(QString::fromUtf8("editDeleteIndexAction"));
|
||||
editDeleteIndexAction->setName("editDeleteIndexAction");
|
||||
editDeleteIndexAction->setText("editDeleteIndexAction");
|
||||
editDeleteIndexAction->setEnabled(false);
|
||||
editDeleteIndexAction->setIcon(QIcon(":/icons/index_delete"));
|
||||
|
||||
fileImportSQLAction = new QAction(mainForm);
|
||||
fileImportSQLAction->setObjectName(QString::fromUtf8("fileImportSQLAction"));
|
||||
fileImportSQLAction->setName("fileImportSQLAction");
|
||||
fileImportSQLAction->setText("fileImportSQLAction");
|
||||
fileExportSQLAction = new QAction(mainForm);
|
||||
fileExportSQLAction->setObjectName(QString::fromUtf8("fileExportSQLAction"));
|
||||
fileExportSQLAction->setName("fileExportSQLAction");
|
||||
fileExportSQLAction->setText("fileExportSQLAction");
|
||||
editPreferencesAction = new QAction(mainForm);
|
||||
editPreferencesAction->setObjectName(QString::fromUtf8("editPreferencesAction"));
|
||||
editPreferencesAction->setName("editPreferencesAction");
|
||||
editPreferencesAction->setText("editPreferencesAction");
|
||||
widget = new QWidget(mainForm);
|
||||
widget->setObjectName(QString::fromUtf8("widget"));
|
||||
vboxLayout = new QVBoxLayout(widget);
|
||||
@@ -650,7 +650,7 @@ public:
|
||||
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(dataTable, SIGNAL(cellDoubleClicked(int,int)), mainForm, SLOT(doubleClickTable(int,int)));
|
||||
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()));
|
||||
@@ -832,6 +832,7 @@ public:
|
||||
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
|
||||
editPreferencesAction->setIconText(QApplication::translate("mainForm", "Preferences", 0, QApplication::UnicodeUTF8));
|
||||
editPreferencesAction->setText(QApplication::translate("mainForm", "Preferences", 0, QApplication::UnicodeUTF8));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
editPreferencesAction->setToolTip(QApplication::translate("mainForm", "Open the preferences window..", 0, QApplication::UnicodeUTF8));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
@@ -944,7 +945,7 @@ public:
|
||||
queryResultTableView->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));
|
||||
//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));
|
||||
@@ -966,7 +967,7 @@ class mainForm : public QMainWindow, public Ui::mainForm
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
mainForm(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::WType_TopLevel);
|
||||
mainForm(QWidget* parent = 0);
|
||||
~mainForm();
|
||||
|
||||
sqlLogForm * logWin;
|
||||
@@ -1020,7 +1021,7 @@ public slots:
|
||||
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 doubleClickTable( int row, int col );
|
||||
virtual void executeQuery();
|
||||
virtual void mainTabSelected( const QString & tabname );
|
||||
virtual void toggleLogWindow( bool enable );
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
#include "qdir.h"
|
||||
#include "qsettings.h"
|
||||
#include "q3filedialog.h"
|
||||
#include <QFileDialog>
|
||||
#include "sqlitedb.h"
|
||||
|
||||
/*
|
||||
* Constructs a preferencesForm as a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'.
|
||||
@@ -14,8 +16,8 @@
|
||||
* The dialog will by default be modeless, unless you set 'modal' to
|
||||
* true to construct a modal dialog.
|
||||
*/
|
||||
preferencesForm::preferencesForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
|
||||
: QDialog(parent, name, modal, fl)
|
||||
preferencesForm::preferencesForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -53,27 +55,27 @@ void preferencesForm::languageChange()
|
||||
|
||||
void preferencesForm::init()
|
||||
{
|
||||
loadSettings();
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
|
||||
void preferencesForm::defaultDataChanged( int which )
|
||||
{
|
||||
if (which==2) {
|
||||
defaultnewdata = QString("\'\'");
|
||||
} else if (which==1) {
|
||||
defaultnewdata = QString("0");
|
||||
defaultnewdata = QString("\'\'");
|
||||
} else if (which==1) {
|
||||
defaultnewdata = QString("0");
|
||||
} else {
|
||||
defaultnewdata = QString("NULL");
|
||||
defaultnewdata = QString("NULL");
|
||||
}
|
||||
}
|
||||
|
||||
void preferencesForm::defaultTextChanged( int which )
|
||||
{
|
||||
if (which==1) {
|
||||
defaulttext = QString("Auto");
|
||||
defaulttext = QString("Auto");
|
||||
} else {
|
||||
defaulttext = QString("Plain");
|
||||
defaulttext = QString("Plain");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -82,63 +84,65 @@ void preferencesForm::defaultTextChanged( int which )
|
||||
void preferencesForm::encodingChanged( int which )
|
||||
{
|
||||
if (which==1) {
|
||||
defaultencoding = QString("Latin1");
|
||||
defaultencoding = QString("Latin1");
|
||||
} else {
|
||||
defaultencoding = QString("UTF8");
|
||||
defaultencoding = QString("UTF8");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void preferencesForm::chooseLocation()
|
||||
{
|
||||
QString s = Q3FileDialog::getExistingDirectory(
|
||||
defaultlocation,
|
||||
this,
|
||||
"get existing directory",
|
||||
"Choose a directory",
|
||||
TRUE );
|
||||
|
||||
defaultlocation = s;
|
||||
locationEdit->setText(defaultlocation);
|
||||
QString s = QFileDialog::getExistingDirectory(
|
||||
this,
|
||||
tr("Choose a directory"),
|
||||
defaultlocation,
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if(!s.isEmpty())
|
||||
{
|
||||
defaultlocation = s;
|
||||
locationEdit->setText(defaultlocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void preferencesForm::loadSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setPath( "sqlitebrowser.sf.net", "SQLite Database Browser 2", QSettings::UserScope );
|
||||
QSettings settings(sOrganisation, sApplicationNameShort);
|
||||
settings.sync();
|
||||
|
||||
defaultencoding = settings.readEntry( "/db/defaultencoding", "UTF8" );
|
||||
defaultnewdata = settings.readEntry( "/db/defaultnewdata", "NULL" );
|
||||
defaultlocation = settings.readEntry( "/db/defaultlocation", QDir::homeDirPath () );
|
||||
defaulttext = settings.readEntry( "/db/defaulttext", "Plain" );
|
||||
|
||||
if (defaultencoding=="Latin1")
|
||||
{
|
||||
encodingComboBox->setCurrentItem(1) ;
|
||||
defaultencoding = settings.value( "/db/defaultencoding", "UTF8" ).toString();
|
||||
defaultnewdata = settings.value( "/db/defaultnewdata", "NULL" ).toString();
|
||||
defaultlocation = settings.value( "/db/defaultlocation", QDir::homePath() ).toString();
|
||||
defaulttext = settings.value( "/db/defaulttext", "Plain" ).toString();
|
||||
|
||||
if (defaultencoding=="Latin1")
|
||||
{
|
||||
encodingComboBox->setCurrentIndex(1);
|
||||
} else {
|
||||
encodingComboBox->setCurrentItem(0) ;
|
||||
defaultencoding = QString("UTF8");
|
||||
}
|
||||
encodingComboBox->setCurrentIndex(0) ;
|
||||
defaultencoding = QString("UTF8");
|
||||
}
|
||||
|
||||
if (defaultnewdata=="\'\'")
|
||||
{
|
||||
defaultdataComboBox->setCurrentItem(2) ;
|
||||
{
|
||||
defaultdataComboBox->setCurrentIndex(2) ;
|
||||
} else if (defaultnewdata=="0")
|
||||
{
|
||||
defaultdataComboBox->setCurrentItem(1) ;
|
||||
{
|
||||
defaultdataComboBox->setCurrentIndex(1) ;
|
||||
} else {
|
||||
defaultdataComboBox->setCurrentItem(0) ;
|
||||
defaultnewdata = QString("NULL");
|
||||
}
|
||||
defaultdataComboBox->setCurrentIndex(0) ;
|
||||
defaultnewdata = QString("NULL");
|
||||
}
|
||||
|
||||
if (defaulttext=="Auto")
|
||||
{
|
||||
defaultTextComboBox->setCurrentItem(1) ;
|
||||
{
|
||||
defaultTextComboBox->setCurrentIndex(1) ;
|
||||
} else {
|
||||
defaultTextComboBox->setCurrentItem(0) ;
|
||||
defaulttext = QString("Plain");
|
||||
}
|
||||
defaultTextComboBox->setCurrentIndex(0) ;
|
||||
defaulttext = QString("Plain");
|
||||
}
|
||||
|
||||
locationEdit->setText(defaultlocation);
|
||||
}
|
||||
@@ -146,14 +150,14 @@ void preferencesForm::loadSettings()
|
||||
|
||||
void preferencesForm::saveSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setPath( "sqlitebrowser.sf.net", "SQLite Database Browser 2", QSettings::UserScope );
|
||||
QSettings settings(sOrganisation, sApplicationNameShort);
|
||||
|
||||
settings.writeEntry( "/db/defaultencoding", defaultencoding );
|
||||
settings.writeEntry( "/db/defaultnewdata", defaultnewdata );
|
||||
settings.writeEntry( "/db/defaultlocation", defaultlocation );
|
||||
settings.writeEntry( "/db/defaulttext", defaulttext );
|
||||
accept();
|
||||
settings.setValue( "/db/defaultencoding", defaultencoding );
|
||||
settings.setValue( "/db/defaultnewdata", defaultnewdata );
|
||||
settings.setValue( "/db/defaultlocation", defaultlocation );
|
||||
settings.setValue( "/db/defaulttext", defaulttext );
|
||||
settings.sync();
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -202,22 +202,22 @@ public:
|
||||
textLabel1->setText(QApplication::translate("preferencesForm", "Database encoding:", 0, QApplication::UnicodeUTF8));
|
||||
encodingComboBox->clear();
|
||||
encodingComboBox->insertItems(0, QStringList()
|
||||
<< QApplication::translate("preferencesForm", "UTF8 (Unicode)", 0, QApplication::UnicodeUTF8)
|
||||
<< QApplication::translate("preferencesForm", "Latin1 (8bit)", 0, QApplication::UnicodeUTF8)
|
||||
);
|
||||
<< QApplication::translate("preferencesForm", "UTF8 (Unicode)", 0, QApplication::UnicodeUTF8)
|
||||
<< QApplication::translate("preferencesForm", "Latin1 (8bit)", 0, QApplication::UnicodeUTF8)
|
||||
);
|
||||
textLabel2->setText(QApplication::translate("preferencesForm", "Default data for new records:", 0, QApplication::UnicodeUTF8));
|
||||
defaultdataComboBox->clear();
|
||||
defaultdataComboBox->insertItems(0, QStringList()
|
||||
<< QApplication::translate("preferencesForm", "NULL", 0, QApplication::UnicodeUTF8)
|
||||
<< QApplication::translate("preferencesForm", "0", 0, QApplication::UnicodeUTF8)
|
||||
<< QApplication::translate("preferencesForm", "Empty string", 0, QApplication::UnicodeUTF8)
|
||||
);
|
||||
<< QApplication::translate("preferencesForm", "NULL", 0, QApplication::UnicodeUTF8)
|
||||
<< QApplication::translate("preferencesForm", "0", 0, QApplication::UnicodeUTF8)
|
||||
<< QApplication::translate("preferencesForm", "Empty string", 0, QApplication::UnicodeUTF8)
|
||||
);
|
||||
textLabel1_2->setText(QApplication::translate("preferencesForm", "Default text editor format:", 0, QApplication::UnicodeUTF8));
|
||||
defaultTextComboBox->clear();
|
||||
defaultTextComboBox->insertItems(0, QStringList()
|
||||
<< QApplication::translate("preferencesForm", "Plain", 0, QApplication::UnicodeUTF8)
|
||||
<< QApplication::translate("preferencesForm", "Auto", 0, QApplication::UnicodeUTF8)
|
||||
);
|
||||
<< QApplication::translate("preferencesForm", "Plain", 0, QApplication::UnicodeUTF8)
|
||||
<< QApplication::translate("preferencesForm", "Auto", 0, QApplication::UnicodeUTF8)
|
||||
);
|
||||
textLabel3->setText(QApplication::translate("preferencesForm", "Default location:", 0, QApplication::UnicodeUTF8));
|
||||
setLocationButton->setText(QApplication::translate("preferencesForm", "...", 0, QApplication::UnicodeUTF8));
|
||||
OKButton->setText(QApplication::translate("preferencesForm", "O&K", 0, QApplication::UnicodeUTF8));
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class preferencesForm: public Ui_preferencesForm {};
|
||||
class preferencesForm: public Ui_preferencesForm {};
|
||||
} // namespace Ui
|
||||
|
||||
QT_END_NAMESPACE
|
||||
@@ -237,7 +237,7 @@ class preferencesForm : public QDialog, public Ui::preferencesForm
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
preferencesForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
|
||||
preferencesForm(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~preferencesForm();
|
||||
|
||||
QString defaulttext;
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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)
|
||||
renameTableForm::renameTableForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~renameTableForm();
|
||||
|
||||
virtual QString getTableName();
|
||||
|
||||
372
src/sqlitedb.cpp
372
src/sqlitedb.cpp
@@ -4,7 +4,6 @@
|
||||
#include <qregexp.h>
|
||||
#include <qimage.h>
|
||||
#include <qfile.h>
|
||||
#include <q3filedialog.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <QProgressDialog>
|
||||
|
||||
@@ -57,26 +56,26 @@ void DBBrowserDB::setDefaultNewData( const QString & data )
|
||||
|
||||
char * DBBrowserDB::GetEncodedQStringAsPointer( const QString & input)
|
||||
{
|
||||
if (curEncoding==kEncodingUTF8) return (char *) input.utf8().constData();
|
||||
if (curEncoding==kEncodingLatin1) return (char *) input.latin1();
|
||||
if (curEncoding==kEncodingUTF8) return (char *) input.toUtf8().constData();
|
||||
if (curEncoding==kEncodingLatin1) return (char *) input.toLatin1().constData();
|
||||
|
||||
return (char *) input.constData();
|
||||
}
|
||||
|
||||
QString DBBrowserDB::GetEncodedQString( const QString & input)
|
||||
{
|
||||
if (curEncoding==kEncodingUTF8) return input.utf8();
|
||||
if (curEncoding==kEncodingLatin1) return input.latin1();
|
||||
if (curEncoding==kEncodingUTF8) return input.toUtf8();
|
||||
if (curEncoding==kEncodingLatin1) return input.toLatin1();
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
QString DBBrowserDB::GetDecodedQString( const QString & input)
|
||||
{
|
||||
if (curEncoding==kEncodingUTF8) return QString::fromUtf8(input);
|
||||
if (curEncoding==kEncodingLatin1) return QString::fromLatin1(input);
|
||||
|
||||
return input;
|
||||
// if (curEncoding==kEncodingUTF8) return QString::fromUtf8(input);
|
||||
// if (curEncoding==kEncodingLatin1) return QString::fromLatin1(input);
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
bool DBBrowserDB::open ( const QString & db)
|
||||
@@ -104,7 +103,7 @@ bool DBBrowserDB::open ( const QString & db)
|
||||
|
||||
lastErrorMessage = QString("no error");
|
||||
|
||||
err = sqlite3_open_v2(GetEncodedQString(db), &_db, SQLITE_OPEN_READWRITE, NULL);
|
||||
err = sqlite3_open_v2(db.toUtf8(), &_db, SQLITE_OPEN_READWRITE, NULL);
|
||||
if ( err ) {
|
||||
lastErrorMessage = sqlite3_errmsg(_db);
|
||||
sqlite3_close(_db);
|
||||
@@ -170,7 +169,7 @@ bool DBBrowserDB::create ( const QString & db)
|
||||
|
||||
lastErrorMessage = QString("no error");
|
||||
|
||||
if( sqlite3_open(GetEncodedQString(db), &_db) != SQLITE_OK ){
|
||||
if( sqlite3_open(db.toUtf8(), &_db) != SQLITE_OK ){
|
||||
lastErrorMessage = sqlite3_errmsg(_db);
|
||||
sqlite3_close(_db);
|
||||
_db = 0;
|
||||
@@ -250,7 +249,7 @@ bool DBBrowserDB::reload( const QString & filename, int * lineErr)
|
||||
{
|
||||
/*to avoid a nested transaction error*/
|
||||
sqlite3_exec(_db,"COMMIT;", NULL,NULL,NULL);
|
||||
FILE * cfile = fopen((const char *) filename, (const char *) "r");
|
||||
FILE * cfile = fopen(filename.toUtf8(), (const char *) "r");
|
||||
load_database(_db, cfile, lineErr);
|
||||
fclose(cfile);
|
||||
setDirty(false);
|
||||
@@ -263,7 +262,7 @@ bool DBBrowserDB::reload( const QString & filename, int * lineErr)
|
||||
|
||||
bool DBBrowserDB::dump( const QString & filename)
|
||||
{
|
||||
FILE * cfile = fopen((const char *) filename, (const char *) "w");
|
||||
FILE * cfile = fopen(filename.toUtf8(), (const char *) "w");
|
||||
if (!cfile)
|
||||
{
|
||||
return false;
|
||||
@@ -283,7 +282,7 @@ bool DBBrowserDB::executeSQL ( const QString & statement, bool dirtyDB, bool log
|
||||
if (_db){
|
||||
if (logsql) logSQL(statement, kLogMsg_App);
|
||||
if (dirtyDB) setDirty(true);
|
||||
if (SQLITE_OK==sqlite3_exec(_db,GetEncodedQString(statement),
|
||||
if (SQLITE_OK==sqlite3_exec(_db,statement.toUtf8(),
|
||||
NULL,NULL,&errmsg)){
|
||||
ok=true;
|
||||
}
|
||||
@@ -318,7 +317,7 @@ bool DBBrowserDB::addRecord ( )
|
||||
if (_db){
|
||||
logSQL(statement, kLogMsg_App);
|
||||
setDirty(true);
|
||||
if (SQLITE_OK==sqlite3_exec(_db,statement,NULL,NULL, &errmsg)){
|
||||
if (SQLITE_OK==sqlite3_exec(_db,statement.toUtf8(),NULL,NULL, &errmsg)){
|
||||
ok=true;
|
||||
//int newrowid = sqlite3_last_insert_rowid(_db);
|
||||
} else {
|
||||
@@ -349,7 +348,7 @@ bool DBBrowserDB::deleteRecord( int wrow)
|
||||
if (_db){
|
||||
logSQL(statement, kLogMsg_App);
|
||||
setDirty(true);
|
||||
if (SQLITE_OK==sqlite3_exec(_db,GetEncodedQString(statement),
|
||||
if (SQLITE_OK==sqlite3_exec(_db,statement.toUtf8(),
|
||||
NULL,NULL,&errmsg)){
|
||||
ok=true;
|
||||
} else {
|
||||
@@ -380,7 +379,7 @@ bool DBBrowserDB::updateRecord(int wrow, int wcol, const QString & wtext)
|
||||
statement.append("=");
|
||||
|
||||
QString wenc = GetEncodedQString(wtext);
|
||||
char * formSQL = sqlite3_mprintf("%Q",(const char *) wenc);
|
||||
char * formSQL = sqlite3_mprintf("%Q", wenc.toUtf8().constData());
|
||||
statement.append(formSQL);
|
||||
if (formSQL) sqlite3_free(formSQL);
|
||||
|
||||
@@ -391,7 +390,7 @@ bool DBBrowserDB::updateRecord(int wrow, int wcol, const QString & wtext)
|
||||
if (_db){
|
||||
logSQL(statement, kLogMsg_App);
|
||||
setDirty(true);
|
||||
if (SQLITE_OK==sqlite3_exec(_db,statement,
|
||||
if (SQLITE_OK==sqlite3_exec(_db,statement.toUtf8(),
|
||||
NULL,NULL,&errmsg)){
|
||||
ok=true;
|
||||
/*update local copy*/
|
||||
@@ -428,7 +427,7 @@ bool DBBrowserDB::browseTable( const QString & tablename )
|
||||
bool DBBrowserDB::createColumn( QString tablename, QString fieldname, QString fieldtype ){
|
||||
qDebug("create column");
|
||||
QString sql = QString("ALTER TABLE `%1` ADD COLUMN `%2` %3").arg(tablename).arg(fieldname).arg(fieldtype);
|
||||
qDebug(sql);
|
||||
qDebug(sql.toUtf8());
|
||||
return executeSQL(sql);
|
||||
}
|
||||
|
||||
@@ -456,7 +455,7 @@ void DBBrowserDB::getTableRecords( const QString & tablename )
|
||||
statement.append(" ORDER BY rowid; ");
|
||||
//qDebug(statement);
|
||||
logSQL(statement, kLogMsg_App);
|
||||
err=sqlite3_prepare(_db,statement,statement.length(),
|
||||
err=sqlite3_prepare(_db,statement.toUtf8(),statement.length(),
|
||||
&vm, &tail);
|
||||
if (err == SQLITE_OK){
|
||||
int rownum = 0;
|
||||
@@ -497,7 +496,7 @@ resultMap DBBrowserDB::getFindResults( const QString & wstatement)
|
||||
lastErrorMessage = QString("no error");
|
||||
QString encstatement = GetEncodedQString(wstatement);
|
||||
logSQL(encstatement, kLogMsg_App);
|
||||
err=sqlite3_prepare(_db,encstatement,encstatement.length(),
|
||||
err=sqlite3_prepare(_db,encstatement.toUtf8(),encstatement.length(),
|
||||
&vm, &tail);
|
||||
if (err == SQLITE_OK){
|
||||
int rownum = 0;
|
||||
@@ -533,7 +532,7 @@ QStringList DBBrowserDB::getTableNames()
|
||||
QStringList res;
|
||||
|
||||
for ( it = tmap.begin(); it != tmap.end(); ++it ) {
|
||||
res.append( it.data().getname() );
|
||||
res.append( it.value().getname() );
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -546,10 +545,10 @@ QStringList DBBrowserDB::getIndexNames()
|
||||
QStringList res;
|
||||
|
||||
for ( it = tmap.begin(); it != tmap.end(); ++it ) {
|
||||
res.append( it.data().getname() );
|
||||
res.append( it.value().getname() );
|
||||
}
|
||||
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
QStringList DBBrowserDB::getTableFields(const QString & tablename)
|
||||
@@ -558,16 +557,16 @@ QStringList DBBrowserDB::getTableFields(const QString & tablename)
|
||||
tableMap tmap = tbmap;
|
||||
QStringList res;
|
||||
|
||||
for ( it = tmap.begin(); it != tmap.end(); ++it ) {
|
||||
if (tablename.compare(it.data().getname())==0 ){
|
||||
fieldMap::Iterator fit;
|
||||
fieldMap fmap = it.data().fldmap;
|
||||
for ( it = tmap.begin(); it != tmap.end(); ++it ) {
|
||||
if (tablename.compare(it.value().getname())==0 ){
|
||||
fieldMap::Iterator fit;
|
||||
fieldMap fmap = it.value().fldmap;
|
||||
|
||||
for ( fit = fmap.begin(); fit != fmap.end(); ++fit ) {
|
||||
res.append( fit.data().getname() );
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( fit = fmap.begin(); fit != fmap.end(); ++fit ) {
|
||||
res.append( fit.value().getname() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -578,12 +577,12 @@ QStringList DBBrowserDB::getTableTypes(const QString & tablename)
|
||||
QStringList res;
|
||||
|
||||
for ( it = tmap.begin(); it != tmap.end(); ++it ) {
|
||||
if (tablename.compare(it.data().getname())==0 ){
|
||||
if (tablename.compare(it.value().getname())==0 ){
|
||||
fieldMap::Iterator fit;
|
||||
fieldMap fmap = it.data().fldmap;
|
||||
fieldMap fmap = it.value().fldmap;
|
||||
|
||||
for ( fit = fmap.begin(); fit != fmap.end(); ++fit ) {
|
||||
res.append( fit.data().gettype() );
|
||||
res.append( fit.value().gettype() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -613,172 +612,173 @@ void DBBrowserDB::logSQL(QString statement, int msgtype)
|
||||
|
||||
void DBBrowserDB::updateSchema( )
|
||||
{
|
||||
// qDebug ("Getting list of tables");
|
||||
sqlite3_stmt *vm;
|
||||
const char *tail;
|
||||
QStringList r;
|
||||
int err=0;
|
||||
QString num;
|
||||
int idxnum =0;
|
||||
int tabnum = 0;
|
||||
// qDebug ("Getting list of tables");
|
||||
sqlite3_stmt *vm;
|
||||
const char *tail;
|
||||
QStringList r;
|
||||
int err=0;
|
||||
QString num;
|
||||
int idxnum =0;
|
||||
int tabnum = 0;
|
||||
|
||||
idxmap.clear();
|
||||
tbmap.clear();
|
||||
idxmap.clear();
|
||||
tbmap.clear();
|
||||
|
||||
lastErrorMessage = QString("no error");
|
||||
QString statement = "SELECT name, sql "
|
||||
"FROM sqlite_master "
|
||||
"WHERE type='table' ;";
|
||||
lastErrorMessage = QString("no error");
|
||||
QString statement = "SELECT name, sql "
|
||||
"FROM sqlite_master "
|
||||
"WHERE type='table' ;";
|
||||
|
||||
err=sqlite3_prepare(_db, (const char *) statement,statement.length(),
|
||||
&vm, &tail);
|
||||
if (err == SQLITE_OK){
|
||||
logSQL(statement, kLogMsg_App);
|
||||
while ( sqlite3_step(vm) == SQLITE_ROW ){
|
||||
num.setNum(tabnum);
|
||||
QString val1, val2;
|
||||
val1 = QString((const char *) sqlite3_column_text(vm, 0));
|
||||
val2 = QString((const char *) sqlite3_column_text(vm, 1));
|
||||
tbmap[num] = DBBrowserTable(GetDecodedQString(val1), GetDecodedQString(val2));
|
||||
tabnum++;
|
||||
}
|
||||
sqlite3_finalize(vm);
|
||||
}else{
|
||||
qDebug ("could not get list of tables: %d, %s",err,sqlite3_errmsg(_db));
|
||||
}
|
||||
|
||||
//now get the field list for each table in tbmap
|
||||
tableMap::Iterator it;
|
||||
for ( it = tbmap.begin(); it != tbmap.end(); ++it ) {
|
||||
statement = "PRAGMA TABLE_INFO(";
|
||||
statement.append( (const char *) GetEncodedQString(it.data().getname()));
|
||||
statement.append(");");
|
||||
logSQL(statement, kLogMsg_App);
|
||||
err=sqlite3_prepare(_db,statement,statement.length(),
|
||||
&vm, &tail);
|
||||
if (err == SQLITE_OK){
|
||||
it.data(). fldmap.clear();
|
||||
int e = 0;
|
||||
while ( sqlite3_step(vm) == SQLITE_ROW ){
|
||||
if (sqlite3_column_count(vm)==6) {
|
||||
QString val1, val2;
|
||||
int ispk= 0;
|
||||
val1 = QString((const char *) sqlite3_column_text(vm, 1));
|
||||
val2 = QString((const char *) sqlite3_column_text(vm, 2));
|
||||
ispk = sqlite3_column_int(vm, 5);
|
||||
if (ispk==1){
|
||||
val2.append(QString(" PRIMARY KEY"));
|
||||
}
|
||||
it.data().addField(e,GetDecodedQString(val1),GetDecodedQString(val2));
|
||||
e++;
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(vm);
|
||||
} else{
|
||||
lastErrorMessage = QString ("could not get types");
|
||||
}
|
||||
}
|
||||
statement = "SELECT name, sql "
|
||||
"FROM sqlite_master "
|
||||
"WHERE type='index' ";
|
||||
/*"ORDER BY name;"*/
|
||||
//finally get indices
|
||||
err=sqlite3_prepare(_db,statement,statement.length(),
|
||||
&vm, &tail);
|
||||
err=sqlite3_prepare(_db, (const char *) statement.toUtf8(),statement.length(),
|
||||
&vm, &tail);
|
||||
if (err == SQLITE_OK){
|
||||
logSQL(statement, kLogMsg_App);
|
||||
if (err == SQLITE_OK){
|
||||
while ( sqlite3_step(vm) == SQLITE_ROW ){
|
||||
QString val1, val2;
|
||||
val1 = QString((const char *) sqlite3_column_text(vm, 0));
|
||||
val2 = QString((const char *) sqlite3_column_text(vm, 1));
|
||||
num.setNum(idxnum);
|
||||
idxmap[num] = DBBrowserIndex(GetDecodedQString(val1),GetDecodedQString(val2));
|
||||
idxnum ++;
|
||||
}
|
||||
sqlite3_finalize(vm);
|
||||
}else{
|
||||
lastErrorMessage = QString ("could not get list of indices");
|
||||
while ( sqlite3_step(vm) == SQLITE_ROW ){
|
||||
num.setNum(tabnum);
|
||||
QString val1, val2;
|
||||
val1 = QString((const char *) sqlite3_column_text(vm, 0));
|
||||
val2 = QString((const char *) sqlite3_column_text(vm, 1));
|
||||
tbmap[num] = DBBrowserTable(GetDecodedQString(val1), GetDecodedQString(val2));
|
||||
tabnum++;
|
||||
}
|
||||
sqlite3_finalize(vm);
|
||||
}else{
|
||||
qDebug ("could not get list of tables: %d, %s",err,sqlite3_errmsg(_db));
|
||||
}
|
||||
|
||||
//now get the field list for each table in tbmap
|
||||
tableMap::Iterator it;
|
||||
for ( it = tbmap.begin(); it != tbmap.end(); ++it ) {
|
||||
statement = "PRAGMA TABLE_INFO(";
|
||||
statement.append( it.value().getname().toUtf8().constData());
|
||||
statement.append(");");
|
||||
logSQL(statement, kLogMsg_App);
|
||||
err=sqlite3_prepare(_db,statement.toUtf8(),statement.length(),
|
||||
&vm, &tail);
|
||||
if (err == SQLITE_OK){
|
||||
it.value(). fldmap.clear();
|
||||
int e = 0;
|
||||
while ( sqlite3_step(vm) == SQLITE_ROW ){
|
||||
if (sqlite3_column_count(vm)==6) {
|
||||
QString val1, val2;
|
||||
int ispk= 0;
|
||||
val1 = QString((const char *) sqlite3_column_text(vm, 1));
|
||||
val2 = QString((const char *) sqlite3_column_text(vm, 2));
|
||||
ispk = sqlite3_column_int(vm, 5);
|
||||
if (ispk==1){
|
||||
val2.append(QString(" PRIMARY KEY"));
|
||||
}
|
||||
it.value().addField(e,GetDecodedQString(val1),GetDecodedQString(val2));
|
||||
e++;
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(vm);
|
||||
} else{
|
||||
lastErrorMessage = QString ("could not get types");
|
||||
}
|
||||
}
|
||||
statement = "SELECT name, sql "
|
||||
"FROM sqlite_master "
|
||||
"WHERE type='index' ";
|
||||
/*"ORDER BY name;"*/
|
||||
//finally get indices
|
||||
err=sqlite3_prepare(_db,statement.toUtf8(),statement.length(),
|
||||
&vm, &tail);
|
||||
logSQL(statement, kLogMsg_App);
|
||||
if (err == SQLITE_OK){
|
||||
while ( sqlite3_step(vm) == SQLITE_ROW ){
|
||||
QString val1, val2;
|
||||
val1 = QString((const char *) sqlite3_column_text(vm, 0));
|
||||
val2 = QString((const char *) sqlite3_column_text(vm, 1));
|
||||
num.setNum(idxnum);
|
||||
idxmap[num] = DBBrowserIndex(GetDecodedQString(val1),GetDecodedQString(val2));
|
||||
idxnum ++;
|
||||
}
|
||||
sqlite3_finalize(vm);
|
||||
}else{
|
||||
lastErrorMessage = QString ("could not get list of indices");
|
||||
}
|
||||
}
|
||||
|
||||
QStringList DBBrowserDB::decodeCSV(const QString & csvfilename, char sep, char quote, int maxrecords, int * numfields)
|
||||
{
|
||||
QFile file(csvfilename);
|
||||
QStringList result;
|
||||
QString current = "";
|
||||
bool inquotemode = false;
|
||||
bool inescapemode = false;
|
||||
int recs = 0;
|
||||
*numfields = 0;
|
||||
QFile file(csvfilename);
|
||||
QStringList result;
|
||||
QString current = "";
|
||||
bool inquotemode = false;
|
||||
bool inescapemode = false;
|
||||
int recs = 0;
|
||||
*numfields = 0;
|
||||
|
||||
if ( file.open( QIODevice::ReadWrite ) ) {
|
||||
QProgressDialog progress("Decoding CSV file...", "Cancel", 0, file.size());
|
||||
progress.setWindowModality(Qt::ApplicationModal);
|
||||
char c=0;
|
||||
char c=0;
|
||||
while ( c!=-1) {
|
||||
c = file.getch();
|
||||
if (c==quote){
|
||||
if (inquotemode){
|
||||
if (inescapemode){
|
||||
inescapemode = false;
|
||||
//add the escaped char here
|
||||
current.append(c);
|
||||
} else {
|
||||
//are we escaping, or just finishing the quote?
|
||||
char d = file.getch();
|
||||
if (d==quote) {
|
||||
inescapemode = true;
|
||||
} else {
|
||||
inquotemode = false;
|
||||
}
|
||||
file.ungetch(d);
|
||||
}
|
||||
} else {
|
||||
inquotemode = true;
|
||||
}
|
||||
} else if (c==sep) {
|
||||
if (inquotemode){
|
||||
//add the sep here
|
||||
current.append(c);
|
||||
} else {
|
||||
//not quoting, start new record
|
||||
result << current;
|
||||
current = "";
|
||||
}
|
||||
} else if (c==10) {
|
||||
if (inquotemode){
|
||||
//add the newline
|
||||
current.append(c);
|
||||
} else {
|
||||
//not quoting, start new record
|
||||
result << current;
|
||||
current = "";
|
||||
//for the first line, store the field count
|
||||
if (*numfields == 0){
|
||||
*numfields = result.count();
|
||||
}
|
||||
recs++;
|
||||
progress.setValue(file.pos());
|
||||
if (progress.wasCanceled()) break;
|
||||
if ((recs>maxrecords)&&(maxrecords!=-1)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (c==13) {
|
||||
if (inquotemode){
|
||||
//add the carrier return if in quote mode only
|
||||
current.append(c);
|
||||
}
|
||||
} else {//another character type
|
||||
current.append(c);
|
||||
}
|
||||
}
|
||||
file.getChar(&c);
|
||||
if (c==quote){
|
||||
if (inquotemode){
|
||||
if (inescapemode){
|
||||
inescapemode = false;
|
||||
//add the escaped char here
|
||||
current.append(c);
|
||||
} else {
|
||||
//are we escaping, or just finishing the quote?
|
||||
char d;
|
||||
file.getChar(&d);
|
||||
if (d==quote) {
|
||||
inescapemode = true;
|
||||
} else {
|
||||
inquotemode = false;
|
||||
}
|
||||
file.ungetChar(d);
|
||||
}
|
||||
} else {
|
||||
inquotemode = true;
|
||||
}
|
||||
} else if (c==sep) {
|
||||
if (inquotemode){
|
||||
//add the sep here
|
||||
current.append(c);
|
||||
} else {
|
||||
//not quoting, start new record
|
||||
result << current;
|
||||
current = "";
|
||||
}
|
||||
} else if (c==10) {
|
||||
if (inquotemode){
|
||||
//add the newline
|
||||
current.append(c);
|
||||
} else {
|
||||
//not quoting, start new record
|
||||
result << current;
|
||||
current = "";
|
||||
//for the first line, store the field count
|
||||
if (*numfields == 0){
|
||||
*numfields = result.count();
|
||||
}
|
||||
recs++;
|
||||
progress.setValue(file.pos());
|
||||
if (progress.wasCanceled()) break;
|
||||
if ((recs>maxrecords)&&(maxrecords!=-1)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (c==13) {
|
||||
if (inquotemode){
|
||||
//add the carrier return if in quote mode only
|
||||
current.append(c);
|
||||
}
|
||||
} else {//another character type
|
||||
current.append(c);
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
//do we still have a last result, not appended?
|
||||
//proper csv files should end with a linefeed , so this is not necessary
|
||||
//if (current.length()>0) result << current;
|
||||
//do we still have a last result, not appended?
|
||||
//proper csv files should end with a linefeed , so this is not necessary
|
||||
//if (current.length()>0) result << current;
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <qstringlist.h>
|
||||
#include <qmap.h>
|
||||
#include <q3valuelist.h>
|
||||
#include <qobject.h>
|
||||
#include "sqllogform.h"
|
||||
#include "sqlite3.h"
|
||||
@@ -25,6 +24,8 @@ kEncodingLatin1,
|
||||
kEncodingNONE
|
||||
};
|
||||
|
||||
static QString sOrganisation = QString("duckmansoftware");
|
||||
static QString sApplicationNameShort = QString("sqlitebrowser");
|
||||
static QString applicationName = QString("SQLite Database Browser");
|
||||
static QString applicationIconName = QString(":/oldimages/icon16");
|
||||
static QString aboutText = QString("Version 2.0\n\nSQLite Database Browser is a freeware, public domain, open source visual tool used to create, design and edit database files compatible with SQLite 3.x.\n\nIt has been developed originally by Mauricio Piacentini from Tabuleiro Producoes. \n\nIn the spirit of the original SQLite source code, the author disclaims copyright to this source code.");
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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)
|
||||
sqlLogForm::sqlLogForm(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -45,9 +45,9 @@ void sqlLogForm::log( QString & statement, int msgtype)
|
||||
{
|
||||
if (msgtype==kLogMsg_User)
|
||||
{
|
||||
userLogText->setText(userLogText->text()+statement+"\n");
|
||||
userLogText->setPlainText(userLogText->toPlainText()+statement+"\n");
|
||||
} else {
|
||||
appLogText->setText(appLogText->text()+statement+"\n");
|
||||
appLogText->setPlainText(appLogText->toPlainText()+statement+"\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,6 @@ public:
|
||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||
userLogText = new QTextEdit(WStackPage);
|
||||
userLogText->setObjectName(QString::fromUtf8("userLogText"));
|
||||
userLogText->setTextFormat(Qt::PlainText);
|
||||
userLogText->setReadOnly(true);
|
||||
|
||||
gridLayout->addWidget(userLogText, 0, 0, 1, 1);
|
||||
@@ -110,7 +109,6 @@ public:
|
||||
vboxLayout1->setContentsMargins(0, 0, 0, 0);
|
||||
appLogText = new QTextEdit(WStackPage1);
|
||||
appLogText->setObjectName(QString::fromUtf8("appLogText"));
|
||||
appLogText->setTextFormat(Qt::PlainText);
|
||||
appLogText->setReadOnly(true);
|
||||
|
||||
vboxLayout1->addWidget(appLogText);
|
||||
@@ -152,7 +150,7 @@ 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(QWidget* parent = 0, Qt::WindowFlags fl = Qt::Window);
|
||||
~sqlLogForm();
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
QT += qt3support
|
||||
TEMPLATE = app
|
||||
LANGUAGE = C++
|
||||
INCLUDEPATH += sqlite_source/
|
||||
|
||||
Reference in New Issue
Block a user