mapnik/demo/viewer/layer_info_dialog.cpp

72 lines
2.3 KiB
C++
Raw Permalink Normal View History

/* This file is part of Mapnik (c++ mapping toolkit)
2011-10-23 16:09:12 +02:00
*
2021-01-05 15:39:07 +01:00
* Copyright (C) 2021 Artem Pavlenko
*
* Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2016-01-26 10:54:42 +01:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "layer_info_dialog.hpp"
// mapnik
#include <mapnik/datasource.hpp>
#include <mapnik/params.hpp>
#include <mapnik/params_impl.hpp>
#include <mapnik/layer.hpp>
2022-01-26 23:34:08 +01:00
layer_info_dialog::layer_info_dialog(mapnik::layer& lay, QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
2011-10-23 16:09:12 +02:00
2022-01-26 23:34:08 +01:00
ui.tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem("Name"));
ui.tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
2011-10-23 16:09:12 +02:00
// Layer name
ui.layerNameEdit->setText(QString(lay.name().c_str()));
// Named Styles : TODO!!!
2011-10-23 16:09:12 +02:00
// Datasource
mapnik::datasource_ptr ds = lay.datasource();
if (ds)
{
2011-05-04 17:53:36 +02:00
mapnik::parameters ps = ds->params();
ui.tableWidget->setRowCount(ps.size());
2011-05-04 17:53:36 +02:00
ui.tableWidget->setColumnCount(2);
2011-05-04 17:53:36 +02:00
mapnik::parameters::const_iterator pos;
2022-01-26 23:34:08 +01:00
int index = 0;
for (pos = ps.begin(); pos != ps.end(); ++pos)
2011-05-04 17:53:36 +02:00
{
boost::optional<std::string> result;
2022-01-26 23:34:08 +01:00
mapnik::util::apply_visitor(mapnik::value_extractor_visitor<std::string>(result), pos->second);
2011-05-04 17:53:36 +02:00
if (result)
{
2022-01-26 23:34:08 +01:00
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);
2011-05-04 17:53:36 +02:00
++index;
}
2011-10-23 16:09:12 +02:00
}
}
}
Ui::LayerInfoDialog& layer_info_dialog::getUI()
{
2022-01-26 23:34:08 +01:00
return ui;
}