AnnotationImagePaletteWidget::AnnotationImagePaletteWidget(QWidget* pParent) : QToolBox(pParent) { mDesktopAttachments.addSignal(SIGNAL_NAME(DesktopServices, WindowAdded), Slot(this, &AnnotationImagePaletteWidget::windowAdded)); mDesktopAttachments.addSignal(SIGNAL_NAME(DesktopServices, WindowRemoved), Slot(this, &AnnotationImagePaletteWidget::windowRemoved)); mDesktopAttachments.reset(Service<DesktopServices>().get()); std::vector<Window*> windows; Service<DesktopServices>()->getWindows(SPATIAL_DATA_WINDOW, windows); for (std::vector<Window*>::iterator window = windows.begin(); window != windows.end(); ++window) { SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(*window); if (pWindow != NULL) { pWindow->getWidget()->installEventFilter(this); pWindow->getWidget()->setAcceptDrops(true); mWindows.insert(pWindow); } } setContextMenuPolicy(Qt::ActionsContextMenu); QAction* pRefreshAction = new QAction("Refresh", this); pRefreshAction->setAutoRepeat(false); addAction(pRefreshAction); VERIFYNR(connect(pRefreshAction, SIGNAL(triggered()), this, SLOT(refresh()))); setMinimumHeight(50); }
void AnnotationImagePaletteWidget::windowAdded(Subject& subject, const std::string& signal, const boost::any& val) { SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(boost::any_cast<Window*>(val)); if (pWindow != NULL) { pWindow->getWidget()->installEventFilter(this); pWindow->getWidget()->setAcceptDrops(true); mWindows.insert(pWindow); } }
AnnotationImagePaletteWidget::~AnnotationImagePaletteWidget() { for (std::set<Window*>::iterator window = mWindows.begin(); window != mWindows.end(); ++window) { SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(*window); pWindow->getWidget()->removeEventFilter(this); // Don't disable drops in case another plug-in is expecting drops enabled } }
void AnnotationImagePaletteWidget::windowRemoved(Subject& subject, const std::string& signal, const boost::any& val) { SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(boost::any_cast<Window*>(val)); if (pWindow != NULL) { pWindow->getWidget()->removeEventFilter(this); // Don't disable drops in case another plug-in is expecting drops enabled } mWindows.erase(boost::any_cast<Window*>(val)); }