commands.h

来自「Qt4源代码,详细介绍了Qt4编程中的范例」· C头文件 代码 · 共 68 行

H
68
字号
#ifndef COMMANDS_H
#define COMMANDS_H

#include <QUndoCommand>
#include <QTableWidget>
#include <QColor>
#include <QList>

class UndoWidget;

class TextColorCommand : public QUndoCommand
{
public:
	TextColorCommand(UndoWidget *undoWidget, QColor beforeColor, QColor afterColor, QUndoCommand *parent = 0);

    void undo();
    void redo();

private:
	QList<QTableWidgetItem*> affectedItems;
	QColor before;
	QColor after;
};

class BkgColorCommand : public QUndoCommand
{
public:
	BkgColorCommand(UndoWidget *undoWidget, QColor beforeColor, QColor afterColor, QUndoCommand *parent = 0);

    void undo();
    void redo();

private:
	QList<QTableWidgetItem*> affectedItems;
	QColor before;
	QColor after;
};

class FontCommand : public QUndoCommand
{
public:
	FontCommand(UndoWidget *undoWidget, QFont beforeFont, QFont afterFont, QUndoCommand *parent = 0);

    void undo();
    void redo();

private:
	QList<QTableWidgetItem*> affectedItems;
	QFont before;
	QFont after;
};

class EditCommand : public QUndoCommand
{
public:
	EditCommand(QTableWidgetItem *item, QString beforeText, QString afterText, QUndoCommand *parent = 0);

    void undo();
    void redo();

private:
	QTableWidgetItem* affectedItem;
	QString before;
	QString after;
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?