Changeset View
Changeset View
Standalone View
Standalone View
src/core/kconcatenaterowsproxymodel.cpp
Show First 20 Lines • Show All 143 Lines • ▼ Show 20 Line(s) | 143 | if (d->m_models.isEmpty()) { | |||
---|---|---|---|---|---|
144 | return 0; | 144 | return 0; | ||
145 | } | 145 | } | ||
146 | if (parent.isValid()) { | 146 | if (parent.isValid()) { | ||
147 | return 0; // flat model; | 147 | return 0; // flat model; | ||
148 | } | 148 | } | ||
149 | return d->m_models.at(0)->columnCount(QModelIndex()); | 149 | return d->m_models.at(0)->columnCount(QModelIndex()); | ||
150 | } | 150 | } | ||
151 | 151 | | |||
152 | QHash<int, QByteArray> KConcatenateRowsProxyModel::roleNames() const | ||||
153 | { | ||||
154 | if (d->m_models.isEmpty()) { | ||||
155 | return {}; | ||||
156 | } | ||||
157 | return d->m_models.at(0)->roleNames(); | ||||
158 | } | ||||
159 | | ||||
152 | QModelIndex KConcatenateRowsProxyModel::index(int row, int column, const QModelIndex &parent) const | 160 | QModelIndex KConcatenateRowsProxyModel::index(int row, int column, const QModelIndex &parent) const | ||
153 | { | 161 | { | ||
154 | if(row < 0) { | 162 | if(row < 0) { | ||
155 | return {}; | 163 | return {}; | ||
156 | } | 164 | } | ||
157 | if(column < 0) { | 165 | if(column < 0) { | ||
158 | return {}; | 166 | return {}; | ||
159 | } | 167 | } | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 191 | { | |||
207 | } | 215 | } | ||
208 | d->m_rowCount += newRows; | 216 | d->m_rowCount += newRows; | ||
209 | d->m_models.append(sourceModel); | 217 | d->m_models.append(sourceModel); | ||
210 | if (newRows > 0) { | 218 | if (newRows > 0) { | ||
211 | endInsertRows(); | 219 | endInsertRows(); | ||
212 | } | 220 | } | ||
213 | } | 221 | } | ||
214 | 222 | | |||
223 | QList<QAbstractItemModel*> KConcatenateRowsProxyModel::sources() const | ||||
224 | { | ||||
225 | return d->m_models; | ||||
226 | } | ||||
227 | | ||||
228 | | ||||
229 | | ||||
215 | void KConcatenateRowsProxyModel::removeSourceModel(QAbstractItemModel *sourceModel) | 230 | void KConcatenateRowsProxyModel::removeSourceModel(QAbstractItemModel *sourceModel) | ||
216 | { | 231 | { | ||
217 | Q_ASSERT(d->m_models.contains(sourceModel)); | 232 | Q_ASSERT(d->m_models.contains(sourceModel)); | ||
218 | disconnect(sourceModel, nullptr, this, nullptr); | 233 | disconnect(sourceModel, nullptr, this, nullptr); | ||
219 | 234 | | |||
220 | const int rowsRemoved = sourceModel->rowCount(); | 235 | const int rowsRemoved = sourceModel->rowCount(); | ||
221 | const int rowsPrior = d->computeRowsPrior(sourceModel); // location of removed section | 236 | const int rowsPrior = d->computeRowsPrior(sourceModel); // location of removed section | ||
222 | 237 | | |||
▲ Show 20 Lines • Show All 200 Lines • Show Last 20 Lines |