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 | //TODO: improve the description? | ||||
98 | /** | ||||
99 | * Starts updating variable model (variable lists, etc.). Usually executed after finished all user's commands | ||||
100 | */ | ||||
101 | virtual void update() {}; | ||||
102 | | ||||
87 | public Q_SLOTS: | 103 | public Q_SLOTS: | ||
88 | /** | 104 | /** | ||
89 | * Adds a variable to the model. | 105 | * Adds a variable to the model. | ||
90 | * If a variable with the same name already exists, it will be overwritten. | 106 | * If a variable with the same name already exists, it will be overwritten. | ||
91 | * @param name the name of the variable | 107 | * @param name the name of the variable | ||
92 | * @param value the value of the variable | 108 | * @param value the value of the variable | ||
93 | */ | 109 | */ | ||
94 | void addVariable(const QString& name, const QString& value); | 110 | void addVariable(const QString& name, const QString& value); | ||
Show All 13 Lines | |||||
108 | * @param variable the variable to remove | 124 | * @param variable the variable to remove | ||
109 | */ | 125 | */ | ||
110 | void removeVariable(const Cantor::DefaultVariableModel::Variable& variable); | 126 | void removeVariable(const Cantor::DefaultVariableModel::Variable& variable); | ||
111 | /** | 127 | /** | ||
112 | * Clears all variables from the model | 128 | * Clears all variables from the model | ||
113 | */ | 129 | */ | ||
114 | void clearVariables(); | 130 | void clearVariables(); | ||
115 | 131 | | |||
132 | /** | ||||
133 | * Clears all functions | ||||
134 | */ | ||||
135 | void clearFunctions(); | ||||
136 | | ||||
137 | | ||||
138 | Q_SIGNALS: | ||||
139 | /** | ||||
140 | * Emitted after adding new variables | ||||
141 | * @param variables list of new variables | ||||
142 | */ | ||||
143 | void variablesAdded(const QStringList& variables); | ||||
144 | | ||||
145 | /** | ||||
146 | * Emitted after variables removing | ||||
147 | * @param variables list of removed variables | ||||
148 | */ | ||||
149 | void variablesRemoved(const QStringList& variables); | ||||
150 | | ||||
151 | /** | ||||
152 | * Similar to @c variablesAdded | ||||
153 | */ | ||||
154 | void functionsAdded(const QStringList& names); | ||||
155 | | ||||
156 | /** | ||||
157 | * Similar to @c variablesRemoved | ||||
158 | */ | ||||
159 | void functionsRemoved(const QStringList funcs); | ||||
116 | 160 | | |||
117 | protected: | 161 | protected: | ||
118 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | 162 | 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; | 163 | bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; | ||
120 | 164 | | |||
121 | int columnCount(const QModelIndex& parent = QModelIndex()) const override; | 165 | int columnCount(const QModelIndex& parent = QModelIndex()) const override; | ||
122 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | 166 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||
123 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; | 167 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; | ||
124 | Qt::ItemFlags flags(const QModelIndex& index) const override; | 168 | Qt::ItemFlags flags(const QModelIndex& index) const override; | ||
125 | 169 | | |||
170 | void setVariables(const QList<DefaultVariableModel::Variable>& newVars); | ||||
171 | void setFunctions(const QStringList& newFuns); | ||||
172 | | ||||
126 | enum Column | 173 | enum Column | ||
127 | { | 174 | { | ||
128 | NameColumn = 0, | 175 | NameColumn = 0, | ||
129 | ValueColumn = 1, | 176 | ValueColumn = 1, | ||
130 | ColumnCount = 2 | 177 | ColumnCount = 2 | ||
131 | }; | 178 | }; | ||
132 | 179 | | |||
133 | private: | 180 | private: | ||
Show All 10 Lines |