mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
navegaci?n entre tree,table y flow completada
tambi?n se pueden volver a abrir los c?mcis
This commit is contained in:
parent
bdef116ad2
commit
faebba5a2e
@ -31,7 +31,9 @@ HEADERS += comic_flow.h \
|
||||
bundle_creator.h \
|
||||
./db/data_base_management.h \
|
||||
./db/treeitem.h \
|
||||
./db/treemodel.h
|
||||
./db/treemodel.h \
|
||||
./db/tablemodel.h \
|
||||
./db/tableitem.h
|
||||
SOURCES += comic_flow.cpp \
|
||||
create_library_dialog.cpp \
|
||||
library_creator.cpp \
|
||||
@ -50,7 +52,9 @@ SOURCES += comic_flow.cpp \
|
||||
bundle_creator.cpp \
|
||||
./db/data_base_management.cpp \
|
||||
./db/treeitem.cpp \
|
||||
./db/treemodel.cpp
|
||||
./db/treemodel.cpp \
|
||||
./db/tablemodel.cpp \
|
||||
./db/tableitem.cpp
|
||||
|
||||
include(./server/server.pri)
|
||||
|
||||
|
@ -5,10 +5,6 @@
|
||||
#include <QImageReader>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ComicFlow::ComicFlow(QWidget* parent,FlowType flowType)
|
||||
:YACReaderFlow(parent,flowType)
|
||||
{
|
||||
@ -27,62 +23,6 @@ ComicFlow::~ComicFlow()
|
||||
delete updateTimer;
|
||||
}
|
||||
|
||||
QString ComicFlow::getImagePath() const
|
||||
{
|
||||
return "";//imagePath;
|
||||
}
|
||||
|
||||
QStringList ComicFlow::getImageFiles() const
|
||||
{
|
||||
return imageFiles;
|
||||
}
|
||||
|
||||
// get list of all files in a directory (will be filtered later)
|
||||
// this is usually very fast so no need to put it in a separate thread
|
||||
static QStringList findFiles(const QString& path = QString())
|
||||
{
|
||||
//list<QString> files;
|
||||
QStringList files;
|
||||
|
||||
QDir dir = QDir::current();
|
||||
if(!path.isEmpty())
|
||||
dir = QDir(path);
|
||||
|
||||
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
|
||||
dir.setNameFilters(QStringList() << "*.jpg");
|
||||
//dir.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
||||
QFileInfoList list = dir.entryInfoList();
|
||||
|
||||
qSort(list.begin(),list.end(),naturalSortLessThanCIFileInfo);
|
||||
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
{
|
||||
QFileInfo fileInfo = list.at(i);
|
||||
files.append(dir.absoluteFilePath(fileInfo.fileName()));
|
||||
}
|
||||
|
||||
//std::sort(files.begin(), files.end(), naturalSortLessThanCI);
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
// take only files which are readable (as images)
|
||||
// also seems to be fast as it does a quick check only
|
||||
static QStringList filterImages(const QStringList& files)
|
||||
{
|
||||
QStringList imageFiles;
|
||||
|
||||
QImageReader reader;
|
||||
foreach(QString fname, files)
|
||||
{
|
||||
reader.setFileName(fname);
|
||||
if(reader.canRead())
|
||||
imageFiles += fname;
|
||||
}
|
||||
|
||||
return imageFiles;
|
||||
}
|
||||
|
||||
void ComicFlow::setImagePaths(const QStringList& paths)
|
||||
{
|
||||
clear();
|
||||
@ -135,7 +75,6 @@ void ComicFlow::updateImageData()
|
||||
imagesSetted[idx] = true;
|
||||
numImagesLoaded++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// try to load only few images on the left and right side
|
||||
|
@ -19,9 +19,6 @@ public:
|
||||
ComicFlow(QWidget* parent = 0,FlowType flowType = CoverFlowLike);
|
||||
virtual ~ComicFlow();
|
||||
|
||||
//void render();
|
||||
QString getImagePath() const; //TOTO quitar no se usa
|
||||
QStringList getImageFiles() const;
|
||||
void setImagePaths(const QStringList& paths);
|
||||
//bool eventFilter(QObject *target, QEvent *event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
@ -55,6 +55,8 @@
|
||||
TreeModel::TreeModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
connect(this,SIGNAL(beforeReset()),this,SIGNAL(modelAboutToBeReset()));
|
||||
connect(this,SIGNAL(reset()),this,SIGNAL(modelReset()));
|
||||
}
|
||||
|
||||
//! [0]
|
||||
@ -182,6 +184,7 @@ int TreeModel::rowCount(const QModelIndex &parent) const
|
||||
|
||||
void TreeModel::setupModelData(QString path)
|
||||
{
|
||||
emit(beforeReset());
|
||||
if(rootItem == 0)
|
||||
delete rootItem; //TODO comprobar que se libera bien la memoria
|
||||
|
||||
@ -197,6 +200,7 @@ void TreeModel::setupModelData(QString path)
|
||||
QSqlQuery selectQuery("select * from folder order by parentId,name",_database);
|
||||
|
||||
setupModelData(selectQuery,rootItem);
|
||||
emit(reset());
|
||||
}
|
||||
|
||||
void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||
|
@ -76,6 +76,9 @@ private:
|
||||
TreeItem *rootItem; //el árbol
|
||||
|
||||
QSqlDatabase _database;
|
||||
signals:
|
||||
void beforeReset();
|
||||
void reset();
|
||||
};
|
||||
//! [0]
|
||||
|
||||
|
@ -68,7 +68,7 @@ void LibraryWindow::doLayout()
|
||||
comicFlow->setSlideSize(slideSizeW);
|
||||
setFocusProxy(comicFlow);
|
||||
|
||||
comicView = new QListView;
|
||||
comicView = new QTableView;
|
||||
foldersView = new QTreeView;
|
||||
|
||||
|
||||
@ -115,10 +115,21 @@ void LibraryWindow::doLayout()
|
||||
foldersView->setAnimated(true);
|
||||
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
foldersView->header()->hide();
|
||||
|
||||
comicView->setAlternatingRowColors(true);
|
||||
comicView->setStyleSheet("alternate-background-color: #e7e7d7;background-color: white;");
|
||||
//comicView->setItemDelegate(new YACReaderComicViewDelegate());
|
||||
comicView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
//comicView->verticalHeader()->hide();
|
||||
comicView->setShowGrid(false);
|
||||
comicView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
comicView->horizontalHeader()->setStretchLastSection(true);
|
||||
comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
comicView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
comicView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
|
||||
|
||||
fullScreenToolTip = new QLabel(this);
|
||||
fullScreenToolTip->setText(tr("<font color='white'> press 'F' to close fullscreen mode </font>"));
|
||||
@ -157,7 +168,7 @@ void LibraryWindow::doModels()
|
||||
{
|
||||
//dirmodels
|
||||
dm = new TreeModel();
|
||||
dmCV = new QSqlQueryModel();
|
||||
dmCV = new TableModel();
|
||||
|
||||
|
||||
/*proxyFilter = new YACReaderTreeSearch();
|
||||
@ -289,14 +300,54 @@ void LibraryWindow::createActions()
|
||||
openContainingFolderComicAction->setIcon(QIcon(":/images/open.png"));
|
||||
}
|
||||
|
||||
//TODO unificar con disableActions
|
||||
void LibraryWindow::disableAllActions()
|
||||
{
|
||||
updateLibraryAction->setEnabled(false);
|
||||
renameLibraryAction->setEnabled(false);
|
||||
deleteLibraryAction->setEnabled(false);
|
||||
removeLibraryAction->setEnabled(false);
|
||||
foldersFilter->setEnabled(false);
|
||||
clearFoldersFilter->setEnabled(false);
|
||||
setAsReadAction->setEnabled(false);
|
||||
setAsNonReadAction->setEnabled(false);
|
||||
setAllAsReadAction->setEnabled(false);
|
||||
setAllAsNonReadAction->setEnabled(false);
|
||||
}
|
||||
|
||||
//librería de sólo lectura
|
||||
void LibraryWindow::disableActions()
|
||||
{
|
||||
updateLibraryAction->setEnabled(false);
|
||||
openComicAction->setEnabled(false);
|
||||
showPropertiesAction->setEnabled(false);
|
||||
openContainingFolderAction->setEnabled(false);
|
||||
openContainingFolderComicAction->setEnabled(false);
|
||||
setAsReadAction->setEnabled(false);
|
||||
setAsNonReadAction->setEnabled(false);
|
||||
setAllAsReadAction->setEnabled(false);
|
||||
setAllAsNonReadAction->setEnabled(false);
|
||||
}
|
||||
//librería abierta
|
||||
void LibraryWindow::enableActions()
|
||||
{
|
||||
updateLibraryAction->setEnabled(true);
|
||||
openComicAction->setEnabled(true);
|
||||
showPropertiesAction->setEnabled(true);
|
||||
openContainingFolderAction->setEnabled(true);
|
||||
openContainingFolderComicAction->setEnabled(true);
|
||||
setAsReadAction->setEnabled(true);
|
||||
setAsNonReadAction->setEnabled(true);
|
||||
setAllAsReadAction->setEnabled(true);
|
||||
setAllAsNonReadAction->setEnabled(true);
|
||||
}
|
||||
void LibraryWindow::enableLibraryActions()
|
||||
{
|
||||
renameLibraryAction->setEnabled(true);
|
||||
deleteLibraryAction->setEnabled(true);
|
||||
removeLibraryAction->setEnabled(true);
|
||||
foldersFilter->setEnabled(true);
|
||||
clearFoldersFilter->setEnabled(true);
|
||||
}
|
||||
|
||||
void LibraryWindow::createToolBars()
|
||||
@ -449,31 +500,12 @@ void LibraryWindow::loadLibrary(const QString & name)
|
||||
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
||||
if(d.exists(path))
|
||||
{
|
||||
TreeModel * oldTM = dm;
|
||||
dm = new TreeModel();
|
||||
dm->setupModelData(path);
|
||||
foldersView->setModel(dm);
|
||||
|
||||
foldersView->header()->hideSection(1);
|
||||
foldersView->header()->hideSection(2);
|
||||
foldersView->header()->hideSection(3);
|
||||
foldersView->header()->adjustSize();
|
||||
foldersView->header()->hide();
|
||||
|
||||
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
|
||||
{
|
||||
@ -483,51 +515,22 @@ void LibraryWindow::loadLibrary(const QString & name)
|
||||
}
|
||||
d.setCurrent(libraries.value(name));
|
||||
d.setFilter(QDir::AllDirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
||||
if(d.count()<=1)
|
||||
if(d.count()<=1) //librería de sólo lectura
|
||||
{
|
||||
//QMessageBox::critical(NULL,QString::number(d.count()),QString::number(d.count()));
|
||||
updateLibraryAction->setEnabled(false);
|
||||
openComicAction->setEnabled(false);
|
||||
showPropertiesAction->setEnabled(false);
|
||||
openContainingFolderAction->setEnabled(false);
|
||||
openContainingFolderComicAction->setEnabled(false);
|
||||
setAsReadAction->setEnabled(false);
|
||||
setAsNonReadAction->setEnabled(false);
|
||||
setAllAsReadAction->setEnabled(false);
|
||||
setAllAsNonReadAction->setEnabled(false);
|
||||
disableActions();
|
||||
importedCovers = true;
|
||||
}
|
||||
else
|
||||
else //librería normal abierta
|
||||
{
|
||||
updateLibraryAction->setEnabled(true);
|
||||
openComicAction->setEnabled(true);
|
||||
showPropertiesAction->setEnabled(true);
|
||||
openContainingFolderAction->setEnabled(true);
|
||||
openContainingFolderComicAction->setEnabled(true);
|
||||
setAsReadAction->setEnabled(true);
|
||||
setAsNonReadAction->setEnabled(true);
|
||||
setAllAsReadAction->setEnabled(true);
|
||||
setAllAsNonReadAction->setEnabled(true);
|
||||
enableActions();
|
||||
importedCovers = false;
|
||||
}
|
||||
renameLibraryAction->setEnabled(true);
|
||||
deleteLibraryAction->setEnabled(true);
|
||||
removeLibraryAction->setEnabled(true);
|
||||
foldersFilter->setEnabled(true);
|
||||
clearFoldersFilter->setEnabled(true);
|
||||
enableLibraryActions();
|
||||
}
|
||||
else
|
||||
{
|
||||
updateLibraryAction->setEnabled(false);
|
||||
renameLibraryAction->setEnabled(false);
|
||||
deleteLibraryAction->setEnabled(false);
|
||||
removeLibraryAction->setEnabled(false);
|
||||
foldersFilter->setEnabled(false);
|
||||
clearFoldersFilter->setEnabled(false);
|
||||
setAsReadAction->setEnabled(false);
|
||||
setAsNonReadAction->setEnabled(false);
|
||||
setAllAsReadAction->setEnabled(false);
|
||||
setAllAsNonReadAction->setEnabled(false);
|
||||
disableAllActions();
|
||||
}
|
||||
}
|
||||
|
||||
@ -544,28 +547,18 @@ void LibraryWindow::loadCovers(const QModelIndex & mi)
|
||||
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);
|
||||
dmCV->setupModelData(folderId,dm->getDatabase());
|
||||
comicView->setModel(dmCV);
|
||||
//TODO automatizar (valorar si se deja al modelo)
|
||||
comicView->horizontalHeader()->hideSection(0);
|
||||
comicView->horizontalHeader()->hideSection(1);
|
||||
comicView->horizontalHeader()->hideSection(3);
|
||||
//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";
|
||||
}
|
||||
|
||||
QStringList paths = dmCV->getPaths(currentPath());
|
||||
comicFlow->setImagePaths(paths);
|
||||
comicFlow->setFocus(Qt::OtherFocusReason);
|
||||
paths = comicFlow->getImageFiles();
|
||||
|
||||
if(paths.size()>0 && !importedCovers)
|
||||
{
|
||||
openComicAction->setEnabled(true);
|
||||
@ -584,8 +577,8 @@ void LibraryWindow::loadCovers(const QModelIndex & mi)
|
||||
setAllAsReadAction->setEnabled(false);
|
||||
setAllAsNonReadAction->setEnabled(false);
|
||||
}
|
||||
/*if(paths.size()>0)
|
||||
comicView->setCurrentIndex(dmCV->index(paths[0]));*/
|
||||
if(paths.size()>0)
|
||||
comicView->setCurrentIndex(dmCV->index(0,0));
|
||||
}
|
||||
|
||||
void LibraryWindow::centerComicFlow(const QModelIndex & mi)
|
||||
@ -608,26 +601,24 @@ void LibraryWindow::centerComicFlow(const QModelIndex & mi)
|
||||
void LibraryWindow::updateComicView(int i)
|
||||
{
|
||||
|
||||
/*if((paths.size()>0)&&skip==0)
|
||||
comicView->setCurrentIndex(dmCV->index(paths[i]));*/
|
||||
if(skip==0)
|
||||
{
|
||||
QModelIndex mi = dmCV->index(i,2);
|
||||
comicView->setCurrentIndex(mi);
|
||||
comicView->scrollTo(mi,QAbstractItemView::EnsureVisible);
|
||||
}
|
||||
skip?(--skip):0;
|
||||
}
|
||||
|
||||
void LibraryWindow::openComic()
|
||||
{
|
||||
//int index = comicFlow->centerIndex();
|
||||
if(!importedCovers)
|
||||
{
|
||||
QModelIndex mi = comicView->currentIndex();
|
||||
QString path;// = QDir::cleanPath(dmCV->filePath(mi));
|
||||
QString path = currentPath() + dmCV->getComicPath(comicView->currentIndex());
|
||||
|
||||
path.remove("/.yacreaderlibrary");
|
||||
path.remove(path.size()-4,4);
|
||||
QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+"/YACReader",QStringList() << path);
|
||||
//Comic is readed
|
||||
setCurrentComicReaded();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1004,6 +995,7 @@ void LibraryWindow::reloadOptions()
|
||||
comicFlow->setFlowType(flowType);
|
||||
}
|
||||
|
||||
//TODO esto sobra
|
||||
void LibraryWindow::updateFoldersView(QString path)
|
||||
{
|
||||
//QModelIndex mi = dm->index(path);
|
||||
@ -1036,5 +1028,7 @@ void LibraryWindow::searchInFiles(int state)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString LibraryWindow::currentPath()
|
||||
{
|
||||
return libraries.value(selectedLibrary->currentText());
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
#define __LIBRARYWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QListView>
|
||||
#include <QTableView>
|
||||
#include <QTreeView>
|
||||
#include <QModelIndex>
|
||||
#include <QDirModel>
|
||||
@ -11,8 +11,6 @@
|
||||
#include <QComboBox>
|
||||
#include <QThread>
|
||||
#include <QFileInfoList>
|
||||
#include <QFileSystemModel>
|
||||
#include <QSqlQueryModel>
|
||||
|
||||
#include "create_library_dialog.h"
|
||||
#include "add_library_dialog.h"
|
||||
@ -26,6 +24,7 @@
|
||||
#include "import_library_dialog.h"
|
||||
#include "package_manager.h"
|
||||
#include "treemodel.h"
|
||||
#include "tablemodel.h"
|
||||
|
||||
class LibraryWindow : public QMainWindow
|
||||
{
|
||||
@ -56,12 +55,12 @@ private:
|
||||
QPushButton * clearFoldersFilter;
|
||||
QCheckBox * includeComicsCheckBox;
|
||||
//-------------
|
||||
QListView * comicView;
|
||||
QTableView * comicView;
|
||||
QTreeView * foldersView;
|
||||
QComboBox * selectedLibrary;
|
||||
TreeModel * dm;
|
||||
QSqlQueryModel * dmCV;
|
||||
QStringList paths;
|
||||
TableModel * dmCV;
|
||||
//QStringList paths;
|
||||
QMap<QString,QString> libraries;
|
||||
QLabel * fullScreenToolTip;
|
||||
YACReaderIconProvider fip;
|
||||
@ -121,10 +120,12 @@ private:
|
||||
void doDialogs();
|
||||
void doModels();
|
||||
|
||||
void disableAllActions();
|
||||
void disableActions();
|
||||
void enableActions();
|
||||
void enableLibraryActions();
|
||||
|
||||
QString currentPath();
|
||||
public:
|
||||
LibraryWindow();
|
||||
public slots:
|
||||
|
Loading…
x
Reference in New Issue
Block a user