Skip to content

Commit a0663c7

Browse files
author
Jim Hamill
committed
Updated lots
1 parent 4041f4a commit a0663c7

26 files changed

+782
-59
lines changed

BrowseWidget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ bool BrowseWidget::setTable(QString table)
7474

7575
void BrowseWidget::on_filterButton_clicked()
7676
{
77+
// Set filter and then select (otherwise it doesn't always work)
7778
m_model->setFilter(ui->filterEdit->text());
79+
m_model->select();
7880
}
7981

8082
void BrowseWidget::on_removeButton_clicked()

ColumnDialog.cpp

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#include "ColumnDialog.h"
2+
#include "ui_ColumnDialog.h"
3+
4+
#include "Extension/Extension.h"
5+
6+
ColumnDialog::ColumnDialog(QWidget *parent) :
7+
QDialog(parent),
8+
ui(new Ui::ColumnDialog)
9+
{
10+
ui->setupUi(this);
11+
}
12+
13+
ColumnDialog::~ColumnDialog()
14+
{
15+
delete ui;
16+
}
17+
18+
void ColumnDialog::setDataTypes(QMap<QString, int> dataTypes)
19+
{
20+
QMap<QString, int>::const_iterator i = dataTypes.constBegin();
21+
while (i != dataTypes.constEnd()) {
22+
ui->typeComboBox->addItem(i.key(), QVariant(i.value()));
23+
++i;
24+
}
25+
26+
}
27+
28+
void ColumnDialog::setName(QString name)
29+
{
30+
ui->nameLineEdit->setText(name);
31+
}
32+
33+
void ColumnDialog::setType(QString type)
34+
{
35+
ui->typeComboBox->setCurrentIndex(ui->typeComboBox->findText(type));
36+
}
37+
38+
void ColumnDialog::setLength(int length)
39+
{
40+
ui->lengthLineEdit->setText(QString::number(length));
41+
}
42+
43+
void ColumnDialog::setNullable(bool nullable)
44+
{
45+
ui->nullableCheckBox->setChecked(nullable);
46+
}
47+
48+
void ColumnDialog::setDefaultValue(QString defaultValue)
49+
{
50+
ui->defaultLineEdit->setText(defaultValue);
51+
}
52+
53+
QString ColumnDialog::getName()
54+
{
55+
return ui->nameLineEdit->text();
56+
}
57+
58+
QString ColumnDialog::getType()
59+
{
60+
return ui->typeComboBox->currentText();
61+
}
62+
63+
int ColumnDialog::getLength()
64+
{
65+
if (!ui->lengthLineEdit->isEnabled()) {
66+
return false;
67+
}
68+
69+
return ui->lengthLineEdit->text().toInt();
70+
}
71+
72+
bool ColumnDialog::getNullable()
73+
{
74+
if (!ui->nullableCheckBox->isEnabled()) {
75+
return false;
76+
}
77+
78+
return ui->nullableCheckBox->isChecked();
79+
}
80+
81+
QString ColumnDialog::getDefault()
82+
{
83+
if (!ui->defaultLineEdit->isEnabled()) {
84+
return "";
85+
}
86+
87+
return ui->defaultLineEdit->text();
88+
}
89+
90+
void ColumnDialog::on_typeComboBox_currentIndexChanged(int index)
91+
{
92+
int flags = ui->typeComboBox->itemData(index).toInt();
93+
94+
if (flags & HAS_LENGTH) {
95+
ui->lengthLineEdit->setEnabled(true);
96+
} else {
97+
ui->lengthLineEdit->setEnabled(false);
98+
}
99+
100+
if (flags & HAS_NULLABLE) {
101+
ui->nullableCheckBox->setEnabled(true);
102+
} else {
103+
ui->nullableCheckBox->setEnabled(false);
104+
}
105+
106+
if (flags & HAS_DEFAULT) {
107+
ui->defaultLineEdit->setEnabled(true);
108+
} else {
109+
ui->defaultLineEdit->setEnabled(false);
110+
}
111+
}

ColumnDialog.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifndef COLUMNDIALOG_H
2+
#define COLUMNDIALOG_H
3+
4+
#include <QDialog>
5+
#include <QMap>
6+
7+
namespace Ui {
8+
class ColumnDialog;
9+
}
10+
11+
class ColumnDialog : public QDialog
12+
{
13+
Q_OBJECT
14+
15+
public:
16+
explicit ColumnDialog(QWidget *parent = 0);
17+
~ColumnDialog();
18+
19+
void setDataTypes(QMap<QString, int> dataTypes);
20+
21+
void setName(QString name);
22+
void setType(QString type);
23+
void setLength(int length);
24+
void setNullable(bool nullable);
25+
void setDefaultValue(QString defaultValue);
26+
27+
QString getName();
28+
QString getType();
29+
int getLength();
30+
bool getNullable();
31+
QString getDefault();
32+
33+
private slots:
34+
void on_typeComboBox_currentIndexChanged(int index);
35+
36+
private:
37+
Ui::ColumnDialog *ui;
38+
};
39+
40+
#endif // COLUMNDIALOG_H

ColumnDialog.ui

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>ColumnDialog</class>
4+
<widget class="QDialog" name="ColumnDialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>318</width>
10+
<height>214</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Column Properties</string>
15+
</property>
16+
<layout class="QGridLayout" name="gridLayout_2">
17+
<item row="0" column="0">
18+
<widget class="QGroupBox" name="groupBox">
19+
<property name="title">
20+
<string>Column Properties</string>
21+
</property>
22+
<layout class="QGridLayout" name="gridLayout">
23+
<item row="4" column="1">
24+
<widget class="QLineEdit" name="defaultLineEdit"/>
25+
</item>
26+
<item row="3" column="0">
27+
<widget class="QLabel" name="label_3">
28+
<property name="text">
29+
<string>Nullable:</string>
30+
</property>
31+
</widget>
32+
</item>
33+
<item row="1" column="1">
34+
<widget class="QComboBox" name="typeComboBox"/>
35+
</item>
36+
<item row="4" column="0">
37+
<widget class="QLabel" name="label_4">
38+
<property name="text">
39+
<string>Default:</string>
40+
</property>
41+
</widget>
42+
</item>
43+
<item row="1" column="0">
44+
<widget class="QLabel" name="label_2">
45+
<property name="text">
46+
<string>Type:</string>
47+
</property>
48+
</widget>
49+
</item>
50+
<item row="3" column="1">
51+
<widget class="QCheckBox" name="nullableCheckBox">
52+
<property name="text">
53+
<string/>
54+
</property>
55+
</widget>
56+
</item>
57+
<item row="0" column="0">
58+
<widget class="QLabel" name="label">
59+
<property name="text">
60+
<string>Name:</string>
61+
</property>
62+
</widget>
63+
</item>
64+
<item row="0" column="1">
65+
<widget class="QLineEdit" name="nameLineEdit"/>
66+
</item>
67+
<item row="2" column="0">
68+
<widget class="QLabel" name="label_5">
69+
<property name="text">
70+
<string>Length:</string>
71+
</property>
72+
</widget>
73+
</item>
74+
<item row="2" column="1">
75+
<widget class="QLineEdit" name="lengthLineEdit"/>
76+
</item>
77+
</layout>
78+
</widget>
79+
</item>
80+
<item row="1" column="0">
81+
<widget class="QDialogButtonBox" name="buttonBox">
82+
<property name="orientation">
83+
<enum>Qt::Horizontal</enum>
84+
</property>
85+
<property name="standardButtons">
86+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
87+
</property>
88+
</widget>
89+
</item>
90+
</layout>
91+
</widget>
92+
<resources/>
93+
<connections>
94+
<connection>
95+
<sender>buttonBox</sender>
96+
<signal>accepted()</signal>
97+
<receiver>ColumnDialog</receiver>
98+
<slot>accept()</slot>
99+
<hints>
100+
<hint type="sourcelabel">
101+
<x>248</x>
102+
<y>254</y>
103+
</hint>
104+
<hint type="destinationlabel">
105+
<x>157</x>
106+
<y>274</y>
107+
</hint>
108+
</hints>
109+
</connection>
110+
<connection>
111+
<sender>buttonBox</sender>
112+
<signal>rejected()</signal>
113+
<receiver>ColumnDialog</receiver>
114+
<slot>reject()</slot>
115+
<hints>
116+
<hint type="sourcelabel">
117+
<x>316</x>
118+
<y>260</y>
119+
</hint>
120+
<hint type="destinationlabel">
121+
<x>286</x>
122+
<y>274</y>
123+
</hint>
124+
</hints>
125+
</connection>
126+
</connections>
127+
</ui>

Database.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "Database.h"
2+
3+
Database::Database()
4+
{
5+
}

Database.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndef DATABASE_H
2+
#define DATABASE_H
3+
4+
#include <QSqlDatabase>
5+
6+
class Query
7+
{
8+
public:
9+
Query();
10+
11+
private:
12+
QString m_query;
13+
QString m_datetime;
14+
};
15+
16+
class Database : public QSqlDatabase
17+
{
18+
public:
19+
Database();
20+
21+
QString getName();
22+
23+
QSqlQuery executeQuery(QString query);
24+
25+
QList<Query> getSavedQueries();
26+
QList<Query> getHistoricalQueries();
27+
};
28+
29+
#endif // DATABASE_H

DatabaseConnectionWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ bool DatabaseConnectionWidget::createSshTunnel(QString hostname, int remotePort,
5757
m_sshTunnel.start("ssh", arguments);
5858

5959
// Wait until finished
60-
if (!m_sshTunnel.waitForFinished(5000)) {
60+
if (!m_sshTunnel.waitForFinished(10000)) {
6161
return false;
6262
}
6363

ExplorerWidget.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,14 @@ void ExplorerWidget::init(QSqlDatabase *database, Extension *extension)
5252
// Set the database for child widgets
5353
ui->browseTab->setDatabase(m_database);
5454

55-
// Add the schema editor from the extension
56-
if (m_extension) {
57-
m_schemaWidget = m_extension->createSchemaWidget(this);
55+
// Setup schema widget (if supported by extension)
56+
if (m_extension && m_extension->hasCapability(VIEW_SCHEMA)) {
57+
m_schemaWidget = new SchemaWidget(this, m_database, m_extension);
58+
m_schemaWidget->init();
59+
ui->tabWidget->addTab(m_schemaWidget, QIcon::fromTheme("document-edit"), "Schema");
60+
connect(m_schemaWidget, SIGNAL(refreshNeeded()), this, SLOT(refresh()));
5861
}
5962

60-
// If the extension does not contain its own schema widget, use default
61-
if (!m_schemaWidget) {
62-
m_schemaWidget = new SchemaWidget(this, m_database);
63-
}
64-
65-
// Initalise schema widget and add tab
66-
m_schemaWidget->init();
67-
ui->tabWidget->addTab(m_schemaWidget, QIcon::fromTheme("document-edit"), "Schema");
68-
6963
// Refresh table list
7064
refresh();
7165
}
@@ -85,8 +79,13 @@ void ExplorerWidget::refresh()
8579

8680
void ExplorerWidget::on_tableListWidget_itemActivated(QListWidgetItem *item)
8781
{
82+
// Set the browse tab to this table
8883
ui->browseTab->setTable(item->text());
89-
m_schemaWidget->setTable(item->text());
84+
85+
// If schema is supported, then set schema to this table
86+
if (m_schemaWidget) {
87+
m_schemaWidget->setTable(item->text());
88+
}
9089
}
9190

9291
void ExplorerWidget::addTable()

0 commit comments

Comments
 (0)