-
Notifications
You must be signed in to change notification settings - Fork 0
/
commandteacheredit.cpp
47 lines (38 loc) · 1.32 KB
/
commandteacheredit.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
#include "commandteacheredit.h"
#include "maintablewidget.h"
#include <QStringList>
#include <QHeaderView>
CommandTeacherEdit::CommandTeacherEdit(int column, QString name, \
MainTableWidget *m_pTableWidget, \
QObject*)
{
this->editedColumn = column;
this->headerBefore = m_pTableWidget->HTableHeader().at(column);
this->m_tableWidget = m_pTableWidget;
QString formattedName;
foreach( const QChar c, name )
{
formattedName.append(c);
formattedName.append("\n");
}
this->headerAfter = formattedName;
QString nameBefore = headerBefore.remove("\n");
setText( QString("%1 to %2 at %3").arg(nameBefore).arg(name).arg(column));
}
CommandTeacherEdit::~CommandTeacherEdit()
{
}
void CommandTeacherEdit::undo()
{
QStringList tmpList = this->m_tableWidget->HTableHeader();
tmpList.replace(this->editedColumn, this->headerBefore);
this->m_tableWidget->setHTableHeader(tmpList);
this->m_tableWidget->setHorizontalHeaderLabels(tmpList);
}
void CommandTeacherEdit::redo()
{
QStringList tmpList = this->m_tableWidget->HTableHeader();
tmpList.replace(this->editedColumn, this->headerAfter);
this->m_tableWidget->setHTableHeader(tmpList);
this->m_tableWidget->setHorizontalHeaderLabels(tmpList);
}