Skip to content

Commit

Permalink
Version 5.2.1:Highlight improvements, ebooks massive loading improvem…
Browse files Browse the repository at this point in the history
…ents and fixes, collection ordering by index
  • Loading branch information
Pablo committed May 28, 2014
1 parent 814ed83 commit 257351f
Show file tree
Hide file tree
Showing 39 changed files with 1,085 additions and 726 deletions.
2 changes: 2 additions & 0 deletions QBookApp/src/QBookApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4517,6 +4517,8 @@ void QBookApp::checkBooksChanged()
QFile::remove(book->thumbnail);
getModel()->loadDefaultInfo(book->path);
}
book = NULL;
delete book;

This comment has been minimized.

Copy link
@Jesus89

Jesus89 Apr 16, 2015

Memory leak?

}
}

6 changes: 5 additions & 1 deletion bqBrowser/src/Browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions bqLibrary/inc/Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -272,6 +273,7 @@ protected slots:
void sortListClicked ();

void sortBooksByAuthorClicked ();
void sortBooksByIndexClicked ();
void sortBooksByTitleClicked ();
void sortBooksByDateClicked ();

Expand Down Expand Up @@ -383,6 +385,7 @@ protected slots:
sortDataCallback sortFilesDataCallback;
void applySortMethod ();
void sortBooksByAuthor ();
void sortBooksByIndex ();
void sortBooksByTitle ();
void sortBooksByDate ();
void sortFilesByName ();
Expand Down
4 changes: 2 additions & 2 deletions bqLibrary/inc/LibraryBookSummary.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QString, double> collectionList);
int getCurrentBookOffset ( ) { return m_currentBook; }

signals:
Expand Down Expand Up @@ -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 ();
Expand Down
6 changes: 3 additions & 3 deletions bqLibrary/inc/LibraryCollectionLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LibraryCollectionLayer : public GestureWidget, protected Ui::LibraryCollec
public:
LibraryCollectionLayer ( QWidget* parent );
virtual ~LibraryCollectionLayer ();
void setup ( QStringList collectionList );
void setup ( QHash<QString, double> collectionList );
void paint ();

protected slots:
Expand All @@ -42,15 +42,15 @@ protected slots:
void changeCollection (int idItem);

signals:
void addCollection (QString collectionName);
void addCollection (QString collectionName, double index);
void removeCollection (QString collectionName);
void createCollection ();

protected:

/* http://qt-project.org/forums/viewthread/7340 */
virtual void paintEvent ( QPaintEvent* );
QStringList m_bookCollections;
QHash<QString, double> m_bookCollections;
QStringList m_modelCollections;
QList<LibraryCollectionItem*> items;
int m_page;
Expand Down
9 changes: 5 additions & 4 deletions bqLibrary/inc/LibrarySortBooksByLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions bqLibrary/res/1024/library_styles.qss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions bqLibrary/res/800/library_styles.qss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions bqLibrary/res/800/library_styles_new.qss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion bqLibrary/res/library_styles_generic.qss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions bqLibrary/res/library_styles_generic_new.qss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
80 changes: 76 additions & 4 deletions bqLibrary/src/Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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());
Expand Down Expand Up @@ -1759,7 +1790,6 @@ void Library::sortBooksByDateClicked()

Screen::getInstance()->queueUpdates();


clearKeyboard();

m_sortBooksByLayer->hide();
Expand Down Expand Up @@ -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<QString, double> collections1 = b1->getCollectionsList();
QHash<QString, double> collections2 = b2->getCollectionsList();
QHash<QString, double>::iterator it1 = collections1.find(collectionName);
QHash<QString, double>::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();
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -3805,7 +3870,7 @@ void Library::setBooksSortModeCallback()
break;
}
}
else
else if(m_filterMode != ELFM_COLLECTION)
{
switch(m_booksSortMode)
{
Expand All @@ -3822,6 +3887,8 @@ void Library::setBooksSortModeCallback()
break;
}
}
else
sortBooksDataCallback = &Library::sortBooksByIndex;

sortCurrentDataCallback = sortBooksDataCallback;
}
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 257351f

Please sign in to comment.