Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
2d6ad569
Commit
2d6ad569
authored
14 years ago
by
hjk
Browse files
Options
Downloads
Patches
Plain Diff
coreplugin: introduce an 'Id' class, intended as successor for generic QStrings
to identify actions etc.
parent
05b07bfe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/coreplugin/uniqueidmanager.cpp
+4
-4
4 additions, 4 deletions
src/plugins/coreplugin/uniqueidmanager.cpp
src/plugins/coreplugin/uniqueidmanager.h
+33
-3
33 additions, 3 deletions
src/plugins/coreplugin/uniqueidmanager.h
with
37 additions
and
7 deletions
src/plugins/coreplugin/uniqueidmanager.cpp
+
4
−
4
View file @
2d6ad569
...
@@ -44,12 +44,12 @@ UniqueIDManager::~UniqueIDManager()
...
@@ -44,12 +44,12 @@ UniqueIDManager::~UniqueIDManager()
m_instance
=
0
;
m_instance
=
0
;
}
}
bool
UniqueIDManager
::
hasUniqueIdentifier
(
const
QString
&
id
)
const
bool
UniqueIDManager
::
hasUniqueIdentifier
(
const
Id
&
id
)
const
{
{
return
m_uniqueIdentifiers
.
contains
(
id
);
return
m_uniqueIdentifiers
.
contains
(
id
);
}
}
int
UniqueIDManager
::
uniqueIdentifier
(
const
QString
&
id
)
int
UniqueIDManager
::
uniqueIdentifier
(
const
Id
&
id
)
{
{
if
(
hasUniqueIdentifier
(
id
))
if
(
hasUniqueIdentifier
(
id
))
return
m_uniqueIdentifiers
.
value
(
id
);
return
m_uniqueIdentifiers
.
value
(
id
);
...
@@ -69,13 +69,13 @@ QString UniqueIDManager::stringForUniqueIdentifier(int uid)
...
@@ -69,13 +69,13 @@ QString UniqueIDManager::stringForUniqueIdentifier(int uid)
static
int
toId
(
const
char
*
id
)
static
int
toId
(
const
char
*
id
)
{
{
return
UniqueIDManager
::
instance
()
->
uniqueIdentifier
(
QLatin1String
(
id
)
)
;
return
UniqueIDManager
::
instance
()
->
uniqueIdentifier
(
id
);
}
}
Context
::
Context
(
const
char
*
id
,
int
offset
)
Context
::
Context
(
const
char
*
id
,
int
offset
)
{
{
d
.
append
(
UniqueIDManager
::
instance
()
d
.
append
(
UniqueIDManager
::
instance
()
->
uniqueIdentifier
(
QString
(
id
)
+
QString
::
number
(
offset
)));
->
uniqueIdentifier
(
Id
(
QString
(
id
)
+
QString
::
number
(
offset
)))
)
;
}
}
void
Context
::
add
(
const
char
*
id
)
void
Context
::
add
(
const
char
*
id
)
...
...
This diff is collapsed.
Click to expand it.
src/plugins/coreplugin/uniqueidmanager.h
+
33
−
3
View file @
2d6ad569
...
@@ -37,6 +37,36 @@
...
@@ -37,6 +37,36 @@
namespace
Core
{
namespace
Core
{
// FIXME: The intention is to use this class instead of the
// generic QString to identify actions.
class
CORE_EXPORT
Id
{
public:
Id
()
{}
Id
(
const
char
*
name
)
:
m_name
(
QLatin1String
(
name
))
{}
// FIXME: Replace with QByteArray
Id
(
const
QString
&
name
)
:
m_name
(
name
)
{}
// FIXME: Remove.
operator
QString
()
const
{
return
m_name
;
}
// FIXME: Replace with QByteArray
QString
name
()
const
{
return
m_name
;
}
bool
isValid
()
const
{
return
!
m_name
.
isEmpty
();
}
bool
operator
==
(
const
Id
&
id
)
const
{
return
m_name
==
id
.
m_name
;
}
bool
operator
!=
(
const
Id
&
id
)
const
{
return
m_name
!=
id
.
m_name
;
}
private
:
// Intentionally unimplemented
Id
(
const
QLatin1String
&
);
// FIXME: Replace with QByteArray
QString
m_name
;
};
inline
uint
qHash
(
const
Id
&
id
)
{
return
qHash
(
id
.
name
());
}
class
CORE_EXPORT
UniqueIDManager
class
CORE_EXPORT
UniqueIDManager
{
{
public:
public:
...
@@ -45,12 +75,12 @@ public:
...
@@ -45,12 +75,12 @@ public:
static
UniqueIDManager
*
instance
()
{
return
m_instance
;
}
static
UniqueIDManager
*
instance
()
{
return
m_instance
;
}
bool
hasUniqueIdentifier
(
const
QString
&
id
)
const
;
bool
hasUniqueIdentifier
(
const
Id
&
id
)
const
;
int
uniqueIdentifier
(
const
QString
&
id
);
int
uniqueIdentifier
(
const
Id
&
id
);
QString
stringForUniqueIdentifier
(
int
uid
);
QString
stringForUniqueIdentifier
(
int
uid
);
private
:
private
:
QHash
<
QString
,
int
>
m_uniqueIdentifiers
;
QHash
<
Id
,
int
>
m_uniqueIdentifiers
;
static
UniqueIDManager
*
m_instance
;
static
UniqueIDManager
*
m_instance
;
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment