Utils: Create re-usable Callable for copying and asking for overwrite

FileUtils::copyRecursively has the option to override the copy
operation, and this is e.g. used for asking the user if files already
exist, and to track what is actually copied.

Make that functionality available for re-use.

Change-Id: I16b7eddd32509b06866a1070e45ab58629f9a9be
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2020-06-11 15:41:26 +02:00
parent 0be309bcf1
commit 7cedde2a0a
2 changed files with 76 additions and 2 deletions

View File

@@ -162,6 +162,22 @@ private:
class QTCREATOR_UTILS_EXPORT FileUtils {
public:
#ifdef QT_GUI_LIB
class QTCREATOR_UTILS_EXPORT CopyAskingForOverwrite
{
public:
CopyAskingForOverwrite(QWidget *dialogParent);
bool operator()(const QFileInfo &src, const QFileInfo &dest, QString *error);
QStringList files() const;
private:
QWidget *m_parent;
QStringList m_files;
bool m_overwriteAll = false;
bool m_skipAll = false;
};
#endif // QT_GUI_LIB
static bool removeRecursively(const FilePath &filePath, QString *error = nullptr);
static bool copyRecursively(
const FilePath &srcFilePath, const FilePath &tgtFilePath, QString *error = nullptr,