diff options
| author | 2014-12-06 17:33:25 -0500 | |
|---|---|---|
| committer | 2014-12-06 17:33:25 -0500 | |
| commit | 7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch) | |
| tree | a35c14143716e1f2c98f808c81f89426045a946f /SQLiteStudio3/guiSQLiteStudio/dblistmodel.h | |
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/dblistmodel.h')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/dblistmodel.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/dblistmodel.h b/SQLiteStudio3/guiSQLiteStudio/dblistmodel.h new file mode 100644 index 0000000..121db4d --- /dev/null +++ b/SQLiteStudio3/guiSQLiteStudio/dblistmodel.h @@ -0,0 +1,66 @@ +#ifndef DBLISTMODEL_H +#define DBLISTMODEL_H + +#include "db/db.h" +#include "guiSQLiteStudio_global.h" +#include <QAbstractListModel> + +class QComboBox; + +class GUI_API_EXPORT DbListModel : public QAbstractListModel +{ + Q_OBJECT + public: + enum class SortMode + { + LikeDbTree, + Alphabetical, + ConnectionOrder + }; + + explicit DbListModel(QObject *parent = 0); + ~DbListModel(); + + QVariant data(const QModelIndex & index, int role) const; + int rowCount(const QModelIndex & parent = QModelIndex()) const; + QModelIndex sibling(int row, int column, const QModelIndex & idx) const; + + Db* getDb(int index); + void setSortMode(SortMode sortMode); + SortMode getSortMode() const; + void setSortMode(const QString& sortMode); + QString getSortModeString() const; + void setCombo(QComboBox* combo); + + private: + using QAbstractItemModel::sort; + + class DbTreeComparer + { + public: + DbTreeComparer(); + bool operator()(Db* db1, Db* db2); + + private: + QStringList dbTreeOrder; + }; + + class AlphaComparer + { + public: + bool operator()(Db* db1, Db* db2); + }; + + void sort(); + + QList<Db*> unsortedList; + QList<Db*> dbList; + SortMode sortMode = SortMode::ConnectionOrder; + QComboBox* comboBox = nullptr; + + private slots: + void dbConnected(Db* db); + void dbDisconnected(Db* db); +}; + +#endif // DBLISTMODEL_H |
