forked from qt-creator/qt-creator
Core: FilePath-ify DocumentManager
And adjust users. Change-Id: I10ca9aeb442a07f7c8d42af362b294aa3398f5c1 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -69,7 +69,7 @@ static int indexOfFile(const GeneratedFiles &f, const QString &path)
|
||||
\sa Core::BaseFileWizardFactory
|
||||
*/
|
||||
|
||||
Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const QString &path, QWidget *parent,
|
||||
Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const FilePath &path, QWidget *parent,
|
||||
Id platform,
|
||||
const QVariantMap &extraValues,
|
||||
bool showWizard)
|
||||
@@ -86,7 +86,8 @@ Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const QString &path, QWidget
|
||||
if (flags().testFlag(ForceCapitalLetterForFileName))
|
||||
dialogParameterFlags |= WizardDialogParameters::ForceCapitalLetterForFileName;
|
||||
|
||||
Utils::Wizard *wizard = create(parent, WizardDialogParameters(path, platform,
|
||||
Utils::Wizard *wizard = create(parent, WizardDialogParameters(path.toString(),
|
||||
platform,
|
||||
requiredFeatures(),
|
||||
dialogParameterFlags,
|
||||
extraValues));
|
||||
|
@@ -114,9 +114,8 @@ protected:
|
||||
static bool postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage = nullptr);
|
||||
|
||||
private:
|
||||
// IWizard
|
||||
Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, Utils::Id platform,
|
||||
const QVariantMap &extraValues, bool showWizard = true) override;
|
||||
Utils::Wizard *runWizardImpl(const Utils::FilePath &path, QWidget *parent, Utils::Id platform,
|
||||
const QVariantMap &extraValues, bool showWizard = true) final;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
@@ -202,7 +202,7 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
expander->registerVariable("Config:DefaultProjectDirectory", tr("The configured default directory for projects."),
|
||||
[]() { return DocumentManager::projectsDirectory().toString(); });
|
||||
expander->registerVariable("Config:LastFileDialogDirectory", tr("The directory last visited in a file dialog."),
|
||||
[]() { return DocumentManager::fileDialogLastVisitedDirectory(); });
|
||||
[]() { return DocumentManager::fileDialogLastVisitedDirectory().toString(); });
|
||||
expander->registerVariable("HostOs:isWindows",
|
||||
tr("Is %1 running on Windows?").arg(Constants::IDE_DISPLAY_NAME),
|
||||
[]() { return QVariant(Utils::HostOsInfo::isWindowsHost()).toString(); });
|
||||
|
@@ -473,10 +473,10 @@ void NewDialogWidget::saveState()
|
||||
m_ui->comboBox->currentData().toString());
|
||||
}
|
||||
|
||||
static void runWizard(IWizardFactory *wizard, const QString &defaultLocation, Id platform,
|
||||
static void runWizard(IWizardFactory *wizard, const FilePath &defaultLocation, Id platform,
|
||||
const QVariantMap &variables)
|
||||
{
|
||||
QString path = wizard->runPath(defaultLocation);
|
||||
const FilePath path = wizard->runPath(defaultLocation);
|
||||
wizard->runWizard(path, ICore::dialogParent(), platform, variables);
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ void NewDialogWidget::accept()
|
||||
if (m_ui->templatesView->currentIndex().isValid()) {
|
||||
IWizardFactory *wizard = currentWizardFactory();
|
||||
if (QTC_GUARD(wizard)) {
|
||||
QMetaObject::invokeMethod(wizard, std::bind(&runWizard, wizard, m_defaultLocation.toString(),
|
||||
QMetaObject::invokeMethod(wizard, std::bind(&runWizard, wizard, m_defaultLocation,
|
||||
selectedPlatform(), m_extraVariables), Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
@@ -530,12 +530,12 @@ void ShortcutSettingsWidget::defaultAction()
|
||||
|
||||
void ShortcutSettingsWidget::exportAction()
|
||||
{
|
||||
QString fileName
|
||||
const FilePath filePath
|
||||
= DocumentManager::getSaveFileNameWithExtension(tr("Export Keyboard Mapping Scheme"),
|
||||
schemesPath().toString(),
|
||||
schemesPath(),
|
||||
tr("Keyboard Mapping Scheme (*.kms)"));
|
||||
if (!fileName.isEmpty()) {
|
||||
CommandsFile cf(FilePath::fromString(fileName));
|
||||
if (!filePath.isEmpty()) {
|
||||
CommandsFile cf(filePath);
|
||||
cf.exportCommands(m_scitems);
|
||||
}
|
||||
}
|
||||
|
@@ -188,8 +188,8 @@ public:
|
||||
|
||||
QFileSystemWatcher *m_fileWatcher = nullptr; // Delayed creation.
|
||||
QFileSystemWatcher *m_linkWatcher = nullptr; // Delayed creation (only UNIX/if a link is seen).
|
||||
QString m_lastVisitedDirectory = QDir::currentPath();
|
||||
QString m_defaultLocationForNewFiles;
|
||||
FilePath m_lastVisitedDirectory = FilePath::fromString(QDir::currentPath());
|
||||
FilePath m_defaultLocationForNewFiles;
|
||||
FilePath m_projectsDirectory;
|
||||
// When we are calling into an IDocument
|
||||
// we don't want to receive a changed()
|
||||
@@ -287,7 +287,7 @@ DocumentManager::DocumentManager(QObject *parent)
|
||||
readSettings();
|
||||
|
||||
if (d->m_useProjectsDirectory)
|
||||
setFileDialogLastVisitedDirectory(d->m_projectsDirectory.toString());
|
||||
setFileDialogLastVisitedDirectory(d->m_projectsDirectory);
|
||||
}
|
||||
|
||||
DocumentManager::~DocumentManager()
|
||||
@@ -796,17 +796,17 @@ QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter
|
||||
return filters.join(QLatin1String(";;"));
|
||||
}
|
||||
|
||||
QString DocumentManager::getSaveFileName(const QString &title, const QString &pathIn,
|
||||
const QString &filter, QString *selectedFilter)
|
||||
FilePath DocumentManager::getSaveFileName(const QString &title, const FilePath &pathIn,
|
||||
const QString &filter, QString *selectedFilter)
|
||||
{
|
||||
const FilePath path = FilePath::fromString(pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn);
|
||||
QString fileName;
|
||||
const FilePath path = pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn;
|
||||
FilePath filePath;
|
||||
bool repeat;
|
||||
do {
|
||||
repeat = false;
|
||||
fileName = FileUtils::getSaveFilePath(nullptr, title, path, filter, selectedFilter,
|
||||
QFileDialog::DontConfirmOverwrite).toString();
|
||||
if (!fileName.isEmpty()) {
|
||||
filePath = FileUtils::getSaveFilePath(nullptr, title, path, filter, selectedFilter,
|
||||
QFileDialog::DontConfirmOverwrite);
|
||||
if (!filePath.isEmpty()) {
|
||||
// If the selected filter is All Files (*) we leave the name exactly as the user
|
||||
// specified. Otherwise the suffix must be one available in the selected filter. If
|
||||
// the name already ends with such suffix nothing needs to be done. But if not, the
|
||||
@@ -822,31 +822,31 @@ QString DocumentManager::getSaveFileName(const QString &title, const QString &pa
|
||||
caption.remove(QLatin1Char('*'));
|
||||
const QStringList suffixes = caption.split(QLatin1Char(' '));
|
||||
for (const QString &suffix : suffixes)
|
||||
if (fileName.endsWith(suffix)) {
|
||||
if (filePath.endsWith(suffix)) {
|
||||
suffixOk = true;
|
||||
break;
|
||||
}
|
||||
if (!suffixOk && !suffixes.isEmpty())
|
||||
fileName.append(suffixes.at(0));
|
||||
filePath = filePath.stringAppended(suffixes.at(0));
|
||||
}
|
||||
}
|
||||
if (QFile::exists(fileName)) {
|
||||
if (filePath.exists()) {
|
||||
if (QMessageBox::warning(ICore::dialogParent(), tr("Overwrite?"),
|
||||
tr("An item named \"%1\" already exists at this location. "
|
||||
"Do you want to overwrite it?").arg(QDir::toNativeSeparators(fileName)),
|
||||
"Do you want to overwrite it?").arg(filePath.toUserOutput()),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
|
||||
repeat = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (repeat);
|
||||
if (!fileName.isEmpty())
|
||||
setFileDialogLastVisitedDirectory(QFileInfo(fileName).absolutePath());
|
||||
return fileName;
|
||||
if (!filePath.isEmpty())
|
||||
setFileDialogLastVisitedDirectory(filePath.absolutePath());
|
||||
return filePath;
|
||||
}
|
||||
|
||||
QString DocumentManager::getSaveFileNameWithExtension(const QString &title, const QString &pathIn,
|
||||
const QString &filter)
|
||||
FilePath DocumentManager::getSaveFileNameWithExtension(const QString &title, const FilePath &pathIn,
|
||||
const QString &filter)
|
||||
{
|
||||
QString selected = filter;
|
||||
return getSaveFileName(title, pathIn, filter, &selected);
|
||||
@@ -855,13 +855,13 @@ QString DocumentManager::getSaveFileNameWithExtension(const QString &title, cons
|
||||
/*!
|
||||
Asks the user for a new file name (\uicontrol {Save File As}) for \a document.
|
||||
*/
|
||||
QString DocumentManager::getSaveAsFileName(const IDocument *document)
|
||||
FilePath DocumentManager::getSaveAsFileName(const IDocument *document)
|
||||
{
|
||||
QTC_ASSERT(document, return QString());
|
||||
QTC_ASSERT(document, return {});
|
||||
const QString filter = allDocumentFactoryFiltersString();
|
||||
const QString filePath = document->filePath().toString();
|
||||
const FilePath filePath = document->filePath();
|
||||
QString selectedFilter;
|
||||
QString fileDialogPath = filePath;
|
||||
FilePath fileDialogPath = filePath;
|
||||
if (!filePath.isEmpty()) {
|
||||
selectedFilter = Utils::mimeTypeForFile(filePath).filterString();
|
||||
} else {
|
||||
@@ -871,11 +871,9 @@ QString DocumentManager::getSaveAsFileName(const IDocument *document)
|
||||
if (!types.isEmpty())
|
||||
selectedFilter = types.first().filterString();
|
||||
}
|
||||
const QString defaultPath = document->fallbackSaveAsPath();
|
||||
if (!defaultPath.isEmpty())
|
||||
fileDialogPath = defaultPath + (suggestedName.isEmpty()
|
||||
? QString()
|
||||
: '/' + suggestedName);
|
||||
const FilePath defaultPath = document->fallbackSaveAsPath();
|
||||
if (!defaultPath.isEmpty() && !suggestedName.isEmpty())
|
||||
fileDialogPath = defaultPath / suggestedName;
|
||||
}
|
||||
if (selectedFilter.isEmpty())
|
||||
selectedFilter = Utils::mimeTypeForName(document->mimeType()).filterString();
|
||||
@@ -1037,12 +1035,11 @@ FilePaths DocumentManager::getOpenFileNames(const QString &filters,
|
||||
const FilePath &pathIn,
|
||||
QString *selectedFilter)
|
||||
{
|
||||
const FilePath path = pathIn.isEmpty() ? FilePath::fromString(fileDialogInitialDirectory())
|
||||
: pathIn;
|
||||
const FilePath path = pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn;
|
||||
const FilePaths files = FileUtils::getOpenFilePaths(nullptr, tr("Open File"), path, filters,
|
||||
selectedFilter);
|
||||
if (!files.isEmpty())
|
||||
setFileDialogLastVisitedDirectory(files.front().absolutePath().toString());
|
||||
setFileDialogLastVisitedDirectory(files.front().absolutePath());
|
||||
return files;
|
||||
}
|
||||
|
||||
@@ -1086,7 +1083,7 @@ void DocumentManager::checkForReload()
|
||||
FileDeletedPromptAnswer previousDeletedAnswer = FileDeletedSave;
|
||||
|
||||
QList<IDocument *> documentsToClose;
|
||||
QHash<IDocument*, QString> documentsToSave;
|
||||
QHash<IDocument*, FilePath> documentsToSave;
|
||||
|
||||
// collect file information
|
||||
QMap<FilePath, FileStateItem> currentStates;
|
||||
@@ -1264,12 +1261,12 @@ void DocumentManager::checkForReload()
|
||||
}
|
||||
switch (previousDeletedAnswer) {
|
||||
case FileDeletedSave:
|
||||
documentsToSave.insert(document, document->filePath().toString());
|
||||
documentsToSave.insert(document, document->filePath());
|
||||
unhandled = false;
|
||||
break;
|
||||
case FileDeletedSaveAs:
|
||||
{
|
||||
const QString &saveFileName = getSaveAsFileName(document);
|
||||
const FilePath saveFileName = getSaveAsFileName(document);
|
||||
if (!saveFileName.isEmpty()) {
|
||||
documentsToSave.insert(document, saveFileName);
|
||||
unhandled = false;
|
||||
@@ -1307,7 +1304,7 @@ void DocumentManager::checkForReload()
|
||||
// handle deleted files
|
||||
EditorManager::closeDocuments(documentsToClose, false);
|
||||
for (auto it = documentsToSave.cbegin(), end = documentsToSave.cend(); it != end; ++it) {
|
||||
saveDocument(it.key(), Utils::FilePath::fromString(it.value()));
|
||||
saveDocument(it.key(), it.value());
|
||||
it.key()->checkPermissions();
|
||||
}
|
||||
|
||||
@@ -1323,7 +1320,7 @@ void DocumentManager::checkForReload()
|
||||
\a editorId defaults to the empty ID, which lets \QC figure out
|
||||
the best editor itself.
|
||||
*/
|
||||
void DocumentManager::addToRecentFiles(const Utils::FilePath &filePath, Id editorId)
|
||||
void DocumentManager::addToRecentFiles(const FilePath &filePath, Id editorId)
|
||||
{
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
@@ -1417,11 +1414,11 @@ void readSettings()
|
||||
\sa setFileDialogLastVisitedDirectory(), setDefaultLocationForNewFiles()
|
||||
*/
|
||||
|
||||
QString DocumentManager::fileDialogInitialDirectory()
|
||||
FilePath DocumentManager::fileDialogInitialDirectory()
|
||||
{
|
||||
IDocument *doc = EditorManager::currentDocument();
|
||||
if (doc && !doc->isTemporary() && !doc->filePath().isEmpty())
|
||||
return doc->filePath().absolutePath().path();
|
||||
return doc->filePath().absolutePath();
|
||||
if (!d->m_defaultLocationForNewFiles.isEmpty())
|
||||
return d->m_defaultLocationForNewFiles;
|
||||
return d->m_lastVisitedDirectory;
|
||||
@@ -1433,7 +1430,7 @@ QString DocumentManager::fileDialogInitialDirectory()
|
||||
|
||||
\sa fileDialogInitialDirectory()
|
||||
*/
|
||||
QString DocumentManager::defaultLocationForNewFiles()
|
||||
FilePath DocumentManager::defaultLocationForNewFiles()
|
||||
{
|
||||
return d->m_defaultLocationForNewFiles;
|
||||
}
|
||||
@@ -1441,7 +1438,7 @@ QString DocumentManager::defaultLocationForNewFiles()
|
||||
/*!
|
||||
Sets the default \a location for new files.
|
||||
*/
|
||||
void DocumentManager::setDefaultLocationForNewFiles(const QString &location)
|
||||
void DocumentManager::setDefaultLocationForNewFiles(const FilePath &location)
|
||||
{
|
||||
d->m_defaultLocationForNewFiles = location;
|
||||
}
|
||||
@@ -1507,7 +1504,7 @@ void DocumentManager::setUseProjectsDirectory(bool useProjectsDirectory)
|
||||
|
||||
*/
|
||||
|
||||
QString DocumentManager::fileDialogLastVisitedDirectory()
|
||||
FilePath DocumentManager::fileDialogLastVisitedDirectory()
|
||||
{
|
||||
return d->m_lastVisitedDirectory;
|
||||
}
|
||||
@@ -1521,12 +1518,12 @@ QString DocumentManager::fileDialogLastVisitedDirectory()
|
||||
|
||||
*/
|
||||
|
||||
void DocumentManager::setFileDialogLastVisitedDirectory(const QString &directory)
|
||||
void DocumentManager::setFileDialogLastVisitedDirectory(const FilePath &directory)
|
||||
{
|
||||
d->m_lastVisitedDirectory = directory;
|
||||
}
|
||||
|
||||
void DocumentManager::notifyFilesChangedInternally(const Utils::FilePaths &filePaths)
|
||||
void DocumentManager::notifyFilesChangedInternally(const FilePaths &filePaths)
|
||||
{
|
||||
emit m_instance->filesChangedInternally(filePaths);
|
||||
}
|
||||
|
@@ -87,13 +87,14 @@ public:
|
||||
static Utils::FilePaths getOpenFileNames(const QString &filters,
|
||||
const Utils::FilePath &path = {},
|
||||
QString *selectedFilter = nullptr);
|
||||
static QString getSaveFileName(const QString &title,
|
||||
const QString &pathIn,
|
||||
const QString &filter = QString(),
|
||||
QString *selectedFilter = nullptr);
|
||||
static QString getSaveFileNameWithExtension(const QString &title, const QString &pathIn,
|
||||
const QString &filter);
|
||||
static QString getSaveAsFileName(const IDocument *document);
|
||||
static Utils::FilePath getSaveFileName(const QString &title,
|
||||
const Utils::FilePath &pathIn,
|
||||
const QString &filter = {},
|
||||
QString *selectedFilter = nullptr);
|
||||
static Utils::FilePath getSaveFileNameWithExtension(const QString &title,
|
||||
const Utils::FilePath &pathIn,
|
||||
const QString &filter);
|
||||
static Utils::FilePath getSaveAsFileName(const IDocument *document);
|
||||
|
||||
static bool saveAllModifiedDocumentsSilently(bool *canceled = nullptr,
|
||||
QList<IDocument *> *failedToClose = nullptr);
|
||||
@@ -123,13 +124,13 @@ public:
|
||||
QList<IDocument *> *failedToClose = nullptr);
|
||||
static void showFilePropertiesDialog(const Utils::FilePath &filePath);
|
||||
|
||||
static QString fileDialogLastVisitedDirectory();
|
||||
static void setFileDialogLastVisitedDirectory(const QString &);
|
||||
static Utils::FilePath fileDialogLastVisitedDirectory();
|
||||
static void setFileDialogLastVisitedDirectory(const Utils::FilePath &);
|
||||
|
||||
static QString fileDialogInitialDirectory();
|
||||
static Utils::FilePath fileDialogInitialDirectory();
|
||||
|
||||
static QString defaultLocationForNewFiles();
|
||||
static void setDefaultLocationForNewFiles(const QString &location);
|
||||
static Utils::FilePath defaultLocationForNewFiles();
|
||||
static void setDefaultLocationForNewFiles(const Utils::FilePath &location);
|
||||
|
||||
static bool useProjectsDirectory();
|
||||
static void setUseProjectsDirectory(bool);
|
||||
|
@@ -2478,7 +2478,7 @@ bool EditorManagerPrivate::saveDocumentAs(IDocument *document)
|
||||
if (!document)
|
||||
return false;
|
||||
|
||||
const auto &absoluteFilePath = FilePath::fromString(DocumentManager::getSaveAsFileName(document));
|
||||
const FilePath absoluteFilePath = DocumentManager::getSaveAsFileName(document);
|
||||
|
||||
if (absoluteFilePath.isEmpty())
|
||||
return false;
|
||||
|
@@ -565,9 +565,9 @@ void IDocument::setTemporary(bool temporary)
|
||||
|
||||
\sa fallbackSaveAsFileName()
|
||||
*/
|
||||
QString IDocument::fallbackSaveAsPath() const
|
||||
FilePath IDocument::fallbackSaveAsPath() const
|
||||
{
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@@ -108,7 +108,7 @@ public:
|
||||
bool isTemporary() const;
|
||||
void setTemporary(bool temporary);
|
||||
|
||||
virtual QString fallbackSaveAsPath() const;
|
||||
virtual Utils::FilePath fallbackSaveAsPath() const;
|
||||
virtual QString fallbackSaveAsFileName() const;
|
||||
|
||||
QString mimeType() const;
|
||||
|
@@ -213,7 +213,7 @@ QList<IWizardFactory*> IWizardFactory::allWizardFactories()
|
||||
|
||||
connect(newFactory->m_action, &QAction::triggered, newFactory, [newFactory]() {
|
||||
if (!ICore::isNewItemDialogRunning()) {
|
||||
QString path = newFactory->runPath(QString());
|
||||
FilePath path = newFactory->runPath({});
|
||||
newFactory->runWizard(path, ICore::dialogParent(), Id(), QVariantMap());
|
||||
}
|
||||
});
|
||||
@@ -227,9 +227,9 @@ QList<IWizardFactory*> IWizardFactory::allWizardFactories()
|
||||
return s_allFactories;
|
||||
}
|
||||
|
||||
QString IWizardFactory::runPath(const QString &defaultPath) const
|
||||
FilePath IWizardFactory::runPath(const FilePath &defaultPath) const
|
||||
{
|
||||
QString path = defaultPath;
|
||||
FilePath path = defaultPath;
|
||||
if (path.isEmpty()) {
|
||||
switch (kind()) {
|
||||
case IWizardFactory::ProjectWizard:
|
||||
@@ -237,7 +237,7 @@ QString IWizardFactory::runPath(const QString &defaultPath) const
|
||||
// use last visited directory of file dialog. Never start
|
||||
// at current.
|
||||
path = DocumentManager::useProjectsDirectory()
|
||||
? DocumentManager::projectsDirectory().toString()
|
||||
? DocumentManager::projectsDirectory()
|
||||
: DocumentManager::fileDialogLastVisitedDirectory();
|
||||
break;
|
||||
default:
|
||||
@@ -257,9 +257,9 @@ QString IWizardFactory::runPath(const QString &defaultPath) const
|
||||
created. The wizard should fill this in its path selection elements as a
|
||||
default path.
|
||||
*/
|
||||
Utils::Wizard *IWizardFactory::runWizard(const QString &path, QWidget *parent, Id platform,
|
||||
const QVariantMap &variables,
|
||||
bool showWizard)
|
||||
Wizard *IWizardFactory::runWizard(const FilePath &path, QWidget *parent, Id platform,
|
||||
const QVariantMap &variables,
|
||||
bool showWizard)
|
||||
{
|
||||
QTC_ASSERT(!s_isWizardRunning, return nullptr);
|
||||
|
||||
|
@@ -90,10 +90,10 @@ public:
|
||||
void setFlags(WizardFlags flags) { m_flags = flags; }
|
||||
void setDetailsPageQmlPath(const QString &filePath);
|
||||
|
||||
QString runPath(const QString &defaultPath) const;
|
||||
Utils::FilePath runPath(const Utils::FilePath &defaultPath) const;
|
||||
|
||||
// Does bookkeeping and the calls runWizardImpl. Please implement that.
|
||||
Utils::Wizard *runWizard(const QString &path, QWidget *parent, Utils::Id platform,
|
||||
Utils::Wizard *runWizard(const Utils::FilePath &path, QWidget *parent, Utils::Id platform,
|
||||
const QVariantMap &variables, bool showWizard = true);
|
||||
|
||||
virtual bool isAvailable(Utils::Id platformId) const;
|
||||
@@ -121,8 +121,11 @@ protected:
|
||||
static QSet<Utils::Id> pluginFeatures();
|
||||
static QSet<Utils::Id> availableFeatures(Utils::Id platformId);
|
||||
|
||||
virtual Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, Utils::Id platform,
|
||||
const QVariantMap &variables, bool showWizard = true) = 0;
|
||||
virtual Utils::Wizard *runWizardImpl(const Utils::FilePath &path,
|
||||
QWidget *parent,
|
||||
Utils::Id platform,
|
||||
const QVariantMap &variables,
|
||||
bool showWizard = true) = 0;
|
||||
|
||||
private:
|
||||
static void initialize();
|
||||
|
@@ -78,7 +78,7 @@ FileSystemFilter::FileSystemFilter()
|
||||
void FileSystemFilter::prepareSearch(const QString &entry)
|
||||
{
|
||||
Q_UNUSED(entry)
|
||||
m_currentDocumentDirectory = DocumentManager::fileDialogInitialDirectory();
|
||||
m_currentDocumentDirectory = DocumentManager::fileDialogInitialDirectory().toString();
|
||||
m_currentIncludeHidden = m_includeHidden;
|
||||
}
|
||||
|
||||
|
@@ -253,11 +253,11 @@ bool DiffEditorDocument::setContents(const QByteArray &contents)
|
||||
return true;
|
||||
}
|
||||
|
||||
QString DiffEditorDocument::fallbackSaveAsPath() const
|
||||
FilePath DiffEditorDocument::fallbackSaveAsPath() const
|
||||
{
|
||||
if (!m_baseDirectory.isEmpty())
|
||||
return m_baseDirectory.toString();
|
||||
return QDir::homePath();
|
||||
return m_baseDirectory;
|
||||
return FileUtils::homePath();
|
||||
}
|
||||
|
||||
bool DiffEditorDocument::isSaveAsAllowed() const
|
||||
|
@@ -77,7 +77,7 @@ public:
|
||||
bool ignoreWhitespace() const;
|
||||
|
||||
bool setContents(const QByteArray &contents) override;
|
||||
QString fallbackSaveAsPath() const override;
|
||||
Utils::FilePath fallbackSaveAsPath() const override;
|
||||
QString fallbackSaveAsFileName() const override;
|
||||
|
||||
bool isSaveAsAllowed() const override;
|
||||
|
@@ -176,7 +176,7 @@ void ProjectExplorer::ProjectExplorerPlugin::testJsonWizardsCheckBox()
|
||||
const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), QDir(), &errorMessage));
|
||||
QVERIFY2(factory, qPrintable(errorMessage));
|
||||
|
||||
Wizard *wizard = factory->runWizard(QString(), &parent, Id(), QVariantMap());
|
||||
Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap());
|
||||
|
||||
QVERIFY(!findCheckBox(wizard, "Default")->isChecked());
|
||||
QCOMPARE(wizard->field("DefaultCheckBox"), QVariant(false));
|
||||
@@ -208,7 +208,7 @@ void ProjectExplorer::ProjectExplorerPlugin::testJsonWizardsLineEdit()
|
||||
const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), QDir(), &errorMessage));
|
||||
QVERIFY2(factory, qPrintable(errorMessage));
|
||||
|
||||
Wizard *wizard = factory->runWizard(QString(), &parent, Id(), QVariantMap());
|
||||
Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap());
|
||||
QVERIFY(findLineEdit(wizard, "Default"));
|
||||
QVERIFY(findLineEdit(wizard, "Default")->text().isEmpty());
|
||||
QCOMPARE(qPrintable(findLineEdit(wizard, "WithText")->text()), "some text");
|
||||
@@ -236,7 +236,7 @@ void ProjectExplorer::ProjectExplorerPlugin::testJsonWizardsComboBox()
|
||||
const QJsonObject wizardObject = createGeneralWizard(pages);
|
||||
const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), QDir(), &errorMessage));
|
||||
QVERIFY2(factory, qPrintable(errorMessage));
|
||||
Utils::Wizard *wizard = factory->runWizard(QString(), &parent, Id(), QVariantMap());
|
||||
Utils::Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap());
|
||||
|
||||
QComboBox *defaultComboBox = findComboBox(wizard, "Default");
|
||||
QVERIFY(defaultComboBox);
|
||||
@@ -294,7 +294,7 @@ void ProjectExplorer::ProjectExplorerPlugin::testJsonWizardsIconList()
|
||||
const QJsonObject wizardObject = createGeneralWizard(pages);
|
||||
const FactoryPtr factory(JsonWizardFactory::createWizardFactory(wizardObject.toVariantMap(), QDir(), &errorMessage));
|
||||
QVERIFY2(factory, qPrintable(errorMessage));
|
||||
Wizard *wizard = factory->runWizard(QString(), &parent, Id(), QVariantMap());
|
||||
Wizard *wizard = factory->runWizard({}, &parent, Id(), QVariantMap());
|
||||
|
||||
auto view = wizard->findChild<QListView *>("FancyIconList");
|
||||
QCOMPARE(view->model()->rowCount(), 2);
|
||||
|
@@ -54,6 +54,8 @@
|
||||
#include <QMap>
|
||||
#include <QUuid>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
static QList<JsonWizardPageFactory *> s_pageFactories;
|
||||
@@ -371,7 +373,7 @@ void JsonWizardFactory::registerGeneratorFactory(JsonWizardGeneratorFactory *fac
|
||||
s_generatorFactories.append(factory);
|
||||
}
|
||||
|
||||
Utils::Wizard *JsonWizardFactory::runWizardImpl(const QString &path, QWidget *parent,
|
||||
Utils::Wizard *JsonWizardFactory::runWizardImpl(const FilePath &path, QWidget *parent,
|
||||
Utils::Id platform,
|
||||
const QVariantMap &variables, bool showWizard)
|
||||
{
|
||||
@@ -394,7 +396,7 @@ Utils::Wizard *JsonWizardFactory::runWizardImpl(const QString &path, QWidget *pa
|
||||
for (auto i = variables.constBegin(); i != variables.constEnd(); ++i)
|
||||
wizard->setValue(i.key(), i.value());
|
||||
|
||||
wizard->setValue(QStringLiteral("InitialPath"), path);
|
||||
wizard->setValue(QStringLiteral("InitialPath"), path.toString());
|
||||
wizard->setValue(QStringLiteral("Platform"), platform.toString());
|
||||
|
||||
QString kindStr = QLatin1String(Core::Constants::WIZARD_KIND_UNKNOWN);
|
||||
@@ -452,7 +454,7 @@ Utils::Wizard *JsonWizardFactory::runWizardImpl(const QString &path, QWidget *pa
|
||||
return f->canCreate(data.typeId);
|
||||
});
|
||||
QTC_ASSERT(factory, continue);
|
||||
JsonWizardGenerator *gen = factory->create(data.typeId, data.data, path, platform, variables);
|
||||
JsonWizardGenerator *gen = factory->create(data.typeId, data.data, path.toString(), platform, variables);
|
||||
QTC_ASSERT(gen, continue);
|
||||
|
||||
wizard->addGenerator(gen);
|
||||
@@ -603,9 +605,9 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir,
|
||||
setDescriptionImage(strVal);
|
||||
}
|
||||
|
||||
strVal = baseDir.absoluteFilePath("detailsPage.qml");
|
||||
if (QFileInfo::exists(strVal))
|
||||
setDetailsPageQmlPath(strVal);
|
||||
const FilePath detailsPage = baseDir.resolvePath(QString("detailsPage.qml"));
|
||||
if (detailsPage.exists())
|
||||
setDetailsPageQmlPath(detailsPage.toString());
|
||||
|
||||
setRequiredFeatures(Utils::Id::fromStringList(data.value(QLatin1String(REQUIRED_FEATURES_KEY)).toStringList()));
|
||||
m_preferredFeatures = Utils::Id::fromStringList(data.value(QLatin1String(SUGGESTED_FEATURES_KEY)).toStringList());
|
||||
|
@@ -88,7 +88,7 @@ public:
|
||||
bool isAvailable(Utils::Id platformId) const override;
|
||||
|
||||
private:
|
||||
Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, Utils::Id platform,
|
||||
Utils::Wizard *runWizardImpl(const Utils::FilePath &path, QWidget *parent, Utils::Id platform,
|
||||
const QVariantMap &variables, bool showWizard = true) override;
|
||||
|
||||
// Create all wizards. As other plugins might register factories for derived
|
||||
|
@@ -240,12 +240,12 @@ void ProjectTree::setCurrent(Node *node, Project *project)
|
||||
void ProjectTree::sessionChanged()
|
||||
{
|
||||
if (m_currentProject) {
|
||||
Core::DocumentManager::setDefaultLocationForNewFiles(m_currentProject->projectDirectory().toString());
|
||||
Core::DocumentManager::setDefaultLocationForNewFiles(m_currentProject->projectDirectory());
|
||||
} else if (Project *project = SessionManager::startupProject()) {
|
||||
Core::DocumentManager::setDefaultLocationForNewFiles(project->projectDirectory().toString());
|
||||
Core::DocumentManager::setDefaultLocationForNewFiles(project->projectDirectory());
|
||||
updateFromNode(nullptr); // Make startup project current if there is no other current
|
||||
} else {
|
||||
Core::DocumentManager::setDefaultLocationForNewFiles(QString());
|
||||
Core::DocumentManager::setDefaultLocationForNewFiles({});
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
@@ -213,18 +213,18 @@ void GenerateResource::generateMenuEntry()
|
||||
QObject::connect(action, &QAction::triggered, [] () {
|
||||
auto currentProject = ProjectExplorer::SessionManager::startupProject();
|
||||
QTC_ASSERT(currentProject, return);
|
||||
auto projectPath = currentProject->projectFilePath().parentDir().toString();
|
||||
const FilePath projectPath = currentProject->projectFilePath().parentDir();
|
||||
|
||||
auto projectFileName = Core::DocumentManager::getSaveFileName(
|
||||
QCoreApplication::translate("QmlDesigner::GenerateResource", "Save Project as QRC File"),
|
||||
projectPath + "/" + currentProject->displayName() + ".qrc",
|
||||
projectPath.pathAppended(currentProject->displayName() + ".qrc"),
|
||||
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||
"QML Resource File (*.qrc)"));
|
||||
if (projectFileName.isEmpty())
|
||||
return;
|
||||
|
||||
QTemporaryFile temp(projectPath + "/XXXXXXX.create.resource.qrc");
|
||||
QFile persistentFile(projectFileName);
|
||||
QTemporaryFile temp(projectPath.toString() + "/XXXXXXX.create.resource.qrc");
|
||||
QFile persistentFile(projectFileName.toString());
|
||||
|
||||
if (!temp.open())
|
||||
return;
|
||||
@@ -289,7 +289,7 @@ void GenerateResource::generateMenuEntry()
|
||||
QByteArray firstLine = temp.readLine();
|
||||
QList<ResourceFile> fileList = getFilesFromQrc(&temp);
|
||||
|
||||
QFile existingQrcFile(projectFileName);
|
||||
QFile existingQrcFile(projectFileName.toString());
|
||||
if (existingQrcFile.exists()) {
|
||||
existingQrcFile.open(QFile::ReadOnly);
|
||||
fileList = getFilesFromQrc(&existingQrcFile, true);
|
||||
@@ -297,7 +297,7 @@ void GenerateResource::generateMenuEntry()
|
||||
}
|
||||
|
||||
QDir dir;
|
||||
dir.setCurrent(projectPath);
|
||||
dir.setCurrent(projectPath.toString());
|
||||
|
||||
Utils::FilePaths paths = currentProject->files(ProjectExplorer::Project::AllFiles);
|
||||
QStringList projectFiles = {};
|
||||
@@ -363,11 +363,11 @@ void GenerateResource::generateMenuEntry()
|
||||
QObject::connect(rccAction, &QAction::triggered, [] () {
|
||||
auto currentProject = ProjectExplorer::SessionManager::startupProject();
|
||||
QTC_ASSERT(currentProject, return);
|
||||
auto projectPath = currentProject->projectFilePath().parentDir().toString();
|
||||
const FilePath projectPath = currentProject->projectFilePath().parentDir();
|
||||
|
||||
auto resourceFileName = Core::DocumentManager::getSaveFileName(
|
||||
const FilePath resourceFileName = Core::DocumentManager::getSaveFileName(
|
||||
QCoreApplication::translate("QmlDesigner::GenerateResource", "Save Project as Resource"),
|
||||
projectPath + "/" + currentProject->displayName() + ".qmlrc",
|
||||
projectPath.pathAppended(currentProject->displayName() + ".qmlrc"),
|
||||
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||
"QML Resource File (*.qmlrc);;Resource File (*.rcc)"));
|
||||
if (resourceFileName.isEmpty())
|
||||
@@ -376,12 +376,12 @@ void GenerateResource::generateMenuEntry()
|
||||
Core::MessageManager::writeSilently(
|
||||
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||
"Generate a resource file out of project %1 to %2")
|
||||
.arg(currentProject->displayName(), QDir::toNativeSeparators(resourceFileName)));
|
||||
.arg(currentProject->displayName(), resourceFileName.toUserOutput()));
|
||||
|
||||
QString projectFileName = currentProject->displayName() + ".qrc";
|
||||
QFile persistentFile(projectPath + "/" + projectFileName);
|
||||
QFile persistentFile(projectPath.toString() + "/" + projectFileName);
|
||||
|
||||
QTemporaryFile temp(projectPath + "/XXXXXXX.create.resource.qrc");
|
||||
QTemporaryFile temp(projectPath.toString() + "/XXXXXXX.create.resource.qrc");
|
||||
|
||||
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(
|
||||
currentProject->activeTarget()->kit());
|
||||
@@ -407,7 +407,7 @@ void GenerateResource::generateMenuEntry()
|
||||
Core::MessageManager::writeDisrupting(
|
||||
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||
"Unable to generate resource file: %1")
|
||||
.arg(resourceFileName));
|
||||
.arg(resourceFileName.toUserOutput()));
|
||||
return;
|
||||
}
|
||||
QByteArray stdOut;
|
||||
@@ -477,7 +477,7 @@ void GenerateResource::generateMenuEntry()
|
||||
}
|
||||
|
||||
QDir dir;
|
||||
dir.setCurrent(projectPath);
|
||||
dir.setCurrent(projectPath.toString());
|
||||
|
||||
Utils::FilePaths paths = currentProject->files(ProjectExplorer::Project::AllFiles);
|
||||
QStringList projectFiles = {};
|
||||
@@ -508,7 +508,7 @@ void GenerateResource::generateMenuEntry()
|
||||
temp.close();
|
||||
persistentFile.close();
|
||||
QStringList modifiedList = getFileList(fileList);
|
||||
QTemporaryFile tempFile(projectPath + "/XXXXXXX.create.modifiedresource.qrc");
|
||||
QTemporaryFile tempFile(projectPath.toString() + "/XXXXXXX.create.modifiedresource.qrc");
|
||||
|
||||
if (!tempFile.open())
|
||||
return;
|
||||
@@ -527,7 +527,7 @@ void GenerateResource::generateMenuEntry()
|
||||
tempFile.write("\n</RCC>\n");
|
||||
tempFile.close();
|
||||
|
||||
const QStringList arguments2 = {"--binary", "--output", resourceFileName,
|
||||
const QStringList arguments2 = {"--binary", "--output", resourceFileName.path(),
|
||||
tempFile.fileName()};
|
||||
|
||||
for (const auto &arguments : {arguments2}) {
|
||||
@@ -537,7 +537,7 @@ void GenerateResource::generateMenuEntry()
|
||||
Core::MessageManager::writeDisrupting(
|
||||
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||
"Unable to generate resource file: %1")
|
||||
.arg(resourceFileName));
|
||||
.arg(resourceFileName.toUserOutput()));
|
||||
return;
|
||||
}
|
||||
QByteArray stdOut;
|
||||
|
@@ -89,7 +89,7 @@ public:
|
||||
void updateRevisions();
|
||||
|
||||
public:
|
||||
QString m_defaultPath;
|
||||
FilePath m_defaultPath;
|
||||
QString m_suggestedFileName;
|
||||
TypingSettings m_typingSettings;
|
||||
StorageSettings m_storageSettings;
|
||||
@@ -571,7 +571,7 @@ bool TextDocument::isSaveAsAllowed() const
|
||||
return true;
|
||||
}
|
||||
|
||||
QString TextDocument::fallbackSaveAsPath() const
|
||||
FilePath TextDocument::fallbackSaveAsPath() const
|
||||
{
|
||||
return d->m_defaultPath;
|
||||
}
|
||||
@@ -581,7 +581,7 @@ QString TextDocument::fallbackSaveAsFileName() const
|
||||
return d->m_suggestedFileName;
|
||||
}
|
||||
|
||||
void TextDocument::setFallbackSaveAsPath(const QString &defaultPath)
|
||||
void TextDocument::setFallbackSaveAsPath(const FilePath &defaultPath)
|
||||
{
|
||||
d->m_defaultPath = defaultPath;
|
||||
}
|
||||
|
@@ -122,10 +122,10 @@ public:
|
||||
void setFilePath(const Utils::FilePath &newName) override;
|
||||
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
|
||||
|
||||
QString fallbackSaveAsPath() const override;
|
||||
Utils::FilePath fallbackSaveAsPath() const override;
|
||||
QString fallbackSaveAsFileName() const override;
|
||||
|
||||
void setFallbackSaveAsPath(const QString &fallbackSaveAsPath);
|
||||
void setFallbackSaveAsPath(const Utils::FilePath &fallbackSaveAsPath);
|
||||
void setFallbackSaveAsFileName(const QString &fallbackSaveAsFileName);
|
||||
|
||||
OpenResult open(QString *errorString, const Utils::FilePath &filePath,
|
||||
|
Reference in New Issue
Block a user