From ad08f1971162e7120723108d9d38e15a374a7eef Mon Sep 17 00:00:00 2001 From: con Date: Wed, 9 Dec 2009 16:57:32 +0100 Subject: [PATCH] Remove some unused code in the pro parsing / pro editing. --- src/plugins/qt4projectmanager/profileeditor.h | 2 - src/shared/proparser/proeditor.cpp | 379 ------------- src/shared/proparser/proeditor.h | 124 ----- src/shared/proparser/proeditor.ui | 143 ----- src/shared/proparser/proeditormodel.cpp | 146 +----- src/shared/proparser/proeditormodel.h | 6 - src/shared/proparser/proiteminfo.cpp | 237 --------- src/shared/proparser/proiteminfo.h | 133 ----- src/shared/proparser/proparser.pri | 11 +- src/shared/proparser/valueeditor.cpp | 496 ------------------ src/shared/proparser/valueeditor.h | 115 ---- src/shared/proparser/valueeditor.ui | 384 -------------- 12 files changed, 2 insertions(+), 2174 deletions(-) delete mode 100644 src/shared/proparser/proeditor.cpp delete mode 100644 src/shared/proparser/proeditor.h delete mode 100644 src/shared/proparser/proeditor.ui delete mode 100644 src/shared/proparser/proiteminfo.cpp delete mode 100644 src/shared/proparser/proiteminfo.h delete mode 100644 src/shared/proparser/valueeditor.cpp delete mode 100644 src/shared/proparser/valueeditor.h delete mode 100644 src/shared/proparser/valueeditor.ui diff --git a/src/plugins/qt4projectmanager/profileeditor.h b/src/plugins/qt4projectmanager/profileeditor.h index f4a6b0dae6a..d9673e7e422 100644 --- a/src/plugins/qt4projectmanager/profileeditor.h +++ b/src/plugins/qt4projectmanager/profileeditor.h @@ -45,8 +45,6 @@ class Qt4Project; namespace Internal { class ProFileEditorFactory; -class ProItemInfoManager; -class ProEditorModel; class ProFileHighlighter; class ProFileEditor; diff --git a/src/shared/proparser/proeditor.cpp b/src/shared/proparser/proeditor.cpp deleted file mode 100644 index 37a67965158..00000000000 --- a/src/shared/proparser/proeditor.cpp +++ /dev/null @@ -1,379 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "proeditor.h" -#include "proitems.h" -#include "proeditormodel.h" -#include "procommandmanager.h" -#include "proxml.h" - -#include -#include -#include - -using namespace Qt4ProjectManager::Internal; - -ProEditor::ProEditor(QWidget *parent, bool shortcuts) - : QWidget(parent) -{ - m_shortcuts = shortcuts; - m_advanced = false; - setupUi(this); - - m_setFocusToListView = true; - m_blockSelectionSignal = false; - m_cutAction = new QAction(tr("Cut"), this); - m_copyAction = new QAction(tr("Copy"), this); - m_pasteAction = new QAction(tr("Paste"), this); -} - -ProEditor::~ProEditor() -{ -} - -void ProEditor::initialize(ProEditorModel *model, ProItemInfoManager *infomanager) -{ - m_model = model; - m_infomanager = infomanager; - initialize(); -} - -ProScopeFilter *ProEditor::filterModel() const -{ - return m_filter; -} - -void ProEditor::selectScope(const QModelIndex &scope) -{ - m_setFocusToListView = false; - QModelIndex parent = m_filter->mapToSource(scope); - m_editListView->setRootIndex(parent); - m_editListView->setCurrentIndex(m_model->index(0,0,parent)); - m_setFocusToListView = true; -} - -void ProEditor::initialize() -{ - m_model->setInfoManager(m_infomanager); - m_filter = new ProScopeFilter(this); - m_filter->setSourceModel(m_model); - - m_contextMenu = new QMenu(this); - - if (m_shortcuts) { - m_cutAction->setShortcut(QKeySequence(tr("Ctrl+X"))); - m_copyAction->setShortcut(QKeySequence(tr("Ctrl+C"))); - m_pasteAction->setShortcut(QKeySequence(tr("Ctrl+V"))); - m_editListView->installEventFilter(this); - } - - m_contextMenu->addAction(m_cutAction); - m_contextMenu->addAction(m_copyAction); - m_contextMenu->addAction(m_pasteAction); - - QMenu *addMenu = new QMenu(m_addToolButton); - m_addVariable = addMenu->addAction(tr("Add Variable"), this, SLOT(addVariable())); - m_addScope = addMenu->addAction(tr("Add Scope"), this, SLOT(addScope())); - m_addBlock = addMenu->addAction(tr("Add Block"), this, SLOT(addBlock())); - m_addToolButton->setMenu(addMenu); - m_addToolButton->setPopupMode(QToolButton::InstantPopup); - - m_editListView->setModel(m_model); - m_editListView->setContextMenuPolicy(Qt::CustomContextMenu); - - connect(m_editListView, SIGNAL(customContextMenuRequested(const QPoint &)), - this, SLOT(showContextMenu(const QPoint &))); - - connect(m_editListView->selectionModel(), - SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), - this, SLOT(updateState())); - - connect(m_moveUpToolButton, SIGNAL(clicked()), - this, SLOT(moveUp())); - connect(m_moveDownToolButton, SIGNAL(clicked()), - this, SLOT(moveDown())); - connect(m_removeToolButton, SIGNAL(clicked()), - this, SLOT(remove())); - connect(m_cutAction, SIGNAL(triggered()), - this, SLOT(cut())); - connect(m_copyAction, SIGNAL(triggered()), - this, SLOT(copy())); - connect(m_pasteAction, SIGNAL(triggered()), - this, SLOT(paste())); - - updatePasteAction(); -} - -bool ProEditor::eventFilter(QObject *, QEvent *event) -{ - if (event->type() == QEvent::ShortcutOverride) { - QKeyEvent *k = static_cast(event); - if (k->modifiers() == Qt::ControlModifier) { - switch (k->key()) { - case Qt::Key_X: - cut(); return true; - case Qt::Key_C: - copy(); return true; - case Qt::Key_V: - paste(); return true; - } - } - } else if (event->type() == QEvent::FocusIn) { - updateActions(true); - } else if (event->type() == QEvent::FocusOut) { - updateActions(false); - } - - return false; -} - -void ProEditor::showContextMenu(const QPoint &pos) -{ - updatePasteAction(); - m_contextMenu->popup(m_editListView->viewport()->mapToGlobal(pos)); -} - -void ProEditor::updatePasteAction() -{ - bool pasteEnabled = false; - - const QMimeData *data = QApplication::clipboard()->mimeData(); - if (data && data->hasFormat(QLatin1String("application/x-problock"))) - pasteEnabled = true; - - m_pasteAction->setEnabled(pasteEnabled); -} - -void ProEditor::updateActions(bool focus) -{ - bool copyEnabled = false; - - if (focus) - copyEnabled = m_editListView->currentIndex().isValid(); - - m_cutAction->setEnabled(copyEnabled); - m_copyAction->setEnabled(copyEnabled); -} - -void ProEditor::updateState() -{ - bool addEnabled = false; - bool removeEnabled = false; - bool upEnabled = false; - bool downEnabled = false; - - QModelIndex parent = m_editListView->rootIndex(); - ProBlock *scope = m_model->proBlock(parent); - - if (scope) { - addEnabled = true; - QModelIndex index = m_editListView->currentIndex(); - if (index.isValid()) { - removeEnabled = true; - int count = m_model->rowCount(parent); - int row = index.row(); - if (row > 0) - upEnabled = true; - if (row < (count - 1)) - downEnabled = true; - } - } - - if (!m_blockSelectionSignal) { - emit itemSelected(m_editListView->currentIndex()); - if (m_setFocusToListView) - m_editListView->setFocus(Qt::OtherFocusReason); - } - - updateActions(m_editListView->hasFocus()); - - m_addToolButton->setEnabled(addEnabled); - m_removeToolButton->setEnabled(removeEnabled); - m_moveUpToolButton->setEnabled(upEnabled); - m_moveDownToolButton->setEnabled(downEnabled); -} - -void ProEditor::moveUp() -{ - m_editListView->setFocus(Qt::OtherFocusReason); - QModelIndex index = m_editListView->currentIndex(); - QModelIndex parent = index.parent(); - int row = index.row() - 1; - - m_blockSelectionSignal = true; - m_model->moveItem(index, row); - m_blockSelectionSignal = false; - - index = m_model->index(row, 0, parent); - m_editListView->setCurrentIndex(index); -} - -void ProEditor::moveDown() -{ - m_editListView->setFocus(Qt::OtherFocusReason); - QModelIndex index = m_editListView->currentIndex(); - QModelIndex parent = index.parent(); - int row = index.row() + 1; - - m_blockSelectionSignal = true; - m_model->moveItem(index, row); - m_blockSelectionSignal = false; - - index = m_model->index(row, 0, parent); - m_editListView->setCurrentIndex(index); -} - -void ProEditor::remove() -{ - m_editListView->setFocus(Qt::OtherFocusReason); - m_model->removeItem(m_editListView->currentIndex()); - updateState(); -} - -void ProEditor::cut() -{ - QModelIndex index = m_editListView->currentIndex(); - if (!index.isValid()) - return; - - if (ProItem *item = m_model->proItem(index)) { - m_editListView->setFocus(Qt::OtherFocusReason); - m_model->removeItem(index); - - QMimeData *data = new QMimeData(); - QString xml = ProXmlParser::itemToString(item); - if (item->kind() == ProItem::ValueKind) - data->setData(QLatin1String("application/x-provalue"), xml.toUtf8()); - else - data->setData(QLatin1String("application/x-problock"), xml.toUtf8()); - QApplication::clipboard()->setMimeData(data); - } -} - -void ProEditor::copy() -{ - QModelIndex index = m_editListView->currentIndex(); - if (!index.isValid()) - return; - - if (ProItem *item = m_model->proItem(index)) { - m_editListView->setFocus(Qt::OtherFocusReason); - QMimeData *data = new QMimeData(); - QString xml = ProXmlParser::itemToString(item); - if (item->kind() == ProItem::ValueKind) - data->setData(QLatin1String("application/x-provalue"), xml.toUtf8()); - else - data->setData(QLatin1String("application/x-problock"), xml.toUtf8()); - QApplication::clipboard()->setMimeData(data); - } -} - -void ProEditor::paste() -{ - if (const QMimeData *data = QApplication::clipboard()->mimeData()) { - m_editListView->setFocus(Qt::OtherFocusReason); - QModelIndex parent = m_editListView->rootIndex(); - ProBlock *block = m_model->proBlock(parent); - if (!block) - return; - - QString xml; - if (data->hasFormat(QLatin1String("application/x-provalue"))) { - xml = QString::fromUtf8(data->data(QLatin1String("application/x-provalue"))); - } else if (data->hasFormat(QLatin1String("application/x-problock"))) { - xml = QString::fromUtf8(data->data(QLatin1String("application/x-problock"))); - } - - if (ProItem *item = ProXmlParser::stringToItem(xml)) { - QModelIndex parent = m_editListView->rootIndex(); - int row = m_model->rowCount(parent); - m_model->insertItem(item, row, parent); - m_editListView->setCurrentIndex(m_model->index(row,0,parent)); - } - } -} - -void ProEditor::addVariable() -{ - QModelIndex parent = m_editListView->rootIndex(); - if (ProBlock *pblock = m_model->proBlock(parent)) { - m_editListView->setFocus(Qt::OtherFocusReason); - int row = m_model->rowCount(parent); - - QString defid("..."); - ProVariable::VariableOperator op = ProVariable::SetOperator; - QList vars = m_infomanager->variables(); - if (!vars.isEmpty()) { - defid = vars.first()->id(); - op = vars.first()->defaultOperator(); - } - - ProVariable *var = new ProVariable(defid, pblock); - var->setVariableOperator(op); - - m_model->insertItem(var, row, parent); - m_editListView->setCurrentIndex(m_model->index(row,0,parent)); - } -} - -void ProEditor::addScope() -{ - QModelIndex parent = m_editListView->rootIndex(); - if (ProBlock *pblock = m_model->proBlock(parent)) { - m_editListView->setFocus(Qt::OtherFocusReason); - int row = m_model->rowCount(parent); - ProBlock *scope = new ProBlock(pblock); - scope->setBlockKind(ProBlock::ScopeKind); - ProBlock *scopecontents = new ProBlock(scope); - scopecontents->setBlockKind(ProBlock::ScopeContentsKind); - - QString defid("..."); - QList vars = m_infomanager->scopes(); - if (!vars.isEmpty()) - defid = vars.first()->id(); - - scope->setItems(QList() << new ProCondition(defid) << scopecontents); - m_model->insertItem(scope, row, parent); - m_editListView->setCurrentIndex(m_model->index(row,0,parent)); - } -} - -void ProEditor::addBlock() -{ - QModelIndex parent = m_editListView->rootIndex(); - if (ProBlock *pblock = m_model->proBlock(parent)) { - m_editListView->setFocus(Qt::OtherFocusReason); - int row = m_model->rowCount(parent); - ProBlock *block = new ProBlock(pblock); - block->setBlockKind(ProBlock::NormalKind); - block->setItems(QList() << new ProFunction("...")); - m_model->insertItem(block, row, parent); - m_editListView->setCurrentIndex(m_model->index(row,0,parent)); - } -} diff --git a/src/shared/proparser/proeditor.h b/src/shared/proparser/proeditor.h deleted file mode 100644 index 1c80ee36ad8..00000000000 --- a/src/shared/proparser/proeditor.h +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef PROEDITOR_H -#define PROEDITOR_H - -#include "namespace_global.h" - -#include "ui_proeditor.h" - -#include "proiteminfo.h" - -#include -#include - -QT_BEGIN_NAMESPACE -class QMenu; -class QAction; -class ProBlock; -class ProVariable; -class ProFile; -QT_END_NAMESPACE - -namespace Qt4ProjectManager { -namespace Internal { - -class ProEditorModel; -class ProScopeFilter; - -class ProEditor : public QWidget, protected Ui::ProEditor -{ - Q_OBJECT - -public: - ProEditor(QWidget *parent, bool shortcuts = true); - ~ProEditor(); - - virtual void initialize(ProEditorModel *model, ProItemInfoManager *infomanager); - - ProScopeFilter *filterModel() const; - -public slots: - void selectScope(const QModelIndex &scope); - -signals: - void itemSelected(const QModelIndex &index); - -protected slots: - void showContextMenu(const QPoint &pos); - void updatePasteAction(); - void updateState(); - - void moveUp(); - void moveDown(); - void remove(); - void cut(); - void copy(); - void paste(); - - void addVariable(); - void addScope(); - void addBlock(); - -protected: - void updateActions(bool focus); - bool eventFilter(QObject *obj, QEvent *event); - -private: - void initialize(); - -protected: - ProEditorModel *m_model; - QAction *m_cutAction; - QAction *m_copyAction; - QAction *m_pasteAction; - -private: - QMenu *m_contextMenu; - - QAction *m_addVariable; - QAction *m_addScope; - QAction *m_addBlock; - - ProScopeFilter *m_filter; - ProItemInfoManager *m_infomanager; - - bool m_blockSelectionSignal; - - // used because of some strange behavior when integrated into eclipse - bool m_setFocusToListView; - bool m_shortcuts; - bool m_advanced; -}; - -} //namespace Internal -} //namespace Qt4ProjectManager - -#endif // PROEDITOR_H diff --git a/src/shared/proparser/proeditor.ui b/src/shared/proparser/proeditor.ui deleted file mode 100644 index b4daca4150a..00000000000 --- a/src/shared/proparser/proeditor.ui +++ /dev/null @@ -1,143 +0,0 @@ - - Qt4ProjectManager::Internal::ProEditor - - - - 0 - 0 - 621 - 557 - - - - - 0 - - - 6 - - - - - QAbstractItemView::NoEditTriggers - - - true - - - true - - - - - - - 0 - - - 6 - - - - - - 1 - 0 - 0 - 0 - - - - - 0 - 23 - - - - New - - - - - - - - 1 - 0 - 0 - 0 - - - - - 0 - 23 - - - - Remove - - - - - - - - 1 - 0 - 0 - 0 - - - - - 0 - 23 - - - - Up - - - - - - - - 1 - 0 - 0 - 0 - - - - - 0 - 23 - - - - Down - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - diff --git a/src/shared/proparser/proeditormodel.cpp b/src/shared/proparser/proeditormodel.cpp index dcdab35fe2a..f7fa988fc8e 100644 --- a/src/shared/proparser/proeditormodel.cpp +++ b/src/shared/proparser/proeditormodel.cpp @@ -31,7 +31,6 @@ #include "proitems.h" #include "proeditormodel.h" #include "procommandmanager.h" -#include "proiteminfo.h" #include #include @@ -236,7 +235,6 @@ private: ProEditorModel::ProEditorModel(QObject *parent) : QAbstractItemModel(parent) { - m_infomanager = 0; m_cmdmanager = new ProCommandManager(this); } @@ -244,17 +242,6 @@ ProEditorModel::~ProEditorModel() { } -void ProEditorModel::setInfoManager(ProItemInfoManager *infomanager) -{ - m_infomanager = infomanager; - reset(); -} - -ProItemInfoManager *ProEditorModel::infoManager() const -{ - return m_infomanager; -} - ProCommandManager *ProEditorModel::cmdManager() const { return m_cmdmanager; @@ -312,10 +299,6 @@ QString ProEditorModel::blockName(ProBlock *block) const // variables has a name if (block->blockKind() & ProBlock::VariableKind) { ProVariable *v = static_cast(block); - if (m_infomanager) { - if (ProVariableInfo *info = m_infomanager->variable(v->variable())) - return info->name(); - } return v->variable(); } @@ -479,13 +462,6 @@ QVariant ProEditorModel::data(const QModelIndex &index, int role) const } else if (item->kind() == ProItem::ValueKind) { ProValue *value = static_cast(item); if (role == Qt::DisplayRole) { - ProVariable *var = proVariable(index.parent()); - if (var && m_infomanager) { - if (ProVariableInfo *varinfo = m_infomanager->variable(var->variable())) { - if (ProValueInfo *valinfo = varinfo->value(value->value())) - return QVariant(valinfo->name()); - } - } return QVariant(value->value()); } else if (role == Qt::DecorationRole) { return QIcon(":/proparser/images/value.png"); @@ -497,96 +473,6 @@ QVariant ProEditorModel::data(const QModelIndex &index, int role) const return QVariant(); } -bool ProEditorModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - static bool block = false; - - if (block) - return false; - - if (role != Qt::EditRole) - return false; - - ProItem *item = proItem(index); - if (!item) - return false; - - if (item->kind() == ProItem::ValueKind) { - ProValue *val = static_cast(item); - if (val->value() == value.toString()) - return false; - - block = true; - m_cmdmanager->beginGroup(tr("Change Item")); - bool result = m_cmdmanager->command(new ProRemoveCommand(this, index)); - if (result) { - ProValue *item = new ProValue(value.toString(), proVariable(index.parent())); - result = m_cmdmanager->command(new ProAddCommand(this, item, index.row(), index.parent())); - } - block = false; - - m_cmdmanager->endGroup(); - markProFileModified(index); - emit dataChanged(index,index); - return result; - } else if (item->kind() == ProItem::BlockKind) { - ProBlock *block = proBlock(index); - if (block->blockKind() & ProBlock::VariableKind) { - ProVariable *var = static_cast(block); - if (value.type() == QVariant::Int) { - if ((int)var->variableOperator() == value.toInt()) - return false; - - m_cmdmanager->beginGroup(tr("Change Variable Assignment")); - m_cmdmanager->command(new ChangeProVariableOpCommand(this, var, - (ProVariable::VariableOperator)value.toInt())); - m_cmdmanager->endGroup(); - markProFileModified(index); - emit dataChanged(index,index); - return true; - } else { - if (var->variable() == value.toString()) - return false; - - m_cmdmanager->beginGroup(tr("Change Variable Type")); - m_cmdmanager->command(new ChangeProVariableIdCommand(this, var, - value.toString())); - m_cmdmanager->endGroup(); - markProFileModified(index); - emit dataChanged(index,index); - return true; - } - } else if (block->blockKind() & ProBlock::ScopeContentsKind) { - ProBlock *scope = block->parent(); - QString oldExp = expressionToString(scope); - if (oldExp == value.toString()) - return false; - - m_cmdmanager->beginGroup(tr("Change Scope Condition")); - m_cmdmanager->command(new ChangeProScopeCommand(this, scope, value.toString())); - m_cmdmanager->endGroup(); - markProFileModified(index); - emit dataChanged(index,index); - return true; - } else if (block->blockKind() & ProBlock::ProFileKind) { - return false; - } else { - QString oldExp = expressionToString(block); - if (oldExp == value.toString()) - return false; - - m_cmdmanager->beginGroup(tr("Change Expression")); - m_cmdmanager->command(new ChangeProAdvancedCommand(this, block, value.toString())); - m_cmdmanager->endGroup(); - markProFileModified(index); - emit dataChanged(index,index); - return true; - } - } - - return false; -} - Qt::ItemFlags ProEditorModel::flags(const QModelIndex &index) const { if (!index.isValid()) @@ -613,29 +499,6 @@ QMimeData *ProEditorModel::mimeData(const QModelIndexList &indexes) const return data; } -bool ProEditorModel::moveItem(const QModelIndex &index, int row) -{ - if (!index.isValid()) - return false; - - int oldrow = index.row(); - QModelIndex parentIndex = index.parent(); - - if (oldrow == row) - return false; - - ProItem *item = proItem(index); - - m_cmdmanager->beginGroup(tr("Move Item")); - bool result = m_cmdmanager->command(new ProRemoveCommand(this, index, false)); - if (result) - result = m_cmdmanager->command(new ProAddCommand(this, item, row, parentIndex, false)); - m_cmdmanager->endGroup(); - markProFileModified(index); - - return result; -} - bool ProEditorModel::removeModelItem(const QModelIndex &index) { if (!index.isValid()) @@ -793,14 +656,7 @@ QString ProEditorModel::expressionToString(ProBlock *block, bool display) const break; } case ProItem::ConditionKind: { ProCondition *v = static_cast(item); - if (m_infomanager && display) { - if (ProScopeInfo *info = m_infomanager->scope(v->text())) - result += info->name(); - else - result += v->text(); - } else { - result += v->text(); - } + result += v->text(); break; } case ProItem::OperatorKind: { diff --git a/src/shared/proparser/proeditormodel.h b/src/shared/proparser/proeditormodel.h index 00ba4bb7101..5f5f01e23c8 100644 --- a/src/shared/proparser/proeditormodel.h +++ b/src/shared/proparser/proeditormodel.h @@ -49,7 +49,6 @@ namespace Qt4ProjectManager { namespace Internal { class ProCommandManager; -class ProItemInfoManager; class ProEditorModel : public QAbstractItemModel { @@ -59,8 +58,6 @@ public: ProEditorModel(QObject *parent = 0); ~ProEditorModel(); - void setInfoManager(ProItemInfoManager *infomanager); - ProItemInfoManager *infoManager() const; ProCommandManager *cmdManager() const; void setProFiles(QList proFiles); @@ -69,7 +66,6 @@ public: QList findVariables(const QStringList &varname, const QModelIndex &parent = QModelIndex()) const; QList findBlocks(const QModelIndex &parent = QModelIndex()) const; - bool moveItem(const QModelIndex &index, int row); bool insertItem(ProItem *item, int row, const QModelIndex &parent); bool removeItem(const QModelIndex &index); @@ -82,7 +78,6 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); Qt::ItemFlags flags(const QModelIndex &index) const; QMimeData *mimeData(const QModelIndexList &indexes) const; @@ -105,7 +100,6 @@ private: ProCommandManager *m_cmdmanager; QList m_proFiles; QSet m_changed; - ProItemInfoManager *m_infomanager; friend class ProAddCommand; friend class ProRemoveCommand; diff --git a/src/shared/proparser/proiteminfo.cpp b/src/shared/proparser/proiteminfo.cpp deleted file mode 100644 index 165a96aea5b..00000000000 --- a/src/shared/proparser/proiteminfo.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "proiteminfo.h" - -#include - -using namespace Qt4ProjectManager::Internal; - -ProItemInfo::ProItemInfo(ProItemInfoKind kind) - : m_kind(kind) -{ } - -ProItemInfo::ProItemInfoKind ProItemInfo::kind() const -{ - return m_kind; -} - -void ProItemInfo::setId(const QString &id) -{ - m_id = id; -} - -void ProItemInfo::setName(const QString &name) -{ - m_name = name; -} - -void ProItemInfo::setDescription(const QString &desc) -{ - m_description = desc; -} - -QString ProItemInfo::id() const -{ - return m_id; -} - -QString ProItemInfo::name() const -{ - return m_name; -} - -QString ProItemInfo::description() const -{ - return m_description; -} - -ProScopeInfo::ProScopeInfo() - : ProItemInfo(ProItemInfo::Scope) -{ } - -ProValueInfo::ProValueInfo() - : ProItemInfo(ProItemInfo::Value) -{ } - -ProVariableInfo::ProVariableInfo() - : ProItemInfo(ProItemInfo::Variable) -{ - m_operator = ProVariable::SetOperator; -} - -ProVariableInfo::~ProVariableInfo() -{ - qDeleteAll(m_values.values()); -} - -void ProVariableInfo::addValue(ProValueInfo *value) -{ - m_values.insert(value->id(), value); -} - -void ProVariableInfo::setMultiple(bool multiple) -{ - m_multiple = multiple; -} - -void ProVariableInfo::setDefaultOperator(ProVariable::VariableOperator op) -{ - m_operator = op; -} - -ProValueInfo *ProVariableInfo::value(const QString &id) const -{ - return m_values.value(id, 0); -} - -QList ProVariableInfo::values() const -{ - return m_values.values(); -} - -bool ProVariableInfo::multiple() const -{ - return m_multiple; -} - -ProVariable::VariableOperator ProVariableInfo::defaultOperator() const -{ - return m_operator; -} - -ProItemInfoManager::ProItemInfoManager(QObject *parent) - : QObject(parent) -{ - load(QLatin1String(":/proparser/proiteminfo.xml")); -} - -ProItemInfoManager::~ProItemInfoManager() -{ - qDeleteAll(m_variables.values()); - qDeleteAll(m_scopes.values()); -} - -void ProItemInfoManager::addVariable(ProVariableInfo *variable) -{ - m_variables.insert(variable->id(), variable); -} - -void ProItemInfoManager::addScope(ProScopeInfo *scope) -{ - m_scopes.insert(scope->id(), scope); -} - -ProVariableInfo *ProItemInfoManager::variable(const QString &id) const -{ - return m_variables.value(id, 0); -} - -ProScopeInfo *ProItemInfoManager::scope(const QString &id) const -{ - return m_scopes.value(id, 0); -} - -QList ProItemInfoManager::scopes() const -{ - return m_scopes.values(); -} - -QList ProItemInfoManager::variables() const -{ - return m_variables.values(); -} - -bool ProItemInfoManager::load(const QString &filename) -{ - QFile file(filename); - if (!file.open(QIODevice::ReadOnly)) - return false; - - QDomDocument doc; - if (!doc.setContent(&file)) - return false; - - QDomElement root = doc.documentElement(); - if (root.nodeName() != QLatin1String("proiteminfo")) - return false; - - QDomElement child = root.firstChildElement(); - for (; !child.isNull(); child = child.nextSiblingElement()) { - if (child.nodeName() == QLatin1String("scope")) - readScope(child); - else if (child.nodeName() == QLatin1String("variable")) - readVariable(child); - } - - file.close(); - return true; -} - -void ProItemInfoManager::readItem(ProItemInfo *item, const QDomElement &data) -{ - QDomElement child = data.firstChildElement(); - for (; !child.isNull(); child = child.nextSiblingElement()) { - if (child.nodeName() == QLatin1String("id")) - item->setId(child.text()); - else if (child.nodeName() == QLatin1String("name")) - item->setName(child.text()); - else if (child.nodeName() == QLatin1String("description")) - item->setDescription(child.text()); - } -} - -void ProItemInfoManager::readScope(const QDomElement &data) -{ - ProScopeInfo *scope = new ProScopeInfo(); - readItem(scope, data); - addScope(scope); -} - -void ProItemInfoManager::readVariable(const QDomElement &data) -{ - ProVariableInfo *var = new ProVariableInfo(); - readItem(var, data); - - var->setMultiple(data.attribute(QLatin1String("multiple"), QLatin1String("false")) == QLatin1String("true")); - var->setDefaultOperator((ProVariable::VariableOperator)data.attribute(QLatin1String("operator"), - QLatin1String("3")).toInt()); - - QDomElement child = data.firstChildElement(); - for (; !child.isNull(); child = child.nextSiblingElement()) { - if (child.nodeName() == QLatin1String("value")) { - ProValueInfo *val = new ProValueInfo(); - readItem(val, child); - var->addValue(val); - } - } - - addVariable(var); -} - diff --git a/src/shared/proparser/proiteminfo.h b/src/shared/proparser/proiteminfo.h deleted file mode 100644 index 0511c51f20f..00000000000 --- a/src/shared/proparser/proiteminfo.h +++ /dev/null @@ -1,133 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef PROITEMINFO_H -#define PROITEMINFO_H - -#include -#include -#include -#include -#include - -#include "proitems.h" - -namespace Qt4ProjectManager { -namespace Internal { - -class ProItemInfo -{ -public: - enum ProItemInfoKind { - Scope, - Value, - Variable - }; - - ProItemInfo(ProItemInfoKind kind); - - ProItemInfoKind kind() const; - void setId(const QString &id); - void setName(const QString &name); - void setDescription(const QString &desc); - - QString id() const; - QString name() const; - QString description() const; - -private: - QString m_id; - QString m_name; - QString m_description; - ProItemInfoKind m_kind; -}; - -class ProScopeInfo : public ProItemInfo -{ -public: - ProScopeInfo(); -}; - -class ProValueInfo : public ProItemInfo -{ -public: - ProValueInfo(); -}; - -class ProVariableInfo : public ProItemInfo -{ -public: - ProVariableInfo(); - ~ProVariableInfo(); - - void addValue(ProValueInfo *value); - void setMultiple(bool multiple); - void setDefaultOperator(ProVariable::VariableOperator op); - - ProValueInfo *value(const QString &id) const; - - QList values() const; - bool multiple() const; - ProVariable::VariableOperator defaultOperator() const; - -private: - ProVariable::VariableOperator m_operator; - bool m_multiple; - QMap m_values; -}; - -class ProItemInfoManager : public QObject { - Q_OBJECT - -public: - ProItemInfoManager(QObject *parent); - ~ProItemInfoManager(); - - ProVariableInfo *variable(const QString &id) const; - ProScopeInfo *scope(const QString &id) const; - - QList scopes() const; - QList variables() const; - -private: - bool load(const QString &filename); - void addVariable(ProVariableInfo *variable); - void addScope(ProScopeInfo *scope); - void readItem(ProItemInfo *item, const QDomElement &data); - void readScope(const QDomElement &data); - void readVariable(const QDomElement &data); - - QMap m_scopes; - QMap m_variables; -}; - -} // namespace Internal -} // namespace Qt4ProjectManager - -#endif // PROITEMINFO_H diff --git a/src/shared/proparser/proparser.pri b/src/shared/proparser/proparser.pri index 8b274d51b28..57571968988 100644 --- a/src/shared/proparser/proparser.pri +++ b/src/shared/proparser/proparser.pri @@ -8,28 +8,19 @@ DEPENDPATH *= $$PWD $$PWD/.. HEADERS += \ abstractproitemvisitor.h \ procommandmanager.h \ - proeditor.h \ proeditormodel.h \ profileevaluator.h \ - proiteminfo.h \ proitems.h \ prowriter.h \ proxml.h \ - valueeditor.h \ $$PWD/../namespace_global.h SOURCES += \ procommandmanager.cpp \ - proeditor.cpp \ proeditormodel.cpp \ profileevaluator.cpp \ - proiteminfo.cpp \ proitems.cpp \ prowriter.cpp \ - proxml.cpp \ - valueeditor.cpp - -FORMS += proeditor.ui \ - valueeditor.ui + proxml.cpp RESOURCES += proparser.qrc diff --git a/src/shared/proparser/valueeditor.cpp b/src/shared/proparser/valueeditor.cpp deleted file mode 100644 index a805ef3cf08..00000000000 --- a/src/shared/proparser/valueeditor.cpp +++ /dev/null @@ -1,496 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "valueeditor.h" -#include "proitems.h" -#include "proeditormodel.h" -#include "proiteminfo.h" - -#include -#include - -using namespace Qt4ProjectManager::Internal; - -ValueEditor::ValueEditor(QWidget *parent) - : QWidget(parent), - m_model(0), - m_handleModelChanges(true), - m_infomanager(0) -{ - setupUi(this); -} - -ValueEditor::~ValueEditor() -{ -} - -void ValueEditor::initialize(ProEditorModel *model, ProItemInfoManager *infomanager) -{ - m_model = model; - m_infomanager = infomanager; - initialize(); -} - -void ValueEditor::hideVariable() -{ - m_varGroupBox->setVisible(false); -} - -void ValueEditor::showVariable(bool advanced) -{ - m_varComboBoxLabel->setVisible(!advanced); - m_varComboBox->setVisible(!advanced); - - m_varLineEditLabel->setVisible(advanced); - m_varLineEdit->setVisible(advanced); - - m_assignComboBoxLabel->setVisible(advanced); - m_assignComboBox->setVisible(advanced); - - m_varGroupBox->setVisible(true); -} - -void ValueEditor::setItemEditType(ItemEditType type) -{ - m_editStackWidget->setCurrentIndex(type); -} - -void ValueEditor::setDescription(ItemEditType type, const QString &header, const QString &description) -{ - switch (type) { - case MultiUndefined: - m_multiUndefinedGroupBox->setTitle(header); - m_multiUndefinedDescriptionLabel->setVisible(!description.isEmpty()); - m_multiUndefinedDescriptionLabel->setText(description); - break; - case MultiDefined: - m_multiDefinedGroupBox->setTitle(header); - m_multiDefinedDescriptionLabel->setVisible(!description.isEmpty()); - m_multiDefinedDescriptionLabel->setText(description); - break; - case SingleUndefined: - m_singleUndefinedGroupBox->setTitle(header); - m_singleUndefinedDescriptionLabel->setVisible(!description.isEmpty()); - m_singleUndefinedDescriptionLabel->setText(description); - break; - default: - m_singleDefinedGroupBox->setTitle(header); - m_singleDefinedDescriptionLabel->setVisible(!description.isEmpty()); - m_singleDefinedDescriptionLabel->setText(description); - break; - } -} - -void ValueEditor::initialize() -{ - hideVariable(); - setItemEditType(MultiUndefined); - - m_itemListView->setModel(m_model); - m_itemListView->setRootIndex(QModelIndex()); - - connect(m_itemAddButton, SIGNAL(clicked()), - this, SLOT(addItem())); - connect(m_itemRemoveButton, SIGNAL(clicked()), - this, SLOT(removeItem())); - - connect(m_itemListView->selectionModel(), - SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), - this, SLOT(updateItemList(const QModelIndex &))); - - connect(m_itemListWidget, SIGNAL(itemChanged(QListWidgetItem *)), - this, SLOT(updateItemChanges(QListWidgetItem *))); - - foreach (ProVariableInfo *varinfo, m_infomanager->variables()) { - m_varComboBox->addItem(varinfo->name(), varinfo->id()); - } - - connect(m_varLineEdit, SIGNAL(editingFinished()), this, SLOT(updateVariableId())); - connect(m_varComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateVariableId(int))); - connect(m_assignComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateVariableOp(int))); - - connect(m_itemLineEdit, SIGNAL(editingFinished()), this, SLOT(updateItemId())); - connect(m_itemComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateItemId(int))); - - connect(m_model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(modelChanged(const QModelIndex &))); - - connect(m_model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(modelChanged(const QModelIndex &))); - - connect(m_model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), - this, SLOT(modelChanged(const QModelIndex &))); - - updateItemList(QModelIndex()); -} - -void ValueEditor::modelChanged(const QModelIndex &index) -{ - if (m_handleModelChanges) { - if (m_currentIndex == index || m_currentIndex == index.parent()) - editIndex(m_currentIndex); - } -} - -void ValueEditor::editIndex(const QModelIndex &index) -{ - if (!m_model) - return; - m_currentIndex = index; - ProBlock *block = m_model->proBlock(index); - - m_varGroupBox->setEnabled(block != 0); - m_editStackWidget->setEnabled(block != 0); - - if (!block) - return; - - if (block->blockKind() & ProBlock::ScopeContentsKind) { - showScope(block); - } else if (block->blockKind() & ProBlock::VariableKind) { - showVariable(static_cast(block)); - } else { - showOther(block); - } -} - -ValueEditor::ItemEditType ValueEditor::itemType(bool defined, bool multiple) const -{ - if (defined) { - if (multiple) - return MultiDefined; - else - return SingleDefined; - } else { - if (multiple) - return MultiUndefined; - else - return SingleUndefined; - } -} - -void ValueEditor::showVariable(ProVariable *variable) -{ - if (!m_model) - return; - ProVariableInfo *info = m_infomanager->variable(variable->variable()); - - const bool advanced = (!m_model->infoManager() || (info == 0)); - bool defined = false; - bool multiple = true; - - QSet values; - foreach(ProItem *proitem, variable->items()) { - if (proitem->kind() == ProItem::ValueKind) { - ProValue *val = static_cast(proitem); - values.insert(val->value()); - } - } - - if (!advanced && info) { - defined = !info->values().isEmpty(); - - // check if all values are known - foreach(QString val, values) { - if (!info->value(val)) { - defined = false; - break; - } - } - - multiple = info->multiple(); - } - - if (values.count() > 1) - multiple = true; - - bool wasblocked; - - if (!advanced) { - const int index = m_varComboBox->findData(variable->variable(), Qt::UserRole, Qt::MatchExactly); - wasblocked = m_varComboBox->blockSignals(true); - m_varComboBox->setCurrentIndex(index); - m_varComboBox->blockSignals(wasblocked); - } else { - wasblocked = m_varLineEdit->blockSignals(true); - m_varLineEdit->setText(variable->variable()); - m_varLineEdit->blockSignals(wasblocked); - } - - ItemEditType type = itemType(defined, multiple); - - wasblocked = m_assignComboBox->blockSignals(true); - m_assignComboBox->setCurrentIndex(variable->variableOperator()); - m_assignComboBox->blockSignals(wasblocked); - - QString header = tr("Edit Values"); - QString desc; - if (info) { - header = tr("Edit %1").arg(info->name()); - desc = info->description(); - } - setDescription(type, header, desc); - - m_itemListWidget->clear(); - - switch (type) { - case MultiUndefined: { - const QModelIndex parent = m_currentIndex; - m_itemListView->setRootIndex(parent); - m_itemListView->setCurrentIndex(m_model->index(0,0,parent)); - } - break; - case MultiDefined: - wasblocked = m_itemListWidget->blockSignals(true); - - foreach(ProValueInfo *valinfo, info->values()) { - QListWidgetItem *item = new QListWidgetItem(m_itemListWidget); - item->setText(valinfo->name()); - item->setData(Qt::UserRole, valinfo->id()); - - if (values.contains(valinfo->id())) - item->setCheckState(Qt::Checked); - else - item->setCheckState(Qt::Unchecked); - } - - m_itemListWidget->blockSignals(wasblocked); - break; - case SingleUndefined: - wasblocked = m_itemLineEdit->blockSignals(true); - if (values.isEmpty()) - m_itemLineEdit->setText(QString()); - else - m_itemLineEdit->setText(values.toList().first()); - m_itemLineEdit->blockSignals(wasblocked); - break; - case SingleDefined: - wasblocked = m_itemComboBox->blockSignals(true); - m_itemComboBox->clear(); - - foreach(ProValueInfo *valinfo, info->values()) { - m_itemComboBox->addItem(valinfo->name(), valinfo->id()); - } - - int index = -1; - if (!values.isEmpty()) { - const QString id = values.toList().first(); - index = m_itemComboBox->findData(id, Qt::UserRole, Qt::MatchExactly); - } - - m_itemComboBox->setCurrentIndex(index); - m_itemComboBox->blockSignals(wasblocked); - break; - } - - showVariable(advanced); - setItemEditType(type); -} - -void ValueEditor::showScope(ProBlock *) -{ - if (!m_model) - return; - const bool wasblocked = m_itemLineEdit->blockSignals(true); - m_itemLineEdit->setText(m_model->data(m_currentIndex, Qt::EditRole).toString()); - m_itemLineEdit->blockSignals(wasblocked); - - setDescription(SingleUndefined, tr("Edit Scope")); - - hideVariable(); - setItemEditType(SingleUndefined); -} - -void ValueEditor::showOther(ProBlock *) -{ - if (!m_model) - return; - const bool wasblocked = m_itemLineEdit->blockSignals(true); - m_itemLineEdit->setText(m_model->data(m_currentIndex, Qt::EditRole).toString()); - m_itemLineEdit->blockSignals(wasblocked); - - setDescription(SingleUndefined, tr("Edit Advanced Expression")); - - hideVariable(); - setItemEditType(SingleUndefined); -} - -void ValueEditor::addItem(QString value) -{ - if (!m_model) - return; - QModelIndex parent = m_currentIndex; - ProVariable *var = static_cast(m_model->proBlock(parent)); - - if (value.isEmpty()) { - value = QLatin1String("..."); - - if (ProVariableInfo *varinfo = m_infomanager->variable(var->variable())) { - const QList vals = varinfo->values(); - if (!vals.isEmpty()) - value = vals.first()->id(); - } - } - - m_handleModelChanges = false; - m_model->insertItem(new ProValue(value, var), - m_model->rowCount(parent), parent); - - const QModelIndex idx = m_model->index(m_model->rowCount(parent)-1, 0, parent); - m_itemListView->setCurrentIndex(idx); - m_itemListView->edit(idx); - m_itemListView->scrollToBottom(); - m_handleModelChanges = true; -} - -void ValueEditor::removeItem() -{ - if (!m_model) - return; - m_handleModelChanges = false; - const QModelIndex idx = m_itemListView->currentIndex(); - m_itemListView->closePersistentEditor(idx); - m_model->removeItem(idx); - m_handleModelChanges = true; -} - -void ValueEditor::updateItemList(const QModelIndex &) -{ - if (!m_model) - return; - m_itemRemoveButton->setEnabled(m_model->rowCount(m_currentIndex)); -} - -QModelIndex ValueEditor::findValueIndex(const QString &id) const -{ - if (!m_model) - return QModelIndex(); - const QModelIndex parent = m_currentIndex; - const int rows = m_model->rowCount(parent); - - for (int row=0; rowindex(row, 0, parent); - ProItem *item = m_model->proItem(index); - if (!item || item->kind() != ProItem::ValueKind) - continue; - - if (static_cast(item)->value() == id) - return index; - } - - return QModelIndex(); -} - -void ValueEditor::updateItemChanges(QListWidgetItem *item) -{ - if (!m_model) - return; - const QModelIndex parent = m_currentIndex; - ProBlock *block = m_model->proBlock(parent); - - if (!block || !(block->blockKind() & ProBlock::VariableKind)) - return; - - ProVariable *var = static_cast(block); - const QString id = item->data(Qt::UserRole).toString(); - - m_handleModelChanges = false; - const QModelIndex index = findValueIndex(id); - if (item->checkState() == Qt::Checked && !index.isValid()) { - m_model->insertItem(new ProValue(id, var), - m_model->rowCount(parent), m_currentIndex); - } else if (item->checkState() != Qt::Checked && index.isValid()) { - m_model->removeItem(index); - } - m_handleModelChanges = true; -} - -void ValueEditor::updateVariableId() -{ - if (!m_model) - return; - m_handleModelChanges = false; - m_model->setData(m_currentIndex, QVariant(m_varLineEdit->text())); - m_handleModelChanges = true; -} - -void ValueEditor::updateVariableId(int index) -{ - if (!m_model) - return; - ProVariableInfo *info = m_infomanager->variable(m_varComboBox->itemData(index).toString()); - - m_model->setData(m_currentIndex, info->id()); - m_model->setData(m_currentIndex, info->defaultOperator()); -} - -void ValueEditor::updateVariableOp(int index) -{ - if (!m_model) - return; - m_handleModelChanges = false; - m_model->setData(m_currentIndex, QVariant(index)); - m_handleModelChanges = true; -} - -void ValueEditor::updateItemId() -{ - if (!m_model) - return; - QModelIndex index = m_currentIndex; - if (m_varGroupBox->isVisible()) { - index = m_model->index(0,0,index); - if (!index.isValid()) { - addItem(m_itemLineEdit->text()); - return; - } - } - - m_handleModelChanges = false; - m_model->setData(index, QVariant(m_itemLineEdit->text())); - m_handleModelChanges = true; -} - -void ValueEditor::updateItemId(int index) -{ - if (!m_model) - return; - QModelIndex idx = m_currentIndex; - if (m_varGroupBox->isVisible()) { - idx = m_model->index(0,0,idx); - if (!idx.isValid()) { - addItem(m_itemComboBox->itemData(index).toString()); - return; - } - } - - m_handleModelChanges = false; - m_model->setData(idx, m_itemComboBox->itemData(index)); - m_handleModelChanges = true; -} diff --git a/src/shared/proparser/valueeditor.h b/src/shared/proparser/valueeditor.h deleted file mode 100644 index 81ef2a4293b..00000000000 --- a/src/shared/proparser/valueeditor.h +++ /dev/null @@ -1,115 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef VALUEEDITOR_H -#define VALUEEDITOR_H - -#include "namespace_global.h" -#include "ui_valueeditor.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE -class ProBlock; -class ProVariable; -QT_END_NAMESPACE - -namespace Qt4ProjectManager { -namespace Internal { - -class ProEditorModel; -class ProItemInfoManager; - -class ValueEditor : public QWidget, protected Ui::ValueEditor -{ - Q_OBJECT - -public: - ValueEditor(QWidget *parent = 0); - ~ValueEditor(); - - void initialize(ProEditorModel *model, ProItemInfoManager *infomanager); - -public slots: - void editIndex(const QModelIndex &index); - -protected slots: - void modelChanged(const QModelIndex &index); - - void addItem(QString value = QString()); - void removeItem(); - - void updateItemList(const QModelIndex &item); - void updateItemChanges(QListWidgetItem *item); - - void updateVariableId(); - void updateVariableId(int index); - void updateVariableOp(int index); - - void updateItemId(); - void updateItemId(int index); - -private: - enum ItemEditType { - SingleDefined = 0, - SingleUndefined = 1, - MultiDefined = 2, - MultiUndefined = 3 - }; - - void hideVariable(); - void showVariable(bool advanced); - void setItemEditType(ItemEditType type); - void setDescription(ItemEditType type, const QString &header, const QString &desc = QString()); - - void initialize(); - - void showVariable(ProVariable *variable); - void showScope(ProBlock *scope); - void showOther(ProBlock *block); - - ItemEditType itemType(bool defined, bool multiple) const; - QModelIndex findValueIndex(const QString &id) const; - -protected: - QPointer m_model; - -private: - bool m_handleModelChanges; - - QModelIndex m_currentIndex; - ProItemInfoManager *m_infomanager; -}; - -} // namespace Internal -} // namespace Qt4ProjectManager - -#endif // VALUEEDITOR_H diff --git a/src/shared/proparser/valueeditor.ui b/src/shared/proparser/valueeditor.ui deleted file mode 100644 index 9a281035d28..00000000000 --- a/src/shared/proparser/valueeditor.ui +++ /dev/null @@ -1,384 +0,0 @@ - - Qt4ProjectManager::Internal::ValueEditor - - - - 0 - 0 - 621 - 557 - - - - - 0 - - - 6 - - - - - - 5 - 4 - 0 - 0 - - - - Edit Variable - - - - 9 - - - 6 - - - - - - 7 - 0 - 0 - 0 - - - - - - - - Variable Name: - - - - - - - Assignment Operator: - - - - - - - - - - Variable: - - - - - - - - Append (+=) - - - - - Remove (-=) - - - - - Replace (~=) - - - - - Set (=) - - - - - Unique (*=) - - - - - - - - - - - 2 - - - - - 0 - - - 6 - - - - - Select Item - - - - 9 - - - 6 - - - - - - - - true - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 0 - - - 6 - - - - - Edit Item - - - - 9 - - - 6 - - - - - - - - true - - - - - - - - 5 - 0 - 0 - 0 - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 0 - - - 6 - - - - - Select Items - - - - 9 - - - 6 - - - - - - - - true - - - - - - - - - - - - - - - 0 - - - 6 - - - - - Edit Items - - - - 9 - - - 6 - - - - - - - - true - - - - - - - 0 - - - 6 - - - - - true - - - - - - - 0 - - - 6 - - - - - - 1 - 0 - 0 - 0 - - - - - 0 - 23 - - - - New - - - - - - - - 1 - 0 - 0 - 0 - - - - - 0 - 23 - - - - Remove - - - - - - - Qt::Vertical - - - - 44 - 128 - - - - - - - - - - - - - - - - - - - -