From 342caa2141d1f62cbd1a4280c3ccba972abda0fa Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 9 Dec 2008 11:07:24 +0100 Subject: some more whitespace changes --- .../projectexplorer/environmenteditmodel.cpp | 106 ++++++++++----------- 1 file changed, 53 insertions(+), 53 deletions(-) (limited to 'src/plugins/projectexplorer/environmenteditmodel.cpp') 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, ""); } } @@ -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 ""; 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 name) + for (int i=0; i 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 = ""; - 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 "<