Example #1
0
void DataManager::getAnnotations(AnnotationVector& out_annotations) const
{
  out_annotations.reserve(_annotations.size());

  Threading::ScopedReadLock lock(const_cast<DataManager*>(this)->_dataMutex);
  for(AnnotationVector::const_iterator it = _annotations.begin(); it != _annotations.end(); ++it)
    out_annotations.push_back(it->get());
}
Example #2
0
void MapCatalogWidget::onTreeSelectionChanged()
{
  if (_fields & ANNOTATIONS && !_updating && _manager.valid())
  {
    AnnotationVector annos;

    QList<QTreeWidgetItem*> items = _tree->selectedItems();
    for (QList<QTreeWidgetItem*>::iterator it = items.begin(); it != items.end(); ++it)
    {
      AnnotationTreeItem* annoItem = dynamic_cast<AnnotationTreeItem*>(*it);
      if (annoItem)
        annos.push_back(annoItem->getAnnotation());
    }

    _manager->setSelectedAnnotations(annos);
  }
}
Example #3
0
void DataManager::setSelectedAnnotations(const AnnotationVector& annotations)
{
  if (_selection.size() == 0 && annotations.size() == 0)
    return;

  clearSelectedAnnotations();

  {
    Threading::ScopedWriteLock lock(const_cast<DataManager*>(this)->_dataMutex);

    for (AnnotationVector::const_iterator itNew = annotations.begin(); itNew != annotations.end(); ++itNew)
    {
      (*itNew)->setDecoration(_selectedDecoration);
      _selection.push_back(*itNew);
    }
  }

  emit selectionChanged();
}
Example #4
0
void MapCatalogWidget::refreshAnnotations()
{
  bool wasUpdating = _updating;
  _updating = true;

  if (_manager.valid() && (_fields & ANNOTATIONS))
  {
    if (!_annotationsItem)
    {
      _annotationsItem = new QTreeWidgetItem();
      //_annotationsItem->setIcon(0, QIcon(":/resources/images/globe.png"));
	    _annotationsItem->setText(0, "Annotations");
	    _tree->addTopLevelItem(_annotationsItem);
      _annotationsItem->setExpanded(true);
    }

    _annotationsItem->takeChildren();

    AnnotationVector annos;
    _manager->getAnnotations(annos);
    for (AnnotationVector::const_iterator it = annos.begin(); it != annos.end(); ++it)
    {
      AnnotationTreeItem* annoItem = new AnnotationTreeItem(*it, _map);
      annoItem->setText(0, QString(((*it)->getAnnotationData() ? (*it)->getAnnotationData()->getName().c_str() : "Annotation")));
			annoItem->setCheckState(0, (*it)->getNodeMask() != 0 ? Qt::Checked : Qt::Unchecked);

			_annotationsItem->addChild(annoItem);

      if (_manager->isSelected(*it))
        annoItem->setSelected(true);
    }

    _annotationsItem->setHidden(_hideEmptyGroups && _annotationsItem->childCount() == 0);
  }

  _updating = wasUpdating;
}