diff --git a/common/gl/yacreader_flow_gl.cpp b/common/gl/yacreader_flow_gl.cpp index ad59daf73..afbfa086c 100644 --- a/common/gl/yacreader_flow_gl.cpp +++ b/common/gl/yacreader_flow_gl.cpp @@ -425,8 +425,10 @@ bool YACReaderFlowGL::animate(YACReader3DVector ¤tVector, YACReader3DVecto return false; } -void YACReaderFlowGL::drawCover(const YACReader3DImage &image) +void YACReaderFlowGL::drawCover(int index) { + const YACReader3DImage &image = images[index]; + float w = image.width; float h = image.height; @@ -507,9 +509,9 @@ void YACReaderFlowGL::drawCover(const YACReader3DImage &image) glEnd(); glDisable(GL_TEXTURE_2D); - if (showMarks && loaded[image.index] && marks[image.index] != Unread) { + if (showMarks && loaded[index] && marks[index] != Unread) { glEnable(GL_TEXTURE_2D); - if (marks[image.index] == Read) + if (marks[index] == Read) markTexture->bind(); else readingTexture->bind(); @@ -551,25 +553,15 @@ void YACReaderFlowGL::cleanupAnimation() void YACReaderFlowGL::draw() { - int CS = currentSelected; - int count; - + const int CS = currentSelected; //Draw right Covers - for (count = numObjects - 1; count > -1; count--) { - if (count > CS) { - drawCover(images[count]); - } - } - + for (int i = numObjects - 1; i > CS; --i) + drawCover(i); //Draw left Covers - for (count = 0; count < numObjects - 1; count++) { - if (count < CS) { - drawCover(images[count]); - } - } - + for (int i = 0; i < CS; ++i) + drawCover(i); //Draw Center Cover - drawCover(images[CS]); + drawCover(CS); } void YACReaderFlowGL::showPrevious() @@ -673,26 +665,23 @@ void YACReaderFlowGL::updatePositions() stopAnimationTimer(); } -void YACReaderFlowGL::insert(char *name, QOpenGLTexture *texture, float x, float y, int item) +void YACReaderFlowGL::insert(const char *name, QOpenGLTexture *texture, float x, float y) { startAnimationTimer(); Q_UNUSED(name) - //set a new entry - if (item == -1) { - images.push_back(YACReader3DImage()); - item = numObjects; - numObjects++; + images.push_back(YACReader3DImage()); - calcVector(images[item].current, item); - images[item].current.z = images[item].current.z - 1; - } + const auto item = numObjects; + numObjects++; + + calcVector(images[item].current, item); + images[item].current.z = images[item].current.z - 1; images[item].texture = texture; images[item].width = x; images[item].height = y; - images[item].index = item; //strcpy(cfImages[item].name,name); } @@ -712,14 +701,7 @@ void YACReaderFlowGL::remove(int item) } QOpenGLTexture *texture = images[item].texture; - - int count = item; - while (count <= numObjects - 2) { - images[count].index--; - count++; - } images.removeAt(item); - if (texture != defaultTexture) delete (texture); @@ -737,13 +719,10 @@ void YACReaderFlowGL::replace(char *name, QOpenGLTexture *texture, float x, floa startAnimationTimer(); Q_UNUSED(name) - if (images[item].index == item) { - images[item].texture = texture; - images[item].width = x; - images[item].height = y; - loaded[item] = true; - } else - loaded[item] = false; + images[item].texture = texture; + images[item].width = x; + images[item].height = y; + loaded[item] = true; } void YACReaderFlowGL::populate(int n) @@ -1246,13 +1225,11 @@ void YACReaderComicFlowGL::resortCovers(QList newOrder) QVector marksNew; QVector imagesNew; - int index = 0; foreach (int i, newOrder) { pathsNew << paths.at(i); loadedNew << loaded.at(i); marksNew << marks.at(i); imagesNew << images.at(i); - imagesNew.last().index = index++; } paths = pathsNew; @@ -1326,7 +1303,6 @@ void YACReaderPageFlowGL::updateImageData() float y = 1 * (float(img.height()) / img.width()); QString s = "cover"; replace(s.toLocal8Bit().data(), texture, x, y, idx); - loaded[idx] = true; } } diff --git a/common/gl/yacreader_flow_gl.h b/common/gl/yacreader_flow_gl.h index 6fc965a78..ac39bc404 100644 --- a/common/gl/yacreader_flow_gl.h +++ b/common/gl/yacreader_flow_gl.h @@ -36,8 +36,6 @@ struct YACReader3DImage { float width; float height; - int index; - YACReader3DVector current; YACReader3DVector animEnd; }; @@ -112,7 +110,7 @@ class YACReaderFlowGL : public QOpenGLWidget, public ScrollManagement void calcVector(YACReader3DVector &vector, int pos); //returns true if the animation is finished for Current bool animate(YACReader3DVector ¤tVector, YACReader3DVector &toVector); - void drawCover(const YACReader3DImage &image); + void drawCover(int index); void udpatePerspective(int width, int height); @@ -194,9 +192,7 @@ class YACReaderFlowGL : public QOpenGLWidget, public ScrollManagement //updates the coverflow void updatePositions(); //inserts a new item to the coverflow - //if item is set to a value > -1 it updates a already set value - //otherwise a new entry is set - void insert(char *name, QOpenGLTexture *texture, float x, float y, int item = -1); + void insert(const char *name, QOpenGLTexture *texture, float x, float y); //removes a item virtual void remove(int item); //replaces the texture of the item 'item' with Tex