]> git.sur5r.net Git - minitube/commitdiff
Fixed message item not updating
authorFlavio Tordini <flavio.tordini@gmail.com>
Wed, 29 Jul 2009 07:53:35 +0000 (09:53 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Wed, 29 Jul 2009 07:53:35 +0000 (09:53 +0200)
Also save keywords when the first result is received

src/ListModel.cpp

index e794d3de3ddf68ef35419f45e27221669ac7fbf0..61cdc4ee9d35b0bd77dc2176f41eac21c4a6eb67 100755 (executable)
@@ -2,6 +2,7 @@
 #include "videomimedata.h"
 
 #define MAX_ITEMS 10
+static const QString recentKeywordsKey = "recentKeywords";
 
 ListModel::ListModel(QWidget *parent) : QAbstractListModel(parent) {
     youtubeSearch = 0;
@@ -187,6 +188,9 @@ void ListModel::abortSearch() {
 void ListModel::searchFinished(int total) {
     searching = false;
     canSearchMore = total > 0;
+
+    // update the message item
+    emit dataChanged( createIndex( MAX_ITEMS, 0 ), createIndex( MAX_ITEMS, columnCount() - 1 ) );
 }
 
 void ListModel::addVideo(Video* video) {
@@ -197,9 +201,20 @@ void ListModel::addVideo(Video* video) {
     videos << video;
     endInsertRows();
     
-    // autoplay
+    // first result!
     if (videos.size() == 1) {
+        // autoplay
         setActiveRow(0);
+
+        // save keyword
+        QString query = searchParams->keywords();
+        QSettings settings;
+        QStringList keywords = settings.value(recentKeywordsKey).toStringList();
+        keywords.removeAll(query);
+        keywords.prepend(query);
+        while (keywords.size() > 10)
+            keywords.removeLast();
+        settings.setValue(recentKeywordsKey, keywords);
     }
 
 }