diff --git a/src/datamanager.cpp b/src/datamanager.cpp index d67d7714..f22b77d0 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -141,10 +141,13 @@ Entry* DataManager::getEntry(QString id) const Entry* DataManager::getEntry(const EpisodeModel::Type type, const int entry_index) const { QSqlQuery entryQuery; - if (type == EpisodeModel::All || type == EpisodeModel::New) { + if (type == EpisodeModel::All || type == EpisodeModel::New || type == EpisodeModel::Unread) { if (type == EpisodeModel::New) { entryQuery.prepare(QStringLiteral("SELECT * FROM Entries WHERE new=:new ORDER BY updated DESC LIMIT 1 OFFSET :index;")); entryQuery.bindValue(QStringLiteral(":new"), true); + } else if (type == EpisodeModel::Unread) { + entryQuery.prepare(QStringLiteral("SELECT * FROM Entries WHERE read=:read ORDER BY updated DESC LIMIT 1 OFFSET :index;")); + entryQuery.bindValue(QStringLiteral(":read"), false); } else { // i.e. EpisodeModel::All entryQuery.prepare(QStringLiteral("SELECT * FROM Entries ORDER BY updated DESC LIMIT 1 OFFSET :index;")); } @@ -178,10 +181,13 @@ int DataManager::entryCount(const Feed* feed) const int DataManager::entryCount(const EpisodeModel::Type type) const { QSqlQuery query; - if (type == EpisodeModel::All || type == EpisodeModel::New) { + if (type == EpisodeModel::All || type == EpisodeModel::New || type == EpisodeModel::Unread) { if (type == EpisodeModel::New) { query.prepare(QStringLiteral("SELECT COUNT (id) FROM Entries WHERE new=:new;")); query.bindValue(QStringLiteral(":new"), true); + } else if (type == EpisodeModel::Unread) { + query.prepare(QStringLiteral("SELECT COUNT (id) FROM Entries WHERE read=:read;")); + query.bindValue(QStringLiteral(":read"), false); } else { // i.e. EpisodeModel::All query.prepare(QStringLiteral("SELECT COUNT (id) FROM Entries;")); } diff --git a/src/qml/EpisodeListPage.qml b/src/qml/EpisodeListPage.qml index a56c1c46..0e056323 100644 --- a/src/qml/EpisodeListPage.qml +++ b/src/qml/EpisodeListPage.qml @@ -18,7 +18,6 @@ import org.kde.alligator 1.0 Kirigami.ScrollablePage { //anchors.fill: parent - title: i18n("New Episodes") property var episodeType: EpisodeModel.All supportsRefreshing: true @@ -35,7 +34,10 @@ Kirigami.ScrollablePage { width: Kirigami.Units.gridUnit * 20 anchors.centerIn: parent - text: i18n("No Entries available") + text: i18n("No %1 available", episodeType === EpisodeModel.All ? i18n("episodes") + : episodeType === EpisodeModel.New ? i18n("new episodes") + : episodeType === EpisodeModel.Unread ? i18n("unread episodes") + : i18n("episodes")) } Component { id: episodeListDelegate @@ -50,8 +52,14 @@ Kirigami.ScrollablePage { model: EpisodeModel { type: episodeType } delegate: Kirigami.DelegateRecycler { - width: episodeList.width + width: episodeList.width sourceComponent: episodeListDelegate } } + actions.main: Kirigami.Action { + text: i18n("Refresh all feeds") + iconName: "view-refresh" + onTriggered: refreshing = true + visible: !Kirigami.Settings.isMobile + } } diff --git a/src/qml/EpisodeSwipePage.qml b/src/qml/EpisodeSwipePage.qml index 0d9e705b..d16c29c7 100644 --- a/src/qml/EpisodeSwipePage.qml +++ b/src/qml/EpisodeSwipePage.qml @@ -20,38 +20,63 @@ Kirigami.Page { title: i18n("Episode List") padding: 0 - header: Controls.TabBar { - id: tabBar - currentIndex: swipeView.currentIndex + header: Loader { + id: headerLoader + active: !Kirigami.Settings.isMobile + sourceComponent: tabBarComponent + property var swipeViewItem: swipeView + } - Controls.TabButton { - text: "New Episodes" - } - Controls.TabButton { - text: "All Episodes" + footer: Loader { + id: footerLoader + active: Kirigami.Settings.isMobile + sourceComponent: tabBarComponent + property var swipeViewItem: swipeView + } + + Component { + id: tabBarComponent + Controls.TabBar { + id: tabBar + position: Controls.TabBar.Footer + currentIndex: swipeViewItem.currentIndex + + Controls.TabButton { + width: parent.parent.width/parent.count + height: Kirigami.Units.gridUnit * 2 + text: i18n("New Episodes") + } + Controls.TabButton { + width: parent.parent.width/parent.count + height: Kirigami.Units.gridUnit * 2 + text: i18n("Unread Episodes") + } + Controls.TabButton { + width: parent.parent.width/parent.count + height: Kirigami.Units.gridUnit * 2 + text: i18n("All Episodes") + } } } Controls.SwipeView { id: swipeView anchors.fill: parent - currentIndex: tabBar.currentIndex + currentIndex: Kirigami.Settings.isMobile ? footerLoader.item.currentIndex : headerLoader.item.currentIndex EpisodeListPage { title: i18n("New Episodes") episodeType: EpisodeModel.New } + EpisodeListPage { + title: i18n("Unread Episodes") + episodeType: EpisodeModel.Unread + } + EpisodeListPage { title: i18n("All Episodes") episodeType: EpisodeModel.All } } - - /*actions.main: Kirigami.Action { - text: i18n("Refresh all feeds") - iconName: "view-refresh" - onTriggered: refreshing = true - visible: !Kirigami.Settings.isMobile - }*/ }