mirror of
https://github.com/YACReader/yacreader
synced 2026-04-05 04:12:42 -04:00
merge
This commit is contained in:
@ -13,7 +13,7 @@ INCLUDEPATH += ../common \
|
||||
./comic_vine \
|
||||
./comic_vine/model
|
||||
|
||||
DEFINES += SERVER_RELEASE NOMINMAX
|
||||
DEFINES += SERVER_RELEASE NOMINMAX YACREADER_LIBRARY
|
||||
|
||||
win32 {
|
||||
|
||||
@ -34,7 +34,6 @@ CONFIG -= embed_manifest_exe
|
||||
}
|
||||
|
||||
unix:!macx{
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
|
||||
isEqual(QT_MAJOR_VERSION, 5) {
|
||||
INCLUDEPATH += /usr/include/poppler/qt5
|
||||
@ -67,6 +66,10 @@ CONFIG += objective_c
|
||||
|
||||
}
|
||||
|
||||
unix{
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
}
|
||||
|
||||
#CONFIG += release
|
||||
CONFIG -= flat
|
||||
QT += sql network opengl script
|
||||
@ -113,6 +116,10 @@ HEADERS += comic_flow.h \
|
||||
../common/http_worker.h \
|
||||
yacreader_libraries.h \
|
||||
../common/exit_check.h \
|
||||
comics_view.h \
|
||||
classic_comics_view.h \
|
||||
empty_folder_widget.h
|
||||
|
||||
|
||||
SOURCES += comic_flow.cpp \
|
||||
create_library_dialog.cpp \
|
||||
@ -156,6 +163,10 @@ SOURCES += comic_flow.cpp \
|
||||
../common/yacreader_global.cpp \
|
||||
yacreader_libraries.cpp \
|
||||
../common/exit_check.cpp \
|
||||
comics_view.cpp \
|
||||
classic_comics_view.cpp \
|
||||
empty_folder_widget.cpp
|
||||
|
||||
|
||||
|
||||
include(./server/server.pri)
|
||||
@ -163,6 +174,7 @@ include(../custom_widgets/custom_widgets_yacreaderlibrary.pri)
|
||||
include(../compressed_archive/wrapper.pri)
|
||||
include(./comic_vine/comic_vine.pri)
|
||||
include(../QsLog/QsLog.pri)
|
||||
include(../shortcuts_management/shortcuts_management.pri)
|
||||
|
||||
RESOURCES += images.qrc files.qrc
|
||||
win32:RESOURCES += images_win.qrc
|
||||
@ -186,6 +198,21 @@ TRANSLATIONS = yacreaderlibrary_es.ts \
|
||||
isEqual(QT_MAJOR_VERSION, 5) {
|
||||
Release:DESTDIR = ../release5
|
||||
Debug:DESTDIR = ../debug5
|
||||
|
||||
#QML/GridView
|
||||
QT += quick qml
|
||||
|
||||
HEADERS += grid_comics_view.h \
|
||||
comics_view_transition.h
|
||||
|
||||
SOURCES += grid_comics_view.cpp \
|
||||
comics_view_transition.cpp
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
win32:RESOURCES += qml_win.qrc
|
||||
unix:!macx:RESOURCES += qml_win.qrc
|
||||
macx:RESOURCES += qml_osx.qrc
|
||||
|
||||
} else {
|
||||
Release:DESTDIR = ../release
|
||||
Debug:DESTDIR = ../debug
|
||||
|
||||
243
YACReaderLibrary/classic_comics_view.cpp
Normal file
243
YACReaderLibrary/classic_comics_view.cpp
Normal file
@ -0,0 +1,243 @@
|
||||
#include "classic_comics_view.h"
|
||||
|
||||
#include "yacreader_table_view.h"
|
||||
|
||||
#include "comic_flow_widget.h"
|
||||
#include "QsLog.h"
|
||||
|
||||
ClassicComicsView::ClassicComicsView(QWidget *parent)
|
||||
:ComicsView(parent)
|
||||
{
|
||||
QHBoxLayout * layout = new QHBoxLayout;
|
||||
|
||||
settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
|
||||
settings->beginGroup("libraryConfig");
|
||||
//FLOW-----------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
if(QGLFormat::hasOpenGL() && (settings->value(USE_OPEN_GL).toBool() == true))
|
||||
comicFlow = new ComicFlowWidgetGL(0);
|
||||
else
|
||||
comicFlow = new ComicFlowWidgetSW(0);
|
||||
|
||||
comicFlow->updateConfig(settings);
|
||||
comicFlow->setFocusPolicy(Qt::StrongFocus);
|
||||
comicFlow->setShowMarks(true);
|
||||
setFocusProxy(comicFlow);
|
||||
|
||||
comicFlow->setFocus(Qt::OtherFocusReason);
|
||||
|
||||
comicFlow->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
//TODO!!! set actions....
|
||||
//comicFlow->addAction(toggleFullScreenAction);
|
||||
//comicFlow->addAction(openComicAction);
|
||||
|
||||
//END FLOW----
|
||||
|
||||
|
||||
//layout-----------------------------------------------
|
||||
sVertical = new QSplitter(Qt::Vertical); //spliter derecha
|
||||
|
||||
sVertical->addWidget(comicFlow);
|
||||
comics = new QWidget;
|
||||
QVBoxLayout * comicsLayout = new QVBoxLayout;
|
||||
comicsLayout->setSpacing(0);
|
||||
comicsLayout->setContentsMargins(0,0,0,0);
|
||||
//TODO ComicsView:(set toolbar) comicsLayout->addWidget(editInfoToolBar);
|
||||
|
||||
tableView = new YACReaderTableView;
|
||||
tableView->verticalHeader()->hide();
|
||||
tableView->setFocusPolicy(Qt::StrongFocus);
|
||||
comicsLayout->addWidget(tableView);
|
||||
comics->setLayout(comicsLayout);
|
||||
sVertical->addWidget(comics);
|
||||
|
||||
//config--------------------------------------------------
|
||||
if(settings->contains(COMICS_VIEW_HEADERS))
|
||||
tableView->horizontalHeader()->restoreState(settings->value(COMICS_VIEW_HEADERS).toByteArray());
|
||||
|
||||
//connections---------------------------------------------
|
||||
connect(tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(centerComicFlow(QModelIndex)));
|
||||
connect(comicFlow, SIGNAL(centerIndexChanged(int)), this, SLOT(updateTableView(int)));
|
||||
connect(tableView, SIGNAL(comicRated(int,QModelIndex)), this, SIGNAL(comicRated(int,QModelIndex)));
|
||||
connect(comicFlow, SIGNAL(selected(uint)), this, SIGNAL(selected(uint)));
|
||||
connect(tableView->horizontalHeader(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(saveTableHeadersStatus()));
|
||||
|
||||
layout->addWidget(sVertical);
|
||||
setLayout(layout);
|
||||
|
||||
layout->setMargin(0);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
sVertical->setCollapsible(1,false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ClassicComicsView::setToolBar(QToolBar *toolBar)
|
||||
{
|
||||
static_cast<QVBoxLayout *>(comics->layout())->insertWidget(0,toolBar);
|
||||
}
|
||||
|
||||
void ClassicComicsView::setModel(TableModel *model)
|
||||
{
|
||||
|
||||
ComicsView::setModel(model);
|
||||
|
||||
if(model == NULL)
|
||||
{
|
||||
comicFlow->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), this, SLOT(applyModelChanges(QModelIndex,QModelIndex,QVector<int>)));
|
||||
connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(removeItemsFromFlow(QModelIndex,int,int)));
|
||||
|
||||
tableView->setModel(model);
|
||||
|
||||
tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
|
||||
#if QT_VERSION >= 0x050000
|
||||
tableView->horizontalHeader()->setSectionsMovable(true);
|
||||
#else
|
||||
tableView->horizontalHeader()->setMovable(true);
|
||||
#endif
|
||||
//TODO parametrizar la configuración de las columnas
|
||||
for(int i = 0;i<tableView->horizontalHeader()->count();i++)
|
||||
tableView->horizontalHeader()->hideSection(i);
|
||||
|
||||
tableView->horizontalHeader()->showSection(TableModel::Number);
|
||||
tableView->horizontalHeader()->showSection(TableModel::Title);
|
||||
tableView->horizontalHeader()->showSection(TableModel::FileName);
|
||||
tableView->horizontalHeader()->showSection(TableModel::NumPages);
|
||||
tableView->horizontalHeader()->showSection(TableModel::Hash); //Size is part of the Hash...TODO add Columns::Size to Columns
|
||||
tableView->horizontalHeader()->showSection(TableModel::ReadColumn);
|
||||
tableView->horizontalHeader()->showSection(TableModel::CurrentPage);
|
||||
tableView->horizontalHeader()->showSection(TableModel::Rating);
|
||||
|
||||
//debido a un bug, qt4 no es capaz de ajustar el ancho teniendo en cuenta todas la filas (no sólo las visibles)
|
||||
//así que se ecala la primera vez y después se deja el control al usuario.
|
||||
//if(!settings->contains(COMICS_VIEW_HEADERS))
|
||||
tableView->resizeColumnsToContents();
|
||||
tableView->horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
QStringList paths = model->getPaths(model->getCurrentPath());//TODO ComicsView: get currentpath from somewhere currentPath());
|
||||
comicFlow->setImagePaths(paths);
|
||||
comicFlow->setMarks(model->getReadList());
|
||||
//comicFlow->setFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
|
||||
if(settings->contains(COMICS_VIEW_HEADERS))
|
||||
tableView->horizontalHeader()->restoreState(settings->value(COMICS_VIEW_HEADERS).toByteArray());
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ClassicComicsView::setCurrentIndex(const QModelIndex &index)
|
||||
{
|
||||
tableView->setCurrentIndex(index);
|
||||
//TODO ComicsView: scroll comicFlow to index
|
||||
}
|
||||
|
||||
QModelIndex ClassicComicsView::currentIndex()
|
||||
{
|
||||
return tableView->currentIndex();
|
||||
}
|
||||
|
||||
QItemSelectionModel *ClassicComicsView::selectionModel()
|
||||
{
|
||||
return tableView->selectionModel();
|
||||
}
|
||||
|
||||
void ClassicComicsView::scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint)
|
||||
{
|
||||
comicFlow->setCenterIndex(mi.row());
|
||||
}
|
||||
|
||||
void ClassicComicsView::toFullScreen()
|
||||
{
|
||||
comicFlow->hide();
|
||||
comicFlow->setCenterIndex(comicFlow->centerIndex());
|
||||
comics->hide();
|
||||
|
||||
//showFullScreen() //parent windows
|
||||
|
||||
comicFlow->show();
|
||||
comicFlow->setFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
|
||||
void ClassicComicsView::toNormal()
|
||||
{
|
||||
comicFlow->hide();
|
||||
comicFlow->setCenterIndex(comicFlow->centerIndex());
|
||||
comicFlow->render();
|
||||
comics->show();
|
||||
comicFlow->show();
|
||||
}
|
||||
|
||||
void ClassicComicsView::updateConfig(QSettings *settings)
|
||||
{
|
||||
comicFlow->updateConfig(settings);
|
||||
}
|
||||
|
||||
void ClassicComicsView::setItemActions(const QList<QAction *> &actions)
|
||||
{
|
||||
tableView->addActions(actions);
|
||||
}
|
||||
|
||||
void ClassicComicsView::setViewActions(const QList<QAction *> &actions)
|
||||
{
|
||||
comicFlow->addActions(actions);
|
||||
}
|
||||
|
||||
void ClassicComicsView::selectAll()
|
||||
{
|
||||
tableView->selectAll();
|
||||
}
|
||||
|
||||
void ClassicComicsView::setShowMarks(bool show)
|
||||
{
|
||||
comicFlow->setShowMarks(show);
|
||||
}
|
||||
|
||||
void ClassicComicsView::centerComicFlow(const QModelIndex & mi)
|
||||
{
|
||||
comicFlow->showSlide(mi.row());
|
||||
comicFlow->setFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
|
||||
void ClassicComicsView::updateTableView(int i)
|
||||
{
|
||||
QModelIndex mi = model->index(i,2);
|
||||
tableView->setCurrentIndex(mi);
|
||||
tableView->scrollTo(mi,QAbstractItemView::EnsureVisible);
|
||||
}
|
||||
|
||||
void ClassicComicsView::saveTableHeadersStatus()
|
||||
{
|
||||
settings->setValue(COMICS_VIEW_HEADERS,tableView->horizontalHeader()->saveState());
|
||||
}
|
||||
|
||||
void ClassicComicsView::applyModelChanges(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
|
||||
{
|
||||
Q_UNUSED(topLeft);
|
||||
Q_UNUSED(bottomRight);
|
||||
if(roles.contains(TableModel::ReadColumnRole))
|
||||
{
|
||||
comicFlow->setMarks(model->getReadList());
|
||||
comicFlow->updateMarks();
|
||||
}
|
||||
}
|
||||
|
||||
void ClassicComicsView::removeItemsFromFlow(const QModelIndex &parent, int from, int to)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
for(int i = from; i<=to; i++)
|
||||
comicFlow->remove(i);
|
||||
}
|
||||
|
||||
void ClassicComicsView::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
saveTableHeadersStatus();
|
||||
ComicsView::closeEvent(event);
|
||||
}
|
||||
|
||||
51
YACReaderLibrary/classic_comics_view.h
Normal file
51
YACReaderLibrary/classic_comics_view.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef CLASSIC_COMICS_VIEW_H
|
||||
#define CLASSIC_COMICS_VIEW_H
|
||||
|
||||
#include "comics_view.h"
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QModelIndexList>
|
||||
|
||||
class YACReaderTableView;
|
||||
class QSplitter;
|
||||
class ComicFlowWidget;
|
||||
class QToolBar;
|
||||
class TableModel;
|
||||
|
||||
class ClassicComicsView : public ComicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClassicComicsView(QWidget *parent = 0);
|
||||
void setToolBar(QToolBar * toolBar);
|
||||
void setModel(TableModel *model);
|
||||
void setCurrentIndex(const QModelIndex &index);
|
||||
QModelIndex currentIndex();
|
||||
QItemSelectionModel * selectionModel();
|
||||
void scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint );
|
||||
void toFullScreen();
|
||||
void toNormal();
|
||||
void updateConfig(QSettings * settings);
|
||||
void setItemActions(const QList<QAction *> & actions);
|
||||
void setViewActions(const QList<QAction *> & actions);
|
||||
|
||||
public slots:
|
||||
void centerComicFlow(const QModelIndex & mi);
|
||||
void updateTableView(int i);
|
||||
void saveTableHeadersStatus();
|
||||
void applyModelChanges(const QModelIndex & topLeft,const QModelIndex & bottomRight,const QVector<int> & roles);
|
||||
void removeItemsFromFlow(const QModelIndex & parent, int from, int to);
|
||||
//ComicsView
|
||||
void setShowMarks(bool show);
|
||||
void selectAll();
|
||||
|
||||
private:
|
||||
YACReaderTableView * tableView;
|
||||
QWidget *comics;
|
||||
QSplitter * sVertical;
|
||||
ComicFlowWidget * comicFlow;
|
||||
QSettings * settings;
|
||||
void closeEvent ( QCloseEvent * event );
|
||||
};
|
||||
|
||||
#endif // CLASSIC_COMICS_VIEW_H
|
||||
11
YACReaderLibrary/comics_view.cpp
Normal file
11
YACReaderLibrary/comics_view.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "comics_view.h"
|
||||
|
||||
ComicsView::ComicsView(QWidget *parent) :
|
||||
QWidget(parent),model(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void ComicsView::setModel(TableModel *m)
|
||||
{
|
||||
model = m;
|
||||
}
|
||||
47
YACReaderLibrary/comics_view.h
Normal file
47
YACReaderLibrary/comics_view.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef COMICS_VIEW_H
|
||||
#define COMICS_VIEW_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "tablemodel.h"
|
||||
#include <QAbstractItemView>
|
||||
#include <QSettings>
|
||||
#include <QModelIndex>
|
||||
#include <QModelIndexList>
|
||||
|
||||
class YACReaderTableView;
|
||||
class QSplitter;
|
||||
class ComicFlowWidget;
|
||||
class QToolBar;
|
||||
class TableModel;
|
||||
class ComicsView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ComicsView(QWidget *parent = 0);
|
||||
virtual void setToolBar(QToolBar * toolBar) = 0;
|
||||
virtual void setModel(TableModel *model);
|
||||
virtual void setCurrentIndex(const QModelIndex &index) = 0;
|
||||
virtual QModelIndex currentIndex() = 0;
|
||||
virtual QItemSelectionModel * selectionModel() = 0;
|
||||
virtual void scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint ) = 0;
|
||||
virtual void toFullScreen() = 0;
|
||||
virtual void toNormal() = 0;
|
||||
virtual void updateConfig(QSettings * settings) = 0;
|
||||
//Actions for tableviews
|
||||
virtual void setItemActions(const QList<QAction *> & actions) = 0;
|
||||
//actions for visual-oriented views
|
||||
virtual void setViewActions(const QList<QAction *> & actions) = 0;
|
||||
|
||||
signals:
|
||||
void selected(unsigned int);
|
||||
void comicRated(int,QModelIndex);
|
||||
public slots:
|
||||
virtual void setShowMarks(bool show) = 0;
|
||||
virtual void selectAll() = 0;
|
||||
protected:
|
||||
TableModel * model;
|
||||
|
||||
};
|
||||
|
||||
#endif // COMICS_VIEW_H
|
||||
74
YACReaderLibrary/comics_view_transition.cpp
Normal file
74
YACReaderLibrary/comics_view_transition.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
#include "comics_view_transition.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMovie>
|
||||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
#include <QSizePolicy>
|
||||
#include <QPainter>
|
||||
|
||||
#include "yacreader_global.h"
|
||||
|
||||
ComicsViewTransition::ComicsViewTransition(QWidget *parent) :
|
||||
QWidget(parent),movie(0)
|
||||
{
|
||||
QVBoxLayout * layout = new QVBoxLayout;
|
||||
|
||||
settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat);
|
||||
settings->beginGroup("libraryConfig");
|
||||
|
||||
movieLabel = new QLabel("Placeholder");
|
||||
movieLabel->setAlignment(Qt::AlignCenter);
|
||||
QLabel * textLabel = new QLabel("Switching comics view");
|
||||
textLabel->setAlignment(Qt::AlignCenter);
|
||||
textLabel->setStyleSheet("QLabel {color:#CCCCCC; font-size:24px;font-family:Arial;font-weight:bold;}");
|
||||
//movieLabel->setFixedSize(450,350);
|
||||
|
||||
layout->addSpacing(100);
|
||||
layout->addWidget(movieLabel);
|
||||
layout->addSpacing(20);
|
||||
layout->addWidget(textLabel);
|
||||
layout->addStretch();
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
|
||||
setContentsMargins(0,0,0,0);
|
||||
|
||||
setStyleSheet("QWidget {background:#2A2A2A}");
|
||||
|
||||
//QSizePolicy sp();
|
||||
setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
|
||||
//movieLabel->setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
QSize ComicsViewTransition::sizeHint()
|
||||
{
|
||||
return QSize(450,350);
|
||||
}
|
||||
|
||||
void ComicsViewTransition::startMovie()
|
||||
{
|
||||
if(movie)
|
||||
delete movie;
|
||||
|
||||
if(settings->value(COMICS_VIEW_STATUS) == YACReader::Flow)
|
||||
movie = new QMovie(":/images/flow_to_grid.gif");
|
||||
else
|
||||
movie = new QMovie(":/images/grid_to_flow.gif");
|
||||
|
||||
connect(movie,SIGNAL(finished()),this,SIGNAL(transitionFinished()));
|
||||
//connect(movie,SIGNAL(finished()),movie,SLOT(deleteLater());
|
||||
movie->setSpeed(200);
|
||||
movie->jumpToFrame(0);
|
||||
movieLabel->setMovie(movie);
|
||||
|
||||
QTimer::singleShot(100,movie,SLOT(start()));
|
||||
}
|
||||
|
||||
void ComicsViewTransition::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter (this);
|
||||
painter.fillRect(0,0,width(),height(),QColor("#2A2A2A"));
|
||||
}
|
||||
31
YACReaderLibrary/comics_view_transition.h
Normal file
31
YACReaderLibrary/comics_view_transition.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef COMICS_VIEW_TRANSITION_H
|
||||
#define COMICS_VIEW_TRANSITION_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QMovie;
|
||||
class QSettings;
|
||||
class QLabel;
|
||||
|
||||
class ComicsViewTransition : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ComicsViewTransition(QWidget *parent = 0);
|
||||
QSize sizeHint();
|
||||
|
||||
signals:
|
||||
void transitionFinished();
|
||||
|
||||
public slots:
|
||||
void startMovie();
|
||||
|
||||
protected:
|
||||
QMovie * movie;
|
||||
QSettings * settings;
|
||||
QLabel * movieLabel;
|
||||
|
||||
void paintEvent(QPaintEvent *);
|
||||
};
|
||||
|
||||
#endif // COMICS_VIEW_TRANSITION_H
|
||||
@ -210,7 +210,7 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
||||
//queryDBInfo.finish();
|
||||
|
||||
QSqlQuery query("INSERT INTO db_info (version) "
|
||||
"VALUES ('"VERSION"')",database);
|
||||
"VALUES ('" VERSION "')",database);
|
||||
//query.finish();
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ void DataBaseManagement::exportComicsInfo(QString source, QString dest)
|
||||
queryComicsInfo.exec();*/
|
||||
|
||||
QSqlQuery query("INSERT INTO dest.db_info (version) "
|
||||
"VALUES ('"VERSION"')",destDB);
|
||||
"VALUES ('" VERSION "')",destDB);
|
||||
//query.finish();
|
||||
|
||||
QSqlQuery exportData(destDB);
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
TableModel::TableModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
connect(this,SIGNAL(beforeReset()),this,SIGNAL(modelAboutToBeReset()));
|
||||
connect(this,SIGNAL(reset()),this,SIGNAL(modelReset()));
|
||||
@ -23,7 +23,7 @@ TableModel::TableModel(QObject *parent)
|
||||
|
||||
//! [0]
|
||||
TableModel::TableModel( QSqlQuery &sqlquery, QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
setupModelData(sqlquery);
|
||||
}
|
||||
@ -46,6 +46,27 @@ int TableModel::columnCount(const QModelIndex &parent) const
|
||||
}
|
||||
//! [2]
|
||||
|
||||
QHash<int, QByteArray> TableModel::roleNames() const {
|
||||
QHash<int, QByteArray> roles;
|
||||
|
||||
roles[NumberRole] = "number";
|
||||
roles[TitleRole] = "title";
|
||||
roles[FileNameRole] = "file_name";
|
||||
roles[NumPagesRole] = "num_pages";
|
||||
roles[IdRole] = "id";
|
||||
roles[Parent_IdRole] = "parent_id";
|
||||
roles[PathRole] = "path";
|
||||
roles[HashRole] = "hash";
|
||||
roles[ReadColumnRole] = "read_column";
|
||||
roles[IsBisRole] = "is_bis";
|
||||
roles[CurrentPageRole] = "current_page";
|
||||
roles[RatingRole] = "rating";
|
||||
roles[HasBeenOpenedRole] = "has_been_opened";
|
||||
roles[CoverPathRole] = "cover_path";
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
||||
//! [3]
|
||||
QVariant TableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
@ -84,10 +105,28 @@ QVariant TableModel::data(const QModelIndex &index, int role) const
|
||||
//TODO check here if any view is asking for TableModel::Roles
|
||||
//these roles will be used from QML/GridView
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
TableItem *item = static_cast<TableItem*>(index.internalPointer());
|
||||
|
||||
if (role == NumberRole)
|
||||
return item->data(Number);
|
||||
else if (role == TitleRole)
|
||||
return item->data(Title).isNull()?item->data(FileName):item->data(Title);
|
||||
else if (role == RatingRole)
|
||||
return item->data(Rating);
|
||||
else if (role == CoverPathRole)
|
||||
return "file:///"+_databasePath+"/covers/"+item->data(Hash).toString()+".jpg";
|
||||
else if (role == NumPagesRole)
|
||||
return item->data(NumPages);
|
||||
else if (role == CurrentPageRole)
|
||||
return item->data(CurrentPage);
|
||||
else if (role == ReadColumnRole)
|
||||
return item->data(ReadColumn).toBool();
|
||||
else if (role == HasBeenOpenedRole)
|
||||
return item->data(TableModel::HasBeenOpened);
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
if(index.column() == TableModel::Hash)
|
||||
return QString::number(item->data(index.column()).toString().right(item->data(index.column()).toString().length()-40).toInt()/1024.0/1024.0,'f',2)+"Mb";
|
||||
if(index.column() == TableModel::ReadColumn)
|
||||
@ -265,7 +304,9 @@ void TableModel::setupModelData(unsigned long long int folderId,const QString &
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(_databasePath);
|
||||
endResetModel();
|
||||
//f.close();
|
||||
|
||||
if(_data.length()==0)
|
||||
emit isEmpty();
|
||||
}
|
||||
|
||||
QString TableModel::getComicPath(QModelIndex mi)
|
||||
@ -467,7 +508,7 @@ QVector<YACReaderComicReadStatus> TableModel::setComicsRead(QList<QModelIndex> l
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(_databasePath);
|
||||
|
||||
emit dataChanged(index(list.first().row(),TableModel::ReadColumn),index(list.last().row(),TableModel::CurrentPage+1));
|
||||
emit dataChanged(index(list.first().row(),TableModel::ReadColumn),index(list.last().row(),TableModel::HasBeenOpened),QVector<int>() << ReadColumnRole << CurrentPageRole << HasBeenOpenedRole);
|
||||
|
||||
return getReadList();
|
||||
}
|
||||
@ -553,10 +594,10 @@ void TableModel::remove(ComicDB * comic, int row)
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
ComicDB TableModel::getComic(int row)
|
||||
/*ComicDB TableModel::getComic(int row)
|
||||
{
|
||||
return getComic(index(row,0));
|
||||
}
|
||||
}*/
|
||||
|
||||
void TableModel::remove(int row)
|
||||
{
|
||||
@ -580,8 +621,8 @@ void TableModel::reload(const ComicDB & comic)
|
||||
}
|
||||
row++;
|
||||
}
|
||||
if(found)
|
||||
emit dataChanged(index(row,TableModel::CurrentPage),index(row,TableModel::CurrentPage));
|
||||
if(found)
|
||||
emit dataChanged(index(row,ReadColumn),index(row,HasBeenOpened), QVector<int>() << ReadColumnRole << CurrentPageRole << HasBeenOpenedRole);
|
||||
}
|
||||
|
||||
void TableModel::resetComicRating(const QModelIndex &mi)
|
||||
@ -600,27 +641,6 @@ void TableModel::resetComicRating(const QModelIndex &mi)
|
||||
QSqlDatabase::removeDatabase(_databasePath);
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> TableModel::roleNames()
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
|
||||
roles[NumberRole] = "number";
|
||||
roles[TitleRole] = "title";
|
||||
roles[FileNameRole] = "file_name";
|
||||
roles[NumPagesRole] = "num_pages";
|
||||
roles[IdRole] = "id";
|
||||
roles[Parent_IdRole] = "parent_id";
|
||||
roles[PathRole] = "path";
|
||||
roles[HashRole] = "hash";
|
||||
roles[ReadColumnRole] = "read";
|
||||
roles[IsBisRole] = "is_bis";
|
||||
roles[CurrentPageRole] = "current_page";
|
||||
roles[RatingRole] = "rating";
|
||||
roles[HasBeenOpenedRole] = "has_been_opened";
|
||||
roles[CoverPathRole] = "cover_path";
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
||||
void TableModel::updateRating(int rating, QModelIndex mi)
|
||||
{
|
||||
|
||||
@ -24,7 +24,7 @@ public:
|
||||
TableModel(QObject *parent = 0);
|
||||
TableModel( QSqlQuery &sqlquery, QObject *parent = 0);
|
||||
~TableModel();
|
||||
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
@ -39,8 +39,9 @@ public:
|
||||
//M<>todos de conveniencia
|
||||
QStringList getPaths(const QString & _source);
|
||||
QString getComicPath(QModelIndex mi);
|
||||
QString getCurrentPath(){return QString(_databasePath).remove("/.yacreaderlibrary");};
|
||||
ComicDB getComic(const QModelIndex & mi); //--> para la edici<63>n
|
||||
ComicDB getComic(int row);
|
||||
//ComicDB getComic(int row);
|
||||
QVector<YACReaderComicReadStatus> getReadList();
|
||||
QVector<YACReaderComicReadStatus> setAllComicsRead(YACReaderComicReadStatus readStatus);
|
||||
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la informaci<63>n com<6F>n a los comics seleccionados
|
||||
@ -56,7 +57,7 @@ public:
|
||||
void reload(const ComicDB & comic);
|
||||
void resetComicRating(const QModelIndex & mi);
|
||||
|
||||
QHash<int, QByteArray> roleNames();
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
|
||||
enum Columns {
|
||||
Number = 0,
|
||||
@ -98,6 +99,8 @@ public slots:
|
||||
void finishTransaction();
|
||||
void updateRating(int rating, QModelIndex mi);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
void setupModelData( QSqlQuery &sqlquery);
|
||||
ComicDB _getComic(const QModelIndex & mi);
|
||||
@ -110,6 +113,7 @@ private:
|
||||
signals:
|
||||
void beforeReset();
|
||||
void reset();
|
||||
void isEmpty();
|
||||
};
|
||||
//! [0]
|
||||
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
#include "data_base_management.h"
|
||||
#include "folder.h"
|
||||
#include "db_helper.h"
|
||||
#include "qnaturalsorting.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include <QFileIconProvider>
|
||||
@ -106,7 +107,7 @@ TreeModel::TreeModel(QObject *parent)
|
||||
TreeModel::TreeModel( QSqlQuery &sqlquery, QObject *parent)
|
||||
: QAbstractItemModel(parent),rootItem(0),rootBeforeFilter(0),filterEnabled(false),includeComics(false)
|
||||
{
|
||||
//lo m<>s probable es que el nodo ra<72>z no necesite tener informaci<63>n
|
||||
//lo m<>s probable es que el nodo ra<72>z no necesite tener informaci<63>n
|
||||
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);
|
||||
@ -265,7 +266,7 @@ void TreeModel::setupModelData(QString path)
|
||||
filterEnabled = false;
|
||||
rootItem = 0;
|
||||
rootBeforeFilter = 0;
|
||||
//inicializar el nodo ra<72>z
|
||||
//inicializar el nodo ra<72>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);
|
||||
@ -291,10 +292,10 @@ void TreeModel::setupModelData(QString path)
|
||||
|
||||
void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||
{
|
||||
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
|
||||
//el diccionario permitir<69> encontrar cualquier nodo del <20>rbol r<>pidamente, de forma que a<>adir un hijo a un padre sea O(1)
|
||||
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
|
||||
//el diccionario permitir<69> encontrar cualquier nodo del <20>rbol r<>pidamente, de forma que a<>adir un hijo a un padre sea O(1)
|
||||
items.clear();
|
||||
//se a<>ade el nodo 0
|
||||
//se a<>ade el nodo 0
|
||||
items.insert(parent->id,parent);
|
||||
|
||||
while (sqlquery.next()) {
|
||||
@ -308,11 +309,11 @@ void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||
TreeItem * item = new TreeItem(data);
|
||||
|
||||
item->id = record.value("id").toULongLong();
|
||||
//la inserci<63>n de hijos se hace de forma ordenada
|
||||
//la inserci<63>n de hijos se hace de forma ordenada
|
||||
TreeItem * parent = items.value(record.value("parentId").toULongLong());
|
||||
if(parent !=0) //TODO if parent==0 the parent of item was removed from the DB and delete on cascade didn't work, ERROR.
|
||||
parent->appendChild(item);
|
||||
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
|
||||
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
|
||||
items.insert(item->id,item);
|
||||
}
|
||||
}
|
||||
@ -323,12 +324,12 @@ void TreeModel::setupFilteredModelData()
|
||||
|
||||
//TODO hay que liberar memoria de anteriores filtrados
|
||||
|
||||
//inicializar el nodo ra<72>z
|
||||
//inicializar el nodo ra<72>z
|
||||
|
||||
if(rootBeforeFilter == 0)
|
||||
rootBeforeFilter = rootItem;
|
||||
else
|
||||
delete rootItem;//los resultados de la b<>squeda anterior deben ser borrados
|
||||
delete rootItem;//los resultados de la b<>squeda anterior deben ser borrados
|
||||
|
||||
QList<QVariant> rootData;
|
||||
rootData << "root"; //id 1, padre 1, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
|
||||
@ -365,10 +366,10 @@ void TreeModel::setupFilteredModelData()
|
||||
|
||||
void TreeModel::setupFilteredModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||
{
|
||||
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
|
||||
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
|
||||
filteredItems.clear();
|
||||
|
||||
//se a<>ade el nodo 0 al modelo que representa el arbol de elementos que cumplen con el filtro
|
||||
//se a<>ade el nodo 0 al modelo que representa el arbol de elementos que cumplen con el filtro
|
||||
filteredItems.insert(parent->id,parent);
|
||||
|
||||
while (sqlquery.next()) { //se procesan todos los folders que cumplen con el filtro
|
||||
@ -387,39 +388,39 @@ void TreeModel::setupFilteredModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||
//id del padre
|
||||
quint64 parentId = record.value("parentId").toULongLong();
|
||||
|
||||
//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
|
||||
if(!filteredItems.contains(item->id))
|
||||
filteredItems.insert(item->id,item);
|
||||
|
||||
//es necesario conocer las coordenadas de origen para poder realizar scroll autom<6F>tico en la vista
|
||||
//es necesario conocer las coordenadas de origen para poder realizar scroll autom<6F>tico en la vista
|
||||
item->originalItem = items.value(item->id);
|
||||
|
||||
//si el padre ya existe en el modelo, el item se a<>ade como hijo
|
||||
//si el padre ya existe en el modelo, el item se a<>ade como hijo
|
||||
if(filteredItems.contains(parentId))
|
||||
filteredItems.value(parentId)->appendChild(item);
|
||||
else//si el padre a<>n no se ha a<>adido, hay que a<>adirlo a <20>l y todos los padres hasta el nodo ra<72>z
|
||||
else//si el padre a<>n no se ha a<>adido, hay que a<>adirlo a <20>l y todos los padres hasta el nodo ra<72>z
|
||||
{
|
||||
//comprobamos con esta variable si el <20>ltimo de los padres (antes del nodo ra<72>z) ya exist<73>a en el modelo
|
||||
//comprobamos con esta variable si el <20>ltimo de los padres (antes del nodo ra<72>z) ya exist<73>a en el modelo
|
||||
bool parentPreviousInserted = false;
|
||||
|
||||
//mientras no se alcance el nodo ra<72>z se procesan todos los padres (de abajo a arriba)
|
||||
//mientras no se alcance el nodo ra<72>z se procesan todos los padres (de abajo a arriba)
|
||||
while(parentId != ROOT )
|
||||
{
|
||||
//el padre no estaba en el modelo filtrado, as<61> que se rescata del modelo original
|
||||
//el padre no estaba en el modelo filtrado, as<61> que se rescata del modelo original
|
||||
TreeItem * parentItem = items.value(parentId);
|
||||
//se debe crear un nuevo nodo (para no compartir los hijos con el nodo original)
|
||||
TreeItem * newparentItem = new TreeItem(parentItem->getData()); //padre que se a<>adir<69> a la estructura de directorios filtrados
|
||||
TreeItem * newparentItem = new TreeItem(parentItem->getData()); //padre que se a<>adir<69> a la estructura de directorios filtrados
|
||||
newparentItem->id = parentId;
|
||||
|
||||
newparentItem->originalItem = parentItem;
|
||||
|
||||
//si el modelo contiene al padre, se a<>ade el item actual como hijo
|
||||
//si el modelo contiene al padre, se a<>ade el item actual como hijo
|
||||
if(filteredItems.contains(parentId))
|
||||
{
|
||||
filteredItems.value(parentId)->appendChild(item);
|
||||
parentPreviousInserted = true;
|
||||
}
|
||||
//sino se registra el nodo para poder encontrarlo con posterioridad y se a<>ade el item actual como hijo
|
||||
//sino se registra el nodo para poder encontrarlo con posterioridad y se a<>ade el item actual como hijo
|
||||
else
|
||||
{
|
||||
newparentItem->appendChild(item);
|
||||
@ -432,7 +433,7 @@ void TreeModel::setupFilteredModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||
parentId = parentItem->parentItem->id;
|
||||
}
|
||||
|
||||
//si el nodo es hijo de 1 y no hab<61>a sido previamente insertado como hijo, se a<>ade como tal
|
||||
//si el nodo es hijo de 1 y no hab<61>a sido previamente insertado como hijo, se a<>ade como tal
|
||||
if(!parentPreviousInserted)
|
||||
filteredItems.value(ROOT)->appendChild(item);
|
||||
}
|
||||
@ -468,7 +469,7 @@ void TreeModel::resetFilter()
|
||||
//items.clear();
|
||||
filteredItems.clear();
|
||||
TreeItem * root = rootItem;
|
||||
rootItem = rootBeforeFilter; //TODO si no se aplica el filtro previamente, esto invalidar<61>a en modelo
|
||||
rootItem = rootBeforeFilter; //TODO si no se aplica el filtro previamente, esto invalidar<61>a en modelo
|
||||
if(root !=0)
|
||||
delete root;
|
||||
|
||||
@ -518,3 +519,26 @@ void TreeModel::updateFolderFinishedStatus(const QModelIndexList &list, bool sta
|
||||
|
||||
emit dataChanged(index(list.first().row(),TreeModel::Name),index(list.last().row(),TreeModel::Completed));
|
||||
}
|
||||
|
||||
QStringList TreeModel::getSubfoldersNames(const QModelIndex &mi)
|
||||
{
|
||||
QStringList result;
|
||||
qulonglong id = 1;
|
||||
if(mi.isValid()){
|
||||
TreeItem * item = static_cast<TreeItem*>(mi.internalPointer());
|
||||
id = item->id;
|
||||
}
|
||||
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||
db.transaction();
|
||||
|
||||
result = DBHelper::loadSubfoldersNames(id,db);
|
||||
|
||||
db.commit();
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(_databasePath);
|
||||
|
||||
//TODO sort result))
|
||||
qSort(result.begin(),result.end(),naturalSortLessThanCI);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -85,6 +85,8 @@ public:
|
||||
void updateFolderCompletedStatus(const QModelIndexList & list, bool status);
|
||||
void updateFolderFinishedStatus(const QModelIndexList & list, bool status);
|
||||
|
||||
QStringList getSubfoldersNames(const QModelIndex & mi);
|
||||
|
||||
enum Columns {
|
||||
Name = 0,
|
||||
Path = 1,
|
||||
|
||||
@ -254,6 +254,7 @@ void DBHelper::update(ComicInfo * comicInfo, QSqlDatabase & db)
|
||||
updateComicInfo.bindValue(":notes",comicInfo->notes);
|
||||
|
||||
bool read = comicInfo->read || comicInfo->currentPage == comicInfo->numPages.toInt(); //if current page is the las page, the comic is read(completed)
|
||||
comicInfo->read = read;
|
||||
updateComicInfo.bindValue(":read", read?1:0);
|
||||
updateComicInfo.bindValue(":id", comicInfo->id);
|
||||
updateComicInfo.bindValue(":edited", comicInfo->edited?1:0);
|
||||
@ -298,6 +299,21 @@ void DBHelper::update(const Folder & folder, QSqlDatabase &db)
|
||||
updateFolderInfo.exec();
|
||||
}
|
||||
|
||||
void DBHelper::updateProgress(qulonglong libraryId, const ComicInfo &comicInfo)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||
|
||||
ComicDB comic = DBHelper::loadComic(comicInfo.id,db);
|
||||
comic.info.currentPage = comicInfo.currentPage;
|
||||
comic.info.hasBeenOpened = true;
|
||||
|
||||
DBHelper::update(&comic.info,db);
|
||||
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
}
|
||||
|
||||
void DBHelper::updateProgress(qulonglong libraryId, const ComicInfo &comicInfo)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
@ -686,5 +702,18 @@ ComicInfo DBHelper::loadComicInfo(QString hash, QSqlDatabase & db)
|
||||
else
|
||||
comicInfo.existOnDb = false;
|
||||
|
||||
return comicInfo;
|
||||
return comicInfo;
|
||||
}
|
||||
|
||||
QList<QString> DBHelper::loadSubfoldersNames(qulonglong folderId, QSqlDatabase &db)
|
||||
{
|
||||
QList<QString> result;
|
||||
QSqlQuery selectQuery(db);
|
||||
selectQuery.prepare("SELECT name FROM folder WHERE parentId = :parentId AND id <> 1"); //do not select the root folder
|
||||
selectQuery.bindValue(":parentId", folderId);
|
||||
selectQuery.exec();
|
||||
while(selectQuery.next()){
|
||||
result << selectQuery.record().value("name").toString();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -52,6 +52,7 @@ public:
|
||||
static ComicDB loadComic(qulonglong id, QSqlDatabase & db);
|
||||
static ComicDB loadComic(QString cname, QString cpath, QString chash, QSqlDatabase & database);
|
||||
static ComicInfo loadComicInfo(QString hash, QSqlDatabase & db);
|
||||
static QList<QString> loadSubfoldersNames(qulonglong folderId, QSqlDatabase & db);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
89
YACReaderLibrary/empty_folder_widget.cpp
Normal file
89
YACReaderLibrary/empty_folder_widget.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
#include "empty_folder_widget.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QListView>
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
#include <QStringListModel>
|
||||
void testListView(QListView * l)
|
||||
{
|
||||
QStringListModel * slm = new QStringListModel(QStringList() << "Lorem ipsum" << "Hailer skualer"<< "Mumbaluba X" << "Finger layden" << "Pacum tactus filer" << "Aposum" << "En" << "Lorem ipsum" << "Hailer skualer" << "Mumbaluba X" << "Finger layden" << "Pacum tactus filer" << "Aposum" << "En" );
|
||||
l->setModel(slm);
|
||||
}
|
||||
|
||||
EmptyFolderWidget::EmptyFolderWidget(QWidget *parent) :
|
||||
QWidget(parent),subfoldersModel(new QStringListModel())
|
||||
{
|
||||
QVBoxLayout * layout = new QVBoxLayout;
|
||||
|
||||
iconLabel = new QLabel();
|
||||
iconLabel->setPixmap(QPixmap(":/images/empty_folder.png"));
|
||||
iconLabel->setAlignment(Qt::AlignCenter);
|
||||
|
||||
titleLabel = new QLabel("Subfolders in this folder");
|
||||
titleLabel->setAlignment(Qt::AlignCenter);
|
||||
titleLabel->setStyleSheet("QLabel {color:#CCCCCC; font-size:24px;font-family:Arial;font-weight:bold;}");
|
||||
|
||||
foldersView = new QListView();
|
||||
foldersView->setMinimumWidth(282);
|
||||
foldersView->setWrapping(true);
|
||||
|
||||
foldersView->setStyleSheet("QListView {background-color:transparent; border: none; color:#858585; outline:0; font-size: 18px; font:bold; show-decoration-selected: 0; margin:0}"
|
||||
"QListView::item:selected {background-color: #212121; color:#CCCCCC;}"
|
||||
"QListView::item:hover {background-color:#212121; color:#CCCCCC; }"
|
||||
|
||||
|
||||
"QScrollBar:vertical { border: none; background: #212121; width: 14px; margin: 0 10px 0 0; }"
|
||||
"QScrollBar::handle:vertical { background: #858585; width: 14px; min-height: 20px; }"
|
||||
"QScrollBar::add-line:vertical { border: none; background: #212121; height: 0px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
|
||||
|
||||
"QScrollBar::sub-line:vertical { border: none; background: #212121; height: 0px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
|
||||
"QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
|
||||
"QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
|
||||
|
||||
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }"
|
||||
"QScrollBar:horizontal{height:0px;}"
|
||||
);
|
||||
|
||||
foldersView->setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
|
||||
testListView(foldersView);
|
||||
|
||||
layout->addSpacing(100);
|
||||
layout->addWidget(iconLabel);
|
||||
layout->addSpacing(30);
|
||||
layout->addWidget(titleLabel);
|
||||
layout->addSpacing(12);
|
||||
layout->addWidget(foldersView,1,Qt::AlignHCenter);
|
||||
layout->addStretch();
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
|
||||
setContentsMargins(0,0,0,0);
|
||||
|
||||
setStyleSheet("QWidget {background:#2A2A2A}");
|
||||
|
||||
setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
|
||||
setLayout(layout);
|
||||
|
||||
connect(foldersView,SIGNAL(clicked(QModelIndex)),this,SLOT(onItemClicked(QModelIndex)));
|
||||
}
|
||||
|
||||
void EmptyFolderWidget::setSubfolders(const QModelIndex &mi, const QStringList &foldersNames)
|
||||
{
|
||||
parent = mi;
|
||||
subfoldersModel->setStringList(foldersNames);
|
||||
foldersView->setModel(subfoldersModel);
|
||||
}
|
||||
|
||||
void EmptyFolderWidget::onItemClicked(const QModelIndex &mi)
|
||||
{
|
||||
emit subfolderSelected(parent,mi.row());
|
||||
}
|
||||
|
||||
void EmptyFolderWidget::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter (this);
|
||||
painter.fillRect(0,0,width(),height(),QColor("#2A2A2A"));
|
||||
}
|
||||
32
YACReaderLibrary/empty_folder_widget.h
Normal file
32
YACReaderLibrary/empty_folder_widget.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef EMPTY_FOLDER_WIDGET_H
|
||||
#define EMPTY_FOLDER_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QModelIndex>
|
||||
|
||||
class QLabel;
|
||||
class QListView;
|
||||
class QStringListModel;
|
||||
|
||||
class EmptyFolderWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EmptyFolderWidget(QWidget *parent = 0);
|
||||
void setSubfolders(const QModelIndex & mi, const QStringList & foldersNames);
|
||||
signals:
|
||||
void subfolderSelected(QModelIndex, int);
|
||||
|
||||
public slots:
|
||||
void onItemClicked(const QModelIndex & mi);
|
||||
|
||||
protected:
|
||||
QLabel * iconLabel;
|
||||
QLabel * titleLabel;
|
||||
QListView * foldersView;
|
||||
QModelIndex parent;
|
||||
QStringListModel * subfoldersModel;
|
||||
void paintEvent(QPaintEvent *);
|
||||
};
|
||||
|
||||
#endif // EMPTY_FOLDER_WIDGET_H
|
||||
234
YACReaderLibrary/grid_comics_view.cpp
Normal file
234
YACReaderLibrary/grid_comics_view.cpp
Normal file
@ -0,0 +1,234 @@
|
||||
#include "grid_comics_view.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QtQuick>
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
GridComicsView::GridComicsView(QWidget *parent) :
|
||||
ComicsView(parent),_selectionModel(NULL)
|
||||
{
|
||||
qmlRegisterType<TableModel>("comicModel",1,0,"TableModel");
|
||||
|
||||
view = new QQuickView();
|
||||
container = QWidget::createWindowContainer(view, this);
|
||||
|
||||
container->setMinimumSize(200, 200);
|
||||
container->setFocusPolicy(Qt::TabFocus);
|
||||
view->setSource(QUrl("qrc:/qml/GridComicsView.qml"));
|
||||
|
||||
setShowMarks(true);//TODO save this in settings
|
||||
|
||||
QVBoxLayout * l = new QVBoxLayout;
|
||||
l->addWidget(container);
|
||||
this->setLayout(l);
|
||||
|
||||
setContentsMargins(0,0,0,0);
|
||||
l->setContentsMargins(0,0,0,0);
|
||||
l->setSpacing(0);
|
||||
|
||||
QLOG_INFO() << "GridComicsView";
|
||||
}
|
||||
|
||||
GridComicsView::~GridComicsView()
|
||||
{
|
||||
delete view;
|
||||
}
|
||||
|
||||
void GridComicsView::setToolBar(QToolBar *toolBar)
|
||||
{
|
||||
QLOG_INFO() << "setToolBar";
|
||||
static_cast<QVBoxLayout *>(this->layout())->insertWidget(1,toolBar);
|
||||
}
|
||||
|
||||
void GridComicsView::setModel(TableModel *model)
|
||||
{
|
||||
QLOG_INFO() << "setModel";
|
||||
|
||||
QQmlContext *ctxt = view->rootContext();
|
||||
|
||||
//there is only one mothel in the system
|
||||
ComicsView::setModel(model);
|
||||
if(this->model != NULL)
|
||||
{
|
||||
QLOG_INFO() << "xxx";
|
||||
|
||||
if(_selectionModel != NULL)
|
||||
delete _selectionModel;
|
||||
_selectionModel = new QItemSelectionModel(this->model);
|
||||
|
||||
ctxt->setContextProperty("comicsList", this->model);
|
||||
ctxt->setContextProperty("comicsSelection", _selectionModel);
|
||||
ctxt->setContextProperty("comicsSelectionHelper", this);
|
||||
ctxt->setContextProperty("dummyValue", true);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
ctxt->setContextProperty("backgroundColor", "#EDEDED");
|
||||
ctxt->setContextProperty("cellColor", "#FFFFFF");
|
||||
ctxt->setContextProperty("selectedColor", "#DDDDDD");
|
||||
ctxt->setContextProperty("titleColor", "#121212");
|
||||
ctxt->setContextProperty("textColor", "#636363");
|
||||
ctxt->setContextProperty("dropShadow",true);
|
||||
#else
|
||||
ctxt->setContextProperty("backgroundColor", "#2A2A2A");
|
||||
ctxt->setContextProperty("cellColor", "#212121");
|
||||
ctxt->setContextProperty("selectedColor", "#121212");
|
||||
ctxt->setContextProperty("titleColor", "#E6E6E6");
|
||||
ctxt->setContextProperty("textColor", "#E6E6E6");
|
||||
ctxt->setContextProperty("dropShadow",false);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GridComicsView::setCurrentIndex(const QModelIndex &index)
|
||||
{
|
||||
QLOG_INFO() << "setCurrentIndex";
|
||||
}
|
||||
|
||||
QModelIndex GridComicsView::currentIndex()
|
||||
{
|
||||
QLOG_INFO() << "currentIndex";
|
||||
QModelIndexList indexes = _selectionModel->selectedRows();
|
||||
if(indexes.length()>0)
|
||||
return indexes[0];
|
||||
|
||||
this->selectIndex(0);
|
||||
return _selectionModel->selectedRows()[0];
|
||||
}
|
||||
|
||||
QItemSelectionModel *GridComicsView::selectionModel()
|
||||
{
|
||||
QLOG_INFO() << "selectionModel";
|
||||
QModelIndexList indexes = _selectionModel->selectedRows();
|
||||
if(indexes.length()==0)
|
||||
this->selectIndex(0);
|
||||
|
||||
return _selectionModel;
|
||||
}
|
||||
|
||||
void GridComicsView::scrollTo(const QModelIndex &mi, QAbstractItemView::ScrollHint hint)
|
||||
{
|
||||
QLOG_INFO() << "scrollTo";
|
||||
}
|
||||
|
||||
void GridComicsView::toFullScreen()
|
||||
{
|
||||
QLOG_INFO() << "toFullScreen";
|
||||
}
|
||||
|
||||
void GridComicsView::toNormal()
|
||||
{
|
||||
QLOG_INFO() << "toNormal";
|
||||
}
|
||||
|
||||
void GridComicsView::updateConfig(QSettings *settings)
|
||||
{
|
||||
QLOG_INFO() << "updateConfig";
|
||||
}
|
||||
|
||||
void GridComicsView::setItemActions(const QList<QAction *> &actions)
|
||||
{
|
||||
QLOG_INFO() << "setItemActions";
|
||||
}
|
||||
|
||||
void GridComicsView::setViewActions(const QList<QAction *> &actions)
|
||||
{
|
||||
//TODO generate QML Menu from actions
|
||||
QLOG_INFO() << "setViewActions";
|
||||
this->addActions(actions);
|
||||
|
||||
//TODO this is completely unsafe, but QActions can't be used directly in QML
|
||||
if(actions.length()>17)
|
||||
{
|
||||
QQmlContext *ctxt = view->rootContext();
|
||||
|
||||
ctxt->setContextProperty("openComicAction",actions[0]);
|
||||
|
||||
ctxt->setContextProperty("openContainingFolderComicAction",actions[2]);
|
||||
|
||||
ctxt->setContextProperty("resetComicRatingAction",actions[4]);
|
||||
|
||||
ctxt->setContextProperty("editSelectedComicsAction",actions[6]);
|
||||
ctxt->setContextProperty("getInfoAction",actions[7]);
|
||||
ctxt->setContextProperty("asignOrderAction",actions[8]);
|
||||
|
||||
ctxt->setContextProperty("selectAllComicsAction",actions[10]);
|
||||
|
||||
ctxt->setContextProperty("setAsReadAction",actions[12]);
|
||||
ctxt->setContextProperty("setAsNonReadAction",actions[13]);
|
||||
ctxt->setContextProperty("showHideMarksAction",actions[14]);
|
||||
|
||||
ctxt->setContextProperty("deleteComicsAction",actions[16]);
|
||||
|
||||
ctxt->setContextProperty("toggleFullScreenAction",actions[18]);
|
||||
}
|
||||
else
|
||||
QLOG_ERROR() << "setViewActions invoked with the wrong number of actions";
|
||||
}
|
||||
|
||||
void GridComicsView::selectAll()
|
||||
{
|
||||
QLOG_INFO() << "selectAll";
|
||||
}
|
||||
|
||||
QSize GridComicsView::sizeHint()
|
||||
{
|
||||
QLOG_INFO() << "sizeHint";
|
||||
return QSize(1280,768);
|
||||
}
|
||||
|
||||
//helper
|
||||
void GridComicsView::selectIndex(int index)
|
||||
{
|
||||
QLOG_INFO() << "selectIndex" << index;
|
||||
if(_selectionModel != NULL && model!=NULL)
|
||||
_selectionModel->select(model->index(index,0),QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
}
|
||||
|
||||
bool GridComicsView::isSelectedIndex(int index)
|
||||
{
|
||||
if(_selectionModel != NULL && model!=NULL)
|
||||
{
|
||||
QModelIndex mi = model->index(index,0);
|
||||
return _selectionModel->isSelected(mi);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GridComicsView::clear()
|
||||
{
|
||||
QLOG_INFO() << "clear";
|
||||
if(_selectionModel != NULL)
|
||||
{
|
||||
_selectionModel->clear();
|
||||
|
||||
QQmlContext *ctxt = view->rootContext();
|
||||
ctxt->setContextProperty("dummyValue", true);
|
||||
}
|
||||
//model->forceClear();
|
||||
}
|
||||
|
||||
void GridComicsView::selectedItem(int index)
|
||||
{
|
||||
emit doubleClicked(model->index(index,0));
|
||||
}
|
||||
|
||||
void GridComicsView::setShowMarks(bool show)
|
||||
{
|
||||
QLOG_INFO() << "setShowMarks";
|
||||
QQmlContext *ctxt = view->rootContext();
|
||||
ctxt->setContextProperty("show_marks", show);
|
||||
}
|
||||
|
||||
void GridComicsView::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QLOG_INFO() << "closeEvent";
|
||||
QObject *object = view->rootObject();
|
||||
QMetaObject::invokeMethod(object, "exit");
|
||||
container->close();
|
||||
view->close();
|
||||
event->accept();
|
||||
ComicsView::closeEvent(event);
|
||||
}
|
||||
59
YACReaderLibrary/grid_comics_view.h
Normal file
59
YACReaderLibrary/grid_comics_view.h
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef GRID_COMICS_VIEW_H
|
||||
#define GRID_COMICS_VIEW_H
|
||||
|
||||
#include "comics_view.h"
|
||||
|
||||
#include <QModelIndex>
|
||||
|
||||
class QAbstractListModel;
|
||||
class QItemSelectionModel;
|
||||
class QQuickView;
|
||||
class QQuickView;
|
||||
|
||||
|
||||
class GridComicsView : public ComicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GridComicsView(QWidget *parent = 0);
|
||||
virtual ~GridComicsView();
|
||||
void setToolBar(QToolBar * toolBar);
|
||||
void setModel(TableModel *model);
|
||||
void setCurrentIndex(const QModelIndex &index);
|
||||
QModelIndex currentIndex();
|
||||
QItemSelectionModel * selectionModel();
|
||||
void scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint );
|
||||
void toFullScreen();
|
||||
void toNormal();
|
||||
void updateConfig(QSettings * settings);
|
||||
void setItemActions(const QList<QAction *> & actions);
|
||||
void setViewActions(const QList<QAction *> & actions);
|
||||
|
||||
QSize sizeHint();
|
||||
signals:
|
||||
signals:
|
||||
void comicRated(int,QModelIndex);
|
||||
void doubleClicked(QModelIndex);
|
||||
|
||||
public slots:
|
||||
//selection helper
|
||||
void selectIndex(int index);
|
||||
bool isSelectedIndex(int index);
|
||||
void clear();
|
||||
//double clicked item
|
||||
void selectedItem(int index);
|
||||
|
||||
//ComicsView
|
||||
void setShowMarks(bool show);
|
||||
void selectAll();
|
||||
|
||||
private:
|
||||
QItemSelectionModel * _selectionModel;
|
||||
QQuickView *view;
|
||||
QWidget *container;
|
||||
bool dummy;
|
||||
void closeEvent ( QCloseEvent * event );
|
||||
|
||||
};
|
||||
|
||||
#endif // GRID_COMICS_VIEW_H
|
||||
@ -77,7 +77,7 @@
|
||||
<file>../images/social_dialog/shadow.png</file>
|
||||
<file>../images/social_dialog/twitter.png</file>
|
||||
<file>../images/social_dialog/separator.png</file>-->
|
||||
<file>../images/main_toolbar/divider.png</file>
|
||||
<file>../images/main_toolbar/divider.png</file>
|
||||
<file>../images/collapsed_branch_osx.png</file>
|
||||
<file>../images/expanded_branch_osx.png</file>
|
||||
<file>../images/folder_macosx.png</file>
|
||||
@ -100,8 +100,18 @@
|
||||
<file>../images/comic_vine/downArrow.png</file>
|
||||
<file>../images/comic_vine/upArrow.png</file>
|
||||
<file>../images/find_folder.png</file>
|
||||
<file>../images/clear_shortcut.png</file>
|
||||
<file>../images/accept_shortcut.png</file>
|
||||
<file>../images/f_overlayed.png</file>
|
||||
<file>../images/f_overlayed_retina.png</file>
|
||||
<file>../images/shortcuts_group_comics.png</file>
|
||||
<file>../images/shortcuts_group_folders.png</file>
|
||||
<file>../images/shortcuts_group_general.png</file>
|
||||
<file>../images/shortcuts_group_libraries.png</file>
|
||||
<file>../images/shortcuts_group_mglass.png</file>
|
||||
<file>../images/shortcuts_group_page.png</file>
|
||||
<file>../images/shortcuts_group_reading.png</file>
|
||||
<file>../images/shortcuts_group_visualization.png</file>
|
||||
<!--<file>../images/busy_background.png</file>-->
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@ -17,5 +17,8 @@
|
||||
<file alias="images/colapse.png">../images/colapse_osx.png</file>
|
||||
<file alias="images/newLibraryIcon.png">../images/newLibraryIcon_osx.png</file>
|
||||
<file alias="images/openLibraryIcon.png">../images/openLibraryIcon_osx.png</file>
|
||||
<file alias="images/flow_to_grid.gif">../images/flow_to_grid.gif</file>
|
||||
<file alias="images/grid_to_flow.gif">../images/grid_to_flow.gif</file>
|
||||
<file alias="images/empty_folder.png">../images/empty_folder.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@ -1,19 +1,23 @@
|
||||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file>../images/main_toolbar/back.png</file>
|
||||
<file>../images/main_toolbar/back_disabled.png</file>
|
||||
<file>../images/main_toolbar/forward.png</file>
|
||||
<file>../images/main_toolbar/forward_disabled.png</file>
|
||||
<file>../images/main_toolbar/settings.png</file>
|
||||
<file>../images/main_toolbar/server.png</file>
|
||||
<file>../images/main_toolbar/help.png</file>
|
||||
<file>../images/main_toolbar/fullscreen.png</file>
|
||||
|
||||
<file>../images/libraryIcon.png</file>
|
||||
<file>../images/setRoot.png</file>
|
||||
<file>../images/expand.png</file>
|
||||
<file>../images/colapse.png</file>
|
||||
<file>../images/newLibraryIcon.png</file>
|
||||
<file>../images/openLibraryIcon.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/">
|
||||
<file>../images/main_toolbar/back.png</file>
|
||||
<file>../images/main_toolbar/back_disabled.png</file>
|
||||
<file>../images/main_toolbar/forward.png</file>
|
||||
<file>../images/main_toolbar/forward_disabled.png</file>
|
||||
<file>../images/main_toolbar/settings.png</file>
|
||||
<file>../images/main_toolbar/server.png</file>
|
||||
<file>../images/main_toolbar/help.png</file>
|
||||
<file>../images/main_toolbar/fullscreen.png</file>
|
||||
<file>../images/libraryIcon.png</file>
|
||||
<file>../images/setRoot.png</file>
|
||||
<file>../images/expand.png</file>
|
||||
<file>../images/colapse.png</file>
|
||||
<file>../images/newLibraryIcon.png</file>
|
||||
<file>../images/openLibraryIcon.png</file>
|
||||
<file>../images/main_toolbar/flow.png</file>
|
||||
<file>../images/main_toolbar/grid.png</file>
|
||||
<file>../images/flow_to_grid.gif</file>
|
||||
<file>../images/grid_to_flow.gif</file>
|
||||
<file>../images/empty_folder.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -27,7 +27,6 @@ class HelpAboutDialog;
|
||||
class RenameLibraryDialog;
|
||||
class PropertiesDialog;
|
||||
class PackageManager;
|
||||
class ComicFlowWidget;
|
||||
class QCheckBox;
|
||||
class QPushButton;
|
||||
class TableModel;
|
||||
@ -50,6 +49,13 @@ class YACReaderLibraryListWidget;
|
||||
class YACReaderTreeView;
|
||||
class YACReaderMainToolBar;
|
||||
class ComicVineDialog;
|
||||
class ComicsView;
|
||||
class ClassicComicsView;
|
||||
class GridComicsView;
|
||||
class ComicsViewTransition;
|
||||
class EmptyFolderWidget;
|
||||
class EditShortcutsDialog;
|
||||
|
||||
#include "comic_db.h"
|
||||
|
||||
using namespace YACReader;
|
||||
@ -59,7 +65,7 @@ class LibraryWindow : public QMainWindow
|
||||
Q_OBJECT
|
||||
private:
|
||||
YACReaderSideBar * sideBar;
|
||||
QSplitter * sVertical;
|
||||
|
||||
CreateLibraryDialog * createLibraryDialog;
|
||||
ExportLibraryDialog * exportLibraryDialog;
|
||||
ImportLibraryDialog * importLibraryDialog;
|
||||
@ -71,6 +77,7 @@ private:
|
||||
RenameLibraryDialog * renameLibraryDialog;
|
||||
PropertiesDialog * propertiesDialog;
|
||||
ComicVineDialog * comicVineDialog;
|
||||
EditShortcutsDialog * editShortcutsDialog;
|
||||
//YACReaderSocialDialog * socialDialog;
|
||||
bool fullscreen;
|
||||
bool importedCovers; //if true, the library is read only (not updates,open comic or properties)
|
||||
@ -80,7 +87,6 @@ private:
|
||||
//YACReaderSortComics * proxySort;
|
||||
PackageManager * packageManager;
|
||||
|
||||
ComicFlowWidget * comicFlow;
|
||||
QSize slideSizeW;
|
||||
QSize slideSizeF;
|
||||
//search filter
|
||||
@ -91,15 +97,20 @@ private:
|
||||
QPushButton * clearFoldersFilter;
|
||||
QCheckBox * includeComicsCheckBox;
|
||||
//-------------
|
||||
QWidget *comics;
|
||||
YACReaderTableView * comicView;
|
||||
|
||||
ComicsView * comicsView;
|
||||
ClassicComicsView * classicComicsView;
|
||||
GridComicsView * gridComicsView;
|
||||
QStackedWidget * comicsViewStack;
|
||||
ComicsViewTransition * comicsViewTransition;
|
||||
EmptyFolderWidget * emptyFolderWidget;
|
||||
|
||||
YACReaderTreeView * foldersView;
|
||||
YACReaderLibraryListWidget * selectedLibrary;
|
||||
TreeModel * dm;
|
||||
TableModel * dmCV;
|
||||
//QStringList paths;
|
||||
YACReaderLibraries libraries;
|
||||
QLabel * fullScreenToolTip;
|
||||
|
||||
QStackedWidget * mainWidget;
|
||||
NoLibrariesWidget * noLibrariesWidget;
|
||||
@ -116,8 +127,8 @@ private:
|
||||
QAction * createLibraryAction;
|
||||
QAction * openLibraryAction;
|
||||
|
||||
QAction * exportComicsInfo;
|
||||
QAction * importComicsInfo;
|
||||
QAction * exportComicsInfoAction;
|
||||
QAction * importComicsInfoAction;
|
||||
|
||||
QAction * exportLibraryAction;
|
||||
QAction * importLibraryAction;
|
||||
@ -129,6 +140,7 @@ private:
|
||||
QAction * toggleFullScreenAction;
|
||||
QAction * optionsAction;
|
||||
QAction * serverConfigAction;
|
||||
QAction * toggleComicsViewAction;
|
||||
//QAction * socialAction;
|
||||
|
||||
//tree actions
|
||||
@ -141,8 +153,8 @@ private:
|
||||
QAction * setFolderAsNotCompletedAction;
|
||||
QAction * setFolderAsCompletedAction;
|
||||
//--
|
||||
QAction * setFolderAsFinishedAction;
|
||||
QAction * setFolderAsNotFinishedAction;
|
||||
QAction * setFolderAsReadAction;
|
||||
QAction * setFolderAsUnreadAction;
|
||||
|
||||
QAction * openContainingFolderComicAction;
|
||||
QAction * setAsReadAction;
|
||||
@ -156,11 +168,16 @@ private:
|
||||
//edit info actions
|
||||
QAction * selectAllComicsAction;
|
||||
QAction * editSelectedComicsAction;
|
||||
QAction * asignOrderActions;
|
||||
QAction * forceConverExtractedAction;
|
||||
QAction * asignOrderAction;
|
||||
QAction * forceCoverExtractedAction;
|
||||
QAction * deleteComicsAction;
|
||||
QAction * hideComicViewAction;
|
||||
|
||||
QAction *showEditShortcutsAction;
|
||||
|
||||
QList<QAction *> itemActions;
|
||||
QList<QAction *> viewActions;
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
QToolBar * libraryToolBar;
|
||||
#else
|
||||
@ -191,103 +208,113 @@ private:
|
||||
void createConnections();
|
||||
void doLayout();
|
||||
void doDialogs();
|
||||
void setUpShortcutsManagement();
|
||||
void doModels();
|
||||
void disconnectComicsViewConnections(ComicsView * widget);
|
||||
void doComicsViewConnections();
|
||||
|
||||
//ACTIONS MANAGEMENT
|
||||
void disableComicsActions(bool disabled);
|
||||
void disableLibrariesActions(bool disabled);
|
||||
void disableNoUpdatedLibrariesActions(bool disabled);
|
||||
void disableFoldersActions(bool disabled);
|
||||
|
||||
void disableAllActions();
|
||||
//void disableActions();
|
||||
//void enableActions();
|
||||
//void enableLibraryActions();
|
||||
//ACTIONS MANAGEMENT
|
||||
void disableComicsActions(bool disabled);
|
||||
void disableLibrariesActions(bool disabled);
|
||||
void disableNoUpdatedLibrariesActions(bool disabled);
|
||||
void disableFoldersActions(bool disabled);
|
||||
|
||||
QString currentPath();
|
||||
void disableAllActions();
|
||||
//void disableActions();
|
||||
//void enableActions();
|
||||
//void enableLibraryActions();
|
||||
|
||||
//settings
|
||||
QSettings * settings;
|
||||
QString currentPath();
|
||||
|
||||
//navigation backward and forward
|
||||
int currentFolderNavigation;
|
||||
QList<QModelIndex> history;
|
||||
//settings
|
||||
QSettings * settings;
|
||||
|
||||
bool removeError;
|
||||
//navigation backward and forward
|
||||
int currentFolderNavigation;
|
||||
QList<QModelIndex> history;
|
||||
|
||||
bool removeError;
|
||||
|
||||
ComicsViewStatus comicsViewStatus;
|
||||
|
||||
protected:
|
||||
virtual void closeEvent ( QCloseEvent * event );
|
||||
virtual void closeEvent ( QCloseEvent * event );
|
||||
public:
|
||||
LibraryWindow();
|
||||
public slots:
|
||||
void loadLibrary(const QString & path);
|
||||
void loadCovers(const QModelIndex & mi);
|
||||
void checkEmptyFolder(QStringList * paths = 0);
|
||||
void reloadCovers();
|
||||
void centerComicFlow(const QModelIndex & mi);
|
||||
void updateComicView(int i);
|
||||
void openComic();
|
||||
void createLibrary();
|
||||
void create(QString source,QString dest, QString name);
|
||||
void showAddLibrary();
|
||||
void openLibrary(QString path, QString name);
|
||||
void loadLibraries();
|
||||
void saveLibraries();
|
||||
void reloadCurrentLibrary();
|
||||
void openLastCreated();
|
||||
void updateLibrary();
|
||||
//void deleteLibrary();
|
||||
void openContainingFolder();
|
||||
void setFolderAsNotCompleted();
|
||||
void setFolderAsCompleted();
|
||||
void setFolderAsFinished();
|
||||
void setFolderAsNotFinished();
|
||||
void openContainingFolderComic();
|
||||
void deleteCurrentLibrary();
|
||||
void removeLibrary();
|
||||
void renameLibrary();
|
||||
void rename(QString newName);
|
||||
void cancelCreating();
|
||||
void stopLibraryCreator();
|
||||
void setRootIndex();
|
||||
void toggleFullScreen();
|
||||
void toNormal();
|
||||
void toFullScreen();
|
||||
void setFoldersFilter(QString filter);
|
||||
void showProperties();
|
||||
void exportLibrary(QString destPath);
|
||||
void importLibrary(QString clc,QString destPath,QString name);
|
||||
void reloadOptions();
|
||||
void setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus);
|
||||
void setCurrentComicReaded();
|
||||
void setCurrentComicUnreaded();
|
||||
void setComicsReaded();
|
||||
void setComicsUnreaded();
|
||||
void hideComicFlow(bool hide);
|
||||
void showExportComicsInfo();
|
||||
void showImportComicsInfo();
|
||||
void asignNumbers();
|
||||
void showNoLibrariesWidget();
|
||||
void showRootWidget();
|
||||
void showImportingWidget();
|
||||
void manageCreatingError(const QString & error);
|
||||
void manageUpdatingError(const QString & error);
|
||||
void manageOpeningLibraryError(const QString & error);
|
||||
QModelIndexList getSelectedComics();
|
||||
void deleteComics();
|
||||
//void showSocial();
|
||||
void backward();
|
||||
void forward();
|
||||
void updateHistory(const QModelIndex & mi);
|
||||
void updateFoldersViewConextMenu(const QModelIndex & mi);
|
||||
void libraryAlreadyExists(const QString & name);
|
||||
void importLibraryPackage();
|
||||
void updateComicsView(quint64 libraryId, const ComicDB & comic);
|
||||
void setCurrentComicOpened();
|
||||
void showComicVineScraper();
|
||||
void setRemoveError();
|
||||
void checkRemoveError();
|
||||
void resetComicRating();
|
||||
LibraryWindow();
|
||||
|
||||
public slots:
|
||||
void loadLibrary(const QString & path);
|
||||
void loadCovers(const QModelIndex & mi);
|
||||
void selectSubfolder(const QModelIndex & mi, int child);
|
||||
void checkEmptyFolder(QStringList * paths = 0);
|
||||
void reloadCovers();
|
||||
void openComic();
|
||||
void createLibrary();
|
||||
void create(QString source,QString dest, QString name);
|
||||
void showAddLibrary();
|
||||
void openLibrary(QString path, QString name);
|
||||
void loadLibraries();
|
||||
void saveLibraries();
|
||||
void reloadCurrentLibrary();
|
||||
void openLastCreated();
|
||||
void updateLibrary();
|
||||
//void deleteLibrary();
|
||||
void openContainingFolder();
|
||||
void setFolderAsNotCompleted();
|
||||
void setFolderAsCompleted();
|
||||
void setFolderAsRead();
|
||||
void setFolderAsUnread();
|
||||
void openContainingFolderComic();
|
||||
void deleteCurrentLibrary();
|
||||
void removeLibrary();
|
||||
void renameLibrary();
|
||||
void rename(QString newName);
|
||||
void cancelCreating();
|
||||
void stopLibraryCreator();
|
||||
void setRootIndex();
|
||||
void toggleFullScreen();
|
||||
void toNormal();
|
||||
void toFullScreen();
|
||||
void setFoldersFilter(QString filter);
|
||||
void showProperties();
|
||||
void exportLibrary(QString destPath);
|
||||
void importLibrary(QString clc,QString destPath,QString name);
|
||||
void reloadOptions();
|
||||
void setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus);
|
||||
void setCurrentComicReaded();
|
||||
void setCurrentComicUnreaded();
|
||||
void hideComicFlow(bool hide);
|
||||
void showExportComicsInfo();
|
||||
void showImportComicsInfo();
|
||||
void asignNumbers();
|
||||
void showNoLibrariesWidget();
|
||||
void showRootWidget();
|
||||
void showImportingWidget();
|
||||
void manageCreatingError(const QString & error);
|
||||
void manageUpdatingError(const QString & error);
|
||||
void manageOpeningLibraryError(const QString & error);
|
||||
QModelIndexList getSelectedComics();
|
||||
void deleteComics();
|
||||
//void showSocial();
|
||||
void backward();
|
||||
void forward();
|
||||
void updateHistory(const QModelIndex & mi);
|
||||
void updateFoldersViewConextMenu(const QModelIndex & mi);
|
||||
void libraryAlreadyExists(const QString & name);
|
||||
void importLibraryPackage();
|
||||
void updateComicsView(quint64 libraryId, const ComicDB & comic);
|
||||
void setCurrentComicOpened();
|
||||
void showComicVineScraper();
|
||||
void setRemoveError();
|
||||
void checkRemoveError();
|
||||
void resetComicRating();
|
||||
void switchToComicsView(ComicsView *from, ComicsView *to);
|
||||
void showComicsViewTransition();
|
||||
void toggleComicsView_delayed();//used in orther to avoid flickering;
|
||||
void showComicsView();
|
||||
void showEmptyFolderView();
|
||||
void toggleComicsView();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -239,9 +239,12 @@ int main( int argc, char ** argv )
|
||||
|
||||
YACReader::exitCheck(ret);
|
||||
|
||||
//server shutdown
|
||||
//shutdown
|
||||
s->stop();
|
||||
delete s;
|
||||
localServer->close();
|
||||
delete localServer;
|
||||
delete mw;
|
||||
|
||||
QsLogging::Logger::destroyInstance();
|
||||
|
||||
|
||||
@ -20,33 +20,50 @@ FlowType flowType = Strip;
|
||||
OptionsDialog::OptionsDialog(QWidget * parent)
|
||||
:YACReaderOptionsDialog(parent)
|
||||
{
|
||||
QVBoxLayout * layout = new QVBoxLayout;
|
||||
QTabWidget * tabWidget = new QTabWidget();
|
||||
|
||||
QHBoxLayout * switchFlowType = new QHBoxLayout;
|
||||
switchFlowType->addStretch();
|
||||
switchFlowType->addWidget(useGL);
|
||||
QVBoxLayout * layout = new QVBoxLayout(this);
|
||||
|
||||
QVBoxLayout * flowLayout = new QVBoxLayout;
|
||||
QVBoxLayout * generalLayout = new QVBoxLayout();
|
||||
|
||||
QHBoxLayout * switchFlowType = new QHBoxLayout;
|
||||
switchFlowType->addStretch();
|
||||
switchFlowType->addWidget(useGL);
|
||||
|
||||
QHBoxLayout * buttons = new QHBoxLayout();
|
||||
buttons->addStretch();
|
||||
buttons->addWidget(accept);
|
||||
buttons->addWidget(cancel);
|
||||
QHBoxLayout * buttons = new QHBoxLayout();
|
||||
buttons->addStretch();
|
||||
buttons->addWidget(accept);
|
||||
buttons->addWidget(cancel);
|
||||
|
||||
layout->addWidget(sw);
|
||||
layout->addWidget(gl);
|
||||
layout->addLayout(switchFlowType);
|
||||
layout->addLayout(buttons);
|
||||
flowLayout->addWidget(sw);
|
||||
flowLayout->addWidget(gl);
|
||||
flowLayout->addLayout(switchFlowType);
|
||||
|
||||
sw->hide();
|
||||
sw->hide();
|
||||
|
||||
setLayout(layout);
|
||||
//restoreOptions(settings); //load options
|
||||
//resize(200,0);
|
||||
setModal (true);
|
||||
setWindowTitle(tr("Options"));
|
||||
QWidget * comicFlowW = new QWidget;
|
||||
comicFlowW->setLayout(flowLayout);
|
||||
|
||||
QWidget * generalW = new QWidget;
|
||||
generalW->setLayout(generalLayout);
|
||||
generalLayout->addWidget(shortcutsBox);
|
||||
generalLayout->addStretch();
|
||||
|
||||
tabWidget->addTab(comicFlowW,tr("Comic Flow"));
|
||||
tabWidget->addTab(generalW,tr("General"));
|
||||
|
||||
layout->addWidget(tabWidget);
|
||||
layout->addLayout(buttons);
|
||||
setLayout(layout);
|
||||
//restoreOptions(settings); //load options
|
||||
//resize(200,0);
|
||||
setModal (true);
|
||||
setWindowTitle(tr("Options"));
|
||||
|
||||
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||
|
||||
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
8
YACReaderLibrary/qml.qrc
Normal file
8
YACReaderLibrary/qml.qrc
Normal file
@ -0,0 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>qml/GridComicsView.qml</file>
|
||||
<file>qml/YACReaderScrollView.qml</file>
|
||||
<file>qml/tick.png</file>
|
||||
<file>qml/reading.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
295
YACReaderLibrary/qml/GridComicsView.qml
Normal file
295
YACReaderLibrary/qml/GridComicsView.qml
Normal file
@ -0,0 +1,295 @@
|
||||
import QtQuick 2.3
|
||||
import QtQuick.Controls 1.0
|
||||
import QtQuick.Controls 1.1
|
||||
import QtGraphicalEffects 1.0
|
||||
import comicModel 1.0
|
||||
|
||||
Rectangle {
|
||||
id: main
|
||||
color: backgroundColor
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
anchors.margins: 0
|
||||
|
||||
function selectAll(from,to)
|
||||
{
|
||||
for(var i = from+1;i<to;i++)
|
||||
{
|
||||
comicsSelectionHelper.selectIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: appDelegate
|
||||
Rectangle
|
||||
{
|
||||
id: cell
|
||||
width: grid.cellWidth
|
||||
height: grid.cellHeight
|
||||
color: backgroundColor
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
comicsSelectionHelper.clear();
|
||||
comicsSelectionHelper.selectIndex(grid.currentIndex);
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: realCell
|
||||
|
||||
width: 156; height: 287
|
||||
color: ((dummyValue || !dummyValue) && comicsSelectionHelper.isSelectedIndex(index)) || grid.currentIndex === index?selectedColor:cellColor;
|
||||
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
onDoubleClicked: {
|
||||
|
||||
comicsSelectionHelper.clear();
|
||||
|
||||
comicsSelectionHelper.selectIndex(index);
|
||||
grid.currentIndex = index;
|
||||
comicsSelectionHelper.selectedItem(index);
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
//grid.currentIndex = index
|
||||
//comicsSelection.setCurrentIndex(index,0x0002)
|
||||
var ci = grid.currentIndex;
|
||||
if(mouse.button == Qt.RightButton || !(mouse.modifiers & Qt.ControlModifier || mouse.modifiers & Qt.ShiftModifier))
|
||||
{
|
||||
comicsSelectionHelper.clear();
|
||||
}
|
||||
|
||||
if(mouse.button == Qt.RightButton)
|
||||
myContextMenu.popup();
|
||||
|
||||
if(mouse.modifiers & Qt.ShiftModifier)
|
||||
if(index < ci)
|
||||
selectAll(index,ci);
|
||||
else if (index > ci)
|
||||
selectAll(ci,index);
|
||||
|
||||
mouse.accepted = true;
|
||||
|
||||
comicsSelectionHelper.selectIndex(index)
|
||||
grid.currentIndex = index;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Menu emits the 'main' signals
|
||||
Menu {
|
||||
id: myContextMenu
|
||||
MenuItem { text: "Open comic"; enabled: true; iconSource:"qrc:///images/openInYACReader.png"; onTriggered: openComicAction.trigger() }
|
||||
MenuSeparator{}
|
||||
MenuItem { text: "Open containing folder..."; enabled: true; iconSource: "qrc:///images/open.png"; onTriggered: openContainingFolderComicAction.trigger() }
|
||||
MenuSeparator{}
|
||||
MenuItem { text: "Reset comic rating"; onTriggered: resetComicRatingAction.trigger() }
|
||||
MenuSeparator{}
|
||||
MenuItem { text: "Edit"; enabled: true; iconSource:"qrc:///images/editComic.png"; onTriggered: editSelectedComicsAction.trigger() }
|
||||
MenuItem { text: "Download tags from Comic Vine"; enabled: true; iconSource:"qrc:///images/getInfo.png"; onTriggered: getInfoAction.trigger() }
|
||||
MenuItem { text: "Asign current order to comics"; enabled: true; iconSource:"qrc:///images/asignNumber.png"; onTriggered: asignOrderAction.trigger() }
|
||||
MenuSeparator{}
|
||||
MenuItem { text: "Select all comics"; enabled: true; iconSource:"qrc:///images/selectAll.png"; onTriggered: selectAllComicsAction.trigger() }
|
||||
MenuSeparator{}
|
||||
MenuItem { text: "Set as read"; enabled: true; iconSource:"qrc:///images/setReadButton.png"; onTriggered: setAsReadAction.trigger() }
|
||||
MenuItem { text: "Set as unread"; enabled: true; iconSource:"qrc:///images/setUnread.png"; onTriggered: setAsNonReadAction.trigger() }
|
||||
MenuItem { text: "Show or hide read marks"; enabled: true; iconSource:"qrc:///images/showMarks.png"; onTriggered: showHideMarksAction.trigger() }
|
||||
MenuSeparator{}
|
||||
MenuItem { text: "Delete selected comics"; enabled: true; iconSource:"qrc:///images/trash.png"; onTriggered: deleteComicsAction.trigger() }
|
||||
MenuSeparator{}
|
||||
MenuItem { text: "Fullscreen mode on/off"; onTriggered: toggleFullScreenAction.trigger() }
|
||||
//MenuItem { text: "Show details"; onTriggered: cell.state = 'Details';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
DropShadow {
|
||||
anchors.fill: source
|
||||
horizontalOffset: 0
|
||||
verticalOffset: 0
|
||||
radius: 3
|
||||
samples: 24
|
||||
color: "#40000000"
|
||||
transparentBorder: true;
|
||||
source: realCell;
|
||||
enabled: dropShadow;
|
||||
visible: dropShadow;
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
//cover
|
||||
Image {
|
||||
id: coverElement
|
||||
width: 148
|
||||
height: 224
|
||||
anchors {horizontalCenter: parent.horizontalCenter; top: realCell.top; topMargin: 4}
|
||||
source: cover_path
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
//smooth: true
|
||||
mipmap: true
|
||||
//antialiasing: true
|
||||
asynchronous : true
|
||||
cache: false //TODO clear cache only when it is neede
|
||||
}
|
||||
//mark
|
||||
Image {
|
||||
id: mark
|
||||
width: 23
|
||||
height: 23
|
||||
source: read_column&&show_marks?"tick.png":has_been_opened&&show_marks?"reading.png":""
|
||||
anchors {right: coverElement.right; top: coverElement.top; topMargin: 11; rightMargin: 11}
|
||||
asynchronous : true
|
||||
}
|
||||
|
||||
//title
|
||||
Text {
|
||||
anchors { top: realCell.top; left: realCell.left; leftMargin: 4; rightMargin: 4; topMargin: 234; }
|
||||
width: 148
|
||||
maximumLineCount: 2
|
||||
wrapMode: Text.WordWrap
|
||||
text: title
|
||||
elide: Text.ElideRight
|
||||
color: titleColor
|
||||
clip: true
|
||||
font.letterSpacing: 0.5
|
||||
}
|
||||
//number
|
||||
Text {
|
||||
anchors {bottom: realCell.bottom; left: realCell.left; margins: 4}
|
||||
text: number?"<b>#</b>"+number:""
|
||||
color: textColor
|
||||
font.letterSpacing: 0.5
|
||||
}
|
||||
//page icon
|
||||
Image {
|
||||
id: pageImage
|
||||
anchors {bottom: realCell.bottom; right: realCell.right; bottomMargin: 5; rightMargin: 4; leftMargin: 4}
|
||||
source: "page.png"
|
||||
}
|
||||
//numPages
|
||||
Text {
|
||||
id: pages
|
||||
anchors {bottom: realCell.bottom; right: pageImage.left; margins: 4}
|
||||
text: has_been_opened?current_page+"/"+num_pages:num_pages
|
||||
color: textColor
|
||||
font.letterSpacing: 0.5
|
||||
}
|
||||
//rating icon
|
||||
Image {
|
||||
id: ratingImage
|
||||
anchors {bottom: realCell.bottom; right: pageImage.left; bottomMargin: 5; rightMargin: Math.floor(pages.width)+12}
|
||||
source: "star.png"
|
||||
}
|
||||
//comic rating
|
||||
Text {
|
||||
id: comicRating
|
||||
anchors {bottom: realCell.bottom; right: ratingImage.left; margins: 4}
|
||||
text: rating>0?rating:"-"
|
||||
color: textColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
YACReaderScrollView{
|
||||
id: scrollView
|
||||
anchors.fill: parent
|
||||
anchors.margins: 0
|
||||
|
||||
|
||||
GridView {
|
||||
id:grid
|
||||
anchors.fill: parent
|
||||
cellHeight: 295
|
||||
highlight: appHighlight
|
||||
focus: true
|
||||
model: comicsList
|
||||
delegate: appDelegate
|
||||
anchors.topMargin: 20
|
||||
anchors.bottomMargin: 20
|
||||
anchors.leftMargin: 10
|
||||
anchors.rightMargin: 10
|
||||
pixelAligned: true
|
||||
//flickDeceleration: -2000
|
||||
snapMode: GridView.SnapToRow
|
||||
currentIndex: 0
|
||||
cacheBuffer: 0
|
||||
|
||||
|
||||
function numCellsPerRow() {
|
||||
return Math.floor(width / 190);
|
||||
}
|
||||
|
||||
onWidthChanged: {
|
||||
var numCells = numCellsPerRow();
|
||||
var rest = width % 190;
|
||||
|
||||
if(numCells > 0)
|
||||
{
|
||||
cellWidth = Math.floor(width / numCells) ;
|
||||
//console.log("numCells=",numCells,"rest=",rest,"cellWidth=",cellWidth,"width=",width);
|
||||
}
|
||||
}
|
||||
}
|
||||
focus: true
|
||||
Keys.onPressed: {
|
||||
if (event.modifiers & Qt.ControlModifier || event.modifiers & Qt.ShiftModifier)
|
||||
return;
|
||||
var numCells = grid.numCellsPerRow();
|
||||
var ci
|
||||
if (event.key === Qt.Key_Right) {
|
||||
ci = Math.min(grid.currentIndex+1,grid.count);
|
||||
}
|
||||
else if (event.key === Qt.Key_Left) {
|
||||
ci = Math.max(0,grid.currentIndex-1);
|
||||
}
|
||||
else if (event.key === Qt.Key_Up) {
|
||||
ci = Math.max(0,grid.currentIndex-numCells);
|
||||
}
|
||||
else if (event.key === Qt.Key_Down) {
|
||||
ci = Math.min(grid.currentIndex+numCells,grid.count);
|
||||
}
|
||||
|
||||
event.accepted = true;
|
||||
//var ci = grid.currentIndex;
|
||||
grid.currentIndex = -1
|
||||
comicsSelectionHelper.clear();
|
||||
comicsSelectionHelper.selectIndex(ci);
|
||||
grid.currentIndex = ci;
|
||||
}
|
||||
//}
|
||||
|
||||
/*MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
clicked.accepted = false;
|
||||
console.log("xx");
|
||||
}
|
||||
|
||||
onWheel: {
|
||||
var newValue = Math.max(0,scrollView.flickableItem.contentY - wheel.angleDelta.y)
|
||||
scrollView.flickableItem.contentY = newValue
|
||||
|
||||
}
|
||||
}*/
|
||||
/*ScrollBar {
|
||||
flickable: grid;
|
||||
}
|
||||
|
||||
PerformanceMeter {
|
||||
anchors {top: parent.top; left: parent.left; margins: 4}
|
||||
id: performanceMeter
|
||||
width: 128
|
||||
height: 64
|
||||
enabled: (dummyValue || !dummyValue)
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
336
YACReaderLibrary/qml/YACReaderScrollView.qml
Normal file
336
YACReaderLibrary/qml/YACReaderScrollView.qml
Normal file
@ -0,0 +1,336 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
||||
** of its contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
import QtQuick.Controls.Styles 1.1
|
||||
|
||||
/*!
|
||||
\qmltype ScrollView
|
||||
\inqmlmodule QtQuick.Controls
|
||||
\since 5.1
|
||||
\ingroup views
|
||||
\brief Provides a scrolling view within another Item.
|
||||
|
||||
A ScrollView can be used either to replace a \l Flickable or decorate an
|
||||
existing \l Flickable. Depending on the platform, it will add scroll bars and
|
||||
a content frame.
|
||||
|
||||
Only one Item can be a direct child of the ScrollView and the child is implicitly anchored
|
||||
to fill the scroll view.
|
||||
|
||||
Example:
|
||||
\code
|
||||
ScrollView {
|
||||
Image { source: "largeImage.png" }
|
||||
}
|
||||
\endcode
|
||||
|
||||
In the previous example the Image item will implicitly get scroll behavior as if it was
|
||||
used within a \l Flickable. The width and height of the child item will be used to
|
||||
define the size of the content area.
|
||||
|
||||
Example:
|
||||
\code
|
||||
ScrollView {
|
||||
ListView {
|
||||
...
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
In this case the content size of the ScrollView will simply mirror that of its contained
|
||||
\l flickableItem.
|
||||
|
||||
You can create a custom appearance for a ScrollView by
|
||||
assigning a \l {QtQuick.Controls.Styles::ScrollViewStyle}{ScrollViewStyle}.
|
||||
*/
|
||||
|
||||
FocusScope {
|
||||
id: root
|
||||
|
||||
implicitWidth: 240
|
||||
implicitHeight: 150
|
||||
|
||||
/*!
|
||||
This property tells the ScrollView if it should render
|
||||
a frame around its content.
|
||||
|
||||
The default value is \c false.
|
||||
*/
|
||||
property bool frameVisible: false
|
||||
|
||||
/*!
|
||||
This property controls if there should be a highlight
|
||||
around the frame when the ScrollView has input focus.
|
||||
|
||||
The default value is \c false.
|
||||
|
||||
\note This property is only applicable on some platforms, such
|
||||
as Mac OS.
|
||||
*/
|
||||
property bool highlightOnFocus: false
|
||||
|
||||
/*!
|
||||
\qmlproperty Item ScrollView::viewport
|
||||
|
||||
The viewport determines the current "window" on the contentItem.
|
||||
In other words, it clips it and the size of the viewport tells you
|
||||
how much of the content area is visible.
|
||||
*/
|
||||
property alias viewport: viewportItem
|
||||
|
||||
/*!
|
||||
\qmlproperty Item ScrollView::flickableItem
|
||||
|
||||
The flickableItem of the ScrollView. If the contentItem provided
|
||||
to the ScrollView is a Flickable, it will be the \l contentItem.
|
||||
*/
|
||||
readonly property alias flickableItem: internal.flickableItem
|
||||
|
||||
/*!
|
||||
The contentItem of the ScrollView. This is set by the user.
|
||||
|
||||
Note that the definition of contentItem is somewhat different to that
|
||||
of a Flickable, where the contentItem is implicitly created.
|
||||
*/
|
||||
default property Item contentItem
|
||||
|
||||
/*! \internal */
|
||||
property Item __scroller: scroller
|
||||
/*! \internal */
|
||||
property alias __wheelAreaScrollSpeed: wheelArea.scrollSpeed
|
||||
/*! \internal */
|
||||
property int __scrollBarTopMargin: 0
|
||||
/*! \internal */
|
||||
property int __viewTopMargin: 0
|
||||
/*! \internal */
|
||||
property alias __horizontalScrollBar: scroller.horizontalScrollBar
|
||||
/*! \internal */
|
||||
property alias __verticalScrollBar: scroller.verticalScrollBar
|
||||
/*! \qmlproperty Component ScrollView::style
|
||||
|
||||
The style Component for this control.
|
||||
\sa {Qt Quick Controls Styles QML Types}
|
||||
|
||||
*/
|
||||
property Component style: Qt.createComponent(Settings.style + "/ScrollViewStyle.qml", root)
|
||||
|
||||
/*! \internal */
|
||||
property Style __style: styleLoader.item
|
||||
|
||||
activeFocusOnTab: true
|
||||
|
||||
onContentItemChanged: {
|
||||
//console.log("onContentItemChanged");
|
||||
if (contentItem.hasOwnProperty("contentY") && // Check if flickable
|
||||
contentItem.hasOwnProperty("contentHeight")) {
|
||||
internal.flickableItem = contentItem // "Use content if it is a flickable
|
||||
internal.flickableItem.parent = viewportItem
|
||||
} else {
|
||||
internal.flickableItem = flickableComponent.createObject(viewportItem)
|
||||
contentItem.parent = internal.flickableItem.contentItem
|
||||
}
|
||||
internal.flickableItem.anchors.fill = viewportItem
|
||||
if (!Settings.hasTouchScreen)
|
||||
internal.flickableItem.interactive = false
|
||||
}
|
||||
|
||||
|
||||
children: Item {
|
||||
id: internal
|
||||
|
||||
property Flickable flickableItem
|
||||
|
||||
Loader {
|
||||
id: styleLoader
|
||||
sourceComponent: style
|
||||
onStatusChanged: {
|
||||
if (status === Loader.Error)
|
||||
console.error("Failed to load Style for", root)
|
||||
}
|
||||
property alias __control: root
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: flickableItem
|
||||
property: "contentHeight"
|
||||
when: contentItem !== flickableItem
|
||||
value: contentItem ? contentItem.height : 0
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: flickableItem
|
||||
when: contentItem !== flickableItem
|
||||
property: "contentWidth"
|
||||
value: contentItem ? contentItem.width : 0
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: flickableItem
|
||||
|
||||
onContentYChanged: {
|
||||
//console.log("onContentYChanged2");
|
||||
scroller.blockUpdates = true
|
||||
scroller.verticalScrollBar.value = flickableItem.contentY
|
||||
scroller.blockUpdates = false
|
||||
}
|
||||
|
||||
onContentXChanged: {
|
||||
//console.log("onContentXChanged2");
|
||||
scroller.blockUpdates = true
|
||||
scroller.horizontalScrollBar.value = flickableItem.contentX
|
||||
scroller.blockUpdates = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
Component {
|
||||
id: flickableComponent
|
||||
Flickable {}
|
||||
}
|
||||
|
||||
WheelArea {
|
||||
id: wheelArea
|
||||
parent: flickableItem
|
||||
|
||||
// ### Note this is needed due to broken mousewheel behavior in Flickable.
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
property int stepSize: 295
|
||||
|
||||
property int acceleration: 40
|
||||
property int flickThreshold: Settings.dragThreshold
|
||||
property real speedThreshold: 3
|
||||
property real ignored: 0.001 // ## flick() does not work with 0 yVelocity
|
||||
property int maxFlick: 400
|
||||
|
||||
property bool horizontalRecursionGuard: false
|
||||
property bool verticalRecursionGuard: false
|
||||
|
||||
horizontalMinimumValue: flickableItem ? flickableItem.originX : 0
|
||||
horizontalMaximumValue: flickableItem ? flickableItem.originX + flickableItem.contentWidth - viewport.width : 0
|
||||
|
||||
verticalMinimumValue: flickableItem ? flickableItem.originY : 0
|
||||
verticalMaximumValue: flickableItem ? flickableItem.originY + flickableItem.contentHeight - viewport.height + __viewTopMargin : 0
|
||||
|
||||
Connections {
|
||||
target: flickableItem
|
||||
|
||||
onContentYChanged: {
|
||||
//console.log("onContentYChanged");
|
||||
wheelArea.verticalRecursionGuard = true
|
||||
wheelArea.verticalValue = flickableItem.contentY
|
||||
wheelArea.verticalRecursionGuard = false
|
||||
}
|
||||
onContentXChanged: {
|
||||
//console.log("onContentXChanged");
|
||||
wheelArea.horizontalRecursionGuard = true
|
||||
wheelArea.horizontalValue = flickableItem.contentX
|
||||
wheelArea.horizontalRecursionGuard = false
|
||||
}
|
||||
}
|
||||
|
||||
onVerticalValueChanged: {
|
||||
if (!verticalRecursionGuard) {
|
||||
//console.log(verticalDelta);
|
||||
|
||||
if (flickableItem.contentY < flickThreshold && verticalDelta > speedThreshold) {
|
||||
flickableItem.flick(ignored, Math.min(maxFlick, acceleration * verticalDelta))
|
||||
} else if (flickableItem.contentY > flickableItem.contentHeight
|
||||
- flickThreshold - viewport.height && verticalDelta < -speedThreshold) {
|
||||
flickableItem.flick(ignored, Math.max(-maxFlick, acceleration * verticalDelta))
|
||||
} else {
|
||||
var absDelta = Math.abs(verticalDelta);
|
||||
|
||||
if(verticalDelta < 0)
|
||||
flickableItem.contentY = verticalValue + Math.min(98,0.93*absDelta+4.5);
|
||||
else
|
||||
flickableItem.contentY = verticalValue - Math.min(98,0.93*absDelta+4.5);
|
||||
}
|
||||
|
||||
|
||||
//TODO: snap to row
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onHorizontalValueChanged: {
|
||||
if (!horizontalRecursionGuard)
|
||||
flickableItem.contentX = horizontalValue
|
||||
}
|
||||
}
|
||||
|
||||
ScrollViewHelper {
|
||||
id: scroller
|
||||
anchors.fill: parent
|
||||
active: wheelArea.active
|
||||
property bool outerFrame: !frameVisible || !(__style ? __style.__externalScrollBars : 0)
|
||||
property int scrollBarSpacing: outerFrame ? 0 : (__style ? __style.__scrollBarSpacing : 0)
|
||||
property int verticalScrollbarOffset: verticalScrollBar.visible && !verticalScrollBar.isTransient ?
|
||||
verticalScrollBar.width + scrollBarSpacing : 0
|
||||
property int horizontalScrollbarOffset: horizontalScrollBar.visible && !horizontalScrollBar.isTransient ?
|
||||
horizontalScrollBar.height + scrollBarSpacing : 0
|
||||
Loader {
|
||||
id: frameLoader
|
||||
sourceComponent: __style ? __style.frame : null
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: scroller.outerFrame ? 0 : scroller.verticalScrollbarOffset
|
||||
anchors.bottomMargin: scroller.outerFrame ? 0 : scroller.horizontalScrollbarOffset
|
||||
}
|
||||
|
||||
Item {
|
||||
id: viewportItem
|
||||
anchors.fill: frameLoader
|
||||
anchors.topMargin: frameVisible ? __style.padding.top : 0
|
||||
anchors.leftMargin: frameVisible ? __style.padding.left : 0
|
||||
anchors.rightMargin: (frameVisible ? __style.padding.right : 0) + (scroller.outerFrame ? scroller.verticalScrollbarOffset : 0)
|
||||
anchors.bottomMargin: (frameVisible ? __style.padding.bottom : 0) + (scroller.outerFrame ? scroller.horizontalScrollbarOffset : 0)
|
||||
clip: true
|
||||
}
|
||||
}
|
||||
FocusFrame { visible: highlightOnFocus && root.activeFocus }
|
||||
}
|
||||
}
|
||||
BIN
YACReaderLibrary/qml/page-macosx.png
Normal file
BIN
YACReaderLibrary/qml/page-macosx.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 171 B |
BIN
YACReaderLibrary/qml/page.png
Normal file
BIN
YACReaderLibrary/qml/page.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 155 B |
BIN
YACReaderLibrary/qml/reading.png
Normal file
BIN
YACReaderLibrary/qml/reading.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 374 B |
BIN
YACReaderLibrary/qml/star-macosx.png
Normal file
BIN
YACReaderLibrary/qml/star-macosx.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 288 B |
BIN
YACReaderLibrary/qml/star.png
Normal file
BIN
YACReaderLibrary/qml/star.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 242 B |
BIN
YACReaderLibrary/qml/tick.png
Normal file
BIN
YACReaderLibrary/qml/tick.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 488 B |
6
YACReaderLibrary/qml_osx.qrc
Normal file
6
YACReaderLibrary/qml_osx.qrc
Normal file
@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file alias="qml/page.png">qml/page-macosx.png</file>
|
||||
<file alias="qml/star.png">qml/star-macosx.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
6
YACReaderLibrary/qml_win.qrc
Normal file
6
YACReaderLibrary/qml_win.qrc
Normal file
@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>qml/page.png</file>
|
||||
<file>qml/star.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@ -37,7 +37,7 @@ void Startup::start() {
|
||||
//QSettings* debugLogSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
//debugLogSettings->beginGroup("debugLogFile");
|
||||
Logger* logger=new FileLogger(mainLogSettings,10000,app);
|
||||
logger->installMsgHandler();
|
||||
logger->installMsgHandler();
|
||||
|
||||
// Configure template loader and cache
|
||||
QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
@ -65,9 +65,14 @@ void Startup::start() {
|
||||
|
||||
|
||||
void Startup::stop() {
|
||||
qDebug("ServiceHelper: Service has been stopped");
|
||||
// QCoreApplication destroys all objects that have been created in start().
|
||||
delete listener;
|
||||
qDebug("ServiceHelper: Service has been stopped");
|
||||
// QCoreApplication destroys all objects that have been created in start().
|
||||
if(listener!=nullptr)
|
||||
{
|
||||
listener->close();
|
||||
delete listener;
|
||||
listener = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -64,7 +64,12 @@ bool YACReaderLocalServer::isRunning()
|
||||
socket.connectToServer(YACREADERLIBRARY_GUID);
|
||||
if (socket.waitForConnected(500))
|
||||
return true; // Server is running (another instance of YACReaderLibrary has been launched)
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void YACReaderLocalServer::close()
|
||||
{
|
||||
localServer->close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ public slots:
|
||||
bool isListening();
|
||||
void sendResponse();
|
||||
static bool isRunning();
|
||||
void close();
|
||||
private:
|
||||
//void run();
|
||||
QLocalServer * localServer;
|
||||
|
||||
@ -44,11 +44,14 @@ YACReaderMainToolBar::YACReaderMainToolBar(QWidget *parent) :
|
||||
helpButton->setStyleSheet(qToolButtonStyleSheet);
|
||||
helpButton->setIconSize(QSize(14,25));
|
||||
|
||||
toggleComicsViewButton = new QToolButton;
|
||||
toggleComicsViewButton->setStyleSheet(qToolButtonStyleSheet);
|
||||
toggleComicsViewButton->setIconSize(QSize(24,24));
|
||||
|
||||
fullscreenButton = new QToolButton();
|
||||
fullscreenButton->setStyleSheet(qToolButtonStyleSheet);
|
||||
fullscreenButton->setIconSize(QSize(24,24));
|
||||
|
||||
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(0);
|
||||
|
||||
@ -66,6 +69,8 @@ YACReaderMainToolBar::YACReaderMainToolBar(QWidget *parent) :
|
||||
|
||||
mainLayout->addStretch();
|
||||
|
||||
mainLayout->addWidget(toggleComicsViewButton);
|
||||
addWideDivider();
|
||||
mainLayout->addWidget(fullscreenButton);
|
||||
mainLayout->addSpacing(10);
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ class QResizeEvent;
|
||||
class QPaintEvent;
|
||||
class QHBoxLayout;
|
||||
|
||||
//TODO create methods for adding actions, separators and sctreches dynimically
|
||||
class YACReaderMainToolBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -21,8 +22,10 @@ public:
|
||||
QToolButton * settingsButton;
|
||||
QToolButton * serverButton;
|
||||
QToolButton * helpButton;
|
||||
QToolButton * toggleComicsViewButton;
|
||||
QToolButton * fullscreenButton;
|
||||
|
||||
|
||||
void setCurrentFolderName(const QString & name);
|
||||
signals:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user