Files
GenericQtClientCore/model/commands/insertrowscommand.cpp

34 lines
955 B
C++

#include "insertrowscommand.h"
#include <QDebug>
#include "../tablemodel.h"
InsertRowsCommand::InsertRowsCommand(TableModel* model,
int startRow,
QList<ModelItemValues> valueList,
QUndoCommand* parent)
: QUndoCommand(parent)
, m_tableModel(model)
, m_startRow(startRow)
, m_valueList(valueList) {
qInfo() << "New InsertCommand...";
const QString commandText =
QString("inserting %1 item(s) on row %2").arg(valueList.length()).arg(startRow);
setText(commandText);
}
void InsertRowsCommand::undo() {
qDebug() << "Undoing the InsertCommand...";
if (m_tableModel) {
m_tableModel->execRemoveItems(m_startRow, m_valueList.length());
}
}
void InsertRowsCommand::redo() {
qDebug() << "(Re-)doing the InsertCommand...";
if (m_tableModel) {
m_tableModel->execInsertItems(m_startRow, m_valueList);
}
}