Skip to content

Commit

Permalink
Add model to tree view
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jul 11, 2011
1 parent c0c4b54 commit e13fb8a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
23 changes: 21 additions & 2 deletions src/gui/qgsexpressionbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 );
}
}

Expand All @@ -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);
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/gui/qgsexpressionbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
5 changes: 4 additions & 1 deletion src/ui/qgsexpressionbuilder.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit e13fb8a

Please sign in to comment.