mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
loadCovers funcionando....
falta integrar la ordenaci?n sensible al locale...
This commit is contained in:
parent
3533a9ec64
commit
bdef116ad2
@ -29,7 +29,7 @@ ComicFlow::~ComicFlow()
|
|||||||
|
|
||||||
QString ComicFlow::getImagePath() const
|
QString ComicFlow::getImagePath() const
|
||||||
{
|
{
|
||||||
return imagePath;
|
return "";//imagePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ComicFlow::getImageFiles() const
|
QStringList ComicFlow::getImageFiles() const
|
||||||
@ -83,12 +83,12 @@ static QStringList filterImages(const QStringList& files)
|
|||||||
return imageFiles;
|
return imageFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComicFlow::setImagePath(const QString& path)
|
void ComicFlow::setImagePaths(const QStringList& paths)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
imagePath = path;
|
//imagePath = path;
|
||||||
imageFiles = findFiles(path);
|
imageFiles = paths;
|
||||||
imagesLoaded.clear();
|
imagesLoaded.clear();
|
||||||
imagesLoaded.fill(false,imageFiles.size());
|
imagesLoaded.fill(false,imageFiles.size());
|
||||||
numImagesLoaded = 0;
|
numImagesLoaded = 0;
|
||||||
|
@ -20,9 +20,9 @@ public:
|
|||||||
virtual ~ComicFlow();
|
virtual ~ComicFlow();
|
||||||
|
|
||||||
//void render();
|
//void render();
|
||||||
QString getImagePath() const;
|
QString getImagePath() const; //TOTO quitar no se usa
|
||||||
QStringList getImageFiles() const;
|
QStringList getImageFiles() const;
|
||||||
void setImagePath(const QString& path);
|
void setImagePaths(const QStringList& paths);
|
||||||
//bool eventFilter(QObject *target, QEvent *event);
|
//bool eventFilter(QObject *target, QEvent *event);
|
||||||
void keyPressEvent(QKeyEvent* event);
|
void keyPressEvent(QKeyEvent* event);
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ private slots:
|
|||||||
void updateImageData();
|
void updateImageData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString imagePath;
|
//QString imagePath;
|
||||||
QStringList imageFiles;
|
QStringList imageFiles;
|
||||||
QVector<bool> imagesLoaded;
|
QVector<bool> imagesLoaded;
|
||||||
QVector<bool> imagesSetted;
|
QVector<bool> imagesSetted;
|
||||||
|
@ -34,7 +34,7 @@ QSqlDatabase DataBaseManagement::loadDatabase(QString path)
|
|||||||
{
|
{
|
||||||
//TODO check path
|
//TODO check path
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
|
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
|
||||||
db.setDatabaseName(path);
|
db.setDatabaseName(path+"/library.ydb");
|
||||||
if (!db.open()) {
|
if (!db.open()) {
|
||||||
/*QMessageBox::critical( 0, QObject::tr("Cannot open database"),
|
/*QMessageBox::critical( 0, QObject::tr("Cannot open database"),
|
||||||
QObject::tr("Unable to establish a database connection.\n"
|
QObject::tr("Unable to establish a database connection.\n"
|
||||||
|
@ -15,8 +15,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
DataBaseManagement();
|
DataBaseManagement();
|
||||||
TreeModel * newTreeModel(QString path);
|
TreeModel * newTreeModel(QString path);
|
||||||
QSqlDatabase createDatabase(QString name, QString path);
|
static QSqlDatabase createDatabase(QString name, QString path);
|
||||||
QSqlDatabase loadDatabase(QString path);
|
static QSqlDatabase loadDatabase(QString path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -50,10 +50,16 @@
|
|||||||
|
|
||||||
#include "treeitem.h"
|
#include "treeitem.h"
|
||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
|
#include "data_base_management.h"
|
||||||
|
|
||||||
|
TreeModel::TreeModel(QObject *parent)
|
||||||
|
: QAbstractItemModel(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
TreeModel::TreeModel( QSqlQuery &sqlquery, QObject *parent)
|
TreeModel::TreeModel( QSqlQuery &sqlquery, QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent),rootItem(0)
|
||||||
{
|
{
|
||||||
//lo más probable es que el nodo raíz no necesite tener información
|
//lo más probable es que el nodo raíz no necesite tener información
|
||||||
QList<QVariant> rootData;
|
QList<QVariant> rootData;
|
||||||
@ -87,6 +93,9 @@ QVariant TreeModel::data(const QModelIndex &index, int role) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
|
if (role == Qt::DecorationRole)
|
||||||
|
return QVariant(QIcon(":/images/folder.png"));
|
||||||
|
|
||||||
if (role != Qt::DisplayRole)
|
if (role != Qt::DisplayRole)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@ -171,6 +180,25 @@ int TreeModel::rowCount(const QModelIndex &parent) const
|
|||||||
}
|
}
|
||||||
//! [8]
|
//! [8]
|
||||||
|
|
||||||
|
void TreeModel::setupModelData(QString path)
|
||||||
|
{
|
||||||
|
if(rootItem == 0)
|
||||||
|
delete rootItem; //TODO comprobar que se libera bien la memoria
|
||||||
|
|
||||||
|
//inicializar el nodo raí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)
|
||||||
|
rootItem = new TreeItem(rootData);
|
||||||
|
rootItem->id = 0;
|
||||||
|
|
||||||
|
//cargar la base de datos
|
||||||
|
_database = DataBaseManagement::loadDatabase(path);
|
||||||
|
//crear la consulta
|
||||||
|
QSqlQuery selectQuery("select * from folder order by parentId,name",_database);
|
||||||
|
|
||||||
|
setupModelData(selectQuery,rootItem);
|
||||||
|
}
|
||||||
|
|
||||||
void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||||
{
|
{
|
||||||
//64 bits para la primary key, es decir la misma precisión que soporta sqlit 2^64
|
//64 bits para la primary key, es decir la misma precisión que soporta sqlit 2^64
|
||||||
@ -190,3 +218,8 @@ void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
|||||||
items.insert(item->id,item);
|
items.insert(item->id,item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSqlDatabase & TreeModel::getDatabase()
|
||||||
|
{
|
||||||
|
return _database;
|
||||||
|
}
|
@ -45,6 +45,7 @@
|
|||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
#include <QSqlDatabase>
|
||||||
|
|
||||||
class TreeItem;
|
class TreeItem;
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ class TreeModel : public QAbstractItemModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
TreeModel(QObject *parent = 0);
|
||||||
TreeModel( QSqlQuery &sqlquery, QObject *parent = 0);
|
TreeModel( QSqlQuery &sqlquery, QObject *parent = 0);
|
||||||
~TreeModel();
|
~TreeModel();
|
||||||
|
|
||||||
@ -66,11 +68,14 @@ public:
|
|||||||
QModelIndex parent(const QModelIndex &index) const;
|
QModelIndex parent(const QModelIndex &index) const;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
void setupModelData(QString path);
|
||||||
|
QSqlDatabase & getDatabase();
|
||||||
private:
|
private:
|
||||||
void setupModelData( QSqlQuery &sqlquery, TreeItem *parent);
|
void setupModelData( QSqlQuery &sqlquery, TreeItem *parent);
|
||||||
|
|
||||||
TreeItem *rootItem; //el árbol
|
TreeItem *rootItem; //el árbol
|
||||||
|
|
||||||
|
QSqlDatabase _database;
|
||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "library_window.h"
|
#include "library_window.h"
|
||||||
#include "custom_widgets.h"
|
#include "custom_widgets.h"
|
||||||
|
#include "treeitem.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
@ -27,18 +28,22 @@ LibraryWindow::LibraryWindow()
|
|||||||
|
|
||||||
void LibraryWindow::setupUI()
|
void LibraryWindow::setupUI()
|
||||||
{
|
{
|
||||||
createLibraryDialog = new CreateLibraryDialog(this);
|
|
||||||
updateLibraryDialog = new UpdateLibraryDialog(this);
|
|
||||||
renameLibraryDialog = new RenameLibraryDialog(this);
|
|
||||||
propertiesDialog = new PropertiesDialog(this);
|
|
||||||
exportLibraryDialog = new ExportLibraryDialog(this);
|
|
||||||
importLibraryDialog = new ImportLibraryDialog(this);
|
|
||||||
|
|
||||||
libraryCreator = new LibraryCreator();
|
libraryCreator = new LibraryCreator();
|
||||||
packageManager = new PackageManager();
|
packageManager = new PackageManager();
|
||||||
|
|
||||||
addLibraryDialog = new AddLibraryDialog(this);
|
doModels();
|
||||||
|
doLayout();
|
||||||
|
doDialogs();
|
||||||
|
createActions();
|
||||||
|
createToolBars();
|
||||||
|
createMenus();
|
||||||
|
createConnections();
|
||||||
|
|
||||||
|
setWindowTitle(tr("YACReader Library"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LibraryWindow::doLayout()
|
||||||
|
{
|
||||||
QSplitter * sVertical = new QSplitter(Qt::Vertical);
|
QSplitter * sVertical = new QSplitter(Qt::Vertical);
|
||||||
QSplitter * sHorizontal = new QSplitter(Qt::Horizontal);
|
QSplitter * sHorizontal = new QSplitter(Qt::Horizontal);
|
||||||
//TODO: flowType is a global variable
|
//TODO: flowType is a global variable
|
||||||
@ -106,45 +111,35 @@ void LibraryWindow::setupUI()
|
|||||||
sHorizontal->setStretchFactor(1,1);
|
sHorizontal->setStretchFactor(1,1);
|
||||||
setCentralWidget(sHorizontal);
|
setCentralWidget(sHorizontal);
|
||||||
|
|
||||||
//dirmodels
|
|
||||||
dm = new QFileSystemModel();
|
|
||||||
dm->setFilter(QDir::Dirs|QDir::NoDotAndDotDot);
|
|
||||||
dm->sort(0);//,QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
|
||||||
dmCV = new QFileSystemModel();
|
|
||||||
dmCV->setNameFilters(QStringList() << "*jpg");
|
|
||||||
dmCV->setFilter(QDir::Files|QDir::CaseSensitive|QDir::NoDotAndDotDot);//,QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
|
||||||
dmCV->setNameFilterDisables(true);
|
|
||||||
|
|
||||||
dm->setReadOnly(true);
|
|
||||||
//dm->setLazyChildCount(false);
|
|
||||||
dmCV->setReadOnly(true);
|
|
||||||
|
|
||||||
dm->setIconProvider(&fip);
|
|
||||||
dmCV->setIconProvider(&fip);
|
|
||||||
//dmCV->sort(1);
|
|
||||||
|
|
||||||
proxyFilter = new YACReaderTreeSearch();
|
|
||||||
proxyFilter->setSourceModel(dm);
|
|
||||||
proxyFilter->setFilterRole(Qt::DisplayRole);
|
|
||||||
|
|
||||||
/*proxySort = new YACReaderSortComics();
|
|
||||||
proxySort->setSourceModel(dmCV);
|
|
||||||
proxySort->setFilterRole(Qt::DisplayRole);*/
|
|
||||||
|
|
||||||
//views
|
//views
|
||||||
foldersView->header()->hideSection(1);
|
|
||||||
foldersView->header()->hideSection(2);
|
|
||||||
foldersView->header()->hideSection(3);
|
|
||||||
foldersView->header()->adjustSize();
|
|
||||||
foldersView->header()->hide();
|
|
||||||
foldersView->setAnimated(true);
|
foldersView->setAnimated(true);
|
||||||
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
|
||||||
comicView->setAlternatingRowColors(true);
|
comicView->setAlternatingRowColors(true);
|
||||||
comicView->setItemDelegate(new YACReaderComicViewDelegate());
|
//comicView->setItemDelegate(new YACReaderComicViewDelegate());
|
||||||
comicView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
comicView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
|
||||||
|
fullScreenToolTip = new QLabel(this);
|
||||||
|
fullScreenToolTip->setText(tr("<font color='white'> press 'F' to close fullscreen mode </font>"));
|
||||||
|
fullScreenToolTip->setPalette(QPalette(QColor(0,0,0)));
|
||||||
|
fullScreenToolTip->setFont(QFont("courier new",15,234));
|
||||||
|
fullScreenToolTip->setAutoFillBackground(true);
|
||||||
|
fullScreenToolTip->hide();
|
||||||
|
fullScreenToolTip->adjustSize();
|
||||||
|
|
||||||
|
comicFlow->setFocus(Qt::OtherFocusReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LibraryWindow::doDialogs()
|
||||||
|
{
|
||||||
|
createLibraryDialog = new CreateLibraryDialog(this);
|
||||||
|
updateLibraryDialog = new UpdateLibraryDialog(this);
|
||||||
|
renameLibraryDialog = new RenameLibraryDialog(this);
|
||||||
|
propertiesDialog = new PropertiesDialog(this);
|
||||||
|
exportLibraryDialog = new ExportLibraryDialog(this);
|
||||||
|
importLibraryDialog = new ImportLibraryDialog(this);
|
||||||
|
addLibraryDialog = new AddLibraryDialog(this);
|
||||||
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())
|
||||||
@ -156,25 +151,23 @@ void LibraryWindow::setupUI()
|
|||||||
had->loadHelp(":/files/helpYACReaderLibrary_"+sufix+".html");
|
had->loadHelp(":/files/helpYACReaderLibrary_"+sufix+".html");
|
||||||
else
|
else
|
||||||
had->loadHelp(":/files/helpYACReaderLibrary.html");
|
had->loadHelp(":/files/helpYACReaderLibrary.html");
|
||||||
|
}
|
||||||
|
|
||||||
fullScreenToolTip = new QLabel(this);
|
void LibraryWindow::doModels()
|
||||||
fullScreenToolTip->setText(tr("<font color='white'> press 'F' to close fullscreen mode </font>"));
|
{
|
||||||
fullScreenToolTip->setPalette(QPalette(QColor(0,0,0)));
|
//dirmodels
|
||||||
fullScreenToolTip->setFont(QFont("courier new",15,234));
|
dm = new TreeModel();
|
||||||
fullScreenToolTip->setAutoFillBackground(true);
|
dmCV = new QSqlQueryModel();
|
||||||
fullScreenToolTip->hide();
|
|
||||||
fullScreenToolTip->adjustSize();
|
|
||||||
|
|
||||||
createActions();
|
|
||||||
createToolBars();
|
|
||||||
createMenus();
|
|
||||||
createConnections();
|
|
||||||
|
|
||||||
|
/*proxyFilter = new YACReaderTreeSearch();
|
||||||
|
proxyFilter->setSourceModel(dm);
|
||||||
|
proxyFilter->setFilterRole(Qt::DisplayRole);*/
|
||||||
|
|
||||||
|
/*proxySort = new YACReaderSortComics();
|
||||||
|
proxySort->setSourceModel(dmCV);
|
||||||
|
proxySort->setFilterRole(Qt::DisplayRole);*/
|
||||||
setFoldersFilter("");
|
setFoldersFilter("");
|
||||||
|
|
||||||
comicFlow->setFocus(Qt::OtherFocusReason);
|
|
||||||
|
|
||||||
setWindowTitle(tr("YACReader Library"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::createActions()
|
void LibraryWindow::createActions()
|
||||||
@ -296,6 +289,16 @@ void LibraryWindow::createActions()
|
|||||||
openContainingFolderComicAction->setIcon(QIcon(":/images/open.png"));
|
openContainingFolderComicAction->setIcon(QIcon(":/images/open.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LibraryWindow::disableActions()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void LibraryWindow::enableActions()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void LibraryWindow::enableLibraryActions()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void LibraryWindow::createToolBars()
|
void LibraryWindow::createToolBars()
|
||||||
{
|
{
|
||||||
libraryToolBar = addToolBar(tr("Library"));
|
libraryToolBar = addToolBar(tr("Library"));
|
||||||
@ -435,7 +438,7 @@ void LibraryWindow::createConnections()
|
|||||||
connect(openContainingFolderAction,SIGNAL(triggered()),this,SLOT(openContainingFolder()));
|
connect(openContainingFolderAction,SIGNAL(triggered()),this,SLOT(openContainingFolder()));
|
||||||
|
|
||||||
//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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::loadLibrary(const QString & name)
|
void LibraryWindow::loadLibrary(const QString & name)
|
||||||
@ -446,57 +449,10 @@ void LibraryWindow::loadLibrary(const QString & name)
|
|||||||
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
||||||
if(d.exists(path))
|
if(d.exists(path))
|
||||||
{
|
{
|
||||||
//renew dirmodels (because QFileSystemModel is.......crap ;) )
|
TreeModel * oldTM = dm;
|
||||||
QFileSystemModel * oldDm = dm;
|
dm = new TreeModel();
|
||||||
QFileSystemModel * oldDmCV = dmCV;
|
dm->setupModelData(path);
|
||||||
YACReaderTreeSearch * oldTreeSearch = proxyFilter;
|
foldersView->setModel(dm);
|
||||||
//YACReaderSortComics * oldSortProxy = proxySort;
|
|
||||||
|
|
||||||
dm = new QFileSystemModel();
|
|
||||||
dm->setFilter(QDir::Dirs|QDir::NoDotAndDotDot);
|
|
||||||
dm->sort(0);//,QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
|
||||||
dmCV = new QFileSystemModel();
|
|
||||||
dmCV->setNameFilters(QStringList() << "*jpg");
|
|
||||||
dmCV->setFilter(QDir::Files|QDir::CaseSensitive|QDir::NoDotAndDotDot);//,QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
|
||||||
dmCV->setNameFilterDisables(true);
|
|
||||||
|
|
||||||
dm->setReadOnly(true);
|
|
||||||
//dm->setLazyChildCount(false);
|
|
||||||
dmCV->setReadOnly(true);
|
|
||||||
|
|
||||||
dm->setIconProvider(&fip);
|
|
||||||
dmCV->setIconProvider(&fip);
|
|
||||||
//dmCV->sort(1);
|
|
||||||
|
|
||||||
proxyFilter = new YACReaderTreeSearch();
|
|
||||||
proxyFilter->setSourceModel(dm);
|
|
||||||
proxyFilter->setFilterRole(Qt::DisplayRole);
|
|
||||||
|
|
||||||
/*proxySort = new YACReaderSortComics();
|
|
||||||
proxySort->setSourceModel(dmCV);
|
|
||||||
proxySort->setFilterRole(Qt::DisplayRole);*/
|
|
||||||
|
|
||||||
connect(dm,SIGNAL(directoryLoaded(QString)),this,SLOT(updateFoldersView(QString)));
|
|
||||||
|
|
||||||
includeComicsCheckBox->setCheckState(Qt::Unchecked);
|
|
||||||
|
|
||||||
if(oldDm !=0)
|
|
||||||
delete oldDm;
|
|
||||||
if(oldDmCV !=0)
|
|
||||||
delete oldDmCV;
|
|
||||||
if(oldTreeSearch !=0)
|
|
||||||
delete oldTreeSearch;
|
|
||||||
/*if(oldSortProxy !=0)
|
|
||||||
delete oldSortProxy;*/
|
|
||||||
//end renew dirmodels
|
|
||||||
//TODO review this code, some sentences could be not necessary
|
|
||||||
foldersView->setModel(proxyFilter);
|
|
||||||
comicView->setModel(dmCV);
|
|
||||||
_rootIndex = dm->setRootPath(path);
|
|
||||||
i=0;
|
|
||||||
|
|
||||||
comicView->setRootIndex(dmCV->setRootPath(path));
|
|
||||||
foldersView->setRootIndex(proxyFilter->mapFromSource(_rootIndex));//dm->setRootPath(path)));
|
|
||||||
|
|
||||||
foldersView->header()->hideSection(1);
|
foldersView->header()->hideSection(1);
|
||||||
foldersView->header()->hideSection(2);
|
foldersView->header()->hideSection(2);
|
||||||
@ -504,9 +460,20 @@ void LibraryWindow::loadLibrary(const QString & name)
|
|||||||
foldersView->header()->adjustSize();
|
foldersView->header()->adjustSize();
|
||||||
foldersView->header()->hide();
|
foldersView->header()->hide();
|
||||||
|
|
||||||
loadCovers(proxyFilter->mapFromSource(dm->index(path)));
|
loadCovers(QModelIndex());
|
||||||
|
|
||||||
|
/*proxyFilter = new YACReaderTreeSearch();
|
||||||
|
proxyFilter->setSourceModel(dm);
|
||||||
|
proxyFilter->setFilterRole(Qt::DisplayRole);*/
|
||||||
|
|
||||||
|
//connect(dm,SIGNAL(directoryLoaded(QString)),this,SLOT(updateFoldersView(QString)));
|
||||||
|
|
||||||
|
includeComicsCheckBox->setCheckState(Qt::Unchecked);
|
||||||
|
|
||||||
//foldersView->expandAll();
|
//foldersView->expandAll();
|
||||||
|
|
||||||
|
/*if(oldTM!=0)
|
||||||
|
delete oldTM;*/ //TODO corregir error al liberar memoria
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -571,27 +538,32 @@ if(foldersFilter->text()!="")
|
|||||||
setFoldersFilter("");
|
setFoldersFilter("");
|
||||||
foldersFilter->clear();
|
foldersFilter->clear();
|
||||||
}
|
}
|
||||||
QString path = dm->filePath(proxyFilter->mapToSource(mi));
|
unsigned long long int folderId = 0;
|
||||||
delete dmCV;
|
if(mi.isValid())
|
||||||
dmCV = new QFileSystemModel();
|
{
|
||||||
dmCV->setFilter(QDir::Files|QDir::CaseSensitive|QDir::NoDotAndDotDot);
|
TreeItem *item = static_cast<TreeItem*>(mi.internalPointer());
|
||||||
dmCV->setNameFilters(QStringList() << "*jpg");
|
folderId = item->id;
|
||||||
dmCV->setNameFilterDisables(false);
|
}
|
||||||
dmCV->setReadOnly(true);
|
QSqlQuery selectQuery(dm->getDatabase()); //TODO check
|
||||||
|
selectQuery.prepare("select fileName from comic where comic.parentId = :parentId");
|
||||||
dmCV->setIconProvider(&fip);
|
selectQuery.bindValue(":parentId", folderId);
|
||||||
//dmCV->sort(1);
|
selectQuery.exec();
|
||||||
//delete proxySort;
|
dmCV->setQuery(selectQuery);
|
||||||
|
|
||||||
//TODO
|
|
||||||
/*proxySort = new YACReaderSortComics();
|
|
||||||
proxySort->setSourceModel(dmCV);
|
|
||||||
proxySort->setFilterRole(Qt::DisplayRole);*/
|
|
||||||
|
|
||||||
comicView->setModel(dmCV);
|
comicView->setModel(dmCV);
|
||||||
comicView->setRootIndex(dmCV->setRootPath(path));
|
//TODO
|
||||||
|
QSqlQuery selectQueryPaths(dm->getDatabase()); //TODO check
|
||||||
|
selectQueryPaths.prepare("select ci.hash from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId");
|
||||||
|
selectQueryPaths.bindValue(":parentId", folderId);
|
||||||
|
selectQueryPaths.exec();
|
||||||
|
QStringList paths;
|
||||||
|
QString currentLibrary = selectedLibrary->currentText();
|
||||||
|
QString path = libraries.value(currentLibrary);
|
||||||
|
path = path + "/.yacreaderlibrary/covers/";
|
||||||
|
while (selectQueryPaths.next()) {
|
||||||
|
paths << path+selectQueryPaths.value(0).toString()+".jpg";
|
||||||
|
}
|
||||||
|
|
||||||
comicFlow->setImagePath(path);
|
comicFlow->setImagePaths(paths);
|
||||||
comicFlow->setFocus(Qt::OtherFocusReason);
|
comicFlow->setFocus(Qt::OtherFocusReason);
|
||||||
paths = comicFlow->getImageFiles();
|
paths = comicFlow->getImageFiles();
|
||||||
if(paths.size()>0 && !importedCovers)
|
if(paths.size()>0 && !importedCovers)
|
||||||
@ -612,9 +584,8 @@ if(foldersFilter->text()!="")
|
|||||||
setAllAsReadAction->setEnabled(false);
|
setAllAsReadAction->setEnabled(false);
|
||||||
setAllAsNonReadAction->setEnabled(false);
|
setAllAsNonReadAction->setEnabled(false);
|
||||||
}
|
}
|
||||||
if(paths.size()>0)
|
/*if(paths.size()>0)
|
||||||
comicView->setCurrentIndex(dmCV->index(paths[0]));
|
comicView->setCurrentIndex(dmCV->index(paths[0]));*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::centerComicFlow(const QModelIndex & mi)
|
void LibraryWindow::centerComicFlow(const QModelIndex & mi)
|
||||||
@ -637,8 +608,8 @@ void LibraryWindow::centerComicFlow(const QModelIndex & mi)
|
|||||||
void LibraryWindow::updateComicView(int i)
|
void LibraryWindow::updateComicView(int i)
|
||||||
{
|
{
|
||||||
|
|
||||||
if((paths.size()>0)&&skip==0)
|
/*if((paths.size()>0)&&skip==0)
|
||||||
comicView->setCurrentIndex(dmCV->index(paths[i]));
|
comicView->setCurrentIndex(dmCV->index(paths[i]));*/
|
||||||
skip?(--skip):0;
|
skip?(--skip):0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,7 +619,7 @@ void LibraryWindow::openComic()
|
|||||||
if(!importedCovers)
|
if(!importedCovers)
|
||||||
{
|
{
|
||||||
QModelIndex mi = comicView->currentIndex();
|
QModelIndex mi = comicView->currentIndex();
|
||||||
QString path = QDir::cleanPath(dmCV->filePath(mi));
|
QString path;// = QDir::cleanPath(dmCV->filePath(mi));
|
||||||
|
|
||||||
path.remove("/.yacreaderlibrary");
|
path.remove("/.yacreaderlibrary");
|
||||||
path.remove(path.size()-4,4);
|
path.remove(path.size()-4,4);
|
||||||
@ -663,18 +634,12 @@ void LibraryWindow::openComic()
|
|||||||
void LibraryWindow::setCurrentComicReaded()
|
void LibraryWindow::setCurrentComicReaded()
|
||||||
{
|
{
|
||||||
comicFlow->markSlide(comicFlow->centerIndex());
|
comicFlow->markSlide(comicFlow->centerIndex());
|
||||||
QModelIndex mi = comicView->currentIndex();
|
|
||||||
QString path = QDir::cleanPath(dmCV->filePath(mi));
|
|
||||||
QFile f(path.remove(path.size()-3,3)+"r");
|
|
||||||
f.open(QIODevice::WriteOnly);
|
|
||||||
f.close();
|
|
||||||
|
|
||||||
comicFlow->updateMarks();
|
comicFlow->updateMarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::setComicsReaded()
|
void LibraryWindow::setComicsReaded()
|
||||||
{
|
{
|
||||||
QModelIndex mi = proxyFilter->mapToSource(foldersView->currentIndex());
|
/*QModelIndex mi = proxyFilter->mapToSource(foldersView->currentIndex());
|
||||||
QString path;
|
QString path;
|
||||||
|
|
||||||
if(mi.isValid())
|
if(mi.isValid())
|
||||||
@ -694,7 +659,7 @@ void LibraryWindow::setComicsReaded()
|
|||||||
f.open(QIODevice::WriteOnly);
|
f.open(QIODevice::WriteOnly);
|
||||||
f.close();
|
f.close();
|
||||||
comicFlow->markSlide(i);
|
comicFlow->markSlide(i);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
comicFlow->updateMarks();
|
comicFlow->updateMarks();
|
||||||
}
|
}
|
||||||
@ -702,19 +667,19 @@ void LibraryWindow::setComicsReaded()
|
|||||||
void LibraryWindow::setCurrentComicUnreaded()
|
void LibraryWindow::setCurrentComicUnreaded()
|
||||||
{
|
{
|
||||||
comicFlow->unmarkSlide(comicFlow->centerIndex());
|
comicFlow->unmarkSlide(comicFlow->centerIndex());
|
||||||
QModelIndex mi = comicView->currentIndex();
|
/*QModelIndex mi = comicView->currentIndex();
|
||||||
QString path = QDir::cleanPath(dmCV->filePath(mi));
|
QString path = QDir::cleanPath(dmCV->filePath(mi));
|
||||||
QFile f(path.remove(path.size()-3,3)+"r");
|
QFile f(path.remove(path.size()-3,3)+"r");
|
||||||
f.open(QIODevice::WriteOnly);
|
f.open(QIODevice::WriteOnly);
|
||||||
f.remove();
|
f.remove();
|
||||||
f.close();
|
f.close();*/
|
||||||
|
|
||||||
comicFlow->updateMarks();
|
comicFlow->updateMarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::setComicsUnreaded()
|
void LibraryWindow::setComicsUnreaded()
|
||||||
{
|
{
|
||||||
QModelIndex mi = proxyFilter->mapToSource(foldersView->currentIndex());
|
/*QModelIndex mi = proxyFilter->mapToSource(foldersView->currentIndex());
|
||||||
QString path;
|
QString path;
|
||||||
|
|
||||||
if(mi.isValid())
|
if(mi.isValid())
|
||||||
@ -736,7 +701,7 @@ void LibraryWindow::setComicsUnreaded()
|
|||||||
f.close();
|
f.close();
|
||||||
comicFlow->unmarkSlide(i);
|
comicFlow->unmarkSlide(i);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
comicFlow->updateMarks();
|
comicFlow->updateMarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -918,8 +883,8 @@ void LibraryWindow::setRootIndex()
|
|||||||
if(d.exists(path))
|
if(d.exists(path))
|
||||||
{
|
{
|
||||||
//dmCV->refresh(dmCV->index(path));
|
//dmCV->refresh(dmCV->index(path));
|
||||||
comicView->setRootIndex(dmCV->index(path));
|
/*comicView->setRootIndex(dmCV->index(path));
|
||||||
loadCovers(proxyFilter->mapFromSource(dm->index(path)));
|
loadCovers(proxyFilter->mapFromSource(dm->index(path)));*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -971,7 +936,7 @@ void LibraryWindow::toNormal()
|
|||||||
|
|
||||||
void LibraryWindow::setFoldersFilter(QString filter)
|
void LibraryWindow::setFoldersFilter(QString filter)
|
||||||
{
|
{
|
||||||
if(filter.contains(previousFilter))
|
/*if(filter.contains(previousFilter))
|
||||||
proxyFilter->softReset();
|
proxyFilter->softReset();
|
||||||
else
|
else
|
||||||
proxyFilter->reset();
|
proxyFilter->reset();
|
||||||
@ -986,13 +951,13 @@ void LibraryWindow::setFoldersFilter(QString filter)
|
|||||||
proxyFilter->setFilterRegExp(QRegExp());
|
proxyFilter->setFilterRegExp(QRegExp());
|
||||||
foldersView->scrollTo(foldersView->currentIndex(),QAbstractItemView::PositionAtTop);
|
foldersView->scrollTo(foldersView->currentIndex(),QAbstractItemView::PositionAtTop);
|
||||||
foldersView->collapseAll();
|
foldersView->collapseAll();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::showProperties()
|
void LibraryWindow::showProperties()
|
||||||
{
|
{
|
||||||
//TODO create a new method for this
|
//TODO create a new method for this
|
||||||
QModelIndex mi = comicView->currentIndex();
|
/*QModelIndex mi = comicView->currentIndex();
|
||||||
QString path = QDir::cleanPath(dmCV->filePath(mi)).remove("/.yacreaderlibrary");
|
QString path = QDir::cleanPath(dmCV->filePath(mi)).remove("/.yacreaderlibrary");
|
||||||
path.remove(path.size()-4,4);
|
path.remove(path.size()-4,4);
|
||||||
|
|
||||||
@ -1004,21 +969,21 @@ void LibraryWindow::showProperties()
|
|||||||
QFile file(path);
|
QFile file(path);
|
||||||
propertiesDialog->setSize(file.size()/(1024.0*1024));
|
propertiesDialog->setSize(file.size()/(1024.0*1024));
|
||||||
file.close();
|
file.close();
|
||||||
propertiesDialog->show();
|
propertiesDialog->show();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::openContainingFolderComic()
|
void LibraryWindow::openContainingFolderComic()
|
||||||
{
|
{
|
||||||
QModelIndex modelIndex = comicView->currentIndex();
|
QModelIndex modelIndex = comicView->currentIndex();
|
||||||
QString path = QDir::cleanPath(dmCV->fileInfo(modelIndex).absolutePath()).remove("/.yacreaderlibrary");
|
//QString path = QDir::cleanPath(dmCV->fileInfo(modelIndex).absolutePath()).remove("/.yacreaderlibrary");
|
||||||
QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode));
|
//QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::openContainingFolder()
|
void LibraryWindow::openContainingFolder()
|
||||||
{
|
{
|
||||||
QModelIndex modelIndex = foldersView->currentIndex();
|
QModelIndex modelIndex = foldersView->currentIndex();
|
||||||
QString path = QDir::cleanPath(dm->filePath(proxyFilter->mapToSource(modelIndex))).remove("/.yacreaderlibrary");
|
//QString path = QDir::cleanPath(dm->filePath(proxyFilter->mapToSource(modelIndex))).remove("/.yacreaderlibrary");
|
||||||
QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode));
|
//QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::exportLibrary(QString destPath)
|
void LibraryWindow::exportLibrary(QString destPath)
|
||||||
@ -1041,20 +1006,20 @@ void LibraryWindow::reloadOptions()
|
|||||||
|
|
||||||
void LibraryWindow::updateFoldersView(QString path)
|
void LibraryWindow::updateFoldersView(QString path)
|
||||||
{
|
{
|
||||||
QModelIndex mi = dm->index(path);
|
//QModelIndex mi = dm->index(path);
|
||||||
int rowCount = dm->rowCount(mi);
|
//int rowCount = dm->rowCount(mi);
|
||||||
if(!fetching)
|
//if(!fetching)
|
||||||
{
|
//{
|
||||||
//fetching = true;
|
// //fetching = true;
|
||||||
for(int i=0;i<rowCount;i++)
|
// for(int i=0;i<rowCount;i++)
|
||||||
{
|
// {
|
||||||
dm->fetchMore(dm->index(i,0,mi));
|
// dm->fetchMore(dm->index(i,0,mi));
|
||||||
//int childCount = dm->rowCount(dm->index(i,0,mi));
|
// //int childCount = dm->rowCount(dm->index(i,0,mi));
|
||||||
//if(childCount>0)
|
// //if(childCount>0)
|
||||||
// QMessageBox::critical(NULL,tr("..."),tr("-----"));
|
// // QMessageBox::critical(NULL,tr("..."),tr("-----"));
|
||||||
fetching = false;
|
// fetching = false;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1063,11 +1028,11 @@ void LibraryWindow::searchInFiles(int state)
|
|||||||
|
|
||||||
if(state == Qt::Checked)
|
if(state == Qt::Checked)
|
||||||
{
|
{
|
||||||
dm->setFilter(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot); //crash, after update proxy filter
|
//dm->setFilter(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot); //crash, after update proxy filter
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dm->setFilter(QDir::Dirs|QDir::NoDotAndDotDot); //crash
|
//dm->setFilter(QDir::Dirs|QDir::NoDotAndDotDot); //crash
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QFileInfoList>
|
#include <QFileInfoList>
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
|
#include <QSqlQueryModel>
|
||||||
|
|
||||||
#include "create_library_dialog.h"
|
#include "create_library_dialog.h"
|
||||||
#include "add_library_dialog.h"
|
#include "add_library_dialog.h"
|
||||||
@ -24,7 +25,7 @@
|
|||||||
#include "export_library_dialog.h"
|
#include "export_library_dialog.h"
|
||||||
#include "import_library_dialog.h"
|
#include "import_library_dialog.h"
|
||||||
#include "package_manager.h"
|
#include "package_manager.h"
|
||||||
|
#include "treemodel.h"
|
||||||
|
|
||||||
class LibraryWindow : public QMainWindow
|
class LibraryWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
@ -58,8 +59,8 @@ private:
|
|||||||
QListView * comicView;
|
QListView * comicView;
|
||||||
QTreeView * foldersView;
|
QTreeView * foldersView;
|
||||||
QComboBox * selectedLibrary;
|
QComboBox * selectedLibrary;
|
||||||
QFileSystemModel * dm;
|
TreeModel * dm;
|
||||||
QFileSystemModel * dmCV;
|
QSqlQueryModel * dmCV;
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
QMap<QString,QString> libraries;
|
QMap<QString,QString> libraries;
|
||||||
QLabel * fullScreenToolTip;
|
QLabel * fullScreenToolTip;
|
||||||
@ -116,6 +117,14 @@ private:
|
|||||||
void createToolBars();
|
void createToolBars();
|
||||||
void createMenus();
|
void createMenus();
|
||||||
void createConnections();
|
void createConnections();
|
||||||
|
void doLayout();
|
||||||
|
void doDialogs();
|
||||||
|
void doModels();
|
||||||
|
|
||||||
|
void disableActions();
|
||||||
|
void enableActions();
|
||||||
|
void enableLibraryActions();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LibraryWindow();
|
LibraryWindow();
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user