Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ignored duplicate entries in the HistoryProvider

Currently razorqt-runner can produce duplicates in the history:
if you run the same command from the CustomCommandProvider twice, it
will be inserted into the HistoryProvider-list and the file twice.

This patch checks changes HistoryProvider::AddCommand, so that it will
search if this command already exists and it will move that entry to
the top of the list (instead of creating a new item).
  • Loading branch information...
commit 84985abec791def3aacfa082da1ea9b6db25aa5b 1 parent 7a5216f
@Boris-de Boris-de authored
Showing with 15 additions and 2 deletions.
  1. +15 −2 razorqt-runner/providers.cpp
View
17 razorqt-runner/providers.cpp
@@ -380,8 +380,21 @@ HistoryProvider::~HistoryProvider()
************************************************/
void HistoryProvider::AddCommand(const QString &command)
{
- HistoryItem *item = new HistoryItem(command);
- insert(0, item);
+ bool commandExists = false;
+ for (int i=0; !commandExists && i<length(); ++i)
+ {
+ if (command == static_cast<HistoryItem*>(at(i))->command())
+ {
+ move(i, 0);
+ commandExists = true;
+ }
+ }
+
+ if (!commandExists)
+ {
+ HistoryItem *item = new HistoryItem(command);
+ insert(0, item);
+ }
mHistoryFile->clear();
for (int i=0; i<qMin(length(), MAX_HISTORY); ++i)
Please sign in to comment.
Something went wrong with that request. Please try again.