void PersistentState::mouseDoubleClickEvent(QMouseEvent *e) { _persistentCursor = editor()->cursorForPosition(e->pos()); _persistentCursor.select(QTextCursor::WordUnderCursor); editor()->setTextCursor(_lastCursor); editor()->updateView(true); emit copyAvailable(true); }
void PersistentState::mouseReleaseEvent(QMouseEvent *e) { if (!_persistentCursorState.isNull()) { _lastCursor = editor()->textCursor(); editor()->setTextCursor(_persistentCursorState); _persistentCursorState = QTextCursor(); } else { if (_persistentCursor.hasSelection()) emit copyAvailable(true); else emit copyAvailable(false); } if (_dragStartTimer.isActive()) _dragStartTimer.stop(); }
Editor::~Editor() { emit copyAvailable (false); emit undoAvailable (false); emit redoAvailable (false); if (numUntitleDocuments > 0) numUntitleDocuments--; }
/*! * \author Anders Fernström * \date 2006-04-18 * * \brief Help function for selection handling */ void CellDocument::addSelectedCell( Cell* cell ) { if( cell ) { cell->setSelected( true ); selectedCells_.push_back( cell ); emit copyAvailable(true); } }
void HelpViewer::actionChanged() { QAction *a = qobject_cast<QAction *>(sender()); if (a == pageAction(QWebPage::Copy)) emit copyAvailable(a->isEnabled()); else if (a == pageAction(QWebPage::Back)) emit backwardAvailable(a->isEnabled()); else if (a == pageAction(QWebPage::Forward)) emit forwardAvailable(a->isEnabled()); }
void CellDocument::clearSelection() { vector<Cell*>::iterator i = selectedCells_.begin(); for(; i!= selectedCells_.end(); ++i) (*i)->setSelected(false); selectedCells_.clear(); emit copyAvailable(false); }
void Stack::setCurrentDocument(int index) { m_current_document = m_documents[index]; m_contents->setCurrentWidget(m_current_document); m_scenes->setDocument(m_current_document); emit copyAvailable(!m_current_document->text()->textCursor().selectedText().isEmpty()); emit redoAvailable(m_current_document->text()->document()->isRedoAvailable()); emit undoAvailable(m_current_document->text()->document()->isUndoAvailable()); emit updateFormatActions(); }
void PersistentState::editorSelectionChange() { QTextCursor cursor = editor()->textCursor(); if (cursor.hasSelection()) { if (cursor.anchor() == _persistentCursor.position()) _persistentCursor.setPosition(cursor.position(), QTextCursor::KeepAnchor); else _persistentCursor = cursor; cursor.clearSelection(); editor()->setTextCursor(cursor); editor()->update(); emit copyAvailable(true); } }
bool MessageEditor::qt_emit( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->signalOffset() ) { case 0: translationChanged((const QString&)static_QUType_QString.get(_o+1)); break; case 1: finished((bool)static_QUType_bool.get(_o+1)); break; case 2: prevUnfinished(); break; case 3: nextUnfinished(); break; case 4: updateActions((bool)static_QUType_bool.get(_o+1)); break; case 5: undoAvailable((bool)static_QUType_bool.get(_o+1)); break; case 6: redoAvailable((bool)static_QUType_bool.get(_o+1)); break; case 7: cutAvailable((bool)static_QUType_bool.get(_o+1)); break; case 8: copyAvailable((bool)static_QUType_bool.get(_o+1)); break; case 9: pasteAvailable((bool)static_QUType_bool.get(_o+1)); break; case 10: focusSourceList(); break; case 11: focusPhraseList(); break; default: return QWidget::qt_emit(_id,_o); } return TRUE; }
void Editor::onCurrentChanged(int idx) { if(idx < 0) return; emit cursorPositionChanged(); QTextDocument * document = currentTextEdit()->document(); QTextCursor cursor = currentTextEdit()->textCursor(); // update cursor position. emit cursorPositionChanged(); // update copy/undo/redo available. emit copyAvailable(cursor.position() != cursor.anchor()); emit undoAvailable(document->isUndoAvailable()); emit redoAvailable(document->isRedoAvailable()); emit pasteAvailable(true); connect(currentTextEdit(), SIGNAL(copyAvailable(bool)), this, SLOT(onCopyAvailable(bool))); connect(currentTextEdit(), SIGNAL(undoAvailable(bool)), this, SLOT(onUndoAvailable(bool))); connect(currentTextEdit(), SIGNAL(redoAvailable(bool)), this, SLOT(onRedoAvailable(bool))); }
int _sourcecodeeditor::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QFrame::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: updateBrowser(); break; case 1: cursorPositionChanged(); break; case 2: activated((*reinterpret_cast< int(*)>(_a[1]))); break; case 3: setFullscreen(); break; case 4: setNoFullscreen2(); break; case 5: setWindow_extend(); break; case 6: showEvents(); break; case 7: copyAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break; case 8: redoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break; case 9: undoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break; case 10: textChanged(); break; case 11: selectionChanged(); break; } _id -= 12; } return _id; }
void Editor::onCopyAvailable(bool available) { emit copyAvailable(available); }
void MdiChild::viableModelSelected(bool viable) { emit copyAvailable(viable); }
void WidgetStub::sendCopyAvailable(bool yes) { emit copyAvailable(yes); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), _has_unsaved_data(true), _current_file(""), _can_run(false), _is_running(false), _is_debug_input(false) { ui->setupUi(this); initStyles(); updateWindowTitle(); redoAvailable(false); undoAvailable(false); copyAvailable(false); _window = this; ui->debugRun->setVisible(false); ui->runWidget->setVisible(false); registerFileType(tr("Yad.Markov.File"), tr("Markov Algorithm File"), ".yad", 1); updateDebugMenu(); //Connect MainWindow menu connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->actionUndo, SIGNAL(triggered()), this, SIGNAL(undo())); connect(ui->actionRedo, SIGNAL(triggered()), this, SIGNAL(redo())); connect(ui->actionSelect_All, SIGNAL(triggered()), this, SIGNAL(selectAll())); connect(ui->actionCopy, SIGNAL(triggered()), this, SIGNAL(copy())); connect(ui->actionPaste, SIGNAL(triggered()), this, SIGNAL(paste())); connect(ui->actionCut, SIGNAL(triggered()), this, SIGNAL(cut())); connect(ui->actionDelete, SIGNAL(triggered()), this, SIGNAL(deleteSelection())); connect(ui->actionNew, SIGNAL(triggered()), this, SIGNAL(newFile())); connect(ui->actionOpen, SIGNAL(triggered()), this, SIGNAL(open())); connect(ui->actionSave, SIGNAL(triggered()), this, SIGNAL(save())); connect(ui->actionSave_As, SIGNAL(triggered()), this, SIGNAL(saveAs())); connect(ui->actionTutorial, SIGNAL(triggered()), this, SLOT(tutorial())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); //Connect InputWidget and HistoryManager HistoryManager* history_manager = HistoryManager::getInstance(); connect(ui->input, SIGNAL(addToHistory(QString)), history_manager, SLOT(addToHistory(QString))); connect(history_manager, SIGNAL(wordSelected(QString)), ui->input, SLOT(setInput(QString))); //Connect HistoryWidget and HistoryManager connect(ui->history, SIGNAL(inputWordSelected(QString)), history_manager, SIGNAL(wordSelected(QString))); connect(ui->history, SIGNAL(removeFromHistory(QString)), history_manager, SLOT(removeFromHistory(QString))); connect(history_manager, SIGNAL(historyChanged(QVector<QString>)), ui->history, SLOT(historyChanged(QVector<QString>))); //Connect MainWindows and FileManager FileManager* file_manager = FileManager::getInstance(); connect(this, SIGNAL(newFile()), file_manager, SLOT(newFile())); connect(this, SIGNAL(open()), file_manager, SLOT(open())); connect(this, SIGNAL(save()), file_manager, SLOT(save())); connect(this, SIGNAL(saveAs()), file_manager, SLOT(saveAs())); connect(file_manager, SIGNAL(hasUnsavedData(bool)), this, SLOT(hasUnsavedData(bool))); connect(file_manager, SIGNAL(fileNameChanged(QString)), this, SLOT(fileNameChanged(QString))); //Connect MainWindows and EditorWindowWidget connect(this, SIGNAL(undo()), ui->editorWindow, SLOT(undo())); connect(this, SIGNAL(redo()), ui->editorWindow, SLOT(redo())); connect(this, SIGNAL(selectAll()), ui->editorWindow, SLOT(selectAll())); connect(this, SIGNAL(copy()), ui->editorWindow, SLOT(copy())); connect(this, SIGNAL(paste()), ui->editorWindow, SLOT(paste())); connect(this, SIGNAL(cut()), ui->editorWindow, SLOT(cut())); connect(this, SIGNAL(deleteSelection()), ui->editorWindow, SLOT(deleteSelection())); connect(ui->editorWindow, SIGNAL(redoAvailable(bool)), this, SLOT(redoAvailable(bool))); connect(ui->editorWindow, SIGNAL(undoAvailable(bool)), this, SLOT(undoAvailable(bool))); connect(ui->editorWindow, SIGNAL(copyAvailable(bool)), this, SLOT(copyAvailable(bool))); //Connect InputWidget and MarkovRunManager MarkovRunManager* run_manager = MarkovRunManager::getInstance(); connect(ui->input, SIGNAL(run(QString)), run_manager, SLOT(runWithoutDebug(QString))); connect(ui->input, SIGNAL(runWithDebug(QString)), run_manager, SLOT(runWithDebug(QString))); connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)), ui->input, SLOT(runStarted())); connect(ui->input, SIGNAL(runWithDebugStepByStep(QString)), run_manager, SLOT(runWithDebugStepByStep(QString))); connect(run_manager, SIGNAL(debugStarted(QString)), ui->input, SLOT(runStarted())); connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)), ui->input, SLOT(runFinished())); connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)), ui->input, SLOT(runFinished())); connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)), ui->input, SLOT(runFinished())); connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)), ui->input, SLOT(runFinished())); connect(run_manager, SIGNAL(canRunSourceCode(bool)), ui->input, SLOT(canRunAlgorithm(bool))); //Connect SourceCodeManager and EditorWindowWidget SourceCodeManager* source_manager = SourceCodeManager::getInstance(); connect(source_manager, SIGNAL(newSourceCodeWasLoaded(QString)), ui->editorWindow, SLOT(newSourceCode(QString))); connect(ui->editorWindow, SIGNAL(sourceCodeChanged(QString)), source_manager, SLOT(setSourceCode(QString))); //Connect InputWidget and FileManager connect(ui->input, SIGNAL(save()), file_manager, SLOT(save())); //Connect MarkovRunManager and EditorWindowWidget connect(ui->editorWindow, SIGNAL(canRun(bool)), run_manager, SLOT(setCanRunSourceCode(bool))); connect(ui->editorWindow, SIGNAL(markovAlgorithmChanged(MarkovAlgorithm)), run_manager, SLOT(setAlgorithm(MarkovAlgorithm))); //Connect SourceCodeManager and FileManager connect(file_manager, SIGNAL(newSourceCodeLoaded(QString)), source_manager, SLOT(setNewSourceCodeFromFile(QString))); connect(source_manager, SIGNAL(sourceCodeChanged(QString)), file_manager, SLOT(sourceCodeChanged())); //Connect FileManager and HistoryManager connect(file_manager, SIGNAL(newHistoryLoaded(QVector<QString>)), this, SLOT(newHistoryLoaded(QVector<QString>))); connect(history_manager, SIGNAL(historyChanged(QVector<QString>)), file_manager, SLOT(historyChanged())); //Connect RunWidget and MarkovRunManager connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)), ui->runWidget, SLOT(runStarted(QString))); connect(run_manager, SIGNAL(runStepsMade(int)), ui->runWidget, SLOT(runStepsMade(int))); connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)), ui->runWidget, SLOT(runFailed(QString,RunError,int))); connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)), ui->runWidget, SLOT(runSuccess(QString,QString,int))); connect(run_manager, SIGNAL(debugStarted(QString)), ui->runWidget, SLOT(hide())); //Connect DebugRunWidget and MarkovRunManager connect(ui->debugRun, SIGNAL(nextStepClicked()), run_manager, SLOT(debugNextStep())); connect(ui->debugRun, SIGNAL(continueClicked()), run_manager, SLOT(debugContinue())); connect(ui->debugRun, SIGNAL(stopClicked()), run_manager, SLOT(debugStop())); connect(run_manager, SIGNAL(debugStarted(QString)), ui->debugRun, SLOT(debugStarted(QString))); connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)), ui->debugRun, SLOT(debugSuccess(QString,QString,int))); connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)), ui->debugRun, SLOT(debugFailed(QString,RunError,int))); connect(run_manager, SIGNAL(debugStepFinished(int,QString,QString,MarkovRule)), ui->debugRun, SLOT(debugStepFinished(int,QString,QString,MarkovRule))); connect(run_manager, SIGNAL(debugBreakPointReached(int)), ui->debugRun, SLOT(breakPointReached(int))); connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)), ui->debugRun, SLOT(hide())); connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)), ui->runWidget, SLOT(hide())); connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)), ui->debugRun, SLOT(hide())); //Connect DebugRunWidget and EditorWindowWidget connect(ui->debugRun, SIGNAL(removeBreakPoint()), ui->editorWindow, SLOT(removeLineHighlight())); connect(ui->debugRun, SIGNAL(showBreakPoint(int)), ui->editorWindow, SLOT(showLineHighlight(int))); //Connect MarkovRunManager and EditorWindowWidget connect(ui->editorWindow, SIGNAL(breakPointAdded(int)), run_manager, SLOT(addBreakPoint(int))); connect(ui->editorWindow, SIGNAL(breakPointRemoved(int)), run_manager, SLOT(removeBreakPoint(int))); //Connect top menu connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)), this, SLOT(runStarted())); connect(run_manager, SIGNAL(debugStarted(QString)), this, SLOT(runStarted())); connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)), this, SLOT(runFinished())); connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)), this, SLOT(runFinished())); connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)), this, SLOT(runFinished())); connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)), this, SLOT(runFinished())); connect(run_manager, SIGNAL(canRunSourceCode(bool)), this, SLOT(canRunAlgorithm(bool))); connect(run_manager, SIGNAL(debugBreakPointReached(int)), this, SLOT(debugInputStarted())); connect(run_manager, SIGNAL(debugStepFinished(int,QString,QString,MarkovRule)), this, SLOT(debugInputFinished())); connect(ui->actionRun, SIGNAL(triggered()), ui->input, SLOT(runCliked())); connect(ui->actionDebug, SIGNAL(triggered()), ui->input, SLOT(runWithDebugClicked())); connect(ui->actionNext_Step, SIGNAL(triggered()), run_manager, SLOT(debugNextStep())); connect(ui->actionContinue, SIGNAL(triggered()), run_manager, SLOT(debugContinue())); connect(ui->actionStop_Debug, SIGNAL(triggered()), run_manager, SLOT(debugStop())); connect(ui->actionDebug_Step_By_Step, SIGNAL(triggered()), ui->input, SLOT(runWithDebugStepByStepClicked())); //Read file to open from command line QStringList arguments = QCoreApplication::arguments(); if(arguments.size() >= 2) { QString file_name = arguments.at(1); FileManager::getInstance()->openFile(file_name); } else { source_manager->setNewSourceCodeFromFile(tr("//Alphabet\nT = {a, b}\n\n//Rules\nab -> a\na ->. b")); } }