X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2FListModel.cpp;h=644e512fc12f941e43969ddee55fd17f28db254c;hb=df8b2c951e66b538dd4d191220e883d86b700864;hp=e7592ecbf096e3e17369554b3a5af7ba7bdfa7dc;hpb=efec77e73c8eafb7ba1f0b7817567272f02262e5;p=minitube
diff --git a/src/ListModel.cpp b/src/ListModel.cpp
old mode 100755
new mode 100644
index e7592ec..644e512
--- a/src/ListModel.cpp
+++ b/src/ListModel.cpp
@@ -3,6 +3,7 @@
#define MAX_ITEMS 10
static const QString recentKeywordsKey = "recentKeywords";
+static const QString recentChannelsKey = "recentChannels";
ListModel::ListModel(QWidget *parent) : QAbstractListModel(parent) {
youtubeSearch = 0;
@@ -78,29 +79,7 @@ QVariant ListModel::data(const QModelIndex &index, int role) const {
case ActiveTrackRole:
return video == m_activeVideo;
case Qt::DisplayRole:
- case Qt::StatusTipRole:
return video->title();
- /*
- case Qt::ToolTipRole:
-
- QString tooltip;
- if (!element.firstChildElement().text().isEmpty()) {
- tooltip.append(QString("").append(element.firstChildElement().text()).append("
"));
- }
- if (!fromDate.isEmpty()) {
- tooltip.append("Pubblicato il ").append(fromDate);
- }
- if (!toDate.isEmpty()) {
- tooltip.append("
Scadenza: ").append(toDate);
- }
- tooltip.append("
Tipo: ").append(typeName)
- .append("
Id: ").appen QFont boldFont;
- boldFont.setBold(true);d(id);
- return tooltip;
- */
-
- // case StreamUrlRole:
- // return video->streamUrl();
}
return QVariant();
@@ -112,8 +91,6 @@ void ListModel::setActiveRow( int row) {
m_activeRow = row;
m_activeVideo = videoAt(row);
- // setStateOfRow( row, Item::Played );
-
int oldactiverow = m_activeRow;
if ( rowExists( oldactiverow ) )
@@ -226,13 +203,32 @@ void ListModel::addVideo(Video* video) {
// 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);
+ if (!query.isEmpty() && !searchParams->isTransient()) {
+ if (query.startsWith("http://")) {
+ // Save the video title
+ query += "|" + videos.first()->title();
+ }
+ QSettings settings;
+ QStringList keywords = settings.value(recentKeywordsKey).toStringList();
+ keywords.removeAll(query);
+ keywords.prepend(query);
+ while (keywords.size() > 10)
+ keywords.removeLast();
+ settings.setValue(recentKeywordsKey, keywords);
+ }
+
+ // save channel
+ QString channel = searchParams->author();
+ if (!channel.isEmpty() && !searchParams->isTransient()) {
+ QSettings settings;
+ QStringList channels = settings.value(recentChannelsKey).toStringList();
+ channels.removeAll(channel);
+ channels.prepend(channel);
+ while (channels.size() > 10)
+ channels.removeLast();
+ settings.setValue(recentChannelsKey, channels);
+ }
+
}
}
@@ -268,6 +264,7 @@ void ListModel::removeIndexes(QModelIndexList &indexes) {
QList