27 #include "../../../../common/Translator.h"
28 #include "../../../../dataaccess/datasource/DataSourceInfoManager.h"
29 #include "../../../../dataaccess/query/Expression.h"
30 #include "../../../../dataaccess/query/Select.h"
31 #include "../../../../dataaccess/query/Where.h"
32 #include "../../../../maptools/QueryLayer.h"
33 #include "../../../../se/Style.h"
34 #include "../../Exception.h"
41 #include <boost/algorithm/string/replace.hpp>
67 if(role == Qt::DecorationRole)
68 return QVariant(QIcon::fromTheme(
"query-layer"));
70 if(role == Qt::DisplayRole)
71 return QVariant(QString::fromUtf8(m_layer->getTitle().c_str()));
73 if(role == Qt::CheckStateRole)
74 return QVariant(m_layer->getVisibility() ==
te::map::VISIBLE ? Qt::Checked : Qt::Unchecked);
76 if (role == Qt::ToolTipRole)
77 return buildToolTip();
96 return (((m_layer->getStyle() != 0) && (!m_layer->getStyle()->getRules().empty())) || m_layer->getGrouping() != 0 || m_layer->getChart() != 0);
101 return Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;;
106 if(m_layer->getStyle() && children().empty())
108 const std::vector<te::se::Rule*>& rules = m_layer->getStyle()->getRules();
110 for(std::size_t i = 0; i != rules.size(); ++i)
114 if(m_layer->getGrouping() && !hasGroupingItem())
117 if(m_layer->getChart() && !hasChartItem())
118 new ChartItem(m_layer->getChart(),
this);
123 return (m_layer->getStyle() != 0) && (m_layer->getStyle()->getRules().empty() ==
false);
128 if(role == Qt::CheckStateRole)
130 Qt::CheckState checkState =
static_cast<Qt::CheckState
>(value.toInt());
131 if(checkState == Qt::Checked)
133 else if(checkState == Qt::Unchecked)
136 m_layer->updateVisibilityOfAncestors();
151 return "QUERY_LAYER_ITEM";
156 GroupingItem* groupingItem = findChild<GroupingItem*>();
158 return groupingItem != 0;
163 ChartItem* chartItem = findChild<ChartItem*>();
165 return chartItem != 0;
170 if (!m_layer->isValid())
171 return tr(
"Invalid Layer");
176 const std::string&
id = m_layer->getDataSourceId();
178 const std::map<std::string, std::string>& connInfo = info->getConnInfo();
180 toolTip += tr(
"Connection Info") +
":\n";
183 std::map<std::string, std::string>::const_iterator it;
184 for (it = connInfo.begin(); it != connInfo.end(); ++it)
186 toolTip += it->first.c_str();
188 toolTip += it->second.c_str();
190 if (i != connInfo.size())
196 toolTip += tr(
"SRID: ");
197 toolTip += QString::number(m_layer->getSRID());
202 toolTip += tr(
"Restriction: ");
203 std::string query = m_layer->getQueryAsString();
204 boost::replace_all(query,
", ",
",\n");
206 toolTip += QString::fromStdString(query);
A layer resulting from a query.
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
A class that represents a chart of a layer in a LayerTreeModel.
The class that represents a query layer item in a LayerTreeModel.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr