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 | | ||||
87 | public Q_SLOTS: | 97 | public Q_SLOTS: | ||
88 | /** | 98 | /** | ||
89 | * Adds a variable to the model. | 99 | * Adds a variable to the model. | ||
90 | * If a variable with the same name already exists, it will be overwritten. | 100 | * If a variable with the same name already exists, it will be overwritten. | ||
91 | * @param name the name of the variable | 101 | * @param name the name of the variable | ||
92 | * @param value the value of the variable | 102 | * @param value the value of the variable | ||
93 | */ | 103 | */ | ||
94 | void addVariable(const QString& name, const QString& value); | 104 | void addVariable(const QString& name, const QString& value); | ||
Show All 13 Lines | |||||
108 | * @param variable the variable to remove | 118 | * @param variable the variable to remove | ||
109 | */ | 119 | */ | ||
110 | void removeVariable(const Cantor::DefaultVariableModel::Variable& variable); | 120 | void removeVariable(const Cantor::DefaultVariableModel::Variable& variable); | ||
111 | /** | 121 | /** | ||
112 | * Clears all variables from the model | 122 | * Clears all variables from the model | ||
113 | */ | 123 | */ | ||
114 | void clearVariables(); | 124 | void clearVariables(); | ||
115 | 125 | | |||
126 | Q_SIGNALS: | ||||
127 | /** | ||||
128 | * Emitted after adding new variables | ||||
129 | * @param variables list of new variables | ||||
130 | */ | ||||
131 | void variablesAdded(const QStringList& variables); | ||||
132 | | ||||
133 | /** | ||||
134 | * Emitted after variables removing | ||||
135 | * @param variables list of removed variables | ||||
136 | */ | ||||
137 | void variablesRemoved(const QStringList& variables); | ||||
116 | 138 | | |||
117 | protected: | 139 | protected: | ||
118 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | 140 | 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; | 141 | bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; | ||
120 | 142 | | |||
121 | int columnCount(const QModelIndex& parent = QModelIndex()) const override; | 143 | int columnCount(const QModelIndex& parent = QModelIndex()) const override; | ||
122 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | 144 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||
123 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; | 145 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; | ||
124 | Qt::ItemFlags flags(const QModelIndex& index) const override; | 146 | Qt::ItemFlags flags(const QModelIndex& index) const override; | ||
125 | 147 | | |||
148 | void setVariables(const QList<DefaultVariableModel::Variable>& newVars); | ||||
149 | | ||||
126 | enum Column | 150 | enum Column | ||
127 | { | 151 | { | ||
128 | NameColumn = 0, | 152 | NameColumn = 0, | ||
129 | ValueColumn = 1, | 153 | ValueColumn = 1, | ||
130 | ColumnCount = 2 | 154 | ColumnCount = 2 | ||
131 | }; | 155 | }; | ||
132 | 156 | | |||
133 | private: | 157 | private: | ||
Show All 10 Lines |