fixed qt4 compilation

added remove/reset comics to SortVolumeComics
This commit is contained in:
Luis Ángel San Martín
2013-11-18 18:47:45 +01:00
parent e64e5d2d2a
commit 4006bf6e43
5 changed files with 91 additions and 1 deletions

View File

@ -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)

View File

@ -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