Skip to content

Commit 148b2e4

Browse files
author
Jim Hamill
committed
Some fixes and efficiency improvements
1 parent 1f4e889 commit 148b2e4

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

BrowseWidget.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <QSqlRecord>
88
#include <QSqlField>
99
#include <QSqlError>
10+
#include <QSqlQuery>
1011

1112
#include <QMessageBox>
1213

@@ -45,6 +46,9 @@ bool BrowseWidget::setTable(QString table)
4546
commitChanges();
4647
}
4748

49+
// Set new table
50+
m_table = table;
51+
4852
// Create model
4953
m_model->setTable(table);
5054
m_model->setEditStrategy(QSqlTableModel::OnFieldChange);
@@ -119,10 +123,8 @@ void BrowseWidget::on_clearButton_clicked()
119123
// Display messagebox for confirmation
120124
if (QMessageBox::Yes == QMessageBox::question(this, "Clear Table", "Are you sure you want to clear this table?")) {
121125

122-
// Remove all rows TODO make more efficient
123-
for (int i = 0; i < m_model->rowCount(); i++) {
124-
m_model->removeRow(i);
125-
}
126+
// Remove all rows (TODO Will this work across all SQL implementations?)
127+
m_database->exec("DELETE FROM " + m_table);
126128

127129
// Refresh browse widget
128130
m_model->select();

BrowseWidget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ private slots:
4444

4545
// Model for table
4646
QSqlTableModel *m_model;
47+
48+
// Current Table
49+
QString m_table;
4750
};
4851

4952
#endif // BROWSEWIDGET_H

DatabaseConnectionWidget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ bool DatabaseConnectionWidget::importDatabase()
157157
qDebug() << "Error: " << statement;
158158
}
159159

160+
// If the cancel button was clicked, abort
161+
if (progress.wasCanceled())
162+
return false;
163+
160164
// Increment progress bar value
161165
progress.setValue(splitter.getPosition());
162166
}

MainWindow.ui

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
<bool>true</bool>
132132
</property>
133133
<property name="windowTitle">
134-
<string>toolBar</string>
134+
<string>Main Toolbar</string>
135135
</property>
136136
<attribute name="toolBarArea">
137137
<enum>TopToolBarArea</enum>
@@ -188,7 +188,7 @@
188188
</action>
189189
<action name="actionAbout_QuteSql">
190190
<property name="icon">
191-
<iconset theme="database">
191+
<iconset theme="help-about">
192192
<normaloff/>
193193
</iconset>
194194
</property>
@@ -198,7 +198,7 @@
198198
</action>
199199
<action name="actionAbout_Qt">
200200
<property name="icon">
201-
<iconset theme="qt">
201+
<iconset theme="help-about">
202202
<normaloff/>
203203
</iconset>
204204
</property>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Todo
44

55
- Create wrapper QSqlDatabase class (with functions like executeQuery(), getName(), etc)
6-
- Create log tab that shows history of all SQL commands executed. (Should do as list view or something)
6+
- Create log tab that shows history of all SQL commands executed. (Should do as list view or something... maybe a table with DATE and COMMAND)
77
- Store settings in SQLite Database (Storing using QSettings is inconvenient with arrays.)
88
- Export selected
99

0 commit comments

Comments
 (0)