]> git.sur5r.net Git - minitube/blobdiff - src/channelview.cpp
New upstream version 2.9
[minitube] / src / channelview.cpp
index 6203dbeaea73213eed1dff8edbf3c900152170ab..d6dcd46556a34cffa93d44c3eeb486e08aecb56d 100644 (file)
@@ -25,7 +25,6 @@ $END_LICENSE */
 #include "channelmodel.h"
 #include "channelitemdelegate.h"
 #include "database.h"
-#include "ytsearch.h"
 #include "channelaggregator.h"
 #include "aggregatevideosource.h"
 #include "mainwindow.h"
@@ -35,8 +34,10 @@ $END_LICENSE */
 #endif
 #include "channellistview.h"
 
-static const char *sortByKey = "subscriptionsSortBy";
-static const char *showUpdatedKey = "subscriptionsShowUpdated";
+namespace {
+static const QString sortByKey = "subscriptionsSortBy";
+static const QString showUpdatedKey = "subscriptionsShowUpdated";
+}
 
 ChannelView::ChannelView(QWidget *parent) : View(parent),
     showUpdated(false),
@@ -139,22 +140,27 @@ void ChannelView::setupActions() {
     connect(showUpdatedAction, SIGNAL(toggled(bool)), SLOT(toggleShowUpdated(bool)));
     statusActions << showUpdatedAction;
 
-    foreach (QAction *action, statusActions) {
+    for (QAction *action : statusActions) {
         window()->addAction(action);
         IconUtils::setupAction(action);
     }
 }
 
+QString ChannelView::noSubscriptionsMessage() {
+    return tr("You have no subscriptions. "
+                    "Use the star symbol to subscribe to channels.");
+}
+
 void ChannelView::appear() {
     updateQuery();
-    foreach (QAction* action, statusActions)
+    for (QAction* action : statusActions)
         MainWindow::instance()->showActionInStatusBar(action, true);
     setFocus();
     ChannelAggregator::instance()->start();
 }
 
 void ChannelView::disappear() {
-    foreach (QAction* action, statusActions)
+    for (QAction* action : statusActions)
         MainWindow::instance()->showActionInStatusBar(action, false);
 }
 
@@ -166,16 +172,16 @@ void ChannelView::itemActivated(const QModelIndex &index) {
         params->setChannelId(channel->getChannelId());
         params->setSortBy(SearchParams::SortByNewest);
         params->setTransient(true);
-        YTSearch *videoSource = new YTSearch(params, this);
+        YTSearch *videoSource = new YTSearch(params);
         videoSource->setAsyncDetails(true);
         emit activated(videoSource);
         channel->updateWatched();
     } else if (itemType == ChannelModel::ItemAggregate) {
-        AggregateVideoSource *videoSource = new AggregateVideoSource(this);
+        AggregateVideoSource *videoSource = new AggregateVideoSource();
         videoSource->setName(tr("All Videos"));
         emit activated(videoSource);
     } else if (itemType == ChannelModel::ItemUnwatched) {
-        AggregateVideoSource *videoSource = new AggregateVideoSource(this);
+        AggregateVideoSource *videoSource = new AggregateVideoSource();
         videoSource->setName(tr("Unwatched Videos"));
         videoSource->setUnwatched(true);
         emit activated(videoSource);
@@ -224,7 +230,11 @@ void ChannelView::toggleShowUpdated(bool enable) {
 void ChannelView::updateQuery(bool transition) {
     Q_UNUSED(transition);
     listView->clearErrorMessage();
-    if (!Database::exists()) return;
+
+    if (!Database::exists()) {
+        listView->setErrorMessage(noSubscriptionsMessage());
+        return;
+    }
 
     QString sql = "select user_id from subscriptions";
     if (showUpdated)
@@ -262,8 +272,7 @@ void ChannelView::updateQuery(bool transition) {
         if (showUpdated)
             msg = tr("There are no updated subscriptions at this time.");
         else
-            msg = tr("You have no subscriptions. "
-                     "Use the star symbol to subscribe to channels.");
+            msg = noSubscriptionsMessage();
         listView->setErrorMessage(msg);
     }
 }