mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
added sorting options to SortVolumeComics
This commit is contained in:
@ -214,7 +214,10 @@ void ComicVineDialog::debugClientResults(const QString & string)
|
||||
p.loadJSONResponse(string);
|
||||
//QMessageBox::information(0,"Result", QString("Number of results : %1").arg(p.getNumResults()));
|
||||
if(p.responseError())
|
||||
{
|
||||
QMessageBox::critical(0,"Error from ComicVine", "-");
|
||||
goBack();
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(mode)
|
||||
|
@ -20,7 +20,7 @@ QModelIndex LocalComicListModel::parent(const QModelIndex &index) const
|
||||
int LocalComicListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return _data.count() + numExtraRows;
|
||||
return _data.count();
|
||||
}
|
||||
|
||||
int LocalComicListModel::columnCount(const QModelIndex &parent) const
|
||||
@ -51,10 +51,10 @@ QVariant LocalComicListModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
int row = index.row();
|
||||
|
||||
if(row < _data.count())
|
||||
//if(row < _data.count())
|
||||
return _data[row].getFileName();
|
||||
else
|
||||
return QVariant();
|
||||
//else
|
||||
//return QVariant();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
numExtraRows = numRows;
|
||||
for(int i = 0; i<numExtraRows; i++)
|
||||
_data.append(ComicDB());
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,8 @@ public:
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
void moveSelectionUp(const QList<QModelIndex> & selectedIndexes);
|
||||
void moveSelectionDown(const QList<QModelIndex> & selectedIndexes);
|
||||
void addExtraRows(int numRows);
|
||||
|
||||
private:
|
||||
|
@ -14,20 +14,27 @@ SortVolumeComics::SortVolumeComics(QWidget *parent) :
|
||||
{
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
moveUpButtonCL = new ScrapperToolButton(ScrapperToolButton::LEFT);
|
||||
moveUpButtonCL->setIcon(QIcon(":/images/comic_vine/rowUp.png"));
|
||||
moveUpButtonCL->setAutoRepeat(true);
|
||||
moveDownButtonCL = new ScrapperToolButton(ScrapperToolButton::RIGHT);
|
||||
moveDownButtonCL->setIcon(QIcon(":/images/comic_vine/rowDown.png"));
|
||||
moveUpButtonIL = new ScrapperToolButton(ScrapperToolButton::LEFT);
|
||||
moveUpButtonIL->setIcon(QIcon(":/images/comic_vine/rowUp.png"));
|
||||
moveDownButtonIL = new ScrapperToolButton(ScrapperToolButton::RIGHT);
|
||||
moveDownButtonIL->setIcon(QIcon(":/images/comic_vine/rowDown.png"));
|
||||
moveDownButtonCL->setAutoRepeat(true);
|
||||
//moveUpButtonIL = new ScrapperToolButton(ScrapperToolButton::LEFT);
|
||||
//moveUpButtonIL->setIcon(QIcon(":/images/comic_vine/rowUp.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;
|
||||
QHBoxLayout * content = new QHBoxLayout;
|
||||
@ -36,6 +43,9 @@ SortVolumeComics::SortVolumeComics(QWidget *parent) :
|
||||
tableFiles = new ScraperTableView();
|
||||
tableVolumeComics = new ScraperTableView();
|
||||
|
||||
tableFiles->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
tableFiles->setSelectionMode(QAbstractItemView::ContiguousSelection);
|
||||
|
||||
tableFiles->setFixedSize(407,341);
|
||||
tableVolumeComics->setFixedSize(407,341);
|
||||
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(tableFiles->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
|
||||
|
||||
connect(tableVolumeComics, SIGNAL(pressed(QModelIndex)), tableFiles, SLOT(setCurrentIndex(QModelIndex)));
|
||||
connect(tableFiles, SIGNAL(pressed(QModelIndex)), tableVolumeComics, SLOT(setCurrentIndex(QModelIndex)));
|
||||
//connect(tableVolumeComics, SIGNAL(pressed(QModelIndex)), tableFiles, SLOT(setCurrentIndex(QModelIndex)));
|
||||
//connect(tableFiles, SIGNAL(pressed(QModelIndex)), tableVolumeComics, SLOT(setCurrentIndex(QModelIndex)));
|
||||
|
||||
sortButtonsLayout->addWidget(moveUpButtonCL);
|
||||
sortButtonsLayout->addWidget(ScrapperToolButton::getSeparator());
|
||||
sortButtonsLayout->addWidget(moveDownButtonCL);
|
||||
sortButtonsLayout->addStretch();
|
||||
sortButtonsLayout->addSpacing(10);
|
||||
//sortButtonsLayout->addStretch();
|
||||
sortButtonsLayout->addWidget(sortLabel);
|
||||
sortButtonsLayout->addStretch();
|
||||
sortButtonsLayout->addWidget(moveUpButtonIL);
|
||||
sortButtonsLayout->addWidget(ScrapperToolButton::getSeparator());
|
||||
sortButtonsLayout->addWidget(moveDownButtonIL);
|
||||
//sortButtonsLayout->addStretch();
|
||||
//sortButtonsLayout->addWidget(moveUpButtonIL);
|
||||
//sortButtonsLayout->addWidget(ScrapperToolButton::getSeparator());
|
||||
//sortButtonsLayout->addWidget(moveDownButtonIL);
|
||||
sortButtonsLayout->setSpacing(0);
|
||||
|
||||
l->addSpacing(15);
|
||||
@ -117,3 +128,37 @@ void SortVolumeComics::synchronizeScroll(int pos)
|
||||
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:
|
||||
void paintEvent(QPaintEvent * e)
|
||||
{
|
||||
QPainter p(this);
|
||||
protected:
|
||||
void paintEvent(QPaintEvent * e)
|
||||
{
|
||||
QPainter p(this);
|
||||
|
||||
switch (appearance) {
|
||||
case LEFT:
|
||||
p.fillRect(16,0,2,18,QColor("#2E2E2E"));
|
||||
break;
|
||||
case RIGHT:
|
||||
p.fillRect(0,0,2,18,QColor("#2E2E2E"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QPushButton::paintEvent(e);
|
||||
switch (appearance) {
|
||||
case LEFT:
|
||||
p.fillRect(16,0,2,18,QColor("#2E2E2E"));
|
||||
break;
|
||||
case RIGHT:
|
||||
p.fillRect(0,0,2,18,QColor("#2E2E2E"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
private:
|
||||
Appearance appearance;
|
||||
};
|
||||
QPushButton::paintEvent(e);
|
||||
}
|
||||
|
||||
class SortVolumeComics : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SortVolumeComics(QWidget *parent = 0);
|
||||
private:
|
||||
Appearance appearance;
|
||||
};
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void setData(QList<ComicDB> & comics, const QString & json);
|
||||
class SortVolumeComics : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SortVolumeComics(QWidget *parent = 0);
|
||||
|
||||
protected slots:
|
||||
void synchronizeScroll(int pos);
|
||||
signals:
|
||||
|
||||
private:
|
||||
ScraperTableView * tableFiles;
|
||||
ScraperTableView * tableVolumeComics;
|
||||
public slots:
|
||||
void setData(QList<ComicDB> & comics, const QString & json);
|
||||
|
||||
LocalComicListModel * localComicsModel;
|
||||
VolumeComicsModel * volumeComicsModel;
|
||||
protected slots:
|
||||
void synchronizeScroll(int pos);
|
||||
void moveUpCL();
|
||||
void moveDownCL();
|
||||
void moveUpIL();
|
||||
void moveDownIL();
|
||||
|
||||
ScrapperToolButton * moveUpButtonCL;
|
||||
ScrapperToolButton * moveDownButtonCL;
|
||||
ScrapperToolButton * moveUpButtonIL;
|
||||
ScrapperToolButton * moveDownButtonIL;
|
||||
private:
|
||||
ScraperTableView * tableFiles;
|
||||
ScraperTableView * tableVolumeComics;
|
||||
|
||||
};
|
||||
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