aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.h
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2014-12-06 17:33:25 -0500
committerLibravatarUnit 193 <unit193@ubuntu.com>2014-12-06 17:33:25 -0500
commit7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch)
treea35c14143716e1f2c98f808c81f89426045a946f /SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.h
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.h')
-rw-r--r--SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.h135
1 files changed, 135 insertions, 0 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.h b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.h
new file mode 100644
index 0000000..c92fa2c
--- /dev/null
+++ b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.h
@@ -0,0 +1,135 @@
+#ifndef DBTREEMODEL_H
+#define DBTREEMODEL_H
+
+#include "db/db.h"
+#include "dbtreeitem.h"
+#include "services/config.h"
+#include "guiSQLiteStudio_global.h"
+#include "common/strhash.h"
+#include <QStandardItemModel>
+#include <QObject>
+
+class DbManager;
+class DbTreeView;
+class DbPlugin;
+class DbObjectOrganizer;
+class QMenu;
+class QCheckBox;
+
+class GUI_API_EXPORT DbTreeModel : public QStandardItemModel
+{
+ Q_OBJECT
+
+ public:
+ DbTreeModel();
+ ~DbTreeModel();
+
+ void connectDbManagerSignals();
+ DbTreeItem* findItem(DbTreeItem::Type type, const QString &name);
+ DbTreeItem* findItem(DbTreeItem::Type type, Db* db);
+ DbTreeItem* findItemBySignature(const QString& signature);
+ QList<DbTreeItem*> findItems(DbTreeItem::Type type);
+ void move(QStandardItem* itemToMove, QStandardItem* newParentItem, int newRow = -1);
+ void move(QStandardItem* itemToMove, int newRow);
+ DbTreeItem *createGroup(const QString& name, QStandardItem *parent = nullptr);
+ void deleteGroup(QStandardItem* groupItem);
+ QStandardItem *root() const;
+ QStringList getGroupFor(QStandardItem* item);
+ void storeGroups();
+ void refreshSchema(Db* db);
+ QList<DbTreeItem*> getAllItemsAsFlatList() const;
+ void setTreeView(DbTreeView *value);
+ QVariant data(const QModelIndex &index, int role) const;
+ QStringList mimeTypes() const;
+ QMimeData* mimeData(const QModelIndexList &indexes) const;
+ bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
+ bool pasteData(const QMimeData* data, int row, int column, const QModelIndex& parent, Qt::DropAction defaultAction = Qt::IgnoreAction,
+ bool *invokeStdAction = nullptr);
+ void interruptableStarted(Interruptable* obj);
+ void interruptableFinished(Interruptable* obj);
+ bool getIgnoreDbLoadedSignal() const;
+ void setIgnoreDbLoadedSignal(bool value);
+ bool hasDbTreeItem(const QMimeData* data);
+ QList<DbTreeItem*> getDragItems(const QMimeData* data);
+ QList<DbTreeItem*> getItemsForIndexes(const QModelIndexList& indexes) const;
+
+ static DbTreeItem* findItem(QStandardItem *parentItem, DbTreeItem::Type type, const QString &name);
+ static DbTreeItem* findItem(QStandardItem* parentItem, DbTreeItem::Type type, Db* db);
+ static QList<DbTreeItem*> findItems(QStandardItem* parentItem, DbTreeItem::Type type);
+ static void staticInit();
+
+ static const constexpr char* MIMETYPE = "application/x-sqlitestudio-dbtreeitem";
+
+ private:
+ void readGroups(QList<Db*> dbList);
+ QList<Config::DbGroupPtr> childsToConfig(QStandardItem* item);
+ void restoreGroup(const Config::DbGroupPtr& group, QList<Db*>* dbList = nullptr, QStandardItem *parent = nullptr);
+ bool applyFilter(QStandardItem* parentItem, const QString& filter);
+ void refreshSchema(Db* db, QStandardItem* item);
+ void collectExpandedState(QHash<QString, bool>& state, QStandardItem* parentItem = nullptr);
+ QStandardItem* refreshSchemaDb(Db* db);
+ QList<QStandardItem*> refreshSchemaTables(const QStringList &tables, const QStringList& virtualTables, bool sort);
+ StrHash<QList<QStandardItem*> > refreshSchemaTableColumns(const StrHash<QStringList>& columns);
+ StrHash<QList<QStandardItem*> > refreshSchemaIndexes(const StrHash<QStringList>& indexes, bool sort);
+ StrHash<QList<QStandardItem*> > refreshSchemaTriggers(const StrHash<QStringList>& triggers, bool sort);
+ QList<QStandardItem*> refreshSchemaViews(const QStringList &views, bool sort);
+ void populateChildItemsWithDb(QStandardItem* parentItem, Db* db);
+ void refreshSchemaBuild(QStandardItem* dbItem, QList<QStandardItem*> tables, StrHash<QList<QStandardItem*> > indexes,
+ StrHash<QList<QStandardItem*> > triggers, QList<QStandardItem*> views, StrHash<QList<QStandardItem*> > allTableColumns);
+ void restoreExpandedState(const QHash<QString, bool>& expandedState, QStandardItem* parentItem);
+ QString getToolTip(DbTreeItem *item) const;
+ QString getDbToolTip(DbTreeItem *item) const;
+ QString getTableToolTip(DbTreeItem *item) const;
+ QList<DbTreeItem*> getChildsAsFlatList(QStandardItem* item) const;
+ bool dropDbTreeItem(const QList<DbTreeItem*>& srcItems, DbTreeItem* dstItem, Qt::DropAction defaultAction, bool &invokeStdDropAction);
+ bool dropDbObjectItem(const QList<DbTreeItem*>& srcItems, DbTreeItem* dstItem, Qt::DropAction defaultAction);
+ QCheckBox* createCopyOrMoveMenuCheckBox(QMenu* menu, const QString& label);
+ bool dropUrls(const QList<QUrl>& urls);
+ void moveOrCopyDbObjects(const QList<DbTreeItem*>& srcItems, DbTreeItem* dstItem, bool move, bool includeData, bool includeIndexes, bool includeTriggers);
+
+ static bool confirmReferencedTables(const QStringList& tables);
+ static bool resolveNameConflict(QString& nameInConflict);
+ static bool confirmConversion(const QList<QPair<QString,QString>>& diffs);
+ static bool confirmConversionErrors(const QHash<QString, QSet<QString> >& errors);
+
+ static const QString toolTipTableTmp;
+ static const QString toolTipHdrRowTmp;
+ static const QString toolTipRowTmp;
+ static const QString toolTipIconRowTmp;
+
+ DbTreeView* treeView = nullptr;
+ bool requireSchemaReloading = false;
+ DbObjectOrganizer* dbOrganizer = nullptr;
+ QList<Interruptable*> interruptables;
+ bool ignoreDbLoadedSignal = false;
+ QString currentFilter;
+
+ private slots:
+ void expanded(const QModelIndex &index);
+ void collapsed(const QModelIndex &index);
+ void dbAdded(Db* db);
+ void dbUpdated(const QString &oldName, Db* db);
+ void dbRemoved(Db* db);
+ void dbConnected(Db* db);
+ void dbDisconnected(Db* db);
+ void dbUnloaded(Db* db);
+ void dbLoaded(Db* db);
+ void massSaveBegins();
+ void massSaveCommited();
+ void markSchemaReloadingRequired();
+ void dbObjectsMoveFinished(bool success, Db* srcDb, Db* dstDb);
+ void dbObjectsCopyFinished(bool success, Db* srcDb, Db* dstDb);
+
+ public slots:
+ void loadDbList();
+ void itemChangedVisibility(DbTreeItem* item);
+ void applyFilter(const QString& filter);
+ void dbRemoved(const QString& name);
+ void dbRemoved(QStandardItem* item);
+ void interrupt();
+
+ signals:
+ void updateItemHidden(DbTreeItem* item);
+};
+
+#endif // DBTREEMODEL_H