}
else if (name == "file_location_insert")
{
- int id = payload.toInt();
- if (id)
- emit fileLocationInsert(id);
+ QStringList ids = payload.toString().split(QChar(','), QString::SkipEmptyParts);
+ int locationId = 0;
+ int fid = 0;
+
+ if (ids.count())
+ locationId = ids.takeFirst().toInt();
+ if (ids.count())
+ fid = ids.takeFirst().toInt();
+
+ if (locationId)
+ emit fileLocationInsert(locationId, fid);
}
#endif
}
void animeInsert(int aid);
void episodeInsert(int eid, int aid);
void fileInsert(int fid, int eid, int aid);
- void fileLocationInsert(int id);
+ void fileLocationInsert(int locationId, int fid);
private slots:
// moc doesn't expand macros
connect(MyList::instance()->database(), SIGNAL(animeInsert(int)), this, SLOT(animeInsert(int)));
connect(MyList::instance()->database(), SIGNAL(episodeInsert(int,int)), this, SLOT(episodeInsert(int,int)));
connect(MyList::instance()->database(), SIGNAL(fileInsert(int,int,int)), this, SLOT(fileInsert(int,int,int)));
- connect(MyList::instance()->database(), SIGNAL(fileLocationInsert(int)), this, SLOT(fileLocationInsert(int)));
+ connect(MyList::instance()->database(), SIGNAL(fileLocationInsert(int,int)), this, SLOT(fileLocationInsert(int,int)));
}
MyListModel::~MyListModel()
parentNode->childAdded(eid);
}
-void MyListModel::fileLocationInsert(int id)
+void MyListModel::fileLocationInsert(int locationId, int fid)
{
- if (fileLocationIndex(id).isValid())
+ if (fileLocationIndex(locationId).isValid())
return;
+ MyListNode *parentNode = node(fileIndex(fid));
+ if (!parentNode)
+ return;
+
+ parentNode->childAdded(locationId);
}
QModelIndex MyListModel::index(MyListNode *node) const
// Delay fetching of more rows untill they are really needed.
// Only for the root node
- // Lazy loading didn't work before for children, not sure why
+ // Lazy loading didn't work for children, even before the async change, not sure why
// TODO figure out if it can be fixed
// Enableing this for non-root makes it never fetch more.
if (node == rootItem)
ON UPDATE TO file DO SELECT pg_notify('file_update', new.fid::text || ',' || new.eid::text || ',' || new.aid::text);
CREATE OR REPLACE RULE file_location_update_rule AS
- ON UPDATE TO file_location DO SELECT pg_notify('file_location_update', new.location_id::text);
+ ON UPDATE TO file_location DO SELECT pg_notify('file_location_update', new.location_id::text || ',' || new.fid::text);