Various tweaks and things

This commit is contained in:
Raoul Snyman 2011-06-24 15:26:14 +02:00
parent ee9de66380
commit 84d085fe60
8 changed files with 131 additions and 32 deletions

16
.bzrignore Normal file
View File

@ -0,0 +1,16 @@
moc_mainwindow.cpp
moc_mainwindow.o
moc_registerdialog.cpp
moc_registerdialog.o
moc_sqlform.cpp
moc_sqlform.o
moc_tableform.cpp
moc_tableform.o
ui_mainwindow.h
ui_registerdialog.h
ui_sqlform.h
ui_tableform.h
IoSQL
qrc_IoSQL.cpp
qrc_IoSQL.o
IoSQL.pro.user

View File

@ -1,21 +1,21 @@
#############################################################################
# Makefile for building: IoSQL
# Generated by qmake (2.01a) (Qt 4.7.2) on: Wed Jun 22 13:31:58 2011
# Generated by qmake (2.01a) (Qt 4.7.2) on: Fri Jun 24 13:41:46 2011
# Project: IoSQL.pro
# Template: app
# Command: /usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug QMLJSDEBUGGER_PATH=/usr/share/qtcreator/qml/qmljsdebugger -o Makefile IoSQL.pro
# Command: /usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ QMLJSDEBUGGER_PATH=/usr/share/qtcreator/qml/qmljsdebugger -o Makefile IoSQL.pro
#############################################################################
####### Compiler, tools and options
CC = gcc
CXX = g++
DEFINES = -DQT_SQL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
DEFINES = -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtSql -I/usr/include/qt4 -I/usr/include/qt4/Qsci -I. -I.
LINK = g++
LFLAGS =
LFLAGS = -Wl,-O1
LIBS = $(SUBLIBS) -L/usr/lib -lqscintilla2 -lQtSql -lQtGui -lQtNetwork -lQtCore -lpthread
AR = ar cqs
RANLIB =
@ -72,7 +72,7 @@ DIST = /usr/share/qt4/mkspecs/common/g++.conf \
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
/usr/share/qt4/mkspecs/features/default_pre.prf \
/usr/share/qt4/mkspecs/features/debug.prf \
/usr/share/qt4/mkspecs/features/release.prf \
/usr/share/qt4/mkspecs/features/default_post.prf \
/usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/qt.prf \
@ -125,7 +125,7 @@ Makefile: IoSQL.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
/usr/share/qt4/mkspecs/features/default_pre.prf \
/usr/share/qt4/mkspecs/features/debug.prf \
/usr/share/qt4/mkspecs/features/release.prf \
/usr/share/qt4/mkspecs/features/default_post.prf \
/usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/qt.prf \
@ -140,7 +140,7 @@ Makefile: IoSQL.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/
/usr/lib/libQtGui.prl \
/usr/lib/libQtNetwork.prl \
/usr/lib/libQtCore.prl
$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug QMLJSDEBUGGER_PATH=/usr/share/qtcreator/qml/qmljsdebugger -o Makefile IoSQL.pro
$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ QMLJSDEBUGGER_PATH=/usr/share/qtcreator/qml/qmljsdebugger -o Makefile IoSQL.pro
/usr/share/qt4/mkspecs/common/g++.conf:
/usr/share/qt4/mkspecs/common/unix.conf:
/usr/share/qt4/mkspecs/common/linux.conf:
@ -151,7 +151,7 @@ Makefile: IoSQL.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/
/usr/share/qt4/mkspecs/features/qt_config.prf:
/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
/usr/share/qt4/mkspecs/features/default_pre.prf:
/usr/share/qt4/mkspecs/features/debug.prf:
/usr/share/qt4/mkspecs/features/release.prf:
/usr/share/qt4/mkspecs/features/default_post.prf:
/usr/share/qt4/mkspecs/features/warn_on.prf:
/usr/share/qt4/mkspecs/features/qt.prf:
@ -167,7 +167,7 @@ Makefile: IoSQL.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/
/usr/lib/libQtNetwork.prl:
/usr/lib/libQtCore.prl:
qmake: FORCE
@$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug QMLJSDEBUGGER_PATH=/usr/share/qtcreator/qml/qmljsdebugger -o Makefile IoSQL.pro
@$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ QMLJSDEBUGGER_PATH=/usr/share/qtcreator/qml/qmljsdebugger -o Makefile IoSQL.pro
dist:
@$(CHK_DIR_EXISTS) .tmp/IoSQL1.0.0 || $(MKDIR) .tmp/IoSQL1.0.0

View File

@ -116,26 +116,6 @@ void MainWindow::loadConnection(QString connectionName, QString serverType, QStr
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(connectionName));
item->setIcon(0, QIcon(":/Server/images/server-database-register.png"));
ui->DatabaseTreeWidget->addTopLevelItem(item);
QSettings settings;
if (!settings.contains("connection " + connectionName))
{
QMap<QString, QVariant> connectionMap;
connectionMap.insert("connectionName", connectionName);
connectionMap.insert("serverType", serverType);
connectionMap.insert("serverName", serverName);
connectionMap.insert("serverPort", serverPort);
connectionMap.insert("databaseName", databaseName);
connectionMap.insert("username", username);
connectionMap.insert("password", password);
settings.setValue("connection " + connectionName, connectionMap);
QStringList connectionList;
if (settings.contains("connectionList"))
{
connectionList = settings.value("connectionList").toStringList();
}
connectionList.append(connectionName);
settings.setValue("connectionList", connectionList);
}
}
bool MainWindow::setupConnection(QString connectionName, QString serverType, QString serverName, int serverPort, QString databaseName, QString username, QString password)
@ -244,6 +224,7 @@ void MainWindow::on_DatabaseRegisterAction_triggered()
m_RegisterDialog->username(),
m_RegisterDialog->password()
);
m_QueryForm->reloadConnections();
}
}
@ -343,6 +324,7 @@ void MainWindow::on_DatabaseDeregisterAction_triggered()
}
delete item;
}
m_QueryForm->reloadConnections();
}
}
@ -480,6 +462,7 @@ void MainWindow::on_DatabaseEditAction_triggered()
settings.setValue("connection " + connectionName, connectionMap);
item->setText(0, connectionName);
}
m_QueryForm->reloadConnections();
}
}

View File

@ -1,5 +1,10 @@
#include "sqlform.h"
#include "ui_sqlform.h"
#include <QComboBox>
#include <QSqlDatabase>
#include <QSqlTableModel>
#include <QSqlQueryModel>
#include <QSettings>
#include <Qsci/qscilexersql.h>
SqlForm::SqlForm(QWidget *parent) :
@ -18,13 +23,31 @@ SqlForm::SqlForm(QWidget *parent) :
}
ui->setupUi(this);
ui->QueryTextEdit->setLexer(lexer);
m_ConnectionComboBox = new QComboBox(this);
reloadConnections();
ui->QueryToolBar->addWidget(m_ConnectionComboBox);
m_QueryModel = 0;
}
SqlForm::~SqlForm()
{
delete m_ConnectionComboBox;
delete m_QueryModel;
delete ui;
}
void SqlForm::reloadConnections()
{
QSettings settings;
QStringList connectionList = settings.value("connectionList").toStringList();
m_ConnectionComboBox->clear();
for (int i = 0; i < connectionList.count(); i++)
{
QMap<QString, QVariant> connectionMap = settings.value("connection " + connectionList.at(i)).toMap();
m_ConnectionComboBox->addItem(connectionMap.value("connectionName").toString());
}
}
void SqlForm::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
@ -36,3 +59,26 @@ void SqlForm::changeEvent(QEvent *e)
break;
}
}
void SqlForm::on_RunQueryAction_triggered()
{
m_Database = QSqlDatabase::database(m_ConnectionComboBox->currentText());
m_Database.open();
QCoreApplication::processEvents();
QString query = "";
if (m_QueryModel == 0)
{
m_QueryModel = new QSqlQueryModel;
}
if (ui->QueryTextEdit->hasSelectedText())
{
query = ui->QueryTextEdit->selectedText();
}
else
{
query = ui->QueryTextEdit->text();
}
m_QueryModel->setQuery(query, m_Database);
ui->ResultsTableView->setModel(m_QueryModel);
ui->ResultsTableView->resizeColumnsToContents();
}

View File

@ -2,6 +2,9 @@
#define SQLFORM_H
#include <QDialog>
#include <QComboBox>
#include <QSqlDatabase>
#include <QSqlQueryModel>
#include <Qsci/qsciscintilla.h>
namespace Ui {
@ -13,12 +16,19 @@ class SqlForm : public QDialog {
public:
SqlForm(QWidget *parent = 0);
~SqlForm();
void reloadConnections();
protected:
void changeEvent(QEvent *e);
private slots:
void on_RunQueryAction_triggered();
private:
Ui::SqlForm *ui;
QSqlDatabase m_Database;
QSqlQueryModel *m_QueryModel;
QComboBox *m_ConnectionComboBox;
};
#endif // SQLFORM_H

View File

@ -20,6 +20,30 @@
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QToolBar" name="QueryToolBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<addaction name="RunQueryAction"/>
<addaction name="separator"/>
</widget>
</item>
<item>
<widget class="QSplitter" name="SqlSplitter">
<property name="orientation">
@ -37,6 +61,21 @@
</widget>
</item>
</layout>
<action name="RunQueryAction">
<property name="icon">
<iconset resource="IoSQL.qrc">
<normaloff>:/Table/images/run-build.png</normaloff>:/Table/images/run-build.png</iconset>
</property>
<property name="text">
<string>Run Query</string>
</property>
<property name="toolTip">
<string>Run the selected SQL query.</string>
</property>
<property name="shortcut">
<string>F5</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
@ -45,6 +84,8 @@
<header>Qsci/qsciscintilla.h</header>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="IoSQL.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -3,6 +3,7 @@
#include <QSqlDatabase>
#include <QSqlTableModel>
#include <QSqlQueryModel>
#include <QSqlRecord>
#include <QSqlField>
#include <QTableWidgetItem>

View File

@ -2,7 +2,9 @@
#define TABLEFORM_H
#include <QWidget>
#include <QSqlDatabase>
#include <QSqlTableModel>
#include <QSqlQueryModel>
namespace Ui {
class TableForm;