[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ktorrent] ktorrent/dialogs: improve recent download folders list
From:       Nick Shaforostoff <shafff () ukr ! net>
Date:       2016-12-08 0:30:30
Message-ID: E1cEmbW-0003LR-Jq () code ! kde ! org
[Download RAW message or body]

Git commit 248931f76bccc340e5b049932d88acc27427e511 by Nick Shaforostoff.
Committed on 08/12/2016 at 00:28.
Pushed by shaforo into branch 'master'.

improve recent download folders list

M  +17   -9    ktorrent/dialogs/fileselectdlg.cpp
M  +3    -3    ktorrent/dialogs/fileselectdlg.h

https://commits.kde.org/ktorrent/248931f76bccc340e5b049932d88acc27427e511

diff --git a/ktorrent/dialogs/fileselectdlg.cpp b/ktorrent/dialogs/fileselectdlg.cpp
index b7126af4..b4dc69d9 100644
--- a/ktorrent/dialogs/fileselectdlg.cpp
+++ b/ktorrent/dialogs/fileselectdlg.cpp
@@ -182,12 +182,18 @@ namespace kt
         QString cn = m_completedLocation->url().toLocalFile();
         if (!cn.endsWith('/')) cn += '/';
         if (m_moveCompleted->isChecked() && !cn.isEmpty())
-            move_on_completion_location_history.insert(cn);
+        {
+            move_on_completion_location_history.removeOne(cn);
+            move_on_completion_location_history.prepend(cn);
+        }
 
         QString dn = m_downloadLocation->url().toLocalFile();
         if (!dn.endsWith('/')) dn += '/';
         if (!dn.isEmpty())
-            download_location_history.insert(dn);
+        {
+            download_location_history.removeOne(dn);
+            download_location_history.prepend(dn);
+        }
 
 
         QString tld = tc->getUserModifiedFileName();
@@ -612,10 +618,12 @@ namespace kt
         show_file_tree = g.readEntry("show_file_tree", true);
         m_tree->setChecked(show_file_tree);
         m_list->setChecked(!show_file_tree);
-        QStringList tmp = g.readEntry("download_location_history", QStringList());
-        download_location_history = QSet<QString>::fromList(tmp);
-        tmp = g.readEntry("move_on_completion_location_history", QStringList());
-        move_on_completion_location_history = QSet<QString>::fromList(tmp);
+        download_location_history = g.readEntry("download_location_history", \
QStringList()); +        for (int i=0; i<download_location_history.count(); i++)
+            if (download_location_history.at(i).endsWith(QLatin1String("//"))) \
download_location_history[i].chop(1); +        \
download_location_history.removeDuplicates(); +        \
move_on_completion_location_history = \
g.readEntry("move_on_completion_location_history", QStringList()); +        \
move_on_completion_location_history.removeDuplicates();  
         if (download_location_history.count())
         {
@@ -647,12 +655,12 @@ namespace kt
         KConfigGroup g = cfg->group("FileSelectDlg");
         g.writeEntry("size", size());
         g.writeEntry("show_file_tree", show_file_tree);
-        g.writeEntry("download_location_history", \
                download_location_history.toList());
-        g.writeEntry("move_on_completion_location_history", \
move_on_completion_location_history.toList()); +        \
g.writeEntry("download_location_history", download_location_history); +        \
g.writeEntry("move_on_completion_location_history", \
move_on_completion_location_history);  g.writeEntry("file_view", \
m_file_view->header()->saveState());  }
 
-    QMenu* FileSelectDlg::createHistoryMenu(const QSet<QString> & urls, const char* \
slot) +    QMenu* FileSelectDlg::createHistoryMenu(const QStringList & urls, const \
char* slot)  {
         QMenu* m = new QMenu(this);
         foreach (const QString& url, urls)
diff --git a/ktorrent/dialogs/fileselectdlg.h b/ktorrent/dialogs/fileselectdlg.h
index 3c0b3524..9b76882e 100644
--- a/ktorrent/dialogs/fileselectdlg.h
+++ b/ktorrent/dialogs/fileselectdlg.h
@@ -84,7 +84,7 @@ namespace kt
         void setFilter(const QString& filter);
         void updateExistingFiles();
         void moveCompletedToggled(bool on);
-        QMenu* createHistoryMenu(const QSet<QString> & urls, const char* slot);
+        QMenu* createHistoryMenu(const QStringList& urls, const char* slot);
         void clearDownloadLocationHistory();
         void clearMoveOnCompletionLocationHistory();
         void downloadLocationHistoryTriggered(QAction* act);
@@ -106,8 +106,8 @@ namespace kt
         kt::Group* initial_group;
         bool show_file_tree;
         QSortFilterProxyModel* filter_model;
-        QSet<QString> download_location_history;
-        QSet<QString> move_on_completion_location_history;
+        QStringList download_location_history;
+        QStringList move_on_completion_location_history;
         bt::Uint64 already_downloaded;
     };
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic