mirror of
https://github.com/YACReader/yacreader
synced 2025-11-12 21:12:43 -05:00
added sorting options to SortVolumeComics
This commit is contained in:
@ -214,7 +214,10 @@ void ComicVineDialog::debugClientResults(const QString & string)
|
|||||||
p.loadJSONResponse(string);
|
p.loadJSONResponse(string);
|
||||||
//QMessageBox::information(0,"Result", QString("Number of results : %1").arg(p.getNumResults()));
|
//QMessageBox::information(0,"Result", QString("Number of results : %1").arg(p.getNumResults()));
|
||||||
if(p.responseError())
|
if(p.responseError())
|
||||||
|
{
|
||||||
QMessageBox::critical(0,"Error from ComicVine", "-");
|
QMessageBox::critical(0,"Error from ComicVine", "-");
|
||||||
|
goBack();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch(mode)
|
switch(mode)
|
||||||
|
|||||||
@ -20,7 +20,7 @@ QModelIndex LocalComicListModel::parent(const QModelIndex &index) const
|
|||||||
int LocalComicListModel::rowCount(const QModelIndex &parent) const
|
int LocalComicListModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent)
|
Q_UNUSED(parent)
|
||||||
return _data.count() + numExtraRows;
|
return _data.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LocalComicListModel::columnCount(const QModelIndex &parent) const
|
int LocalComicListModel::columnCount(const QModelIndex &parent) const
|
||||||
@ -51,10 +51,10 @@ QVariant LocalComicListModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
|
|
||||||
if(row < _data.count())
|
//if(row < _data.count())
|
||||||
return _data[row].getFileName();
|
return _data[row].getFileName();
|
||||||
else
|
//else
|
||||||
return QVariant();
|
//return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags LocalComicListModel::flags(const QModelIndex &index) const
|
Qt::ItemFlags LocalComicListModel::flags(const QModelIndex &index) const
|
||||||
@ -86,8 +86,48 @@ QModelIndex LocalComicListModel::index(int row, int column, const QModelIndex &p
|
|||||||
return createIndex(row, column);
|
return createIndex(row, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalComicListModel::moveSelectionUp(const QList<QModelIndex> &selectedIndexes)
|
||||||
|
{
|
||||||
|
QModelIndex mi = selectedIndexes.first();
|
||||||
|
QModelIndex lastMi = selectedIndexes.last();
|
||||||
|
int sourceRow = mi.row();
|
||||||
|
int sourceLastRow = lastMi.row();
|
||||||
|
int destRow = sourceRow - 1;
|
||||||
|
|
||||||
|
if(destRow < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
beginMoveRows(mi.parent(),sourceRow,sourceLastRow,mi.parent(),destRow);
|
||||||
|
|
||||||
|
for(int i = sourceRow; i <= sourceLastRow; i++)
|
||||||
|
_data.swap(i, i-1);
|
||||||
|
|
||||||
|
endMoveRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalComicListModel::moveSelectionDown(const QList<QModelIndex> &selectedIndexes)
|
||||||
|
{
|
||||||
|
QModelIndex mi = selectedIndexes.first();
|
||||||
|
QModelIndex lastMi = selectedIndexes.last();
|
||||||
|
int sourceRow = mi.row();
|
||||||
|
int sourceLastRow = lastMi.row();
|
||||||
|
int destRow = sourceLastRow + 1;
|
||||||
|
|
||||||
|
if(destRow >= _data.count())
|
||||||
|
return;
|
||||||
|
|
||||||
|
beginMoveRows(mi.parent(),sourceRow,sourceLastRow,mi.parent(),destRow+1);
|
||||||
|
|
||||||
|
for(int i = sourceLastRow; i >= sourceRow; i--)
|
||||||
|
_data.swap(i, i+1);
|
||||||
|
|
||||||
|
endMoveRows();
|
||||||
|
}
|
||||||
|
|
||||||
void LocalComicListModel::addExtraRows(int numRows)
|
void LocalComicListModel::addExtraRows(int numRows)
|
||||||
{
|
{
|
||||||
numExtraRows = numRows;
|
numExtraRows = numRows;
|
||||||
|
for(int i = 0; i<numExtraRows; i++)
|
||||||
|
_data.append(ComicDB());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,8 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void moveSelectionUp(const QList<QModelIndex> & selectedIndexes);
|
||||||
|
void moveSelectionDown(const QList<QModelIndex> & selectedIndexes);
|
||||||
void addExtraRows(int numRows);
|
void addExtraRows(int numRows);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -14,20 +14,27 @@ SortVolumeComics::SortVolumeComics(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
|
QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
|
||||||
|
|
||||||
QLabel * label = new QLabel(tr("Please, sort the list of comics info on the right until it matches your comics."));
|
QLabel * label = new QLabel(tr("Please, sort the list of comics on the left until it matches the comics' information."));
|
||||||
label->setStyleSheet(labelStylesheet);
|
label->setStyleSheet(labelStylesheet);
|
||||||
|
|
||||||
QLabel * sortLabel = new QLabel(tr("sort comic info to match your comic files"));
|
QLabel * sortLabel = new QLabel(tr("sort comics to match comic information"));
|
||||||
sortLabel->setStyleSheet(labelStylesheet);
|
sortLabel->setStyleSheet(labelStylesheet);
|
||||||
|
|
||||||
moveUpButtonCL = new ScrapperToolButton(ScrapperToolButton::LEFT);
|
moveUpButtonCL = new ScrapperToolButton(ScrapperToolButton::LEFT);
|
||||||
moveUpButtonCL->setIcon(QIcon(":/images/comic_vine/rowUp.png"));
|
moveUpButtonCL->setIcon(QIcon(":/images/comic_vine/rowUp.png"));
|
||||||
|
moveUpButtonCL->setAutoRepeat(true);
|
||||||
moveDownButtonCL = new ScrapperToolButton(ScrapperToolButton::RIGHT);
|
moveDownButtonCL = new ScrapperToolButton(ScrapperToolButton::RIGHT);
|
||||||
moveDownButtonCL->setIcon(QIcon(":/images/comic_vine/rowDown.png"));
|
moveDownButtonCL->setIcon(QIcon(":/images/comic_vine/rowDown.png"));
|
||||||
moveUpButtonIL = new ScrapperToolButton(ScrapperToolButton::LEFT);
|
moveDownButtonCL->setAutoRepeat(true);
|
||||||
moveUpButtonIL->setIcon(QIcon(":/images/comic_vine/rowUp.png"));
|
//moveUpButtonIL = new ScrapperToolButton(ScrapperToolButton::LEFT);
|
||||||
moveDownButtonIL = new ScrapperToolButton(ScrapperToolButton::RIGHT);
|
//moveUpButtonIL->setIcon(QIcon(":/images/comic_vine/rowUp.png"));
|
||||||
moveDownButtonIL->setIcon(QIcon(":/images/comic_vine/rowDown.png"));
|
//moveDownButtonIL = new ScrapperToolButton(ScrapperToolButton::RIGHT);
|
||||||
|
//moveDownButtonIL->setIcon(QIcon(":/images/comic_vine/rowDown.png"));
|
||||||
|
|
||||||
|
connect(moveUpButtonCL,SIGNAL(clicked()),this,SLOT(moveUpCL()));
|
||||||
|
connect(moveDownButtonCL,SIGNAL(clicked()),this,SLOT(moveDownCL()));
|
||||||
|
//connect(moveUpButtonIL,SIGNAL(clicked()),this,SLOT(moveUpIL()));
|
||||||
|
//connect(moveUpButtonIL,SIGNAL(clicked()),this,SLOT(moveDownIL()));
|
||||||
|
|
||||||
QVBoxLayout * l = new QVBoxLayout;
|
QVBoxLayout * l = new QVBoxLayout;
|
||||||
QHBoxLayout * content = new QHBoxLayout;
|
QHBoxLayout * content = new QHBoxLayout;
|
||||||
@ -36,6 +43,9 @@ SortVolumeComics::SortVolumeComics(QWidget *parent) :
|
|||||||
tableFiles = new ScraperTableView();
|
tableFiles = new ScraperTableView();
|
||||||
tableVolumeComics = new ScraperTableView();
|
tableVolumeComics = new ScraperTableView();
|
||||||
|
|
||||||
|
tableFiles->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
tableFiles->setSelectionMode(QAbstractItemView::ContiguousSelection);
|
||||||
|
|
||||||
tableFiles->setFixedSize(407,341);
|
tableFiles->setFixedSize(407,341);
|
||||||
tableVolumeComics->setFixedSize(407,341);
|
tableVolumeComics->setFixedSize(407,341);
|
||||||
content->addWidget(tableFiles,0,Qt::AlignLeft|Qt::AlignTop);
|
content->addWidget(tableFiles,0,Qt::AlignLeft|Qt::AlignTop);
|
||||||
@ -45,18 +55,19 @@ SortVolumeComics::SortVolumeComics(QWidget *parent) :
|
|||||||
connect(tableVolumeComics->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
|
connect(tableVolumeComics->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
|
||||||
connect(tableFiles->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
|
connect(tableFiles->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
|
||||||
|
|
||||||
connect(tableVolumeComics, SIGNAL(pressed(QModelIndex)), tableFiles, SLOT(setCurrentIndex(QModelIndex)));
|
//connect(tableVolumeComics, SIGNAL(pressed(QModelIndex)), tableFiles, SLOT(setCurrentIndex(QModelIndex)));
|
||||||
connect(tableFiles, SIGNAL(pressed(QModelIndex)), tableVolumeComics, SLOT(setCurrentIndex(QModelIndex)));
|
//connect(tableFiles, SIGNAL(pressed(QModelIndex)), tableVolumeComics, SLOT(setCurrentIndex(QModelIndex)));
|
||||||
|
|
||||||
sortButtonsLayout->addWidget(moveUpButtonCL);
|
sortButtonsLayout->addWidget(moveUpButtonCL);
|
||||||
sortButtonsLayout->addWidget(ScrapperToolButton::getSeparator());
|
sortButtonsLayout->addWidget(ScrapperToolButton::getSeparator());
|
||||||
sortButtonsLayout->addWidget(moveDownButtonCL);
|
sortButtonsLayout->addWidget(moveDownButtonCL);
|
||||||
sortButtonsLayout->addStretch();
|
sortButtonsLayout->addSpacing(10);
|
||||||
|
//sortButtonsLayout->addStretch();
|
||||||
sortButtonsLayout->addWidget(sortLabel);
|
sortButtonsLayout->addWidget(sortLabel);
|
||||||
sortButtonsLayout->addStretch();
|
//sortButtonsLayout->addStretch();
|
||||||
sortButtonsLayout->addWidget(moveUpButtonIL);
|
//sortButtonsLayout->addWidget(moveUpButtonIL);
|
||||||
sortButtonsLayout->addWidget(ScrapperToolButton::getSeparator());
|
//sortButtonsLayout->addWidget(ScrapperToolButton::getSeparator());
|
||||||
sortButtonsLayout->addWidget(moveDownButtonIL);
|
//sortButtonsLayout->addWidget(moveDownButtonIL);
|
||||||
sortButtonsLayout->setSpacing(0);
|
sortButtonsLayout->setSpacing(0);
|
||||||
|
|
||||||
l->addSpacing(15);
|
l->addSpacing(15);
|
||||||
@ -117,3 +128,37 @@ void SortVolumeComics::synchronizeScroll(int pos)
|
|||||||
connect(tableVolumeComicsScrollBar, SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
|
connect(tableVolumeComicsScrollBar, SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SortVolumeComics::moveUpCL()
|
||||||
|
{
|
||||||
|
QList<QModelIndex> selection = tableFiles->selectionModel()->selectedIndexes();
|
||||||
|
|
||||||
|
if(selection.count() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
localComicsModel->moveSelectionUp(selection);
|
||||||
|
|
||||||
|
selection = tableFiles->selectionModel()->selectedIndexes();
|
||||||
|
tableFiles->scrollTo(selection.first());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SortVolumeComics::moveDownCL()
|
||||||
|
{
|
||||||
|
QList<QModelIndex> selection = tableFiles->selectionModel()->selectedIndexes();
|
||||||
|
|
||||||
|
if(selection.count() > 0)
|
||||||
|
localComicsModel->moveSelectionDown(selection);
|
||||||
|
|
||||||
|
selection = tableFiles->selectionModel()->selectedIndexes();
|
||||||
|
tableFiles->scrollTo(selection.last());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SortVolumeComics::moveUpIL()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SortVolumeComics::moveDownIL()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -33,55 +33,60 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent * e)
|
void paintEvent(QPaintEvent * e)
|
||||||
{
|
{
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
|
|
||||||
switch (appearance) {
|
switch (appearance) {
|
||||||
case LEFT:
|
case LEFT:
|
||||||
p.fillRect(16,0,2,18,QColor("#2E2E2E"));
|
p.fillRect(16,0,2,18,QColor("#2E2E2E"));
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
p.fillRect(0,0,2,18,QColor("#2E2E2E"));
|
p.fillRect(0,0,2,18,QColor("#2E2E2E"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
QPushButton::paintEvent(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
QPushButton::paintEvent(e);
|
||||||
Appearance appearance;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
class SortVolumeComics : public QWidget
|
private:
|
||||||
{
|
Appearance appearance;
|
||||||
Q_OBJECT
|
};
|
||||||
public:
|
|
||||||
explicit SortVolumeComics(QWidget *parent = 0);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
public slots:
|
class SortVolumeComics : public QWidget
|
||||||
void setData(QList<ComicDB> & comics, const QString & json);
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit SortVolumeComics(QWidget *parent = 0);
|
||||||
|
|
||||||
protected slots:
|
signals:
|
||||||
void synchronizeScroll(int pos);
|
|
||||||
|
|
||||||
private:
|
public slots:
|
||||||
ScraperTableView * tableFiles;
|
void setData(QList<ComicDB> & comics, const QString & json);
|
||||||
ScraperTableView * tableVolumeComics;
|
|
||||||
|
|
||||||
LocalComicListModel * localComicsModel;
|
protected slots:
|
||||||
VolumeComicsModel * volumeComicsModel;
|
void synchronizeScroll(int pos);
|
||||||
|
void moveUpCL();
|
||||||
|
void moveDownCL();
|
||||||
|
void moveUpIL();
|
||||||
|
void moveDownIL();
|
||||||
|
|
||||||
ScrapperToolButton * moveUpButtonCL;
|
private:
|
||||||
ScrapperToolButton * moveDownButtonCL;
|
ScraperTableView * tableFiles;
|
||||||
ScrapperToolButton * moveUpButtonIL;
|
ScraperTableView * tableVolumeComics;
|
||||||
ScrapperToolButton * moveDownButtonIL;
|
|
||||||
|
|
||||||
};
|
LocalComicListModel * localComicsModel;
|
||||||
|
VolumeComicsModel * volumeComicsModel;
|
||||||
|
|
||||||
#endif // SORT_VOLUME_COMICS_H
|
ScrapperToolButton * moveUpButtonCL;
|
||||||
|
ScrapperToolButton * moveDownButtonCL;
|
||||||
|
ScrapperToolButton * moveUpButtonIL;
|
||||||
|
ScrapperToolButton * moveDownButtonIL;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SORT_VOLUME_COMICS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user