diff options
| author | Al <gabriel.cortesi@outlook.com> | 2019-05-19 16:58:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-19 16:58:08 +0200 |
| commit | b22ee0dc56fcf055088f86624c4f83aa194c2037 (patch) | |
| tree | 85dda74610e06f3a470a00c840f34fcf2c005f2f /src/modinfodialog.h | |
| parent | c1db638d924bbec6521147de45f8815c9c9ee5e1 (diff) | |
| parent | eb203e4c2a7ef8d7e9efe43b9e5df0c8b2253ea7 (diff) | |
Merge pull request #717 from isanae/Develop
enable multiple selection in the conflict tree and file tree
Diffstat (limited to 'src/modinfodialog.h')
| -rw-r--r-- | src/modinfodialog.h | 162 |
1 files changed, 154 insertions, 8 deletions
diff --git a/src/modinfodialog.h b/src/modinfodialog.h index 4c731c00..66c50be5 100644 --- a/src/modinfodialog.h +++ b/src/modinfodialog.h @@ -49,6 +49,141 @@ class QTreeView; class CategoryFactory;
/**
+* Renames individual files and handles dialog boxes to confirm replacements and
+* failures with the user
+**/
+class FileRenamer
+{
+public:
+ /**
+ * controls appearance and replacement behaviour; if RENAME_REPLACE_ALL and
+ * RENAME_REPLACE_NONE are not provided, the user will have the option to
+ * choose on the first replacement
+ **/
+ enum RenameFlags
+ {
+ /**
+ * this renamer will be used on multiple files, so display additional
+ * buttons to replace all and for canceling
+ **/
+ MULTIPLE = 0x01,
+
+ /**
+ * customizes some of the text shown on dialog to mention that files are
+ * being hidden
+ **/
+ HIDE = 0x02,
+
+ /**
+ * customizes some of the text shown on dialog to mention that files are
+ * being unhidden
+ **/
+ UNHIDE = 0x04,
+
+ /**
+ * silently replaces all existing files
+ **/
+ REPLACE_ALL = 0x08,
+
+ /**
+ * silently skips all existing files
+ **/
+ REPLACE_NONE = 0x10,
+ };
+
+
+ /** result of a single rename
+ *
+ **/
+ enum RenameResults
+ {
+ /**
+ * the user skipped this file
+ */
+ RESULT_SKIP,
+
+ /**
+ * the file was successfully renamed
+ */
+ RESULT_OK,
+
+ /**
+ * the user wants to cancel
+ */
+ RESULT_CANCEL
+ };
+
+
+ /**
+ * @param parent Parent widget for dialog boxes
+ **/
+ FileRenamer(QWidget* parent, QFlags<RenameFlags> flags);
+
+ /**
+ * renames the given file
+ * @param oldName current filename
+ * @param newName new filename
+ * @return whether the file was renamed, skipped or the user wants to cancel
+ **/
+ RenameResults rename(const QString& oldName, const QString& newName);
+
+private:
+ /**
+ *user's decision when replacing
+ **/
+ enum RenameDecision
+ {
+ /**
+ * replace the file
+ **/
+ DECISION_REPLACE,
+
+ /**
+ * skip the file
+ **/
+ DECISION_SKIP,
+
+ /**
+ * cancel the whole thing
+ **/
+ DECISION_CANCEL
+ };
+
+ /**
+ * parent widget for dialog boxes
+ **/
+ QWidget* m_parent;
+
+ /**
+ * flags
+ **/
+ QFlags<RenameFlags> m_flags;
+
+ /**
+ * asks the user to replace an existing file, may return early if the user
+ * has already selected to replace all/none
+ * @return whether to replace, skip or cancel
+ **/
+ RenameDecision confirmReplace(const QString& newName);
+
+ /**
+ * removal of a file failed, ask the user to continue or cancel
+ * @param name The name of the file that failed to be removed
+ * @return true to continue, false to stop
+ **/
+ bool removeFailed(const QString& name);
+
+ /**
+ * renaming a file failed, ask the user to continue or cancel
+ * @param oldName current filename
+ * @param newName new filename
+ * @return true to continue, false to stop
+ **/
+ bool renameFailed(const QString& oldName, const QString& newName);
+};
+
+
+/**
* this is a larger dialog used to visualise information abount the mod.
* @todo this would probably a good place for a plugin-system
**/
@@ -147,8 +282,8 @@ private: void openIniFile(const QString &fileName);
bool allowNavigateFromTXT();
bool allowNavigateFromINI();
- bool hideFile(const QString &oldName);
- bool unhideFile(const QString &oldName);
+ FileRenamer::RenameResults hideFile(FileRenamer& renamer, const QString &oldName);
+ FileRenamer::RenameResults unhideFile(FileRenamer& renamer, const QString &oldName);
void addCheckedCategories(QTreeWidgetItem *tree);
void refreshPrimaryCategoriesBox();
@@ -156,12 +291,14 @@ private: private slots:
- void hideConflictFile();
- void unhideConflictFile();
+ void hideConflictFiles();
+ void unhideConflictFiles();
+ void previewOverwriteDataFile();
+ void openOverwriteDataFile();
int getBinaryExecuteInfo(const QFileInfo &targetInfo, QFileInfo &binaryInfo, QString &arguments);
- void previewDataFile();
- void openDataFile();
+ void previewOverwrittenDataFile();
+ void openOverwrittenDataFile();
void thumbnailClicked(const QString &fileName);
void linkClicked(const QUrl &url);
@@ -241,13 +378,22 @@ private: QAction *m_HideAction;
QAction *m_UnhideAction;
- QTreeWidgetItem *m_ConflictsContextItem;
-
const MOShared::DirectoryEntry *m_Directory;
MOShared::FilesOrigin *m_Origin;
std::map<int, int> m_RealTabPos;
+ bool canHideConflictItem(const QTreeWidgetItem* item) const;
+ bool canUnhideConflictItem(const QTreeWidgetItem* item) const;
+ bool canPreviewConflictItem(const QTreeWidgetItem* item) const;
+
+ void previewDataFile(const QTreeWidgetItem* item);
+ void openDataFile(const QTreeWidgetItem* item);
+ void changeConflictFilesVisibility(bool hide);
+ void changeFiletreeVisibility(bool hide);
+
+ bool canHideFile(bool isArchive, const QString& filename) const;
+ bool canUnhideFile(bool isArchive, const QString& filename) const;
};
#endif // MODINFODIALOG_H
|
