From: APTX Date: Tue, 16 Apr 2013 14:21:47 +0000 (+0200) Subject: Add options to mark whole Anime/Episodes to localmylist-management. X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=aec05f5871240ab7d18f14eddf4a21fba1408ad8;p=localmylist.git Add options to mark whole Anime/Episodes to localmylist-management. --- diff --git a/localmylist-management/mylistview.cpp b/localmylist-management/mylistview.cpp index bebe6ec..1e6bcb3 100644 --- a/localmylist-management/mylistview.cpp +++ b/localmylist-management/mylistview.cpp @@ -1,6 +1,7 @@ #include "mylistview.h" #include "mylist.h" +#include "database.h" #include "mylistmodel.h" #include "mylistnode.h" #include "mylistfiltermodel.h" @@ -23,8 +24,12 @@ MyListView::MyListView(QWidget *parent) : connect(openAction, SIGNAL(triggered()), this, SLOT(requestOpenFile())); openNextAction = new QAction(tr("Open Next"), this); connect(openNextAction, SIGNAL(triggered()), this, SLOT(requestOpenFile())); - markWatchedAction = new QAction(tr("Marked Watched"), this); - connect(markWatchedAction, SIGNAL(triggered()), this, SLOT(markWatched())); + markAnimeWatchedAction = new QAction(tr("Mark Anime Watched"), this); + connect(markAnimeWatchedAction, SIGNAL(triggered()), this, SLOT(markAnimeWatched())); + markEpisodeWatchedAction = new QAction(tr("Mark Episode Watched"), this); + connect(markEpisodeWatchedAction, SIGNAL(triggered()), this, SLOT(markEpisodeWatched())); + markFileWatchedAction = new QAction(tr("Mark Watched"), this); + connect(markFileWatchedAction, SIGNAL(triggered()), this, SLOT(markFileWatched())); aniDBLinkAction = new QAction(tr("Open AniDB Page"), this); connect(aniDBLinkAction, SIGNAL(triggered()), this, SLOT(openAnidbPage())); renameFilesAction = new QAction(tr("Rename Files Related to Entry"), this); @@ -64,6 +69,7 @@ void MyListView::showCustomContextMenu(const QPoint &pos) aniDBLinkAction->setText(tr("Open AniDB Page (%1%2)").arg('a').arg(node->id())); actions << aniDBLinkAction << openNextAction + << markAnimeWatchedAction << renameFilesAction << requestDataAction; break; @@ -71,6 +77,7 @@ void MyListView::showCustomContextMenu(const QPoint &pos) aniDBLinkAction->setText(tr("Open AniDB Page (%1%2)").arg('e').arg(node->id())); actions << aniDBLinkAction << openAction + << markEpisodeWatchedAction << renameFilesAction << requestDataAction; break; @@ -78,7 +85,7 @@ void MyListView::showCustomContextMenu(const QPoint &pos) aniDBLinkAction->setText(tr("Open AniDB Page (%1%2)").arg('f').arg(node->id())); actions << aniDBLinkAction << openAction - << markWatchedAction + << markFileWatchedAction << renameTestAction << renameFilesAction << requestDataAction; @@ -86,7 +93,6 @@ void MyListView::showCustomContextMenu(const QPoint &pos) case MyListNode::FileLocationNode: aniDBLinkAction->setText(tr("Open AniDB Page (%1%2)").arg('f').arg(node->id())); actions << aniDBLinkAction - << markWatchedAction << renameTestAction << renameFilesAction; break; @@ -107,12 +113,53 @@ void MyListView::requestOpenFile() emit openFileRequested(customContextMenuIndex); } -void MyListView::markWatched() +void MyListView::markAnimeWatched() { using namespace LocalMyList; MyListNode *node = myListFilterModel()->node(customContextMenuIndex); + if (node->type() != MyListNode::AnimeNode) + return; + + PendingMyListUpdate pmu; + pmu.aid = node->id(); + + pmu.setMyWatched = true; + pmu.myWatched = QDateTime::currentDateTime(); + + MyList::instance()->database()->addPendingMyListUpdate(pmu); +} + +void MyListView::markEpisodeWatched() +{ + using namespace LocalMyList; + + MyListEpisodeNode *node = static_cast(myListFilterModel()->node(customContextMenuIndex)); + + if (node->type() != MyListNode::EpisodeNode) + return; + + PendingMyListUpdate pmu; + pmu.aid = node->internalData().data.aid; + pmu.epno = node->internalData().data.epno; + pmu.eptype = node->internalData().data.type; + + pmu.setMyWatched = true; + pmu.myWatched = QDateTime::currentDateTime(); + + MyList::instance()->database()->addPendingMyListUpdate(pmu); +} + +void MyListView::markFileWatched() +{ + using namespace LocalMyList; + + MyListNode *node = myListFilterModel()->node(customContextMenuIndex); + + if (node->type() != MyListNode::FileNode) + return; + MyList::instance()->markWatched(node->id()); } diff --git a/localmylist-management/mylistview.h b/localmylist-management/mylistview.h index 430b1a9..9a34585 100644 --- a/localmylist-management/mylistview.h +++ b/localmylist-management/mylistview.h @@ -22,7 +22,9 @@ private slots: MyListFilterModel *myListFilterModel() const; void showCustomContextMenu(const QPoint &pos); void requestOpenFile(); - void markWatched(); + void markAnimeWatched(); + void markEpisodeWatched(); + void markFileWatched(); void openAnidbPage(); void requestFileRename(); void renameTest(); @@ -34,7 +36,9 @@ private: QAction *openAction; QAction *openNextAction; - QAction *markWatchedAction; + QAction *markAnimeWatchedAction; + QAction *markEpisodeWatchedAction; + QAction *markFileWatchedAction; QAction *aniDBLinkAction; QAction *renameTestAction; QAction *renameFilesAction;