summaryrefslogtreecommitdiff
path: root/src/modlist.h
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-12-30 19:11:48 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-02 15:38:17 +0100
commit89ff59da4613f06a05a633b4aa4387470831ce94 (patch)
tree2217435c5c5b575ab81013d9113d673e2409bb4a /src/modlist.h
parent313589cf10640ae06cd7873989b5840f7c476e50 (diff)
Add message for invalid drag. Split & clean code.
Diffstat (limited to 'src/modlist.h')
-rw-r--r--src/modlist.h93
1 files changed, 9 insertions, 84 deletions
diff --git a/src/modlist.h b/src/modlist.h
index 815024b9..870978f9 100644
--- a/src/modlist.h
+++ b/src/modlist.h
@@ -43,6 +43,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
class QSortFilterProxyModel;
class PluginContainer;
class OrganizerCore;
+class ModListDropInfo;
/**
* Model presenting an overview of the installed mod
@@ -353,6 +354,14 @@ private:
MOBase::IModList::ModStates state(unsigned int modIndex) const;
+ // handle dropping of local URLs files
+ //
+ bool dropLocalFiles(const ModListDropInfo& dropInfo, int row, const QModelIndex& parent);
+
+ // return the priority of the mod for a drop event
+ //
+ int dropPriority(int row, const QModelIndex& parent) const;
+
private slots:
private:
@@ -374,90 +383,6 @@ private:
private:
- // small class that extract information from mimeData
- //
- class DropInfo {
- public:
-
- struct RelativeUrl {
- const QUrl url;
- const QString relativePath;
- const QString originName;
- };
-
- // returns true if this drop is valid
- //
- bool isValid() const;
-
- // returns true if these data corresponds to drag&drop
- // of local files (e.g. from overwrite)
- //
- bool isLocalFileDrop() const;
-
- // returns true if these data corresponds to drag&drop
- // of mod in the list
- //
- bool isModDrop() const;
-
- // returns true if these data corresponds to drag&drop
- // from the download list
- //
- bool isDownloadDrop() const;
-
- // returns true if these data corresponds to dropping
- // an archive for installation
- //
- bool isExternalArchiveDrop() const;
-
- // returns true if these data corresponds to dropping
- // a folder for copy
- //
- bool isExternalFolderDrop() const;
-
- const auto& rows() const { return m_rows; }
- const auto& download() const { return m_download; }
- const auto& localUrls() const { return m_localUrls; }
- const auto& externalUrl() const { return m_url; }
-
- private:
-
- friend class ModList;
-
- // retrieve the relative path of file and its origin given a URL from Mime data
- // returns an empty optional if the URL is not a valid file for dropping
- //
- std::optional<RelativeUrl> relativeUrl(const QUrl&) const;
-
- private:
- DropInfo(const QMimeData* mimeData, OrganizerCore& core);
-
- // rows for drag&drop between views
- std::vector<int> m_rows;
- int m_download; // -1 if invalid
-
- // local URLs from the data (relative path + origin name)
- std::vector<RelativeUrl> m_localUrls;
-
- // external URL
- QUrl m_url;
- };
-
- // create a DropInfo object from the given data
- //
- DropInfo dropInfo(const QMimeData* mimeData) const;
-
- bool dropURLs(const DropInfo& dropInfo, int row, const QModelIndex& parent);
-
- // return the priority of the mod for a drop event
- //
- int dropPriority(int row, const QModelIndex& parent) const;
-
-private:
-
- friend class ModListProxy;
- friend class ModListSortProxy;
- friend class ModListByPriorityProxy;
-
OrganizerCore *m_Organizer;
Profile *m_Profile;