summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer/environmenteditmodel.cpp
diff options
context:
space:
mode:
authorhjk <qtc-committer@nokia.com>2008-12-09 11:07:24 +0100
committerhjk <qtc-committer@nokia.com>2008-12-09 11:07:24 +0100
commit342caa2141d1f62cbd1a4280c3ccba972abda0fa (patch)
tree51224cf821021f06dde8645043d4215d6924ac6f /src/plugins/projectexplorer/environmenteditmodel.cpp
parent88b7a14a7973058248874f9a4d3dbcb181bcd352 (diff)
downloadqt-creator-342caa2141d1f62cbd1a4280c3ccba972abda0fa.tar.gz
some more whitespace changes
Diffstat (limited to 'src/plugins/projectexplorer/environmenteditmodel.cpp')
-rw-r--r--src/plugins/projectexplorer/environmenteditmodel.cpp106
1 files changed, 53 insertions, 53 deletions
diff --git a/src/plugins/projectexplorer/environmenteditmodel.cpp b/src/plugins/projectexplorer/environmenteditmodel.cpp
index 2405d86998..68bb6f5fdf 100644
--- a/src/plugins/projectexplorer/environmenteditmodel.cpp
+++ b/src/plugins/projectexplorer/environmenteditmodel.cpp
@@ -38,11 +38,13 @@ using namespace ProjectExplorer;
EnvironmentModel::EnvironmentModel()
: m_mergedEnvironments(false)
{}
-EnvironmentModel::~EnvironmentModel() {}
+
+EnvironmentModel::~EnvironmentModel()
+{}
QString EnvironmentModel::indexToVariable(const QModelIndex &index) const
{
- if(m_mergedEnvironments)
+ if (m_mergedEnvironments)
return m_resultEnvironment.key(m_resultEnvironment.constBegin() + index.row());
else
return m_items.at(index.row()).name;
@@ -53,7 +55,7 @@ void EnvironmentModel::updateResultEnvironment()
m_resultEnvironment = m_baseEnvironment;
m_resultEnvironment.modify(m_items);
foreach (const EnvironmentItem &item, m_items) {
- if(item.unset) {
+ if (item.unset) {
m_resultEnvironment.set(item.name, "<UNSET>");
}
}
@@ -68,10 +70,10 @@ void EnvironmentModel::setBaseEnvironment(const ProjectExplorer::Environment &en
void EnvironmentModel::setMergedEnvironments(bool b)
{
- if(m_mergedEnvironments == b)
+ if (m_mergedEnvironments == b)
return;
m_mergedEnvironments = b;
- if(b)
+ if (b)
updateResultEnvironment();
reset();
}
@@ -96,48 +98,46 @@ int EnvironmentModel::columnCount(const QModelIndex &parent) const
bool EnvironmentModel::changes(const QString &name) const
{
- foreach(const EnvironmentItem& item, m_items) {
- if(item.name == name) {
+ foreach (const EnvironmentItem& item, m_items)
+ if (item.name == name)
return true;
- }
- }
return false;
}
QVariant EnvironmentModel::data(const QModelIndex &index, int role) const
{
- if((role == Qt::DisplayRole || role == Qt::EditRole) && index.isValid()) {
- if((m_mergedEnvironments && index.row() >= m_resultEnvironment.size()) ||
+ if ((role == Qt::DisplayRole || role == Qt::EditRole) && index.isValid()) {
+ if ((m_mergedEnvironments && index.row() >= m_resultEnvironment.size()) ||
(!m_mergedEnvironments && index.row() >= m_items.count())) {
return QVariant();
}
- if(index.column() == 0) {
- if(m_mergedEnvironments) {
+ if (index.column() == 0) {
+ if (m_mergedEnvironments) {
return m_resultEnvironment.key(m_resultEnvironment.constBegin() + index.row());
} else {
return m_items.at(index.row()).name;
}
- } else if(index.column() == 1) {
- if(m_mergedEnvironments) {
- if(role == Qt::EditRole) {
+ } else if (index.column() == 1) {
+ if (m_mergedEnvironments) {
+ if (role == Qt::EditRole) {
int pos = findInChanges(indexToVariable(index));
- if(pos != -1)
+ if (pos != -1)
return m_items.at(pos).value;
}
return m_resultEnvironment.value(m_resultEnvironment.constBegin() + index.row());
} else {
- if(m_items.at(index.row()).unset)
+ if (m_items.at(index.row()).unset)
return "<UNSET>";
else
return m_items.at(index.row()).value;
}
}
}
- if(role == Qt::FontRole) {
- if(m_mergedEnvironments) {
+ if (role == Qt::FontRole) {
+ if (m_mergedEnvironments) {
// check wheter this environment variable exists in m_items
- if(changes(m_resultEnvironment.key(m_resultEnvironment.constBegin() + index.row()))) {
+ if (changes(m_resultEnvironment.key(m_resultEnvironment.constBegin() + index.row()))) {
QFont f;
f.setBold(true);
return QVariant(f);
@@ -157,7 +157,7 @@ Qt::ItemFlags EnvironmentModel::flags(const QModelIndex &index) const
bool EnvironmentModel::hasChildren(const QModelIndex &index) const
{
- if(!index.isValid())
+ if (!index.isValid())
return true;
else
return false;
@@ -165,14 +165,14 @@ bool EnvironmentModel::hasChildren(const QModelIndex &index) const
QVariant EnvironmentModel::headerData(int section, Qt::Orientation orientation, int role) const
{
- if(orientation == Qt::Vertical || role != Qt::DisplayRole)
+ if (orientation == Qt::Vertical || role != Qt::DisplayRole)
return QVariant();
return section == 0 ? tr("Variable") : tr("Value");
}
QModelIndex EnvironmentModel::index(int row, int column, const QModelIndex &parent) const
{
- if(!parent.isValid())
+ if (!parent.isValid())
return createIndex(row, column, 0);
return QModelIndex();
}
@@ -188,16 +188,16 @@ QModelIndex EnvironmentModel::parent(const QModelIndex &index) const
/// *****************
int EnvironmentModel::findInChanges(const QString &name) const
{
- for(int i=0; i<m_items.size(); ++i)
- if(m_items.at(i).name == name)
+ for (int i=0; i<m_items.size(); ++i)
+ if (m_items.at(i).name == name)
return i;
return -1;
}
int EnvironmentModel::findInChangesInsertPosition(const QString &name) const
{
- for(int i=0; i<m_items.size(); ++i)
- if(m_items.at(i).name > name)
+ for (int i=0; i<m_items.size(); ++i)
+ if (m_items.at(i).name > name)
return i;
return m_items.size();
}
@@ -206,8 +206,8 @@ int EnvironmentModel::findInResult(const QString &name) const
{
Environment::const_iterator it;
int i = 0;
- for(it = m_resultEnvironment.constBegin(); it != m_resultEnvironment.constEnd(); ++it, ++i)
- if(m_resultEnvironment.key(it) == name)
+ for (it = m_resultEnvironment.constBegin(); it != m_resultEnvironment.constEnd(); ++it, ++i)
+ if (m_resultEnvironment.key(it) == name)
return i;
return -1;
}
@@ -216,28 +216,28 @@ int EnvironmentModel::findInResultInsertPosition(const QString &name) const
{
Environment::const_iterator it;
int i = 0;
- for(it = m_resultEnvironment.constBegin(); it != m_resultEnvironment.constEnd(); ++it, ++i)
- if(m_resultEnvironment.key(it) > name)
+ for (it = m_resultEnvironment.constBegin(); it != m_resultEnvironment.constEnd(); ++it, ++i)
+ if (m_resultEnvironment.key(it) > name)
return i;
return m_resultEnvironment.size();
}
bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
- if(role == Qt::EditRole && index.isValid()) {
- if(index.column() == 0) {
+ if (role == Qt::EditRole && index.isValid()) {
+ if (index.column() == 0) {
//fail if a variable with the same name already exists
#ifdef Q_OS_WIN
- if(findInChanges(value.toString().toUpper()) != -1)
+ if (findInChanges(value.toString().toUpper()) != -1)
return false;
#else
- if(findInChanges(value.toString()) != -1)
+ if (findInChanges(value.toString()) != -1)
return false;
#endif
EnvironmentItem old("", "");
- if(m_mergedEnvironments) {
+ if (m_mergedEnvironments) {
int pos = findInChanges(indexToVariable(index));
- if(pos != -1) {
+ if (pos != -1) {
old = m_items.at(pos);
} else {
old.name = m_resultEnvironment.key(m_resultEnvironment.constBegin() + index.row());
@@ -252,16 +252,16 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
#else
const QString &newName = value.toString();
#endif
- if(changes(old.name))
+ if (changes(old.name))
removeVariable(old.name);
old.name = newName;
addVariable(old);
return true;
- } else if(index.column() == 1) {
- if(m_mergedEnvironments) {
+ } else if (index.column() == 1) {
+ if (m_mergedEnvironments) {
const QString &name = indexToVariable(index);
int pos = findInChanges(name);
- if(pos != -1) {
+ if (pos != -1) {
m_items[pos].value = value.toString();
m_items[pos].unset = false;
updateResultEnvironment();
@@ -287,13 +287,13 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
QModelIndex EnvironmentModel::addVariable()
{
const QString &name = "<VARIABLE>";
- if(m_mergedEnvironments) {
+ if (m_mergedEnvironments) {
int i = findInResult(name);
- if(i != -1)
+ if (i != -1)
return index(i, 0, QModelIndex());
} else {
int i = findInChanges(name);
- if(i != -1)
+ if (i != -1)
return index(i, 0, QModelIndex());
}
// Don't exist, really add them
@@ -302,10 +302,10 @@ QModelIndex EnvironmentModel::addVariable()
QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
{
- if(m_mergedEnvironments) {
+ if (m_mergedEnvironments) {
bool existsInBaseEnvironment = (m_baseEnvironment.find(item.name) != m_baseEnvironment.constEnd());
int rowInResult;
- if(existsInBaseEnvironment)
+ if (existsInBaseEnvironment)
rowInResult = findInResult(item.name);
else
rowInResult = findInResultInsertPosition(item.name);
@@ -313,7 +313,7 @@ QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
qDebug()<<"addVariable "<<item.name<<existsInBaseEnvironment<<rowInResult<<rowInChanges;
- if(existsInBaseEnvironment) {
+ if (existsInBaseEnvironment) {
m_items.insert(rowInChanges, item);
updateResultEnvironment();
emit dataChanged(index(rowInResult, 0, QModelIndex()), index(rowInResult, 1, QModelIndex()));
@@ -340,11 +340,11 @@ QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
void EnvironmentModel::removeVariable(const QString &name)
{
- if(m_mergedEnvironments) {
+ if (m_mergedEnvironments) {
int rowInResult = findInResult(name);
int rowInChanges = findInChanges(name);
bool existsInBaseEnvironment = m_baseEnvironment.find(name) != m_baseEnvironment.constEnd();
- if(existsInBaseEnvironment) {
+ if (existsInBaseEnvironment) {
m_items.removeAt(rowInChanges);
updateResultEnvironment();
emit dataChanged(index(rowInResult, 0, QModelIndex()), index(rowInResult, 1, QModelIndex()));
@@ -368,11 +368,11 @@ void EnvironmentModel::removeVariable(const QString &name)
void EnvironmentModel::unset(const QString &name)
{
- if(m_mergedEnvironments) {
+ if (m_mergedEnvironments) {
int row = findInResult(name);
// look in m_items for the variable
int pos = findInChanges(name);
- if(pos != -1) {
+ if (pos != -1) {
m_items[pos].unset = true;
updateResultEnvironment();
emit dataChanged(index(row, 0, QModelIndex()), index(row, 1, QModelIndex()));
@@ -398,7 +398,7 @@ void EnvironmentModel::unset(const QString &name)
bool EnvironmentModel::isUnset(const QString &name)
{
int pos = findInChanges(name);
- if(pos != -1)
+ if (pos != -1)
return m_items.at(pos).unset;
else
return false;