git-svn-id: svn://db.shs.com.ru/libs@457 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -7,6 +7,7 @@ HistoryView::HistoryView(QWidget* parent): QListWidget(parent) {
|
||||
setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
setEditTriggers(NoEditTriggers);
|
||||
active_ = true;
|
||||
duplicates_ = false;
|
||||
index = 0;
|
||||
setLimit(32);
|
||||
setHistoryColor(palette().color(QPalette::Highlight));
|
||||
@@ -20,19 +21,34 @@ HistoryView::~HistoryView() {
|
||||
}
|
||||
|
||||
|
||||
QByteArray HistoryView::current() const {
|
||||
QListWidgetItem * ci = currentItem();
|
||||
if (!ci) return QByteArray();
|
||||
int i = row(ci);
|
||||
if (i < 0 || i >= history_.size()) return QByteArray();
|
||||
return history_[i].command;
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::addEntry(int action, int count_, const QString & suffix) {
|
||||
if (!active_) return;
|
||||
QByteArray ba;
|
||||
emit commandRequest(ba);
|
||||
if (!duplicates_)
|
||||
if (current() == ba)
|
||||
return;
|
||||
int cnt = count();
|
||||
for (int i = index; i < cnt; ++i)
|
||||
if (i >= 0) delete takeItem(index);
|
||||
addItem(new QListWidgetItem(actions_.value(action).icon, actionText(action, count_) + suffix));
|
||||
QListWidgetItem * li = new QListWidgetItem(actions_.value(action).icon, actionText(action, count_) + suffix);
|
||||
blockSignals(true);
|
||||
addItem(li);
|
||||
setCurrentItem(li);
|
||||
index = count();
|
||||
history_.resize(index);
|
||||
history_.back() = Entry(action);
|
||||
history_.back() = Entry(action, ba);
|
||||
checkLimit();
|
||||
emit commandRequest(history_.back().command);
|
||||
scrollToItem(item(index - 1));
|
||||
blockSignals(true);
|
||||
for (int i = 0; i < index; ++i)
|
||||
item(i)->setSelected(true);
|
||||
blockSignals(false);
|
||||
@@ -87,6 +103,7 @@ void HistoryView::itemSelectionChanged() {
|
||||
if (index < 1) index = 1;
|
||||
//qDebug() << "changed" << count();
|
||||
blockSignals(true);
|
||||
setCurrentItem(item(index - 1));
|
||||
for (int i = 0; i < index; ++i)
|
||||
item(i)->setSelected(true);
|
||||
for (int i = index; i < count(); ++i)
|
||||
|
||||
Reference in New Issue
Block a user