mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-12-24 20:34:59 +00:00
NOISSUE Try to enable dragging accross views
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <QString>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QDebug>
|
||||
#include <QtCore/QDataStream>
|
||||
|
||||
SimpleModList::SimpleModList(const QString &dir) : QAbstractListModel(), m_dir(dir)
|
||||
{
|
||||
@@ -313,8 +314,7 @@ Qt::ItemFlags SimpleModList::flags(const QModelIndex &index) const
|
||||
{
|
||||
Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
|
||||
if (index.isValid())
|
||||
return Qt::ItemIsUserCheckable | Qt::ItemIsDropEnabled |
|
||||
defaultFlags;
|
||||
return Qt::ItemIsUserCheckable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled | defaultFlags;
|
||||
else
|
||||
return Qt::ItemIsDropEnabled | defaultFlags;
|
||||
}
|
||||
@@ -325,6 +325,11 @@ Qt::DropActions SimpleModList::supportedDropActions() const
|
||||
return Qt::CopyAction | Qt::MoveAction;
|
||||
}
|
||||
|
||||
Qt::DropActions SimpleModList::supportedDragActions() const
|
||||
{
|
||||
return Qt::CopyAction | Qt::MoveAction;
|
||||
}
|
||||
|
||||
QStringList SimpleModList::mimeTypes() const
|
||||
{
|
||||
QStringList types;
|
||||
@@ -332,6 +337,7 @@ QStringList SimpleModList::mimeTypes() const
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
bool SimpleModList::dropMimeData(const QMimeData* data, Qt::DropAction action, int, int, const QModelIndex&)
|
||||
{
|
||||
if (action == Qt::IgnoreAction)
|
||||
@@ -363,3 +369,22 @@ bool SimpleModList::dropMimeData(const QMimeData* data, Qt::DropAction action, i
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QMimeData *SimpleModList::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
auto *mimeData = new QMimeData();
|
||||
QByteArray encodedData;
|
||||
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
for(const auto &index : indexes)
|
||||
{
|
||||
if(index.isValid())
|
||||
{
|
||||
auto mod = mods[index.row()];
|
||||
stream << "file://" << mod.filename().absoluteFilePath() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
mimeData->setData("text/uri-list", encodedData);
|
||||
return mimeData;
|
||||
}
|
||||
@@ -49,11 +49,13 @@ public:
|
||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
|
||||
/// flags, mostly to support drag&drop
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QStringList mimeTypes() const override;
|
||||
bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
|
||||
virtual int rowCount(const QModelIndex &) const override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user