mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 00:58:32 -04:00
seleccionados los c?mpos definitivos para la table view
recarga de datos de los c?mics y covers despu?s de editarlos a?adidos al repositorio los di?logos comic_info
This commit is contained in:
parent
960cadee41
commit
aa1efea8ff
@ -15,7 +15,7 @@ public:
|
||||
QVariant data(int column) const;
|
||||
int row() const;
|
||||
unsigned long long int id; //TODO sustituir por una clase adecuada
|
||||
Comic comic;
|
||||
//Comic comic;
|
||||
private:
|
||||
QList<QVariant> itemData;
|
||||
|
||||
|
@ -7,6 +7,17 @@
|
||||
#include "data_base_management.h"
|
||||
#include "qnaturalsorting.h"
|
||||
|
||||
//ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read
|
||||
#define NUMBER 0
|
||||
#define TITLE 1
|
||||
#define FILE_NAME 2
|
||||
#define NUM_PAGES 3
|
||||
#define ID 4
|
||||
#define PARENT_ID 5
|
||||
#define PATH 6
|
||||
#define HASH 7
|
||||
#define READ 8
|
||||
|
||||
TableModel::TableModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
@ -77,13 +88,13 @@ QVariant TableModel::headerData(int section, Qt::Orientation orientation,
|
||||
switch(section)//TODO obtener esto de la query
|
||||
{
|
||||
case 0:
|
||||
return QVariant(QString("Id"));
|
||||
return QVariant(QString("#"));
|
||||
case 1:
|
||||
return QVariant(QString("ParentId"));
|
||||
return QVariant(QString(tr("Title")));
|
||||
case 2:
|
||||
return QVariant(QString("File Name"));
|
||||
return QVariant(QString(tr("File Name")));
|
||||
case 3:
|
||||
return QVariant(QString("Path"));
|
||||
return QVariant(QString(tr("Pages")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,8 +144,8 @@ QStringList TableModel::getPaths(const QString & _source)
|
||||
QList<TableItem *>::ConstIterator itr;
|
||||
for(itr = _data.constBegin();itr != _data.constEnd();itr++)
|
||||
{
|
||||
QString path = (*itr)->data(4).toString();
|
||||
paths << source+ path +".jpg";
|
||||
QString hash = (*itr)->data(HASH).toString();
|
||||
paths << source+ hash +".jpg";
|
||||
}
|
||||
|
||||
return paths;
|
||||
@ -158,7 +169,7 @@ void TableModel::setupModelData(unsigned long long int folderId,const QString &
|
||||
//crear la consulta
|
||||
//timer.restart();
|
||||
QSqlQuery selectQuery(db); //TODO check
|
||||
selectQuery.prepare("select c.id,c.parentId,c.fileName,c.path,ci.hash,ci.read from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId");
|
||||
selectQuery.prepare("select ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId");
|
||||
selectQuery.bindValue(":parentId", folderId);
|
||||
selectQuery.exec();
|
||||
//txtS << "TABLEMODEL: Tiempo de consulta: " << timer.elapsed() << "ms\r\n";
|
||||
@ -176,7 +187,7 @@ void TableModel::setupModelData(unsigned long long int folderId,const QString &
|
||||
QString TableModel::getComicPath(QModelIndex mi)
|
||||
{
|
||||
if(mi.isValid())
|
||||
return _data.at(mi.row())->data(3).toString();
|
||||
return _data.at(mi.row())->data(6).toString();
|
||||
return "";
|
||||
}
|
||||
void TableModel::setupModelData(QSqlQuery &sqlquery)
|
||||
@ -196,15 +207,15 @@ void TableModel::setupModelData(QSqlQuery &sqlquery)
|
||||
else
|
||||
{
|
||||
TableItem * last = _data.back();
|
||||
QString nameLast = last->data(2).toString(); //TODO usar info name si está disponible, sino el nombre del fichero.....
|
||||
QString nameCurrent = currentItem->data(2).toString();
|
||||
QString nameLast = last->data(FILE_NAME).toString(); //TODO usar info name si está disponible, sino el nombre del fichero.....
|
||||
QString nameCurrent = currentItem->data(FILE_NAME).toString();
|
||||
QList<TableItem *>::iterator i;
|
||||
i = _data.end();
|
||||
i--;
|
||||
while ((lessThan = naturalSortLessThanCI(nameCurrent,nameLast)) && i != _data.begin())
|
||||
{
|
||||
i--;
|
||||
nameLast = (*i)->data(2).toString();
|
||||
nameLast = (*i)->data(FILE_NAME).toString();
|
||||
}
|
||||
if(!lessThan) //si se ha encontrado un elemento menor que current, se inserta justo después
|
||||
_data.insert(++i,currentItem);
|
||||
@ -220,7 +231,7 @@ Comic TableModel::getComic(const QModelIndex & mi)
|
||||
Comic c;
|
||||
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||
c.load(_data.at(mi.row())->data(0).toLongLong(),db);
|
||||
c.load(_data.at(mi.row())->data(ID).toLongLong(),db);
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(_databasePath);
|
||||
|
||||
@ -232,7 +243,7 @@ Comic TableModel::_getComic(const QModelIndex & mi)
|
||||
Comic c;
|
||||
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||
c.load(_data.at(mi.row())->data(0).toLongLong(),db);
|
||||
c.load(_data.at(mi.row())->data(ID).toLongLong(),db);
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(_databasePath);
|
||||
|
||||
@ -247,7 +258,7 @@ QVector<bool> TableModel::getReadList()
|
||||
for(int i=0;i<numComics;i++)
|
||||
{
|
||||
//TODO reemplazar el acceso a las columnas con enteros por defines
|
||||
readList[i] = _data.value(i)->data(5).toBool();
|
||||
readList[i] = _data.value(i)->data(READ).toBool();
|
||||
}
|
||||
return readList;
|
||||
}
|
||||
@ -262,9 +273,9 @@ QVector<bool> TableModel::setAllComicsRead(bool read)
|
||||
{
|
||||
//TODO reemplazar el acceso a las columnas con enteros por defines
|
||||
readList[i] = read;
|
||||
_data.value(i)->data(5) = QVariant(true);
|
||||
_data.value(i)->data(READ) = QVariant(true);
|
||||
Comic c;
|
||||
c.load(_data.value(i)->data(0).toLongLong(),db);
|
||||
c.load(_data.value(i)->data(ID).toLongLong(),db);
|
||||
c.info.read = read;
|
||||
c.info.update(db);
|
||||
}
|
||||
|
84
YACReaderLibrary/export_comics_info_dialog.cpp
Normal file
84
YACReaderLibrary/export_comics_info_dialog.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#include "export_comics_info_dialog.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
|
||||
#include "data_base_management.h"
|
||||
|
||||
ExportComicsInfoDialog::ExportComicsInfoDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
textLabel = new QLabel(tr("Output file : "));
|
||||
path = new QLineEdit;
|
||||
textLabel->setBuddy(path);
|
||||
|
||||
accept = new QPushButton(tr("Create"));
|
||||
accept->setDisabled(true);
|
||||
connect(accept,SIGNAL(clicked()),this,SLOT(exportComicsInfo()));
|
||||
|
||||
cancel = new QPushButton(tr("Cancel"));
|
||||
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
|
||||
connect(cancel,SIGNAL(clicked()),this,SIGNAL(rejected()));
|
||||
|
||||
find = new QPushButton(QIcon(":/images/db.png"),"");
|
||||
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
|
||||
|
||||
QHBoxLayout *libraryLayout = new QHBoxLayout;
|
||||
|
||||
libraryLayout->addWidget(textLabel);
|
||||
libraryLayout->addWidget(path);
|
||||
libraryLayout->addWidget(find);
|
||||
libraryLayout->setStretchFactor(find,0); //TODO
|
||||
|
||||
QHBoxLayout *bottomLayout = new QHBoxLayout;
|
||||
bottomLayout->addStretch();
|
||||
bottomLayout->addWidget(accept);
|
||||
bottomLayout->addWidget(cancel);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(libraryLayout);
|
||||
mainLayout->addWidget(progress=new QLabel());
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addLayout(bottomLayout);
|
||||
|
||||
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
||||
QLabel * imgLabel = new QLabel(this);
|
||||
QPixmap p(":/images/exportComicsInfo.png");
|
||||
imgLabel->setPixmap(p);
|
||||
imgMainLayout->addWidget(imgLabel);
|
||||
imgMainLayout->addLayout(mainLayout);
|
||||
|
||||
setLayout(imgMainLayout);
|
||||
|
||||
setModal(true);
|
||||
setWindowTitle(tr("Export comics info"));
|
||||
}
|
||||
|
||||
ExportComicsInfoDialog::~ExportComicsInfoDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ExportComicsInfoDialog::findPath()
|
||||
{
|
||||
QString s = QFileDialog::getSaveFileName(this,tr("Destination database name"),".","*.ydb");
|
||||
if(!s.isEmpty())
|
||||
{
|
||||
path->setText(s);
|
||||
accept->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ExportComicsInfoDialog::exportComicsInfo()
|
||||
{
|
||||
DataBaseManagement::exportComicsInfo(source,path->text());
|
||||
close();
|
||||
}
|
||||
|
||||
void ExportComicsInfoDialog::close()
|
||||
{
|
||||
path->clear();
|
||||
QDialog::close();
|
||||
}
|
35
YACReaderLibrary/export_comics_info_dialog.h
Normal file
35
YACReaderLibrary/export_comics_info_dialog.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef EXPORT_COMICS_INFO_DIALOG_H
|
||||
#define EXPORT_COMICS_INFO_DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
|
||||
|
||||
class ExportComicsInfoDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExportComicsInfoDialog(QWidget *parent = 0);
|
||||
~ExportComicsInfoDialog();
|
||||
QString source;
|
||||
|
||||
public slots:
|
||||
void findPath();
|
||||
void exportComicsInfo();
|
||||
void close();
|
||||
|
||||
private:
|
||||
QLabel * progress;
|
||||
QLabel * textLabel;
|
||||
QLineEdit * path;
|
||||
QPushButton * find;
|
||||
QPushButton * accept;
|
||||
QPushButton * cancel;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // EXPORT_COMICS_INFO_DIALOG_H
|
110
YACReaderLibrary/import_comics_info_dialog.cpp
Normal file
110
YACReaderLibrary/import_comics_info_dialog.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
#include "import_comics_info_dialog.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFileDialog>
|
||||
#include <QProgressBar>
|
||||
|
||||
#include "data_base_management.h"
|
||||
|
||||
ImportComicsInfoDialog::ImportComicsInfoDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
setModal(true);
|
||||
setWindowTitle(tr("Import comics info"));
|
||||
|
||||
|
||||
textLabel = new QLabel(tr("Info database location : "));
|
||||
path = new QLineEdit;
|
||||
textLabel->setBuddy(path);
|
||||
|
||||
accept = new QPushButton(tr("Import"));
|
||||
accept->setDisabled(true);
|
||||
connect(accept,SIGNAL(clicked()),this,SLOT(import()));
|
||||
|
||||
cancel = new QPushButton(tr("Cancel"));
|
||||
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
|
||||
//connect(cancel,SIGNAL(clicked()),this,SIGNAL(rejected()));
|
||||
|
||||
find = new QPushButton(QIcon(":/images/coversPackage.png"),"");
|
||||
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
|
||||
|
||||
QHBoxLayout *libraryLayout = new QHBoxLayout;
|
||||
|
||||
libraryLayout->addWidget(textLabel);
|
||||
libraryLayout->addWidget(path);
|
||||
libraryLayout->addWidget(find);
|
||||
libraryLayout->setStretchFactor(find,0); //TODO
|
||||
|
||||
progressBar = new QProgressBar(this);
|
||||
progressBar->setMinimum(0);
|
||||
progressBar->setMaximum(0);
|
||||
progressBar->setTextVisible(false);
|
||||
progressBar->hide();
|
||||
connect(accept,SIGNAL(progressBar()),this,SLOT(show()));
|
||||
|
||||
QHBoxLayout *bottomLayout = new QHBoxLayout;
|
||||
bottomLayout->addStretch();
|
||||
bottomLayout->addWidget(accept);
|
||||
bottomLayout->addWidget(cancel);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(libraryLayout);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addWidget(progressBar);
|
||||
mainLayout->addLayout(bottomLayout);
|
||||
|
||||
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
||||
QLabel * imgLabel = new QLabel(this);
|
||||
QPixmap p(":/images/importComicsInfo.png");
|
||||
imgLabel->setPixmap(p);
|
||||
imgMainLayout->addWidget(imgLabel);
|
||||
imgMainLayout->addLayout(mainLayout);
|
||||
|
||||
setLayout(imgMainLayout);
|
||||
|
||||
setModal(true);
|
||||
}
|
||||
|
||||
ImportComicsInfoDialog::~ImportComicsInfoDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ImportComicsInfoDialog::findPath()
|
||||
{
|
||||
QString s = QFileDialog::getOpenFileName(0,"Comics Info",".",tr("Comics info file (*.ydb)"));
|
||||
if(!s.isEmpty())
|
||||
{
|
||||
path->setText(s);
|
||||
accept->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ImportComicsInfoDialog::import()
|
||||
{
|
||||
progressBar->show();
|
||||
|
||||
Importer * importer = new Importer();
|
||||
importer->source = path->text();
|
||||
importer->dest = dest;
|
||||
connect(importer,SIGNAL(finished()),this,SLOT(close()));
|
||||
connect(importer,SIGNAL(finished()),this,SLOT(hide()));
|
||||
importer->start();
|
||||
}
|
||||
|
||||
void ImportComicsInfoDialog::close()
|
||||
{
|
||||
path->clear();
|
||||
progressBar->hide();
|
||||
accept->setDisabled(true);
|
||||
QDialog::close();
|
||||
}
|
||||
|
||||
void Importer::run()
|
||||
{
|
||||
DataBaseManagement::importComicsInfo(source,dest);
|
||||
}
|
||||
|
||||
|
52
YACReaderLibrary/import_comics_info_dialog.h
Normal file
52
YACReaderLibrary/import_comics_info_dialog.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef IMPORT_COMICS_INFO_DIALOG_H
|
||||
#define IMPORT_COMICS_INFO_DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QProgressBar>
|
||||
#include <QThread>
|
||||
|
||||
class Importer : public QThread
|
||||
{
|
||||
public:
|
||||
QString source;
|
||||
QString dest;
|
||||
private:
|
||||
void run();
|
||||
};
|
||||
|
||||
class ImportComicsInfoDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ImportComicsInfoDialog(QWidget *parent = 0);
|
||||
~ImportComicsInfoDialog();
|
||||
QString dest;
|
||||
|
||||
private:
|
||||
QLabel * nameLabel;
|
||||
QLabel * textLabel;
|
||||
QLabel * destLabel;
|
||||
QLineEdit * path;
|
||||
QLineEdit * destPath;
|
||||
QLineEdit * nameEdit;
|
||||
QPushButton * find;
|
||||
QPushButton * findDest;
|
||||
QPushButton * accept;
|
||||
QPushButton * cancel;
|
||||
QLabel * progress;
|
||||
void setupUI();
|
||||
int progressCount;
|
||||
QProgressBar *progressBar;
|
||||
|
||||
public slots:
|
||||
void findPath();
|
||||
void import();
|
||||
void close();
|
||||
};
|
||||
|
||||
#endif // IMPORT_COMICS_INFO_DIALOG_H
|
@ -550,6 +550,9 @@ void LibraryWindow::createConnections()
|
||||
connect(exportComicsInfo,SIGNAL(triggered()),this,SLOT(showExportComicsInfo()));
|
||||
connect(importComicsInfo,SIGNAL(triggered()),this,SLOT(showImportComicsInfo()));
|
||||
|
||||
//properties
|
||||
connect(propertiesDialog,SIGNAL(accepted()),this,SLOT(reloadCovers()));
|
||||
|
||||
connect(updateLibraryAction,SIGNAL(triggered()),this,SLOT(updateLibrary()));
|
||||
connect(renameLibraryAction,SIGNAL(triggered()),this,SLOT(renameLibrary()));
|
||||
connect(deleteLibraryAction,SIGNAL(triggered()),this,SLOT(deleteLibrary()));
|
||||
@ -642,7 +645,7 @@ void LibraryWindow::loadLibrary(const QString & name)
|
||||
|
||||
void LibraryWindow::loadCovers(const QModelIndex & mi)
|
||||
{
|
||||
|
||||
_rootIndexCV = mi;
|
||||
unsigned long long int folderId = 1;
|
||||
if(mi.isValid())
|
||||
{
|
||||
@ -670,11 +673,12 @@ void LibraryWindow::loadCovers(const QModelIndex & mi)
|
||||
//comicView->setModel(NULL);
|
||||
dmCV->setupModelData(folderId,dm->getDatabase());
|
||||
comicView->setModel(dmCV);
|
||||
//TODO automatizar (valorar si se deja al modelo)
|
||||
comicView->horizontalHeader()->hideSection(1);
|
||||
|
||||
comicView->horizontalHeader()->hideSection(4);
|
||||
comicView->horizontalHeader()->hideSection(3);
|
||||
//TODO
|
||||
comicView->horizontalHeader()->hideSection(5);
|
||||
comicView->horizontalHeader()->hideSection(6);
|
||||
comicView->horizontalHeader()->hideSection(7);
|
||||
comicView->horizontalHeader()->hideSection(8);
|
||||
|
||||
QStringList paths = dmCV->getPaths(currentPath());
|
||||
comicFlow->setImagePaths(paths);
|
||||
@ -709,6 +713,11 @@ void LibraryWindow::loadCovers(const QModelIndex & mi)
|
||||
comicView->setCurrentIndex(dmCV->index(0,0));
|
||||
}
|
||||
|
||||
void LibraryWindow::reloadCovers()
|
||||
{
|
||||
loadCovers(_rootIndexCV);
|
||||
}
|
||||
|
||||
void LibraryWindow::centerComicFlow(const QModelIndex & mi)
|
||||
{
|
||||
int distance = comicFlow->centerIndex()-mi.row();
|
||||
|
@ -155,6 +155,7 @@ public:
|
||||
public slots:
|
||||
void loadLibrary(const QString & path);
|
||||
void loadCovers(const QModelIndex & mi);
|
||||
void reloadCovers();
|
||||
void centerComicFlow(const QModelIndex & mi);
|
||||
void updateComicView(int i);
|
||||
void openComic();
|
||||
|
Loading…
x
Reference in New Issue
Block a user