git-svn-id: svn://db.shs.com.ru/libs@188 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
74
qad/application/historyview.h
Normal file
74
qad/application/historyview.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef HISTORYVIEW_H
|
||||
#define HISTORYVIEW_H
|
||||
|
||||
#include <QListWidget>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
class HistoryView: public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(int limit READ limit WRITE setLimit)
|
||||
Q_PROPERTY(QColor historyColor READ historyColor WRITE setHistoryColor)
|
||||
public:
|
||||
explicit HistoryView(QWidget * parent = 0);
|
||||
~HistoryView();
|
||||
|
||||
bool isActive() const {return active_;}
|
||||
int limit() const {return limit_;}
|
||||
QColor historyColor() const {return color_;}
|
||||
|
||||
void addEntry(int action, int count = 0, const QString & suffix = QString());
|
||||
void registerAction(int action, const QString & text, const QImage & icon = QImage());
|
||||
|
||||
private:
|
||||
struct Action {
|
||||
Action(int i = -1, const QString & t = QString(), const QImage & c = QImage()): id(i), text(t) {
|
||||
QPixmap px = QPixmap::fromImage(c);
|
||||
icon.addPixmap(px, QIcon::Active);
|
||||
icon.addPixmap(px, QIcon::Disabled);
|
||||
icon.addPixmap(px, QIcon::Normal);
|
||||
icon.addPixmap(px, QIcon::Selected);
|
||||
}
|
||||
int id;
|
||||
QString text;
|
||||
QIcon icon;
|
||||
};
|
||||
struct Entry {
|
||||
Entry(int a = -1, const QByteArray & c = QByteArray()): action(a), command(c) {}
|
||||
int action;
|
||||
QByteArray command;
|
||||
};
|
||||
|
||||
void checkLimit();
|
||||
QString actionText(int action, int count_);
|
||||
|
||||
QMap<int, Action> actions_;
|
||||
QVector<Entry> history_;
|
||||
QColor color_;
|
||||
bool active_;
|
||||
int index, limit_;
|
||||
|
||||
public slots:
|
||||
void setActive(bool yes) {active_ = yes;}
|
||||
void setLimit(int l);
|
||||
void setHistoryColor(const QColor & c);
|
||||
void clear(bool silent = false);
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
private slots:
|
||||
void itemClicked(QListWidgetItem * item);
|
||||
void itemSelectionChanged();
|
||||
|
||||
signals:
|
||||
void undoAvailable(bool);
|
||||
void redoAvailable(bool);
|
||||
void clearAvailable(bool);
|
||||
void commandRequest(QByteArray & s);
|
||||
void commandExecute(const QByteArray & s);
|
||||
|
||||
};
|
||||
|
||||
#endif // HISTORYVIEW_H
|
||||
Reference in New Issue
Block a user