Add methods to the flow implementations to add new items dynamically

This commit is contained in:
Luis Ángel San Martín
2023-08-13 11:15:47 +02:00
parent 82aa380bb5
commit 024f6df9de
4 changed files with 49 additions and 2 deletions

View File

@ -724,6 +724,24 @@ void YACReaderFlowGL::remove(int item)
numObjects--;
}
void YACReaderFlowGL::add(int item)
{
float x = 1;
float y = 1 * (700.f / 480.0f);
QString s = "cover";
images.insert(item, YACReader3DImage());
loaded.insert(item, false);
marks.insert(item, Unread);
numObjects++;
for (int i = item + 1; i < numObjects; i++) {
images[i].index++;
}
insert(s.toLocal8Bit().data(), defaultTexture, x, y, item);
}
/*Info*/
YACReader3DImage YACReaderFlowGL::getCurrentSelected()
{
@ -747,6 +765,7 @@ void YACReaderFlowGL::replace(char *name, QOpenGLTexture *texture, float x, floa
void YACReaderFlowGL::populate(int n)
{
emit centerIndexChanged(0);
float x = 1;
float y = 1 * (700.f / 480.0f);
int i;
@ -1218,8 +1237,21 @@ void YACReaderComicFlowGL::remove(int item)
worker->lock();
worker->reset();
YACReaderFlowGL::remove(item);
if (item >= 0 && item < paths.size())
if (item >= 0 && item < paths.size()) {
paths.removeAt(item);
}
worker->unlock();
}
void YACReaderComicFlowGL::add(const QString &path, int index)
{
worker->lock();
worker->reset();
paths.insert(index, path);
YACReaderFlowGL::add(index);
worker->unlock();
}