mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
fixed qt4 compilation
added remove/reset comics to SortVolumeComics
This commit is contained in:
parent
e64e5d2d2a
commit
4006bf6e43
@ -88,7 +88,52 @@ QModelIndex LocalComicListModel::index(int row, int column, const QModelIndex &p
|
||||
|
||||
QList<ComicDB> LocalComicListModel::getData()
|
||||
{
|
||||
return _data;
|
||||
return _data;
|
||||
}
|
||||
|
||||
void LocalComicListModel::removeComics(const QList<QModelIndex> &selectedIndexes)
|
||||
{
|
||||
QModelIndex mi = selectedIndexes.first();
|
||||
QModelIndex lastMi = selectedIndexes.last();
|
||||
int sourceRow = mi.row();
|
||||
int sourceLastRow = lastMi.row();
|
||||
|
||||
beginRemoveRows(QModelIndex(),selectedIndexes.first().row(),selectedIndexes.last().row());
|
||||
|
||||
for(int i = sourceLastRow;i>=sourceRow;i--)
|
||||
{
|
||||
_removed.push_front(_data.at(i));
|
||||
_data.removeAt(i);
|
||||
}
|
||||
|
||||
endRemoveRows();
|
||||
|
||||
beginInsertRows(QModelIndex(),_data.count()-_removed.count(),_data.count()-1);
|
||||
for(int i = 0; i<_removed.count(); i++)
|
||||
_data.append(ComicDB());
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void LocalComicListModel::restoreAll()
|
||||
{
|
||||
int numItemsToRemove = 0;
|
||||
for(int i = 0;numItemsToRemove<_removed.count();i++)
|
||||
{
|
||||
if(_data.at(i).getFileName().isEmpty())
|
||||
{
|
||||
beginRemoveRows(QModelIndex(),i,i);
|
||||
_data.removeAt(i);
|
||||
endRemoveRows();
|
||||
|
||||
beginInsertRows(QModelIndex(),i,i);
|
||||
_data.insert(i,_removed.at(numItemsToRemove));
|
||||
endInsertRows();
|
||||
|
||||
numItemsToRemove++;
|
||||
}
|
||||
}
|
||||
|
||||
_removed.clear();
|
||||
}
|
||||
|
||||
void LocalComicListModel::moveSelectionUp(const QList<QModelIndex> &selectedIndexes)
|
||||
|
@ -23,6 +23,9 @@ public:
|
||||
int role = Qt::DisplayRole) const;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
QList<ComicDB> getData();
|
||||
|
||||
void removeComics(const QList<QModelIndex> & selectedIndexes);
|
||||
void restoreAll();
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
@ -33,6 +36,7 @@ public slots:
|
||||
private:
|
||||
int numExtraRows;
|
||||
QList<ComicDB> _data;
|
||||
QList<ComicDB> _removed;
|
||||
};
|
||||
|
||||
#endif // LOCAL_COMIC_LIST_MODEL_H
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QHeaderView>
|
||||
#include <QToolButton>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "scraper_tableview.h"
|
||||
|
||||
@ -49,7 +50,11 @@ SelectVolume::SelectVolume(QWidget *parent)
|
||||
|
||||
tableVolumes = new ScraperTableView(this);
|
||||
tableVolumes->setSortingEnabled(true);
|
||||
#if QT_VERSION >= 0x050000
|
||||
tableVolumes->horizontalHeader()->setSectionsClickable(true);
|
||||
#else
|
||||
tableVolumes->horizontalHeader()->setClickable(true);
|
||||
#endif
|
||||
//tableVolumes->horizontalHeader()->setSortIndicatorShown(false);
|
||||
connect(tableVolumes->horizontalHeader(),SIGNAL(sectionClicked(int)), tableVolumes, SLOT(sortByColumn(int)));
|
||||
//connections
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QScrollBar>
|
||||
#include <QAction>
|
||||
|
||||
#include "scraper_tableview.h"
|
||||
#include "local_comic_list_model.h"
|
||||
@ -85,6 +86,20 @@ SortVolumeComics::SortVolumeComics(QWidget *parent) :
|
||||
l->setContentsMargins(0,0,0,0);
|
||||
setLayout(l);
|
||||
setContentsMargins(0,0,0,0);
|
||||
|
||||
//rows actions
|
||||
QAction * removeItemFromList = new QAction(tr("remove selected comics"),this);
|
||||
QAction * restoreAllItems = new QAction(tr("restore all removed comics"),this);
|
||||
QAction * restoreItems = new QAction(tr("restore removed comics"),this);
|
||||
|
||||
tableFiles->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
tableFiles->addAction(removeItemFromList);
|
||||
tableFiles->addAction(restoreAllItems);
|
||||
//tableFiles->addAction(restoreItems);
|
||||
|
||||
connect(removeItemFromList,SIGNAL(triggered()),this,SLOT(removeSelectedComics()));
|
||||
connect(restoreAllItems,SIGNAL(triggered()),this,SLOT(restoreAllComics()));
|
||||
connect(restoreItems,SIGNAL(triggered()),this,SLOT(showRemovedComicsSelector()));
|
||||
}
|
||||
|
||||
void SortVolumeComics::setData(QList<ComicDB> & comics, const QString &json, const QString &vID)
|
||||
@ -170,6 +185,23 @@ void SortVolumeComics::moveDownIL()
|
||||
|
||||
}
|
||||
|
||||
void SortVolumeComics::removeSelectedComics()
|
||||
{
|
||||
QList<QModelIndex> selection = tableFiles->selectionModel()->selectedIndexes();
|
||||
|
||||
localComicsModel->removeComics(selection);
|
||||
}
|
||||
|
||||
void SortVolumeComics::restoreAllComics()
|
||||
{
|
||||
localComicsModel->restoreAll();
|
||||
}
|
||||
|
||||
void SortVolumeComics::showRemovedComicsSelector()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QList<QPair<ComicDB, QString> > SortVolumeComics::getMatchingInfo()
|
||||
{
|
||||
QList<ComicDB> comicList = localComicsModel->getData();
|
||||
|
@ -77,6 +77,10 @@ protected slots:
|
||||
void moveUpIL();
|
||||
void moveDownIL();
|
||||
|
||||
void removeSelectedComics();
|
||||
void restoreAllComics();
|
||||
void showRemovedComicsSelector();
|
||||
|
||||
|
||||
private:
|
||||
ScraperTableView * tableFiles;
|
||||
|
Loading…
Reference in New Issue
Block a user