Example #1
0
bool NoteItem::eventFilter(QObject *obj, QEvent *ev)
{
    QEvent::Type type = ev->type();
    QObject* textBrowser = findChild<QObject *>("contentWidget");
    switch(type) {
        case QEvent::MouseButtonDblClick:
            setActiveItem(this);
            g_mainWindow->editActiveNote();
            return true;
        case QEvent::MouseButtonPress:
        case QEvent::FocusIn:
            if(s_activeNote != this){
                setActiveItem(this);
            }
            break;
        case QEvent::KeyPress:
            if(obj==textBrowser && s_activeNote == this){
                QKeyEvent *keyEvent = static_cast<QKeyEvent*>(ev);
                int k = keyEvent->key();
                if(m_readOnly || keyEvent->modifiers() == Qt::AltModifier) {
                    return shortCut(k);
                }
            }
            break;
        default:
            break;
    }
    return QFrame::eventFilter(obj,ev);
}
void CNavigationDiagramView::contentsMousePressEvent(QMouseEvent * e){
	QWMatrix matrix = inverseWorldMatrix();
	int xPos = matrix.m11() * e->pos().x() + matrix.m12() * e->pos().y();
	int yPos = matrix.m21() * e->pos().x() + matrix.m22() * e->pos().y();
	QPoint p(xPos, yPos);

	QCanvasItemList items = canvas()->collisions(p);
	if (items.empty()){
		setActiveItem(0);
	}else{
		setActiveItem(*items.begin());
	}
	m_qLastPos = e->pos();
}
Example #3
0
/**
 * Sets the active session item
 * called from the global update handler in msgdialog/group room window
 * on every tab activation to ensure consistency
 *
 * @param dat    _MessageWindowData*: session data
 *
 * @return The previously active item (that can be zero)
 */
const CSideBarButton* CSideBar::setActiveItem(const TWindowData *dat)
{
	CSideBarButton *item = findSession(dat);
	if (item != NULL)
		return setActiveItem(item);

	return 0;
}
Example #4
0
void Scene::removeGroup(LayerGroup *group)
{
	if(group == NULL)
		return;

	int index = indexOfGroup(group);
	if(index < 0)
		return; // Not in scene
	const GroupInfo &info = m_groups.at(index);

	// Clean up
	SceneItem *groupItem = info.sceneItem;
	if(getActiveItem() == groupItem)
		setActiveItem(NULL);
	if(m_isVisible && info.isVisible)
		group->derefVisible();

	// Disconnect to group signals. If the object is destructing then
	// disconnecting results in crashing.
	if(!m_isDestructing) {
		disconnect(group, &LayerGroup::groupChanged,
			this, &Scene::groupChanged);
		disconnect(group, &LayerGroup::layerAdded,
			this, &Scene::layerAdded);
		disconnect(group, &LayerGroup::destroyingLayer,
			this, &Scene::destroyingLayer);
		disconnect(group, &LayerGroup::layerMoved,
			this, &Scene::layerMoved);
		disconnect(group, &LayerGroup::layerChanged,
			this, &Scene::layerChanged);
	}

	// Remove group and layer scene items
	emit removingItem(groupItem); // Expected to be first
	delete groupItem;
	const LayerList &layers = group->getLayers();
	for(int i = 0; i < layers.size(); i++) {
		Layer *layer = layers.at(i);
		emit removingItem(m_layerSceneItems[layer]);
		m_layerSceneItems.remove(layer);
	}

	// Actually remove from the group list
	m_groups.remove(index);

	// As we cannot detect if the shared state has changed when a scene is
	// deleted we just blindly assume that if a group is no longer shared then
	// its shared state has changed.
	if(!group->isShared())
		group->groupChanged(group); // Remote emit

	// Delete any group that is no longer in a scene. We don't do this while
	// destructing as this scene object has already been removed from the
	// profile meaning the second and later groups will be pruned before we
	// dereference them here.
	if(!m_isDestructing)
		m_profile->pruneLayerGroups();
}
Example #5
0
// This popup is much more useful from keyboard if it has the active
// window active by default - however, TQPopupMenu tries hard to resist.
// TQPopupMenu::popup() resets the active item, so this needs to be
// called after popup().
void KWindowListMenu::selectActiveWindow()
{
    for( unsigned int i = 0;
         i < count();
         ++i )
        if( isItemChecked( idAt( i )))
            {
            setActiveItem( i );
            break;
            }
}
Example #6
0
void CSideBar::Init()
{
	m_iTopButtons = m_iBottomButtons = 0;
	m_topHeight = m_bottomHeight = 0;
	m_firstVisibleOffset = 0;
	m_totalItemHeight = 0;

	m_uLayout = (m_pContainer->dwFlagsEx & 0xff000000) >> 24;
	m_uLayout = ((m_uLayout < NR_LAYOUTS) ? m_uLayout : 0);

	m_currentLayout = &m_layouts[m_uLayout];

	m_dwFlags = m_currentLayout->dwFlags;

	m_dwFlags = (m_pContainer->dwFlagsEx & TCF_SBARLEFT ? m_dwFlags | SIDEBARORIENTATION_LEFT : m_dwFlags & ~SIDEBARORIENTATION_LEFT);
	m_dwFlags = (m_pContainer->dwFlagsEx & TCF_SBARRIGHT ? m_dwFlags | SIDEBARORIENTATION_RIGHT : m_dwFlags & ~SIDEBARORIENTATION_RIGHT);

	if (m_pContainer->dwFlags & CNT_SIDEBAR) {
		if (m_hwndScrollWnd == 0)
			m_hwndScrollWnd = ::CreateWindowEx(0, _T("TS_SideBarClass"), _T(""), WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | WS_CHILD,
				0, 0, m_width, 40, m_pContainer->hwnd, reinterpret_cast<HMENU>(5000), g_hInst, this);

		m_isActive = true;
		m_isVisible = m_isActive ? m_isVisible : true;
		createScroller();
		m_elementHeight = m_currentLayout->height;
		m_elementWidth = m_currentLayout->width;
		m_width = m_elementWidth + 4;
		populateAll();
		if (m_activeItem)
			setActiveItem(m_activeItem);
	}
	else {
		destroyScroller();
		m_width = 0;
		m_isActive = m_isVisible = false;
		m_activeItem = 0;

		removeAll();
		if (m_hwndScrollWnd)
			::DestroyWindow(m_hwndScrollWnd);
		m_hwndScrollWnd = 0;
	}
}
Example #7
0
void KPopupMenu::keyPressEvent(QKeyEvent* e)
{
    if (!d->shortcuts) {
        // continue event processing by Qpopup
        //e->ignore();
        QPopupMenu::keyPressEvent(e);
        return;
    }

    int i = 0;
    bool firstpass = true;
    QString keyString = e->text();

    // check for common commands dealt with by QPopup
    int key = e->key();
    if (key == Key_Escape || key == Key_Return || key == Key_Enter
            || key == Key_Up || key == Key_Down || key == Key_Left
            || key == Key_Right || key == Key_F1) {

        resetKeyboardVars();
        // continue event processing by Qpopup
        //e->ignore();
        QPopupMenu::keyPressEvent(e);
        return;
    }

    // check to see if the user wants to remove a key from the sequence (backspace)
    // or clear the sequence (delete)
    if (d->keySeq != QString::null) {

        if (key == Key_Backspace) {

            if (d->keySeq.length() == 1) {
                resetKeyboardVars();
                return;
            }

            // keep the last sequence in keyString
            keyString = d->keySeq.left(d->keySeq.length() - 1);

            // allow sequence matching to be tried again
            resetKeyboardVars();

        } else if (key == Key_Delete) {
            resetKeyboardVars();

            // clear active item
            setActiveItem(0);
            return;

        } else if (d->noMatches) {
            // clear if there are no matches
            resetKeyboardVars();

            // clear active item
            setActiveItem(0);

        } else {
            // the key sequence is not a null string
            // therefore the lastHitIndex is valid
            i = d->lastHitIndex;
        }
    } else if (key == Key_Backspace && parentMenu) {
        // backspace with no chars in the buffer... go back a menu.
        hide();
        resetKeyboardVars();
        return;
    }

    d->keySeq += keyString;
    int seqLen = d->keySeq.length();

    for (; i < (int)count(); i++) {
        // compare typed text with text of this entry
        int j = idAt(i);

        // don't search disabled entries
        if (!isItemEnabled(j))
            continue;

        QString thisText;

        // retrieve the right text
        // (the last selected item one may have additional ampersands)
        if (i == d->lastHitIndex)
            thisText = d->originalText;
        else
            thisText = text(j);

        // if there is an accelerator present, remove it
        if ((int)accel(j) != 0)
            thisText = thisText.replace(QRegExp("&"), "");

        // chop text to the search length
        thisText = thisText.left(seqLen);

        // do the search
        if (thisText.find(d->keySeq, 0, false) == 0) {

            if (firstpass) {
                // match
                setActiveItem(i);

                // check to see if we're underlining a different item
                if (d->lastHitIndex != i)
                    // yes; revert the underlining
                    changeItem(idAt(d->lastHitIndex), d->originalText);

                // set the original text if it's a different item
                if (d->lastHitIndex != i || d->lastHitIndex == -1)
                    d->originalText = text(j);

                // underline the currently selected item
                changeItem(j, underlineText(d->originalText, d->keySeq.length()));

                // remeber what's going on
                d->lastHitIndex = i;

                // start/restart the clear timer
                d->clearTimer.start(5000, true);

                // go around for another try, to see if we can execute
                firstpass = false;
            } else {
                // don't allow execution
                return;
            }
        }

        // fall through to allow execution
    }

    if (!firstpass) {
        if (d->autoExec) {
            // activate anything
            activateItemAt(d->lastHitIndex);
            resetKeyboardVars();

        } else if (findItem(idAt(d->lastHitIndex)) &&
                   findItem(idAt(d->lastHitIndex))->popup()) {
            // only activate sub-menus
            activateItemAt(d->lastHitIndex);
            resetKeyboardVars();
        }

        return;
    }

    // no matches whatsoever, clean up
    resetKeyboardVars(true);
    //e->ignore();
    QPopupMenu::keyPressEvent(e);
}
Example #8
0
/// <summary>
/// Convenience method.
/// </summary>
void Scene::setActiveItemLayer(Layer *layer)
{
	setActiveItem(itemForLayer(layer));
}
Example #9
0
/// <summary>
/// Convenience method.
/// </summary>
void Scene::setActiveItemGroup(LayerGroup *group)
{
	setActiveItem(itemForGroup(group));
}