From: Flavio Tordini Date: Wed, 29 Jul 2009 07:53:35 +0000 (+0200) Subject: Fixed message item not updating X-Git-Tag: 0.5~12 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bfdfcca19283216eca22f7ec3b2330bbddbdc095;p=minitube Fixed message item not updating Also save keywords when the first result is received --- diff --git a/src/ListModel.cpp b/src/ListModel.cpp index e794d3d..61cdc4e 100755 --- a/src/ListModel.cpp +++ b/src/ListModel.cpp @@ -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); } }