#include "mylistmodel.h"
#include <QMenu>
+#include <QDesktopServices>
+#include <QUrl>
MyListView::MyListView(QWidget *parent) :
QTreeView(parent)
openAction = new QAction(tr("Open"), this);
connect(openAction, SIGNAL(triggered()), this, SLOT(requestOpenFile()));
- openNextAction = new QAction(tr("Open next"), this);
+ 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()));
+ aniDBLinkAction = new QAction(tr("Open AniDB Page"), this);
+ connect(aniDBLinkAction, SIGNAL(triggered()), this, SLOT(openAnidbPage()));
}
LocalMyList::MyListModel *MyListView::myListModel() const
return;
MyListModel::NodeType type = myListModel()->type(idx);
-
- //QAction a(tr("Dummyaction r=%1, c=%2").arg(idx.row()).arg(idx.column()), this);
-
- //QAction b(tr("%1 = %2").arg(type == MyListModel::Anime ? "aid" : type == MyListModel::Episode ? "eid" : type == MyListModel::File ? "fid" : "none").arg(myListModel()->id(idx)), this);
+ int id = myListModel()->id(idx);
QList<QAction *> actions;
- if (type == MyListModel::Anime)
- actions << openNextAction;
- else
- actions << openAction;
- if (type == MyListModel::File)
- actions << markWatchedAction;
+ switch (type)
+ {
+ case MyListModel::Anime:
+ aniDBLinkAction->setText(tr("Open AniDB Page (%1%2)").arg('a').arg(id));
+ actions << aniDBLinkAction
+ << openNextAction;
+ break;
+ case MyListModel::Episode:
+ aniDBLinkAction->setText(tr("Open AniDB Page (%1%2)").arg('e').arg(id));
+ actions << aniDBLinkAction
+ << openAction;
+ break;
+ case MyListModel::File:
+ aniDBLinkAction->setText(tr("Open AniDB Page (%1%2)").arg('f').arg(id));
+ actions << aniDBLinkAction
+ << openAction
+ << markWatchedAction;
+ break;
+ }
if(actions.isEmpty())
return;
LocalMyList::instance()->markWatched(id);
}
+
+void MyListView::openAnidbPage()
+{
+ using namespace LocalMyList;
+
+ QString aniDBUrlBase = "http://anidb.net/%1%2";
+ int id = myListModel()->id(customContextMenuIndex);
+ MyListModel::NodeType type = myListModel()->type(customContextMenuIndex);
+
+ switch (type)
+ {
+ case MyListModel::Anime:
+ QDesktopServices::openUrl(QUrl(aniDBUrlBase.arg('a').arg(id)));
+ break;
+ case MyListModel::Episode:
+ QDesktopServices::openUrl(QUrl(aniDBUrlBase.arg('e').arg(id)));
+ break;
+ case MyListModel::File:
+ QDesktopServices::openUrl(QUrl(aniDBUrlBase.arg('f').arg(id)));
+ break;
+ }
+}