From 7167ce41b61d2ba2cdb526777a4233eb84a3b66a Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sat, 6 Dec 2014 17:33:25 -0500 Subject: Imported Upstream version 2.99.6 --- .../windows/collationseditormodel.h | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 SQLiteStudio3/guiSQLiteStudio/windows/collationseditormodel.h (limited to 'SQLiteStudio3/guiSQLiteStudio/windows/collationseditormodel.h') diff --git a/SQLiteStudio3/guiSQLiteStudio/windows/collationseditormodel.h b/SQLiteStudio3/guiSQLiteStudio/windows/collationseditormodel.h new file mode 100644 index 0000000..0c17c5b --- /dev/null +++ b/SQLiteStudio3/guiSQLiteStudio/windows/collationseditormodel.h @@ -0,0 +1,77 @@ +#ifndef COLLATIONSEDITORMODEL_H +#define COLLATIONSEDITORMODEL_H + +#include "services/collationmanager.h" +#include "guiSQLiteStudio_global.h" +#include +#include +#include + +class GUI_API_EXPORT CollationsEditorModel : public QAbstractListModel +{ + Q_OBJECT + public: + using QAbstractItemModel::setData; + + explicit CollationsEditorModel(QObject *parent = 0); + + void clearModified(); + bool isModified() const; + bool isModified(int row) const; + void setModified(int row, bool modified); + void setName(int row, const QString& name); + QString getName(int row) const; + void setLang(int row, const QString& lang); + QString getLang(int row) const; + void setAllDatabases(int row, bool allDatabases); + bool getAllDatabases(int row) const; + void setCode(int row, const QString& code); + QString getCode(int row) const; + void setDatabases(int row, const QStringList& databases); + QStringList getDatabases(int row); + bool isValid(int row) const; + void setValid(int row, bool valid); + bool isValid() const; + void setData(const QList& collations); + void addCollation(const CollationManager::CollationPtr& collation); + void deleteCollation(int row); + QList getCollations() const; + QStringList getCollationNames() const; + void validateNames(); + bool isAllowedName(int rowToSkip, const QString& nameToValidate); + bool isValidRowIndex(int row) const; + + int rowCount(const QModelIndex& parent = QModelIndex()) const; + QVariant data(const QModelIndex& index, int role) const; + + private: + struct Collation + { + Collation(); + Collation(const CollationManager::CollationPtr& other); + + CollationManager::CollationPtr data; + bool modified = false; + bool valid = true; + QString originalName; + }; + + void init(); + void emitDataChanged(int row); + + QList collationList; + + /** + * @brief List of collation pointers before modifications. + * + * This list is kept to check for modifications in the overall list of collations. + * Pointers on this list may be already deleted, so don't use them! + * It's only used to compare list of pointers to collationList, so it can tell you + * if the list was modified in regards of adding or deleting collations. + */ + QList originalCollationList; + QHash langToIcon; + bool listModified = false; +}; + +#endif // COLLATIONSEDITORMODEL_H -- cgit v1.2.3