From 257351fe3f408c60f5b207454a46e107fdca004b Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 28 May 2014 13:24:07 +0200 Subject: [PATCH] Version 5.2.1:Highlight improvements, ebooks massive loading improvements and fixes, collection ordering by index --- QBookApp/src/QBookApp.cpp | 2 + bqBrowser/src/Browser.cpp | 6 +- bqLibrary/inc/Library.h | 3 + bqLibrary/inc/LibraryBookSummary.h | 4 +- bqLibrary/inc/LibraryCollectionLayer.h | 6 +- bqLibrary/inc/LibrarySortBooksByLayer.h | 9 +- bqLibrary/res/1024/library_styles.qss | 6 + bqLibrary/res/800/library_styles.qss | 6 + bqLibrary/res/800/library_styles_new.qss | 6 + bqLibrary/res/library_styles_generic.qss | 8 +- bqLibrary/res/library_styles_generic_new.qss | 6 + bqLibrary/src/Library.cpp | 80 +++++- bqLibrary/src/LibraryBookSummary.cpp | 24 +- bqLibrary/src/LibraryCollectionLayer.cpp | 12 +- bqLibrary/src/LibraryEditCollection.cpp | 18 +- bqLibrary/src/LibrarySortBooksByLayer.cpp | 49 +++- bqLibrary/tr/bqLibrary_ca.ts | 257 +++++++++--------- bqLibrary/tr/bqLibrary_en.ts | 257 +++++++++--------- bqLibrary/tr/bqLibrary_es.ts | 257 +++++++++--------- bqLibrary/tr/bqLibrary_eu.ts | 12 + bqLibrary/tr/bqLibrary_gl.ts | 257 +++++++++--------- bqLibrary/tr/bqLibrary_pt.ts | 257 +++++++++--------- bqLibrary/ui/LibrarySortBooksByLayer.ui | 33 ++- bqUi/inc/MouseFilter.h | 2 +- bqViewer/inc/ViewerBookSummary.h | 4 +- bqViewer/inc/ViewerCollectionLayer.h | 6 +- bqViewer/src/ViewerBookSummary.cpp | 24 +- bqViewer/src/ViewerCollectionLayer.cpp | 13 +- .../inc/EpubMetaDataExtractor.h | 1 + metadata-extractor/inc/Fb2MetaDataExtractor.h | 1 + metadata-extractor/inc/MetaDataExtractor.h | 1 + .../src/EpubMetaDataExtractor.cpp | 35 +++ .../src/Fb2MetaDataExtractor.cpp | 41 +++ metadata-extractor/src/MetaDataExtractor.cpp | 19 ++ model/inc/BookInfo.h | 6 +- model/src/BookInfo.cpp | 34 +-- model/src/Model.cpp | 15 +- model/src/ModelBackendOneFile.cpp | 32 ++- version.h | 2 +- 39 files changed, 1085 insertions(+), 726 deletions(-) diff --git a/QBookApp/src/QBookApp.cpp b/QBookApp/src/QBookApp.cpp index 58db210..4324661 100644 --- a/QBookApp/src/QBookApp.cpp +++ b/QBookApp/src/QBookApp.cpp @@ -4517,6 +4517,8 @@ void QBookApp::checkBooksChanged() QFile::remove(book->thumbnail); getModel()->loadDefaultInfo(book->path); } + book = NULL; + delete book; } } diff --git a/bqBrowser/src/Browser.cpp b/bqBrowser/src/Browser.cpp index 9197ca9..c217042 100644 --- a/bqBrowser/src/Browser.cpp +++ b/bqBrowser/src/Browser.cpp @@ -1313,7 +1313,11 @@ void Browser::populateBookInfo(BookInfo* book) MetaDataExtractor::getMetaData(book->path, book->title, book->author, book->publisher, book->publishTime, book->synopsis, book->format, book->isDRMFile, collection, book->language); book->corrupted = false; if(!collection.isEmpty()) - book->addCollection(collection); + { + double index = MetaDataExtractor::getCollectionIndex(book->path); + QBookApp::instance()->getModel()->addCollection(collection); + book->addCollection(collection, index); + } if (book->format != "pdf") book->fontSize = 2; } diff --git a/bqLibrary/inc/Library.h b/bqLibrary/inc/Library.h index f9ec653..e750692 100644 --- a/bqLibrary/inc/Library.h +++ b/bqLibrary/inc/Library.h @@ -163,6 +163,7 @@ class Library : public QBookForm, protected Ui::Library void setupLibrary (); static QString modifyStyleSheet (QString styleSheet, QString styleToModify); + QString getCollectionSelected () { return m_collection; } public slots: void itemClicked ( const QString& path ); @@ -272,6 +273,7 @@ protected slots: void sortListClicked (); void sortBooksByAuthorClicked (); + void sortBooksByIndexClicked (); void sortBooksByTitleClicked (); void sortBooksByDateClicked (); @@ -383,6 +385,7 @@ protected slots: sortDataCallback sortFilesDataCallback; void applySortMethod (); void sortBooksByAuthor (); + void sortBooksByIndex (); void sortBooksByTitle (); void sortBooksByDate (); void sortFilesByName (); diff --git a/bqLibrary/inc/LibraryBookSummary.h b/bqLibrary/inc/LibraryBookSummary.h index 13eafc4..8f0409b 100644 --- a/bqLibrary/inc/LibraryBookSummary.h +++ b/bqLibrary/inc/LibraryBookSummary.h @@ -40,7 +40,7 @@ class LibraryBookSummary : public QWidget, protected Ui::LibraryBookSummary void setBook ( const BookInfo* book, int currentBook, int totalBooks ); bool hideElements ( ); void setActionsBtnText ( BookInfo::readStateEnum ); - void setCollectionLayerBtnText (QStringList collectionList); + void setCollectionLayerBtnText (QHash collectionList); int getCurrentBookOffset ( ) { return m_currentBook; } signals: @@ -74,7 +74,7 @@ protected slots: void synopsisUp (); void setupPagination (int); void changeReadState (int); - void addBookToCollection (QString collectionName); + void addBookToCollection (QString collectionName, double index); void removeBookToCollection (QString collectionName); void createNewCollection (); void previousBook (); diff --git a/bqLibrary/inc/LibraryCollectionLayer.h b/bqLibrary/inc/LibraryCollectionLayer.h index 0811cfb..0d3d791 100644 --- a/bqLibrary/inc/LibraryCollectionLayer.h +++ b/bqLibrary/inc/LibraryCollectionLayer.h @@ -33,7 +33,7 @@ class LibraryCollectionLayer : public GestureWidget, protected Ui::LibraryCollec public: LibraryCollectionLayer ( QWidget* parent ); virtual ~LibraryCollectionLayer (); - void setup ( QStringList collectionList ); + void setup ( QHash collectionList ); void paint (); protected slots: @@ -42,7 +42,7 @@ protected slots: void changeCollection (int idItem); signals: - void addCollection (QString collectionName); + void addCollection (QString collectionName, double index); void removeCollection (QString collectionName); void createCollection (); @@ -50,7 +50,7 @@ protected slots: /* http://qt-project.org/forums/viewthread/7340 */ virtual void paintEvent ( QPaintEvent* ); - QStringList m_bookCollections; + QHash m_bookCollections; QStringList m_modelCollections; QList items; int m_page; diff --git a/bqLibrary/inc/LibrarySortBooksByLayer.h b/bqLibrary/inc/LibrarySortBooksByLayer.h index cd5767b..bb1cbce 100644 --- a/bqLibrary/inc/LibrarySortBooksByLayer.h +++ b/bqLibrary/inc/LibrarySortBooksByLayer.h @@ -36,33 +36,34 @@ class LibrarySortBooksByLayer : public QWidget, public Ui::LibrarySortBooksByLay virtual ~LibrarySortBooksByLayer (); void enableRecent (bool enable); + void enableIndex (bool enable); void setRecentChecked (); void setTitleChecked (); void setAuthorChecked (); + void setIndexChecked (); QString getRecentSortName () const; QString getTitleSortName () const; QString getAuthorSortName () const; + QString getIndexSortName () const; signals: void recentSelected (); void titleSelected (); void authorSelected (); + void indexSelected (); private slots: void recentClicked (); void titleClicked (); void authorClicked (); + void indexClicked (); protected: /* http://qt-project.org/forums/viewthread/7340 */ virtual void paintEvent ( QPaintEvent* ); - QString m_recentName; - QString m_titleName; - QString m_authorName; - }; #endif // LIBRARYSORTBOOKSBYLAYER_H diff --git a/bqLibrary/res/1024/library_styles.qss b/bqLibrary/res/1024/library_styles.qss index b6eb2a9..ec672fb 100644 --- a/bqLibrary/res/1024/library_styles.qss +++ b/bqLibrary/res/1024/library_styles.qss @@ -247,6 +247,12 @@ border-width:2px; border-top-left-radius:6px; border-bottom-left-radius:6px; } +#sortBooksCont #indexSortBtn{ +padding:0px 38px; +min-height:51px; +max-height:51px; +border-width:2px; +} #sortBooksCont #titleSortBtn{ padding:0px 38px; min-height:51px; diff --git a/bqLibrary/res/800/library_styles.qss b/bqLibrary/res/800/library_styles.qss index fb2347b..7a519ea 100644 --- a/bqLibrary/res/800/library_styles.qss +++ b/bqLibrary/res/800/library_styles.qss @@ -249,6 +249,12 @@ border-width:2px; border-top-left-radius:5px; border-bottom-left-radius:5px; } +#sortBooksCont #indexSortBtn{ +padding:0px 30px; +min-height:40px; +max-height:40px; +border-width:2px; +} #sortBooksCont #titleSortBtn{ padding:0px 30px; min-height:40px; diff --git a/bqLibrary/res/800/library_styles_new.qss b/bqLibrary/res/800/library_styles_new.qss index 9bdf7a2..36a9e5a 100644 --- a/bqLibrary/res/800/library_styles_new.qss +++ b/bqLibrary/res/800/library_styles_new.qss @@ -212,6 +212,12 @@ border-width:2px; border-top-left-radius:5px; border-bottom-left-radius:5px; } +#sortBooksCont #indexSortBtn{ +padding:0px 30px; +min-height:40px; +max-height:40px; +border-width:2px; +} #sortBooksCont #titleSortBtn{ padding:0px 30px; min-height:40px; diff --git a/bqLibrary/res/library_styles_generic.qss b/bqLibrary/res/library_styles_generic.qss index fa2502b..36f8e8a 100644 --- a/bqLibrary/res/library_styles_generic.qss +++ b/bqLibrary/res/library_styles_generic.qss @@ -169,6 +169,12 @@ border-right:none; background-color:#FFFFFF; } +#sortBooksCont #indexSortBtn{ +border-color:#808080; +border-style:solid; +background-color:#FFFFFF; +} + #sortBooksCont #titleSortBtn{ border-color:#808080; border-style:solid; @@ -714,7 +720,7 @@ background-color:#EDEDED; background-repeat:no-repeat; background-position:center right; }*/ -#LibrarySortBooksByLayer QPushButton#recentSortBtn, #LibrarySortBooksByLayer QPushButton#authorSortBtn, #LibrarySortBooksByLayer QPushButton#titleSortBtn{ +#LibrarySortBooksByLayer QPushButton#recentSortBtn, #LibrarySortBooksByLayer QPushButton#authorSortBtn, #LibrarySortBooksByLayer QPushButton#indexSortBtn, #LibrarySortBooksByLayer QPushButton#titleSortBtn{ background-repeat:no-repeat; background-position:center right; } diff --git a/bqLibrary/res/library_styles_generic_new.qss b/bqLibrary/res/library_styles_generic_new.qss index 930f4bf..9dbb4a6 100644 --- a/bqLibrary/res/library_styles_generic_new.qss +++ b/bqLibrary/res/library_styles_generic_new.qss @@ -138,6 +138,12 @@ border-right:none; background-color:#FFFFFF; } +#sortBooksCont #indexSortBtn{ +border-color:#808080; +border-style:solid; +background-color:#FFFFFF; +} + #sortBooksCont #titleSortBtn{ border-color:#808080; border-style:solid; diff --git a/bqLibrary/src/Library.cpp b/bqLibrary/src/Library.cpp index 360b86b..6a08045 100644 --- a/bqLibrary/src/Library.cpp +++ b/bqLibrary/src/Library.cpp @@ -200,6 +200,7 @@ Library::Library( QWidget* parent ) : connect(m_sortBooksByLayer, SIGNAL(recentSelected()), this, SLOT(sortBooksByDateClicked())); connect(m_sortBooksByLayer, SIGNAL(titleSelected()), this, SLOT(sortBooksByTitleClicked())); connect(m_sortBooksByLayer, SIGNAL(authorSelected()), this, SLOT(sortBooksByAuthorClicked())); + connect(m_sortBooksByLayer, SIGNAL(indexSelected()), this, SLOT(sortBooksByIndexClicked())); // // LibrarySortBrowserBooksByLayer @@ -1715,6 +1716,34 @@ void Library::sortBooksByAuthorClicked() delete powerLock; } +void Library::sortBooksByIndexClicked() +{ + qDebug() << Q_FUNC_INFO << "m_books: " << m_books.size(); + + PowerManagerLock* powerLock = PowerManager::getNewLock(this); + powerLock->activate(); + + QBookApp::instance()->getStatusBar()->setSpinner(true); + Screen::getInstance()->queueUpdates(); + + clearKeyboard(); + + m_sortBooksByLayer->hide(); + + sortByBtn->setText(m_sortBooksByLayer->getIndexSortName()); + + sortBooksDataCallback = &Library::sortBooksByIndex; + sortCurrentDataCallback = sortBooksDataCallback; + + applySortMethod(); + + QBookApp::instance()->getStatusBar()->setSpinner(false); + Screen::getInstance()->setMode(Screen::MODE_SAFE, true, FLAG_FULLSCREEN_UPDATE, Q_FUNC_INFO); + Screen::getInstance()->setUpdateScheme(Screen::SCHEME_MERGE, true); + Screen::getInstance()->flushUpdates(); + delete powerLock; +} + void Library::sortBooksByTitleClicked() { qDebug() << Q_FUNC_INFO; @@ -1723,10 +1752,12 @@ void Library::sortBooksByTitleClicked() powerLock->activate(); QBookApp::instance()->getStatusBar()->setSpinner(true); + Screen::getInstance()->queueUpdates(); + clearKeyboard(); - + m_sortBooksByLayer->hide(); sortByBtn->setText(m_sortBooksByLayer->getTitleSortName()); @@ -1759,7 +1790,6 @@ void Library::sortBooksByDateClicked() Screen::getInstance()->queueUpdates(); - clearKeyboard(); m_sortBooksByLayer->hide(); @@ -1843,6 +1873,29 @@ void Library::sortFilesByDateClicked() delete powerLock; } +bool sortByCollectionIndex(const BookInfo* b1, const BookInfo* b2) +{ + qDebug() << Q_FUNC_INFO; + + QString collectionName = QBookApp::instance()->getLibrary()->getCollectionSelected(); + QHash collections1 = b1->getCollectionsList(); + QHash collections2 = b2->getCollectionsList(); + QHash::iterator it1 = collections1.find(collectionName); + QHash::iterator it2 = collections2.find(collectionName); + + if(it1 != collections1.end() && it1.key() == collectionName && it2 == collections2.end() && it2.key() != collectionName) + return true; + else if(it1 == collections1.end() && it1.key() != collectionName && it2 != collections2.end() && it2.key() == collectionName) + return false; + else if(it1 != collections1.end() && it1.key() == collectionName && it2 != collections2.end() && it2.key() == collectionName) + { + if (it1.value() == it2.value()) + return (titleLessThan(b1, b2)); + else + return (it1.value() < it2.value()); + } +} + void Library::sortBooksByAuthor() { qDebug() << Q_FUNC_INFO << "m_books:" << m_books.size(); @@ -1857,6 +1910,16 @@ void Library::sortBooksByAuthor() } +void Library::sortBooksByIndex() +{ + qDebug() << Q_FUNC_INFO << "m_books:" << m_books.size(); + + // TODO: ask the model to sort it for us (but this way is faster, because we are omiting the books we don't care) + + qSort(m_books.begin(), m_books.end(), sortByCollectionIndex); + +} + void Library::sortBooksByTitle() { qDebug() << Q_FUNC_INFO; @@ -2719,6 +2782,8 @@ void Library::changeFilterMode( ELibraryFilterMode mode ) (this->*sortCurrentDataCallback)(); if(m_filterMode == ELFM_COLLECTION) showCollectionFilterUIStuff(); + else + m_sortBooksByLayer->enableIndex(false); // Show the new current view (maybe it will start running tasks like generating thumbnails) m_currentView->start(); delete powerLock; @@ -3805,7 +3870,7 @@ void Library::setBooksSortModeCallback() break; } } - else + else if(m_filterMode != ELFM_COLLECTION) { switch(m_booksSortMode) { @@ -3822,6 +3887,8 @@ void Library::setBooksSortModeCallback() break; } } + else + sortBooksDataCallback = &Library::sortBooksByIndex; sortCurrentDataCallback = sortBooksDataCallback; } @@ -3961,14 +4028,19 @@ void Library::selectCollection(const QString& collection) Screen::getInstance()->queueUpdates(); - setBooksSortModeCallback(); handleBooksSortModeUI(); m_currentIconView = m_iconGridViewer; m_currentLineView = m_lineGridViewer; m_collection = collection; fillNewDataCallback = &Library::fillCollectionData; + // Sort mode + sortByBtn->setText(m_sortBooksByLayer->getIndexSortName()); + m_sortBooksByLayer->enableIndex(true); + m_sortBooksByLayer->setIndexChecked(); + sortCurrentDataCallback = &Library::sortBooksByIndex; changeFilterMode(ELFM_COLLECTION); + qSort(m_books.begin(), m_books.end(),sortByCollectionIndex); showCollectionFilterUIStuff(); QBookApp::instance()->getStatusBar()->setSpinner(false); diff --git a/bqLibrary/src/LibraryBookSummary.cpp b/bqLibrary/src/LibraryBookSummary.cpp index a3cd7e2..2a2bbfb 100644 --- a/bqLibrary/src/LibraryBookSummary.cpp +++ b/bqLibrary/src/LibraryBookSummary.cpp @@ -73,7 +73,7 @@ LibraryBookSummary::LibraryBookSummary( QWidget* parent ) : m_collectionLayer = new LibraryCollectionLayer(this); m_collectionLayer->hide(); - connect(m_collectionLayer, SIGNAL(addCollection(QString)), this, SLOT(addBookToCollection(QString))); + connect(m_collectionLayer, SIGNAL(addCollection(QString, double)), this, SLOT(addBookToCollection(QString, double))); connect(m_collectionLayer, SIGNAL(removeCollection(QString)), this, SLOT(removeBookToCollection(QString))); connect(m_collectionLayer, SIGNAL(createCollection()), this, SLOT(createNewCollection())); @@ -223,7 +223,7 @@ void LibraryBookSummary::setBook( const BookInfo* book, int currentBook, int tot m_bookListActions->setButtonsState(m_bookInfo->readingStatus); setActionsBtnText(m_bookInfo->readingStatus); - QStringList bookCollectionList = m_bookInfo->getCollectionsList(); + QHash bookCollectionList = m_bookInfo->getCollectionsList(); m_collectionLayer->setup(bookCollectionList); setCollectionLayerBtnText(bookCollectionList); @@ -464,28 +464,30 @@ void LibraryBookSummary::setActionsBtnText(BookInfo::readStateEnum state) } } -void LibraryBookSummary::setCollectionLayerBtnText(QStringList collectionList) +void LibraryBookSummary::setCollectionLayerBtnText(QHash collectionList) { qDebug() << Q_FUNC_INFO; - if(collectionList.empty()) + if(collectionList.isEmpty()) addToCollectionBtn->setText(tr("Colecciones")); else if (collectionList.size() == 1) { + QHash::iterator it = collectionList.begin(); + QString collectionName = it.key(); if(QBook::getInstance()->getResolution() == QBook::RES758x1024) { - if(collectionList[0].size() >= 10) + if(collectionName.size() >= 10) addToCollectionBtn->setStyleSheet(LITTLE_FONT_SIZE_HD); else addToCollectionBtn->setStyleSheet(FONT_SIZE_HD); } else { - if(collectionList[0].size() >= 10) + if(collectionName.size() >= 10) addToCollectionBtn->setStyleSheet(LITTLE_FONT_SIZE_SD); else addToCollectionBtn->setStyleSheet(FONT_SIZE_SD); } - addToCollectionBtn->setText(bqUtils::truncateStringToLength(tr("%1").arg(collectionList[0]), COLLECTION_MAX_LENGTH)); + addToCollectionBtn->setText(bqUtils::truncateStringToLength(tr("%1").arg(collectionName), COLLECTION_MAX_LENGTH)); } else { @@ -500,12 +502,12 @@ void LibraryBookSummary::setCollectionLayerBtnText(QStringList collectionList) } } -void LibraryBookSummary::addBookToCollection(QString collectionName) +void LibraryBookSummary::addBookToCollection(QString collectionName, double index) { qDebug() << Q_FUNC_INFO; BookInfo* book = new BookInfo (*m_bookInfo); - book->addCollection(collectionName); - QStringList bookCollectionList = book->getCollectionsList(); + book->addCollection(collectionName, index); + QHash bookCollectionList = book->getCollectionsList(); setCollectionLayerBtnText(bookCollectionList); QBookApp::instance()->getModel()->updateBook(book); delete book; @@ -517,7 +519,7 @@ void LibraryBookSummary::removeBookToCollection(QString collectionName) qDebug() << Q_FUNC_INFO; BookInfo* book = new BookInfo (*m_bookInfo); book->removeCollection(collectionName); - QStringList bookCollectionList = book->getCollectionsList(); + QHash bookCollectionList = book->getCollectionsList(); setCollectionLayerBtnText(bookCollectionList); QBookApp::instance()->getModel()->updateBook(book); delete book; diff --git a/bqLibrary/src/LibraryCollectionLayer.cpp b/bqLibrary/src/LibraryCollectionLayer.cpp index 6fd12ae..1e6a307 100644 --- a/bqLibrary/src/LibraryCollectionLayer.cpp +++ b/bqLibrary/src/LibraryCollectionLayer.cpp @@ -98,7 +98,7 @@ void LibraryCollectionLayer::paint() } } -void LibraryCollectionLayer::setup(QStringList collectionList) +void LibraryCollectionLayer::setup(QHash collectionList) { qDebug() << Q_FUNC_INFO << collectionList; m_bookCollections = collectionList; @@ -149,18 +149,20 @@ void LibraryCollectionLayer::changeCollection(int idItem) Screen::getInstance()->queueUpdates(); LibraryCollectionItem* item = items[idItem]; QString collectionName = item->getText(); + QHash::iterator it = m_bookCollections.find(collectionName); - if(m_bookCollections.contains(collectionName)) + if(it != m_bookCollections.end() && it.key() == collectionName) { item->setChecked(false); - m_bookCollections.removeOne(collectionName); + it = m_bookCollections.erase(it); emit removeCollection(collectionName); } else { item->setChecked(true); - m_bookCollections.append(collectionName); - emit addCollection(collectionName); + double index = QBookApp::instance()->getModel()->getBooksInCollectionCount(collectionName) + 1; + m_bookCollections.insert(collectionName, index); + emit addCollection(collectionName, index); } paint(); Screen::getInstance()->setMode(Screen::MODE_QUICK, true, FLAG_PARTIALSCREEN_UPDATE, Q_FUNC_INFO); diff --git a/bqLibrary/src/LibraryEditCollection.cpp b/bqLibrary/src/LibraryEditCollection.cpp index bba296a..6ce9b86 100644 --- a/bqLibrary/src/LibraryEditCollection.cpp +++ b/bqLibrary/src/LibraryEditCollection.cpp @@ -159,16 +159,10 @@ void LibraryEditCollection::paint() { const BookInfo* book = m_books.at(pos); item->setBook(book); - QStringList bookCollections = book->getCollectionsList(); + QHash bookCollections = book->getCollectionsList(); bool inCollection = false; - for(int i = 0; i < bookCollections.size(); i++) - { - if(m_collection == bookCollections[i]) - { + if(bookCollections.find(m_collection) != bookCollections.end()) inCollection = true; - break; - } - } if(inCollection) item->setChecked(true); else @@ -239,7 +233,10 @@ void LibraryEditCollection::saveCollection() continue; BookInfo *bookInfo = new BookInfo(*book); if(it.value()) - bookInfo->addCollection(m_collection); + { + double index = QBookApp::instance()->getModel()->getBooksInCollectionCount(m_collection) + 1; + bookInfo->addCollection(m_collection, index); + } else bookInfo->removeCollection(m_collection); QBookApp::instance()->getModel()->updateBook(bookInfo); @@ -261,7 +258,8 @@ void LibraryEditCollection::changeOldCollection() { BookInfo *bookInfo = new BookInfo(*(*it)); bookInfo->removeCollection(m_initialCollectionName); - bookInfo->addCollection(m_collection); + double index = QBookApp::instance()->getModel()->getBooksInCollectionCount(m_collection) + 1; + bookInfo->addCollection(m_collection, index); QBookApp::instance()->getModel()->updateBook(bookInfo); } QBookApp::instance()->getModel()->removeCollection(m_initialCollectionName); diff --git a/bqLibrary/src/LibrarySortBooksByLayer.cpp b/bqLibrary/src/LibrarySortBooksByLayer.cpp index 2103476..c76604d 100644 --- a/bqLibrary/src/LibrarySortBooksByLayer.cpp +++ b/bqLibrary/src/LibrarySortBooksByLayer.cpp @@ -39,11 +39,13 @@ LibrarySortBooksByLayer::LibrarySortBooksByLayer(QWidget* parent) : connect(recentSortBtn, SIGNAL(clicked()), this, SLOT(recentClicked())); connect(titleSortBtn, SIGNAL(clicked()), this, SLOT(titleClicked())); connect(authorSortBtn, SIGNAL(clicked()), this, SLOT(authorClicked())); + connect(indexSortBtn, SIGNAL(clicked()), this, SLOT(indexClicked())); recentSortBtn->setStyleSheet(CHECKED); recentSortBtn->setStyleSheet(ENABLED); titleSortBtn->setStyleSheet(ENABLED); authorSortBtn->setStyleSheet(ENABLED); + indexSortBtn->setStyleSheet(ENABLED); } LibrarySortBooksByLayer::~LibrarySortBooksByLayer() @@ -61,6 +63,7 @@ void LibrarySortBooksByLayer::recentClicked () { Screen::getInstance()->queueUpdates(); recentSortBtn->setStyleSheet(CHECKED); + indexSortBtn->setStyleSheet(UNCHECKED); titleSortBtn->setStyleSheet(UNCHECKED); authorSortBtn->setStyleSheet(UNCHECKED); Screen::getInstance()->setMode(Screen::MODE_FASTEST, true, Q_FUNC_INFO); @@ -73,6 +76,7 @@ void LibrarySortBooksByLayer::titleClicked () Screen::getInstance()->queueUpdates(); recentSortBtn->setStyleSheet(UNCHECKED); titleSortBtn->setStyleSheet(CHECKED); + indexSortBtn->setStyleSheet(UNCHECKED); authorSortBtn->setStyleSheet(UNCHECKED); Screen::getInstance()->setMode(Screen::MODE_FASTEST, true, Q_FUNC_INFO); Screen::getInstance()->flushUpdates(); @@ -85,6 +89,7 @@ void LibrarySortBooksByLayer::authorClicked () Screen::getInstance()->queueUpdates(); recentSortBtn->setStyleSheet(UNCHECKED); titleSortBtn->setStyleSheet(UNCHECKED); + indexSortBtn->setStyleSheet(UNCHECKED); authorSortBtn->setStyleSheet(CHECKED); Screen::getInstance()->setMode(Screen::MODE_FASTEST, true, Q_FUNC_INFO); Screen::getInstance()->flushUpdates(); @@ -92,22 +97,48 @@ void LibrarySortBooksByLayer::authorClicked () emit authorSelected(); } +void LibrarySortBooksByLayer::indexClicked () +{ + Screen::getInstance()->queueUpdates(); + indexSortBtn->setStyleSheet(CHECKED); + recentSortBtn->setStyleSheet(UNCHECKED); + titleSortBtn->setStyleSheet(UNCHECKED); + authorSortBtn->setStyleSheet(UNCHECKED); + Screen::getInstance()->setMode(Screen::MODE_FASTEST, true, Q_FUNC_INFO); + Screen::getInstance()->flushUpdates(); + + emit indexSelected(); +} + void LibrarySortBooksByLayer::enableRecent(bool enable) { if(enable) - recentSortBtn->setStyleSheet(ENABLED); + recentSortBtn->show(); else - recentSortBtn->setStyleSheet(DISABLED); + recentSortBtn->hide(); recentSortBtn->setEnabled(enable); } +void LibrarySortBooksByLayer::enableIndex(bool enable) +{ + if(enable) + indexSortBtn->show(); + + else + indexSortBtn->hide(); + + indexSortBtn->setEnabled(enable); + +} + void LibrarySortBooksByLayer::setRecentChecked() { recentSortBtn->setStyleSheet(CHECKED); titleSortBtn->setStyleSheet(UNCHECKED); + indexSortBtn->setStyleSheet(UNCHECKED); authorSortBtn->setStyleSheet(UNCHECKED); } @@ -115,6 +146,7 @@ void LibrarySortBooksByLayer::setTitleChecked() { recentSortBtn->setStyleSheet(UNCHECKED); titleSortBtn->setStyleSheet(CHECKED); + indexSortBtn->setStyleSheet(UNCHECKED); authorSortBtn->setStyleSheet(UNCHECKED); } @@ -122,9 +154,18 @@ void LibrarySortBooksByLayer::setAuthorChecked() { recentSortBtn->setStyleSheet(UNCHECKED); titleSortBtn->setStyleSheet(UNCHECKED); + indexSortBtn->setStyleSheet(UNCHECKED); authorSortBtn->setStyleSheet(CHECKED); } +void LibrarySortBooksByLayer::setIndexChecked() +{ + recentSortBtn->setStyleSheet(UNCHECKED); + titleSortBtn->setStyleSheet(UNCHECKED); + indexSortBtn->setStyleSheet(CHECKED); + authorSortBtn->setStyleSheet(UNCHECKED); +} + QString LibrarySortBooksByLayer::getRecentSortName() const { return recentSortBtn->text(); @@ -140,3 +181,7 @@ QString LibrarySortBooksByLayer::getAuthorSortName() const return authorSortBtn->text(); } +QString LibrarySortBooksByLayer::getIndexSortName() const +{ + return indexSortBtn->text(); +} diff --git a/bqLibrary/tr/bqLibrary_ca.ts b/bqLibrary/tr/bqLibrary_ca.ts index b8d2b51..485990e 100755 --- a/bqLibrary/tr/bqLibrary_ca.ts +++ b/bqLibrary/tr/bqLibrary_ca.ts @@ -117,43 +117,43 @@ Tancar - - + + Biblioteca Biblioteca - + Sincronizacion en curso... Para desarchivar, por favor espera unos minutos. Sincronització en curs ... Per arxivar o desarxivar, si us plau esperi uns minuts. - - + + Sincronizando... Por favor, espera unos minutos Sincronitzant... Si us plau, espera uns minuts. - + Fallo de sincronizacion. Error de sincronització. - + Biblioteca sincronizada pero algunos libros han fallado. Biblioteca sincronitzada però alguns llibres han fallat. - + You are about to remove the book Estàs a punt d'esborrar el llibre - - - + + + from de @@ -162,17 +162,17 @@ però alguns llibres han fallat. Estàs a punt de tancar el llibre - - - + + + internal memory. memòria interna. - - - + + + SD card. targeta SD. @@ -182,41 +182,41 @@ però alguns llibres han fallat. Aquest llibre serà eliminat de la llista de recents. - - + + This action will remove the book from device. El llibre deixarà d'estar disponible. - + The sample book will not be available for download. La Mostra no estarà disponible per descarregar-la una altra vegada. - - + + The book will be always available for download. El llibre seguirà disponible per descarregar-lo de nou. - - - + + + Remove Esborrar - + Book correctly removed. Llibre esborrat correctament. - + You are about to archive the book Estàs a punt d'arxivar el llibre - + Has llegado al limite de subscripciones de tu cuenta. Por favor archiva algun otro antes de desarchivar. Has arribat al límit de subscripcions del teu compte. Si us plau, arxiva un llibre abans de desarxivar-ne un altre. @@ -225,218 +225,218 @@ però alguns llibres han fallat. Estàs a punt d'eliminar l'arxiu - + from internal memory. de la memòria interna. - + from SD card. de la targeta SD. - + File correctly removed. Arxiu correctament eliminat. - + Remove failure, the file can not be removed. Error en esborrar l'arxiu. L'arxiu no es pot eliminar. - + from internal memory to SD. de la memòria interna a la targeta SD. - + from SD card to internal memory. de la targeta SD a la memòria interna. - + Todas las colecciones Totes les col·leccions - + (%1) - + Your book is being downloaded. Please wait. El teu llibre s'està descarregant. Si us plau, espera. - + Your book is now available at your Digital Editions folder El llibre està disponible al teu directori Digital Editions. - + Not enough space in the device No hi ha prou espai al dispositiu. - + Check your license activation Comprova la teva llicència. - + Download request has expired La petició de descàrrega ha caducat. - + Error while fulfilling book. Error en obtenir el llibre. - + Are you sure you want to delete %1 collection? The books in the collection will not be deleted. Estàs segur que desitges esborrar la col·lecció %1? Els llibres que hi conté no s'eliminaran. - + SD card is not mounted. La targeta SD no està muntada. - + You are about to change the book state Estàs a punt de canviar l'estat del llibre - + This book will be marked as no read. El llibre es marcarà com a no llegit. - + This book will be marked as now reading. El llibre es marcarà com "llegint". - + This book will be marked as read. El llibre es marcarà com a llegit. - + Change Canviar - + You are about to remove the Estàs a punt d'eliminar - - + + folder directori - - + + file l'arxiu - + Folder correctly removed. Directori eliminat correctament. - + Remove failure, the folder can not be removed. Error en esborrar. El directori no pot ésser eliminat. - + You are about to copy the Estàs a punt de copiar el - + The file already exists. Please delete the file before copy it. El fitxer ja existeix a destí. Si us plau, esborra el fitxer abans de copiar-lo. - + Already exists a folder with this name. Please delete the file before copy it. Ja existeix un directori amb el mateix nom. Si us plau, esborra el directori abans de copiar-lo. - + Copying files... Copiant fitxers... - + Folder correctly copied. Directori copiat correctament. - - + + Copy has failed. Please check your SD card. La copia ha fallat. Si us plau, comprova que has introduït la targeta SD correctament. - + Copy failure, the file already exists. No s'ha pogut copiar, el fitxer ja existeix al destí. - + You are about to export notes from this book Estàs a punt d'exportar les teves notes i ressaltats d'aquest llibre - + from your library to internal memory. a la memòria interna. - + from internal memory to internal memory. a la memòria interna. - + from SD card to SD card. a la targeta SD. - + Export Exportar - + Notes exported correctly. Anotacions exportades correctament. - + Archive Arxivar - + Libro correctamente desarchivado. Llibre correctament desarxivat. - + Document format not supported Format de document no suportat @@ -445,38 +445,38 @@ Please delete the file before copy it. Estàs a punt de copiar el fitxer - - - + + + Do you want to continue? Vols continuar? - + Copy Copiar - + File correctly copied. Arxiu copiat correctament. - + %1 - + Buscar Cercar - - - + + + Mostrando (%1) resultados Mostrant (%1) resultats @@ -582,68 +582,73 @@ Vols continuar? Formulari - + La sombra de la sirena L'ombra de la sirena - + Camilla Läckberg Camilla Läckberg - + FB2 - + 9,95€ 9,95 € - + Total de páginas: Total de pàgines: - + 100 100 - - + + Colecciones Col·leccions - + Comprar Comprar + + + 1/20 + 1/20 + - + Más acciones Més accions - + Copiar a SD Copiar - + Exportar notas Exportar notes - + Archivar Arxivar - + Remove Esborrar @@ -652,12 +657,12 @@ Vols continuar? Llegir mostra - + Sinopsis Sinopsi - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -666,48 +671,53 @@ p, li { white-space: pre-wrap; } - + Copy Copiar - + Unarchive Desarxivar - + Archive Arxivar - + + %1/%2 + + + + Leyendo Llegint - + Leido Llegit - + No leido No llegit - + %1 - + En %1 colecciones A %1 col·leccions - - + + Autor Desconocido Autor desconegut @@ -738,7 +748,7 @@ p, li { white-space: pre-wrap; } - + Autor Desconocido Autor desconegut @@ -872,7 +882,7 @@ p, li { white-space: pre-wrap; } LibraryCollectionLayer - + Añadir colección Crear col·lecció @@ -915,22 +925,22 @@ p, li { white-space: pre-wrap; } Guardar col·lecció - + Editar %1 Editar %1 - + Crear Collecion Crear col·lecció - + Ocultar Amagar - + ¿Deseas sobreescribir la coleccion del mismo nombre? No se mantendran los libros guardados en ella. Desitges sobreescriure la col·lecció del mateix nom? Els llibres que hi tens guardats no es mantindran a la nova col·lecció. @@ -1059,17 +1069,17 @@ p, li { white-space: pre-wrap; } llibres - + %1 - + Book llibre - + Books llibres @@ -1304,20 +1314,25 @@ p, li { white-space: pre-wrap; } Formulari - + Reciente Recent - + Título Títol - + Autor Autor + + + Índice colección + Índex col·lecció + LibrarySortBrowserBooksByLayer diff --git a/bqLibrary/tr/bqLibrary_en.ts b/bqLibrary/tr/bqLibrary_en.ts index 19a8158..8a508a7 100755 --- a/bqLibrary/tr/bqLibrary_en.ts +++ b/bqLibrary/tr/bqLibrary_en.ts @@ -117,43 +117,43 @@ Close - - + + Biblioteca Library - + Sincronizacion en curso... Para desarchivar, por favor espera unos minutos. Synchronization in progress... To archive or unarchive, please wait a few minutes. - - + + Sincronizando... Por favor, espera unos minutos Synchronizing... Please wait a few minutes. - + Fallo de sincronizacion. Synchronization failed. - + Biblioteca sincronizada pero algunos libros han fallado. Library synchronized but some books have failed. - + You are about to remove the book You are about to remove the book - - - + + + from from @@ -162,17 +162,17 @@ but some books have failed. Your are about to close the book - - - + + + internal memory. internal memory. - - - + + + SD card. @@ -182,41 +182,41 @@ but some books have failed. This book will be deleted from the Recent Reads list. - - + + This action will remove the book from device. The book will no longer be available. - + The sample book will not be available for download. The sample will not be available for download again. - - + + The book will be always available for download. The book will continue to be available for new download. - - - + + + Remove Delete - + Book correctly removed. Book deleted correctly. - + You are about to archive the book You are about to archive this book - + Has llegado al limite de subscripciones de tu cuenta. Por favor archiva algun otro antes de desarchivar. You have reached the subscription limit for your account. Please archive a book before restoring any others. @@ -225,218 +225,218 @@ but some books have failed. You are about to delete the file - + from internal memory. from the internal memory. - + from SD card. from the SD card. - + File correctly removed. File deleted correctly. - + Remove failure, the file can not be removed. File deletion error. The file cannot be deleted. - + from internal memory to SD. from the Internal memory to the SD card. - + from SD card to internal memory. from the the SD card to the Internal memory. - + Todas las colecciones All collections - + (%1) - + Your book is being downloaded. Please wait. Your book is being downloaded. Please wait. - + Your book is now available at your Digital Editions folder This book is available in your Digital Editions directory. - + Not enough space in the device Not enough space in the device. - + Check your license activation Check your licence. - + Download request has expired The download request has expired. - + Error while fulfilling book. An error occurred while trying to obtain the book. - + Are you sure you want to delete %1 collection? The books in the collection will not be deleted. Are you sure you want to delete the %1 collection? The books it contains will not be deleted. - + SD card is not mounted. The SD card is not mounted. - + You are about to change the book state You are about to change the status of the book - + This book will be marked as no read. The book will be marked as unread. - + This book will be marked as now reading. The book will be marked as being read. - + This book will be marked as read. The book will be marked as read. - + Change Change - + You are about to remove the You are about to delete the - - + + folder directory - - + + file file - + Folder correctly removed. Directory deleted correctly. - + Remove failure, the folder can not be removed. Deletion error. The directory could not be deleted. - + You are about to copy the You are about to copy the - + The file already exists. Please delete the file before copy it. The file already exists in this destination. Please delete the file before copying it. - + Already exists a folder with this name. Please delete the file before copy it. A directory with this name already exists. Please delete the directory before copying it. - + Copying files... Copying files... - + Folder correctly copied. Directory copied successfully. - - + + Copy has failed. Please check your SD card. The copy procedure has failed. Please make sure you have inserted the SD card correctly. - + Copy failure, the file already exists. Copy failure, the file already exists. - + You are about to export notes from this book You are about to export the notes and highlighting for this book - + from your library to internal memory. to internal memory. - + from internal memory to internal memory. to internal memory. - + from SD card to SD card. to SD card. - + Export Export - + Notes exported correctly. Notes exported correctly. - + Archive Archive - + Libro correctamente desarchivado. Book unarchived correctly. - + Document format not supported Document format not supported @@ -445,38 +445,38 @@ Please delete the file before copy it. You are about to copy this file - - - + + + Do you want to continue? Would you like to continue? - + Copy Copy - + File correctly copied. File copied successfully. - + %1 - + Buscar Search - - - + + + Mostrando (%1) resultados Showing (%1) of results @@ -582,68 +582,73 @@ Would you like to continue? Form - + La sombra de la sirena The Shadow of the Mermaid - + Camilla Läckberg Camilla Läckberg - + FB2 - + 9,95€ €9.95 - + Total de páginas: Total pages: - + 100 100 - - + + Colecciones Collections - + Comprar Buy + + + 1/20 + 1/20 + - + Más acciones More options - + Copiar a SD Copy - + Exportar notas Export notes - + Archivar Archive - + Remove Delete @@ -652,12 +657,12 @@ Would you like to continue? Read a sample - + Sinopsis Synopsis - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -670,48 +675,53 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">ssdsdsdsd</p></body></html> - + Copy Copy - + Unarchive Unarchive - + Archive Archive - + + %1/%2 + + + + Leyendo Reading - + Leido Read - + No leido Unread - + %1 - + En %1 colecciones In %1 collections - - + + Autor Desconocido Unknown author @@ -742,7 +752,7 @@ p, li { white-space: pre-wrap; } - + Autor Desconocido Unknown author @@ -876,7 +886,7 @@ p, li { white-space: pre-wrap; } LibraryCollectionLayer - + Añadir colección Create collection @@ -919,22 +929,22 @@ p, li { white-space: pre-wrap; } Save collection - + Editar %1 Edit %1 - + Crear Collecion Create collection - + Ocultar Hide - + ¿Deseas sobreescribir la coleccion del mismo nombre? No se mantendran los libros guardados en ella. Do you wish to replace the existing collection of the same name? The books stored in it will not be included in the new collection. @@ -1063,17 +1073,17 @@ p, li { white-space: pre-wrap; } books - + %1 - + Book book - + Books books @@ -1308,20 +1318,25 @@ p, li { white-space: pre-wrap; } Form - + Reciente Recent - + Título Title - + Autor Author + + + Índice colección + Collection index + LibrarySortBrowserBooksByLayer diff --git a/bqLibrary/tr/bqLibrary_es.ts b/bqLibrary/tr/bqLibrary_es.ts index c748c14..25e1eb2 100755 --- a/bqLibrary/tr/bqLibrary_es.ts +++ b/bqLibrary/tr/bqLibrary_es.ts @@ -117,43 +117,43 @@ Cerrar - - + + Biblioteca Biblioteca - + Sincronizacion en curso... Para desarchivar, por favor espera unos minutos. Sincronización en curso... Para archivar o desarchivar, por favor espera unos minutos. - - + + Sincronizando... Por favor, espera unos minutos Sincronizando... Por favor, espera unos minutos. - + Fallo de sincronizacion. Fallo de sincronización. - + Biblioteca sincronizada pero algunos libros han fallado. Biblioteca sincronizada pero algunos libros han fallado. - + You are about to remove the book Estás a punto de eliminar el libro - - - + + + from de @@ -162,17 +162,17 @@ pero algunos libros han fallado. Estás a punto de cerrar el libro - - - + + + internal memory. la memoria interna. - - - + + + SD card. la tarjeta SD. @@ -182,41 +182,41 @@ pero algunos libros han fallado. Este libro será eliminado de la lista de recientes. - - + + This action will remove the book from device. El libro dejará de estar disponible. - + The sample book will not be available for download. La muestra no estará disponible para descargarla de nuevo. - - + + The book will be always available for download. El libro seguirá disponible para descargarlo de nuevo. - - - + + + Remove Borrar - + Book correctly removed. Libro borrado correctamente. - + You are about to archive the book Estás a punto de archivar el libro - + Has llegado al limite de subscripciones de tu cuenta. Por favor archiva algun otro antes de desarchivar. Has llegado al límite de suscripciones de tu cuenta. Por favor archiva algún libro antes de desarchivar. @@ -225,218 +225,218 @@ pero algunos libros han fallado. Estás a punto de eliminar el archivo - + from internal memory. de la memoria interna. - + from SD card. de la tarjeta SD. - + File correctly removed. Archivo correctamente eliminado. - + Remove failure, the file can not be removed. Fallo al borrar el archivo. El archivo no se puede eliminar. - + from internal memory to SD. de la memoria interna a la tarjeta SD. - + from SD card to internal memory. de la tarjeta SD a la memoria interna. - + Todas las colecciones Todas las colecciones - + (%1) - + Your book is being downloaded. Please wait. Tu libro se está descargando. Por favor espera. - + Your book is now available at your Digital Editions folder El libro está disponible en tu directorio Digital Editions. - + Not enough space in the device No hay suficiente espacio en el dispositivo. - + Check your license activation Comprueba tu licencia. - + Download request has expired La petición de descarga ha caducado. - + Error while fulfilling book. Error al obtener el libro. - + Are you sure you want to delete %1 collection? The books in the collection will not be deleted. ¿Estás seguro de que quieres borrar la colección %1? Los libros contenidos en ella no se eliminarán. - + SD card is not mounted. La tarjeta SD no está montada. - + You are about to change the book state Estás a punto de cambiar el estado del libro - + This book will be marked as no read. El libro se marcará como no leído. - + This book will be marked as now reading. El libro se marcará como leyendo. - + This book will be marked as read. El libro se marcará como leído. - + Change Cambiar - + You are about to remove the Estás a punto de eliminar el - - + + folder directorio - - + + file archivo - + Folder correctly removed. Directorio eliminado correctamente. - + Remove failure, the folder can not be removed. Error al borrar. El directorio no puede ser eliminado. - + You are about to copy the Estás a punto de copiar el - + The file already exists. Please delete the file before copy it. El fichero ya existe en destino. Por favor, borra el fichero antes de copiarlo. - + Already exists a folder with this name. Please delete the file before copy it. Ya existe un directorio con el mismo nombre. Por favor, borra el directorio antes de copiarlo. - + Copying files... Copiando ficheros... - + Folder correctly copied. Directorio copiado correctamente. - - + + Copy has failed. Please check your SD card. La copia ha fallado. Por favor, comprueba que has introducido la tarjeta SD correctamente. - + Copy failure, the file already exists. No se pudo copiar, el fichero ya existe en destino. - + You are about to export notes from this book Estás a punto de exportar tus notas y resaltados de este libro - + from your library to internal memory. a la memoria interna. - + from internal memory to internal memory. a la memoria interna. - + from SD card to SD card. a la tarjeta SD. - + Export Exportar - + Notes exported correctly. Anotaciones exportadas correctamente. - + Archive Archivar - + Libro correctamente desarchivado. Libro correctamente desarchivado. - + Document format not supported Formato de documento no soportado @@ -445,38 +445,38 @@ Please delete the file before copy it. Estás a punto de copiar el fichero - - - + + + Do you want to continue? ¿Deseas continuar? - + Copy Copiar - + File correctly copied. Archivo copiado correctamente. - + %1 - + Buscar Buscar - - - + + + Mostrando (%1) resultados Mostrando (%1) resultados @@ -582,68 +582,73 @@ Do you want to continue? Formulario - + La sombra de la sirena La sombra de la sirena - + Camilla Läckberg Camilla Läckberg - + FB2 - + 9,95€ 9,95€ - + Total de páginas: Total de páginas: - + 100 100 - - + + Colecciones Colecciones - + Comprar Comprar + + + 1/20 + 1/20 + - + Más acciones Más acciones - + Copiar a SD Copiar - + Exportar notas Exportar notas - + Archivar Archivar - + Remove Borrar @@ -652,12 +657,12 @@ Do you want to continue? Leer muestra - + Sinopsis Sinopsis - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -666,48 +671,53 @@ p, li { white-space: pre-wrap; } - + Copy Copiar - + Unarchive Desarchivar - + Archive Archivar - + + %1/%2 + + + + Leyendo Leyendo - + Leido Leído - + No leido No leído - + %1 - + En %1 colecciones En %1 colecciones - - + + Autor Desconocido Autor desconocido @@ -738,7 +748,7 @@ p, li { white-space: pre-wrap; } - + Autor Desconocido Autor desconocido @@ -872,7 +882,7 @@ p, li { white-space: pre-wrap; } LibraryCollectionLayer - + Añadir colección Crear colección @@ -915,22 +925,22 @@ p, li { white-space: pre-wrap; } Guardar colección - + Editar %1 Editar %1 - + Crear Collecion Crear colección - + Ocultar Ocultar - + ¿Deseas sobreescribir la coleccion del mismo nombre? No se mantendran los libros guardados en ella. ¿Deseas sobreescribir la colección del mismo nombre? Los libros guardados en ella no se mantendrán en la nueva colección. @@ -1059,17 +1069,17 @@ p, li { white-space: pre-wrap; } libros - + %1 - + Book libro - + Books libros @@ -1304,20 +1314,25 @@ p, li { white-space: pre-wrap; } Formulario - + Reciente Reciente - + Título Título - + Autor Autor + + + Índice colección + Índice colección + LibrarySortBrowserBooksByLayer diff --git a/bqLibrary/tr/bqLibrary_eu.ts b/bqLibrary/tr/bqLibrary_eu.ts index c2fcc80..24644aa 100755 --- a/bqLibrary/tr/bqLibrary_eu.ts +++ b/bqLibrary/tr/bqLibrary_eu.ts @@ -587,6 +587,14 @@ p, li { white-space: pre-wrap; } En %1 colecciones %1 bildumatan + + 1/20 + 1/20 + + + %1/%2 + + LibraryBookToCollectionItem @@ -1080,6 +1088,10 @@ p, li { white-space: pre-wrap; } Autor Egilea + + Índice colección + Aurkibidea + LibrarySortBrowserBooksByLayer diff --git a/bqLibrary/tr/bqLibrary_gl.ts b/bqLibrary/tr/bqLibrary_gl.ts index 8e9213b..d0240e1 100644 --- a/bqLibrary/tr/bqLibrary_gl.ts +++ b/bqLibrary/tr/bqLibrary_gl.ts @@ -69,29 +69,29 @@ Mostrar resultados - - + + Biblioteca Biblioteca - + Sincronizacion en curso... Para desarchivar, por favor espera unos minutos. Sincronización en curso...Para arquivar ou desarquivar, por favor agarda uns minutos. - - + + Sincronizando... Por favor, espera unos minutos Sincronizando...Por favor, agarda uns minutos. - + Fallo de sincronizacion. Fallo de sincronización. - + Biblioteca sincronizada pero algunos libros han fallado. Biblioteca sincronizada @@ -102,24 +102,24 @@ mais algúns libros fallaron. Estás a piques de pecha-lo libro - - - + + + from de - - - + + + internal memory. memoria interna. - - - + + + SD card. tarxeta SD. @@ -129,86 +129,86 @@ mais algúns libros fallaron. Este libro será eliminado da lista de recentes. - + You are about to change the book state Estás a piques de cambiar o estado do libro - + This book will be marked as no read. O libro marcarase como non lido. - + This book will be marked as now reading. O libro marcarase como lendo. - + This book will be marked as read. O libro marcarase como lido. - + Change Cambiar - + You are about to remove the book Estás a piques de elimina-lo libro - - + + This action will remove the book from device. O libro deixará de estar dispoñible. - + The sample book will not be available for download. A mostra non estará dispoñible para descargala de novo. - - + + The book will be always available for download. O libro seguirá dispoñible para descargalo de novo. - - - + + + Remove Borrar - + Book correctly removed. Libro borrado correctamente. - + You are about to archive the book Estás a piques de arquiva-lo libro - + Archive Arquivar - + Libro correctamente desarchivado. Libro correctamente desarquivado. - + Has llegado al limite de subscripciones de tu cuenta. Por favor archiva algun otro antes de desarchivar. Chegaches ó límite de subscricións da túa conta. Por favor arquiva algún libro antes de desarquivar. - + Document format not supported Formato de documento non soportado @@ -217,31 +217,31 @@ mais algúns libros fallaron. Estás a piques de elimina-lo arquivo - + from internal memory. da memoria interna. - + from SD card. da tarxeta SD. - - - + + + Do you want to continue? ¿Desexas continuar? - + File correctly removed. Arquivo correctamente eliminado. - + Remove failure, the file can not be removed. Fallo ó borra-lo arquivo. O arquivo non se pode eliminar. @@ -250,184 +250,184 @@ Do you want to continue? Estás a piques de copiar o ficheiro - + You are about to remove the Estás a piques de elimina-lo - - + + folder directorio - - + + file arquivo - + Folder correctly removed. Directorio eliminado correctamente. - + Remove failure, the folder can not be removed. Erro ao borrar. O directorio non pode ser eliminado. - + You are about to copy the Estás a piques de copiar o - + SD card is not mounted. A tarxeta SD non está montada. - + from internal memory to SD. da memoria interna á tarxeta SD. - + from SD card to internal memory. da tarxeta SD á memoria interna. - + The file already exists. Please delete the file before copy it. O ficheiro xa existe en destino. Por favor, borra o ficheiro antes de copialo. - + Already exists a folder with this name. Please delete the file before copy it. Xa existe un directorio co mesmo nome. Por favor, borra o directorio antes de copialo. - + Copy Copiar - + Copying files... Copiando ficheiros... - + Folder correctly copied. Directorio copiado correctamente. - + File correctly copied. Arquivo copiado correctamente. - - + + Copy has failed. Please check your SD card. A copia fallou. Por favor, comproba que introduciches a tarxeta SD correctamente. - + Copy failure, the file already exists. Non se puido copiar, o ficheiro xa existe no destino. - + You are about to export notes from this book Estás a piques de exportar as túas notas e resaltados deste libro - + from your library to internal memory. á memoria interna. - + from internal memory to internal memory. á memoria interna. - + from SD card to SD card. á tarxeta SD. - + Export Exportar - + Notes exported correctly. Anotacións exportadas correctamente. - + Todas las colecciones Todas as coleccións - + %1 - + (%1) - + Buscar Buscar - - - + + + Mostrando (%1) resultados Mostrando (%1) resultados - + Your book is being downloaded. Please wait. O teu libro estase descargando. Por favor agarda. - + Your book is now available at your Digital Editions folder O teu libro está dispoñible no teu directorio Digital Editions. - + Not enough space in the device Non hai suficiente espazo no dispositivo. - + Check your license activation Comproba a túa licencia. - + Download request has expired A petición de descarga caducou. - + Error while fulfilling book. Erro ó obte-lo libro. - + Are you sure you want to delete %1 collection? The books in the collection will not be deleted. ¿Estás seguro de que queres borrar a colección %1? Os libros contidos nela non se eliminarán. @@ -538,68 +538,73 @@ The books in the collection will not be deleted. Formulario - + La sombra de la sirena A sombra da serea - + Camilla Läckberg Camilla Läckberg - + FB2 - + 9,95€ 9,95€ - + Total de páginas: Total de páxinas: - + 100 100 - - + + Colecciones Coleccións - + Comprar Mercar + + + 1/20 + 1/20 + - + Más acciones Máis accións - + Copiar a SD Copiar - + Exportar notas Exportar notas - + Archivar Arquivar - + Remove Borrar @@ -608,12 +613,12 @@ The books in the collection will not be deleted. Ler mostra - + Sinopsis Sinopse - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -626,48 +631,53 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">ssdsdsdsd</p></body></html> - + Copy Copiar - + Unarchive Desarquivar - + Archive Arquivar - + + %1/%2 + + + + Leyendo Lendo - + Leido Lido - + No leido Non lido - + %1 - + En %1 colecciones En %1 coleccións - - + + Autor Desconocido Autor descoñecido @@ -698,7 +708,7 @@ p, li { white-space: pre-wrap; } - + Autor Desconocido Autor descoñecido @@ -804,7 +814,7 @@ p, li { white-space: pre-wrap; } LibraryCollectionLayer - + Añadir colección Crear colección @@ -847,22 +857,22 @@ p, li { white-space: pre-wrap; } Gardar colección - + Editar %1 Editar %1 - + Crear Collecion Crear colección - + Ocultar Ocultar - + ¿Deseas sobreescribir la coleccion del mismo nombre? No se mantendran los libros guardados en ella. ¿Desexas sobrescribir a colección do mesmo nome? Os libros gardados nela non se manterán na nova colección. @@ -987,17 +997,17 @@ p, li { white-space: pre-wrap; } libros - + %1 - + Book libro - + Books libros @@ -1228,20 +1238,25 @@ p, li { white-space: pre-wrap; } Formulario - + Reciente Recente - + Título Título - + Autor Autor + + + Índice colección + Índice colección + LibrarySortBrowserBooksByLayer diff --git a/bqLibrary/tr/bqLibrary_pt.ts b/bqLibrary/tr/bqLibrary_pt.ts index 53b4ed2..031872d 100755 --- a/bqLibrary/tr/bqLibrary_pt.ts +++ b/bqLibrary/tr/bqLibrary_pt.ts @@ -117,43 +117,43 @@ Fechar - - + + Biblioteca Biblioteca - + Sincronizacion en curso... Para desarchivar, por favor espera unos minutos. Sincronização em andamento... Para arquivar ou desarquivar, por favor aguarde alguns minutos. - - + + Sincronizando... Por favor, espera unos minutos Sincronização... Por favor, aguarde alguns minutos. - + Fallo de sincronizacion. Falha na sincronização. - + Biblioteca sincronizada pero algunos libros han fallado. Biblioteca sincronizada mas alguns livros falharam. - + You are about to remove the book Está prestes a eliminar o livro - - - + + + from de @@ -162,17 +162,17 @@ mas alguns livros falharam. Está prestes a fechar o livro - - - + + + internal memory. memória interna. - - - + + + SD card. cartão SD. @@ -182,41 +182,41 @@ mas alguns livros falharam. Este livro será eliminado da lista de recentes. - - + + This action will remove the book from device. O livro deixará de estar disponível. - + The sample book will not be available for download. A amostra não estará disponível para descarregar novamente. - - + + The book will be always available for download. O livro continuará disponível para baixar novamente. - - - + + + Remove Eliminar - + Book correctly removed. Livro eliminado corretamente. - + You are about to archive the book Está prestes a arquivar o livro - + Has llegado al limite de subscripciones de tu cuenta. Por favor archiva algun otro antes de desarchivar. O limite de subscrições da sua conta foi atingido. Por favor, arquive um livro antes de desarquivar outro. @@ -225,218 +225,218 @@ mas alguns livros falharam. Estás prestes a eliminar o ficheiro - + from internal memory. da memória interna. - + from SD card. do cartão SD. - + File correctly removed. Ficheiro corretamente eliminado. - + Remove failure, the file can not be removed. Erro ao apagar os dados. O arquivo não pode ser apagado. - + from internal memory to SD. da memória interna para o cartão SD. - + from SD card to internal memory. do cartão SD para a memória interna. - + Todas las colecciones Todas as coleções - + (%1) - + Your book is being downloaded. Please wait. O seu livro está a ser descarregado. Por favor, aguarde. - + Your book is now available at your Digital Editions folder O livro está disponível no seu diretorio Digital Editions. - + Not enough space in the device Não há espaço suficiente no dispositivo. - + Check your license activation Verifique a sua licença. - + Download request has expired A ordem de descarga expirou. - + Error while fulfilling book. Erro ao obter o livro. - + Are you sure you want to delete %1 collection? The books in the collection will not be deleted. Tem a certeza de que pretende apagar a coleção %1? Os livros contidos nela não serão eliminados. - + SD card is not mounted. O cartão SD não foi reconhecido. - + You are about to change the book state Está prestes a alterar o estado do livro - + This book will be marked as no read. O libro será marcado como não lido. - + This book will be marked as now reading. O libro será marcado com leitura em curso. - + This book will be marked as read. O libro será marcado como lido. - + Change Alterar - + You are about to remove the Está prestes a eliminar o - - + + folder diretório - - + + file ficheiro - + Folder correctly removed. Diretório corretamente eliminado. - + Remove failure, the folder can not be removed. Erro ao apagar. O diretório não pode ser eliminado. - + You are about to copy the Está prestes a copiar o - + The file already exists. Please delete the file before copy it. O ficheiro já existe no destino. Por favor, apague primeiro o ficheiro antes de o copiar. - + Already exists a folder with this name. Please delete the file before copy it. Já existe um diretório com o mesmo nome. Por favor, apague primeiro o diretório antes de o copiar. - + Copying files... A copiar ficheiros... - + Folder correctly copied. Diretório copiado com sucesso. - - + + Copy has failed. Please check your SD card. A cópia falhou. Por favor, comprove se o cartão SD foi introduzido corretamente. - + Copy failure, the file already exists. Não é possível copiar. O ficheiro já existe no destino. - + You are about to export notes from this book Está prestes a exportar as suas notas e destaques deste livro - + from your library to internal memory. a memória interna. - + from internal memory to internal memory. a memória interna. - + from SD card to SD card. a cartão SD. - + Export Exportar - + Notes exported correctly. Anotações exportadas correctamente. - + Archive Arquivar - + Libro correctamente desarchivado. Livro corretamente desarquivado. - + Document format not supported Formato de documento não suportado @@ -445,38 +445,38 @@ Please delete the file before copy it. Está a prestes a copiar o arquivo - - - + + + Do you want to continue? Deseja continuar? - + Copy Copiar - + File correctly copied. Arquivo copiado com sucesso. - + %1 - + Buscar Procurar - - - + + + Mostrando (%1) resultados A mostrar (%1) resultados @@ -582,68 +582,73 @@ Deseja continuar? Formulário - + La sombra de la sirena La sombra de la sirena - + Camilla Läckberg Camilla Läckberg - + FB2 - + 9,95€ 9,95€ - + Total de páginas: Total de páginas: - + 100 100 - - + + Colecciones Coleções - + Comprar Comprar + + + 1/20 + 1/20 + - + Más acciones Mais ações - + Copiar a SD Copiar - + Exportar notas Exportar notas - + Archivar Arquivar - + Remove Eliminar @@ -652,12 +657,12 @@ Deseja continuar? Ler amostra - + Sinopsis Sinopse - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -666,48 +671,53 @@ p, li { white-space: pre-wrap; } - + Copy Copiar - + Unarchive Desarquivar - + Archive Arquivar - + + %1/%2 + + + + Leyendo A ler - + Leido Lido - + No leido Não lido - + %1 - + En %1 colecciones Em %1 coleções - - + + Autor Desconocido Autor desconhecido @@ -738,7 +748,7 @@ p, li { white-space: pre-wrap; } - + Autor Desconocido Autor desconhecido @@ -872,7 +882,7 @@ p, li { white-space: pre-wrap; } LibraryCollectionLayer - + Añadir colección Criar coleção @@ -915,22 +925,22 @@ p, li { white-space: pre-wrap; } Guardar coleção - + Editar %1 Editar %1 - + Crear Collecion Criar coleção - + Ocultar Ocultar - + ¿Deseas sobreescribir la coleccion del mismo nombre? No se mantendran los libros guardados en ella. Deseja sobrescrever a coleção com o mesmo nome? Os livros guardados nela não serão mantidos na nova coleção. @@ -1059,17 +1069,17 @@ p, li { white-space: pre-wrap; } livros - + %1 - + Book livro - + Books livros @@ -1304,20 +1314,25 @@ p, li { white-space: pre-wrap; } Formulário - + Reciente Recente - + Título Título - + Autor Autor + + + Índice colección + Índice coleção + LibrarySortBrowserBooksByLayer diff --git a/bqLibrary/ui/LibrarySortBooksByLayer.ui b/bqLibrary/ui/LibrarySortBooksByLayer.ui index b4f74de..4e2bed8 100755 --- a/bqLibrary/ui/LibrarySortBooksByLayer.ui +++ b/bqLibrary/ui/LibrarySortBooksByLayer.ui @@ -146,14 +146,8 @@ 620 - - - 0 - - - 0 - - + + @@ -172,7 +166,7 @@ - + @@ -191,7 +185,7 @@ - + @@ -210,6 +204,25 @@ + + + + + 0 + 0 + + + + Qt::NoFocus + + + Índice colección + + + true + + + diff --git a/bqUi/inc/MouseFilter.h b/bqUi/inc/MouseFilter.h index a6eb83d..26a2c2a 100644 --- a/bqUi/inc/MouseFilter.h +++ b/bqUi/inc/MouseFilter.h @@ -27,7 +27,7 @@ along with the source code. If not, see . #include #include -#define LONG_PRESS_INTERVAL 700 +#define LONG_PRESS_INTERVAL 300 #define SWIPE_MIN_LENGTH 32 // Set by tuning #define SWIPE_MIN_LENGTH_HD 40 // Set by tuning #define SWIPE_MAX_TIME 600 diff --git a/bqViewer/inc/ViewerBookSummary.h b/bqViewer/inc/ViewerBookSummary.h index c355618..b3b823c 100644 --- a/bqViewer/inc/ViewerBookSummary.h +++ b/bqViewer/inc/ViewerBookSummary.h @@ -73,8 +73,8 @@ private slots: void deleteBook (); void exportNotes (); void changeReadState ( int ); - void setCollectionLayerBtnText (QStringList collectionList); - void addBookToCollection (QString collectionName); + void setCollectionLayerBtnText (QHash collectionList); + void addBookToCollection (QString collectionName, double index); void removeBookToCollection (QString collectionName); void createNewCollection (); }; diff --git a/bqViewer/inc/ViewerCollectionLayer.h b/bqViewer/inc/ViewerCollectionLayer.h index cfa2bef..f7fbf4f 100644 --- a/bqViewer/inc/ViewerCollectionLayer.h +++ b/bqViewer/inc/ViewerCollectionLayer.h @@ -33,7 +33,7 @@ class ViewerCollectionLayer : public GestureWidget, protected Ui::ViewerCollecti public: ViewerCollectionLayer ( QWidget* parent ); virtual ~ViewerCollectionLayer (); - void setup ( QStringList collectionList ); + void setup ( QHash collectionList ); void paint (); @@ -43,7 +43,7 @@ protected slots: void changeCollection (int idItem); signals: - void addCollection (QString collectionName); + void addCollection (QString collectionName, double index); void removeCollection (QString collectionName); void createCollection (); @@ -51,7 +51,7 @@ protected slots: /* http://qt-project.org/forums/viewthread/7340 */ virtual void paintEvent ( QPaintEvent* ); - QStringList m_bookCollections; + QHash m_bookCollections; QStringList m_modelCollections; QList items; int m_page; diff --git a/bqViewer/src/ViewerBookSummary.cpp b/bqViewer/src/ViewerBookSummary.cpp index d24092d..f99d087 100644 --- a/bqViewer/src/ViewerBookSummary.cpp +++ b/bqViewer/src/ViewerBookSummary.cpp @@ -69,7 +69,7 @@ ViewerBookSummary::ViewerBookSummary(Viewer* viewer) : m_collectionLayer = new ViewerCollectionLayer(this); m_collectionLayer->hide(); - connect(m_collectionLayer, SIGNAL(addCollection(QString)), this, SLOT(addBookToCollection(QString))); + connect(m_collectionLayer, SIGNAL(addCollection(QString, double)), this, SLOT(addBookToCollection(QString, double))); connect(m_collectionLayer, SIGNAL(removeCollection(QString)), this, SLOT(removeBookToCollection(QString))); connect(m_collectionLayer, SIGNAL(createCollection()), this, SLOT(createNewCollection())); @@ -188,7 +188,7 @@ void ViewerBookSummary::setBook(const BookInfo* book) m_viewerListActions->setButtonsState(m_book->readingStatus); setActionsBtnText(m_book->readingStatus); - QStringList bookCollectionList = m_book->getCollectionsList(); + QHash bookCollectionList = m_book->getCollectionsList(); m_collectionLayer->setup(bookCollectionList); setCollectionLayerBtnText(bookCollectionList); @@ -599,28 +599,30 @@ void ViewerBookSummary::changeReadState(int state) dialog->showForSpecifiedTime(); } -void ViewerBookSummary::setCollectionLayerBtnText(QStringList collectionList) +void ViewerBookSummary::setCollectionLayerBtnText(QHash collectionList) { qDebug() << Q_FUNC_INFO; - if(collectionList.empty()) + if(collectionList.isEmpty()) addToCollectionBtn->setText(tr("Colecciones")); else if (collectionList.size() == 1) { + QHash::iterator it = collectionList.begin(); + QString collectionName = it.key(); if(QBook::getInstance()->getResolution() == QBook::RES758x1024) { - if(collectionList[0].size() >= 10) + if(collectionName.size() >= 10) addToCollectionBtn->setStyleSheet(LITTLE_FONT_SIZE_HD); else addToCollectionBtn->setStyleSheet(FONT_SIZE_HD); } else { - if(collectionList[0].size() >= 10) + if(collectionName.size() >= 10) addToCollectionBtn->setStyleSheet(LITTLE_FONT_SIZE_SD); else addToCollectionBtn->setStyleSheet(FONT_SIZE_SD); } - addToCollectionBtn->setText(bqUtils::truncateStringToLength(tr("%1").arg(collectionList[0]), COLLECTION_MAX_LENGTH)); + addToCollectionBtn->setText(bqUtils::truncateStringToLength(tr("%1").arg(collectionName), COLLECTION_MAX_LENGTH)); } else @@ -636,12 +638,12 @@ void ViewerBookSummary::setCollectionLayerBtnText(QStringList collectionList) } } -void ViewerBookSummary::addBookToCollection(QString collectionName) +void ViewerBookSummary::addBookToCollection(QString collectionName, double index) { qDebug() << Q_FUNC_INFO; BookInfo* book = new BookInfo(*m_book); - book->addCollection(collectionName); - QStringList bookCollectionList = book->getCollectionsList(); + book->addCollection(collectionName, index); + QHash bookCollectionList = book->getCollectionsList(); setCollectionLayerBtnText(bookCollectionList); QBookApp::instance()->getModel()->updateBook(book); m_book = QBookApp::instance()->getModel()->getBookInfo(book->path); @@ -653,7 +655,7 @@ void ViewerBookSummary::removeBookToCollection(QString collectionName) qDebug() << Q_FUNC_INFO; BookInfo* book = new BookInfo(*m_book); book->removeCollection(collectionName); - QStringList bookCollectionList = book->getCollectionsList(); + QHash bookCollectionList = book->getCollectionsList(); setCollectionLayerBtnText(bookCollectionList); QBookApp::instance()->getModel()->updateBook(book); m_book = QBookApp::instance()->getModel()->getBookInfo(book->path); diff --git a/bqViewer/src/ViewerCollectionLayer.cpp b/bqViewer/src/ViewerCollectionLayer.cpp index ce9481f..6c8018c 100644 --- a/bqViewer/src/ViewerCollectionLayer.cpp +++ b/bqViewer/src/ViewerCollectionLayer.cpp @@ -99,7 +99,7 @@ void ViewerCollectionLayer::paint() } } -void ViewerCollectionLayer::setup(QStringList collectionList) +void ViewerCollectionLayer::setup(QHash collectionList) { qDebug() << Q_FUNC_INFO << collectionList; m_bookCollections = collectionList; @@ -150,18 +150,19 @@ void ViewerCollectionLayer::changeCollection(int idItem) Screen::getInstance()->queueUpdates(); ViewerCollectionItem* item = items[idItem]; QString collectionName = item->getText(); - - if(m_bookCollections.contains(collectionName)) + QHash::iterator it = m_bookCollections.find(collectionName); + if(it != m_bookCollections.end() && it.key() == collectionName) { item->setChecked(false); - m_bookCollections.removeOne(collectionName); + it = m_bookCollections.erase(it); emit removeCollection(collectionName); } else { item->setChecked(true); - m_bookCollections.append(collectionName); - emit addCollection(collectionName); + double index = QBookApp::instance()->getModel()->getBooksInCollectionCount(collectionName) + 1; + m_bookCollections.insert(collectionName, index); + emit addCollection(collectionName, index); } paint(); Screen::getInstance()->setMode(Screen::MODE_QUICK, true, FLAG_PARTIALSCREEN_UPDATE, Q_FUNC_INFO); diff --git a/metadata-extractor/inc/EpubMetaDataExtractor.h b/metadata-extractor/inc/EpubMetaDataExtractor.h index c1dde20..8834371 100644 --- a/metadata-extractor/inc/EpubMetaDataExtractor.h +++ b/metadata-extractor/inc/EpubMetaDataExtractor.h @@ -34,6 +34,7 @@ class EpubMetaDataExtractor { static QStringList extractCSS(const QString& epubFilename); static bool isDRM(const QString& filename); static QString getCollection(const QString& epubFilename); + static double getCollectionIndex(const QString& epubFilename); diff --git a/metadata-extractor/inc/Fb2MetaDataExtractor.h b/metadata-extractor/inc/Fb2MetaDataExtractor.h index 859256d..ddc2521 100644 --- a/metadata-extractor/inc/Fb2MetaDataExtractor.h +++ b/metadata-extractor/inc/Fb2MetaDataExtractor.h @@ -32,6 +32,7 @@ class Fb2MetaDataExtractor static bool getMetaData (const QString& fb2Filename, QString& title, QString& author, QString& publisher, QDateTime& date, QString& description, bool& isDRMBook, QString& language); static bool extractCover (const QString& fb2Filename, const QString& coverPath); static QString getCollection (const QString& fb2Filename); + static double getCollectionIndex (const QString& fb2Filename); protected: static bool getAuthorMetaData (const QByteArray& data, QString& author); diff --git a/metadata-extractor/inc/MetaDataExtractor.h b/metadata-extractor/inc/MetaDataExtractor.h index ef6c4d0..747bc5e 100644 --- a/metadata-extractor/inc/MetaDataExtractor.h +++ b/metadata-extractor/inc/MetaDataExtractor.h @@ -44,6 +44,7 @@ class MetaDataExtractor { static bool extractCover (const QString& filename, QString& coverPath); static QStringList extractCSS (const QString& epubFilename); static QString getLanguage (const QString& filename); + static double getCollectionIndex (const QString& filename); }; #endif //METADATAEXTRACTOR_H diff --git a/metadata-extractor/src/EpubMetaDataExtractor.cpp b/metadata-extractor/src/EpubMetaDataExtractor.cpp index f75ac1c..2b7584d 100644 --- a/metadata-extractor/src/EpubMetaDataExtractor.cpp +++ b/metadata-extractor/src/EpubMetaDataExtractor.cpp @@ -320,5 +320,40 @@ QString EpubMetaDataExtractor::getCollection(const QString& epubFilename) QString collection = QString::fromUtf8( metadata ); if(!collection.isEmpty()) qDebug() << Q_FUNC_INFO << collection; + + epub_close(book); return collection; } + +double EpubMetaDataExtractor::getCollectionIndex(const QString& epubFilename) +{ + int size; + struct epub *book = openEpub(epubFilename); + if (book == NULL) { + qDebug() << Q_FUNC_INFO << "Cannot open: " << epubFilename; + return 0; + } + + unsigned char **meta; + meta = epub_get_metadata(book, EPUB_META, &size); + if (!meta) { + qDebug() << Q_FUNC_INFO << "Cannot get EPUB_META from " << epubFilename; + epub_close (book); + return 0; + } + + char *metadata = NULL; + + int i; + for (i = 0; i < size; i++) { + if (strncmp("calibre:series_index", (char*)meta[i], 20) == 0) { + metadata = strdup((char*)meta[i] + 22); + break; + } + } + QString indexString(metadata); + double collectionIndex = indexString.toDouble(); + qDebug() << Q_FUNC_INFO << collectionIndex; + epub_close (book); + return collectionIndex; +} diff --git a/metadata-extractor/src/Fb2MetaDataExtractor.cpp b/metadata-extractor/src/Fb2MetaDataExtractor.cpp index fa10929..b1cf27f 100644 --- a/metadata-extractor/src/Fb2MetaDataExtractor.cpp +++ b/metadata-extractor/src/Fb2MetaDataExtractor.cpp @@ -498,3 +498,44 @@ bool Fb2MetaDataExtractor::getLanguageMetaData(const QByteArray& data, QString& } return false; } + +double Fb2MetaDataExtractor::getCollectionIndex(const QString& fb2Filename) +{ + QString nodeAttr1Name = "number"; + + QFile file(fb2Filename); + if (!file.open(QIODevice::ReadOnly)) return 0; + QByteArray data = file.readAll(); + file.close(); + if (data.isEmpty()) return 0; + QXmlStreamReader streamData(data); + QString collectionIndex; + + // Searching cover name. + while (!streamData.atEnd()) + { + if (streamData.readNext() == QXmlStreamReader::StartElement && streamData.name() == "sequence") // Begin of a target node . + { + QXmlStreamAttributes nodeAttributes = streamData.attributes(); + + if (nodeAttributes.hasAttribute(nodeAttr1Name)) + { + collectionIndex = nodeAttributes.value(nodeAttr1Name).toString(); + break; + } + } + else if (streamData.isEndElement() && streamData.name() == "sequence") break; // Ensures image node withim coverpage node. + + if (!collectionIndex.isEmpty()) break; + else if (streamData.name() == "body") break; // Ensures break before the end. + }// end While + + + if (streamData.hasError()) + { + qDebug() << Q_FUNC_INFO << streamData.error(); + // TODO: do error handling + } + + return collectionIndex.toDouble(); +} diff --git a/metadata-extractor/src/MetaDataExtractor.cpp b/metadata-extractor/src/MetaDataExtractor.cpp index 188589e..33297bc 100644 --- a/metadata-extractor/src/MetaDataExtractor.cpp +++ b/metadata-extractor/src/MetaDataExtractor.cpp @@ -139,3 +139,22 @@ QString MetaDataExtractor::getLanguage(const QString &filename) return language; } + +double MetaDataExtractor::getCollectionIndex(const QString& filename) +{ + qDebug() << Q_FUNC_INFO; + + QFileInfo info = QFileInfo(filename); + + if (!info.isReadable()) { + qDebug() << Q_FUNC_INFO << "Cannot read " << filename; + return false; + } + + QString format = info.suffix().toLower(); + + if (format == "epub") + return EpubMetaDataExtractor::getCollectionIndex(filename); + else if (format == "fb2") + return Fb2MetaDataExtractor::getCollectionIndex(filename); +} diff --git a/model/inc/BookInfo.h b/model/inc/BookInfo.h index a81cf5d..9ab64ff 100644 --- a/model/inc/BookInfo.h +++ b/model/inc/BookInfo.h @@ -175,15 +175,15 @@ class BookInfo{ bool existsFile () const; void appendPercent ( const QString percent ); void clearPercentageList ( ) const; - QStringList& getCollectionsList ( ) const; - void addCollection (QString); + const QHash& getCollectionsList ( ) const; + void addCollection (QString, double ); void removeCollection (QString); static readStateEnum getReadingStateFromString ( QString ); static QString getStringFromReadingState ( readStateEnum ); private: QHash m_locations; - mutable QStringList m_collections; + QHash m_collections; mutable long readingPeriod; mutable QStringList m_cssFileList; }; diff --git a/model/src/BookInfo.cpp b/model/src/BookInfo.cpp index ca0a977..265a11f 100644 --- a/model/src/BookInfo.cpp +++ b/model/src/BookInfo.cpp @@ -913,38 +913,28 @@ void BookInfo::clearAllMetadata() resetReadingPeriod(); } -void BookInfo::addCollection(QString collection) +void BookInfo::addCollection(QString collection, double index) { - qDebug() << Q_FUNC_INFO; - bool isAddedYet = false; - for(int j = 0; j < m_collections.size(); j++) - { - if(m_collections.at(j) == collection) - { - isAddedYet = true; - break; - } - } - if(!isAddedYet) - { - m_collections.append(collection); - } + qDebug() << Q_FUNC_INFO << collection << index; + + QHash::iterator it = m_collections.find(collection); + if(it == m_collections.end()) + m_collections.insert(collection, index); + else + it.value() = index; } void BookInfo::removeCollection(QString collection) { qDebug() << Q_FUNC_INFO; - for(int j = 0; j < m_collections.size(); j++) + QHash::iterator it = m_collections.find(collection); + if(it != m_collections.end() && it.key() == collection) { - if(m_collections.at(j) == collection) - { - m_collections.removeAt(j); - break; - } + it = m_collections.erase(it); } } -QStringList& BookInfo::getCollectionsList() const +const QHash& BookInfo::getCollectionsList() const { return m_collections; } diff --git a/model/src/Model.cpp b/model/src/Model.cpp index 4a0ee4d..8b46230 100644 --- a/model/src/Model.cpp +++ b/model/src/Model.cpp @@ -325,15 +325,11 @@ void Model::getBooksInCollection( QList& books, const QString& const BookInfo* bookInfo = it.value(); if(!bookInfo->m_archived && !bookInfo->hasExpired()) { - QStringList bookCollections = bookInfo->getCollectionsList(); - for(int j=0; j < bookCollections.size(); j++) - { - if(bookCollections[j] == collection) + const QHash& bookCollections = bookInfo->getCollectionsList(); + if(bookCollections.find(collection) != bookCollections.end()) { qDebug() << Q_FUNC_INFO << "Add book to list" << bookInfo->title; books.append(bookInfo); - break; - } } } } @@ -503,13 +499,10 @@ int Model::getBooksInCollectionCount( const QString& collection ) const for(; it != itEnd; ++it) { const BookInfo* bookInfo = it.value(); - QStringList collections = bookInfo->getCollectionsList(); - for (int i= 0; i < collections.size(); i++) - { - if(collections.at(i)==collection && !bookInfo->m_archived && !bookInfo->hasExpired())// NOTE: we are extracting the books not archived) + const QHash& collections = bookInfo->getCollectionsList(); + if(collections.find(collection) != collections.end() && !bookInfo->m_archived && !bookInfo->hasExpired()) ++count; } - } return count; } diff --git a/model/src/ModelBackendOneFile.cpp b/model/src/ModelBackendOneFile.cpp index 8f90aa6..89f92a0 100644 --- a/model/src/ModelBackendOneFile.cpp +++ b/model/src/ModelBackendOneFile.cpp @@ -433,20 +433,31 @@ BookInfo* ModelBackendOneFile::loadBook (QXmlStreamReader& xml) } } else if (name == "collections") { + QString collection; while (!xml.atEnd() && !xml.hasError()) { xml.readNext(); + double index = 0; if (xml.isEndElement()) { if (xml.name() == "collections") break; } else { QStringRef name = xml.name(); if (name == "collection") { - QString collection = xml.readElementText(); - info->addCollection(collection); + collection = xml.readElementText(); + info->addCollection(collection, index); addCollection(collection); } + else if(name == "index") + { + if(!collection.isEmpty()) + { + index = xml.readElementText().toDouble(); + info->addCollection(collection, index); + addCollection(collection); + } + } } } } @@ -489,7 +500,10 @@ BookInfo* ModelBackendOneFile::loadBook (QXmlStreamReader& xml) if(info->author.isEmpty()) info->author = QString("---"); if(!collection.isEmpty()) - info->addCollection(collection); + { + double collectionIndex = MetaDataExtractor::getCollectionIndex(info->path); + info->addCollection(collection, collectionIndex); + } info->setCSSFileList(MetaDataExtractor::extractCSS(info->path)); } } @@ -575,7 +589,8 @@ BookInfo* ModelBackendOneFile::loadDefaultInfo( const QString& path ) if (!collection.isEmpty()) { addCollection(collection); - bookInfo->addCollection(collection); + double index = MetaDataExtractor::getCollectionIndex(path); + bookInfo->addCollection(collection, index); } bookInfo->setCSSFileList(MetaDataExtractor::extractCSS(path)); } else { @@ -826,12 +841,13 @@ void ModelBackendOneFile::saveBookInfo (const BookInfo* info, QXmlStreamWriter & } xml.writeEndElement(); xml.writeStartElement("collections"); - const QStringList& collections = info->getCollectionsList(); - QStringList::const_iterator it1 = collections.begin(); - QStringList::const_iterator itEnd1 = collections.constEnd(); + const QHash& collections = info->getCollectionsList(); + QHash::const_iterator it1 = collections.begin(); + QHash::const_iterator itEnd1 = collections.constEnd(); while( it1!=itEnd1 ) { - xml.writeTextElement("collection", (*it1)); + xml.writeTextElement("collection", it1.key()); + xml.writeTextElement("index", QString::number(it1.value())); ++it1; } diff --git a/version.h b/version.h index a86586b..22e9698 100644 --- a/version.h +++ b/version.h @@ -18,4 +18,4 @@ along with the source code. If not, see . *************************************************************************/ -static const char *QBOOKAPP_VERSION = "bqOS-5.2.0"; +static const char *QBOOKAPP_VERSION = "bqOS-5.2.1";