aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/common
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2015-04-04 14:41:04 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2015-04-04 14:41:04 -0400
commita5b034d4a9c44f9bc1e83b01de82530f8fc63013 (patch)
tree7a358206c4aff9c33df1752c92eafec97cee2244 /SQLiteStudio3/coreSQLiteStudio/common
parent306d6d3ca9c9ad774d19135681a7f9805f77035f (diff)
Imported Upstream version 3.0.4upstream/3.0.4
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/common')
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/common/global.h7
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/common/signalwait.cpp29
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/common/signalwait.h23
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/common/table.cpp40
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/common/table.h17
5 files changed, 116 insertions, 0 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/common/global.h b/SQLiteStudio3/coreSQLiteStudio/common/global.h
index bc228ca..b1f4b01 100644
--- a/SQLiteStudio3/coreSQLiteStudio/common/global.h
+++ b/SQLiteStudio3/coreSQLiteStudio/common/global.h
@@ -32,6 +32,13 @@
var = nullptr; \
}
+#define qobject_safe_delete(var) \
+ if (var) \
+ { \
+ var->deleteLater(); \
+ var = nullptr; \
+ }
+
#define static_char static constexpr const char
#define static_qstring(N,V) const static QString N = QStringLiteral(V)
diff --git a/SQLiteStudio3/coreSQLiteStudio/common/signalwait.cpp b/SQLiteStudio3/coreSQLiteStudio/common/signalwait.cpp
new file mode 100644
index 0000000..90f9075
--- /dev/null
+++ b/SQLiteStudio3/coreSQLiteStudio/common/signalwait.cpp
@@ -0,0 +1,29 @@
+#include "signalwait.h"
+#include <QCoreApplication>
+#include <QTime>
+
+SignalWait::SignalWait(QObject* object, const char* signal) :
+ QObject()
+{
+ connect(object, signal, this, SLOT(handleSignal()));
+}
+
+bool SignalWait::wait(int msTimeout)
+{
+ QTime timer(0, 0, 0, msTimeout);
+ timer.start();
+ while (!called && timer.elapsed() < msTimeout)
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+
+ return called;
+}
+
+void SignalWait::reset()
+{
+ called = false;
+}
+
+void SignalWait::handleSignal()
+{
+ called = true;
+}
diff --git a/SQLiteStudio3/coreSQLiteStudio/common/signalwait.h b/SQLiteStudio3/coreSQLiteStudio/common/signalwait.h
new file mode 100644
index 0000000..7b7b903
--- /dev/null
+++ b/SQLiteStudio3/coreSQLiteStudio/common/signalwait.h
@@ -0,0 +1,23 @@
+#ifndef SIGNALWAIT_H
+#define SIGNALWAIT_H
+
+#include <QObject>
+
+class SignalWait : public QObject
+{
+ Q_OBJECT
+
+ public:
+ SignalWait(QObject *object, const char *signal);
+
+ bool wait(int msTimeout);
+ void reset();
+
+ private:
+ bool called = false;
+
+ private slots:
+ void handleSignal();
+};
+
+#endif // SIGNALWAIT_H
diff --git a/SQLiteStudio3/coreSQLiteStudio/common/table.cpp b/SQLiteStudio3/coreSQLiteStudio/common/table.cpp
index c590995..a9b0f16 100644
--- a/SQLiteStudio3/coreSQLiteStudio/common/table.cpp
+++ b/SQLiteStudio3/coreSQLiteStudio/common/table.cpp
@@ -50,3 +50,43 @@ int qHash(Table table)
{
return qHash(table.getDatabase() + "." + table.getTable());
}
+
+AliasedTable::AliasedTable()
+{
+}
+
+AliasedTable::AliasedTable(const QString& database, const QString& table, const QString& alias) :
+ Table(database, table)
+{
+ setTableAlias(alias);
+}
+
+AliasedTable::AliasedTable(const AliasedTable& other) :
+ Table(other.database, other.table)
+{
+ tableAlias = other.tableAlias;
+}
+
+AliasedTable::~AliasedTable()
+{
+}
+
+int AliasedTable::operator ==(const AliasedTable& other) const
+{
+ return other.database == this->database && other.table == this->table && other.tableAlias == this->tableAlias;
+}
+
+QString AliasedTable::getTableAlias() const
+{
+ return tableAlias;
+}
+
+void AliasedTable::setTableAlias(const QString& value)
+{
+ tableAlias = value;
+}
+
+int qHash(AliasedTable table)
+{
+ return qHash(table.getDatabase() + "." + table.getTable() + " " + table.getTableAlias());
+}
diff --git a/SQLiteStudio3/coreSQLiteStudio/common/table.h b/SQLiteStudio3/coreSQLiteStudio/common/table.h
index d17a729..5cc4570 100644
--- a/SQLiteStudio3/coreSQLiteStudio/common/table.h
+++ b/SQLiteStudio3/coreSQLiteStudio/common/table.h
@@ -23,10 +23,27 @@ class API_EXPORT Table
protected:
QString database;
QString table;
+};
+
+class API_EXPORT AliasedTable : public Table
+{
+ public:
+ AliasedTable();
+ AliasedTable(const QString& database, const QString& table, const QString& alias);
+ AliasedTable(const AliasedTable& other);
+ virtual ~AliasedTable();
+ int operator ==(const AliasedTable& other) const;
+
+ QString getTableAlias() const;
+ void setTableAlias(const QString& value);
+
+ protected:
+ QString tableAlias;
};
int API_EXPORT qHash(Table table);
+int API_EXPORT qHash(AliasedTable table);
#endif // TABLE_H