mirror of
https://github.com/YACReader/yacreader
synced 2025-07-22 06:54:39 -04:00
added label content loading
This commit is contained in:
@ -127,7 +127,8 @@ HEADERS += comic_flow.h \
|
|||||||
yacreader_reading_lists_view.h \
|
yacreader_reading_lists_view.h \
|
||||||
add_label_dialog.h \
|
add_label_dialog.h \
|
||||||
yacreader_history_controller.h \
|
yacreader_history_controller.h \
|
||||||
yacreader_navigation_controller.h
|
yacreader_navigation_controller.h \
|
||||||
|
empty_label_widget.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += comic_flow.cpp \
|
SOURCES += comic_flow.cpp \
|
||||||
@ -183,7 +184,8 @@ SOURCES += comic_flow.cpp \
|
|||||||
yacreader_reading_lists_view.cpp \
|
yacreader_reading_lists_view.cpp \
|
||||||
add_label_dialog.cpp \
|
add_label_dialog.cpp \
|
||||||
yacreader_history_controller.cpp \
|
yacreader_history_controller.cpp \
|
||||||
yacreader_navigation_controller.cpp
|
yacreader_navigation_controller.cpp \
|
||||||
|
empty_label_widget.cpp
|
||||||
|
|
||||||
|
|
||||||
include(./server/server.pri)
|
include(./server/server.pri)
|
||||||
|
@ -274,36 +274,50 @@ QStringList ComicModel::getPaths(const QString & _source)
|
|||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComicModel::setupModelData(unsigned long long int folderId,const QString & databasePath)
|
void ComicModel::setupFolderModelData(unsigned long long int folderId,const QString & databasePath)
|
||||||
{
|
{
|
||||||
//QFile f(QCoreApplication::applicationDirPath()+"/performance.txt");
|
beginResetModel();
|
||||||
//f.open(QIODevice::Append);
|
qDeleteAll(_data);
|
||||||
beginResetModel();
|
_data.clear();
|
||||||
//QElapsedTimer timer;
|
|
||||||
//timer.start();
|
|
||||||
qDeleteAll(_data);
|
|
||||||
_data.clear();
|
|
||||||
|
|
||||||
//QTextStream txtS(&f);
|
_databasePath = databasePath;
|
||||||
//txtS << "TABLEMODEL: Tiempo de borrado: " << timer.elapsed() << "ms\r\n";
|
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
||||||
_databasePath = databasePath;
|
{
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
QSqlQuery selectQuery(db);
|
||||||
{
|
selectQuery.prepare("select ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read,ci.isBis,ci.currentPage,ci.rating,ci.hasBeenOpened from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId");
|
||||||
//crear la consulta
|
selectQuery.bindValue(":parentId", folderId);
|
||||||
//timer.restart();
|
selectQuery.exec();
|
||||||
QSqlQuery selectQuery(db);
|
setupModelData(selectQuery);
|
||||||
selectQuery.prepare("select ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read,ci.isBis,ci.currentPage,ci.rating,ci.hasBeenOpened from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId");
|
}
|
||||||
selectQuery.bindValue(":parentId", folderId);
|
db.close();
|
||||||
selectQuery.exec();
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
//txtS << "TABLEMODEL: Tiempo de consulta: " << timer.elapsed() << "ms\r\n";
|
endResetModel();
|
||||||
//timer.restart();
|
|
||||||
setupModelData(selectQuery);
|
if(_data.length()==0)
|
||||||
//txtS << "TABLEMODEL: Tiempo de creaci�n del modelo: " << timer.elapsed() << "ms\r\n";
|
emit isEmpty();
|
||||||
//selectQuery.finish();
|
}
|
||||||
}
|
|
||||||
db.close();
|
void ComicModel::setupLabelModelData(unsigned long long parentLabel, const QString &databasePath)
|
||||||
QSqlDatabase::removeDatabase(_databasePath);
|
{
|
||||||
endResetModel();
|
beginResetModel();
|
||||||
|
qDeleteAll(_data);
|
||||||
|
_data.clear();
|
||||||
|
|
||||||
|
_databasePath = databasePath;
|
||||||
|
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
||||||
|
{
|
||||||
|
QSqlQuery selectQuery(db);
|
||||||
|
selectQuery.prepare("SELECT ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read,ci.isBis,ci.currentPage,ci.rating,ci.hasBeenOpened "
|
||||||
|
"FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) "
|
||||||
|
"INNER JOIN comic_label cl ON (c.id == cl.comic_id) "
|
||||||
|
"WHERE cl.label_id = :parentLabelId");
|
||||||
|
selectQuery.bindValue(":parentLabelId", parentLabel);
|
||||||
|
selectQuery.exec();
|
||||||
|
setupModelData(selectQuery);
|
||||||
|
}
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
|
endResetModel();
|
||||||
|
|
||||||
if(_data.length()==0)
|
if(_data.length()==0)
|
||||||
emit isEmpty();
|
emit isEmpty();
|
||||||
|
@ -34,7 +34,8 @@ public:
|
|||||||
QModelIndex parent(const QModelIndex &index) const;
|
QModelIndex parent(const QModelIndex &index) const;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
void setupModelData(unsigned long long int parentFolder,const QString & databasePath);
|
void setupFolderModelData(unsigned long long int parentFolder,const QString & databasePath);
|
||||||
|
void setupLabelModelData(unsigned long long int parentLabel, const QString & databasePath);
|
||||||
//configures the model for showing the comics matching the filter criteria.
|
//configures the model for showing the comics matching the filter criteria.
|
||||||
void setupModelData(const SearchModifiers modifier, const QString & filter, const QString & databasePath);
|
void setupModelData(const SearchModifiers modifier, const QString & filter, const QString & databasePath);
|
||||||
|
|
||||||
|
@ -73,6 +73,9 @@ QVariant ReadingListModel::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant(ReadingListModel::Separator);
|
return QVariant(ReadingListModel::Separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (role == ReadingListModel::IDRole)
|
||||||
|
return item->getId();
|
||||||
|
|
||||||
if(typeid(*item) == typeid(ReadingListSeparatorItem))
|
if(typeid(*item) == typeid(ReadingListSeparatorItem))
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ public:
|
|||||||
|
|
||||||
enum Roles {
|
enum Roles {
|
||||||
TypeListsRole = Qt::UserRole + 1,
|
TypeListsRole = Qt::UserRole + 1,
|
||||||
|
IDRole
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TypeList {
|
enum TypeList {
|
||||||
|
49
YACReaderLibrary/empty_label_widget.cpp
Normal file
49
YACReaderLibrary/empty_label_widget.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include "empty_label_widget.h"
|
||||||
|
|
||||||
|
EmptyLabelWidget::EmptyLabelWidget(QWidget *parent) :
|
||||||
|
QWidget(parent)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
backgroundColor = "#FFFFFF";
|
||||||
|
#else
|
||||||
|
backgroundColor = "#2A2A2A";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QVBoxLayout * layout = new QVBoxLayout;
|
||||||
|
|
||||||
|
iconLabel = new QLabel();
|
||||||
|
iconLabel->setPixmap(QPixmap(":/images/empty_label.png"));
|
||||||
|
iconLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
|
//titleLabel->setText(tr("This label doesn't contain comics yet") + QString("<p style='color:rgb(150,150,150);font-size:14px;font-weight:normal;'>%1</p>").arg(tr("Drag and drop folders and comics here")));
|
||||||
|
titleLabel = new QLabel(("This label doesn't contain comics yet"));
|
||||||
|
titleLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
titleLabel->setStyleSheet("QLabel {color:#888888; font-size:24px;font-family:Arial;font-weight:bold;}");
|
||||||
|
#else
|
||||||
|
titleLabel->setStyleSheet("QLabel {color:#CCCCCC; font-size:24px;font-family:Arial;font-weight:bold;}");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
layout->addSpacing(100);
|
||||||
|
layout->addWidget(iconLabel);
|
||||||
|
layout->addSpacing(30);
|
||||||
|
layout->addWidget(titleLabel);
|
||||||
|
layout->addStretch();
|
||||||
|
|
||||||
|
setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyLabelWidget::setColor(YACReader::LabelColors color)
|
||||||
|
{
|
||||||
|
//TODO tint the widget depending on color
|
||||||
|
//backgroundColor = "#FF0000";
|
||||||
|
|
||||||
|
//repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyLabelWidget::paintEvent(QPaintEvent * event)
|
||||||
|
{
|
||||||
|
QPainter painter (this);
|
||||||
|
painter.fillRect(0,0,width(),height(),QColor(backgroundColor));
|
||||||
|
}
|
26
YACReaderLibrary/empty_label_widget.h
Normal file
26
YACReaderLibrary/empty_label_widget.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef EMPTY_LABEL_WIDGET_H
|
||||||
|
#define EMPTY_LABEL_WIDGET_H
|
||||||
|
|
||||||
|
#include <QtWidgets>
|
||||||
|
#include "yacreader_global.h"
|
||||||
|
|
||||||
|
class EmptyLabelWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit EmptyLabelWidget(QWidget *parent = 0);
|
||||||
|
void setColor(YACReader::LabelColors color);
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QLabel * iconLabel;
|
||||||
|
QLabel * titleLabel;
|
||||||
|
QString backgroundColor;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EMPTY_LABEL_WIDGET_H
|
@ -25,6 +25,7 @@
|
|||||||
<file alias="images/flow_to_grid.gif">../images/flow_to_grid.gif</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/grid_to_flow.gif">../images/grid_to_flow.gif</file>
|
||||||
<file alias="images/empty_folder.png">../images/empty_folder_osx.png</file>
|
<file alias="images/empty_folder.png">../images/empty_folder_osx.png</file>
|
||||||
|
<file alias="images/empty_label.png">../images/empty_label_osx.png</file>
|
||||||
<file alias="images/empty_search.png">../images/empty_search_osx.png</file>
|
<file alias="images/empty_search.png">../images/empty_search_osx.png</file>
|
||||||
<file>../images/iconSearch.png</file>
|
<file>../images/iconSearch.png</file>
|
||||||
<file>../images/clearSearch.png</file>
|
<file>../images/clearSearch.png</file>
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
<file>../images/flow_to_grid.gif</file>
|
<file>../images/flow_to_grid.gif</file>
|
||||||
<file>../images/grid_to_flow.gif</file>
|
<file>../images/grid_to_flow.gif</file>
|
||||||
<file>../images/empty_folder.png</file>
|
<file>../images/empty_folder.png</file>
|
||||||
|
<file>../images/empty_label.png</file>
|
||||||
<file>../images/empty_search.png</file>
|
<file>../images/empty_search.png</file>
|
||||||
<file>../images/addNew_sidebar.png</file>
|
<file>../images/addNew_sidebar.png</file>
|
||||||
<file>../images/delete_sidebar.png</file>
|
<file>../images/delete_sidebar.png</file>
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
#include "grid_comics_view.h"
|
#include "grid_comics_view.h"
|
||||||
#include "comics_view_transition.h"
|
#include "comics_view_transition.h"
|
||||||
#include "empty_folder_widget.h"
|
#include "empty_folder_widget.h"
|
||||||
|
#include "empty_label_widget.h"
|
||||||
|
|
||||||
#include "edit_shortcuts_dialog.h"
|
#include "edit_shortcuts_dialog.h"
|
||||||
#include "shortcuts_manager.h"
|
#include "shortcuts_manager.h"
|
||||||
@ -240,6 +241,7 @@ void LibraryWindow::doLayout()
|
|||||||
comicsView->setToolBar(editInfoToolBar);
|
comicsView->setToolBar(editInfoToolBar);
|
||||||
comicsViewStack->addWidget(comicsViewTransition = new ComicsViewTransition());
|
comicsViewStack->addWidget(comicsViewTransition = new ComicsViewTransition());
|
||||||
comicsViewStack->addWidget(emptyFolderWidget = new EmptyFolderWidget());
|
comicsViewStack->addWidget(emptyFolderWidget = new EmptyFolderWidget());
|
||||||
|
comicsViewStack->addWidget(emptyLabelWidget = new EmptyLabelWidget());
|
||||||
comicsViewStack->addWidget(noSearchResultsWidget = new NoSearchResultsWidget());
|
comicsViewStack->addWidget(noSearchResultsWidget = new NoSearchResultsWidget());
|
||||||
comicsViewStack->addWidget(comicsView);
|
comicsViewStack->addWidget(comicsView);
|
||||||
|
|
||||||
@ -2153,6 +2155,11 @@ void LibraryWindow::showEmptyFolderView()
|
|||||||
comicsViewStack->setCurrentWidget(emptyFolderWidget);
|
comicsViewStack->setCurrentWidget(emptyFolderWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LibraryWindow::showEmptyLabelView()
|
||||||
|
{
|
||||||
|
comicsViewStack->setCurrentWidget(emptyLabelWidget);
|
||||||
|
}
|
||||||
|
|
||||||
void LibraryWindow::showNoSearchResultsView()
|
void LibraryWindow::showNoSearchResultsView()
|
||||||
{
|
{
|
||||||
comicsViewStack->setCurrentWidget(noSearchResultsWidget);
|
comicsViewStack->setCurrentWidget(noSearchResultsWidget);
|
||||||
|
@ -68,6 +68,7 @@ class ReadingListModel;
|
|||||||
class ReadingListModelProxy;
|
class ReadingListModelProxy;
|
||||||
class YACReaderReadingListsView;
|
class YACReaderReadingListsView;
|
||||||
class YACReaderHistoryController;
|
class YACReaderHistoryController;
|
||||||
|
class EmptyLabelWidget;
|
||||||
|
|
||||||
#include "comic_db.h"
|
#include "comic_db.h"
|
||||||
|
|
||||||
@ -121,6 +122,7 @@ private:
|
|||||||
QStackedWidget * comicsViewStack;
|
QStackedWidget * comicsViewStack;
|
||||||
ComicsViewTransition * comicsViewTransition;
|
ComicsViewTransition * comicsViewTransition;
|
||||||
EmptyFolderWidget * emptyFolderWidget;
|
EmptyFolderWidget * emptyFolderWidget;
|
||||||
|
EmptyLabelWidget * emptyLabelWidget;
|
||||||
NoSearchResultsWidget * noSearchResultsWidget;
|
NoSearchResultsWidget * noSearchResultsWidget;
|
||||||
|
|
||||||
YACReaderFoldersView * foldersView;
|
YACReaderFoldersView * foldersView;
|
||||||
@ -358,6 +360,7 @@ public slots:
|
|||||||
void toggleComicsView_delayed();//used in orther to avoid flickering;
|
void toggleComicsView_delayed();//used in orther to avoid flickering;
|
||||||
void showComicsView();
|
void showComicsView();
|
||||||
void showEmptyFolderView();
|
void showEmptyFolderView();
|
||||||
|
void showEmptyLabelView();
|
||||||
void showNoSearchResultsView();
|
void showNoSearchResultsView();
|
||||||
void toggleComicsView();
|
void toggleComicsView();
|
||||||
void checkSearchNumResults(int numResults);
|
void checkSearchNumResults(int numResults);
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include "comics_view.h"
|
#include "comics_view.h"
|
||||||
#include "empty_folder_widget.h"
|
#include "empty_folder_widget.h"
|
||||||
#include "yacreader_search_line_edit.h"
|
#include "yacreader_search_line_edit.h"
|
||||||
|
#include "yacreader_global.h"
|
||||||
|
#include "empty_label_widget.h"
|
||||||
|
|
||||||
#include "QsLog.h"
|
#include "QsLog.h"
|
||||||
|
|
||||||
@ -56,7 +58,7 @@ void YACReaderNavigationController::loadFolderInfo(const QModelIndex &modelIndex
|
|||||||
qulonglong folderId = folderModelIndexToID(modelIndex);
|
qulonglong folderId = folderModelIndexToID(modelIndex);
|
||||||
|
|
||||||
//check comics in folder with id = folderId
|
//check comics in folder with id = folderId
|
||||||
libraryWindow->comicsModel->setupModelData(folderId,libraryWindow->foldersModel->getDatabase());
|
libraryWindow->comicsModel->setupFolderModelData(folderId,libraryWindow->foldersModel->getDatabase());
|
||||||
libraryWindow->comicsView->setModel(libraryWindow->comicsModel);
|
libraryWindow->comicsView->setModel(libraryWindow->comicsModel);
|
||||||
|
|
||||||
//configure views
|
//configure views
|
||||||
@ -77,6 +79,53 @@ void YACReaderNavigationController::loadFolderInfo(const QModelIndex &modelIndex
|
|||||||
}
|
}
|
||||||
|
|
||||||
void YACReaderNavigationController::loadListInfo(const QModelIndex &modelIndex)
|
void YACReaderNavigationController::loadListInfo(const QModelIndex &modelIndex)
|
||||||
|
{
|
||||||
|
qulonglong id = modelIndex.data(ReadingListModel::IDRole).toULongLong();
|
||||||
|
|
||||||
|
switch(modelIndex.data(ReadingListModel::TypeListsRole).toInt())
|
||||||
|
{
|
||||||
|
case ReadingListModel::SpecialList:
|
||||||
|
loadSpecialListInfo(id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ReadingListModel::Label:
|
||||||
|
loadLabelInfo(id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ReadingListModel::ReadingList:
|
||||||
|
loadReadingListInfo(id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderNavigationController::loadSpecialListInfo(const qulonglong id)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderNavigationController::loadLabelInfo(const qulonglong id)
|
||||||
|
{
|
||||||
|
//check comics in folder with id = folderId
|
||||||
|
libraryWindow->comicsModel->setupLabelModelData(id,libraryWindow->foldersModel->getDatabase());
|
||||||
|
libraryWindow->comicsView->setModel(libraryWindow->comicsModel);
|
||||||
|
|
||||||
|
//configure views
|
||||||
|
if(libraryWindow->comicsModel->rowCount() > 0)
|
||||||
|
{
|
||||||
|
//updateView
|
||||||
|
libraryWindow->showComicsView();
|
||||||
|
libraryWindow->disableComicsActions(false);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//showEmptyFolder
|
||||||
|
//loadEmptyLabelInfo(); //there is no info in an empty label by now, TODO design something
|
||||||
|
//TODO libraryWindow->emptyLabelWidget->setColor(YACReader::YRed);
|
||||||
|
libraryWindow->showEmptyLabelView();
|
||||||
|
libraryWindow->disableComicsActions(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderNavigationController::loadReadingListInfo(const qulonglong id)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,10 @@ public slots:
|
|||||||
|
|
||||||
void loadFolderInfo(const QModelIndex & modelIndex);
|
void loadFolderInfo(const QModelIndex & modelIndex);
|
||||||
void loadListInfo(const QModelIndex & modelIndex);
|
void loadListInfo(const QModelIndex & modelIndex);
|
||||||
|
void loadSpecialListInfo(const qulonglong id);
|
||||||
|
void loadLabelInfo(const qulonglong id);
|
||||||
|
void loadReadingListInfo(const qulonglong id);
|
||||||
|
|
||||||
void loadPreviousStatus();
|
void loadPreviousStatus();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
BIN
images/empty_label.png
Normal file
BIN
images/empty_label.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
BIN
images/empty_label_osx.png
Normal file
BIN
images/empty_label_osx.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
Reference in New Issue
Block a user