if (m_type != Root)
return;
- itemData << "Title" << "Episode / Version" << "Rating / Quality" << "Vote" << "Watched";
+ itemData << "Title" << "Episode / Version" << "Rating / Quality" << "Vote" << "Watched / Renamed";
}
if (m_totalRowCount != -1)
return m_totalRowCount;
- if (m_type == File)
+ if (m_type == FileLocation)
{
m_totalRowCount = 0;
return m_totalRowCount;
bool MyListNode::canFetchMore() const
{
- if (m_type != File && childCount() < totalRowCount())
+ if (m_type != FileLocation && childCount() < totalRowCount())
return true;
return false;
}
int MyListNode::fetchMore()
{
- qDebug() << "fetching some more for" << m_id;
+ qDebug() << "fetching some more for root";
QSqlQuery q(LocalMyList::instance()->database()->connection());
if (!q.exec("SELECT aid, title_romaji AS title, (SELECT COUNT(e.eid) FROM episode e WHERE e.aid = a.aid), rating, my_vote, (SELECT COUNT(DISTINCT f.eid) FROM episode e JOIN file f ON (f.eid = e.eid) WHERE e.aid = a.aid AND f.my_watched IS NOT NULL) FROM anime a ORDER BY title ASC "
bool MyListNode::hasChildren() const
{
- if (m_type == File)
+ if (m_type == FileLocation)
return false;
return true;
int MyListFileNode::fetchMore()
{
- return 0;
+ qDebug() << "fetching some more for fid" << m_id;
+ QSqlQuery q(LocalMyList::instance()->database()->connection());
+
+ if (!q.exec("SELECT fl.fid, fl.host_id, h.name, fl.path, fl.renamed, fl.failed_rename FROM file_location fl "
+ " JOIN host h ON (fl.host_id = h.host_id) "
+ "WHERE fl.fid = " + QString::number(m_id)))
+ return 0;
+
+ while (q.next())
+ {
+ int id = q.value(0).toInt();
+ QVariantList data;
+ data << q.value(3)
+ << QObject::tr("%1 (%2)").arg(q.value(2).toString()).arg(q.value(1).toString())
+ << ""
+ << ""
+ << (q.value(5).toBool() ? QObject::tr("Rename Failed") : q.value(4).toDateTime().isValid() ? QObject::tr("Yes, on %1").arg(q.value(4).toDateTime().toString()) : QObject::tr("Not Renamed"));
+ childItems << new MyListFileLocationNode(id, data, this);
+ }
+
+ return q.size();
}
QString MyListFileNode::totalRowCountSql() const
+{
+ return "SELECT COUNT(fid) FROM file_location WHERE fid = " + QString::number(m_id);
+}
+
+// ---------------
+
+MyListFileLocationNode::MyListFileLocationNode(int id, const QList<QVariant> &data, MyListNode *parent) :
+ MyListNode(FileLocation, id, data, parent)
+{
+}
+
+int MyListFileLocationNode::fetchMore()
+{
+ return 0;
+}
+
+QString MyListFileLocationNode::totalRowCountSql() const
{
return "SELECT 0";
}
Root,
Anime,
Episode,
- File
+ File,
+ FileLocation
};
MyListNode(NodeType type = Root, int m_id = 0, const QList<QVariant> &data = QList<QVariant>(), MyListNode *parent = 0);
QString totalRowCountSql() const;
};
+class MyListFileLocationNode : public MyListNode
+{
+public:
+ MyListFileLocationNode(int id = 0, const QList<QVariant> &data = QList<QVariant>(), MyListNode *parent = 0);
+
+ int fetchMore();
+
+protected:
+ QString totalRowCountSql() const;
+};
+
} // namespace LocalMyList
#endif // MYLISTNODE_H