code format
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
#include "historyview.h"
|
||||
#include <QScrollBar>
|
||||
|
||||
#include <QEvent>
|
||||
#include <QScrollBar>
|
||||
|
||||
|
||||
HistoryView::HistoryView(QWidget* parent): QListWidget(parent) {
|
||||
HistoryView::HistoryView(QWidget * parent): QListWidget(parent) {
|
||||
setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
setEditTriggers(NoEditTriggers);
|
||||
active_ = true;
|
||||
active_ = true;
|
||||
duplicates_ = false;
|
||||
index = 0;
|
||||
index = 0;
|
||||
setLimit(32);
|
||||
setHistoryColor(palette().color(QPalette::Highlight));
|
||||
connect(this, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemClicked(QListWidgetItem*)));
|
||||
connect(this, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(itemClicked(QListWidgetItem *)));
|
||||
connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(itemSelectionChanged()));
|
||||
registerAction(-1, tr("History cleared"), QImage(":/icons/clear-history.png"));
|
||||
}
|
||||
|
||||
|
||||
HistoryView::~HistoryView() {
|
||||
}
|
||||
HistoryView::~HistoryView() {}
|
||||
|
||||
|
||||
QByteArray HistoryView::current() const {
|
||||
@@ -37,8 +37,7 @@ void HistoryView::addEntry(int action, int count_, const QString & suffix) {
|
||||
QByteArray ba;
|
||||
emit commandRequest(ba);
|
||||
if (!duplicates_)
|
||||
if (current() == ba)
|
||||
return;
|
||||
if (current() == ba) return;
|
||||
int cnt = count();
|
||||
for (int i = index; i < cnt; ++i)
|
||||
if (i >= 0) delete takeItem(index);
|
||||
@@ -94,11 +93,8 @@ void HistoryView::checkLimit() {
|
||||
void HistoryView::changeEvent(QEvent * e) {
|
||||
QListWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
actions_[-1].text = tr("History cleared");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case QEvent::LanguageChange: actions_[-1].text = tr("History cleared"); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +103,7 @@ void HistoryView::itemClicked(QListWidgetItem * item) {
|
||||
if (!active_) return;
|
||||
if (index == row(item) + 1) return;
|
||||
index = row(item) + 1;
|
||||
//qDebug() << actions[index - 1].command;
|
||||
// qDebug() << actions[index - 1].command;
|
||||
emit commandExecute(history_[index - 1].command);
|
||||
emit changed();
|
||||
itemSelectionChanged();
|
||||
@@ -117,7 +113,7 @@ void HistoryView::itemClicked(QListWidgetItem * item) {
|
||||
void HistoryView::itemSelectionChanged() {
|
||||
if (!active_) return;
|
||||
if (index < 1) index = 1;
|
||||
//qDebug() << "changed" << count();
|
||||
// qDebug() << "changed" << count();
|
||||
int vpos = verticalScrollBar()->value();
|
||||
blockSignals(true);
|
||||
setCurrentItem(item(index - 1));
|
||||
|
||||
Reference in New Issue
Block a user