27 #include "../../../../common/Translator.h"
28 #include "../../../../maptools/DataSetAdapterLayer.h"
29 #include "../../../../se/Style.h"
30 #include "../../Exception.h"
37 #include <QtGui/QMenu>
38 #include <QtGui/QWidget>
57 if(role == Qt::DecorationRole)
58 return QVariant(QIcon::fromTheme(
"dataset-layer"));
60 if(role == Qt::DisplayRole)
61 return QVariant(QString::fromStdString(m_layer->getTitle()));
63 if(role == Qt::CheckStateRole)
64 return QVariant(m_layer->getVisibility() ==
te::map::VISIBLE ? Qt::Checked : Qt::Unchecked);
76 return (((m_layer->getStyle() != 0) && (!m_layer->getStyle()->getRules().empty())) || m_layer->getGrouping() != 0 || m_layer->getChart() != 0);
81 return Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
86 if(m_layer->getStyle() && children().empty())
88 const std::vector<te::se::Rule*>& rules = m_layer->getStyle()->getRules();
90 for(std::size_t i = 0; i != rules.size(); ++i)
94 if(m_layer->getGrouping() && !hasGroupingItem())
97 if(m_layer->getChart() && !hasChartItem())
103 return ((m_layer->getStyle() != 0) && (!m_layer->getStyle()->getRules().empty())) || m_layer->getGrouping() != 0 || m_layer->getChart() != 0;
108 if(role == Qt::CheckStateRole)
110 Qt::CheckState checkState =
static_cast<Qt::CheckState
>(value.toInt());
112 if(checkState == Qt::Checked)
114 else if(checkState == Qt::Unchecked)
117 m_layer->updateVisibilityOfAncestors();
132 return "DATASET_ADAPTER_LAYER_ITEM";
137 GroupingItem* groupingItem = findChild<GroupingItem*>();
139 return groupingItem != 0;
144 ChartItem* chartItem = findChild<ChartItem*>();
146 return chartItem != 0;
~DataSetAdapterLayerItem()
bool canFetchMore() const
QVariant data(int column, int role) const
A class that represents a legend item of a layer in a LayerTreeModel.
QMenu * getMenu(QWidget *parent=0) const
const std::string getItemType() const
It returns the item type.
bool hasChartItem() const
A class that represents a grouping of a layer in a LayerTreeModel.
bool hasGroupingItem() const
Qt::ItemFlags flags() const
The class that represents an item in a LayerTreeModel.
te::map::AbstractLayerPtr getLayer() const
A layer with reference to a DataSetTypeConverter.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
A class that represents a chart of a layer in a LayerTreeModel.
bool setData(int column, const QVariant &value, int role=Qt::EditRole)
te::map::DataSetAdapterLayerPtr m_layer
DataSetAdapterLayerItem(const te::map::AbstractLayerPtr &l, QObject *parent=0)
The class that represents a dataset adapter layer item in a LayerTreeModel.