27 #include "../../../../common/Translator.h"
28 #include "../../../../dataaccess/datasource/DataSourceInfoManager.h"
29 #include "../../../../maptools/DataSetAdapterLayer.h"
30 #include "../../../../se/Style.h"
31 #include "../../Exception.h"
58 if(role == Qt::DecorationRole)
60 if(m_layer->isValid())
61 return QVariant(QIcon::fromTheme(
"dataset-layer-tabular"));
63 return QVariant(QIcon::fromTheme(
"dataset-layer-invalid"));
66 if(role == Qt::DisplayRole)
67 return QVariant(QString::fromStdString(m_layer->getTitle()));
69 if(role == Qt::CheckStateRole)
70 return QVariant(m_layer->getVisibility() ==
te::map::VISIBLE ? Qt::Checked : Qt::Unchecked);
72 if(role == Qt::ToolTipRole)
73 return buildToolTip();
85 return (((m_layer->getStyle() != 0) && (!m_layer->getStyle()->getRules().empty())) || m_layer->getGrouping() != 0 || m_layer->getChart() != 0);
90 return Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
95 if(m_layer->getStyle() && children().empty())
97 const std::vector<te::se::Rule*>& rules = m_layer->getStyle()->getRules();
99 for(std::size_t i = 0; i != rules.size(); ++i)
103 if(m_layer->getGrouping() && !hasGroupingItem())
106 if(m_layer->getChart() && !hasChartItem())
107 new ChartItem(m_layer->getChart(),
this);
112 return ((m_layer->getStyle() != 0) && (!m_layer->getStyle()->getRules().empty())) || m_layer->getGrouping() != 0 || m_layer->getChart() != 0;
117 if(role == Qt::CheckStateRole)
119 Qt::CheckState checkState =
static_cast<Qt::CheckState
>(value.toInt());
121 if(checkState == Qt::Checked)
123 else if(checkState == Qt::Unchecked)
126 m_layer->updateVisibilityOfAncestors();
141 return "DATASET_ADAPTER_LAYER_ITEM";
146 GroupingItem* groupingItem = findChild<GroupingItem*>();
148 return groupingItem != 0;
153 ChartItem* chartItem = findChild<ChartItem*>();
155 return chartItem != 0;
160 if(!m_layer->isValid())
161 return tr(
"Invalid Layer");
166 toolTip += tr(
"DataSet") +
": " + m_layer->getDataSetName().c_str() +
"\n";
169 const std::string&
id = m_layer->getDataSourceId();
171 const std::map<std::string, std::string>& connInfo = info->getConnInfo();
173 toolTip += tr(
"Connection Info") +
":\n";
176 std::map<std::string, std::string>::const_iterator it;
177 for(it = connInfo.begin(); it != connInfo.end(); ++it)
179 toolTip += it->first.c_str();
181 toolTip += it->second.c_str();
183 if(i != connInfo.size())
The class that represents a dataset adapter layer item in a LayerTreeModel.
A layer with reference to a DataSetTypeConverter.
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
A class that represents a chart of a layer in a LayerTreeModel.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr