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 --- .../guiSQLiteStudio/windows/functionseditormodel.h | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 SQLiteStudio3/guiSQLiteStudio/windows/functionseditormodel.h (limited to 'SQLiteStudio3/guiSQLiteStudio/windows/functionseditormodel.h') diff --git a/SQLiteStudio3/guiSQLiteStudio/windows/functionseditormodel.h b/SQLiteStudio3/guiSQLiteStudio/windows/functionseditormodel.h new file mode 100644 index 0000000..79f073f --- /dev/null +++ b/SQLiteStudio3/guiSQLiteStudio/windows/functionseditormodel.h @@ -0,0 +1,98 @@ +#ifndef FUNCTIONSEDITORMODEL_H +#define FUNCTIONSEDITORMODEL_H + +#include "services/config.h" +#include "services/functionmanager.h" +#include "guiSQLiteStudio_global.h" +#include +#include + +class GUI_API_EXPORT FunctionsEditorModel : public QAbstractListModel +{ + Q_OBJECT + + public: + using QAbstractItemModel::setData; + + enum Role + { + CODE = 1000, + MODIFIED = 1001, + VALID = 1002, + TYPE = 1003 + }; + + explicit FunctionsEditorModel(QObject *parent = 0); + + void clearModified(); + bool isModified() const; + bool isModified(int row) const; + void setModified(int row, bool modified); + bool isValid() const; + bool isValid(int row) const; + void setValid(int row, bool valid); + void setCode(int row, const QString& code); + QString getCode(int row) const; + void setFinalCode(int row, const QString& code); + QString getFinalCode(int row) const; + void setInitCode(int row, const QString& code); + QString getInitCode(int row) const; + void setName(int row, const QString& newName); + QString getName(int row) const; + void setLang(int row, const QString& lang); + QString getLang(int row) const; + QStringList getDatabases(int row) const; + void setDatabases(int row, const QStringList& value); + QStringList getArguments(int row) const; + void setArguments(int row, const QStringList& value); + FunctionManager::ScriptFunction::Type getType(int row) const; + void setType(int row, FunctionManager::ScriptFunction::Type type); + bool isAggregate(int row) const; + bool isScalar(int row) const; + bool getUndefinedArgs(int row) const; + void setUndefinedArgs(int row, bool value); + bool getAllDatabases(int row) const; + void setAllDatabases(int row, bool value); + void setData(const QList& functions); + void addFunction(FunctionManager::ScriptFunction* function); + void deleteFunction(int row); + QList generateFunctions() const; + QStringList getFunctionNames() 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 Function + { + Function(); + Function(FunctionManager::ScriptFunction* other); + + FunctionManager::ScriptFunction data; + bool modified = false; + bool valid = true; + QString originalName; + }; + + void init(); + void emitDataChanged(int row); + + QList functionList; + + /** + * @brief List of function pointers before modifications. + * + * This list is kept to check for modifications in the overall list of functions. + * Pointers on this list may be already deleted, so don't use them! + * It's only used to compare list of pointers to functionList, so it can tell you + * if the list was modified in regards of adding or deleting functions. + */ + QList originalFunctionList; + QHash langToIcon; + bool listModified = false; +}; + +#endif // FUNCTIONSEDITORMODEL_H -- cgit v1.2.3