mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
fixed Grid View sorting on discontinuous selection (drag&drop for sorting)
This commit is contained in:
parent
d28b56db17
commit
433e1ef71c
@ -47,7 +47,7 @@ bool ComicModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, i
|
|||||||
return data->formats().contains(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat);
|
return data->formats().contains(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: optimize this method
|
//TODO: optimize this method (seriously)
|
||||||
bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -118,9 +118,26 @@ bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
|||||||
|
|
||||||
QLOG_INFO() << newSorting;
|
QLOG_INFO() << newSorting;
|
||||||
|
|
||||||
if(!beginMoveRows(parent,currentIndexes.first(),currentIndexes.last(),parent,row))
|
int tempRow = row;
|
||||||
return false;
|
foreach(qulonglong id, comicIds)
|
||||||
_data = resortedData;
|
{
|
||||||
|
int i = 0;
|
||||||
|
foreach (ComicItem *item, _data) {
|
||||||
|
if(item->data(Id) == id)
|
||||||
|
{
|
||||||
|
beginMoveRows(parent,i,i,parent,tempRow);
|
||||||
|
_data.removeAll(item);
|
||||||
|
_data.insert(tempRow++, item);
|
||||||
|
endMoveRows();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if(!beginMoveRows(parent,currentIndexes.first(),currentIndexes.last(),parent,row))
|
||||||
|
return false;*/
|
||||||
|
_data = resortedData; //TODO No longer needed
|
||||||
|
|
||||||
|
|
||||||
//TODO emit signals
|
//TODO emit signals
|
||||||
@ -145,7 +162,7 @@ bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
|||||||
|
|
||||||
QSqlDatabase::removeDatabase(_databasePath);
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
|
|
||||||
endMoveRows();
|
//endMoveRows();
|
||||||
|
|
||||||
emit resortedIndexes(newSorting);
|
emit resortedIndexes(newSorting);
|
||||||
int destSelectedIndex = row<0?_data.length():row;
|
int destSelectedIndex = row<0?_data.length():row;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user