mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Separaci?n en ficheros de las clases LibraryItem, Folder y Comic
A?adida la toolbar para la gesti?n de c?mics + im?genes para los iconos Modificado el di?logo de informaci?n/propiedades de los c?mics
This commit is contained in:
parent
9dfa9c5f62
commit
ed850ef374
@ -33,7 +33,10 @@ HEADERS += comic_flow.h \
|
|||||||
./db/treeitem.h \
|
./db/treeitem.h \
|
||||||
./db/treemodel.h \
|
./db/treemodel.h \
|
||||||
./db/tablemodel.h \
|
./db/tablemodel.h \
|
||||||
./db/tableitem.h
|
./db/tableitem.h \
|
||||||
|
./db/comic.h \
|
||||||
|
./db/folder.h \
|
||||||
|
./db/library_item.h
|
||||||
SOURCES += comic_flow.cpp \
|
SOURCES += comic_flow.cpp \
|
||||||
create_library_dialog.cpp \
|
create_library_dialog.cpp \
|
||||||
library_creator.cpp \
|
library_creator.cpp \
|
||||||
@ -54,7 +57,10 @@ SOURCES += comic_flow.cpp \
|
|||||||
./db/treeitem.cpp \
|
./db/treeitem.cpp \
|
||||||
./db/treemodel.cpp \
|
./db/treemodel.cpp \
|
||||||
./db/tablemodel.cpp \
|
./db/tablemodel.cpp \
|
||||||
./db/tableitem.cpp
|
./db/tableitem.cpp \
|
||||||
|
./db/comic.cpp \
|
||||||
|
./db/folder.cpp \
|
||||||
|
./db/library_item.cpp
|
||||||
|
|
||||||
include(./server/server.pri)
|
include(./server/server.pri)
|
||||||
|
|
||||||
|
101
YACReaderLibrary/db/comic.cpp
Normal file
101
YACReaderLibrary/db/comic.cpp
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
#include "comic.h"
|
||||||
|
|
||||||
|
#include <QSqlQuery>
|
||||||
|
#include <QSqlRecord>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
Comic::Comic()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Comic::Comic(qulonglong cparentId, qulonglong ccomicInfoId, QString cname, QString cpath, QString chash)
|
||||||
|
:comicInfoId(ccomicInfoId),hash(chash)
|
||||||
|
{
|
||||||
|
parentId = cparentId;
|
||||||
|
name = cname;
|
||||||
|
path = cpath;
|
||||||
|
}
|
||||||
|
|
||||||
|
qulonglong Comic::insert(QSqlDatabase & db)
|
||||||
|
{
|
||||||
|
//TODO comprobar si ya hay comic info con ese hash
|
||||||
|
QSqlQuery comicInfoInsert(db);
|
||||||
|
comicInfoInsert.prepare("INSERT INTO comic_info (hash) "
|
||||||
|
"VALUES (:hash)");
|
||||||
|
comicInfoInsert.bindValue(":hash", hash);
|
||||||
|
comicInfoInsert.exec();
|
||||||
|
qulonglong comicInfoId =comicInfoInsert.lastInsertId().toLongLong();
|
||||||
|
|
||||||
|
QSqlQuery query(db);
|
||||||
|
query.prepare("INSERT INTO comic (parentId, comicInfoId, fileName, path) "
|
||||||
|
"VALUES (:parentId,:comicInfoId,:name, :path)");
|
||||||
|
query.bindValue(":parentId", parentId);
|
||||||
|
query.bindValue(":comicInfoId", comicInfoId);
|
||||||
|
query.bindValue(":name", name);
|
||||||
|
query.bindValue(":path", path);
|
||||||
|
query.exec();
|
||||||
|
return query.lastInsertId().toLongLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<LibraryItem *> Comic::getComicsFromParent(qulonglong parentId, QSqlDatabase & db)
|
||||||
|
{
|
||||||
|
QList<LibraryItem *> list;
|
||||||
|
|
||||||
|
QSqlQuery selectQuery(db); //TODO check
|
||||||
|
selectQuery.prepare("select c.id,c.parentId,c.fileName,c.path,ci.hash from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId");
|
||||||
|
selectQuery.bindValue(":parentId", parentId);
|
||||||
|
selectQuery.exec();
|
||||||
|
|
||||||
|
Comic * currentItem;
|
||||||
|
while (selectQuery.next())
|
||||||
|
{
|
||||||
|
QList<QVariant> data;
|
||||||
|
QSqlRecord record = selectQuery.record();
|
||||||
|
for(int i=0;i<record.count();i++)
|
||||||
|
data << record.value(i);
|
||||||
|
//TODO sort by sort indicator and name
|
||||||
|
currentItem = new Comic();
|
||||||
|
currentItem->id = record.value(0).toLongLong();
|
||||||
|
currentItem->parentId = record.value(1).toLongLong();
|
||||||
|
currentItem->name = record.value(2).toString();
|
||||||
|
currentItem->hash = record.value(3).toString();
|
||||||
|
int lessThan = 0;
|
||||||
|
if(list.isEmpty())
|
||||||
|
list.append(currentItem);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Comic * last = static_cast<Comic *>(list.back());
|
||||||
|
QString nameLast = last->name;
|
||||||
|
QString nameCurrent = currentItem->name;
|
||||||
|
QList<LibraryItem *>::iterator i;
|
||||||
|
i = list.end();
|
||||||
|
i--;
|
||||||
|
while ((0 > (lessThan = nameCurrent.localeAwareCompare(nameLast))) && i != list.begin()) //se usa la misma ordenación que en QDir
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
nameLast = (*i)->name;
|
||||||
|
}
|
||||||
|
if(lessThan>0) //si se ha encontrado un elemento menor que current, se inserta justo después
|
||||||
|
list.insert(++i,currentItem);
|
||||||
|
else
|
||||||
|
list.insert(i,currentItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Comic::removeFromDB(QSqlDatabase & db)
|
||||||
|
{
|
||||||
|
QSqlQuery query(db);
|
||||||
|
query.prepare("DELETE FROM comic WHERE id = :id");
|
||||||
|
query.bindValue(":id", id);
|
||||||
|
query.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Comic::isDir()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
24
YACReaderLibrary/db/comic.h
Normal file
24
YACReaderLibrary/db/comic.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef __COMIC_H
|
||||||
|
#define __COMIC_H
|
||||||
|
|
||||||
|
#include "library_item.h"
|
||||||
|
#include <QSqlDatabase>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
class Comic : public LibraryItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
qulonglong comicInfoId;
|
||||||
|
QString hash;
|
||||||
|
|
||||||
|
Comic();
|
||||||
|
Comic(qulonglong cparentId, qulonglong ccomicInfoId, QString cname, QString cpath, QString chash);
|
||||||
|
//Comic(QString fn, QString fp):name(fn),path(fp),knownParent(false), knownId(false){};
|
||||||
|
qulonglong insert(QSqlDatabase & db);
|
||||||
|
static QList<LibraryItem *> getComicsFromParent(qulonglong parentId, QSqlDatabase & db);
|
||||||
|
bool isDir();
|
||||||
|
void removeFromDB(QSqlDatabase & db);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
71
YACReaderLibrary/db/folder.cpp
Normal file
71
YACReaderLibrary/db/folder.cpp
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
|
||||||
|
#include "folder.h"
|
||||||
|
#include <QSqlQuery>
|
||||||
|
#include <QSqlRecord>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
qulonglong Folder::insert(QSqlDatabase & db)
|
||||||
|
{
|
||||||
|
QSqlQuery query(db);
|
||||||
|
query.prepare("INSERT INTO folder (parentId, name, path) "
|
||||||
|
"VALUES (:parentId, :name, :path)");
|
||||||
|
query.bindValue(":parentId", parentId);
|
||||||
|
query.bindValue(":name", name);
|
||||||
|
query.bindValue(":path", path);
|
||||||
|
query.exec();
|
||||||
|
return query.lastInsertId().toLongLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<LibraryItem *> Folder::getFoldersFromParent(qulonglong parentId, QSqlDatabase & db)
|
||||||
|
{
|
||||||
|
QList<LibraryItem *> list;
|
||||||
|
|
||||||
|
QSqlQuery selectQuery(db); //TODO check
|
||||||
|
selectQuery.prepare("SELECT * FROM folder WHERE parentId = :parentId");
|
||||||
|
selectQuery.bindValue(":parentId", parentId);
|
||||||
|
selectQuery.exec();
|
||||||
|
|
||||||
|
Folder * currentItem;
|
||||||
|
while (selectQuery.next())
|
||||||
|
{
|
||||||
|
QList<QVariant> data;
|
||||||
|
QSqlRecord record = selectQuery.record();
|
||||||
|
for(int i=0;i<record.count();i++)
|
||||||
|
data << record.value(i);
|
||||||
|
//TODO sort by sort indicator and name
|
||||||
|
currentItem = new Folder(record.value(0).toLongLong(),record.value(1).toLongLong(),record.value(2).toString(),record.value(2).toString());
|
||||||
|
int lessThan = 0;
|
||||||
|
if(list.isEmpty())
|
||||||
|
list.append(currentItem);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Folder * last = static_cast<Folder *>(list.back());
|
||||||
|
QString nameLast = last->name; //TODO usar info name si está disponible, sino el nombre del fichero.....
|
||||||
|
QString nameCurrent = currentItem->name;
|
||||||
|
QList<LibraryItem *>::iterator i;
|
||||||
|
i = list.end();
|
||||||
|
i--;
|
||||||
|
while ((0 > (lessThan = nameCurrent.localeAwareCompare(nameLast))) && i != list.begin())
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
nameLast = (*i)->name;
|
||||||
|
}
|
||||||
|
if(lessThan>0) //si se ha encontrado un elemento menor que current, se inserta justo después
|
||||||
|
list.insert(++i,currentItem);
|
||||||
|
else
|
||||||
|
list.insert(i,currentItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Folder::removeFromDB(QSqlDatabase & db)
|
||||||
|
{
|
||||||
|
QSqlQuery query(db);
|
||||||
|
query.prepare("DELETE FROM folder WHERE id = :id");
|
||||||
|
query.bindValue(":id", id);
|
||||||
|
query.exec();
|
||||||
|
}
|
||||||
|
|
26
YACReaderLibrary/db/folder.h
Normal file
26
YACReaderLibrary/db/folder.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef __FOLDER_H
|
||||||
|
#define __FOLDER_H
|
||||||
|
|
||||||
|
#include "library_item.h"
|
||||||
|
|
||||||
|
#include <QSqlDatabase>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
class Folder : public LibraryItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool knownParent;
|
||||||
|
bool knownId;
|
||||||
|
|
||||||
|
Folder():knownParent(false), knownId(false){};
|
||||||
|
Folder(qulonglong sid, qulonglong pid,QString fn, QString fp):knownParent(true), knownId(true){id = sid; parentId = pid;name = fn; path = fp;};
|
||||||
|
Folder(QString fn, QString fp):knownParent(false), knownId(false){name = fn; path = fp;};
|
||||||
|
void setId(qulonglong sid){id = sid;knownId = true;};
|
||||||
|
void setFather(qulonglong pid){parentId = pid;knownParent = true;};
|
||||||
|
static QList<LibraryItem *> getFoldersFromParent(qulonglong parentId, QSqlDatabase & db);
|
||||||
|
qulonglong insert(QSqlDatabase & db);
|
||||||
|
bool isDir(){return true;};
|
||||||
|
void removeFromDB(QSqlDatabase & db);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
0
YACReaderLibrary/db/library_item.cpp
Normal file
0
YACReaderLibrary/db/library_item.cpp
Normal file
17
YACReaderLibrary/db/library_item.h
Normal file
17
YACReaderLibrary/db/library_item.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef __LIBRARY_ITEM_H
|
||||||
|
#define __LIBRARY_ITEM_H
|
||||||
|
|
||||||
|
#include <QSqlDatabase>
|
||||||
|
|
||||||
|
class LibraryItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool isDir() = 0;
|
||||||
|
virtual void removeFromDB(QSqlDatabase & db) = 0;
|
||||||
|
QString name;
|
||||||
|
QString path;
|
||||||
|
qulonglong parentId;
|
||||||
|
qulonglong id;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
42
YACReaderLibrary/db/tableitem.cpp
Normal file
42
YACReaderLibrary/db/tableitem.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
#include "tableitem.h"
|
||||||
|
|
||||||
|
//! [0]
|
||||||
|
TableItem::TableItem(const QList<QVariant> &data)
|
||||||
|
{
|
||||||
|
itemData = data;
|
||||||
|
}
|
||||||
|
//! [0]
|
||||||
|
|
||||||
|
//! [1]
|
||||||
|
TableItem::~TableItem()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
//! [1]
|
||||||
|
|
||||||
|
|
||||||
|
//! [5]
|
||||||
|
int TableItem::columnCount() const
|
||||||
|
{
|
||||||
|
return itemData.count();
|
||||||
|
}
|
||||||
|
//! [5]
|
||||||
|
|
||||||
|
//! [6]
|
||||||
|
QVariant TableItem::data(int column) const
|
||||||
|
{
|
||||||
|
return itemData.value(column);
|
||||||
|
}
|
||||||
|
//! [6]
|
||||||
|
|
||||||
|
|
||||||
|
//! [8]
|
||||||
|
int TableItem::row() const
|
||||||
|
{
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//! [8]
|
24
YACReaderLibrary/db/tableitem.h
Normal file
24
YACReaderLibrary/db/tableitem.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef TABLEITEM_H
|
||||||
|
#define TABLEITEM_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
//! [0]
|
||||||
|
class TableItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TableItem(const QList<QVariant> &data);
|
||||||
|
~TableItem();
|
||||||
|
int columnCount() const;
|
||||||
|
QVariant data(int column) const;
|
||||||
|
int row() const;
|
||||||
|
unsigned long long int id; //TODO sustituir por una clase adecuada
|
||||||
|
private:
|
||||||
|
QList<QVariant> itemData;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
//! [0]
|
||||||
|
|
||||||
|
#endif
|
211
YACReaderLibrary/db/tablemodel.cpp
Normal file
211
YACReaderLibrary/db/tablemodel.cpp
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
|
||||||
|
#include <QtGui>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include "tableitem.h"
|
||||||
|
#include "tablemodel.h"
|
||||||
|
#include "data_base_management.h"
|
||||||
|
#include "qnaturalsorting.h"
|
||||||
|
|
||||||
|
TableModel::TableModel(QObject *parent)
|
||||||
|
: QAbstractItemModel(parent)
|
||||||
|
{
|
||||||
|
connect(this,SIGNAL(beforeReset()),this,SIGNAL(modelAboutToBeReset()));
|
||||||
|
connect(this,SIGNAL(reset()),this,SIGNAL(modelReset()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [0]
|
||||||
|
TableModel::TableModel( QSqlQuery &sqlquery, QObject *parent)
|
||||||
|
: QAbstractItemModel(parent)
|
||||||
|
{
|
||||||
|
setupModelData(sqlquery);
|
||||||
|
}
|
||||||
|
//! [0]
|
||||||
|
|
||||||
|
//! [1]
|
||||||
|
TableModel::~TableModel()
|
||||||
|
{
|
||||||
|
qDeleteAll(_data);
|
||||||
|
}
|
||||||
|
//! [1]
|
||||||
|
|
||||||
|
//! [2]
|
||||||
|
int TableModel::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if(_data.isEmpty())
|
||||||
|
return 0;
|
||||||
|
return _data.first()->columnCount();
|
||||||
|
}
|
||||||
|
//! [2]
|
||||||
|
|
||||||
|
//! [3]
|
||||||
|
QVariant TableModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
if (role == Qt::DecorationRole)
|
||||||
|
{
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (role != Qt::DisplayRole)
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
TableItem *item = static_cast<TableItem*>(index.internalPointer());
|
||||||
|
|
||||||
|
return item->data(index.column());
|
||||||
|
}
|
||||||
|
//! [3]
|
||||||
|
|
||||||
|
//! [4]
|
||||||
|
Qt::ItemFlags TableModel::flags(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
|
//! [4]
|
||||||
|
|
||||||
|
//! [5]
|
||||||
|
QVariant TableModel::headerData(int section, Qt::Orientation orientation,
|
||||||
|
int role) const
|
||||||
|
{
|
||||||
|
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
||||||
|
{
|
||||||
|
switch(section)//TODO obtener esto de la query
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return QVariant(QString("Id"));
|
||||||
|
case 1:
|
||||||
|
return QVariant(QString("ParentId"));
|
||||||
|
case 2:
|
||||||
|
return QVariant(QString("File Name"));
|
||||||
|
case 3:
|
||||||
|
return QVariant(QString("Path"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(orientation == Qt::Vertical && role == Qt::DecorationRole)
|
||||||
|
return QVariant(QIcon(":/images/icon.png"));
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
//! [5]
|
||||||
|
|
||||||
|
//! [6]
|
||||||
|
QModelIndex TableModel::index(int row, int column, const QModelIndex &parent)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
if (!hasIndex(row, column, parent))
|
||||||
|
return QModelIndex();
|
||||||
|
|
||||||
|
return createIndex(row, column, _data.at(row));
|
||||||
|
}
|
||||||
|
//! [6]
|
||||||
|
|
||||||
|
//! [7]
|
||||||
|
QModelIndex TableModel::parent(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
//! [7]
|
||||||
|
|
||||||
|
//! [8]
|
||||||
|
int TableModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
TreeItem *parentItem;
|
||||||
|
if (parent.column() > 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!parent.isValid())
|
||||||
|
return _data.count();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//! [8]
|
||||||
|
|
||||||
|
QStringList TableModel::getPaths(const QString & _source)
|
||||||
|
{
|
||||||
|
QStringList paths;
|
||||||
|
QString source = _source + "/.yacreaderlibrary/covers/";
|
||||||
|
QList<TableItem *>::ConstIterator itr;
|
||||||
|
for(itr = _data.constBegin();itr != _data.constEnd();itr++)
|
||||||
|
{
|
||||||
|
QString path = (*itr)->data(4).toString();
|
||||||
|
paths << source+ path +".jpg";
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TableModel::setupModelData(unsigned long long int folderId,QSqlDatabase & db)
|
||||||
|
{
|
||||||
|
//QFile f(QCoreApplication::applicationDirPath()+"/performance.txt");
|
||||||
|
//f.open(QIODevice::Append);
|
||||||
|
emit(beforeReset());
|
||||||
|
//QElapsedTimer timer;
|
||||||
|
//timer.start();
|
||||||
|
qDeleteAll(_data);
|
||||||
|
_data.clear();
|
||||||
|
|
||||||
|
//QTextStream txtS(&f);
|
||||||
|
//txtS << "TABLEMODEL: Tiempo de borrado: " << timer.elapsed() << "ms\r\n";
|
||||||
|
db.open();
|
||||||
|
//crear la consulta
|
||||||
|
//timer.restart();
|
||||||
|
QSqlQuery selectQuery(db); //TODO check
|
||||||
|
selectQuery.prepare("select c.id,c.parentId,c.fileName,c.path,ci.hash from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId");
|
||||||
|
selectQuery.bindValue(":parentId", folderId);
|
||||||
|
selectQuery.exec();
|
||||||
|
//txtS << "TABLEMODEL: Tiempo de consulta: " << timer.elapsed() << "ms\r\n";
|
||||||
|
//timer.restart();
|
||||||
|
setupModelData(selectQuery);
|
||||||
|
//txtS << "TABLEMODEL: Tiempo de creación del modelo: " << timer.elapsed() << "ms\r\n";
|
||||||
|
db.close();
|
||||||
|
emit(reset());
|
||||||
|
//f.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TableModel::getComicPath(QModelIndex & mi)
|
||||||
|
{
|
||||||
|
if(mi.isValid())
|
||||||
|
return _data.at(mi.row())->data(3).toString();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
void TableModel::setupModelData(QSqlQuery &sqlquery)
|
||||||
|
{
|
||||||
|
TableItem * currentItem;
|
||||||
|
while (sqlquery.next())
|
||||||
|
{
|
||||||
|
QList<QVariant> data;
|
||||||
|
QSqlRecord record = sqlquery.record();
|
||||||
|
for(int i=0;i<record.count();i++)
|
||||||
|
data << record.value(i);
|
||||||
|
//TODO sort by sort indicator and name
|
||||||
|
currentItem = new TableItem(data);
|
||||||
|
bool lessThan = false;
|
||||||
|
if(_data.isEmpty())
|
||||||
|
_data.append(currentItem);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TableItem * last = _data.back();
|
||||||
|
QString nameLast = last->data(2).toString(); //TODO usar info name si está disponible, sino el nombre del fichero.....
|
||||||
|
QString nameCurrent = currentItem->data(2).toString();
|
||||||
|
QList<TableItem *>::iterator i;
|
||||||
|
i = _data.end();
|
||||||
|
i--;
|
||||||
|
while ((lessThan = naturalSortLessThanCI(nameCurrent,nameLast)) && i != _data.begin())
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
nameLast = (*i)->data(2).toString();
|
||||||
|
}
|
||||||
|
if(!lessThan) //si se ha encontrado un elemento menor que current, se inserta justo después
|
||||||
|
_data.insert(++i,currentItem);
|
||||||
|
else
|
||||||
|
_data.insert(i,currentItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
52
YACReaderLibrary/db/tablemodel.h
Normal file
52
YACReaderLibrary/db/tablemodel.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#ifndef TABLEMODEL_H
|
||||||
|
#define TABLEMODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
#include <QModelIndex>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QSqlQuery>
|
||||||
|
#include <QSqlDatabase>
|
||||||
|
|
||||||
|
class TableItem;
|
||||||
|
|
||||||
|
//! [0]
|
||||||
|
class TableModel : public QAbstractItemModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TableModel(QObject *parent = 0);
|
||||||
|
TableModel( QSqlQuery &sqlquery, QObject *parent = 0);
|
||||||
|
~TableModel();
|
||||||
|
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
|
int role = Qt::DisplayRole) const;
|
||||||
|
QModelIndex index(int row, int column,
|
||||||
|
const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
QModelIndex parent(const QModelIndex &index) const;
|
||||||
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
void setupModelData(unsigned long long int parentFolder,QSqlDatabase & db);
|
||||||
|
|
||||||
|
//Métodos de conveniencia
|
||||||
|
QStringList getPaths(const QString & _source);
|
||||||
|
QString getComicPath(QModelIndex & mi);
|
||||||
|
//getComicInfo(QModelIndex & mi); --> para la edición
|
||||||
|
//getComicsInfo(QList<QModelIndex> list); --> recupera la información común a 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
|
||||||
|
private:
|
||||||
|
void setupModelData( QSqlQuery &sqlquery);
|
||||||
|
|
||||||
|
QList<TableItem *> _data;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void beforeReset();
|
||||||
|
void reset();
|
||||||
|
};
|
||||||
|
//! [0]
|
||||||
|
|
||||||
|
#endif
|
@ -61,9 +61,11 @@ public:
|
|||||||
TreeItem *parent();
|
TreeItem *parent();
|
||||||
TreeItem *parentItem;
|
TreeItem *parentItem;
|
||||||
unsigned long long int id;
|
unsigned long long int id;
|
||||||
|
QList<QString> comicNames;
|
||||||
private:
|
private:
|
||||||
QList<TreeItem*> childItems;
|
QList<TreeItem*> childItems;
|
||||||
QList<QVariant> itemData;
|
QList<QVariant> itemData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -221,6 +221,15 @@ void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
|||||||
data << sqlquery.value(2).toString();
|
data << sqlquery.value(2).toString();
|
||||||
data << sqlquery.value(3).toString();
|
data << sqlquery.value(3).toString();
|
||||||
TreeItem * item = new TreeItem(data);
|
TreeItem * item = new TreeItem(data);
|
||||||
|
|
||||||
|
/*QSqlQuery selectQuery(_database); //TODO check
|
||||||
|
selectQuery.prepare("select fileName from comic where parentId = :parentId");
|
||||||
|
selectQuery.bindValue(":parentId", sqlquery.value(0).toLongLong());
|
||||||
|
selectQuery.exec();
|
||||||
|
while (selectQuery.next()) {
|
||||||
|
item->comicNames.append(sqlquery.value(0).toString());
|
||||||
|
}*/
|
||||||
|
|
||||||
item->id = sqlquery.value(0).toLongLong();
|
item->id = sqlquery.value(0).toLongLong();
|
||||||
items.value(sqlquery.value(1).toLongLong())->appendChild(item);
|
items.value(sqlquery.value(1).toLongLong())->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
|
||||||
|
@ -29,5 +29,8 @@
|
|||||||
<file>../images/setUnread.png</file>
|
<file>../images/setUnread.png</file>
|
||||||
<file>../images/setAllUnread.png</file>
|
<file>../images/setAllUnread.png</file>
|
||||||
<file>../images/showMarks.png</file>
|
<file>../images/showMarks.png</file>
|
||||||
|
<file>../images/importCover.png</file>
|
||||||
|
<file>../images/editComic.png</file>
|
||||||
|
<file>../images/selectAll.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -15,151 +15,6 @@ QMutex mutex;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
qint64 Folder::insert(QSqlDatabase & db)
|
|
||||||
{
|
|
||||||
QSqlQuery query(db);
|
|
||||||
query.prepare("INSERT INTO folder (parentId, name, path) "
|
|
||||||
"VALUES (:parentId, :name, :path)");
|
|
||||||
query.bindValue(":parentId", parentId);
|
|
||||||
query.bindValue(":name", name);
|
|
||||||
query.bindValue(":path", path);
|
|
||||||
query.exec();
|
|
||||||
return query.lastInsertId().toLongLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<LibraryItem *> Folder::getFoldersFromParent(qint64 parentId, QSqlDatabase & db)
|
|
||||||
{
|
|
||||||
QList<LibraryItem *> list;
|
|
||||||
|
|
||||||
QSqlQuery selectQuery(db); //TODO check
|
|
||||||
selectQuery.prepare("SELECT * FROM folder WHERE parentId = :parentId");
|
|
||||||
selectQuery.bindValue(":parentId", parentId);
|
|
||||||
selectQuery.exec();
|
|
||||||
|
|
||||||
Folder * currentItem;
|
|
||||||
while (selectQuery.next())
|
|
||||||
{
|
|
||||||
QList<QVariant> data;
|
|
||||||
QSqlRecord record = selectQuery.record();
|
|
||||||
for(int i=0;i<record.count();i++)
|
|
||||||
data << record.value(i);
|
|
||||||
//TODO sort by sort indicator and name
|
|
||||||
currentItem = new Folder(record.value(0).toLongLong(),record.value(1).toLongLong(),record.value(2).toString(),record.value(2).toString());
|
|
||||||
int lessThan = 0;
|
|
||||||
if(list.isEmpty())
|
|
||||||
list.append(currentItem);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Folder * last = static_cast<Folder *>(list.back());
|
|
||||||
QString nameLast = last->name; //TODO usar info name si está disponible, sino el nombre del fichero.....
|
|
||||||
QString nameCurrent = currentItem->name;
|
|
||||||
QList<LibraryItem *>::iterator i;
|
|
||||||
i = list.end();
|
|
||||||
i--;
|
|
||||||
while ((0 > (lessThan = nameCurrent.localeAwareCompare(nameLast))) && i != list.begin())
|
|
||||||
{
|
|
||||||
i--;
|
|
||||||
nameLast = (*i)->name;
|
|
||||||
}
|
|
||||||
if(lessThan>0) //si se ha encontrado un elemento menor que current, se inserta justo después
|
|
||||||
list.insert(++i,currentItem);
|
|
||||||
else
|
|
||||||
list.insert(i,currentItem);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Folder::removeFromDB(QSqlDatabase & db)
|
|
||||||
{
|
|
||||||
QSqlQuery query(db);
|
|
||||||
query.prepare("DELETE FROM folder WHERE id = :id");
|
|
||||||
query.bindValue(":id", id);
|
|
||||||
query.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
qint64 Comic::insert(QSqlDatabase & db)
|
|
||||||
{
|
|
||||||
//TODO comprobar si ya hay comic info con ese hash
|
|
||||||
QSqlQuery comicInfoInsert(db);
|
|
||||||
comicInfoInsert.prepare("INSERT INTO comic_info (hash) "
|
|
||||||
"VALUES (:hash)");
|
|
||||||
comicInfoInsert.bindValue(":hash", hash);
|
|
||||||
comicInfoInsert.exec();
|
|
||||||
qint64 comicInfoId =comicInfoInsert.lastInsertId().toLongLong();
|
|
||||||
|
|
||||||
QSqlQuery query(db);
|
|
||||||
query.prepare("INSERT INTO comic (parentId, comicInfoId, fileName, path) "
|
|
||||||
"VALUES (:parentId,:comicInfoId,:name, :path)");
|
|
||||||
query.bindValue(":parentId", parentId);
|
|
||||||
query.bindValue(":comicInfoId", comicInfoId);
|
|
||||||
query.bindValue(":name", name);
|
|
||||||
query.bindValue(":path", path);
|
|
||||||
query.exec();
|
|
||||||
return query.lastInsertId().toLongLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<LibraryItem *> Comic::getComicsFromParent(qint64 parentId, QSqlDatabase & db)
|
|
||||||
{
|
|
||||||
QList<LibraryItem *> list;
|
|
||||||
|
|
||||||
QSqlQuery selectQuery(db); //TODO check
|
|
||||||
selectQuery.prepare("select c.id,c.parentId,c.fileName,c.path,ci.hash from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId");
|
|
||||||
selectQuery.bindValue(":parentId", parentId);
|
|
||||||
selectQuery.exec();
|
|
||||||
|
|
||||||
Comic * currentItem;
|
|
||||||
while (selectQuery.next())
|
|
||||||
{
|
|
||||||
QList<QVariant> data;
|
|
||||||
QSqlRecord record = selectQuery.record();
|
|
||||||
for(int i=0;i<record.count();i++)
|
|
||||||
data << record.value(i);
|
|
||||||
//TODO sort by sort indicator and name
|
|
||||||
currentItem = new Comic;
|
|
||||||
currentItem->id = record.value(0).toLongLong();
|
|
||||||
currentItem->parentId = record.value(1).toLongLong();
|
|
||||||
currentItem->name = record.value(2).toString();
|
|
||||||
currentItem->hash = record.value(3).toString();
|
|
||||||
int lessThan = 0;
|
|
||||||
if(list.isEmpty())
|
|
||||||
list.append(currentItem);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Comic * last = static_cast<Comic *>(list.back());
|
|
||||||
QString nameLast = last->name;
|
|
||||||
QString nameCurrent = currentItem->name;
|
|
||||||
QList<LibraryItem *>::iterator i;
|
|
||||||
i = list.end();
|
|
||||||
i--;
|
|
||||||
while ((0 > (lessThan = nameCurrent.localeAwareCompare(nameLast))) && i != list.begin()) //se usa la misma ordenación que en QDir
|
|
||||||
{
|
|
||||||
i--;
|
|
||||||
nameLast = (*i)->name;
|
|
||||||
}
|
|
||||||
if(lessThan>0) //si se ha encontrado un elemento menor que current, se inserta justo después
|
|
||||||
list.insert(++i,currentItem);
|
|
||||||
else
|
|
||||||
list.insert(i,currentItem);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Comic::removeFromDB(QSqlDatabase & db)
|
|
||||||
{
|
|
||||||
QSqlQuery query(db);
|
|
||||||
query.prepare("DELETE FROM comic WHERE id = :id");
|
|
||||||
query.bindValue(":id", id);
|
|
||||||
query.exec();
|
|
||||||
}
|
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
LibraryCreator::LibraryCreator()
|
LibraryCreator::LibraryCreator()
|
||||||
{
|
{
|
||||||
@ -249,7 +104,7 @@ void LibraryCreator::stop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//retorna el id del ultimo de los folders
|
//retorna el id del ultimo de los folders
|
||||||
qint64 LibraryCreator::insertFolders()
|
qulonglong LibraryCreator::insertFolders()
|
||||||
{
|
{
|
||||||
QList<Folder>::iterator i;
|
QList<Folder>::iterator i;
|
||||||
int currentId = 0;
|
int currentId = 0;
|
||||||
@ -269,7 +124,7 @@ qint64 LibraryCreator::insertFolders()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*qint64 LibraryCreator::insertFolder(qint64 parentId,const Folder & folder)
|
/*qulonglong LibraryCreator::insertFolder(qulonglong parentId,const Folder & folder)
|
||||||
{
|
{
|
||||||
QSqlQuery query(_database);
|
QSqlQuery query(_database);
|
||||||
query.prepare("INSERT INTO folder (parentId, name, path) "
|
query.prepare("INSERT INTO folder (parentId, name, path) "
|
||||||
@ -281,7 +136,7 @@ qint64 LibraryCreator::insertFolders()
|
|||||||
return query.lastInsertId().toLongLong();
|
return query.lastInsertId().toLongLong();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/*qint64 LibraryCreator::insertComic(const Comic & comic)
|
/*qulonglong LibraryCreator::insertComic(const Comic & comic)
|
||||||
{
|
{
|
||||||
//TODO comprobar si ya hay comic info con ese hash
|
//TODO comprobar si ya hay comic info con ese hash
|
||||||
QSqlQuery comicInfoInsert(_database);
|
QSqlQuery comicInfoInsert(_database);
|
||||||
@ -289,7 +144,7 @@ qint64 LibraryCreator::insertFolders()
|
|||||||
"VALUES (:hash)");
|
"VALUES (:hash)");
|
||||||
comicInfoInsert.bindValue(":hash", comic.hash);
|
comicInfoInsert.bindValue(":hash", comic.hash);
|
||||||
comicInfoInsert.exec();
|
comicInfoInsert.exec();
|
||||||
qint64 comicInfoId =comicInfoInsert.lastInsertId().toLongLong();
|
qulonglong comicInfoId =comicInfoInsert.lastInsertId().toLongLong();
|
||||||
|
|
||||||
QSqlQuery query(_database);
|
QSqlQuery query(_database);
|
||||||
query.prepare("INSERT INTO comic (parentId, comicInfoId, fileName, path) "
|
query.prepare("INSERT INTO comic (parentId, comicInfoId, fileName, path) "
|
||||||
|
@ -14,51 +14,8 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
|
|
||||||
|
#include "folder.h"
|
||||||
class LibraryItem
|
#include "comic.h"
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual bool isDir() = 0;
|
|
||||||
virtual void removeFromDB(QSqlDatabase & db) = 0;
|
|
||||||
QString name;
|
|
||||||
QString path;
|
|
||||||
qint64 parentId;
|
|
||||||
qint64 id;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Folder : public LibraryItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool knownParent;
|
|
||||||
bool knownId;
|
|
||||||
|
|
||||||
Folder():knownParent(false), knownId(false){};
|
|
||||||
Folder(qint64 sid, qint64 pid,QString fn, QString fp):knownParent(true), knownId(true){id = sid; parentId = pid;name = fn; path = fp;};
|
|
||||||
Folder(QString fn, QString fp):knownParent(false), knownId(false){name = fn; path = fp;};
|
|
||||||
void setId(qint64 sid){id = sid;knownId = true;};
|
|
||||||
void setFather(qint64 pid){parentId = pid;knownParent = true;};
|
|
||||||
static QList<LibraryItem *> getFoldersFromParent(qint64 parentId, QSqlDatabase & db);
|
|
||||||
qint64 insert(QSqlDatabase & db);
|
|
||||||
bool isDir(){return true;};
|
|
||||||
void removeFromDB(QSqlDatabase & db);
|
|
||||||
};
|
|
||||||
|
|
||||||
class Comic : public LibraryItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
qint64 comicInfoId;
|
|
||||||
QString hash;
|
|
||||||
|
|
||||||
Comic(){};
|
|
||||||
Comic(qint64 cparentId, qint64 ccomicInfoId, QString cname, QString cpath, QString chash)
|
|
||||||
:comicInfoId(ccomicInfoId),hash(chash){parentId = cparentId;name = cname; path = cpath;};
|
|
||||||
//Comic(QString fn, QString fp):name(fn),path(fp),knownParent(false), knownId(false){};
|
|
||||||
qint64 insert(QSqlDatabase & db);
|
|
||||||
static QList<LibraryItem *> getComicsFromParent(qint64 parentId, QSqlDatabase & db);
|
|
||||||
bool isDir(){return false;};
|
|
||||||
void removeFromDB(QSqlDatabase & db);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LibraryCreator : public QThread
|
class LibraryCreator : public QThread
|
||||||
@ -83,10 +40,10 @@ public:
|
|||||||
void update(QDir currentDirectory);
|
void update(QDir currentDirectory);
|
||||||
void run();
|
void run();
|
||||||
bool createTables();
|
bool createTables();
|
||||||
qint64 insertFolders();//devuelve el id del último folder añadido (último en la ruta)
|
qulonglong insertFolders();//devuelve el id del último folder añadido (último en la ruta)
|
||||||
void insertComic(const QString & relativePath,const QFileInfo & fileInfo);
|
void insertComic(const QString & relativePath,const QFileInfo & fileInfo);
|
||||||
//qint64 insertFolder(qint64 parentId,const Folder & folder);
|
//qulonglong insertFolder(qulonglong parentId,const Folder & folder);
|
||||||
//qint64 insertComic(const Comic & comic);
|
//qulonglong insertComic(const Comic & comic);
|
||||||
bool stopRunning;
|
bool stopRunning;
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
@ -44,13 +44,11 @@ void LibraryWindow::setupUI()
|
|||||||
|
|
||||||
void LibraryWindow::doLayout()
|
void LibraryWindow::doLayout()
|
||||||
{
|
{
|
||||||
QSplitter * sVertical = new QSplitter(Qt::Vertical);
|
QSplitter * sVertical = new QSplitter(Qt::Vertical); //spliter derecha
|
||||||
QSplitter * sHorizontal = new QSplitter(Qt::Horizontal);
|
QSplitter * sHorizontal = new QSplitter(Qt::Horizontal); //spliter principal
|
||||||
//TODO: flowType is a global variable
|
//TODO: flowType is a global variable
|
||||||
optionsDialog = new OptionsDialog(this);
|
//CONFIG COMIC_FLOW--------------------------------------------------------
|
||||||
optionsDialog->restoreOptions();
|
|
||||||
comicFlow = new ComicFlow(0,flowType);
|
comicFlow = new ComicFlow(0,flowType);
|
||||||
|
|
||||||
comicFlow->setFocusPolicy(Qt::StrongFocus);
|
comicFlow->setFocusPolicy(Qt::StrongFocus);
|
||||||
comicFlow->setShowMarks(true);
|
comicFlow->setShowMarks(true);
|
||||||
QMatrix m;
|
QMatrix m;
|
||||||
@ -67,17 +65,46 @@ void LibraryWindow::doLayout()
|
|||||||
slideSizeF = QSize(width,height);
|
slideSizeF = QSize(width,height);
|
||||||
comicFlow->setSlideSize(slideSizeW);
|
comicFlow->setSlideSize(slideSizeW);
|
||||||
setFocusProxy(comicFlow);
|
setFocusProxy(comicFlow);
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//CONFIG TREE/TABLE VIEWS--------------------------------------------------
|
||||||
comicView = new QTableView;
|
comicView = new QTableView;
|
||||||
foldersView = new QTreeView;
|
foldersView = new QTreeView;
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//CONFIG FLOW/COMICS-------------------------------------------------------
|
||||||
sVertical->addWidget(comicFlow);
|
|
||||||
sVertical->addWidget(comicView);
|
|
||||||
/*sVertical->setStretchFactor(0,1);
|
/*sVertical->setStretchFactor(0,1);
|
||||||
sVertical->setStretchFactor(1,0);
|
sVertical->setStretchFactor(1,0);
|
||||||
*/
|
*/
|
||||||
|
//views
|
||||||
|
foldersView->setAnimated(true);
|
||||||
|
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
foldersView->header()->hide();
|
||||||
|
foldersView->setUniformRowHeights(true);
|
||||||
|
|
||||||
|
comicView->setAlternatingRowColors(true);
|
||||||
|
//comicView->setStyleSheet("alternate-background-color: #e7e7d7;background-color: white;");
|
||||||
|
//comicView->setItemDelegate(new YACReaderComicViewDelegate());
|
||||||
|
comicView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
comicView->setShowGrid(false);
|
||||||
|
comicView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||||
|
comicView->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
comicView->horizontalHeader()->setClickable(false);
|
||||||
|
//comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||||
|
comicView->verticalHeader()->setDefaultSectionSize(24);
|
||||||
|
comicView->verticalHeader()->setClickable(false); //TODO comportamiento anómalo
|
||||||
|
comicView->setCornerButtonEnabled(false);
|
||||||
|
comicView->setStyleSheet("QTableView {selection-background-color: #d7d7c7; selection-color: #000000;}");
|
||||||
|
// comicView->verticalHeader()->setStyleSheet("QHeaderView::section"
|
||||||
|
//"{"
|
||||||
|
// "background-color: white /* steelblue */"
|
||||||
|
//"}");
|
||||||
|
comicView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
comicView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//CONFIG NAVEGACIÓN/BÚSQUEDA-----------------------------------------------
|
||||||
left = new QWidget;
|
left = new QWidget;
|
||||||
QVBoxLayout * l = new QVBoxLayout;
|
QVBoxLayout * l = new QVBoxLayout;
|
||||||
selectedLibrary = new QComboBox;
|
selectedLibrary = new QComboBox;
|
||||||
@ -104,37 +131,23 @@ void LibraryWindow::doLayout()
|
|||||||
l->addLayout(searchLayout);
|
l->addLayout(searchLayout);
|
||||||
l->setSpacing(1);
|
l->setSpacing(1);
|
||||||
left->setLayout(l);
|
left->setLayout(l);
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//FINAL LAYOUT-------------------------------------------------------------
|
||||||
|
sVertical->addWidget(comicFlow);
|
||||||
|
QWidget *comics = new QWidget;
|
||||||
|
QVBoxLayout * comicsLayout = new QVBoxLayout;
|
||||||
|
comicsLayout->setContentsMargins(2,2,0,0);
|
||||||
|
comicsLayout->addWidget(editInfoToolBar = new QToolBar(comics));
|
||||||
|
comicsLayout->addWidget(comicView);
|
||||||
|
comics->setLayout(comicsLayout);
|
||||||
|
sVertical->addWidget(comics);
|
||||||
sHorizontal->addWidget(left);
|
sHorizontal->addWidget(left);
|
||||||
sHorizontal->addWidget(sVertical);
|
sHorizontal->addWidget(sVertical);
|
||||||
sHorizontal->setStretchFactor(0,0);
|
sHorizontal->setStretchFactor(0,0);
|
||||||
sHorizontal->setStretchFactor(1,1);
|
sHorizontal->setStretchFactor(1,1);
|
||||||
setCentralWidget(sHorizontal);
|
setCentralWidget(sHorizontal);
|
||||||
|
//FINAL LAYOUT-------------------------------------------------------------
|
||||||
//views
|
|
||||||
foldersView->setAnimated(true);
|
|
||||||
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
|
||||||
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
|
||||||
foldersView->header()->hide();
|
|
||||||
foldersView->setUniformRowHeights(true);
|
|
||||||
|
|
||||||
comicView->setAlternatingRowColors(true);
|
|
||||||
//comicView->setStyleSheet("alternate-background-color: #e7e7d7;background-color: white;");
|
|
||||||
//comicView->setItemDelegate(new YACReaderComicViewDelegate());
|
|
||||||
comicView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
|
||||||
comicView->setShowGrid(false);
|
|
||||||
comicView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
|
||||||
comicView->horizontalHeader()->setStretchLastSection(true);
|
|
||||||
//comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
|
||||||
comicView->verticalHeader()->setDefaultSectionSize(24);
|
|
||||||
// comicView->verticalHeader()->setStyleSheet("QHeaderView::section"
|
|
||||||
//"{"
|
|
||||||
// "background-color: white /* steelblue */"
|
|
||||||
//"}");
|
|
||||||
comicView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
||||||
comicView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fullScreenToolTip = new QLabel(this);
|
fullScreenToolTip = new QLabel(this);
|
||||||
fullScreenToolTip->setText(tr("<font color='white'> press 'F' to close fullscreen mode </font>"));
|
fullScreenToolTip->setText(tr("<font color='white'> press 'F' to close fullscreen mode </font>"));
|
||||||
@ -156,6 +169,8 @@ void LibraryWindow::doDialogs()
|
|||||||
exportLibraryDialog = new ExportLibraryDialog(this);
|
exportLibraryDialog = new ExportLibraryDialog(this);
|
||||||
importLibraryDialog = new ImportLibraryDialog(this);
|
importLibraryDialog = new ImportLibraryDialog(this);
|
||||||
addLibraryDialog = new AddLibraryDialog(this);
|
addLibraryDialog = new AddLibraryDialog(this);
|
||||||
|
optionsDialog = new OptionsDialog(this);
|
||||||
|
optionsDialog->restoreOptions();
|
||||||
had = new HelpAboutDialog(this); //TODO load data.
|
had = new HelpAboutDialog(this); //TODO load data.
|
||||||
QString sufix = QLocale::system().name();
|
QString sufix = QLocale::system().name();
|
||||||
if(QFile(":/files/about_"+sufix+".html").exists())
|
if(QFile(":/files/about_"+sufix+".html").exists())
|
||||||
@ -303,6 +318,24 @@ void LibraryWindow::createActions()
|
|||||||
openContainingFolderComicAction = new QAction(this);
|
openContainingFolderComicAction = new QAction(this);
|
||||||
openContainingFolderComicAction->setText(tr("Open containing folder..."));
|
openContainingFolderComicAction->setText(tr("Open containing folder..."));
|
||||||
openContainingFolderComicAction->setIcon(QIcon(":/images/open.png"));
|
openContainingFolderComicAction->setIcon(QIcon(":/images/open.png"));
|
||||||
|
|
||||||
|
//Edit comics actions------------------------------------------------------
|
||||||
|
selectAllComicsAction = new QAction(this);
|
||||||
|
selectAllComicsAction->setText(tr("Select all comics"));
|
||||||
|
selectAllComicsAction->setIcon(QIcon(":/images/selectAll.png"));
|
||||||
|
|
||||||
|
editSelectedComicsAction = new QAction(this);
|
||||||
|
editSelectedComicsAction->setText(tr("Edit"));
|
||||||
|
editSelectedComicsAction->setIcon(QIcon(":/images/editComic.png"));
|
||||||
|
|
||||||
|
asignOrderActions = new QAction(this);
|
||||||
|
asignOrderActions->setText(tr("Asign current order to comics"));
|
||||||
|
asignOrderActions->setIcon(QIcon(":/images/fit.png"));
|
||||||
|
|
||||||
|
forceConverExtractedAction = new QAction(this);
|
||||||
|
forceConverExtractedAction->setText(tr("Update cover"));
|
||||||
|
forceConverExtractedAction->setIcon(QIcon(":/images/importCover.png"));
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO unificar con disableActions
|
//TODO unificar con disableActions
|
||||||
@ -407,6 +440,13 @@ void LibraryWindow::createToolBars()
|
|||||||
|
|
||||||
comicFlow->addAction(toggleFullScreenAction);
|
comicFlow->addAction(toggleFullScreenAction);
|
||||||
comicFlow->addAction(openComicAction);
|
comicFlow->addAction(openComicAction);
|
||||||
|
|
||||||
|
editInfoToolBar->addAction(openComicAction);
|
||||||
|
editInfoToolBar->addSeparator();
|
||||||
|
editInfoToolBar->addAction(editSelectedComicsAction);
|
||||||
|
editInfoToolBar->addAction(selectAllComicsAction);
|
||||||
|
editInfoToolBar->addSeparator();
|
||||||
|
editInfoToolBar->addAction(forceConverExtractedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::createMenus()
|
void LibraryWindow::createMenus()
|
||||||
@ -495,6 +535,9 @@ void LibraryWindow::createConnections()
|
|||||||
|
|
||||||
//connect(dm,SIGNAL(directoryLoaded(QString)),foldersView,SLOT(expandAll()));
|
//connect(dm,SIGNAL(directoryLoaded(QString)),foldersView,SLOT(expandAll()));
|
||||||
//connect(dm,SIGNAL(directoryLoaded(QString)),this,SLOT(updateFoldersView(QString)));
|
//connect(dm,SIGNAL(directoryLoaded(QString)),this,SLOT(updateFoldersView(QString)));
|
||||||
|
//Comicts edition
|
||||||
|
connect(selectAllComicsAction,SIGNAL(triggered()),comicView,SLOT(selectAll()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::loadLibrary(const QString & name)
|
void LibraryWindow::loadLibrary(const QString & name)
|
||||||
|
@ -96,10 +96,16 @@ private:
|
|||||||
QAction * setAllAsNonReadAction;
|
QAction * setAllAsNonReadAction;
|
||||||
QAction * showHideMarksAction;
|
QAction * showHideMarksAction;
|
||||||
|
|
||||||
|
QAction * selectAllComicsAction;
|
||||||
|
QAction * editSelectedComicsAction;
|
||||||
|
QAction * asignOrderActions;
|
||||||
|
QAction * forceConverExtractedAction;
|
||||||
|
|
||||||
|
|
||||||
QToolBar * libraryToolBar;
|
QToolBar * libraryToolBar;
|
||||||
QToolBar * treeActions;
|
QToolBar * treeActions;
|
||||||
QToolBar * comicsToolBar;
|
QToolBar * comicsToolBar;
|
||||||
|
QToolBar * editInfoToolBar;
|
||||||
|
|
||||||
OptionsDialog * optionsDialog;
|
OptionsDialog * optionsDialog;
|
||||||
|
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#include <QSizePolicy>
|
||||||
|
|
||||||
|
|
||||||
PropertiesDialog::PropertiesDialog(QWidget * parent)
|
PropertiesDialog::PropertiesDialog(QWidget * parent)
|
||||||
:QDialog(parent)
|
:QDialog(parent)
|
||||||
{
|
{
|
||||||
QVBoxLayout * l = new QVBoxLayout();
|
QHBoxLayout * l = new QHBoxLayout();
|
||||||
|
|
||||||
sa = new QScrollArea(this);
|
sa = new QScrollArea();
|
||||||
_cover = new QLabel(sa);
|
_cover = new QLabel();
|
||||||
_cover->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
_cover->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||||
_cover->setScaledContents(true);
|
_cover->setScaledContents(true);
|
||||||
_cover->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
_cover->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
||||||
@ -24,18 +24,42 @@ PropertiesDialog::PropertiesDialog(QWidget * parent)
|
|||||||
sa->setFrameStyle(QFrame::NoFrame);
|
sa->setFrameStyle(QFrame::NoFrame);
|
||||||
sa->setAlignment(Qt::AlignCenter);
|
sa->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
l->addWidget(sa);
|
QVBoxLayout * coverLayout = new QVBoxLayout();
|
||||||
|
coverLayout->addWidget(sa);
|
||||||
|
//coverLayout->addStretch();
|
||||||
|
|
||||||
|
l->addLayout(coverLayout);
|
||||||
|
|
||||||
QVBoxLayout * info = new QVBoxLayout();
|
QVBoxLayout * info = new QVBoxLayout();
|
||||||
info->addWidget(_name = new QLabel("name"));
|
info->addWidget(_name = new QLabel("name"));
|
||||||
info->addWidget(_pages = new QLabel("pages"));
|
info->addWidget(_pages = new QLabel("pages"));
|
||||||
info->addWidget(_size = new QLabel("size"));
|
info->addWidget(_size = new QLabel("size"));
|
||||||
info->setSizeConstraint(QLayout::SetMaximumSize);
|
info->addStretch();
|
||||||
|
//coverLayout->setSizeConstraint(QLayout::SetMaximumSize);
|
||||||
l->addLayout(info);
|
l->addLayout(info);
|
||||||
|
l->addStretch();
|
||||||
|
//l->setSizeConstraint(QLayout::SetNoConstraint);
|
||||||
this->setLayout(l);
|
this->setLayout(l);
|
||||||
this->setWindowTitle(tr("Comic properties"));
|
this->setWindowTitle(tr("Comic properties"));
|
||||||
|
|
||||||
|
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
|
||||||
|
int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
|
||||||
|
int sHeight,sWidth;
|
||||||
|
sHeight = static_cast<int>(heightDesktopResolution*0.5);
|
||||||
|
sWidth = static_cast<int>(sHeight*1.4);
|
||||||
|
this->resize(sWidth,sHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertiesDialog::setComics(QList<Comic> comics)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesDialog::updateComics(QList<Comic> comics)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
//Deprecated
|
||||||
void PropertiesDialog::setCover(const QPixmap & cover)
|
void PropertiesDialog::setCover(const QPixmap & cover)
|
||||||
{
|
{
|
||||||
_cover->setPixmap(cover);
|
_cover->setPixmap(cover);
|
||||||
@ -43,20 +67,20 @@ void PropertiesDialog::setCover(const QPixmap & cover)
|
|||||||
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
|
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
|
||||||
int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
|
int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
|
||||||
int sHeight,sWidth;
|
int sHeight,sWidth;
|
||||||
sHeight = static_cast<int>(heightDesktopResolution*0.84);
|
sHeight = static_cast<int>(heightDesktopResolution*0.5);
|
||||||
|
|
||||||
if(aspectRatio<1)
|
if(aspectRatio<1)
|
||||||
{
|
{
|
||||||
sWidth = static_cast<int>(sHeight*0.70);
|
sWidth = static_cast<int>(sHeight*1.4);
|
||||||
this->resize(sWidth,sHeight);
|
//this->resize(sWidth,sHeight);
|
||||||
this->move(QPoint((widthDesktopResolution-sWidth)/2,((heightDesktopResolution-sHeight)-40)/2));
|
this->move(QPoint((widthDesktopResolution-sWidth)/2,((heightDesktopResolution-sHeight)-40)/2));
|
||||||
_cover->resize(static_cast<int>((height()-90)*aspectRatio),
|
_cover->resize(static_cast<int>((sa->height())*aspectRatio),
|
||||||
(height()-90));
|
(sa->height()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sWidth = static_cast<int>(sHeight*1.10);
|
sWidth = static_cast<int>(sHeight/1.16);
|
||||||
this->resize(sWidth,sHeight);
|
//this->resize(sWidth,sHeight);
|
||||||
this->move(QPoint((widthDesktopResolution-sWidth)/2,((heightDesktopResolution-sHeight)-40)/2));
|
this->move(QPoint((widthDesktopResolution-sWidth)/2,((heightDesktopResolution-sHeight)-40)/2));
|
||||||
_cover->resize((width()-25),
|
_cover->resize((width()-25),
|
||||||
static_cast<int>((width()-25)/aspectRatio));
|
static_cast<int>((width()-25)/aspectRatio));
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
|
||||||
|
#include "comic.h"
|
||||||
|
|
||||||
class PropertiesDialog : public QDialog
|
class PropertiesDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -20,6 +22,10 @@
|
|||||||
public:
|
public:
|
||||||
PropertiesDialog(QWidget * parent = 0);
|
PropertiesDialog(QWidget * parent = 0);
|
||||||
public slots:
|
public slots:
|
||||||
|
void setComics(QList<Comic> comics);
|
||||||
|
void updateComics(QList<Comic> comics);
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
void setCover(const QPixmap & cover);
|
void setCover(const QPixmap & cover);
|
||||||
void setFilename(const QString & name);
|
void setFilename(const QString & name);
|
||||||
void setNumpages(int pages);
|
void setNumpages(int pages);
|
||||||
|
BIN
images/editComic.png
Normal file
BIN
images/editComic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
BIN
images/importCover.png
Normal file
BIN
images/importCover.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
images/selectAll.png
Normal file
BIN
images/selectAll.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
Loading…
Reference in New Issue
Block a user