mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 00:58:32 -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
|
||||
{
|
||||
return imagePath;
|
||||
return "";//imagePath;
|
||||
}
|
||||
|
||||
QStringList ComicFlow::getImageFiles() const
|
||||
@ -83,12 +83,12 @@ static QStringList filterImages(const QStringList& files)
|
||||
return imageFiles;
|
||||
}
|
||||
|
||||
void ComicFlow::setImagePath(const QString& path)
|
||||
void ComicFlow::setImagePaths(const QStringList& paths)
|
||||
{
|
||||
clear();
|
||||
|
||||
imagePath = path;
|
||||
imageFiles = findFiles(path);
|
||||
//imagePath = path;
|
||||
imageFiles = paths;
|
||||
imagesLoaded.clear();
|
||||
imagesLoaded.fill(false,imageFiles.size());
|
||||
numImagesLoaded = 0;
|
||||
|
@ -20,9 +20,9 @@ public:
|
||||
virtual ~ComicFlow();
|
||||
|
||||
//void render();
|
||||
QString getImagePath() const;
|
||||
QString getImagePath() const; //TOTO quitar no se usa
|
||||
QStringList getImageFiles() const;
|
||||
void setImagePath(const QString& path);
|
||||
void setImagePaths(const QStringList& paths);
|
||||
//bool eventFilter(QObject *target, QEvent *event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
@ -31,7 +31,7 @@ private slots:
|
||||
void updateImageData();
|
||||
|
||||
private:
|
||||
QString imagePath;
|
||||
//QString imagePath;
|
||||
QStringList imageFiles;
|
||||
QVector<bool> imagesLoaded;
|
||||
QVector<bool> imagesSetted;
|
||||
|
@ -34,7 +34,7 @@ QSqlDatabase DataBaseManagement::loadDatabase(QString path)
|
||||
{
|
||||
//TODO check path
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
db.setDatabaseName(path);
|
||||
db.setDatabaseName(path+"/library.ydb");
|
||||
if (!db.open()) {
|
||||
/*QMessageBox::critical( 0, QObject::tr("Cannot open database"),
|
||||
QObject::tr("Unable to establish a database connection.\n"
|
||||
|
@ -15,8 +15,8 @@ private:
|
||||
public:
|
||||
DataBaseManagement();
|
||||
TreeModel * newTreeModel(QString path);
|
||||
QSqlDatabase createDatabase(QString name, QString path);
|
||||
QSqlDatabase loadDatabase(QString path);
|
||||
static QSqlDatabase createDatabase(QString name, QString path);
|
||||
static QSqlDatabase loadDatabase(QString path);
|
||||
};
|
||||
|
||||
#endif
|
@ -50,10 +50,16 @@
|
||||
|
||||
#include "treeitem.h"
|
||||
#include "treemodel.h"
|
||||
#include "data_base_management.h"
|
||||
|
||||
TreeModel::TreeModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
//! [0]
|
||||
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
|
||||
QList<QVariant> rootData;
|
||||
@ -87,6 +93,9 @@ QVariant TreeModel::data(const QModelIndex &index, int role) const
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DecorationRole)
|
||||
return QVariant(QIcon(":/images/folder.png"));
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
@ -171,6 +180,25 @@ int TreeModel::rowCount(const QModelIndex &parent) const
|
||||
}
|
||||
//! [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)
|
||||
{
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
QSqlDatabase & TreeModel::getDatabase()
|
||||
{
|
||||
return _database;
|
||||
}
|
@ -45,6 +45,7 @@
|
||||
#include <QModelIndex>
|
||||
#include <QVariant>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlDatabase>
|
||||
|
||||
class TreeItem;
|
||||
|
||||
@ -54,6 +55,7 @@ class TreeModel : public QAbstractItemModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TreeModel(QObject *parent = 0);
|
||||
TreeModel( QSqlQuery &sqlquery, QObject *parent = 0);
|
||||
~TreeModel();
|
||||
|
||||
@ -66,11 +68,14 @@ public:
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
void setupModelData(QString path);
|
||||
QSqlDatabase & getDatabase();
|
||||
private:
|
||||
void setupModelData( QSqlQuery &sqlquery, TreeItem *parent);
|
||||
|
||||
TreeItem *rootItem; //el árbol
|
||||
|
||||
QSqlDatabase _database;
|
||||
};
|
||||
//! [0]
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "library_window.h"
|
||||
#include "custom_widgets.h"
|
||||
#include "treeitem.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QSplitter>
|
||||
@ -19,7 +20,7 @@
|
||||
//
|
||||
|
||||
LibraryWindow::LibraryWindow()
|
||||
:QMainWindow(),skip(0),fullscreen(false),fetching(false)
|
||||
:QMainWindow(),skip(0),fullscreen(false),fetching(false)
|
||||
{
|
||||
setupUI();
|
||||
loadLibraries();
|
||||
@ -27,18 +28,22 @@ LibraryWindow::LibraryWindow()
|
||||
|
||||
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();
|
||||
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 * sHorizontal = new QSplitter(Qt::Horizontal);
|
||||
//TODO: flowType is a global variable
|
||||
@ -106,45 +111,35 @@ void LibraryWindow::setupUI()
|
||||
sHorizontal->setStretchFactor(1,1);
|
||||
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
|
||||
foldersView->header()->hideSection(1);
|
||||
foldersView->header()->hideSection(2);
|
||||
foldersView->header()->hideSection(3);
|
||||
foldersView->header()->adjustSize();
|
||||
foldersView->header()->hide();
|
||||
foldersView->setAnimated(true);
|
||||
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
comicView->setAlternatingRowColors(true);
|
||||
comicView->setItemDelegate(new YACReaderComicViewDelegate());
|
||||
//comicView->setItemDelegate(new YACReaderComicViewDelegate());
|
||||
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.
|
||||
QString sufix = QLocale::system().name();
|
||||
if(QFile(":/files/about_"+sufix+".html").exists())
|
||||
@ -156,25 +151,23 @@ void LibraryWindow::setupUI()
|
||||
had->loadHelp(":/files/helpYACReaderLibrary_"+sufix+".html");
|
||||
else
|
||||
had->loadHelp(":/files/helpYACReaderLibrary.html");
|
||||
}
|
||||
|
||||
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();
|
||||
void LibraryWindow::doModels()
|
||||
{
|
||||
//dirmodels
|
||||
dm = new TreeModel();
|
||||
dmCV = new QSqlQueryModel();
|
||||
|
||||
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("");
|
||||
|
||||
comicFlow->setFocus(Qt::OtherFocusReason);
|
||||
|
||||
setWindowTitle(tr("YACReader Library"));
|
||||
}
|
||||
|
||||
void LibraryWindow::createActions()
|
||||
@ -296,6 +289,16 @@ void LibraryWindow::createActions()
|
||||
openContainingFolderComicAction->setIcon(QIcon(":/images/open.png"));
|
||||
}
|
||||
|
||||
void LibraryWindow::disableActions()
|
||||
{
|
||||
}
|
||||
void LibraryWindow::enableActions()
|
||||
{
|
||||
}
|
||||
void LibraryWindow::enableLibraryActions()
|
||||
{
|
||||
}
|
||||
|
||||
void LibraryWindow::createToolBars()
|
||||
{
|
||||
libraryToolBar = addToolBar(tr("Library"));
|
||||
@ -435,7 +438,7 @@ void LibraryWindow::createConnections()
|
||||
connect(openContainingFolderAction,SIGNAL(triggered()),this,SLOT(openContainingFolder()));
|
||||
|
||||
//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)
|
||||
@ -446,57 +449,10 @@ void LibraryWindow::loadLibrary(const QString & name)
|
||||
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
||||
if(d.exists(path))
|
||||
{
|
||||
//renew dirmodels (because QFileSystemModel is.......crap ;) )
|
||||
QFileSystemModel * oldDm = dm;
|
||||
QFileSystemModel * oldDmCV = dmCV;
|
||||
YACReaderTreeSearch * oldTreeSearch = proxyFilter;
|
||||
//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)));
|
||||
TreeModel * oldTM = dm;
|
||||
dm = new TreeModel();
|
||||
dm->setupModelData(path);
|
||||
foldersView->setModel(dm);
|
||||
|
||||
foldersView->header()->hideSection(1);
|
||||
foldersView->header()->hideSection(2);
|
||||
@ -504,9 +460,20 @@ void LibraryWindow::loadLibrary(const QString & name)
|
||||
foldersView->header()->adjustSize();
|
||||
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();
|
||||
|
||||
/*if(oldTM!=0)
|
||||
delete oldTM;*/ //TODO corregir error al liberar memoria
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -566,32 +533,37 @@ void LibraryWindow::loadLibrary(const QString & name)
|
||||
|
||||
void LibraryWindow::loadCovers(const QModelIndex & mi)
|
||||
{
|
||||
if(foldersFilter->text()!="")
|
||||
{
|
||||
if(foldersFilter->text()!="")
|
||||
{
|
||||
setFoldersFilter("");
|
||||
foldersFilter->clear();
|
||||
}
|
||||
QString path = dm->filePath(proxyFilter->mapToSource(mi));
|
||||
delete dmCV;
|
||||
dmCV = new QFileSystemModel();
|
||||
dmCV->setFilter(QDir::Files|QDir::CaseSensitive|QDir::NoDotAndDotDot);
|
||||
dmCV->setNameFilters(QStringList() << "*jpg");
|
||||
dmCV->setNameFilterDisables(false);
|
||||
dmCV->setReadOnly(true);
|
||||
|
||||
dmCV->setIconProvider(&fip);
|
||||
//dmCV->sort(1);
|
||||
//delete proxySort;
|
||||
|
||||
//TODO
|
||||
/*proxySort = new YACReaderSortComics();
|
||||
proxySort->setSourceModel(dmCV);
|
||||
proxySort->setFilterRole(Qt::DisplayRole);*/
|
||||
|
||||
}
|
||||
unsigned long long int folderId = 0;
|
||||
if(mi.isValid())
|
||||
{
|
||||
TreeItem *item = static_cast<TreeItem*>(mi.internalPointer());
|
||||
folderId = item->id;
|
||||
}
|
||||
QSqlQuery selectQuery(dm->getDatabase()); //TODO check
|
||||
selectQuery.prepare("select fileName from comic where comic.parentId = :parentId");
|
||||
selectQuery.bindValue(":parentId", folderId);
|
||||
selectQuery.exec();
|
||||
dmCV->setQuery(selectQuery);
|
||||
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);
|
||||
paths = comicFlow->getImageFiles();
|
||||
if(paths.size()>0 && !importedCovers)
|
||||
@ -612,9 +584,8 @@ if(foldersFilter->text()!="")
|
||||
setAllAsReadAction->setEnabled(false);
|
||||
setAllAsNonReadAction->setEnabled(false);
|
||||
}
|
||||
if(paths.size()>0)
|
||||
comicView->setCurrentIndex(dmCV->index(paths[0]));
|
||||
|
||||
/*if(paths.size()>0)
|
||||
comicView->setCurrentIndex(dmCV->index(paths[0]));*/
|
||||
}
|
||||
|
||||
void LibraryWindow::centerComicFlow(const QModelIndex & mi)
|
||||
@ -637,8 +608,8 @@ void LibraryWindow::centerComicFlow(const QModelIndex & mi)
|
||||
void LibraryWindow::updateComicView(int i)
|
||||
{
|
||||
|
||||
if((paths.size()>0)&&skip==0)
|
||||
comicView->setCurrentIndex(dmCV->index(paths[i]));
|
||||
/*if((paths.size()>0)&&skip==0)
|
||||
comicView->setCurrentIndex(dmCV->index(paths[i]));*/
|
||||
skip?(--skip):0;
|
||||
}
|
||||
|
||||
@ -648,7 +619,7 @@ void LibraryWindow::openComic()
|
||||
if(!importedCovers)
|
||||
{
|
||||
QModelIndex mi = comicView->currentIndex();
|
||||
QString path = QDir::cleanPath(dmCV->filePath(mi));
|
||||
QString path;// = QDir::cleanPath(dmCV->filePath(mi));
|
||||
|
||||
path.remove("/.yacreaderlibrary");
|
||||
path.remove(path.size()-4,4);
|
||||
@ -663,18 +634,12 @@ void LibraryWindow::openComic()
|
||||
void LibraryWindow::setCurrentComicReaded()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
void LibraryWindow::setComicsReaded()
|
||||
{
|
||||
QModelIndex mi = proxyFilter->mapToSource(foldersView->currentIndex());
|
||||
/*QModelIndex mi = proxyFilter->mapToSource(foldersView->currentIndex());
|
||||
QString path;
|
||||
|
||||
if(mi.isValid())
|
||||
@ -694,7 +659,7 @@ void LibraryWindow::setComicsReaded()
|
||||
f.open(QIODevice::WriteOnly);
|
||||
f.close();
|
||||
comicFlow->markSlide(i);
|
||||
}
|
||||
}*/
|
||||
|
||||
comicFlow->updateMarks();
|
||||
}
|
||||
@ -702,19 +667,19 @@ void LibraryWindow::setComicsReaded()
|
||||
void LibraryWindow::setCurrentComicUnreaded()
|
||||
{
|
||||
comicFlow->unmarkSlide(comicFlow->centerIndex());
|
||||
QModelIndex mi = comicView->currentIndex();
|
||||
/*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.remove();
|
||||
f.close();
|
||||
f.close();*/
|
||||
|
||||
comicFlow->updateMarks();
|
||||
}
|
||||
|
||||
void LibraryWindow::setComicsUnreaded()
|
||||
{
|
||||
QModelIndex mi = proxyFilter->mapToSource(foldersView->currentIndex());
|
||||
/*QModelIndex mi = proxyFilter->mapToSource(foldersView->currentIndex());
|
||||
QString path;
|
||||
|
||||
if(mi.isValid())
|
||||
@ -736,7 +701,7 @@ void LibraryWindow::setComicsUnreaded()
|
||||
f.close();
|
||||
comicFlow->unmarkSlide(i);
|
||||
}
|
||||
|
||||
*/
|
||||
comicFlow->updateMarks();
|
||||
}
|
||||
|
||||
@ -918,8 +883,8 @@ void LibraryWindow::setRootIndex()
|
||||
if(d.exists(path))
|
||||
{
|
||||
//dmCV->refresh(dmCV->index(path));
|
||||
comicView->setRootIndex(dmCV->index(path));
|
||||
loadCovers(proxyFilter->mapFromSource(dm->index(path)));
|
||||
/*comicView->setRootIndex(dmCV->index(path));
|
||||
loadCovers(proxyFilter->mapFromSource(dm->index(path)));*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -971,7 +936,7 @@ void LibraryWindow::toNormal()
|
||||
|
||||
void LibraryWindow::setFoldersFilter(QString filter)
|
||||
{
|
||||
if(filter.contains(previousFilter))
|
||||
/*if(filter.contains(previousFilter))
|
||||
proxyFilter->softReset();
|
||||
else
|
||||
proxyFilter->reset();
|
||||
@ -986,13 +951,13 @@ void LibraryWindow::setFoldersFilter(QString filter)
|
||||
proxyFilter->setFilterRegExp(QRegExp());
|
||||
foldersView->scrollTo(foldersView->currentIndex(),QAbstractItemView::PositionAtTop);
|
||||
foldersView->collapseAll();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void LibraryWindow::showProperties()
|
||||
{
|
||||
//TODO create a new method for this
|
||||
QModelIndex mi = comicView->currentIndex();
|
||||
/*QModelIndex mi = comicView->currentIndex();
|
||||
QString path = QDir::cleanPath(dmCV->filePath(mi)).remove("/.yacreaderlibrary");
|
||||
path.remove(path.size()-4,4);
|
||||
|
||||
@ -1004,21 +969,21 @@ void LibraryWindow::showProperties()
|
||||
QFile file(path);
|
||||
propertiesDialog->setSize(file.size()/(1024.0*1024));
|
||||
file.close();
|
||||
propertiesDialog->show();
|
||||
propertiesDialog->show();*/
|
||||
}
|
||||
|
||||
void LibraryWindow::openContainingFolderComic()
|
||||
{
|
||||
QModelIndex modelIndex = comicView->currentIndex();
|
||||
QString path = QDir::cleanPath(dmCV->fileInfo(modelIndex).absolutePath()).remove("/.yacreaderlibrary");
|
||||
QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode));
|
||||
//QString path = QDir::cleanPath(dmCV->fileInfo(modelIndex).absolutePath()).remove("/.yacreaderlibrary");
|
||||
//QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode));
|
||||
}
|
||||
|
||||
void LibraryWindow::openContainingFolder()
|
||||
{
|
||||
QModelIndex modelIndex = foldersView->currentIndex();
|
||||
QString path = QDir::cleanPath(dm->filePath(proxyFilter->mapToSource(modelIndex))).remove("/.yacreaderlibrary");
|
||||
QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode));
|
||||
//QString path = QDir::cleanPath(dm->filePath(proxyFilter->mapToSource(modelIndex))).remove("/.yacreaderlibrary");
|
||||
//QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode));
|
||||
}
|
||||
|
||||
void LibraryWindow::exportLibrary(QString destPath)
|
||||
@ -1041,20 +1006,20 @@ void LibraryWindow::reloadOptions()
|
||||
|
||||
void LibraryWindow::updateFoldersView(QString path)
|
||||
{
|
||||
QModelIndex mi = dm->index(path);
|
||||
int rowCount = dm->rowCount(mi);
|
||||
if(!fetching)
|
||||
{
|
||||
//fetching = true;
|
||||
for(int i=0;i<rowCount;i++)
|
||||
{
|
||||
dm->fetchMore(dm->index(i,0,mi));
|
||||
//int childCount = dm->rowCount(dm->index(i,0,mi));
|
||||
//if(childCount>0)
|
||||
// QMessageBox::critical(NULL,tr("..."),tr("-----"));
|
||||
fetching = false;
|
||||
}
|
||||
}
|
||||
//QModelIndex mi = dm->index(path);
|
||||
//int rowCount = dm->rowCount(mi);
|
||||
//if(!fetching)
|
||||
//{
|
||||
// //fetching = true;
|
||||
// for(int i=0;i<rowCount;i++)
|
||||
// {
|
||||
// dm->fetchMore(dm->index(i,0,mi));
|
||||
// //int childCount = dm->rowCount(dm->index(i,0,mi));
|
||||
// //if(childCount>0)
|
||||
// // QMessageBox::critical(NULL,tr("..."),tr("-----"));
|
||||
// fetching = false;
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
@ -1063,11 +1028,11 @@ void LibraryWindow::searchInFiles(int state)
|
||||
|
||||
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
|
||||
{
|
||||
dm->setFilter(QDir::Dirs|QDir::NoDotAndDotDot); //crash
|
||||
//dm->setFilter(QDir::Dirs|QDir::NoDotAndDotDot); //crash
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <QThread>
|
||||
#include <QFileInfoList>
|
||||
#include <QFileSystemModel>
|
||||
#include <QSqlQueryModel>
|
||||
|
||||
#include "create_library_dialog.h"
|
||||
#include "add_library_dialog.h"
|
||||
@ -24,7 +25,7 @@
|
||||
#include "export_library_dialog.h"
|
||||
#include "import_library_dialog.h"
|
||||
#include "package_manager.h"
|
||||
|
||||
#include "treemodel.h"
|
||||
|
||||
class LibraryWindow : public QMainWindow
|
||||
{
|
||||
@ -58,8 +59,8 @@ private:
|
||||
QListView * comicView;
|
||||
QTreeView * foldersView;
|
||||
QComboBox * selectedLibrary;
|
||||
QFileSystemModel * dm;
|
||||
QFileSystemModel * dmCV;
|
||||
TreeModel * dm;
|
||||
QSqlQueryModel * dmCV;
|
||||
QStringList paths;
|
||||
QMap<QString,QString> libraries;
|
||||
QLabel * fullScreenToolTip;
|
||||
@ -116,9 +117,17 @@ private:
|
||||
void createToolBars();
|
||||
void createMenus();
|
||||
void createConnections();
|
||||
void doLayout();
|
||||
void doDialogs();
|
||||
void doModels();
|
||||
|
||||
void disableActions();
|
||||
void enableActions();
|
||||
void enableLibraryActions();
|
||||
|
||||
public:
|
||||
LibraryWindow();
|
||||
public slots:
|
||||
public slots:
|
||||
void loadLibrary(const QString & path);
|
||||
void loadCovers(const QModelIndex & mi);
|
||||
void centerComicFlow(const QModelIndex & mi);
|
||||
|
Loading…
x
Reference in New Issue
Block a user