Debugger: Use FilePath in CdbSymbolPathsListEditor

Change-Id: I8935284cf3712903660f61cd06083d4da6f1c7c2
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-09-30 17:45:40 +02:00
parent bdb7aed82e
commit cc8d65aa25
4 changed files with 29 additions and 21 deletions

View File

@@ -35,7 +35,6 @@
#include "symbolpathsdialog.h" #include "symbolpathsdialog.h"
#include <QCheckBox> #include <QCheckBox>
#include <QDir>
#include <QDebug> #include <QDebug>
#include <QAction> #include <QAction>
#include <QFormLayout> #include <QFormLayout>
@@ -165,7 +164,7 @@ void CdbSymbolPathListEditor::addSymbolPath(CdbSymbolPathListEditor::SymbolPathM
{ {
FilePath cacheDir; FilePath cacheDir;
if (promptCacheDirectory(this, &cacheDir)) if (promptCacheDirectory(this, &cacheDir))
insertPathAtCursor(CdbSymbolPathListEditor::symbolPath(cacheDir.path(), mode)); insertPathAtCursor(CdbSymbolPathListEditor::symbolPath(cacheDir, mode));
} }
void CdbSymbolPathListEditor::setupSymbolPaths() void CdbSymbolPathListEditor::setupSymbolPaths()
@@ -174,13 +173,13 @@ void CdbSymbolPathListEditor::setupSymbolPaths()
const int indexOfSymbolServer = indexOfSymbolPath(currentPaths, SymbolServerPath); const int indexOfSymbolServer = indexOfSymbolPath(currentPaths, SymbolServerPath);
const int indexOfSymbolCache = indexOfSymbolPath(currentPaths, SymbolCachePath); const int indexOfSymbolCache = indexOfSymbolPath(currentPaths, SymbolCachePath);
QString path; FilePath path;
if (indexOfSymbolServer != -1) if (indexOfSymbolServer != -1)
path = currentPaths.at(indexOfSymbolServer); path = FilePath::fromString(currentPaths.at(indexOfSymbolServer));
if (path.isEmpty() && indexOfSymbolCache != -1) if (path.isEmpty() && indexOfSymbolCache != -1)
path = currentPaths.at(indexOfSymbolCache); path = FilePath::fromString(currentPaths.at(indexOfSymbolCache));
if (path.isEmpty()) if (path.isEmpty())
path = TemporaryDirectory::masterDirectoryPath() + "/symbolcache"; path = FilePath::fromString(TemporaryDirectory::masterDirectoryPath() + "/symbolcache");
bool useSymbolServer = true; bool useSymbolServer = true;
bool useSymbolCache = true; bool useSymbolCache = true;
@@ -193,20 +192,20 @@ void CdbSymbolPathListEditor::setupSymbolPaths()
if (useSymbolCache) { if (useSymbolCache) {
insertPathAtCursor(CdbSymbolPathListEditor::symbolPath(path, SymbolCachePath)); insertPathAtCursor(CdbSymbolPathListEditor::symbolPath(path, SymbolCachePath));
if (useSymbolServer) if (useSymbolServer)
insertPathAtCursor(CdbSymbolPathListEditor::symbolPath(QString(), SymbolServerPath)); insertPathAtCursor(CdbSymbolPathListEditor::symbolPath({}, SymbolServerPath));
} else if (useSymbolServer) { } else if (useSymbolServer) {
insertPathAtCursor(CdbSymbolPathListEditor::symbolPath(path, SymbolServerPath)); insertPathAtCursor(CdbSymbolPathListEditor::symbolPath(path, SymbolServerPath));
} }
} }
QString CdbSymbolPathListEditor::symbolPath(const QString &cacheDir, QString CdbSymbolPathListEditor::symbolPath(const FilePath &cacheDir,
CdbSymbolPathListEditor::SymbolPathMode mode) CdbSymbolPathListEditor::SymbolPathMode mode)
{ {
if (mode == SymbolCachePath) if (mode == SymbolCachePath)
return symbolCachePrefixC + QDir::toNativeSeparators(cacheDir); return symbolCachePrefixC + cacheDir.toUserOutput();
QString s = QLatin1String(symbolServerPrefixC); QString s = QLatin1String(symbolServerPrefixC);
if (!cacheDir.isEmpty()) if (!cacheDir.isEmpty())
s += QDir::toNativeSeparators(cacheDir) + '*'; s += cacheDir.toUserOutput() + '*';
s += QLatin1String(symbolServerPostfixC); s += QLatin1String(symbolServerPostfixC);
return s; return s;
} }

View File

@@ -53,7 +53,7 @@ public:
static bool promptCacheDirectory(QWidget *parent, Utils::FilePath *cacheDirectory); static bool promptCacheDirectory(QWidget *parent, Utils::FilePath *cacheDirectory);
// Format a symbol path specification // Format a symbol path specification
static QString symbolPath(const QString &cacheDir, SymbolPathMode mode); static QString symbolPath(const Utils::FilePath &cacheDir, SymbolPathMode mode);
// Check for a symbol server path and extract local cache directory // Check for a symbol server path and extract local cache directory
static bool isSymbolServerPath(const QString &path, QString *cacheDir = nullptr); static bool isSymbolServerPath(const QString &path, QString *cacheDir = nullptr);
// Check for a symbol cache path and extract local cache directory // Check for a symbol cache path and extract local cache directory

View File

@@ -26,10 +26,14 @@
#include "symbolpathsdialog.h" #include "symbolpathsdialog.h"
#include "ui_symbolpathsdialog.h" #include "ui_symbolpathsdialog.h"
#include <utils/filepath.h>
#include <QMessageBox> #include <QMessageBox>
using namespace Debugger; using namespace Utils;
using namespace Internal;
namespace Debugger {
namespace Internal {
SymbolPathsDialog::SymbolPathsDialog(QWidget *parent) : SymbolPathsDialog::SymbolPathsDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
@@ -54,9 +58,9 @@ bool SymbolPathsDialog::useSymbolServer() const
return ui->useSymbolServer->isChecked(); return ui->useSymbolServer->isChecked();
} }
QString SymbolPathsDialog::path() const FilePath SymbolPathsDialog::path() const
{ {
return ui->pathChooser->filePath().toString(); return ui->pathChooser->filePath();
} }
void SymbolPathsDialog::setUseSymbolCache(bool useSymbolCache) void SymbolPathsDialog::setUseSymbolCache(bool useSymbolCache)
@@ -69,13 +73,13 @@ void SymbolPathsDialog::setUseSymbolServer(bool useSymbolServer)
ui->useSymbolServer->setChecked(useSymbolServer); ui->useSymbolServer->setChecked(useSymbolServer);
} }
void SymbolPathsDialog::setPath(const QString &path) void SymbolPathsDialog::setPath(const FilePath &path)
{ {
ui->pathChooser->setPath(path); ui->pathChooser->setFilePath(path);
} }
bool SymbolPathsDialog::useCommonSymbolPaths(bool &useSymbolCache, bool &useSymbolServer, bool SymbolPathsDialog::useCommonSymbolPaths(bool &useSymbolCache, bool &useSymbolServer,
QString &path) FilePath &path)
{ {
SymbolPathsDialog dialog; SymbolPathsDialog dialog;
dialog.setUseSymbolCache(useSymbolCache); dialog.setUseSymbolCache(useSymbolCache);
@@ -87,3 +91,6 @@ bool SymbolPathsDialog::useCommonSymbolPaths(bool &useSymbolCache, bool &useSymb
path = dialog.path(); path = dialog.path();
return ret == QDialog::Accepted; return ret == QDialog::Accepted;
} }
} // Internal
} // Debugger

View File

@@ -28,6 +28,8 @@
#include <QDialog> #include <QDialog>
#include <QString> #include <QString>
namespace Utils { class FilePath; }
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
@@ -43,15 +45,15 @@ public:
bool useSymbolCache() const; bool useSymbolCache() const;
bool useSymbolServer() const; bool useSymbolServer() const;
QString path() const; Utils::FilePath path() const;
bool doNotAskAgain() const; bool doNotAskAgain() const;
void setUseSymbolCache(bool useSymbolCache); void setUseSymbolCache(bool useSymbolCache);
void setUseSymbolServer(bool useSymbolServer); void setUseSymbolServer(bool useSymbolServer);
void setPath(const QString &path); void setPath(const Utils::FilePath &path);
void setDoNotAskAgain(bool doNotAskAgain) const; void setDoNotAskAgain(bool doNotAskAgain) const;
static bool useCommonSymbolPaths(bool &useSymbolCache, bool &useSymbolServer, QString &path); static bool useCommonSymbolPaths(bool &useSymbolCache, bool &useSymbolServer, Utils::FilePath &path);
private: private:
Ui::SymbolPathsDialog *ui; Ui::SymbolPathsDialog *ui;