diff --git a/demo/viewer/forms/layer_info.ui b/demo/viewer/forms/layer_info.ui index ea9aaf740..eded7712d 100644 --- a/demo/viewer/forms/layer_info.ui +++ b/demo/viewer/forms/layer_info.ui @@ -1,60 +1,69 @@ - + + Artem Pavlenko LayerInfoDialog - - - + + + + 0 + 0 + 446 + 344 + + + + 0 0 - + Layer Info - + false - - - - - + + + + + - - + + Name: - + - - + + - - + + Styles: - + - - + + - - - + + + Qt::Horizontal - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -62,7 +71,6 @@ - @@ -71,11 +79,11 @@ LayerInfoDialog accept() - + 248 254 - + 157 274 @@ -87,11 +95,11 @@ LayerInfoDialog reject() - + 316 260 - + 286 274 diff --git a/demo/viewer/layer_info_dialog.cpp b/demo/viewer/layer_info_dialog.cpp index 082bad24d..321b62248 100644 --- a/demo/viewer/layer_info_dialog.cpp +++ b/demo/viewer/layer_info_dialog.cpp @@ -20,22 +20,48 @@ #include "layer_info_dialog.hpp" -layer_info_dialog::layer_info_dialog(QVector > const& info, QWidget *parent) +// mapnik +#include + + +layer_info_dialog::layer_info_dialog(mapnik::layer& lay, QWidget *parent) : QDialog(parent) { - ui.setupUi(this); - //ui.tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem("Name")); - //ui.tableWidget->setHorizontalHeaderItem(1,new QTableWidgetItem("Value")); - - ui.tableWidget->setRowCount(info.size()); - ui.tableWidget->setColumnCount(2); - for (int i=0;isetItem(i,0,keyItem); - ui.tableWidget->setItem(i,1,valueItem); - } + ui.setupUi(this); + + ui.tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem("Name")); + ui.tableWidget->setHorizontalHeaderItem(1,new QTableWidgetItem("Value")); + + // Layer name + ui.layerNameEdit->setText(QString(lay.name().c_str())); + + // Named Styles : TODO!!! + + // Datasource + mapnik::datasource_ptr ds = lay.datasource(); + if (ds) + { + mapnik::parameters ps = ds->params(); + + ui.tableWidget->setRowCount(ps.size()); + ui.tableWidget->setColumnCount(2); + + mapnik::parameters::const_iterator pos; + int index=0; + for (pos = ps.begin();pos != ps.end();++pos) + { + boost::optional result; + boost::apply_visitor(mapnik::value_extractor_visitor(result),pos->second); + if (result) + { + QTableWidgetItem *keyItem = new QTableWidgetItem(QString(pos->first.c_str())); + QTableWidgetItem *valueItem = new QTableWidgetItem(QString((*result).c_str())); + ui.tableWidget->setItem(index,0,keyItem); + ui.tableWidget->setItem(index,1,valueItem); + ++index; + } + } + } } Ui::LayerInfoDialog& layer_info_dialog::getUI() diff --git a/demo/viewer/layer_info_dialog.hpp b/demo/viewer/layer_info_dialog.hpp index ab9175e76..487f6b1f9 100644 --- a/demo/viewer/layer_info_dialog.hpp +++ b/demo/viewer/layer_info_dialog.hpp @@ -25,12 +25,17 @@ #include "ui_layer_info.h" #include +namespace mapnik +{ +struct layer; +} + class layer_info_dialog : public QDialog { Q_OBJECT public: - layer_info_dialog(QVector > const& params,QWidget * parent = 0); - Ui::LayerInfoDialog& getUI(); + layer_info_dialog(mapnik::layer& l, QWidget * parent = 0); + Ui::LayerInfoDialog& getUI(); private: Ui::LayerInfoDialog ui; }; diff --git a/demo/viewer/layerwidget.cpp b/demo/viewer/layerwidget.cpp index 15c49bb4a..c5402b53d 100644 --- a/demo/viewer/layerwidget.cpp +++ b/demo/viewer/layerwidget.cpp @@ -77,46 +77,15 @@ void LayerTab::layerInfo2(QModelIndex const& index) { qDebug("LayerInfo id = %d",index.row()); QVector > params; + QVector style_names; unsigned i = index.row(); LayerListModel * model = static_cast(this->model()); boost::optional layer = model->map_layer(i); if (layer) { - mapnik::datasource_ptr ds = (*layer).datasource(); - if (ds) - { - mapnik::parameters ps = ds->params(); - - //mapnik::parameters::extract_iterator_type itr = ps.extract_begin(); - //mapnik::parameters::extract_iterator_type end = ps.extract_end(); - - //for (;itr != end;++itr) - //{ - //if (itr->second) - // { - /// params.push_back(QPair(itr->first.c_str(),itr->first.c_str())); - // } - //} - - - mapnik::parameters::const_iterator pos; - - for (pos = ps.begin();pos != ps.end();++pos) - { - boost::optional result; - boost::apply_visitor(mapnik::value_extractor_visitor(result),pos->second); - if (result) - { - params.push_back(QPair(pos->first.c_str(),(*result).c_str())); - } - } - } - layer_info_dialog dlg(params,this); - dlg.getUI().layerNameEdit->setText(QString((*layer).name().c_str())); - - - dlg.exec(); + layer_info_dialog dlg(*layer,this); + dlg.exec(); } }