Changeset View
Changeset View
Standalone View
Standalone View
src/lib/defaultvariablemodel.h
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 52 | public: | |||
---|---|---|---|---|---|
79 | ~DefaultVariableModel() override = default; | 79 | ~DefaultVariableModel() override = default; | ||
80 | 80 | | |||
81 | /** | 81 | /** | ||
82 | * Get the session which created this Model and whose variables it contains | 82 | * Get the session which created this Model and whose variables it contains | ||
83 | * @return the session | 83 | * @return the session | ||
84 | */ | 84 | */ | ||
85 | Session* session() const; | 85 | Session* session() const; | ||
86 | 86 | | |||
87 | /** | ||||
88 | * Returns variables, stored in this model, as @see Variable. | ||||
89 | */ | ||||
90 | QList<Variable> variables() const; | ||||
91 | | ||||
92 | /** | ||||
93 | * Returns names of stored variables | ||||
94 | */ | ||||
95 | QStringList variableNames() const; | ||||
96 | | ||||
97 | /** | ||||
98 | * Return functions, stored in this model | ||||
99 | */ | ||||
100 | QStringList functions() const; | ||||
101 | | ||||
102 | //TODO: improve the description? | ||||
103 | /** | ||||
104 | * Starts updating variable model (variable lists, etc.). Usually executed after finished all user's commands | ||||
105 | */ | ||||
106 | virtual void update() {}; | ||||
107 | | ||||
87 | public Q_SLOTS: | 108 | public Q_SLOTS: | ||
88 | /** | 109 | /** | ||
89 | * Adds a variable to the model. | 110 | * Adds a variable to the model. | ||
90 | * If a variable with the same name already exists, it will be overwritten. | 111 | * If a variable with the same name already exists, it will be overwritten. | ||
91 | * @param name the name of the variable | 112 | * @param name the name of the variable | ||
92 | * @param value the value of the variable | 113 | * @param value the value of the variable | ||
93 | */ | 114 | */ | ||
94 | void addVariable(const QString& name, const QString& value); | 115 | void addVariable(const QString& name, const QString& value); | ||
Show All 13 Lines | |||||
108 | * @param variable the variable to remove | 129 | * @param variable the variable to remove | ||
109 | */ | 130 | */ | ||
110 | void removeVariable(const Cantor::DefaultVariableModel::Variable& variable); | 131 | void removeVariable(const Cantor::DefaultVariableModel::Variable& variable); | ||
111 | /** | 132 | /** | ||
112 | * Clears all variables from the model | 133 | * Clears all variables from the model | ||
113 | */ | 134 | */ | ||
114 | void clearVariables(); | 135 | void clearVariables(); | ||
115 | 136 | | |||
137 | /** | ||||
138 | * Clears all functions | ||||
139 | */ | ||||
140 | void clearFunctions(); | ||||
141 | | ||||
142 | | ||||
143 | Q_SIGNALS: | ||||
144 | /** | ||||
145 | * Emitted after adding new variables | ||||
146 | * @param variables list of new variables | ||||
147 | */ | ||||
148 | void variablesAdded(const QStringList& variables); | ||||
149 | | ||||
150 | /** | ||||
151 | * Emitted after variables removing | ||||
152 | * @param variables list of removed variables | ||||
153 | */ | ||||
154 | void variablesRemoved(const QStringList& variables); | ||||
155 | | ||||
156 | /** | ||||
157 | * Similar to @c variablesAdded | ||||
158 | */ | ||||
159 | void functionsAdded(const QStringList& names); | ||||
160 | | ||||
161 | /** | ||||
162 | * Similar to @c variablesRemoved | ||||
163 | */ | ||||
164 | void functionsRemoved(const QStringList funcs); | ||||
116 | 165 | | |||
117 | protected: | 166 | protected: | ||
118 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | 167 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||
119 | bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; | 168 | bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; | ||
120 | 169 | | |||
121 | int columnCount(const QModelIndex& parent = QModelIndex()) const override; | 170 | int columnCount(const QModelIndex& parent = QModelIndex()) const override; | ||
122 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | 171 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||
123 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; | 172 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; | ||
124 | Qt::ItemFlags flags(const QModelIndex& index) const override; | 173 | Qt::ItemFlags flags(const QModelIndex& index) const override; | ||
125 | 174 | | |||
175 | void setVariables(const QList<DefaultVariableModel::Variable>& newVars); | ||||
176 | void setFunctions(const QStringList& newFuns); | ||||
177 | | ||||
126 | enum Column | 178 | enum Column | ||
127 | { | 179 | { | ||
128 | NameColumn = 0, | 180 | NameColumn = 0, | ||
129 | ValueColumn = 1, | 181 | ValueColumn = 1, | ||
130 | ColumnCount = 2 | 182 | ColumnCount = 2 | ||
131 | }; | 183 | }; | ||
132 | 184 | | |||
133 | private: | 185 | private: | ||
Show All 10 Lines |