void QsciEditor::showCustomMenu( const QPoint &position ) { contextMenu.clear(); QMenu formatMenu( "&Format" ); formatMenu.addAction( changeFontAct ); if ( hasSelectedText() ) formatMenu.addAction( toggleCaseAct ); contextMenu.addMenu( &formatMenu ); contextMenu.addSeparator(); if ( hasSelectedText() ) { contextMenu.addAction( cutAct ); contextMenu.addAction( copyAct ); } if ( SendScintilla( SCI_CANPASTE ) ) contextMenu.addAction( pasteAct ); if ( hasSelectedText() ) contextMenu.addAction( deleteAct ); if ( not text().isEmpty() or hasSelectedText() ) contextMenu.addSeparator(); if ( not text().isEmpty() ) contextMenu.addAction( selectAct ); if ( hasSelectedText() ) contextMenu.addAction( deselectAct ); if ( isUndoAvailable() or isRedoAvailable() ) contextMenu.addSeparator(); if ( isUndoAvailable() ) contextMenu.addAction( undoAct ); if ( isRedoAvailable() ) contextMenu.addAction( redoAct ); if ( not text().isEmpty() ) { contextMenu.addSeparator(); contextMenu.addAction( searchAct ); contextMenu.addAction( replaceAct ); } contextMenu.exec( QWidget::mapToGlobal( position ) ); };
/** * Constructor * @param parent :: The parent widget (can be NULL) * @param codelexer :: define the syntax highlighting and code completion. * @param settingsGroup :: Used when saving settings to persistent store */ ScriptEditor::ScriptEditor(QWidget *parent, QsciLexer *codelexer, const QString & settingsGroup) : QsciScintilla(parent), m_filename(""), m_progressArrowKey(markerDefine(QsciScintilla::RightArrow)), m_currentExecLine(0), m_completer(NULL),m_previousKey(0), m_findDialog(new FindReplaceDialog(this)), m_settingsGroup(settingsGroup) { // Older versions of QScintilla still use just CR as the line ending, which is pre-OSX. // New versions just use unix-style for everything but Windows. #if defined(Q_OS_WIN) setEolMode(EolWindows); #else setEolMode(EolUnix); #endif //Syntax highlighting and code completion setLexer(codelexer); readSettings(); setMarginLineNumbers(1,true); //Editor properties setAutoIndent(true); setFocusPolicy(Qt::StrongFocus); emit undoAvailable(isUndoAvailable()); emit redoAvailable(isRedoAvailable()); }
void DCommandHistory::updateActions() { if ( m_undo ) m_undo->setEnabled( isUndoAvailable() ); if ( m_redo ) m_redo->setEnabled( isRedoAvailable() ); }
void chanEditorWidget::documentWasModified(){ setWindowModified(true); emit undoAvailable(isUndoAvailable()); emit redoAvailable(isRedoAvailable()); setTitle(); }
// ------------------------------------------------------------------------------- void Editor::sendUndoAvailableSignal( void ) // ------------------------------------------------------------------------------- { if ( isUndoAvailable() ) { if ( SEMAPHORE_TEXT_WAS_SET ) SEMAPHORE_TEXT_WAS_SET = FALSE; else emit undoAvailable( TRUE ); } }
// --------------------------------------------------- void TextDoc::slotSetChanged() { if((isModified() && !DocChanged) || SetChanged) { App->DocumentTab->setTabIconSet(this, QPixmap(smallsave_xpm)); DocChanged = true; } else if((!isModified() && DocChanged)) { App->DocumentTab->setTabIconSet(this, QPixmap(empty_xpm)); DocChanged = false; } App->undo->setEnabled(isUndoAvailable()); App->redo->setEnabled(isRedoAvailable()); }
/** * Constructor * @param parent :: The parent widget (can be NULL) * @param codelexer :: define the syntax highlighting and code completion. * @param settingsGroup :: Used when saving settings to persistent store */ ScriptEditor::ScriptEditor(QWidget *parent, QsciLexer *codelexer, const QString & settingsGroup) : QsciScintilla(parent), m_filename(""), m_progressArrowKey(markerDefine(QsciScintilla::RightArrow)), m_currentExecLine(0), m_completer(NULL),m_previousKey(0), m_findDialog(new FindReplaceDialog(this)), m_settingsGroup(settingsGroup) { //Syntax highlighting and code completion setLexer(codelexer); readSettings(); setMarginLineNumbers(1,true); //Editor properties setAutoIndent(true); setFocusPolicy(Qt::StrongFocus); emit undoAvailable(isUndoAvailable()); emit redoAvailable(isRedoAvailable()); }
// --------------------------------------------------- void TextDoc::becomeCurrent (bool) { int x, y; slotCursorPosChanged(); viewport()->setFocus (); if (isUndoAvailable ()) App->undo->setEnabled (true); else App->undo->setEnabled (false); if (isRedoAvailable ()) App->redo->setEnabled (true); else App->redo->setEnabled (false); // update appropriate menu entries App->symEdit->setMenuText (tr("Edit Text Symbol")); App->symEdit->setStatusTip (tr("Edits the symbol for this text document")); App->symEdit->setWhatsThis ( tr("Edit Text Symbol\n\nEdits the symbol for this text document")); if (language == LANG_VHDL) { App->insEntity->setMenuText (tr("VHDL entity")); App->insEntity->setStatusTip (tr("Inserts skeleton of VHDL entity")); App->insEntity->setWhatsThis ( tr("VHDL entity\n\nInserts the skeleton of a VHDL entity")); } else if (language == LANG_VERILOG || language == LANG_VERILOGA) { App->insEntity->setMenuText (tr("Verilog module")); App->insEntity->setStatusTip (tr("Inserts skeleton of Verilog module")); App->insEntity->setWhatsThis ( tr("Verilog module\n\nInserts the skeleton of a Verilog module")); } else if (language == LANG_OCTAVE) { App->insEntity->setMenuText (tr("Octave function")); App->insEntity->setStatusTip (tr("Inserts skeleton of Octave function")); App->insEntity->setWhatsThis ( tr("Octave function\n\nInserts the skeleton of a Octave function")); } App->simulate->setEnabled (true); App->editActivate->setEnabled (true); }
void OperationList::undoOperation(void) { if(isUndoAvailable()) { Operation *operation=NULL; bool chain_active=false; Exception error; unsigned chain_size=0, pos=0; if(!this->signalsBlocked()) chain_size=getChainSize(); do { /* In the undo operation, it is necessary to obtain the object at current index decremented by 1 since the current index always points to the element after the last element */ operation=operations[current_index-1]; /* If it is detected that the operation is chained with other and active chaining flag is cleared marks the flag to start the execution several operations at once */ if(!ignore_chain && !chain_active && operation->chain_type!=Operation::NO_CHAIN) chain_active=true; /* If the chaining is active and the current operation is not part of chain, aborts execution of the operation */ else if(chain_active && (operation->chain_type==Operation::CHAIN_END || operation->chain_type==Operation::NO_CHAIN)) break; try { if(!this->signalsBlocked() && chain_size > 0) { //Emits a signal with the current progress of operation execution pos++; emit s_operationExecuted((pos/static_cast<float>(chain_size))*100, trUtf8("Undoing operation on object: %1 (%2)") .arg(operation->pool_obj->getName()) .arg(operation->pool_obj->getTypeName()), operation->pool_obj->getObjectType()); } //Executes the undo operation executeOperation(operation, false); } catch(Exception &e) { error=e; } current_index--; } /* Performs the operations while the current operation is part of chain or the undo option is available */ while(!ignore_chain && isUndoAvailable() && operation->chain_type!=Operation::NO_CHAIN); if(error.getErrorType()!=ERR_CUSTOM) throw Exception(error.getErrorMessage(), error.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__); } }
void QsciEditor::undoAction() { if ( isUndoAvailable() ) undo(); };
void pEditor::textChanged() { emit undoAvailable( isUndoAvailable() ); emit redoAvailable( isRedoAvailable() ); }
int QTextDocumentPrivate::undoRedo(bool undo) { PMDEBUG("%s, undoState=%d, undoStack size=%d", undo ? "undo:" : "redo:", undoState, undoStack.size()); if (!undoEnabled || (undo && undoState == 0) || (!undo && undoState == undoStack.size())) return -1; undoEnabled = false; beginEditBlock(); while (1) { if (undo) --undoState; QTextUndoCommand &c = undoStack[undoState]; int resetBlockRevision = c.pos; switch(c.command) { case QTextUndoCommand::Inserted: remove(c.pos, c.length, (QTextUndoCommand::Operation)c.operation); PMDEBUG(" erase: from %d, length %d", c.pos, c.length); c.command = QTextUndoCommand::Removed; break; case QTextUndoCommand::Removed: PMDEBUG(" insert: format %d (from %d, length %d, strpos=%d)", c.format, c.pos, c.length, c.strPos); insert_string(c.pos, c.strPos, c.length, c.format, (QTextUndoCommand::Operation)c.operation); c.command = QTextUndoCommand::Inserted; break; case QTextUndoCommand::BlockInserted: case QTextUndoCommand::BlockAdded: remove_block(c.pos, &c.blockFormat, c.command, (QTextUndoCommand::Operation)c.operation); PMDEBUG(" blockremove: from %d", c.pos); if (c.command == QTextUndoCommand::BlockInserted) c.command = QTextUndoCommand::BlockRemoved; else c.command = QTextUndoCommand::BlockDeleted; break; case QTextUndoCommand::BlockRemoved: case QTextUndoCommand::BlockDeleted: PMDEBUG(" blockinsert: charformat %d blockformat %d (pos %d, strpos=%d)", c.format, c.blockFormat, c.pos, c.strPos); insert_block(c.pos, c.strPos, c.format, c.blockFormat, (QTextUndoCommand::Operation)c.operation, c.command); resetBlockRevision += 1; if (c.command == QTextUndoCommand::BlockRemoved) c.command = QTextUndoCommand::BlockInserted; else c.command = QTextUndoCommand::BlockAdded; break; case QTextUndoCommand::CharFormatChanged: { resetBlockRevision = -1; // ## TODO PMDEBUG(" charFormat: format %d (from %d, length %d)", c.format, c.pos, c.length); FragmentIterator it = find(c.pos); Q_ASSERT(!it.atEnd()); int oldFormat = it.value()->format; setCharFormat(c.pos, c.length, formats.charFormat(c.format)); c.format = oldFormat; break; } case QTextUndoCommand::BlockFormatChanged: { resetBlockRevision = -1; // ## TODO PMDEBUG(" blockformat: format %d pos %d", c.format, c.pos); QTextBlock it = blocksFind(c.pos); Q_ASSERT(it.isValid()); int oldFormat = block(it)->format; block(it)->format = c.format; QTextBlockGroup *oldGroup = qobject_cast<QTextBlockGroup *>(objectForFormat(formats.blockFormat(oldFormat))); QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(formats.blockFormat(c.format))); c.format = oldFormat; if (group != oldGroup) { if (oldGroup) oldGroup->blockRemoved(it); if (group) group->blockInserted(it); } else if (group) { group->blockFormatChanged(it); } documentChange(it.position(), it.length()); break; } case QTextUndoCommand::GroupFormatChange: { resetBlockRevision = -1; // ## TODO PMDEBUG(" group format change"); QTextObject *object = objectForIndex(c.objectIndex); int oldFormat = formats.objectFormatIndex(c.objectIndex); changeObjectFormat(object, c.format); c.format = oldFormat; break; } case QTextUndoCommand::Custom: resetBlockRevision = -1; // ## TODO if (undo) c.custom->undo(); else c.custom->redo(); break; default: Q_ASSERT(false); } if (resetBlockRevision >= 0) { int b = blocks.findNode(resetBlockRevision); QTextBlockData *B = blocks.fragment(b); B->revision = c.revision; } if (undo) { if (undoState == 0 || !undoStack[undoState-1].block) break; } else { ++undoState; if (undoState == undoStack.size() || !undoStack[undoState-1].block) break; } } undoEnabled = true; int editPos = -1; if (docChangeFrom >= 0) { editPos = qMin(docChangeFrom + docChangeLength, length() - 1); } endEditBlock(); emitUndoAvailable(isUndoAvailable()); emitRedoAvailable(isRedoAvailable()); return editPos; }
int QLineEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 21) qt_static_metacall(this, _c, _id, _a); _id -= 21; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = inputMask(); break; case 1: *reinterpret_cast< QString*>(_v) = text(); break; case 2: *reinterpret_cast< int*>(_v) = maxLength(); break; case 3: *reinterpret_cast< bool*>(_v) = hasFrame(); break; case 4: *reinterpret_cast< EchoMode*>(_v) = echoMode(); break; case 5: *reinterpret_cast< QString*>(_v) = displayText(); break; case 6: *reinterpret_cast< int*>(_v) = cursorPosition(); break; case 7: *reinterpret_cast< Qt::Alignment*>(_v) = alignment(); break; case 8: *reinterpret_cast< bool*>(_v) = isModified(); break; case 9: *reinterpret_cast< bool*>(_v) = hasSelectedText(); break; case 10: *reinterpret_cast< QString*>(_v) = selectedText(); break; case 11: *reinterpret_cast< bool*>(_v) = dragEnabled(); break; case 12: *reinterpret_cast< bool*>(_v) = isReadOnly(); break; case 13: *reinterpret_cast< bool*>(_v) = isUndoAvailable(); break; case 14: *reinterpret_cast< bool*>(_v) = isRedoAvailable(); break; case 15: *reinterpret_cast< bool*>(_v) = hasAcceptableInput(); break; case 16: *reinterpret_cast< QString*>(_v) = placeholderText(); break; case 17: *reinterpret_cast< Qt::CursorMoveStyle*>(_v) = cursorMoveStyle(); break; } _id -= 18; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setInputMask(*reinterpret_cast< QString*>(_v)); break; case 1: setText(*reinterpret_cast< QString*>(_v)); break; case 2: setMaxLength(*reinterpret_cast< int*>(_v)); break; case 3: setFrame(*reinterpret_cast< bool*>(_v)); break; case 4: setEchoMode(*reinterpret_cast< EchoMode*>(_v)); break; case 6: setCursorPosition(*reinterpret_cast< int*>(_v)); break; case 7: setAlignment(*reinterpret_cast< Qt::Alignment*>(_v)); break; case 8: setModified(*reinterpret_cast< bool*>(_v)); break; case 11: setDragEnabled(*reinterpret_cast< bool*>(_v)); break; case 12: setReadOnly(*reinterpret_cast< bool*>(_v)); break; case 16: setPlaceholderText(*reinterpret_cast< QString*>(_v)); break; case 17: setCursorMoveStyle(*reinterpret_cast< Qt::CursorMoveStyle*>(_v)); break; } _id -= 18; } else if (_c == QMetaObject::ResetProperty) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 18; } #endif // QT_NO_PROPERTIES return _id; }