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
|
||||||
@ -189,4 +217,9 @@ void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
|||||||
//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);
|
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>
|
||||||
@ -19,7 +20,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
LibraryWindow::LibraryWindow()
|
LibraryWindow::LibraryWindow()
|
||||||
:QMainWindow(),skip(0),fullscreen(false),fetching(false)
|
:QMainWindow(),skip(0),fullscreen(false),fetching(false)
|
||||||
{
|
{
|
||||||
setupUI();
|
setupUI();
|
||||||
loadLibraries();
|
loadLibraries();
|
||||||
@ -27,24 +28,28 @@ 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
|
||||||
optionsDialog = new OptionsDialog(this);
|
optionsDialog = new OptionsDialog(this);
|
||||||
optionsDialog->restoreOptions();
|
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);
|
||||||
@ -83,19 +88,19 @@ void LibraryWindow::setupUI()
|
|||||||
treeActions->setIconSize(QSize(16,16));
|
treeActions->setIconSize(QSize(16,16));
|
||||||
l->addWidget(treeActions);
|
l->addWidget(treeActions);
|
||||||
l->addWidget(foldersView);
|
l->addWidget(foldersView);
|
||||||
|
|
||||||
QVBoxLayout * searchLayout = new QVBoxLayout;
|
QVBoxLayout * searchLayout = new QVBoxLayout;
|
||||||
|
|
||||||
QHBoxLayout * filter = new QHBoxLayout;
|
QHBoxLayout * filter = new QHBoxLayout;
|
||||||
filter->addWidget(foldersFilter = new QLineEdit());
|
filter->addWidget(foldersFilter = new QLineEdit());
|
||||||
previousFilter = "";
|
previousFilter = "";
|
||||||
filter->addWidget(clearFoldersFilter = new QPushButton(tr("Clear")));
|
filter->addWidget(clearFoldersFilter = new QPushButton(tr("Clear")));
|
||||||
|
|
||||||
searchLayout->addWidget(new QLabel(tr("Search folders/comics"),this));
|
searchLayout->addWidget(new QLabel(tr("Search folders/comics"),this));
|
||||||
|
|
||||||
searchLayout->addLayout(filter);
|
searchLayout->addLayout(filter);
|
||||||
searchLayout->addWidget(includeComicsCheckBox = new QCheckBox(tr("Include files (slower)"),this));
|
searchLayout->addWidget(includeComicsCheckBox = new QCheckBox(tr("Include files (slower)"),this));
|
||||||
|
|
||||||
l->addLayout(searchLayout);
|
l->addLayout(searchLayout);
|
||||||
l->setSpacing(1);
|
l->setSpacing(1);
|
||||||
left->setLayout(l);
|
left->setLayout(l);
|
||||||
@ -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()
|
||||||
@ -219,19 +212,19 @@ void LibraryWindow::createActions()
|
|||||||
openComicAction->setToolTip(tr("Open current comic on YACReader"));
|
openComicAction->setToolTip(tr("Open current comic on YACReader"));
|
||||||
openComicAction->setShortcut(Qt::Key_Return);
|
openComicAction->setShortcut(Qt::Key_Return);
|
||||||
openComicAction->setIcon(QIcon(":/images/icon.png"));
|
openComicAction->setIcon(QIcon(":/images/icon.png"));
|
||||||
|
|
||||||
setAsReadAction = new QAction(tr("Set as read"),this);
|
setAsReadAction = new QAction(tr("Set as read"),this);
|
||||||
setAsReadAction->setToolTip(tr("Set comic as read"));
|
setAsReadAction->setToolTip(tr("Set comic as read"));
|
||||||
setAsReadAction->setIcon(QIcon(":/images/setRead.png"));
|
setAsReadAction->setIcon(QIcon(":/images/setRead.png"));
|
||||||
|
|
||||||
setAsNonReadAction = new QAction(tr("Set as unread"),this);
|
setAsNonReadAction = new QAction(tr("Set as unread"),this);
|
||||||
setAsNonReadAction->setToolTip(tr("Set comic as unread"));
|
setAsNonReadAction->setToolTip(tr("Set comic as unread"));
|
||||||
setAsNonReadAction->setIcon(QIcon(":/images/setUnread.png"));
|
setAsNonReadAction->setIcon(QIcon(":/images/setUnread.png"));
|
||||||
|
|
||||||
setAllAsReadAction = new QAction(tr("Set all as read"),this);
|
setAllAsReadAction = new QAction(tr("Set all as read"),this);
|
||||||
setAllAsReadAction->setToolTip(tr("Set all comics as read"));
|
setAllAsReadAction->setToolTip(tr("Set all comics as read"));
|
||||||
setAllAsReadAction->setIcon(QIcon(":/images/setAllRead.png"));
|
setAllAsReadAction->setIcon(QIcon(":/images/setAllRead.png"));
|
||||||
|
|
||||||
setAllAsNonReadAction = new QAction(tr("Set all as unread"),this);
|
setAllAsNonReadAction = new QAction(tr("Set all as unread"),this);
|
||||||
setAllAsNonReadAction->setToolTip(tr("Set all comics as unread"));
|
setAllAsNonReadAction->setToolTip(tr("Set all comics as unread"));
|
||||||
setAllAsNonReadAction->setIcon(QIcon(":/images/setAllUnread.png"));
|
setAllAsNonReadAction->setIcon(QIcon(":/images/setAllUnread.png"));
|
||||||
@ -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"));
|
||||||
@ -314,7 +317,7 @@ void LibraryWindow::createToolBars()
|
|||||||
libraryToolBar->addSeparator();
|
libraryToolBar->addSeparator();
|
||||||
libraryToolBar->addAction(openComicAction);
|
libraryToolBar->addAction(openComicAction);
|
||||||
libraryToolBar->addAction(showPropertiesAction);
|
libraryToolBar->addAction(showPropertiesAction);
|
||||||
|
|
||||||
QToolButton * tb = new QToolButton();
|
QToolButton * tb = new QToolButton();
|
||||||
tb->addAction(setAsReadAction);
|
tb->addAction(setAsReadAction);
|
||||||
tb->addAction(setAllAsReadAction);
|
tb->addAction(setAllAsReadAction);
|
||||||
@ -338,7 +341,7 @@ void LibraryWindow::createToolBars()
|
|||||||
libraryToolBar->addWidget(new QToolBarStretch());
|
libraryToolBar->addWidget(new QToolBarStretch());
|
||||||
libraryToolBar->addAction(optionsAction);
|
libraryToolBar->addAction(optionsAction);
|
||||||
libraryToolBar->addAction(helpAboutAction);
|
libraryToolBar->addAction(helpAboutAction);
|
||||||
|
|
||||||
|
|
||||||
libraryToolBar->setMovable(false);
|
libraryToolBar->setMovable(false);
|
||||||
|
|
||||||
@ -352,8 +355,8 @@ void LibraryWindow::createToolBars()
|
|||||||
|
|
||||||
void LibraryWindow::createMenus()
|
void LibraryWindow::createMenus()
|
||||||
{
|
{
|
||||||
comicView->addAction(openContainingFolderComicAction);
|
comicView->addAction(openContainingFolderComicAction);
|
||||||
foldersView->addAction(openContainingFolderAction);
|
foldersView->addAction(openContainingFolderAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::createConnections()
|
void LibraryWindow::createConnections()
|
||||||
@ -375,7 +378,7 @@ void LibraryWindow::createConnections()
|
|||||||
connect(importLibraryDialog,SIGNAL(rejected()),this,SLOT(deleteCurrentLibrary()));
|
connect(importLibraryDialog,SIGNAL(rejected()),this,SLOT(deleteCurrentLibrary()));
|
||||||
connect(packageManager,SIGNAL(imported()),importLibraryDialog,SLOT(hide()));
|
connect(packageManager,SIGNAL(imported()),importLibraryDialog,SLOT(hide()));
|
||||||
connect(packageManager,SIGNAL(imported()),this,SLOT(openLastCreated()));
|
connect(packageManager,SIGNAL(imported()),this,SLOT(openLastCreated()));
|
||||||
|
|
||||||
|
|
||||||
//create and update dialogs
|
//create and update dialogs
|
||||||
connect(createLibraryDialog,SIGNAL(cancelCreate()),this,SLOT(cancelCreating()));
|
connect(createLibraryDialog,SIGNAL(cancelCreate()),this,SLOT(cancelCreating()));
|
||||||
@ -399,7 +402,7 @@ void LibraryWindow::createConnections()
|
|||||||
connect(createLibraryAction,SIGNAL(triggered()),this,SLOT(createLibrary()));
|
connect(createLibraryAction,SIGNAL(triggered()),this,SLOT(createLibrary()));
|
||||||
connect(exportLibraryAction,SIGNAL(triggered()),exportLibraryDialog,SLOT(show()));
|
connect(exportLibraryAction,SIGNAL(triggered()),exportLibraryDialog,SLOT(show()));
|
||||||
connect(importLibraryAction,SIGNAL(triggered()),importLibraryDialog,SLOT(show()));
|
connect(importLibraryAction,SIGNAL(triggered()),importLibraryDialog,SLOT(show()));
|
||||||
|
|
||||||
connect(openLibraryAction,SIGNAL(triggered()),this,SLOT(showAddLibrary()));
|
connect(openLibraryAction,SIGNAL(triggered()),this,SLOT(showAddLibrary()));
|
||||||
connect(showPropertiesAction,SIGNAL(triggered()),this,SLOT(showProperties()));
|
connect(showPropertiesAction,SIGNAL(triggered()),this,SLOT(showProperties()));
|
||||||
connect(setAsReadAction,SIGNAL(triggered()),this,SLOT(setCurrentComicReaded()));
|
connect(setAsReadAction,SIGNAL(triggered()),this,SLOT(setCurrentComicReaded()));
|
||||||
@ -408,7 +411,7 @@ void LibraryWindow::createConnections()
|
|||||||
connect(setAllAsNonReadAction,SIGNAL(triggered()),this,SLOT(setComicsUnreaded()));
|
connect(setAllAsNonReadAction,SIGNAL(triggered()),this,SLOT(setComicsUnreaded()));
|
||||||
|
|
||||||
connect(showHideMarksAction,SIGNAL(toggled(bool)),comicFlow,SLOT(setShowMarks(bool)));
|
connect(showHideMarksAction,SIGNAL(toggled(bool)),comicFlow,SLOT(setShowMarks(bool)));
|
||||||
|
|
||||||
|
|
||||||
connect(updateLibraryAction,SIGNAL(triggered()),this,SLOT(updateLibrary()));
|
connect(updateLibraryAction,SIGNAL(triggered()),this,SLOT(updateLibrary()));
|
||||||
connect(renameLibraryAction,SIGNAL(triggered()),this,SLOT(renameLibrary()));
|
connect(renameLibraryAction,SIGNAL(triggered()),this,SLOT(renameLibrary()));
|
||||||
@ -429,13 +432,13 @@ void LibraryWindow::createConnections()
|
|||||||
connect(clearFoldersFilter,SIGNAL(clicked()),foldersFilter,SLOT(clear()));
|
connect(clearFoldersFilter,SIGNAL(clicked()),foldersFilter,SLOT(clear()));
|
||||||
connect(foldersFilter,SIGNAL(textChanged(QString)),this,SLOT(setFoldersFilter(QString)));
|
connect(foldersFilter,SIGNAL(textChanged(QString)),this,SLOT(setFoldersFilter(QString)));
|
||||||
connect(includeComicsCheckBox,SIGNAL(stateChanged(int)),this,SLOT(searchInFiles(int)));
|
connect(includeComicsCheckBox,SIGNAL(stateChanged(int)),this,SLOT(searchInFiles(int)));
|
||||||
|
|
||||||
//ContextMenus
|
//ContextMenus
|
||||||
connect(openContainingFolderComicAction,SIGNAL(triggered()),this,SLOT(openContainingFolderComic()));
|
connect(openContainingFolderComicAction,SIGNAL(triggered()),this,SLOT(openContainingFolderComic()));
|
||||||
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
|
||||||
{
|
{
|
||||||
@ -566,55 +533,59 @@ void LibraryWindow::loadLibrary(const QString & name)
|
|||||||
|
|
||||||
void LibraryWindow::loadCovers(const QModelIndex & mi)
|
void LibraryWindow::loadCovers(const QModelIndex & mi)
|
||||||
{
|
{
|
||||||
if(foldersFilter->text()!="")
|
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)
|
||||||
{
|
{
|
||||||
openComicAction->setEnabled(true);
|
openComicAction->setEnabled(true);
|
||||||
showPropertiesAction->setEnabled(true);
|
showPropertiesAction->setEnabled(true);
|
||||||
setAsReadAction->setEnabled(true);
|
setAsReadAction->setEnabled(true);
|
||||||
setAsNonReadAction->setEnabled(true);
|
setAsNonReadAction->setEnabled(true);
|
||||||
setAllAsReadAction->setEnabled(true);
|
setAllAsReadAction->setEnabled(true);
|
||||||
setAllAsNonReadAction->setEnabled(true);
|
setAllAsNonReadAction->setEnabled(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
openComicAction->setEnabled(false);
|
openComicAction->setEnabled(false);
|
||||||
showPropertiesAction->setEnabled(false);
|
showPropertiesAction->setEnabled(false);
|
||||||
setAsReadAction->setEnabled(false);
|
setAsReadAction->setEnabled(false);
|
||||||
setAsNonReadAction->setEnabled(false);
|
setAsNonReadAction->setEnabled(false);
|
||||||
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,8 +619,8 @@ 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);
|
||||||
QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+"/YACReader",QStringList() << path);
|
QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+"/YACReader",QStringList() << path);
|
||||||
@ -663,24 +634,18 @@ 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())
|
||||||
path = QDir::cleanPath(dm->filePath(mi));
|
path = QDir::cleanPath(dm->filePath(mi));
|
||||||
else
|
else
|
||||||
path = dm->rootPath();
|
path = dm->rootPath();
|
||||||
|
|
||||||
QDir d(path,"*.jpg");
|
QDir d(path,"*.jpg");
|
||||||
d.setFilter(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
d.setFilter(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
||||||
@ -688,13 +653,13 @@ void LibraryWindow::setComicsReaded()
|
|||||||
int nFiles = list.size();
|
int nFiles = list.size();
|
||||||
for(int i=0;i<nFiles;i++)
|
for(int i=0;i<nFiles;i++)
|
||||||
{
|
{
|
||||||
QFileInfo info = list.at(i);
|
QFileInfo info = list.at(i);
|
||||||
QString filePath = info.absoluteFilePath();
|
QString filePath = info.absoluteFilePath();
|
||||||
QFile f(filePath.remove(filePath.size()-3,3)+"r");
|
QFile f(filePath.remove(filePath.size()-3,3)+"r");
|
||||||
f.open(QIODevice::WriteOnly);
|
f.open(QIODevice::WriteOnly);
|
||||||
f.close();
|
f.close();
|
||||||
comicFlow->markSlide(i);
|
comicFlow->markSlide(i);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
comicFlow->updateMarks();
|
comicFlow->updateMarks();
|
||||||
}
|
}
|
||||||
@ -702,25 +667,25 @@ 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())
|
||||||
path = QDir::cleanPath(dm->filePath(mi));
|
path = QDir::cleanPath(dm->filePath(mi));
|
||||||
else
|
else
|
||||||
path = dm->rootPath();
|
path = dm->rootPath();
|
||||||
|
|
||||||
QDir d(path,"*.jpg");
|
QDir d(path,"*.jpg");
|
||||||
d.setFilter(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
d.setFilter(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
||||||
@ -728,15 +693,15 @@ void LibraryWindow::setComicsUnreaded()
|
|||||||
int nFiles = list.size();
|
int nFiles = list.size();
|
||||||
for(int i=0;i<nFiles;i++)
|
for(int i=0;i<nFiles;i++)
|
||||||
{
|
{
|
||||||
QFileInfo info = list.at(i);
|
QFileInfo info = list.at(i);
|
||||||
QString filePath = info.absoluteFilePath();
|
QString filePath = info.absoluteFilePath();
|
||||||
QFile f(filePath.remove(filePath.size()-3,3)+"r");
|
QFile f(filePath.remove(filePath.size()-3,3)+"r");
|
||||||
f.open(QIODevice::WriteOnly);
|
f.open(QIODevice::WriteOnly);
|
||||||
f.remove();
|
f.remove();
|
||||||
f.close();
|
f.close();
|
||||||
comicFlow->unmarkSlide(i);
|
comicFlow->unmarkSlide(i);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
comicFlow->updateMarks();
|
comicFlow->updateMarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -802,19 +767,19 @@ void LibraryWindow::loadLibraries()
|
|||||||
void LibraryWindow::saveLibraries()
|
void LibraryWindow::saveLibraries()
|
||||||
{
|
{
|
||||||
QFile f(QCoreApplication::applicationDirPath()+"/libraries.yacr");
|
QFile f(QCoreApplication::applicationDirPath()+"/libraries.yacr");
|
||||||
if(!f.open(QIODevice::WriteOnly))
|
if(!f.open(QIODevice::WriteOnly))
|
||||||
{
|
|
||||||
QMessageBox::critical(NULL,tr("Saving libraries file...."),tr("There was a problem saving YACReaderLibrary libraries file. Please, check if you have enough permissions in the YACReader root folder."));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QTextStream txtS(&f);
|
|
||||||
for(QMap<QString,QString>::iterator i = libraries.begin();i!=libraries.end();i++)
|
|
||||||
{
|
{
|
||||||
txtS << i.key() << "\n";
|
QMessageBox::critical(NULL,tr("Saving libraries file...."),tr("There was a problem saving YACReaderLibrary libraries file. Please, check if you have enough permissions in the YACReader root folder."));
|
||||||
txtS << i.value() << "\n";
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QTextStream txtS(&f);
|
||||||
|
for(QMap<QString,QString>::iterator i = libraries.begin();i!=libraries.end();i++)
|
||||||
|
{
|
||||||
|
txtS << i.key() << "\n";
|
||||||
|
txtS << i.value() << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::updateLibrary()
|
void LibraryWindow::updateLibrary()
|
||||||
@ -839,27 +804,27 @@ void LibraryWindow::deleteLibrary()
|
|||||||
QString currentLibrary = selectedLibrary->currentText();
|
QString currentLibrary = selectedLibrary->currentText();
|
||||||
if(QMessageBox::question(this,tr("Are you sure?"),tr("Do you want delete ")+currentLibrary+" library?",QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes)
|
if(QMessageBox::question(this,tr("Are you sure?"),tr("Do you want delete ")+currentLibrary+" library?",QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
deleteCurrentLibrary();
|
deleteCurrentLibrary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::deleteCurrentLibrary()
|
void LibraryWindow::deleteCurrentLibrary()
|
||||||
{
|
{
|
||||||
QString path = libraries.value(selectedLibrary->currentText());
|
QString path = libraries.value(selectedLibrary->currentText());
|
||||||
libraries.remove(selectedLibrary->currentText());
|
libraries.remove(selectedLibrary->currentText());
|
||||||
selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
||||||
selectedLibrary->setCurrentIndex(0);
|
selectedLibrary->setCurrentIndex(0);
|
||||||
path = path+"/.yacreaderlibrary";
|
path = path+"/.yacreaderlibrary";
|
||||||
QDir d(path);
|
QDir d(path);
|
||||||
delTree(d);
|
delTree(d);
|
||||||
d.rmdir(path);
|
d.rmdir(path);
|
||||||
if(libraries.size()==0)//no more libraries avaliable.
|
if(libraries.size()==0)//no more libraries avaliable.
|
||||||
{
|
{
|
||||||
comicView->setModel(NULL);
|
comicView->setModel(NULL);
|
||||||
foldersView->setModel(NULL);
|
foldersView->setModel(NULL);
|
||||||
comicFlow->clear();
|
comicFlow->clear();
|
||||||
}
|
}
|
||||||
saveLibraries();
|
saveLibraries();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::removeLibrary()
|
void LibraryWindow::removeLibrary()
|
||||||
@ -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
|
||||||
{
|
{
|
||||||
@ -962,37 +927,37 @@ void LibraryWindow::toNormal()
|
|||||||
comicFlow->render();
|
comicFlow->render();
|
||||||
comicView->show();
|
comicView->show();
|
||||||
left->show();
|
left->show();
|
||||||
fullScreenToolTip->hide();
|
fullScreenToolTip->hide();
|
||||||
libraryToolBar->show();
|
libraryToolBar->show();
|
||||||
comicFlow->show();
|
comicFlow->show();
|
||||||
|
|
||||||
showMaximized();
|
showMaximized();
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
previousFilter = filter;
|
previousFilter = filter;
|
||||||
if(!filter.isEmpty())
|
if(!filter.isEmpty())
|
||||||
{
|
{
|
||||||
proxyFilter->setFilterRegExp(QRegExp(filter,Qt::CaseInsensitive,QRegExp::FixedString));
|
proxyFilter->setFilterRegExp(QRegExp(filter,Qt::CaseInsensitive,QRegExp::FixedString));
|
||||||
foldersView->expandAll();
|
foldersView->expandAll();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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,11 +59,11 @@ 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;
|
||||||
YACReaderIconProvider fip;
|
YACReaderIconProvider fip;
|
||||||
|
|
||||||
bool fetching;
|
bool fetching;
|
||||||
@ -116,46 +117,54 @@ 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:
|
||||||
void loadLibrary(const QString & path);
|
void loadLibrary(const QString & path);
|
||||||
void loadCovers(const QModelIndex & mi);
|
void loadCovers(const QModelIndex & mi);
|
||||||
void centerComicFlow(const QModelIndex & mi);
|
void centerComicFlow(const QModelIndex & mi);
|
||||||
void updateComicView(int i);
|
void updateComicView(int i);
|
||||||
void openComic();
|
void openComic();
|
||||||
void createLibrary();
|
void createLibrary();
|
||||||
void create(QString source,QString dest, QString name);
|
void create(QString source,QString dest, QString name);
|
||||||
void showAddLibrary();
|
void showAddLibrary();
|
||||||
void openLibrary(QString path, QString name);
|
void openLibrary(QString path, QString name);
|
||||||
void loadLibraries();
|
void loadLibraries();
|
||||||
void saveLibraries();
|
void saveLibraries();
|
||||||
void openLastCreated();
|
void openLastCreated();
|
||||||
void updateLibrary();
|
void updateLibrary();
|
||||||
void deleteLibrary();
|
void deleteLibrary();
|
||||||
void openContainingFolder();
|
void openContainingFolder();
|
||||||
void openContainingFolderComic();
|
void openContainingFolderComic();
|
||||||
void deleteCurrentLibrary();
|
void deleteCurrentLibrary();
|
||||||
void removeLibrary();
|
void removeLibrary();
|
||||||
void renameLibrary();
|
void renameLibrary();
|
||||||
void rename(QString newName);
|
void rename(QString newName);
|
||||||
void cancelCreating();
|
void cancelCreating();
|
||||||
void stopLibraryCreator();
|
void stopLibraryCreator();
|
||||||
void setRootIndex();
|
void setRootIndex();
|
||||||
void toggleFullScreen();
|
void toggleFullScreen();
|
||||||
void toNormal();
|
void toNormal();
|
||||||
void toFullScreen();
|
void toFullScreen();
|
||||||
void setFoldersFilter(QString filter);
|
void setFoldersFilter(QString filter);
|
||||||
void showProperties();
|
void showProperties();
|
||||||
void exportLibrary(QString destPath);
|
void exportLibrary(QString destPath);
|
||||||
void importLibrary(QString clc,QString destPath,QString name);
|
void importLibrary(QString clc,QString destPath,QString name);
|
||||||
void reloadOptions();
|
void reloadOptions();
|
||||||
void updateFoldersView(QString);
|
void updateFoldersView(QString);
|
||||||
void setCurrentComicReaded();
|
void setCurrentComicReaded();
|
||||||
void setCurrentComicUnreaded();
|
void setCurrentComicUnreaded();
|
||||||
void setComicsReaded();
|
void setComicsReaded();
|
||||||
void setComicsUnreaded();
|
void setComicsUnreaded();
|
||||||
void searchInFiles(int);
|
void searchInFiles(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user