void AttributeHandler::click() { if (isReadOnly()) { requestValue(); item->setText(0, QString::fromStdString(getValue())); } else { QTreeWidget * parent = item->treeWidget(); QRect rect = parent->visualItemRect(item); QPoint pos = parent->mapToGlobal(rect.topLeft()); if (popupMenu == nullptr) { popupMenu = new QMenu(); QAction * actionChange = popupMenu->addAction("Change value"); connect(actionChange, SIGNAL(triggered ( )), this, SLOT(changeValue())); QAction * actionUpdate = popupMenu->addAction("update value"); connect(actionUpdate, SIGNAL(triggered ( )), this, SLOT(updateValue())); } popupMenu->popup(pos); } }
bool QDataBrowser::preNav() { QSqlRecord* buf = d->frm.record(); QSqlCursor* cur = d->cur.cursor(); if ( !buf || !cur ) return FALSE; if ( !isReadOnly() && autoEdit() && currentEdited() ) { bool ok = TRUE; QSql::Confirm conf = QSql::Yes; switch ( d->dat.mode() ){ case QSql::Insert: if ( confirmInsert() ) conf = confirmEdit( QSql::Insert ); switch ( conf ) { case QSql::Yes: ok = insertCurrent(); d->dat.setMode( QSql::Update ); break; case QSql::No: d->dat.setMode( QSql::Update ); break; case QSql::Cancel: return FALSE; } break; default: if ( confirmUpdate() ) conf = confirmEdit( QSql::Update ); switch ( conf ) { case QSql::Yes: ok = updateCurrent(); break; case QSql::No: break; case QSql::Cancel: return FALSE; } } return ok; } return TRUE; }
void TextField::paste() { if(isReadOnly()) { return; } std::string pasteResult = Clipboard::paste(); if(pasteResult.length() == 0 || getTextLength() - getSelectionLength() == getMaxLength()) { return; } deleteSelection(); int start = getCaretPosition(); std::string noNewLine; for(size_t i = 0; i < pasteResult.size(); ++i) { if(pasteResult[i] != '\n') { noNewLine += pasteResult[i]; } } int length = int(unicodeFunctions.length(noNewLine)); int numRemainingChar = getMaxLength() - getTextLength(); if(numRemainingChar < length) { noNewLine = unicodeFunctions.subStr(noNewLine,0,numRemainingChar); length = numRemainingChar; } if(length > 0) { std::string* cText = (std::string*)&getText(); unicodeFunctions.insert(*cText,start,noNewLine); setThisText(*cText); positionCaret(caretPosition + length); } }
void CCodeEditor::HighlightWrongLine(const int lineNumber) { QTextBlock wrongBlock = this->document()->findBlockByLineNumber(lineNumber); QTextCursor wrongCursor(wrongBlock); m_extraSelections.clear(); if (!isReadOnly()) { m_wrongSelection.format.setBackground(COLOR_WRONG); m_wrongSelection.format.setProperty(QTextFormat::FullWidthSelection, true); m_wrongSelection.cursor = wrongCursor; m_wrongSelection.cursor.clearSelection(); m_extraSelections.append(m_selectSelection); m_extraSelections.append(m_pcSelection); m_extraSelections.append(m_wrongSelection); } setExtraSelections(m_extraSelections); }
/************************************************************************* Processing for backspace key *************************************************************************/ void MultiLineEditbox::handleBackspace(void) { if (!isReadOnly()) { if (getSelectionLength() != 0) { eraseSelectedText(); } else if (d_caratPos > 0) { d_text.erase(d_caratPos - 1, 1); setCaratIndex(d_caratPos - 1); WindowEventArgs args(this); onTextChanged(args); } } }
/*! \qmlproperty bool TextEdit::readOnly Whether the user an interact with the TextEdit item. If this property is set to true the text cannot be edited by user interaction. By default this property is false. */ void QDeclarativeTextEdit::setReadOnly(bool r) { Q_D(QDeclarativeTextEdit); if (r == isReadOnly()) return; Qt::TextInteractionFlags flags = Qt::NoTextInteraction; if (r) { flags = Qt::TextSelectableByMouse; } else { flags = Qt::TextEditorInteraction; } d->control->setTextInteractionFlags(flags); if (!r) d->control->moveCursor(QTextCursor::End); emit readOnlyChanged(r); }
/*! Handles key events - Key_Down, KeyLeft\n Decrement by 1 - Key_Prior\n Decrement by pageSize() - Key_Home\n Set the value to minValue() - Key_Up, KeyRight\n Increment by 1 - Key_Next\n Increment by pageSize() - Key_End\n Set the value to maxValue() \param event Key event \sa isReadOnly() */ void QwtDial::keyPressEvent( QKeyEvent *event ) { if ( isReadOnly() ) { event->ignore(); return; } if ( !isValid() ) return; const double previousValue = value(); switch ( event->key() ) { case Qt::Key_Down: case Qt::Key_Left: QwtDoubleRange::incValue( -1 ); break; case Qt::Key_PageUp: QwtDoubleRange::incValue( -pageSize() ); break; case Qt::Key_Home: setValue( minValue() ); break; case Qt::Key_Up: case Qt::Key_Right: QwtDoubleRange::incValue( 1 ); break; case Qt::Key_PageDown: QwtDoubleRange::incValue( pageSize() ); break; case Qt::Key_End: setValue( maxValue() ); break; default:; event->ignore(); } if ( value() != previousValue ) Q_EMIT sliderMoved( value() ); }
void TextEditor::highlightCurrentLine() { QList<QTextEdit::ExtraSelection> extraSelections; if (!isReadOnly()) { QTextEdit::ExtraSelection selection; QColor lineColor = QColor(Qt::yellow).lighter(160); selection.format.setBackground(lineColor); selection.format.setProperty(QTextFormat::FullWidthSelection, true); selection.cursor = textCursor(); selection.cursor.clearSelection(); extraSelections.append(selection); } setExtraSelections(extraSelections); }
/*! Mouse press event handler \param event Mouse event */ void QwtAbstractSlider::mousePressEvent( QMouseEvent *event ) { if ( isReadOnly() ) { event->ignore(); return; } if ( !d_data->isValid || lowerBound() == upperBound() ) return; d_data->isScrolling = isScrollPosition( event->pos() ); if ( d_data->isScrolling ) { d_data->pendingValueChanged = false; Q_EMIT sliderPressed(); } }
/*! * Highlight background of the current line. */ void TextEdit::highlightCurrentLine() { QList<QTextEdit::ExtraSelection> extraSelections; if (!isReadOnly()) { QTextEdit::ExtraSelection selection; QPalette a; selection.format.setBackground(a.brush(QPalette::Window)); //selection.format.setProperty(QTextFormat::BlockNonBreakableLines, false); selection.format.setProperty(QTextFormat::FullWidthSelection, true); selection.cursor = textCursor(); selection.cursor.clearSelection(); selection.cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor); selection.cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); extraSelections.append(selection); } setExtraSelections(extraSelections); }
/************************************************************************* Processing for Delete key *************************************************************************/ void MultiLineEditbox::handleDelete(void) { if (!isReadOnly()) { if (getSelectionLength() != 0) { eraseSelectedText(); } else if (getCaratIndex() < d_text.length() - 1) { d_text.erase(d_caratPos, 1); ensureCaratIsVisible(); WindowEventArgs args(this); onTextChanged(args); } } }
QPopupMenu *KEdit::createPopupMenu( const QPoint& pos ) { enum { IdUndo, IdRedo, IdSep1, IdCut, IdCopy, IdPaste, IdClear, IdSep2, IdSelectAll }; QPopupMenu *menu = QMultiLineEdit::createPopupMenu( pos ); if ( isReadOnly() ) menu->changeItem( menu->idAt(0), SmallIconSet("editcopy"), menu->text( menu->idAt(0) ) ); else { int id = menu->idAt(0); menu->changeItem( id - IdUndo, SmallIconSet("undo"), menu->text( id - IdUndo) ); menu->changeItem( id - IdRedo, SmallIconSet("redo"), menu->text( id - IdRedo) ); menu->changeItem( id - IdCut, SmallIconSet("editcut"), menu->text( id - IdCut) ); menu->changeItem( id - IdCopy, SmallIconSet("editcopy"), menu->text( id - IdCopy) ); menu->changeItem( id - IdPaste, SmallIconSet("editpaste"), menu->text( id - IdPaste) ); menu->changeItem( id - IdClear, SmallIconSet("editclear"), menu->text( id - IdClear) ); } return menu; }
/*! Returns a deep-copied clone of the QMofStructuralFeature. */ QModelingElement *QMofStructuralFeature::clone() const { QMofStructuralFeature *c = new QMofStructuralFeature; c->asQModelingObject()->setObjectName(this->asQModelingObject()->objectName()); c->asQModelingObject()->setProperty("role", this->asQModelingObject()->property("role")); foreach (QMofComment *element, ownedComments()) c->addOwnedComment(dynamic_cast<QMofComment *>(element->clone())); c->setName(name()); c->setVisibility(visibility()); c->setLeaf(isLeaf()); c->setStatic(isStatic()); c->setOrdered(isOrdered()); c->setUnique(isUnique()); if (lowerValue()) c->setLowerValue(dynamic_cast<QMofValueSpecification *>(lowerValue()->clone())); if (upperValue()) c->setUpperValue(dynamic_cast<QMofValueSpecification *>(upperValue()->clone())); c->setReadOnly(isReadOnly()); return c; }
void CharacterDataImpl::setNodeValue(const DOMString &value) { if (isReadOnly()) throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); data = value.clone(); if (this->getOwnerDocument() != null) { typedef RefVectorOf<RangeImpl> RangeImpls; RangeImpls* ranges = this->getOwnerDocument()->getRanges(); if (ranges != null) { unsigned int sz = ranges->size(); if (sz != 0) { for (unsigned int i =0; i<sz; i++) { ranges->elementAt(i)->receiveReplacedText( this); } } } } };
void Entry::showEditPopupMenu(const gfx::Point& pt) { Menu menu; MenuItem cut("Cut"); MenuItem copy("Copy"); MenuItem paste("Paste"); menu.addChild(&cut); menu.addChild(©); menu.addChild(&paste); cut.Click.connect(Bind(&Entry::executeCmd, this, EntryCmd::Cut, 0, false)); copy.Click.connect(Bind(&Entry::executeCmd, this, EntryCmd::Copy, 0, false)); paste.Click.connect(Bind(&Entry::executeCmd, this, EntryCmd::Paste, 0, false)); if (isReadOnly()) { cut.setEnabled(false); paste.setEnabled(false); } menu.showPopup(pt); }
TQPopupMenu *KTextBrowser::createPopupMenu( const TQPoint & pos ) { enum { IdUndo, IdRedo, IdSep1, IdCut, IdCopy, IdPaste, IdClear, IdSep2, IdSelectAll }; TQPopupMenu *popup = TQTextBrowser::createPopupMenu( pos ); if ( isReadOnly() ) popup->changeItem( popup->idAt(0), SmallIconSet("editcopy"), popup->text( popup->idAt(0) ) ); else { int id = popup->idAt(0); popup->changeItem( id - IdUndo, SmallIconSet("undo"), popup->text( id - IdUndo) ); popup->changeItem( id - IdRedo, SmallIconSet("redo"), popup->text( id - IdRedo) ); popup->changeItem( id - IdCut, SmallIconSet("editcut"), popup->text( id - IdCut) ); popup->changeItem( id - IdCopy, SmallIconSet("editcopy"), popup->text( id - IdCopy) ); popup->changeItem( id - IdPaste, SmallIconSet("editpaste"), popup->text( id - IdPaste) ); popup->changeItem( id - IdClear, SmallIconSet("editclear"), popup->text( id - IdClear) ); } return popup; }
/************************************************************************* Processing to insert a new line / paragraph. *************************************************************************/ void MultiLineEditbox::handleNewLine(uint sysKeys) { if (!isReadOnly()) { // erase selected text eraseSelectedText(); // if there is room if (d_text.length() - 1 < d_maxTextLen) { d_text.insert(getCaratIndex(), 1, 0x0a); d_caratPos++; WindowEventArgs args(this); onTextChanged(args); } } }
void ColorLineEdit::dropEvent(QDropEvent *event) { if ( isReadOnly() ) return; if ( event->mimeData()->hasColor() ) { setColor(event->mimeData()->colorData().value<QColor>()); event->accept(); } else if ( event->mimeData()->hasText() ) { QColor col = color_widgets::colorFromString(event->mimeData()->text(), p->show_alpha); if ( col.isValid() ) { setColor(col); event->accept(); } } }
/*! Mouse press event handler \param event Mouse event */ void QwtSlider::mousePressEvent( QMouseEvent *event ) { if ( isReadOnly() ) { event->ignore(); return; } const QPoint pos = event->pos(); if ( isValid() && d_data->sliderRect.contains( pos ) ) { if ( !handleRect().contains( pos ) ) { const int markerPos = transform( value() ); d_data->stepsIncrement = pageSteps(); if ( d_data->orientation == Qt::Horizontal ) { if ( pos.x() < markerPos ) d_data->stepsIncrement = -d_data->stepsIncrement; } else { if ( pos.y() < markerPos ) d_data->stepsIncrement = -d_data->stepsIncrement; } if ( isInverted() ) d_data->stepsIncrement = -d_data->stepsIncrement; d_data->timerTick = false; d_data->repeatTimerId = startTimer( qMax( 250, 2 * updateInterval() ) ); return; } } QwtAbstractSlider::mousePressEvent( event ); }
void UmlRelation::gen_uml_decl() { if (isClassMember()) fw.write("static, "); write(visibility()); writeq(roleName()); fw.write(" : "); roleType()->write(); QByteArray s; s = defaultValue(); if (!s.isEmpty()) { if (s[0] != '=') fw.write(" = "); writeq(s); } s = multiplicity(); if (!s.isEmpty()) { fw.write(", multiplicity : "); writeq(s); } if (isDerived()) fw.write((isDerivedUnion()) ? ", derived union" : ", derived"); if (isReadOnly()) fw.write(", read only"); if (isOrdered()) fw.write(", ordered"); if (isUnique()) fw.write(", unique"); }
/* * Workhorse of both fsync & write_inode */ int jfs_commit_inode(struct inode *inode, int wait) { int rc = 0; tid_t tid; static int noisy = 5; jfs_info("In jfs_commit_inode, inode = 0x%p", inode); /* * Don't commit if inode has been committed since last being * marked dirty, or if it has been deleted. */ if (inode->i_nlink == 0 || !test_cflag(COMMIT_Dirty, inode)) return 0; if (isReadOnly(inode)) { /* kernel allows writes to devices on read-only * partitions and may think inode is dirty */ if (!special_file(inode->i_mode) && noisy) { jfs_err("jfs_commit_inode(0x%p) called on " "read-only volume", inode); jfs_err("Is remount racy?"); noisy--; } return 0; } tid = txBegin(inode->i_sb, COMMIT_INODE); mutex_lock(&JFS_IP(inode)->commit_mutex); /* * Retest inode state after taking commit_mutex */ if (inode->i_nlink && test_cflag(COMMIT_Dirty, inode)) rc = txCommit(tid, 1, &inode, wait ? COMMIT_SYNC : 0); txEnd(tid); mutex_unlock(&JFS_IP(inode)->commit_mutex); return rc; }
/** * Override QMultiLineEdit to notify Java peer of traversal out. * * @param keyEvent key event to handle */ void TextFieldBody::keyPressEvent(QKeyEvent *key) { int k = key->key(); // always handle select event because it switches // between the modal and non-modal modes #ifdef QT_KEYPAD_MODE if (k == Qt::Key_Select) { QMultiLineEdit::keyPressEvent(key); } else if (isModalEditing()) { #endif if (isReadOnly()) { if ((k == Qt::Key_Up && rowIsVisible(0)) || (k == Qt::Key_Down && rowIsVisible(numRows() - 1))) { PlatformMScreen * mscreen = PlatformMScreen::getMScreen(); mscreen->keyPressEvent(key); } else { QMultiLineEdit::keyPressEvent(key); } } else { int line; int col; QMultiLineEdit::getCursorPosition(&line, &col); if ((k == Qt::Key_Up && line == 0) || (k == Qt::Key_Down && (line == numLines() - 1))){ PlatformMScreen * mscreen = PlatformMScreen::getMScreen(); mscreen->keyPressEvent(key); } else { QMultiLineEdit::keyPressEvent(key); } } #ifdef QT_KEYPAD_MODE } else { // not handle events while it's in not modal state key->ignore(); } #endif }
/** Gere les enfoncements de touches du clavier @param e QKeyEvent decrivant l'evenement clavier */ void Diagram::keyPressEvent(QKeyEvent *e) { bool transmit_event = true; if (!isReadOnly()) { QPointF movement; switch(e -> key()) { case Qt::Key_Left: movement = QPointF(-xGrid, 0.0); break; case Qt::Key_Right: movement = QPointF(+xGrid, 0.0); break; case Qt::Key_Up: movement = QPointF(0.0, -yGrid); break; case Qt::Key_Down: movement = QPointF(0.0, +yGrid); break; } if (!movement.isNull() && !focusItem()) { beginMoveElements(); continueMoveElements(movement); e -> accept(); transmit_event = false; } } if (transmit_event) { QGraphicsScene::keyPressEvent(e); } }
bool CVar::fromBinding(CVar::Binding binding) { if (isCheat() && (!com_developer->toBoolean() && !com_enableCheats->toBoolean())) return false; if (m_type != Bind) { if (com_developer && com_developer->toBoolean()) orConsoleRef.print(orConsoleRef.Warning, "Invalid assignment, CVar %s is not a binding", name().c_str()); return false; } if (isReadOnly() && (com_developer && !com_developer->toBoolean())) { orConsoleRef.print(orConsoleRef.Warning, "CVar %s is readonly, restart in developer mode.", name().c_str()); return false; } m_binding = binding; return true; }
void OCDial::mousePressEvent(QMouseEvent* e) { if (e->button() != LeftButton || isTest() || isEdit() || isReadOnly()) return; double w = face.width(); double h = face.height(); double radius = (w < h ? w : h) * 0.45; double ptr_w = radius / 5; double dx = e->x() - w / 2; double dy = h / 2 - e->y(); double s = sin(angle); double c = cos(angle); double d_par = s * dy + c * dx; double d_per = fabs(s * dx - c * dy); if (!button && d_per < ptr_w/2 && d_par > -ptr_w) { button = e->button(); setTrackMouse(true); updateMouse(e->x(), e->y()); } }
void CodeEditor::highlightCurrentLine() { QList<QTextEdit::ExtraSelection> extraSelections; if (!isReadOnly()) { QTextEdit::ExtraSelection selection; QColor lineColor = QColor(Qt::blue).lighter(190); selection.format.setBackground(lineColor); selection.format.setProperty(QTextFormat::FullWidthSelection, true); selection.cursor = textCursor(); selection.cursor.clearSelection(); if (errorLines.indexOf(selection.cursor.blockNumber()+1)!=-1) { QToolTip::showText(QCursor::pos(),errorMsgs.at(errorLines.indexOf(selection.cursor.blockNumber()+1))); } else { QToolTip::hideText(); } extraSelections.append(selection); } setExtraSelections(extraSelections); }
void A2L::fillScalarsInfo(QVector< QSharedPointer<ECUScalar> > &scalars) const { for ( ptrdiff_t i=0; i<m_scalarsInfo.size(); i++ ) { QSharedPointer<ECUScalar> scal(new ECUScalar()); const ptrdiff_t compuMethodInd = findCompuMethod(m_scalarsInfo[i][6]); if ( m_compumethodsInfo[compuMethodInd][2] == "RAT_FUNC" ) { scal->setType(VARTYPE_SCALAR_NUM); scal->setCoefficients(getCoeff(compuMethodInd)); } else if ( m_compumethodsInfo[compuMethodInd][2] == "TAB_VERB" ) { scal->setType(VARTYPE_SCALAR_VTAB); const ptrdiff_t compuVTabInd = findCompuVTab(m_compumethodsInfo[compuMethodInd][5].split(' ').last()); scal->setVTable(getVTab(compuVTabInd)); } scal->setName(m_scalarsInfo[i][0]); scal->setShortDescription(delQuotes(m_scalarsInfo[i][1])); scal->setAddress(m_scalarsInfo[i][3].split("x").last()); scal->setNumType(m_scalarsInfo[i][4].split('_').last()); scal->setRangeSoft(m_scalarsInfo[i][5].toDouble()); scal->setMinValueSoft(m_scalarsInfo[i][7].toDouble()); scal->setMaxValueSoft(m_scalarsInfo[i][8].toDouble()); scal->setPrecision(delQuotes(m_scalarsInfo[i][9].split('.').last()).toInt()); QVector<double> v = getHardLimints(m_scalarsInfo[i][10]); scal->setMinValueHard(v[0]); scal->setMaxValueHard(v[1]); scal->setReadOnly(isReadOnly(i)); scal->setDimension("[" + delQuotes(m_compumethodsInfo[compuMethodInd][4]) + "]"); scalars.push_back(scal); } }
/*! Wheel Event handler In/decreases the value by s number of steps. The direction depends on the invertedControls() property. When the control or shift modifier is pressed the wheel delta ( divided by 120 ) is mapped to an increment according to pageSteps(). Otherwise it is mapped to singleSteps(). \param event Wheel event */ void QwtAbstractSlider::wheelEvent( QWheelEvent *event ) { if ( isReadOnly() ) { event->ignore(); return; } if ( !d_data->isValid || d_data->isScrolling ) return; int numSteps = 0; if ( ( event->modifiers() & Qt::ControlModifier) || ( event->modifiers() & Qt::ShiftModifier ) ) { // one page regardless of delta numSteps = d_data->pageSteps; if ( event->delta() < 0 ) numSteps = -numSteps; } else { const int numTurns = ( event->delta() / 120 ); numSteps = numTurns * d_data->singleSteps; } if ( d_data->invertedControls ) numSteps = -numSteps; const double value = incrementedValue( d_data->value, numSteps ); if ( value != d_data->value ) { d_data->value = value; sliderChange(); Q_EMIT sliderMoved( d_data->value ); Q_EMIT valueChanged( d_data->value ); } }
int encfs_mknod(const char *path, mode_t mode, dev_t rdev) { EncFS_Context *ctx = context(); if (isReadOnly(ctx)) return -EROFS; int res = -EIO; std::shared_ptr<DirNode> FSRoot = ctx->getRoot(&res); if (!FSRoot) return res; try { std::shared_ptr<FileNode> fnode = FSRoot->lookupNode(path, "mknod"); VLOG(1) << "mknod on " << fnode->cipherName() << ", mode " << mode << ", dev " << rdev; uid_t uid = 0; gid_t gid = 0; if (ctx->publicFilesystem) { fuse_context *context = fuse_get_context(); uid = context->uid; gid = context->gid; } res = fnode->mknod(mode, rdev, uid, gid); // Is this error due to access problems? if (ctx->publicFilesystem && -res == EACCES) { // try again using the parent dir's group string parent = fnode->plaintextParent(); VLOG(1) << "trying public filesystem workaround for " << parent; std::shared_ptr<FileNode> dnode = FSRoot->lookupNode(parent.c_str(), "mknod"); struct stat st; if (dnode->getAttr(&st) == 0) res = fnode->mknod(mode, rdev, uid, st.st_gid); } } catch (encfs::Error &err) { RLOG(ERROR) << "error caught in mknod: " << err.what(); } return res; }
/*! Mouse Move Event handler \param event Mouse event */ void QwtAbstractSlider::mouseMoveEvent( QMouseEvent *event ) { if ( isReadOnly() ) { event->ignore(); return; } if ( d_data->isValid && d_data->isScrolling ) { double value = scrolledTo( event->pos() ); if ( value != d_data->value ) { value = boundedValue( value ); if ( d_data->stepAlignment ) { value = alignedValue( value ); } else { value = qwtAlignToScaleDiv( this, value ); } if ( value != d_data->value ) { d_data->value = value; sliderChange(); Q_EMIT sliderMoved( d_data->value ); if ( d_data->isTracking ) Q_EMIT valueChanged( d_data->value ); else d_data->pendingValueChanged = true; } } } }