#include "channelmodel.h"
#include "channelitemdelegate.h"
#include "database.h"
-#include "ytsearch.h"
#include "channelaggregator.h"
#include "aggregatevideosource.h"
#include "mainwindow.h"
#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),
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);
}
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);
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)
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);
}
}