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
dfad3fa7
Commit
dfad3fa7
authored
14 years ago
by
Tobias Hunger
Browse files
Options
Downloads
Patches
Plain Diff
Update EnvironmentModel::setData
Reviewed-by: dt
parent
b5d08242
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/projectexplorer/environmenteditmodel.cpp
+45
-44
45 additions, 44 deletions
src/plugins/projectexplorer/environmenteditmodel.cpp
with
45 additions
and
44 deletions
src/plugins/projectexplorer/environmenteditmodel.cpp
+
45
−
44
View file @
dfad3fa7
...
@@ -190,56 +190,57 @@ int EnvironmentModel::findInResultInsertPosition(const QString &name) const
...
@@ -190,56 +190,57 @@ int EnvironmentModel::findInResultInsertPosition(const QString &name) const
bool
EnvironmentModel
::
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
int
role
)
bool
EnvironmentModel
::
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
int
role
)
{
{
if
(
!
index
.
isValid
())
if
(
!
index
.
isValid
()
||
role
!=
Qt
::
EditRole
)
return
false
;
return
false
;
if
(
role
==
Qt
::
EditRole
&&
index
.
isValid
())
{
// ignore changes to already set values:
// ignore changes to already set values:
if
(
data
(
index
,
role
)
==
value
)
if
(
data
(
index
,
role
)
==
value
)
return
true
;
return
true
;
if
(
index
.
column
()
==
0
)
{
const
QString
oldName
=
data
(
this
->
index
(
index
.
row
(),
0
,
QModelIndex
())).
toString
();
//fail if a variable with the same name already exists
const
QString
oldValue
=
data
(
this
->
index
(
index
.
row
(),
1
,
QModelIndex
())).
toString
();
#ifdef Q_OS_WIN
int
changesPos
=
findInChanges
(
oldName
);
const
QString
&
newName
=
value
.
toString
().
toUpper
();
if
(
index
.
column
()
==
0
)
{
//fail if a variable with the same name already exists
#if defined(Q_OS_WIN)
const
QString
&
newName
=
value
.
toString
().
toUpper
();
#else
#else
const
QString
&
newName
=
value
.
toString
();
const
QString
&
newName
=
value
.
toString
();
#endif
#endif
// Does the new name exist already?
if
(
findInChanges
(
newName
)
!=
-
1
)
if
(
m_resultEnvironment
.
hasKey
(
newName
))
return
false
;
return
false
;
EnvironmentItem
old
(
""
,
""
);
EnvironmentItem
newVariable
(
newName
,
oldValue
);
int
pos
=
findInChanges
(
indexToVariable
(
index
));
if
(
pos
!=
-
1
)
{
if
(
changesPos
!=
-
1
)
old
=
m_items
.
at
(
pos
);
resetVariable
(
oldName
);
// restore the original base variable again
QModelIndex
newIndex
=
addVariable
(
newVariable
);
// add the new variable
emit
focusIndex
(
newIndex
.
sibling
(
newIndex
.
row
(),
1
));
// hint to focus on the value
return
true
;
}
else
if
(
index
.
column
()
==
1
)
{
// We are changing an existing value:
const
QString
stringValue
=
value
.
toString
();
if
(
changesPos
!=
-
1
)
{
// We have already changed this value
if
(
stringValue
==
m_baseEnvironment
.
value
(
oldName
))
{
// ... and now went back to the base value
m_items
.
removeAt
(
changesPos
);
}
else
{
}
else
{
old
.
name
=
m_resultEnvironment
.
key
(
m_resultEnvironment
.
constBegin
()
+
index
.
row
());
// ... and changed it again
old
.
value
=
m_resultEnvironment
.
value
(
m_resultEnvironment
.
constBegin
()
+
index
.
row
())
;
m_items
[
changesPos
].
value
=
stringValue
;
old
.
unset
=
false
;
m_items
[
changesPos
]
.
unset
=
false
;
}
}
}
else
{
if
(
changes
(
old
.
name
))
// Add a new change item:
resetVariable
(
old
.
name
);
m_items
.
append
(
EnvironmentItem
(
oldName
,
stringValue
));
old
.
name
=
newName
;
addVariable
(
old
);
emit
renamedVariable
(
newName
);
return
true
;
}
else
if
(
index
.
column
()
==
1
)
{
const
QString
&
name
=
indexToVariable
(
index
);
int
pos
=
findInChanges
(
name
);
if
(
pos
!=
-
1
)
{
m_items
[
pos
].
value
=
value
.
toString
();
m_items
[
pos
].
unset
=
false
;
updateResultEnvironment
();
emit
dataChanged
(
index
,
index
);
emit
userChangesChanged
();
return
true
;
}
// not found in m_items, so add it as a new variable
addVariable
(
EnvironmentItem
(
name
,
value
.
toString
()));
return
true
;
}
}
updateResultEnvironment
();
emit
dataChanged
(
index
,
index
);
emit
userChangesChanged
();
return
true
;
}
}
return
false
;
return
false
;
}
}
...
@@ -446,8 +447,8 @@ EnvironmentWidget::~EnvironmentWidget()
...
@@ -446,8 +447,8 @@ EnvironmentWidget::~EnvironmentWidget()
void
EnvironmentWidget
::
renamedVariable
(
const
QString
&
name
)
void
EnvironmentWidget
::
renamedVariable
(
const
QString
&
name
)
{
{
QModelIndex
i
d
x
=
m_model
->
variableToIndex
(
name
);
QModelIndex
i
nde
x
=
m_model
->
variableToIndex
(
name
);
m_environmentTreeView
->
setCurrentIndex
(
i
d
x
);
m_environmentTreeView
->
setCurrentIndex
(
i
nde
x
);
m_environmentTreeView
->
setFocus
();
m_environmentTreeView
->
setFocus
();
}
}
...
...
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