mirror of
https://github.com/YACReader/yacreader
synced 2025-08-05 13:55:43 -04:00
added drag&drop to GridView
This commit is contained in:
@ -50,6 +50,7 @@ bool ComicModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, i
|
||||
//TODO: optimize this method
|
||||
bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||
{
|
||||
|
||||
QAbstractItemModel::dropMimeData(data,action,row,column,parent);
|
||||
QLOG_INFO() << ">>>>>>>>>>>>>>dropMimeData ComicModel<<<<<<<<<<<<<<<<<"<< parent << row << "," << column;
|
||||
|
||||
@ -117,6 +118,8 @@ bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
||||
|
||||
QLOG_INFO() << newSorting;
|
||||
|
||||
if(!beginMoveRows(parent,currentIndexes.first(),currentIndexes.last(),parent,row))
|
||||
return false;
|
||||
_data = resortedData;
|
||||
|
||||
|
||||
@ -141,6 +144,9 @@ bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
||||
}
|
||||
|
||||
QSqlDatabase::removeDatabase(_databasePath);
|
||||
|
||||
endMoveRows();
|
||||
|
||||
emit resortedIndexes(newSorting);
|
||||
int destSelectedIndex = row<0?_data.length():row;
|
||||
|
||||
@ -152,6 +158,11 @@ bool ComicModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ComicModel::canBeResorted()
|
||||
{
|
||||
return enableResorting;
|
||||
}
|
||||
|
||||
QMimeData *ComicModel::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
//custom model data
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
||||
bool canBeResorted();
|
||||
QMimeData * mimeData(const QModelIndexList &indexes) const;
|
||||
QStringList mimeTypes() const;
|
||||
|
||||
|
Reference in New Issue
Block a user