//----------------------------------------------------------------------------- // Function: mouseDoubleClickEvent() //----------------------------------------------------------------------------- void TextContentAssistWidget::mouseDoubleClickEvent(QMouseEvent* event) { QListWidget::mouseDoubleClickEvent(event); // Commit the selection. commitSelection(); }
void TimelineSelectionTool::mouseReleaseEvent(TimelineMovableAbstractItem *item, QGraphicsSceneMouseEvent *event) { Q_UNUSED(item); Q_UNUSED(event); commitSelection(selectionMode(event)); reset(); }
CCopasiSelectionWidget::CCopasiSelectionWidget(QWidget* parent): QStackedWidget(parent), mpSimpleTree(NULL), mpObjectBrowser(NULL), mpOutputVector(NULL), mSingleSelect(false), mExpertMode(false) { this->mpSimpleTree = new CQSimpleSelectionTree(this); connect(mpSimpleTree, SIGNAL(selectionCommitted()), this, SLOT(commitSelection())); this->addWidget(this->mpSimpleTree); this->setSingleSelection(false); this->setExpertMode(false); }
//----------------------------------------------------------------------------- // Function: handleKey() //----------------------------------------------------------------------------- bool TextContentAssistWidget::tryHandleKey(QKeyEvent* e) { QString text = target_->toPlainText().left(target_->textCursor().position()) + e->text(); // Check if we can commit. if (contentFound_ && (e->key() == Qt::Key_Return || e->key() == Qt::Key_Tab || (canCommitWith(e) && !matcher_->lookForwardMatch(text)))) { // Commit the selection. commitSelection(); // If the key is a character, let the editor handle it too. if (e->key() != Qt::Key_Return && e->key() != Qt::Key_Tab) { return false; } // Otherwise we're fully done with it. return true; } // Handle up and down arrows and escape, if the content is shown. if (isContentShown()) { switch (e->key()) { case Qt::Key_Up: case Qt::Key_Down: { if (isVisible()) { keyPressEvent(e); return true; } break; } case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Home: case Qt::Key_End: { cancel(); return false; } case Qt::Key_A: { if (e->modifiers() == Qt::ControlModifier) { cancel(); return false; } break; } case Qt::Key_Escape: { cancel(); return true; } } } return false; }