clang-format

This commit is contained in:
Luis Ángel San Martín
2021-10-18 21:56:52 +02:00
parent 78e0c522d2
commit 5aa02a19bb
190 changed files with 2286 additions and 2286 deletions

View File

@ -15,8 +15,8 @@ public:
QVariant data(int column) const;
void setData(int column, const QVariant &value);
int row() const;
//unsigned long long int id; //TODO sustituir por una clase adecuada
//Comic comic;
// unsigned long long int id; //TODO sustituir por una clase adecuada
// Comic comic;
private:
QList<QVariant> itemData;
};

View File

@ -12,7 +12,7 @@
#include "query_parser.h"
#include "reading_list_model.h"
//ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read
// ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read
#include "QsLog.h"
ComicModel::ComicModel(QObject *parent)
@ -51,7 +51,7 @@ bool ComicModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, i
return data->formats().contains(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat);
}
//TODO: optimize this method (seriously)
// TODO: optimize this method (seriously)
bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
@ -78,7 +78,7 @@ bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
std::sort(currentIndexes.begin(), currentIndexes.end());
QList<ComicItem *> resortedData;
if (currentIndexes.contains(row)) //no resorting
if (currentIndexes.contains(row)) // no resorting
return false;
ComicItem *destinationItem;
@ -147,7 +147,7 @@ bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
}
}
//TODO fix selection
// TODO fix selection
QList<qulonglong> allComicIds;
foreach (ComicItem *item, _data) {
allComicIds << item->data(Id).toULongLong();
@ -172,7 +172,7 @@ bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
}
QSqlDatabase::removeDatabase(connectionName);
//endMoveRows();
// endMoveRows();
emit resortedIndexes(newSorting);
int destSelectedIndex = row < 0 ? _data.length() : row;
@ -192,8 +192,8 @@ bool ComicModel::canBeResorted()
QMimeData *ComicModel::mimeData(const QModelIndexList &indexes) const
{
//custom model data
//application/yacreader-comics-ids + list of ids in a QByteArray
// custom model data
// application/yacreader-comics-ids + list of ids in a QByteArray
QList<qulonglong> ids;
foreach (QModelIndex index, indexes) {
QLOG_DEBUG() << "dragging : " << index.data(IdRole).toULongLong();
@ -202,7 +202,7 @@ QMimeData *ComicModel::mimeData(const QModelIndexList &indexes) const
QByteArray data;
QDataStream out(&data, QIODevice::WriteOnly);
out << ids; //serialize the list of identifiers
out << ids; // serialize the list of identifiers
auto mimeData = new QMimeData();
mimeData->setData(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat, data);
@ -246,17 +246,17 @@ QVariant ComicModel::data(const QModelIndex &index, int role) const
return QVariant();
/*if (index.column() == TableModel::Rating && role == Qt::DecorationRole)
{
TableItem *item = static_cast<TableItem*>(index.internalPointer());
return QPixmap(QString(":/images/rating%1.png").arg(item->data(index.column()).toInt()));
}*/
{
TableItem *item = static_cast<TableItem*>(index.internalPointer());
return QPixmap(QString(":/images/rating%1.png").arg(item->data(index.column()).toInt()));
}*/
if (role == Qt::DecorationRole) {
return QVariant();
}
if (role == Qt::TextAlignmentRole) {
switch (index.column()) //TODO obtener esto de la query
switch (index.column()) // TODO obtener esto de la query
{
case ComicModel::Number:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
@ -271,8 +271,8 @@ QVariant ComicModel::data(const QModelIndex &index, int role) const
}
}
//TODO check here if any view is asking for TableModel::Roles
//these roles will be used from QML/GridView
// TODO check here if any view is asking for TableModel::Roles
// these roles will be used from QML/GridView
auto item = static_cast<ComicItem *>(index.internalPointer());
@ -326,7 +326,7 @@ QVariant ComicModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) //TODO obtener esto de la query
switch (section) // TODO obtener esto de la query
{
case ComicModel::Number:
return QVariant(QString("#"));
@ -348,7 +348,7 @@ QVariant ComicModel::headerData(int section, Qt::Orientation orientation,
}
if (orientation == Qt::Horizontal && role == Qt::TextAlignmentRole) {
switch (section) //TODO obtener esto de la query
switch (section) // TODO obtener esto de la query
{
case ComicModel::Number:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
@ -514,7 +514,7 @@ void ComicModel::setupReadingListModelData(unsigned long long parentReadingList,
while (subfolders.next())
ids << subfolders.record().value(0).toULongLong();
enableResorting = ids.length() == 1; //only resorting if no sublists exist
enableResorting = ids.length() == 1; // only resorting if no sublists exist
foreach (qulonglong id, ids) {
QSqlQuery selectQuery(db);
@ -526,7 +526,7 @@ void ComicModel::setupReadingListModelData(unsigned long long parentReadingList,
selectQuery.bindValue(":parentReadingList", id);
selectQuery.exec();
//TODO, extra information is needed (resorting)
// TODO, extra information is needed (resorting)
QList<ComicItem *> tempData = _data;
_data.clear();
@ -649,7 +649,7 @@ void ComicModel::setupModelData(QSqlQuery &sqlquery)
});
}
//comics are sorted by "ordering", the sorting is done in the sql query
// comics are sorted by "ordering", the sorting is done in the sql query
void ComicModel::setupModelDataForList(QSqlQuery &sqlquery)
{
int numColumns = sqlquery.record().count();
@ -707,7 +707,7 @@ QVector<YACReaderComicReadStatus> ComicModel::getReadList()
}
return readList;
}
//TODO untested, this method is no longer used
// TODO untested, this method is no longer used
QVector<YACReaderComicReadStatus> ComicModel::setAllComicsRead(YACReaderComicReadStatus read)
{
return setComicsRead(persistentIndexList(), read);
@ -742,7 +742,7 @@ QList<ComicDB> ComicModel::getComics(QList<QModelIndex> list)
}
return comics;
}
//TODO
// TODO
QVector<YACReaderComicReadStatus> ComicModel::setComicsRead(QList<QModelIndex> list, YACReaderComicReadStatus read)
{
QString connectionName = "";
@ -832,7 +832,7 @@ QModelIndex ComicModel::getIndexFromId(quint64 id)
return index(i, 0);
}
//TODO completely inefficiently
// TODO completely inefficiently
QList<QModelIndex> ComicModel::getIndexesFromIds(const QList<qulonglong> &comicIds)
{
QList<QModelIndex> comicsIndexes;
@ -1083,7 +1083,7 @@ void ComicModel::updateRating(int rating, QModelIndex mi)
QString connectionName = "";
{
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
//TODO optimize update
// TODO optimize update
comic.info.rating = rating;
_data[mi.row()]->setData(ComicModel::Rating, rating);

View File

@ -89,25 +89,25 @@ public:
void setupFavoritesModelData(const QString &databasePath);
void setupReadingModelData(const QString &databasePath);
//Métodos de conveniencia
// Métodos de conveniencia
QStringList getPaths(const QString &_source);
QString getComicPath(QModelIndex mi);
QString getCurrentPath() { return QString(_databasePath).remove("/.yacreaderlibrary"); }
ComicDB getComic(const QModelIndex &mi); //--> para la edición
//ComicDB getComic(int row);
// ComicDB getComic(int row);
QVector<YACReaderComicReadStatus> getReadList();
QVector<YACReaderComicReadStatus> setAllComicsRead(YACReaderComicReadStatus readStatus);
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la información común a los comics seleccionados
QList<ComicDB> getAllComics();
QModelIndex getIndexFromId(quint64 id);
QList<QModelIndex> getIndexesFromIds(const QList<qulonglong> &comicIds);
//setcomicInfo(QModelIndex & mi); --> inserta en la base datos
//setComicInfoForAllComics(); --> inserta la información común a todos los cómics de una sola vez.
//setComicInfoForSelectedComis(QList<QModelIndex> list); -->inserta la información común para los comics seleccionados
// setcomicInfo(QModelIndex & mi); --> inserta en la base datos
// setComicInfoForAllComics(); --> inserta la información común a todos los cómics de una sola vez.
// setComicInfoForSelectedComis(QList<QModelIndex> list); -->inserta la información común para los comics seleccionados
QVector<YACReaderComicReadStatus> setComicsRead(QList<QModelIndex> list, YACReaderComicReadStatus read);
void setComicsManga(QList<QModelIndex> list, bool isManga);
qint64 asignNumbers(QList<QModelIndex> list, int startingNumber);
//void remove(ComicDB * comic, int row);
// void remove(ComicDB * comic, int row);
void removeInTransaction(int row);
void reload(const ComicDB &comic);
void resetComicRating(const QModelIndex &mi);

View File

@ -62,7 +62,7 @@ void YACReader::ComicQueryResultProcessor::createModelData(const YACReader::Sear
break;
}
selectQuery.prepare(queryString.c_str());
selectQuery.bindValue(":limit", 500); //TODO, load this value from settings
selectQuery.bindValue(":limit", 500); // TODO, load this value from settings
result.bindValues(selectQuery);
selectQuery.exec();
@ -71,8 +71,8 @@ void YACReader::ComicQueryResultProcessor::createModelData(const YACReader::Sear
emit newData(data, databasePath);
} catch (const std::exception &e) {
//Do nothing, uncomplete search string will end here and it is part of how the QueryParser works
//I don't like the idea of using exceptions for this though
// Do nothing, uncomplete search string will end here and it is part of how the QueryParser works
// I don't like the idea of using exceptions for this though
}
connectionName = db.connectionName();

View File

@ -53,12 +53,12 @@ DataBaseManagement::DataBaseManagement()
/*TreeModel * DataBaseManagement::newTreeModel(QString path)
{
//la consulta se ejecuta...
QSqlQuery selectQuery(loadDatabase(path));
selectQuery.setForwardOnly(true);
selectQuery.exec("select * from folder order by parentId,name");
//selectQuery.finish();
return new TreeModel(selectQuery);
//la consulta se ejecuta...
QSqlQuery selectQuery(loadDatabase(path));
selectQuery.setForwardOnly(true);
selectQuery.exec("select * from folder order by parentId,name");
//selectQuery.finish();
return new TreeModel(selectQuery);
}*/
QSqlDatabase DataBaseManagement::createDatabase(QString name, QString path)
@ -79,22 +79,22 @@ QSqlDatabase DataBaseManagement::createDatabase(QString dest)
{
QSqlQuery pragma("PRAGMA foreign_keys = ON", db);
//pragma.finish();
// pragma.finish();
DataBaseManagement::createTables(db);
QSqlQuery query("INSERT INTO folder (parentId, name, path) "
"VALUES (1,'root', '/')",
db);
}
//query.finish();
//db.close();
// query.finish();
// db.close();
return db;
}
QSqlDatabase DataBaseManagement::loadDatabase(QString path)
{
//TODO check path
// TODO check path
QString threadId = QString::number((long long)QThread::currentThreadId(), 16);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", path + threadId);
db.setDatabaseName(path + "/library.ydb");
@ -108,12 +108,12 @@ QSqlDatabase DataBaseManagement::loadDatabase(QString path)
QSqlDatabase DataBaseManagement::loadDatabaseFromFile(QString filePath)
{
//TODO check path
// TODO check path
QString threadId = QString::number((long long)QThread::currentThreadId(), 16);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", filePath + threadId);
db.setDatabaseName(filePath);
if (!db.open()) {
//se devuelve una base de datos vacía e inválida
// se devuelve una base de datos vacía e inválida
return QSqlDatabase();
}
@ -127,7 +127,7 @@ bool DataBaseManagement::createTables(QSqlDatabase &database)
bool success = true;
{
//COMIC INFO (representa la información de un cómic, cada cómic tendrá un idéntificador único formado por un hash sha1'de los primeros 512kb' + su tamaño en bytes)
// COMIC INFO (representa la información de un cómic, cada cómic tendrá un idéntificador único formado por un hash sha1'de los primeros 512kb' + su tamaño en bytes)
QSqlQuery queryComicInfo(database);
queryComicInfo.prepare("CREATE TABLE comic_info ("
"id INTEGER PRIMARY KEY,"
@ -154,11 +154,11 @@ bool DataBaseManagement::createTables(QSqlDatabase &database)
"letterer TEXT,"
"coverArtist TEXT,"
"date TEXT," //dd/mm/yyyy --> se mostrará en 3 campos diferentes
"date TEXT," // dd/mm/yyyy --> se mostrará en 3 campos diferentes
"publisher TEXT,"
"format TEXT,"
"color BOOLEAN,"
"ageRating BOOLEAN," //this is actually a string (TEXT), funny thing is that the current implementation works
"ageRating BOOLEAN," // this is actually a string (TEXT), funny thing is that the current implementation works
"synopsis TEXT,"
"characters TEXT,"
@ -167,7 +167,7 @@ bool DataBaseManagement::createTables(QSqlDatabase &database)
"hash TEXT UNIQUE NOT NULL,"
"edited BOOLEAN DEFAULT 0,"
"read BOOLEAN DEFAULT 0,"
//new 7.0 fields
// new 7.0 fields
"hasBeenOpened BOOLEAN DEFAULT 0,"
"rating INTEGER DEFAULT 0,"
@ -178,55 +178,55 @@ bool DataBaseManagement::createTables(QSqlDatabase &database)
"brightness INTEGER DEFAULT -1, "
"contrast INTEGER DEFAULT -1, "
"gamma INTEGER DEFAULT -1, "
//new 7.1 fields
// new 7.1 fields
"comicVineID TEXT,"
//new 9.5 fields
// new 9.5 fields
"lastTimeOpened INTEGER,"
"coverSizeRatio REAL,"
"originalCoverSize STRING," //h/w
//new 9.8 fields
"originalCoverSize STRING," // h/w
// new 9.8 fields
"manga BOOLEAN DEFAULT 0"
")");
success = success && queryComicInfo.exec();
//queryComicInfo.finish();
// queryComicInfo.finish();
//FOLDER (representa una carpeta en disco)
// FOLDER (representa una carpeta en disco)
QSqlQuery queryFolder(database);
queryFolder.prepare("CREATE TABLE folder ("
"id INTEGER PRIMARY KEY,"
"parentId INTEGER NOT NULL,"
"name TEXT NOT NULL,"
"path TEXT NOT NULL,"
//new 7.1 fields
"finished BOOLEAN DEFAULT 0," //reading
"completed BOOLEAN DEFAULT 1," //collecting
//new 9.5 fields
// new 7.1 fields
"finished BOOLEAN DEFAULT 0," // reading
"completed BOOLEAN DEFAULT 1," // collecting
// new 9.5 fields
"numChildren INTEGER,"
"firstChildHash TEXT,"
"customImage TEXT,"
//new 9.8 fields
// new 9.8 fields
"manga BOOLEAN DEFAULT 0,"
"FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE)");
success = success && queryFolder.exec();
//COMIC (representa un cómic en disco, contiene el nombre de fichero)
// COMIC (representa un cómic en disco, contiene el nombre de fichero)
QSqlQuery queryComic(database);
queryComic.prepare("CREATE TABLE comic (id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, comicInfoId INTEGER NOT NULL, fileName TEXT NOT NULL, path TEXT, FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE, FOREIGN KEY(comicInfoId) REFERENCES comic_info(id))");
success = success && queryComic.exec();
//queryComic.finish();
//DB INFO
// queryComic.finish();
// DB INFO
QSqlQuery queryDBInfo(database);
queryDBInfo.prepare("CREATE TABLE db_info (version TEXT NOT NULL)");
success = success && queryDBInfo.exec();
//queryDBInfo.finish();
// queryDBInfo.finish();
QSqlQuery query("INSERT INTO db_info (version) "
"VALUES ('" VERSION "')",
database);
//query.finish();
// query.finish();
//8.0> tables
// 8.0> tables
success = success && DataBaseManagement::createV8Tables(database);
}
@ -237,23 +237,23 @@ bool DataBaseManagement::createV8Tables(QSqlDatabase &database)
{
bool success = true;
{
//8.0> tables
//LABEL
// 8.0> tables
// LABEL
QSqlQuery queryLabel(database);
success = success && queryLabel.exec("CREATE TABLE label (id INTEGER PRIMARY KEY, "
"name TEXT NOT NULL, "
"color TEXT NOT NULL, "
"ordering INTEGER NOT NULL); "); //order depends on the color
"ordering INTEGER NOT NULL); "); // order depends on the color
QSqlQuery queryIndexLabel(database);
success = success && queryIndexLabel.exec("CREATE INDEX label_ordering_index ON label (ordering)");
//COMIC LABEL
// COMIC LABEL
QSqlQuery queryComicLabel(database);
success = success && queryComicLabel.exec("CREATE TABLE comic_label ("
"comic_id INTEGER, "
"label_id INTEGER, "
"ordering INTEGER, " //TODO order????
"ordering INTEGER, " // TODO order????
"FOREIGN KEY(label_id) REFERENCES label(id) ON DELETE CASCADE, "
"FOREIGN KEY(comic_id) REFERENCES comic(id) ON DELETE CASCADE, "
"PRIMARY KEY(label_id, comic_id))");
@ -261,12 +261,12 @@ bool DataBaseManagement::createV8Tables(QSqlDatabase &database)
QSqlQuery queryIndexComicLabel(database);
success = success && queryIndexComicLabel.exec("CREATE INDEX comic_label_ordering_index ON label (ordering)");
//READING LIST
// READING LIST
QSqlQuery queryReadingList(database);
success = success && queryReadingList.exec("CREATE TABLE reading_list ("
"id INTEGER PRIMARY KEY, "
"parentId INTEGER, "
"ordering INTEGER DEFAULT 0, " //only use it if the parentId is NULL
"ordering INTEGER DEFAULT 0, " // only use it if the parentId is NULL
"name TEXT NOT NULL, "
"finished BOOLEAN DEFAULT 0, "
"completed BOOLEAN DEFAULT 1, "
@ -276,7 +276,7 @@ bool DataBaseManagement::createV8Tables(QSqlDatabase &database)
QSqlQuery queryIndexReadingList(database);
success = success && queryIndexReadingList.exec("CREATE INDEX reading_list_ordering_index ON label (ordering)");
//COMIC READING LIST
// COMIC READING LIST
QSqlQuery queryComicReadingList(database);
success = success && queryComicReadingList.exec("CREATE TABLE comic_reading_list ("
"reading_list_id INTEGER, "
@ -289,20 +289,20 @@ bool DataBaseManagement::createV8Tables(QSqlDatabase &database)
QSqlQuery queryIndexComicReadingList(database);
success = success && queryIndexComicReadingList.exec("CREATE INDEX comic_reading_list_ordering_index ON label (ordering)");
//DEFAULT READING LISTS
// DEFAULT READING LISTS
QSqlQuery queryDefaultReadingList(database);
success = success && queryDefaultReadingList.exec("CREATE TABLE default_reading_list ("
"id INTEGER PRIMARY KEY, "
"name TEXT NOT NULL"
//TODO icon????
// TODO icon????
")");
//COMIC DEFAULT READING LISTS
// COMIC DEFAULT READING LISTS
QSqlQuery queryComicDefaultReadingList(database);
success = success && queryComicDefaultReadingList.exec("CREATE TABLE comic_default_reading_list ("
"comic_id INTEGER, "
"default_reading_list_id INTEGER, "
"ordering INTEGER, " //order????
"ordering INTEGER, " // order????
"FOREIGN KEY(default_reading_list_id) REFERENCES default_reading_list(id) ON DELETE CASCADE, "
"FOREIGN KEY(comic_id) REFERENCES comic(id) ON DELETE CASCADE,"
"PRIMARY KEY(default_reading_list_id, comic_id))");
@ -310,15 +310,15 @@ bool DataBaseManagement::createV8Tables(QSqlDatabase &database)
QSqlQuery queryIndexComicDefaultReadingList(database);
success = success && queryIndexComicDefaultReadingList.exec("CREATE INDEX comic_default_reading_list_ordering_index ON label (ordering)");
//INSERT DEFAULT READING LISTS
// INSERT DEFAULT READING LISTS
QSqlQuery queryInsertDefaultReadingList(database);
//if(!queryInsertDefaultReadingList.prepare())
// if(!queryInsertDefaultReadingList.prepare())
//1 Favorites
//queryInsertDefaultReadingList.bindValue(":name", "Favorites");
// 1 Favorites
// queryInsertDefaultReadingList.bindValue(":name", "Favorites");
success = success && queryInsertDefaultReadingList.exec("INSERT INTO default_reading_list (name) VALUES (\"Favorites\")");
//Reading doesn't need its onw list
// Reading doesn't need its onw list
}
return success;
}
@ -377,7 +377,7 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
newInfo.exec();
destDB.transaction();
int cp;
while (newInfo.next()) //cada tupla deberá ser insertada o actualizada
while (newInfo.next()) // cada tupla deberá ser insertada o actualizada
{
QSqlQuery update(destDB);
update.prepare("UPDATE comic_info SET "
@ -558,7 +558,7 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
return b;
}
//TODO fix these bindings
// TODO fix these bindings
void DataBaseManagement::bindValuesFromRecord(const QSqlRecord &record, QSqlQuery &query)
{
bindString("title", record, query);
@ -613,13 +613,13 @@ bool DataBaseManagement::addColumns(const QString &tableName, const QStringList
foreach (QString columnDef, columnDefs) {
QSqlQuery alterTable(db);
alterTable.prepare(sql.arg(tableName).arg(columnDef));
//alterTableComicInfo.bindValue(":column_def",columnDef);
// alterTableComicInfo.bindValue(":column_def",columnDef);
bool exec = alterTable.exec();
returnValue = returnValue && exec;
if (!exec) {
QLOG_ERROR() << alterTable.lastError().text();
}
//returnValue = returnValue && (alterTable.numRowsAffected() > 0);
// returnValue = returnValue && (alterTable.numRowsAffected() > 0);
}
return returnValue;
@ -747,9 +747,9 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &path)
if (updateVersion.numRowsAffected() > 0)
returnValue = true;
if (pre7) //TODO: execute only if previous version was < 7.0
if (pre7) // TODO: execute only if previous version was < 7.0
{
//new 7.0 fields
// new 7.0 fields
QStringList columnDefs;
columnDefs << "hasBeenOpened BOOLEAN DEFAULT 0"
<< "rating INTEGER DEFAULT 0"
@ -764,7 +764,7 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &path)
bool successAddingColumns = addColumns("comic_info", columnDefs, db);
returnValue = returnValue && successAddingColumns;
}
//TODO update hasBeenOpened value
// TODO update hasBeenOpened value
if (pre7_1) {
{
@ -775,7 +775,7 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &path)
returnValue = returnValue && successAddingColumns;
}
{ //comic_info
{ // comic_info
QStringList columnDefs;
columnDefs << "comicVineID TEXT DEFAULT NULL";
bool successAddingColumns = addColumns("comic_info", columnDefs, db);
@ -789,9 +789,9 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &path)
}
if (pre9_5) {
{ //folder
{ // folder
QStringList columnDefs;
//a full library update is needed after updating the table
// a full library update is needed after updating the table
columnDefs << "numChildren INTEGER";
columnDefs << "firstChildHash TEXT";
columnDefs << "customImage TEXT";
@ -799,7 +799,7 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &path)
returnValue = returnValue && successAddingColumns;
}
{ //comic_info
{ // comic_info
QStringList columnDefs;
columnDefs << "lastTimeOpened INTEGER";
columnDefs << "coverSizeRatio REAL";
@ -812,7 +812,7 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &path)
returnValue = returnValue && successCreatingIndex;
}
//update folders info
// update folders info
{
DBHelper::updateChildrenInfo(db);
}
@ -843,13 +843,13 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &path)
}
if (pre9_8) {
{ //comic_info
{ // comic_info
QStringList columnDefs;
columnDefs << "manga BOOLEAN DEFAULT 0";
bool successAddingColumns = addColumns("comic_info", columnDefs, db);
returnValue = returnValue && successAddingColumns;
}
{ //folder
{ // folder
QStringList columnDefs;
columnDefs << "manga BOOLEAN DEFAULT 0";
bool successAddingColumns = addColumns("folder", columnDefs, db);
@ -864,7 +864,7 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &path)
return returnValue;
}
//COMICS_INFO_EXPORTER
// COMICS_INFO_EXPORTER
ComicsInfoExporter::ComicsInfoExporter()
: QThread()
{
@ -874,14 +874,14 @@ void ComicsInfoExporter::exportComicsInfo(QSqlDatabase &source, QSqlDatabase &de
{
Q_UNUSED(source)
Q_UNUSED(dest)
//TODO check this method
// TODO check this method
}
void ComicsInfoExporter::run()
{
}
//COMICS_INFO_IMPORTER
// COMICS_INFO_IMPORTER
ComicsInfoImporter::ComicsInfoImporter()
: QThread()
{
@ -891,7 +891,7 @@ void ComicsInfoImporter::importComicsInfo(QSqlDatabase &source, QSqlDatabase &de
{
Q_UNUSED(source)
Q_UNUSED(dest)
//TODO check this method
// TODO check this method
}
void ComicsInfoImporter::run()

View File

@ -44,11 +44,11 @@ private:
public:
DataBaseManagement();
//TreeModel * newTreeModel(QString path);
//crea una base de datos y todas sus tablas
// TreeModel * newTreeModel(QString path);
// crea una base de datos y todas sus tablas
static QSqlDatabase createDatabase(QString name, QString path);
static QSqlDatabase createDatabase(QString dest);
//carga una base de datos desde la ruta path
// carga una base de datos desde la ruta path
static QSqlDatabase loadDatabase(QString path);
static QSqlDatabase loadDatabaseFromFile(QString path);
static bool createTables(QSqlDatabase &database);
@ -57,8 +57,8 @@ public:
static void exportComicsInfo(QString source, QString dest);
static bool importComicsInfo(QString source, QString dest);
static QString checkValidDB(const QString &fullPath); //retorna "" si la DB es inválida ó la versión si es válida.
static int compareVersions(const QString &v1, const QString v2); //retorna <0 si v1 < v2, 0 si v1 = v2 y >0 si v1 > v2
static QString checkValidDB(const QString &fullPath); // retorna "" si la DB es inválida ó la versión si es válida.
static int compareVersions(const QString &v1, const QString v2); // retorna <0 si v1 < v2, 0 si v1 = v2 y >0 si v1 > v2
static bool updateToCurrentVersion(const QString &path);
};

View File

@ -22,7 +22,7 @@ void FolderItem::appendChild(FolderItem *item)
childItems.append(item);
else {
FolderItem *last = childItems.back();
QString nameLast = last->data(1).toString(); //TODO usar info name si est<73> disponible, sino el nombre del fichero.....
QString nameLast = last->data(1).toString(); // TODO usar info name si est<73> disponible, sino el nombre del fichero.....
QString nameCurrent = item->data(1).toString();
QList<FolderItem *>::iterator i;
i = childItems.end();
@ -31,13 +31,13 @@ void FolderItem::appendChild(FolderItem *item)
i--;
nameLast = (*i)->data(1).toString();
}
if (!naturalSortLessThanCI(nameCurrent, nameLast)) //si se ha encontrado un elemento menor que current, se inserta justo despu<70>s
if (!naturalSortLessThanCI(nameCurrent, nameLast)) // si se ha encontrado un elemento menor que current, se inserta justo despu<70>s
childItems.insert(++i, item);
else
childItems.insert(i, item);
}
//childItems.append(item);
// childItems.append(item);
}
FolderItem *FolderItem::child(int row)

View File

@ -61,14 +61,14 @@ FolderModel::FolderModel(QObject *parent)
FolderModel::FolderModel(QSqlQuery &sqlquery, QObject *parent)
: QAbstractItemModel(parent), rootItem(0)
{
//lo m<>s probable es que el nodo ra<72>z no necesite tener informaci<63>n
// lo m<>s probable es que el nodo ra<72>z no necesite tener informaci<63>n
QList<QVariant> rootData;
rootData << "root"; //id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
rootData << "root"; // id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
rootItem = new FolderItem(rootData);
rootItem->id = ROOT;
rootItem->parentItem = 0;
setupModelData(sqlquery, rootItem);
//sqlquery.finish();
// sqlquery.finish();
}
FolderModel::~FolderModel()
@ -208,20 +208,20 @@ void FolderModel::setupModelData(QString path)
{
beginResetModel();
if (rootItem != 0)
delete rootItem; //TODO comprobar que se libera bien la memoria
delete rootItem; // TODO comprobar que se libera bien la memoria
rootItem = 0;
//inicializar el nodo ra<72>z
// inicializar el nodo ra<72>z
QList<QVariant> rootData;
rootData << "root"; //id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
rootData << "root"; // id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
rootItem = new FolderItem(rootData);
rootItem->id = ROOT;
rootItem->parentItem = 0;
//cargar la base de datos
// cargar la base de datos
_databasePath = path;
//crear la consulta
// crear la consulta
QString connectionName = "";
{
QSqlDatabase db = DataBaseManagement::loadDatabase(path);
@ -230,17 +230,17 @@ void FolderModel::setupModelData(QString path)
setupModelData(selectQuery, rootItem);
connectionName = db.connectionName();
}
//selectQuery.finish();
// selectQuery.finish();
QSqlDatabase::removeDatabase(connectionName);
endResetModel();
}
void FolderModel::setupModelData(QSqlQuery &sqlquery, FolderItem *parent)
{
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
//el diccionario permitir<69> encontrar cualquier nodo del <20>rbol r<>pidamente, de forma que a<>adir un hijo a un padre sea O(1)
// 64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
// el diccionario permitir<69> encontrar cualquier nodo del <20>rbol r<>pidamente, de forma que a<>adir un hijo a un padre sea O(1)
items.clear();
//se a<>ade el nodo 0
// se a<>ade el nodo 0
items.insert(parent->id, parent);
QSqlRecord record = sqlquery.record();
@ -264,11 +264,11 @@ void FolderModel::setupModelData(QSqlQuery &sqlquery, FolderItem *parent)
auto item = new FolderItem(data);
item->id = sqlquery.value(id).toULongLong();
//la inserci<63>n de hijos se hace de forma ordenada
// la inserci<63>n de hijos se hace de forma ordenada
FolderItem *parent = items.value(sqlquery.value(parentId).toULongLong());
//if(parent !=0) //TODO if parent==0 the parent of item was removed from the DB and delete on cascade didn't work, ERROR.
// if(parent !=0) //TODO if parent==0 the parent of item was removed from the DB and delete on cascade didn't work, ERROR.
parent->appendChild(item);
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
// se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
items.insert(item->id, item);
}
}
@ -298,11 +298,11 @@ void FolderModel::updateFolderModelData(QSqlQuery &sqlquery, FolderItem *parent)
auto item = new FolderItem(data);
item->id = sqlquery.value(id).toULongLong();
//la inserci<63>n de hijos se hace de forma ordenada
// la inserci<63>n de hijos se hace de forma ordenada
FolderItem *parent = items.value(sqlquery.value(parentId).toULongLong());
if (parent != 0) //TODO if parent==0 the parent of item was removed from the DB and delete on cascade didn't work, ERROR.
if (parent != 0) // TODO if parent==0 the parent of item was removed from the DB and delete on cascade didn't work, ERROR.
parent->appendChild(item);
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
// se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
items.insert(item->id, item);
}
}
@ -314,7 +314,7 @@ QString FolderModel::getDatabase()
QString FolderModel::getFolderPath(const QModelIndex &folder)
{
if (!folder.isValid()) //root folder
if (!folder.isValid()) // root folder
return "/";
return static_cast<FolderItem *>(folder.internalPointer())->data(FolderModel::Path).toString();
}
@ -425,7 +425,7 @@ void FolderModel::fetchMoreFromDB(const QModelIndex &parent)
else
item = rootItem;
//Remove all children
// Remove all children
if (item->childCount() > 0) {
beginRemoveRows(parent, 0, item->childCount() - 1);
item->clearChildren();
@ -453,14 +453,14 @@ void FolderModel::fetchMoreFromDB(const QModelIndex &parent)
selectQuery.exec();
if (!firstLevelUpdated) {
//NO size support
// NO size support
int numResults = 0;
while (selectQuery.next())
numResults++;
if (!selectQuery.seek(-1))
selectQuery.exec();
//END no size support
// END no size support
beginInsertRows(parent, 0, numResults - 1);
}
@ -513,17 +513,17 @@ QModelIndex FolderModel::addFolderAtParent(const QString &folderName, const QMod
QList<QVariant> data;
data << newFolder.name;
data << newFolder.path;
data << false; //finished
data << true; //completed
data << false; // finished
data << true; // completed
data << newFolder.isManga();
auto item = new FolderItem(data);
item->id = newFolder.id;
beginInsertRows(parent, 0, 0); //TODO calculate the destRow before inserting the new child
beginInsertRows(parent, 0, 0); // TODO calculate the destRow before inserting the new child
parentItem->appendChild(item);
destRow = parentItem->children().indexOf(item); //TODO optimize this, appendChild should return the index of the new item
destRow = parentItem->children().indexOf(item); // TODO optimize this, appendChild should return the index of the new item
items.insert(item->id, item);
endInsertRows();
@ -566,7 +566,7 @@ void FolderModel::updateFolderChildrenInfo(qulonglong folderId)
QSqlDatabase::removeDatabase(connectionName);
}
//PROXY
// PROXY
FolderModelProxy::FolderModelProxy(QObject *parent)
: QSortFilterProxyModel(parent), rootItem(0), filterEnabled(false)
@ -600,7 +600,7 @@ void FolderModelProxy::setFilterData(QMap<unsigned long long, FolderItem *> *fil
beginResetModel();
if (rootItem != 0)
delete rootItem; //TODO comprobar que se libera bien la memoria
delete rootItem; // TODO comprobar que se libera bien la memoria
rootItem = root;

View File

@ -27,7 +27,7 @@ public:
protected:
FolderItem *rootItem;
QMap<unsigned long long int, FolderItem *> filteredItems; //relación entre folders
QMap<unsigned long long int, FolderItem *> filteredItems; // relación entre folders
bool filterEnabled;
@ -46,7 +46,7 @@ public:
explicit FolderModel(QSqlQuery &sqlquery, QObject *parent = nullptr);
~FolderModel() override;
//QAbstractItemModel methods
// QAbstractItemModel methods
QVariant data(const QModelIndex &index, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation,
@ -57,13 +57,13 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
//Convenience methods
// Convenience methods
void setupModelData(QString path);
QString getDatabase();
QString getFolderPath(const QModelIndex &folder);
//QModelIndex indexFromItem(FolderItem * item, int column);
// QModelIndex indexFromItem(FolderItem * item, int column);
//bool isFilterEnabled(){return filterEnabled;};
// bool isFilterEnabled(){return filterEnabled;};
void updateFolderCompletedStatus(const QModelIndexList &list, bool status);
void updateFolderFinishedStatus(const QModelIndexList &list, bool status);
@ -81,7 +81,7 @@ public:
Finished = 2,
Completed = 3,
Manga = 4
}; //id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, name TEXT NOT NULL, path TEXT NOT NULL
}; // id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, name TEXT NOT NULL, path TEXT NOT NULL
enum Roles {
FinishedRole = Qt::UserRole + 1,
@ -98,8 +98,8 @@ private:
void setupModelData(QSqlQuery &sqlquery, FolderItem *parent);
void updateFolderModelData(QSqlQuery &sqlquery, FolderItem *parent);
FolderItem *rootItem; //el árbol
QMap<unsigned long long int, FolderItem *> items; //relación entre folders
FolderItem *rootItem; // el árbol
QMap<unsigned long long int, FolderItem *> items; // relación entre folders
QString _databasePath;
};

View File

@ -12,7 +12,7 @@
#include <QSqlQuery>
#include <QSqlDatabase>
//Copy/pasted from "folder_model.cpp"
// Copy/pasted from "folder_model.cpp"
#define ROOT 1
YACReader::FolderQueryResultProcessor::FolderQueryResultProcessor(FolderModel *model)
@ -29,7 +29,7 @@ void YACReader::FolderQueryResultProcessor::createModelData(const YACReader::Sea
{
QSqlDatabase db = DataBaseManagement::loadDatabase(model->getDatabase());
QSqlQuery selectQuery(db); //TODO check
QSqlQuery selectQuery(db); // TODO check
if (!includeComics) {
selectQuery.prepare("select * from folder where id <> 1 and upper(name) like upper(:filter) order by parentId,name ");
selectQuery.bindValue(":filter", "%%" + filter + "%%");
@ -70,8 +70,8 @@ void YACReader::FolderQueryResultProcessor::createModelData(const YACReader::Sea
setupFilteredModelData(selectQuery);
} catch (const std::exception &e) {
//Do nothing, uncomplete search string will end here and it is part of how the QueryParser works
//I don't like the idea of using exceptions for this though
// Do nothing, uncomplete search string will end here and it is part of how the QueryParser works
// I don't like the idea of using exceptions for this though
}
}
@ -86,7 +86,7 @@ void YACReader::FolderQueryResultProcessor::setupFilteredModelData(QSqlQuery &sq
{
FolderItem *rootItem = 0;
//inicializar el nodo ra<72>z
// inicializar el nodo ra<72>z
QList<QVariant> rootData;
rootData << "root";
rootItem = new FolderItem(rootData);
@ -97,7 +97,7 @@ void YACReader::FolderQueryResultProcessor::setupFilteredModelData(QSqlQuery &sq
QMap<unsigned long long int, FolderItem *> *filteredItems = new QMap<unsigned long long int, FolderItem *>();
//add tree root node
// add tree root node
filteredItems->insert(parent->id, parent);
QSqlRecord record = sqlquery.record();
@ -108,8 +108,8 @@ void YACReader::FolderQueryResultProcessor::setupFilteredModelData(QSqlQuery &sq
int completed = record.indexOf("completed");
int parentIdIndex = record.indexOf("parentId");
while (sqlquery.next()) { //se procesan todos los folders que cumplen con el filtro
//datos de la base de datos
while (sqlquery.next()) { // se procesan todos los folders que cumplen con el filtro
// datos de la base de datos
QList<QVariant> data;
data << sqlquery.value(name).toString();
@ -120,52 +120,52 @@ void YACReader::FolderQueryResultProcessor::setupFilteredModelData(QSqlQuery &sq
auto item = new FolderItem(data);
item->id = sqlquery.value(0).toULongLong();
//id del padre
// id del padre
quint64 parentId = sqlquery.value(parentIdIndex).toULongLong();
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
// se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
if (!filteredItems->contains(item->id))
filteredItems->insert(item->id, item);
//es necesario conocer las coordenadas de origen para poder realizar scroll autom<6F>tico en la vista
// es necesario conocer las coordenadas de origen para poder realizar scroll autom<6F>tico en la vista
item->originalItem = model->items.value(item->id);
//si el padre ya existe en el modelo, el item se a<>ade como hijo
// si el padre ya existe en el modelo, el item se a<>ade como hijo
if (filteredItems->contains(parentId))
filteredItems->value(parentId)->appendChild(item);
else //si el padre a<>n no se ha a<>adido, hay que a<>adirlo a <20>l y todos los padres hasta el nodo ra<72>z
else // si el padre a<>n no se ha a<>adido, hay que a<>adirlo a <20>l y todos los padres hasta el nodo ra<72>z
{
//comprobamos con esta variable si el <20>ltimo de los padres (antes del nodo ra<72>z) ya exist<73>a en el modelo
// comprobamos con esta variable si el <20>ltimo de los padres (antes del nodo ra<72>z) ya exist<73>a en el modelo
bool parentPreviousInserted = false;
//mientras no se alcance el nodo ra<72>z se procesan todos los padres (de abajo a arriba)
// mientras no se alcance el nodo ra<72>z se procesan todos los padres (de abajo a arriba)
while (parentId != ROOT) {
//el padre no estaba en el modelo filtrado, as<61> que se rescata del modelo original
// el padre no estaba en el modelo filtrado, as<61> que se rescata del modelo original
FolderItem *parentItem = model->items.value(parentId);
//se debe crear un nuevo nodo (para no compartir los hijos con el nodo original)
FolderItem *newparentItem = new FolderItem(parentItem->getData()); //padre que se a<>adir<69> a la estructura de directorios filtrados
// se debe crear un nuevo nodo (para no compartir los hijos con el nodo original)
FolderItem *newparentItem = new FolderItem(parentItem->getData()); // padre que se a<>adir<69> a la estructura de directorios filtrados
newparentItem->id = parentId;
newparentItem->originalItem = parentItem;
//si el modelo contiene al padre, se a<>ade el item actual como hijo
// si el modelo contiene al padre, se a<>ade el item actual como hijo
if (filteredItems->contains(parentId)) {
filteredItems->value(parentId)->appendChild(item);
parentPreviousInserted = true;
}
//sino se registra el nodo para poder encontrarlo con posterioridad y se a<>ade el item actual como hijo
// sino se registra el nodo para poder encontrarlo con posterioridad y se a<>ade el item actual como hijo
else {
newparentItem->appendChild(item);
filteredItems->insert(newparentItem->id, newparentItem);
parentPreviousInserted = false;
}
//variables de control del bucle, se avanza hacia el nodo padre
// variables de control del bucle, se avanza hacia el nodo padre
item = newparentItem;
parentId = parentItem->parentItem->id;
}
//si el nodo es hijo de 1 y no hab<61>a sido previamente insertado como hijo, se a<>ade como tal
// si el nodo es hijo de 1 y no hab<61>a sido previamente insertado como hijo, se a<>ade como tal
if (!parentPreviousInserted) {
filteredItems->value(ROOT)->appendChild(item);
} else {

View File

@ -66,7 +66,7 @@ Token QueryLexer::quotedWord()
return Token(Token::Type::quotedWord, input.substr(start, index - start));
}
//This should be a lexical error, but the grammar doesn't support it
// This should be a lexical error, but the grammar doesn't support it
return Token(Token::Type::eof);
}

View File

@ -113,7 +113,7 @@ std::string QueryParser::token(bool advance)
auto lexeme = currentToken.lexeme();
auto res = (tokenType() == Token::Type::quotedWord) ? currentToken.lexeme().substr(1, lexeme.size() - 2) : lexeme; //TODO process quotedWordDiferently?
auto res = (tokenType() == Token::Type::quotedWord) ? currentToken.lexeme().substr(1, lexeme.size() - 2) : lexeme; // TODO process quotedWordDiferently?
if (advance) {
this->advance();
}

View File

@ -134,12 +134,12 @@ ReadingListItem::ReadingListItem(const QList<QVariant> &data, ReadingListItem *p
QIcon ReadingListItem::getIcon() const
{
if (parent->getId() == 0)
return YACReader::noHighlightedIcon(":/images/lists/list.png"); //top level list
return YACReader::noHighlightedIcon(":/images/lists/list.png"); // top level list
else
#ifdef Q_OS_MAC
return QFileIconProvider().icon(QFileIconProvider::Folder);
#else
return YACReader::noHighlightedIcon(":/images/sidebar/folder.png"); //sublist
return YACReader::noHighlightedIcon(":/images/sidebar/folder.png"); // sublist
#endif
}
@ -153,7 +153,7 @@ ReadingListItem *ReadingListItem::child(int row)
return childItems.at(row);
}
//items are sorted by order
// items are sorted by order
void ReadingListItem::appendChild(ReadingListItem *item)
{
item->parent = this;
@ -161,7 +161,7 @@ void ReadingListItem::appendChild(ReadingListItem *item)
if (childItems.isEmpty())
childItems.append(item);
else {
if (item->parent->getId() == 0) //sort by name, top level child
if (item->parent->getId() == 0) // sort by name, top level child
{
int i = 0;
while (i < childItems.length() && naturalSortLessThanCI(childItems.at(i)->name(), item->name()))

View File

@ -6,7 +6,7 @@
#include "yacreader_global_gui.h"
#include "reading_list_model.h"
//TODO add propper constructors, using QList<QVariant> is not safe
// TODO add propper constructors, using QList<QVariant> is not safe
class ListItem
{

View File

@ -19,9 +19,9 @@ ReadingListModel::ReadingListModel(QObject *parent)
int ReadingListModel::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid()) //TOP
if (!parent.isValid()) // TOP
{
int separatorsCount = 2; //labels.isEmpty()?1:2;
int separatorsCount = 2; // labels.isEmpty()?1:2;
return specialLists.count() + labels.count() + rootItem->childCount() + separatorsCount;
} else {
auto item = static_cast<ListItem *>(parent.internalPointer());
@ -108,7 +108,7 @@ Qt::ItemFlags ReadingListModel::flags(const QModelIndex &index) const
return {};
if (typeid(*item) == typeid(ReadingListItem) && static_cast<ReadingListItem *>(item)->parent->getId() != 0)
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled; //only sublists are dragable
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled; // only sublists are dragable
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled;
}
@ -127,7 +127,7 @@ QModelIndex ReadingListModel::index(int row, int column, const QModelIndex &pare
return QModelIndex();
if (!parent.isValid()) {
int separatorsCount = 2; //labels.isEmpty()?1:2;
int separatorsCount = 2; // labels.isEmpty()?1:2;
if (rowIsSpecialList(row, parent))
return createIndex(row, column, specialLists.at(row));
@ -145,12 +145,12 @@ QModelIndex ReadingListModel::index(int row, int column, const QModelIndex &pare
if (rowIsReadingList(row, parent))
return createIndex(row, column, rootItem->child(row - (specialLists.count() + labels.count() + separatorsCount)));
} else //sublist
} else // sublist
{
ReadingListItem *parentItem;
if (!parent.isValid())
parentItem = rootItem; //this should be impossible
parentItem = rootItem; // this should be impossible
else
parentItem = static_cast<ReadingListItem *>(parent.internalPointer());
@ -191,12 +191,12 @@ bool ReadingListModel::canDropMimeData(const QMimeData *data, Qt::DropAction act
if (row == -1)
return false;
if (!parent.isValid()) //top level items
if (!parent.isValid()) // top level items
{
if (row == -1) //no list
if (row == -1) // no list
return false;
if (row == 1) //reading is just an smart list
if (row == 1) // reading is just an smart list
return false;
if (rowIsSeparator(row, parent))
@ -214,7 +214,7 @@ bool ReadingListModel::canDropMimeData(const QMimeData *data, Qt::DropAction act
QList<QPair<int, int>> sublistsRows;
QByteArray rawData = data->data(YACReader::YACReaderLibrarSubReadingListMimeDataFormat);
QDataStream in(&rawData, QIODevice::ReadOnly);
in >> sublistsRows; //deserialize the list of indentifiers
in >> sublistsRows; // deserialize the list of indentifiers
if (parent.row() != sublistsRows.at(0).second)
return false;
return data->formats().contains(YACReader::YACReaderLibrarSubReadingListMimeDataFormat);
@ -255,7 +255,7 @@ bool ReadingListModel::dropComics(const QMimeData *data, Qt::DropAction action,
parentDest = dest.parent();
if (rowIsSpecialList(dest.row(), parentDest)) {
if (dest.row() == 0) //add to favorites
if (dest.row() == 0) // add to favorites
{
QLOG_DEBUG() << "-------addComicsToFavorites : " << comicIds << " to " << dest.data(IDRole).toULongLong();
emit addComicsToFavorites(comicIds);
@ -286,7 +286,7 @@ bool ReadingListModel::dropSublist(const QMimeData *data, Qt::DropAction action,
QList<QPair<int, int>> sublistsRows;
QByteArray rawData = data->data(YACReader::YACReaderLibrarSubReadingListMimeDataFormat);
QDataStream in(&rawData, QIODevice::ReadOnly);
in >> sublistsRows; //deserialize the list of indentifiers
in >> sublistsRows; // deserialize the list of indentifiers
QLOG_DEBUG() << "dropped : " << sublistsRows;
@ -303,7 +303,7 @@ bool ReadingListModel::dropSublist(const QMimeData *data, Qt::DropAction action,
if (sourceRow == destRow)
return false;
//beginMoveRows(destParent,sourceRow,sourceRow,destParent,destRow);
// beginMoveRows(destParent,sourceRow,sourceRow,destParent,destRow);
auto parentItem = static_cast<ReadingListItem *>(destParent.internalPointer());
ReadingListItem *child = parentItem->child(sourceRow);
@ -311,7 +311,7 @@ bool ReadingListModel::dropSublist(const QMimeData *data, Qt::DropAction action,
parentItem->appendChild(child, destRow);
reorderingChildren(parentItem->children());
//endMoveRows();
// endMoveRows();
return true;
}
@ -322,7 +322,7 @@ QMimeData *ReadingListModel::mimeData(const QModelIndexList &indexes) const
if (indexes.length() == 0) {
QLOG_ERROR() << "mimeData requested: indexes is empty";
return new QMimeData(); //TODO what happens if 0 is returned?
return new QMimeData(); // TODO what happens if 0 is returned?
}
if (indexes.length() > 1) {
@ -337,7 +337,7 @@ QMimeData *ReadingListModel::mimeData(const QModelIndexList &indexes) const
QByteArray data;
QDataStream out(&data, QIODevice::WriteOnly);
out << rows; //serialize the list of identifiers
out << rows; // serialize the list of identifiers
auto mimeData = new QMimeData();
mimeData->setData(YACReader::YACReaderLibrarSubReadingListMimeDataFormat, data);
@ -354,17 +354,17 @@ void ReadingListModel::setupReadingListsData(QString path)
_databasePath = path;
QSqlDatabase db = DataBaseManagement::loadDatabase(path);
//setup special lists
// setup special lists
specialLists = setupSpecialLists(db);
//separator--------------------------------------------
// separator--------------------------------------------
//setup labels
// setup labels
setupLabels(db);
//separator--------------------------------------------
// separator--------------------------------------------
//setup reading list
// setup reading list
setupReadingLists(db);
endResetModel();
@ -391,7 +391,7 @@ void ReadingListModel::addReadingList(const QString &name)
QString connectionName = "";
{
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
beginInsertRows(QModelIndex(), 0, 0); //TODO calculate the right coordinates before inserting
beginInsertRows(QModelIndex(), 0, 0); // TODO calculate the right coordinates before inserting
qulonglong id = DBHelper::insertReadingList(name, db);
ReadingListItem *newItem;
@ -416,7 +416,7 @@ void ReadingListModel::addReadingListAt(const QString &name, const QModelIndex &
{
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
beginInsertRows(mi, 0, 0); //TODO calculate the right coordinates before inserting
beginInsertRows(mi, 0, 0); // TODO calculate the right coordinates before inserting
auto readingListParent = static_cast<ReadingListItem *>(mi.internalPointer());
qulonglong id = DBHelper::insertReadingSubList(name, mi.data(IDRole).toULongLong(), readingListParent->childCount(), db);
@ -488,8 +488,8 @@ void ReadingListModel::rename(const QModelIndex &mi, const QString &name)
DBHelper::renameList(item->getId(), name, db);
if (rli->parent->getId() != 0) {
//TODO
//move row depending on the name
// TODO
// move row depending on the name
} else
emit dataChanged(index(mi.row(), 0), index(mi.row(), 0));
} else if (typeid(*item) == typeid(LabelItem)) {
@ -609,7 +609,7 @@ QList<SpecialListItem *> ReadingListModel::setupSpecialLists(QSqlDatabase &db)
<< selectQuery.value(id));
}
//Reading after Favorites, Why? Because I want to :P
// Reading after Favorites, Why? Because I want to :P
list.insert(1, new SpecialListItem(QList<QVariant>() << "Reading" << 0));
return list;
@ -634,7 +634,7 @@ void ReadingListModel::setupLabels(QSqlDatabase &db)
<< selectQuery.value(ordering)));
}
//TEST
// TEST
// INSERT INTO label (name, color, ordering) VALUES ("Oh Oh", "red", 1);
// INSERT INTO label (name, color, ordering) VALUES ("lalala", "orange", 2);
@ -652,18 +652,18 @@ void ReadingListModel::setupLabels(QSqlDatabase &db)
void ReadingListModel::setupReadingLists(QSqlDatabase &db)
{
//setup root item
// setup root item
rootItem = new ReadingListItem(QList<QVariant>() << "ROOT" << 0 << true << false);
QSqlQuery selectQuery("select * from reading_list order by parentId IS NULL DESC", db);
//setup reading lists
// setup reading lists
setupReadingListsData(selectQuery, rootItem);
//TEST
// ReadingListItem * node1;
// rootItem->appendChild(node1 = new ReadingListItem(QList<QVariant>() /*<< 0*/ << "My reading list" << "atr"));
// rootItem->appendChild(new ReadingListItem(QList<QVariant>() /*<< 0*/ << "X timeline" << "atr"));
// TEST
// ReadingListItem * node1;
// rootItem->appendChild(node1 = new ReadingListItem(QList<QVariant>() /*<< 0*/ << "My reading list" << "atr"));
// rootItem->appendChild(new ReadingListItem(QList<QVariant>() /*<< 0*/ << "X timeline" << "atr"));
// node1->appendChild(new ReadingListItem(QList<QVariant>() /*<< 0*/ << "sublist" << "atr",node1));
}
@ -679,7 +679,7 @@ int ReadingListModel::addLabelIntoList(LabelItem *item)
i++;
if (i < labels.count()) {
if (labels.at(i)->colorid() == item->colorid()) //sort by name
if (labels.at(i)->colorid() == item->colorid()) // sort by name
{
while (i < labels.count() && labels.at(i)->colorid() == item->colorid() && naturalSortLessThanCI(labels.at(i)->name(), item->name()))
i++;
@ -720,7 +720,7 @@ void ReadingListModel::reorderingChildren(QList<ReadingListItem *> children)
bool ReadingListModel::rowIsSpecialList(int row, const QModelIndex &parent) const
{
if (parent.isValid())
return false; //by now no sublists in special list
return false; // by now no sublists in special list
if (row >= 0 && row < specialLists.count())
return true;
@ -731,7 +731,7 @@ bool ReadingListModel::rowIsSpecialList(int row, const QModelIndex &parent) cons
bool ReadingListModel::rowIsLabel(int row, const QModelIndex &parent) const
{
if (parent.isValid())
return false; //by now no sublists in labels
return false; // by now no sublists in labels
if (row > specialLists.count() && row <= specialLists.count() + labels.count())
return true;
@ -742,7 +742,7 @@ bool ReadingListModel::rowIsLabel(int row, const QModelIndex &parent) const
bool ReadingListModel::rowIsReadingList(int row, const QModelIndex &parent) const
{
if (parent.isValid())
return true; //only lists with sublists
return true; // only lists with sublists
int separatorsCount = labels.isEmpty() ? 1 : 2;
@ -755,7 +755,7 @@ bool ReadingListModel::rowIsReadingList(int row, const QModelIndex &parent) cons
bool ReadingListModel::rowIsSeparator(int row, const QModelIndex &parent) const
{
if (parent.isValid())
return false; //only separators at top level
return false; // only separators at top level
if (row == specialLists.count())
return true;

View File

@ -28,7 +28,7 @@ class ReadingListModel : public QAbstractItemModel
public:
explicit ReadingListModel(QObject *parent = nullptr);
//QAbstractItemModel methods
// QAbstractItemModel methods
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
@ -42,10 +42,10 @@ public:
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
QMimeData *mimeData(const QModelIndexList &indexes) const override;
//Convenience methods
// Convenience methods
void setupReadingListsData(QString path);
void addNewLabel(const QString &name, YACReader::LabelColors color);
void addReadingList(const QString &name); //top level reading list
void addReadingList(const QString &name); // top level reading list
void addReadingListAt(const QString &name, const QModelIndex &mi);
bool isEditable(const QModelIndex &mi);
bool isReadingList(const QModelIndex &mi);
@ -96,17 +96,17 @@ private:
bool dropComics(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
bool dropSublist(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
//Special lists
// Special lists
QList<SpecialListItem *> specialLists;
//Label
// Label
QList<LabelItem *> labels;
//Reading lists
// Reading lists
ReadingListItem *rootItem; //
QMap<unsigned long long int, ReadingListItem *> items; //lists relationship
QMap<unsigned long long int, ReadingListItem *> items; // lists relationship
//separators
// separators
ReadingListSeparatorItem *separator1;
ReadingListSeparatorItem *separator2;