mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
fixed update process
This commit is contained in:
parent
9b3085f8d1
commit
e3ddde47b3
@ -349,7 +349,7 @@ QList<LibraryItem *> DBHelper::getFoldersFromParent(qulonglong parentId, QSqlDat
|
|||||||
i--;
|
i--;
|
||||||
nameLast = (*i)->name;
|
nameLast = (*i)->name;
|
||||||
}
|
}
|
||||||
if(lessThan>0) //si se ha encontrado un elemento menor que current, se inserta justo después
|
if(lessThan>=0) //si se ha encontrado un elemento menor que current, se inserta justo después
|
||||||
list.insert(++i,currentItem);
|
list.insert(++i,currentItem);
|
||||||
else
|
else
|
||||||
list.insert(i,currentItem);
|
list.insert(i,currentItem);
|
||||||
|
@ -223,20 +223,46 @@ void LibraryCreator::insertComic(const QString & relativePath,const QFileInfo &
|
|||||||
|
|
||||||
void LibraryCreator::update(QDir dirS)
|
void LibraryCreator::update(QDir dirS)
|
||||||
{
|
{
|
||||||
|
//QLOG_TRACE() << "Updating" << dirS.absolutePath();
|
||||||
|
//QLOG_TRACE() << "Getting info from dir" << dirS.absolutePath();
|
||||||
dirS.setNameFilters(_nameFilter);
|
dirS.setNameFilters(_nameFilter);
|
||||||
dirS.setFilter(QDir::AllDirs|QDir::Files|QDir::NoDotAndDotDot);
|
dirS.setFilter(QDir::AllDirs|QDir::NoDotAndDotDot);
|
||||||
dirS.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware|QDir::DirsFirst);
|
dirS.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
||||||
QFileInfoList listS = dirS.entryInfoList();
|
QFileInfoList listSFolders = dirS.entryInfoList();
|
||||||
|
dirS.setFilter(QDir::Files|QDir::NoDotAndDotDot);
|
||||||
|
dirS.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
||||||
|
QFileInfoList listSFiles = dirS.entryInfoList();
|
||||||
|
|
||||||
|
qSort(listSFolders.begin(),listSFolders.end(),naturalSortLessThanCIFileInfo);
|
||||||
|
qSort(listSFiles.begin(),listSFiles.end(),naturalSortLessThanCIFileInfo);
|
||||||
|
|
||||||
|
QFileInfoList listS;
|
||||||
|
listS.append(listSFolders);
|
||||||
|
listS.append(listSFiles);
|
||||||
|
//QLOG_DEBUG() << "---------------------------------------------------------";
|
||||||
|
//foreach(QFileInfo info,listS)
|
||||||
|
// QLOG_DEBUG() << info.fileName();
|
||||||
|
|
||||||
|
//QLOG_TRACE() << "END Getting info from dir" << dirS.absolutePath();
|
||||||
|
|
||||||
|
//QLOG_TRACE() << "Getting info from DB" << dirS.absolutePath();
|
||||||
QList<LibraryItem *> folders = DBHelper::getFoldersFromParent(_currentPathFolders.last().id,_database);
|
QList<LibraryItem *> folders = DBHelper::getFoldersFromParent(_currentPathFolders.last().id,_database);
|
||||||
QList<LibraryItem *> comics = DBHelper::getComicsFromParent(_currentPathFolders.last().id,_database);
|
QList<LibraryItem *> comics = DBHelper::getComicsFromParent(_currentPathFolders.last().id,_database);
|
||||||
|
//QLOG_TRACE() << "END Getting info from DB" << dirS.absolutePath();
|
||||||
|
|
||||||
QList <LibraryItem *> listD;
|
QList <LibraryItem *> listD;
|
||||||
|
qSort(folders.begin(),folders.end(),naturalSortLessThanCILibraryItem);
|
||||||
|
qSort(comics.begin(),comics.end(),naturalSortLessThanCILibraryItem);
|
||||||
listD.append(folders);
|
listD.append(folders);
|
||||||
listD.append(comics);
|
listD.append(comics);
|
||||||
|
//QLOG_DEBUG() << "---------------------------------------------------------";
|
||||||
|
//foreach(LibraryItem * info,listD)
|
||||||
|
// QLOG_DEBUG() << info->name;
|
||||||
|
//QLOG_DEBUG() << "---------------------------------------------------------";
|
||||||
int lenghtS = listS.size();
|
int lenghtS = listS.size();
|
||||||
int lenghtD = listD.size();
|
int lenghtD = listD.size();
|
||||||
|
//QLOG_DEBUG() << "S len" << lenghtS << "D len" << lenghtD;
|
||||||
|
//QLOG_DEBUG() << "---------------------------------------------------------";
|
||||||
|
|
||||||
bool updated;
|
bool updated;
|
||||||
int i,j;
|
int i,j;
|
||||||
@ -247,6 +273,7 @@ void LibraryCreator::update(QDir dirS)
|
|||||||
updated = false;
|
updated = false;
|
||||||
if(i>=lenghtS) //finished source files/dirs
|
if(i>=lenghtS) //finished source files/dirs
|
||||||
{
|
{
|
||||||
|
//QLOG_WARN() << "finished source files/dirs" << dirS.absolutePath();
|
||||||
//delete listD //from j
|
//delete listD //from j
|
||||||
for(;j<lenghtD;j++)
|
for(;j<lenghtD;j++)
|
||||||
{
|
{
|
||||||
@ -258,6 +285,7 @@ void LibraryCreator::update(QDir dirS)
|
|||||||
}
|
}
|
||||||
if(j>=lenghtD) //finished library files/dirs
|
if(j>=lenghtD) //finished library files/dirs
|
||||||
{
|
{
|
||||||
|
//QLOG_WARN() << "finished library files/dirs" << dirS.absolutePath();
|
||||||
//create listS //from i
|
//create listS //from i
|
||||||
for(;i<lenghtS;i++)
|
for(;i<lenghtS;i++)
|
||||||
{
|
{
|
||||||
@ -322,8 +350,10 @@ void LibraryCreator::update(QDir dirS)
|
|||||||
else
|
else
|
||||||
if(comparation < 0) //nameS doesn't exist on DB
|
if(comparation < 0) //nameS doesn't exist on DB
|
||||||
{
|
{
|
||||||
|
|
||||||
if(nameS!="/.yacreaderlibrary")
|
if(nameS!="/.yacreaderlibrary")
|
||||||
{
|
{
|
||||||
|
//QLOG_WARN() << "dir source < dest" << nameS << nameD;
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QStringList src = _source.split("/");
|
QStringList src = _source.split("/");
|
||||||
QString filePath = fileInfoS.absoluteFilePath();
|
QString filePath = fileInfoS.absoluteFilePath();
|
||||||
@ -346,6 +376,7 @@ void LibraryCreator::update(QDir dirS)
|
|||||||
{
|
{
|
||||||
if(nameS!="/.yacreaderlibrary")
|
if(nameS!="/.yacreaderlibrary")
|
||||||
{
|
{
|
||||||
|
//QLOG_WARN() << "dir source > dest" << nameS << nameD;
|
||||||
DBHelper::removeFromDB(fileInfoD,_database);
|
DBHelper::removeFromDB(fileInfoD,_database);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@ -357,6 +388,7 @@ void LibraryCreator::update(QDir dirS)
|
|||||||
{
|
{
|
||||||
if(nameS!="/.yacreaderlibrary") //skip .yacreaderlibrary folder
|
if(nameS!="/.yacreaderlibrary") //skip .yacreaderlibrary folder
|
||||||
{
|
{
|
||||||
|
//QLOG_WARN() << "one of them(or both) is a file" << nameS << nameD;
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QStringList src = _source.split("/");
|
QStringList src = _source.split("/");
|
||||||
QString filePath = fileInfoS.absoluteFilePath();
|
QString filePath = fileInfoS.absoluteFilePath();
|
||||||
|
@ -255,3 +255,8 @@ bool naturalSortLessThanCIFileInfo(const QFileInfo & left,const QFileInfo & righ
|
|||||||
{
|
{
|
||||||
return naturalSortLessThanCI(left.fileName(),right.fileName());
|
return naturalSortLessThanCI(left.fileName(),right.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool naturalSortLessThanCILibraryItem(LibraryItem * left, LibraryItem * right)
|
||||||
|
{
|
||||||
|
return naturalSortLessThanCI(left->name,right->name);
|
||||||
|
}
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include "library_item.h"
|
||||||
|
|
||||||
bool naturalSortLessThanCS( const QString &left, const QString &right );
|
bool naturalSortLessThanCS( const QString &left, const QString &right );
|
||||||
bool naturalSortLessThanCI( const QString &left, const QString &right );
|
bool naturalSortLessThanCI( const QString &left, const QString &right );
|
||||||
bool naturalSortLessThanCIFileInfo(const QFileInfo & left,const QFileInfo & right);
|
bool naturalSortLessThanCIFileInfo(const QFileInfo & left,const QFileInfo & right);
|
||||||
|
bool naturalSortLessThanCILibraryItem(LibraryItem * left, LibraryItem * right);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user