Exemple #1
0
void RawEditorWidget::customContextMenuRequested(const QPoint &pos)
{
	QTreeWidgetItem *it;
	it=(QTreeWidgetItem *)m_pTreeWidget->itemAt(pos);
	KVI_ASSERT(m_bOneTimeSetupDone);
	m_pContextPopup->clear();
	if(it)
	{
		if(it->parent())
		{
			if(!(((RawHandlerTreeWidgetItem *)it)->m_bEnabled))
				m_pContextPopup->addAction(
					*(g_pIconManager->getSmallIcon(KviIconManager::Handler)),
					__tr2qs_ctx("&Enable Handler","editor"),this,SLOT(toggleCurrentHandlerEnabled()));
			else
				m_pContextPopup->addAction(
					*(g_pIconManager->getSmallIcon(KviIconManager::HandlerDisabled)),
					__tr2qs_ctx("&Disable Handler","editor"),this,SLOT(toggleCurrentHandlerEnabled()));

			m_pContextPopup->addAction(
					*(g_pIconManager->getSmallIcon(KviIconManager::Discard)),
					__tr2qs_ctx("Re&move Handler","editor"),
					this,SLOT(removeCurrentHandler()));
			m_pContextPopup->addAction(
					*(g_pIconManager->getSmallIcon(KviIconManager::Save)),
					__tr2qs_ctx("&Export Handler to...","editor"),
					this,SLOT(exportCurrentHandler()));
		} else {
			m_pContextPopup->addAction(
				*(g_pIconManager->getSmallIcon(KviIconManager::Handler)),
				__tr2qs_ctx("&New Handler","editor"),
				this,SLOT(addHandlerForCurrentRaw()));
		}
	}

	m_pContextPopup->addSeparator();
	m_pContextPopup->addAction(
			*(g_pIconManager->getSmallIcon(KviIconManager::RawEvent)),
			__tr2qs_ctx("&Add RAW Event...","editor"),
			this,SLOT(addRaw()));
        m_pContextPopup->popup(mapToGlobal(QPoint(pos.x()+15,pos.y())));
}
void EventEditor::itemPressed(QTreeWidgetItem * it, const QPoint & pnt)
{
	KVI_ASSERT(m_bOneTimeSetupDone);

	if(it)
	{
		m_pContextPopup->clear();
		if(it->parent())
		{
			QString tmp;
			if(!(((EventEditorHandlerTreeWidgetItem *)it)->m_bEnabled))
				m_pContextPopup->addAction(
				    *(g_pIconManager->getSmallIcon(KviIconManager::Handler)),
				    __tr2qs_ctx("&Enable Handler", "editor"), this, SLOT(toggleCurrentHandlerEnabled()));
			else
				m_pContextPopup->addAction(
				    *(g_pIconManager->getSmallIcon(KviIconManager::HandlerDisabled)),
				    __tr2qs_ctx("&Disable Handler", "editor"), this, SLOT(toggleCurrentHandlerEnabled()));

			m_pContextPopup->addAction(
			    *(g_pIconManager->getSmallIcon(KviIconManager::Discard)),
			    __tr2qs_ctx("Re&move Handler", "editor"),
			    this, SLOT(removeCurrentHandler()));
			m_pContextPopup->addAction(
			    *(g_pIconManager->getSmallIcon(KviIconManager::Save)),
			    __tr2qs_ctx("&Export Handler to...", "editor"),
			    this, SLOT(exportCurrentHandler()));
		}
		else
		{
			m_pContextPopup->addAction(
			    *(g_pIconManager->getSmallIcon(KviIconManager::Handler)),
			    __tr2qs_ctx("&New Handler", "editor"),
			    this, SLOT(addHandlerForCurrentEvent()));
		}

		m_pContextPopup->popup(pnt);
	}
}