mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 17:18:23 -04:00
Refactoring: more mixed indentation and curly braces
This commit is contained in:
parent
2edfe534bd
commit
99584c3ba7
@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
enum YACReaderPageSortingMode
|
enum YACReaderPageSortingMode
|
||||||
{
|
{
|
||||||
YACReaderNumericalSorting,
|
YACReaderNumericalSorting,
|
||||||
YACReaderHeuristicSorting,
|
YACReaderHeuristicSorting,
|
||||||
YACReaderAlphabeticalSorting
|
YACReaderAlphabeticalSorting
|
||||||
};
|
};
|
||||||
|
|
||||||
void comic_pages_sort(QList<QString> & pageNames, YACReaderPageSortingMode sortingMode);
|
void comic_pages_sort(QList<QString> & pageNames, YACReaderPageSortingMode sortingMode);
|
||||||
@ -219,20 +219,23 @@ bool Comic::fileIsComic(const QString &path)
|
|||||||
|
|
||||||
QList<QString> Comic::findValidComicFiles(const QList<QUrl> &list)
|
QList<QString> Comic::findValidComicFiles(const QList<QUrl> &list)
|
||||||
{
|
{
|
||||||
QLOG_DEBUG() << "-findValidComicFiles-";
|
QLOG_DEBUG() << "-findValidComicFiles-";
|
||||||
QList<QString> validComicFiles;
|
QList<QString> validComicFiles;
|
||||||
QString currentPath;
|
QString currentPath;
|
||||||
foreach (QUrl url, list) {
|
foreach (QUrl url, list)
|
||||||
currentPath = url.toLocalFile();
|
{
|
||||||
if(Comic::fileIsComic(currentPath))
|
currentPath = url.toLocalFile();
|
||||||
validComicFiles << currentPath;
|
if(Comic::fileIsComic(currentPath))
|
||||||
else if(QFileInfo(currentPath).isDir())
|
{
|
||||||
{
|
validComicFiles << currentPath;
|
||||||
validComicFiles << findValidComicFilesInFolder(currentPath);
|
}
|
||||||
}
|
else if(QFileInfo(currentPath).isDir())
|
||||||
}
|
{
|
||||||
QLOG_DEBUG() << "-" << validComicFiles << "-";
|
validComicFiles << findValidComicFilesInFolder(currentPath);
|
||||||
return validComicFiles;
|
}
|
||||||
|
}
|
||||||
|
QLOG_DEBUG() << "-" << validComicFiles << "-";
|
||||||
|
return validComicFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> Comic::findValidComicFilesInFolder(const QString &path)
|
QList<QString> Comic::findValidComicFilesInFolder(const QString &path)
|
||||||
@ -484,9 +487,13 @@ QList<QVector<quint32> > FileComic::getSections(int & sectionIndex)
|
|||||||
foreach(quint32 si,section)
|
foreach(quint32 si,section)
|
||||||
{
|
{
|
||||||
if(si<realIdx)
|
if(si<realIdx)
|
||||||
|
{
|
||||||
section1.append(si);
|
section1.append(si);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
section2.append(si);
|
section2.append(si);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sectionIndex++;
|
sectionIndex++;
|
||||||
sections.append(section1);
|
sections.append(section1);
|
||||||
@ -744,7 +751,9 @@ bool PDFComic::load(const QString & path, const ComicDB & comic)
|
|||||||
QList<int> bookmarkIndexes;
|
QList<int> bookmarkIndexes;
|
||||||
bookmarkIndexes << comic.info.bookmark1 << comic.info.bookmark2 << comic.info.bookmark3;
|
bookmarkIndexes << comic.info.bookmark1 << comic.info.bookmark2 << comic.info.bookmark3;
|
||||||
if(bm->load(bookmarkIndexes,comic.info.currentPage-1))
|
if(bm->load(bookmarkIndexes,comic.info.currentPage-1))
|
||||||
|
{
|
||||||
emit bookmarksUpdated();
|
emit bookmarksUpdated();
|
||||||
|
}
|
||||||
_firstPage = comic.info.currentPage-1;
|
_firstPage = comic.info.currentPage-1;
|
||||||
_path = QDir::cleanPath(path);
|
_path = QDir::cleanPath(path);
|
||||||
return true;
|
return true;
|
||||||
@ -1000,17 +1009,21 @@ QString get_most_common_prefix(const QList<QString> & pageNames)
|
|||||||
|
|
||||||
void get_double_pages(const QList<QString> & pageNames, QList<QString> & singlePageNames/*out*/, QList<QString> & doublePageNames/*out*/)
|
void get_double_pages(const QList<QString> & pageNames, QList<QString> & singlePageNames/*out*/, QList<QString> & doublePageNames/*out*/)
|
||||||
{
|
{
|
||||||
uint maxExpectedDoublePagesNumberLenght = (int)(log10(pageNames.length())+1) * 2;
|
uint maxExpectedDoublePagesNumberLenght = (int)(log10(pageNames.length())+1) * 2;
|
||||||
|
|
||||||
QString mostCommonPrefix = get_most_common_prefix(pageNames);
|
QString mostCommonPrefix = get_most_common_prefix(pageNames);
|
||||||
|
|
||||||
foreach(const QString & pageName, pageNames)
|
foreach(const QString & pageName, pageNames)
|
||||||
{
|
{
|
||||||
if(is_double_page(pageName.split('/').last(), mostCommonPrefix, maxExpectedDoublePagesNumberLenght))
|
if(is_double_page(pageName.split('/').last(), mostCommonPrefix, maxExpectedDoublePagesNumberLenght))
|
||||||
doublePageNames.append(pageName);
|
{
|
||||||
else
|
doublePageNames.append(pageName);
|
||||||
singlePageNames.append(pageName);
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
singlePageNames.append(pageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> merge_pages(QList<QString> & singlePageNames, QList<QString> & doublePageNames)
|
QList<QString> merge_pages(QList<QString> & singlePageNames, QList<QString> & doublePageNames)
|
||||||
@ -1066,7 +1079,7 @@ void comic_pages_sort(QList<QString> & pageNames, YACReaderPageSortingMode sorti
|
|||||||
|
|
||||||
if(doublePageNames.length() > 0)
|
if(doublePageNames.length() > 0)
|
||||||
{
|
{
|
||||||
pageNames = merge_pages(singlePageNames, doublePageNames);
|
pageNames = merge_pages(singlePageNames, doublePageNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user