summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews/qstandarditemmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/itemviews/qstandarditemmodel.cpp')
-rw-r--r--src/gui/itemviews/qstandarditemmodel.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp
index 9d0f796..30daed2 100644
--- a/src/gui/itemviews/qstandarditemmodel.cpp
+++ b/src/gui/itemviews/qstandarditemmodel.cpp
@@ -1742,18 +1742,21 @@ QList<QStandardItem*> QStandardItem::takeRow(int row)
Q_D(QStandardItem);
if ((row < 0) || (row >= rowCount()))
return QList<QStandardItem*>();
+ if (d->model)
+ d->model->d_func()->rowsAboutToBeRemoved(this, row, row);
QList<QStandardItem*> items;
int index = d->childIndex(row, 0);
- for (int column = 0; column < d->columnCount(); ++column) {
- QStandardItem *ch = d->children.at(index);
- if (ch) {
+ int col_count = d->columnCount();
+ for (int column = 0; column < col_count; ++column) {
+ QStandardItem *ch = d->children.at(index + column);
+ if (ch)
ch->d_func()->setParentAndModel(0, 0);
- d->children.replace(index, 0);
- }
items.append(ch);
- ++index;
}
- removeRow(row);
+ d->children.remove(index, col_count);
+ d->rows--;
+ if (d->model)
+ d->model->d_func()->rowsRemoved(this, row, 1);
return items;
}
@@ -1769,18 +1772,21 @@ QList<QStandardItem*> QStandardItem::takeColumn(int column)
Q_D(QStandardItem);
if ((column < 0) || (column >= columnCount()))
return QList<QStandardItem*>();
+ if (d->model)
+ d->model->d_func()->columnsAboutToBeRemoved(this, column, column);
QList<QStandardItem*> items;
- int index = d->childIndex(0, column);
- for (int row = 0; row < d->rowCount(); ++row) {
+
+ for (int row = d->rowCount() - 1; row >= 0; --row) {
+ int index = d->childIndex(row, column);
QStandardItem *ch = d->children.at(index);
- if (ch) {
+ if (ch)
ch->d_func()->setParentAndModel(0, 0);
- d->children.replace(index, 0);
- }
- items.append(ch);
- index += d->columnCount();
+ d->children.remove(index);
+ items.prepend(ch);
}
- removeColumn(column);
+ d->columns--;
+ if (d->model)
+ d->model->d_func()->columnsRemoved(this, column, 1);
return items;
}