Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
d6706efc
Commit
d6706efc
authored
Aug 04, 2022
by
Ahmad Samir
Browse files
Change Profile::PropertyMap to a std::map
This fixes an issue with QHash in Qt6, see:
#30
parent
d1948549
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/Application.cpp
View file @
d6706efc
...
...
@@ -468,13 +468,7 @@ Profile::Ptr Application::processProfileChangeArgs(Profile::Ptr baseProfile)
const
QStringList
profileProperties
=
m_parser
->
values
(
QStringLiteral
(
"p"
));
for
(
const
QString
&
value
:
profileProperties
)
{
ProfileCommandParser
parser
;
QHashIterator
<
Profile
::
Property
,
QVariant
>
iter
(
parser
.
parse
(
value
));
while
(
iter
.
hasNext
())
{
iter
.
next
();
newProfile
->
setProperty
(
iter
.
key
(),
iter
.
value
());
}
newProfile
->
assignProperties
(
parser
.
parse
(
value
));
shouldUseNewProfile
=
true
;
}
...
...
src/profile/Profile.cpp
View file @
d6706efc
...
...
@@ -267,27 +267,42 @@ const Profile::Ptr Profile::parent() const
bool
Profile
::
isEmpty
()
const
{
return
_propertyValues
.
isE
mpty
();
return
_propertyValues
.
e
mpty
();
}
Profile
::
PropertyMap
Profile
::
properties
()
const
const
Profile
::
PropertyMap
&
Profile
::
properties
()
const
{
return
_propertyValues
;
}
void
Profile
::
setProperty
(
Property
p
,
const
QVariant
&
value
)
{
_propertyValues
.
insert
(
p
,
value
);
_propertyValues
.
insert_or_assign
(
p
,
value
);
}
void
Profile
::
setProperty
(
Property
p
,
QVariant
&&
value
)
{
_propertyValues
.
insert_or_assign
(
p
,
value
);
}
void
Profile
::
assignProperties
(
const
PropertyMap
&
map
)
{
_propertyValues
.
insert
(
map
);
for
(
const
auto
&
[
p
,
value
]
:
map
)
{
setProperty
(
p
,
value
);
}
}
void
Profile
::
assignProperties
(
PropertyMap
&&
map
)
{
// If a key exists in both maps, we want to use the associated
// value from 'map'
map
.
merge
(
_propertyValues
);
_propertyValues
.
swap
(
map
);
}
bool
Profile
::
isPropertySet
(
Property
p
)
const
{
return
_propertyValues
.
contains
(
p
);
return
_propertyValues
.
find
(
p
)
!=
_propertyValues
.
cend
(
);
}
Profile
::
Property
Profile
::
lookupByName
(
const
QString
&
name
)
...
...
src/profile/Profile.h
View file @
d6706efc
...
...
@@ -17,6 +17,7 @@
#include
<QStringList>
#include
<QVariant>
#include
<map>
#include
<vector>
// Konsole
...
...
@@ -366,7 +367,7 @@ public:
Q_ENUM
(
Property
)
using
PropertyMap
=
QHash
<
Property
,
QVariant
>
;
using
PropertyMap
=
std
::
map
<
Property
,
QVariant
>
;
/**
* Constructs a new profile
...
...
@@ -427,8 +428,11 @@ public:
/** Sets the value of the specified @p property to @p value. */
virtual
void
setProperty
(
Property
p
,
const
QVariant
&
value
);
void
setProperty
(
Property
p
,
QVariant
&&
value
);
/** Sets the Porperty/value pairs from @p map on this Profile */
void
assignProperties
(
const
PropertyMap
&
map
);
void
assignProperties
(
PropertyMap
&&
map
);
/** Returns true if the specified property has been set in this Profile
* instance.
...
...
@@ -436,7 +440,7 @@ public:
virtual
bool
isPropertySet
(
Property
p
)
const
;
/** Returns a map of the properties set in this Profile instance. */
virtual
PropertyMap
properties
()
const
;
virtual
const
PropertyMap
&
properties
()
const
;
/** Returns true if no properties have been set in this Profile instance. */
bool
isEmpty
()
const
;
...
...
@@ -833,8 +837,9 @@ inline T Profile::property(Property p) const
template
<
>
inline
QVariant
Profile
::
property
(
Property
p
)
const
{
if
(
_propertyValues
.
contains
(
p
))
{
return
_propertyValues
[
p
];
auto
it
=
_propertyValues
.
find
(
p
);
if
(
it
!=
_propertyValues
.
end
())
{
return
it
->
second
;
}
else
if
(
_parent
&&
canInheritProperty
(
p
))
{
return
_parent
->
property
<
QVariant
>
(
p
);
}
else
{
...
...
src/profile/ProfileCommandParser.cpp
View file @
d6706efc
...
...
@@ -35,8 +35,7 @@ Profile::PropertyMap ProfileCommandParser::parse(const QString &input)
while
(
iterator
.
hasNext
())
{
QRegularExpressionMatch
match
(
iterator
.
next
());
Profile
::
Property
property
=
Profile
::
lookupByName
(
match
.
captured
(
1
));
const
QString
value
=
match
.
captured
(
2
);
changes
.
insert
(
property
,
value
);
changes
.
insert_or_assign
(
property
,
match
.
captured
(
2
));
}
return
changes
;
...
...
src/profile/ProfileManager.cpp
View file @
d6706efc
...
...
@@ -278,19 +278,13 @@ void ProfileManager::changeProfile(Profile::Ptr profile, const Profile::Property
// Don't save a profile with an empty name on disk
persistent
=
persistent
&&
!
profile
->
name
().
isEmpty
();
bool
isNameChanged
=
false
;
// Insert the changes into the existing Profile instance
profile
->
assignProperties
(
propertyMap
);
// Check if the name changed
for
(
auto
it
=
propertyMap
.
cbegin
(),
endIt
=
propertyMap
.
cend
();
it
!=
endIt
;
++
it
)
{
const
auto
property
=
it
.
key
();
isNameChanged
|=
property
==
Profile
::
Name
||
property
==
Profile
::
UntranslatedName
;
if
(
isNameChanged
)
{
break
;
}
}
const
bool
isRenamed
=
std
::
any_of
(
propertyMap
.
cbegin
(),
propertyMap
.
cend
(),
[](
const
auto
&
pair
)
{
Profile
::
Property
prop
=
pair
.
first
;
return
prop
==
Profile
::
Name
||
prop
==
Profile
::
UntranslatedName
;
});
// when changing a group, iterate through the profiles
// in the group and call changeProfile() on each of them
...
...
@@ -313,7 +307,7 @@ void ProfileManager::changeProfile(Profile::Ptr profile, const Profile::Property
profile
->
setProperty
(
Profile
::
Path
,
saveProfile
(
profile
));
}
if
(
is
NameChanged
)
{
//
Renamed
?
if
(
isRenamed
)
{
// origPath is empty when saving a new profile
if
(
!
origPath
.
isEmpty
())
{
// Delete the old/redundant .profile from disk
...
...
src/session/SessionManager.cpp
View file @
d6706efc
...
...
@@ -311,9 +311,6 @@ void SessionManager::sessionProfileCommandReceived(Session *session, const QStri
}
}
ProfileCommandParser
parser
;
Profile
::
PropertyMap
changes
=
parser
.
parse
(
text
);
Profile
::
Ptr
newProfile
;
if
(
!
_sessionRuntimeProfiles
.
contains
(
session
))
{
newProfile
=
new
Profile
(
_sessionProfiles
[
session
]);
...
...
@@ -322,7 +319,8 @@ void SessionManager::sessionProfileCommandReceived(Session *session, const QStri
newProfile
=
_sessionRuntimeProfiles
[
session
];
}
newProfile
->
assignProperties
(
changes
);
ProfileCommandParser
parser
;
newProfile
->
assignProperties
(
parser
.
parse
(
text
));
_sessionProfiles
[
session
]
=
newProfile
;
applyProfile
(
newProfile
,
true
);
...
...
src/widgets/EditProfileDialog.cpp
View file @
d6706efc
...
...
@@ -234,10 +234,9 @@ void EditProfileDialog::save()
// ensure that these settings are not undone by a call
// to unpreview()
QHashIterator
<
Profile
::
Property
,
QVariant
>
iter
(
_tempProfile
->
properties
());
while
(
iter
.
hasNext
())
{
iter
.
next
();
_previewedProperties
.
remove
(
iter
.
key
());
const
Profile
::
PropertyMap
&
map
=
_tempProfile
->
properties
();
for
(
const
auto
&
[
property
,
_
]
:
map
)
{
_previewedProperties
.
remove
(
property
);
}
// Update the default profile if needed
...
...
@@ -1047,11 +1046,11 @@ void EditProfileDialog::unpreviewAll()
QHashIterator
<
int
,
QVariant
>
iter
(
_previewedProperties
);
while
(
iter
.
hasNext
())
{
iter
.
next
();
map
.
insert
(
static_cast
<
Profile
::
Property
>
(
iter
.
key
()),
iter
.
value
());
map
.
insert
(
{
static_cast
<
Profile
::
Property
>
(
iter
.
key
()),
iter
.
value
()
}
);
}
// undo any preview changes
if
(
!
map
.
isE
mpty
())
{
if
(
!
map
.
e
mpty
())
{
ProfileManager
::
instance
()
->
changeProfile
(
_profile
,
map
,
false
);
}
}
...
...
@@ -1064,8 +1063,7 @@ void EditProfileDialog::unpreview(int property)
return
;
}
Profile
::
PropertyMap
map
;
map
.
insert
(
static_cast
<
Profile
::
Property
>
(
property
),
_previewedProperties
[
property
]);
const
Profile
::
PropertyMap
map
({{
static_cast
<
Profile
::
Property
>
(
property
),
_previewedProperties
[
property
]}});
ProfileManager
::
instance
()
->
changeProfile
(
_profile
,
map
,
false
);
_previewedProperties
.
remove
(
property
);
...
...
@@ -1092,8 +1090,9 @@ void EditProfileDialog::delayedPreviewActivate()
void
EditProfileDialog
::
preview
(
int
property
,
const
QVariant
&
value
)
{
Profile
::
PropertyMap
map
;
map
.
insert
(
static_cast
<
Profile
::
Property
>
(
property
),
value
);
// Copy "value" into the map before removing the key/value pair
// from _delayedPreviewProperties
const
Profile
::
PropertyMap
map
{{
static_cast
<
Profile
::
Property
>
(
property
),
value
}};
_delayedPreviewProperties
.
remove
(
property
);
...
...
@@ -1395,13 +1394,8 @@ void EditProfileDialog::updateButtonApply()
{
bool
userModified
=
false
;
QHashIterator
<
Profile
::
Property
,
QVariant
>
iter
(
_tempProfile
->
properties
());
while
(
iter
.
hasNext
())
{
iter
.
next
();
Profile
::
Property
property
=
iter
.
key
();
QVariant
value
=
iter
.
value
();
const
Profile
::
PropertyMap
&
map
=
_tempProfile
->
properties
();
for
(
const
auto
&
[
property
,
value
]
:
map
)
{
// for previewed property
if
(
_previewedProperties
.
contains
(
static_cast
<
int
>
(
property
)))
{
if
(
value
!=
_previewedProperties
.
value
(
static_cast
<
int
>
(
property
)))
{
...
...
Kurt Hindenburg
@hindenburg
mentioned in issue
#30 (closed)
·
Aug 29, 2022
mentioned in issue
#30 (closed)
mentioned in issue #30
Toggle commit list
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment