forked from qt-creator/qt-creator
Utils: Add convenience function for generating a unique Id
Change-Id: I74516ef5077009ebcf1d47c724ca63e502729ede Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QReadWriteLock>
|
#include <QReadWriteLock>
|
||||||
|
#include <QUuid>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
@@ -132,6 +133,11 @@ Id::Id(const char *name)
|
|||||||
: m_id(theId(name, 0))
|
: m_id(theId(name, 0))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
Id Id::generate()
|
||||||
|
{
|
||||||
|
return {QUuid::createUuid().toByteArray()};
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns an internal representation of the id.
|
Returns an internal representation of the id.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ public:
|
|||||||
Id(const char *name); // Good to use.
|
Id(const char *name); // Good to use.
|
||||||
Id(const QLatin1String &) = delete;
|
Id(const QLatin1String &) = delete;
|
||||||
|
|
||||||
|
static Id generate();
|
||||||
|
|
||||||
Id withSuffix(int suffix) const;
|
Id withSuffix(int suffix) const;
|
||||||
Id withSuffix(const char *suffix) const;
|
Id withSuffix(const char *suffix) const;
|
||||||
Id withSuffix(const QString &suffix) const;
|
Id withSuffix(const QString &suffix) const;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QUuid>
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
@@ -261,7 +260,7 @@ AxivionServer DashboardSettingsWidget::dashboardServer() const
|
|||||||
if (m_id.isValid())
|
if (m_id.isValid())
|
||||||
result.id = m_id;
|
result.id = m_id;
|
||||||
else
|
else
|
||||||
result.id = Id::fromName(QUuid::createUuid().toByteArray());
|
result.id = Id::generate();
|
||||||
result.dashboard = fixUrl(m_dashboardUrl());
|
result.dashboard = fixUrl(m_dashboardUrl());
|
||||||
result.username = m_username();
|
result.username = m_username();
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
using namespace CppEditor;
|
using namespace CppEditor;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -1295,7 +1294,7 @@ void disableChecks(const QList<Diagnostic> &diagnostics)
|
|||||||
QTC_ASSERT(configs.isEmpty(), return);
|
QTC_ASSERT(configs.isEmpty(), return);
|
||||||
config = builtinConfig();
|
config = builtinConfig();
|
||||||
config.setIsReadOnly(false);
|
config.setIsReadOnly(false);
|
||||||
config.setId(Utils::Id::fromString(QUuid::createUuid().toString()));
|
config.setId(Id::generate());
|
||||||
config.setDisplayName(Tr::tr("Custom Configuration"));
|
config.setDisplayName(Tr::tr("Custom Configuration"));
|
||||||
configs << config;
|
configs << config;
|
||||||
RunSettings runSettings = settings->runSettings();
|
RunSettings runSettings = settings->runSettings();
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -95,7 +94,7 @@ public:
|
|||||||
const FilePath &qchFile,
|
const FilePath &qchFile,
|
||||||
bool autoRun,
|
bool autoRun,
|
||||||
bool autodetected)
|
bool autodetected)
|
||||||
: m_id(Id::fromString(QUuid::createUuid().toString()))
|
: m_id(Id::generate())
|
||||||
, m_name(name)
|
, m_name(name)
|
||||||
, m_executable(executable)
|
, m_executable(executable)
|
||||||
, m_qchFile(qchFile)
|
, m_qchFile(qchFile)
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -104,7 +103,7 @@ CMakeTool::CMakeTool(Detection d, const Id &id)
|
|||||||
, m_isAutoDetected(d == AutoDetection)
|
, m_isAutoDetected(d == AutoDetection)
|
||||||
, m_introspection(std::make_unique<Internal::IntrospectionData>())
|
, m_introspection(std::make_unique<Internal::IntrospectionData>())
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_id.isValid(), m_id = Id::fromString(QUuid::createUuid().toString()));
|
QTC_ASSERT(m_id.isValid(), m_id = Id::generate());
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeTool::CMakeTool(const Store &map, bool fromSdk) :
|
CMakeTool::CMakeTool(const Store &map, bool fromSdk) :
|
||||||
@@ -133,7 +132,7 @@ CMakeTool::~CMakeTool() = default;
|
|||||||
|
|
||||||
Id CMakeTool::createId()
|
Id CMakeTool::createId()
|
||||||
{
|
{
|
||||||
return Id::fromString(QUuid::createUuid().toString());
|
return Id::generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeTool::setFilePath(const FilePath &executable)
|
void CMakeTool::setFilePath(const FilePath &executable)
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
|
|
||||||
@@ -70,7 +69,7 @@ ClangDiagnosticConfig ClangDiagnosticConfigsModel::createCustomConfig(
|
|||||||
const ClangDiagnosticConfig &baseConfig, const QString &displayName)
|
const ClangDiagnosticConfig &baseConfig, const QString &displayName)
|
||||||
{
|
{
|
||||||
ClangDiagnosticConfig copied = baseConfig;
|
ClangDiagnosticConfig copied = baseConfig;
|
||||||
copied.setId(Utils::Id::fromString(QUuid::createUuid().toString()));
|
copied.setId(Utils::Id::generate());
|
||||||
copied.setDisplayName(displayName);
|
copied.setDisplayName(displayName);
|
||||||
copied.setIsReadOnly(false);
|
copied.setIsReadOnly(false);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -110,7 +109,7 @@ GitLabServerWidget::GitLabServerWidget(Mode m, QWidget *parent)
|
|||||||
GitLabServer GitLabServerWidget::gitLabServer() const
|
GitLabServer GitLabServerWidget::gitLabServer() const
|
||||||
{
|
{
|
||||||
GitLabServer result;
|
GitLabServer result;
|
||||||
result.id = m_mode == Edit ? Id::fromName(QUuid::createUuid().toByteArray()) : m_id;
|
result.id = m_mode == Edit ? Id::generate() : m_id;
|
||||||
result.host = m_host();
|
result.host = m_host();
|
||||||
result.description = m_description();
|
result.description = m_description();
|
||||||
result.token = m_token();
|
result.token = m_token();
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class ClientPrivate : public QObject
|
|||||||
public:
|
public:
|
||||||
ClientPrivate(Client *client, BaseClientInterface *clientInterface, const Utils::Id &id)
|
ClientPrivate(Client *client, BaseClientInterface *clientInterface, const Utils::Id &id)
|
||||||
: q(client)
|
: q(client)
|
||||||
, m_id(id.isValid() ? id : Utils::Id::fromString(QUuid::createUuid().toString()))
|
, m_id(id.isValid() ? id : Id::generate())
|
||||||
, m_clientCapabilities(q->defaultClientCapabilities())
|
, m_clientCapabilities(q->defaultClientCapabilities())
|
||||||
, m_clientInterface(new InterfaceController(clientInterface))
|
, m_clientInterface(new InterfaceController(clientInterface))
|
||||||
, m_documentSymbolCache(q)
|
, m_documentSymbolCache(q)
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
template<typename First>
|
template<typename First>
|
||||||
void impl_option_cat(QStringList &list, const First &first)
|
void impl_option_cat(QStringList &list, const First &first)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
namespace MesonProjectManager {
|
namespace MesonProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -16,7 +15,7 @@ namespace Internal {
|
|||||||
ToolTreeItem::ToolTreeItem(const QString &name)
|
ToolTreeItem::ToolTreeItem(const QString &name)
|
||||||
: m_name{name}
|
: m_name{name}
|
||||||
, m_autoDetected{false}
|
, m_autoDetected{false}
|
||||||
, m_id(Utils::Id::fromString(QUuid::createUuid().toString()))
|
, m_id(Utils::Id::generate())
|
||||||
, m_unsavedChanges{true}
|
, m_unsavedChanges{true}
|
||||||
{
|
{
|
||||||
self_check();
|
self_check();
|
||||||
@@ -37,7 +36,7 @@ ToolTreeItem::ToolTreeItem(const ToolTreeItem &other)
|
|||||||
: m_name{Tr::tr("Clone of %1").arg(other.m_name)}
|
: m_name{Tr::tr("Clone of %1").arg(other.m_name)}
|
||||||
, m_executable{other.m_executable}
|
, m_executable{other.m_executable}
|
||||||
, m_autoDetected{false}
|
, m_autoDetected{false}
|
||||||
, m_id{Utils::Id::fromString(QUuid::createUuid().toString())}
|
, m_id{Utils::Id::generate()}
|
||||||
, m_unsavedChanges{true}
|
, m_unsavedChanges{true}
|
||||||
{
|
{
|
||||||
self_check();
|
self_check();
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
namespace MesonProjectManager {
|
namespace MesonProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -14,7 +12,7 @@ ToolWrapper::ToolWrapper(const QString &name, const Utils::FilePath &path, bool
|
|||||||
: m_version(read_version(path))
|
: m_version(read_version(path))
|
||||||
, m_isValid{path.exists() && m_version.isValid}
|
, m_isValid{path.exists() && m_version.isValid}
|
||||||
, m_autoDetected{autoDetected}
|
, m_autoDetected{autoDetected}
|
||||||
, m_id{Utils::Id::fromString(QUuid::createUuid().toString())}
|
, m_id{Utils::Id::generate()}
|
||||||
, m_exe{path}
|
, m_exe{path}
|
||||||
, m_name{name}
|
, m_name{name}
|
||||||
{}
|
{}
|
||||||
@@ -30,7 +28,7 @@ ToolWrapper::ToolWrapper(const QString &name,
|
|||||||
, m_exe{path}
|
, m_exe{path}
|
||||||
, m_name{name}
|
, m_name{name}
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_id.isValid(), m_id = Utils::Id::fromString(QUuid::createUuid().toString()));
|
QTC_ASSERT(m_id.isValid(), m_id = Utils::Id::generate());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolWrapper::setExe(const Utils::FilePath &newExe)
|
void ToolWrapper::setExe(const Utils::FilePath &newExe)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QUuid>
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -55,7 +54,7 @@ public:
|
|||||||
if (dlg.exec() != QDialog::Accepted)
|
if (dlg.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
CustomParserSettings newParser = dlg.settings();
|
CustomParserSettings newParser = dlg.settings();
|
||||||
newParser.id = Utils::Id::fromString(QUuid::createUuid().toString());
|
newParser.id = Utils::Id::generate();
|
||||||
newParser.displayName = Tr::tr("New Parser");
|
newParser.displayName = Tr::tr("New Parser");
|
||||||
m_customParsers << newParser;
|
m_customParsers << newParser;
|
||||||
resetListView();
|
resetListView();
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
|||||||
@@ -530,7 +530,6 @@ IDevice::ConstPtr DeviceManager::defaultDevice(Id deviceType) const
|
|||||||
#include <projectexplorer/projectexplorer_test.h>
|
#include <projectexplorer/projectexplorer_test.h>
|
||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
@@ -539,7 +538,7 @@ class TestDevice : public IDevice
|
|||||||
public:
|
public:
|
||||||
TestDevice()
|
TestDevice()
|
||||||
{
|
{
|
||||||
setupId(AutoDetected, Id::fromString(QUuid::createUuid().toString()));
|
setupId(AutoDetected, Id::generate());
|
||||||
setType(testTypeId());
|
setType(testTypeId());
|
||||||
setMachineType(Hardware);
|
setMachineType(Hardware);
|
||||||
setOsType(HostOsInfo::hostOs());
|
setOsType(HostOsInfo::hostOs());
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QReadWriteLock>
|
#include <QReadWriteLock>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \class ProjectExplorer::IDevice::DeviceAction
|
* \class ProjectExplorer::IDevice::DeviceAction
|
||||||
@@ -89,7 +88,7 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
static Id newId()
|
static Id newId()
|
||||||
{
|
{
|
||||||
return Id::fromString(QUuid::createUuid().toString());
|
return Id::generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char DisplayNameKey[] = "Name";
|
const char DisplayNameKey[] = "Name";
|
||||||
|
|||||||
@@ -131,8 +131,6 @@ bool GnuMakeParser::hasFatalErrors() const
|
|||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
# include <QTest>
|
# include <QTest>
|
||||||
|
|
||||||
# include <QUuid>
|
|
||||||
|
|
||||||
# include "outputparser_test.h"
|
# include "outputparser_test.h"
|
||||||
# include "projectexplorer_test.h"
|
# include "projectexplorer_test.h"
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -60,7 +59,7 @@ public:
|
|||||||
m_id(id)
|
m_id(id)
|
||||||
{
|
{
|
||||||
if (!id.isValid())
|
if (!id.isValid())
|
||||||
m_id = Id::fromString(QUuid::createUuid().toString());
|
m_id = Id::generate();
|
||||||
|
|
||||||
m_unexpandedDisplayName.setDefaultValue(Tr::tr("Unnamed"));
|
m_unexpandedDisplayName.setDefaultValue(Tr::tr("Unnamed"));
|
||||||
|
|
||||||
|
|||||||
@@ -1068,7 +1068,7 @@ TextEditorWidgetPrivate::TextEditorWidgetPrivate(TextEditorWidget *parent)
|
|||||||
, m_codeAssistant(parent)
|
, m_codeAssistant(parent)
|
||||||
, m_hoverHandlerRunner(parent, m_hoverHandlers)
|
, m_hoverHandlerRunner(parent, m_hoverHandlers)
|
||||||
, m_autoCompleter(new AutoCompleter)
|
, m_autoCompleter(new AutoCompleter)
|
||||||
, m_editorContext(Id::fromString(QUuid::createUuid().toString()))
|
, m_editorContext(Id::generate())
|
||||||
{
|
{
|
||||||
m_selectionHighlightOverlay->show();
|
m_selectionHighlightOverlay->show();
|
||||||
auto aggregate = new Aggregation::Aggregate;
|
auto aggregate = new Aggregation::Aggregate;
|
||||||
|
|||||||
Reference in New Issue
Block a user