Skip to content
Permalink
Browse files

Add model to tree view

  • Loading branch information
NathanW2 committed Jul 11, 2011
1 parent c0c4b54 commit e13fb8a4c351a308c7edd14420a882427d4c3d4e
Showing with 33 additions and 3 deletions.
  1. +21 −2 src/gui/qgsexpressionbuilder.cpp
  2. +8 −0 src/gui/qgsexpressionbuilder.h
  3. +4 −1 src/ui/qgsexpressionbuilder.ui
@@ -16,12 +16,20 @@
#include "qgsexpressionbuilder.h"
#include "ui_qgsexpressionbuilder.h"


QgsExpressionBuilderWidget::QgsExpressionBuilderWidget(QgsVectorLayer *layer)
: QWidget(),
mLayer( layer )
{
setupUi(this);
if (!layer) return;
mModel = new QStandardItemModel();
expressionTree->setModel(mModel);
QStandardItem* operators = new QStandardItem('Operators');
mModel->appendRow(operators);
//mExpressionGroups.insert("Operators",operators);

//this->registerFunction("Operators","+"," + ");
}

QgsExpressionBuilderWidget::~QgsExpressionBuilderWidget()
@@ -49,7 +57,7 @@ void QgsExpressionBuilderWidget::loadFieldNames()

//insert into field list and field combo box
//mFieldMap.insert( fieldName, fieldIt.key() );
mFieldsListWidget->addItem( fieldName );
//mFieldsListWidget->addItem( fieldName );
}
}

@@ -61,7 +69,18 @@ void QgsExpressionBuilderWidget::fillFieldValues(int fieldIndex, int countLimit)

foreach(QVariant value, values)
{
mValueListWidget->addItem(value.toString());
//mValueListWidget->addItem(value.toString());
}
}

void QgsExpressionBuilderWidget::registerFunction(QString group, QString label, QString expressionText)
{
// Look up the group and insert the new function.
if (mExpressionGroups.contains(group))
{
QStandardItem* groupNode = mExpressionGroups.value(group);
QStandardItem* item = new QStandardItem(label);
groupNode->appendRow(item);
}
}

@@ -20,6 +20,9 @@
#include "ui_qgsexpressionbuilder.h"
#include "qgsvectorlayer.h"

#include "QStandardItemModel"
#include "QStandardItem"

class QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExpressionBuilder {
Q_OBJECT
public:
@@ -30,10 +33,15 @@ class QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExpressionBuil
void fillFieldValues(int fieldIndex, int countLimit);
QString getExpressionString();
void setExpressionString(const QString expressionString);
void registerFunction(QString group, QString label, QString expressionText);

public slots:
void on_mAllPushButton_clicked();

private:
QgsVectorLayer* mLayer;
QStandardItemModel* mModel;
QMap<QString, QStandardItem*> mExpressionGroups;
};

#endif // QGSEXPRESSIONBUILDER_H
@@ -27,13 +27,16 @@
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTreeView" name="treeView">
<widget class="QTreeView" name="expressionTree">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="uniformRowHeights">
<bool>false</bool>
</property>

0 comments on commit e13fb8a

Please sign in to comment.
You can’t perform that action at this time.