-
Notifications
You must be signed in to change notification settings - Fork 0
/
commandclasshighlight.cpp
48 lines (36 loc) · 1.51 KB
/
commandclasshighlight.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "commandclasshighlight.h"
#include "maintablewidget.h"
CommandClassHighlight::CommandClassHighlight(int row, int col, QString highlighter, \
MainTableWidget *m_ptableWidget, \
QObject*)
{
this->row = row;
this->col = col;
this->m_tableWidget = m_ptableWidget;
this->oldHighlight = new QString( m_ptableWidget->item(row,col)->data(Qt::UserRole).\
toStringList().at(MainTableOptions::ClassHighlight) );
this->newHighlight = new QString( highlighter );
}
CommandClassHighlight::~CommandClassHighlight()
{
delete this->newHighlight;
delete this->oldHighlight;
}
void CommandClassHighlight::undo()
{
QStringList oldData = this->m_tableWidget->item(row,col)->data(Qt::UserRole).toStringList();
oldData.replace(MainTableOptions::ClassHighlight, *this->oldHighlight);
this->m_tableWidget->item(row,col)->setData(Qt::UserRole, (QVariant)oldData);
this->m_tableWidget->hide();
this->m_tableWidget->show();
m_tableWidget->setCurrentCell(row, col);
}
void CommandClassHighlight::redo()
{
QStringList oldData = this->m_tableWidget->item(row,col)->data(Qt::UserRole).toStringList();
oldData.replace(MainTableOptions::ClassHighlight, *this->newHighlight);
this->m_tableWidget->item(row,col)->setData(Qt::UserRole, (QVariant)oldData);
this->m_tableWidget->hide();
this->m_tableWidget->show();
m_tableWidget->setCurrentCell(row, col);
}