Пример #1
0
/**
 * 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());
}
Пример #2
0
void ScriptEditor::setEditor(int editorType)
{
    if(m_editor && m_editor->getType() == editorType)
        return;

    EditorWidget *w = EditorWidget::getEditor(editorType, this);
    if(!w)
        return;

    emit undoAvailable(false);
    emit redoAvailable(false);
    connect(w, SIGNAL(undoAvailable(bool)),    SIGNAL(undoAvailable(bool)));
    connect(w, SIGNAL(redoAvailable(bool)),    SIGNAL(redoAvailable(bool)));

    if(m_editor)
    {
        w->setText(m_editor->getText());
        delete m_editor;
    }
    w->setHighlighter((EditorHighlight)m_language);

    m_editor = w;
    int idx = ui->mainLayout->indexOf(ui->resizeLine);
    ui->mainLayout->insertWidget(idx, m_editor->getWidget(),
                                 100 - ui->mainLayout->stretch(ui->mainLayout->indexOf(ui->errorEdit)));

    connect(m_editor, SIGNAL(textChangedByUser()),    SLOT(textChanged()));
    connect(m_editor, SIGNAL(applyShortcutPressed()), SLOT(applyAct()));
    connect(this,     SIGNAL(undo()),       m_editor, SLOT(undo()));
    connect(this,     SIGNAL(redo()),       m_editor, SLOT(redo()));

    sConfig.set(CFG_QUINT32_SCRIPTEDITOR_TYPE, editorType);
}
Пример #3
0
Editor::~Editor() {
    emit copyAvailable (false);
    emit undoAvailable (false);
    emit redoAvailable (false);
    if (numUntitleDocuments > 0)
        numUntitleDocuments--;
}
Пример #4
0
void UndoRedoStack::redo()
{
	if(m_redoStack.empty()){
		return;
	}
	m_actionInProgress = true;
	Action* redoAction = m_redoStack.top();
	m_redoStack.pop();
	m_undoStack.push(redoAction);
	QTextCursor c(m_textEdit->textCursor());
	if(dynamic_cast<UndoableInsert*>(redoAction)){
		UndoableInsert* insertAction = static_cast<UndoableInsert*>(redoAction);
		c.setPosition(insertAction->pos);
		c.insertText(insertAction->text);
	}else{
		UndoableDelete* deleteAction = static_cast<UndoableDelete*>(redoAction);
		c.setPosition(deleteAction->start);
		c.setPosition(deleteAction->end, QTextCursor::KeepAnchor);
		c.removeSelectedText();
	}
	m_textEdit->setTextCursor(c);
	emit undoAvailable(!m_undoStack.empty());
	emit redoAvailable(!m_redoStack.empty());
	m_actionInProgress = false;
}
Пример #5
0
void KickViewHeaderedWidget::newButtonClicked()
{
  parameters.phaseParameters.clear();
  strcpy(parameters.name, "newKick");
  fileName = QString("newKick.kmc");
  parameters.numberOfPhases = 0;
  parameters.footOrigin = Vector3<> (0.f, 60.f, -210.f);
  parameters.armOrigin = Vector3<>(0.f, 100.f, 30.f);
  parameters.kdx = 0;
  parameters.kix = 0;
  parameters.kpx = 0;
  parameters.kdy = 0;
  parameters.kiy = 0;
  parameters.kpy = 0;

  parameters.loop = false;
  parameters.preview = 100;
  parameters.autoComTra = false;
  parameters.comOrigin = Vector2<>(10.f, 0.f);

  undo.clear();
  redo.clear();
  emit undoAvailable(false);
  emit redoAvailable(false);
  kickViewWidget->updateEditorView();
}
Пример #6
0
void chanEditorWidget::documentWasModified(){

	setWindowModified(true);

	emit undoAvailable(isUndoAvailable());
	emit redoAvailable(isRedoAvailable());

	setTitle();
}
Пример #7
0
void EditorWidgetKate::modified(KTextEditor::Document *)
{
    emit textChangedByUser();

    // FIXME: how the f**k do I get to "isUndoAvailable()" through
    // these fancy abstraction patterns?!
    emit undoAvailable(true);
    emit redoAvailable(true);
}
Пример #8
0
void UndoRedoStack::clear()
{
	qDeleteAll(m_undoStack);
	qDeleteAll(m_redoStack);
	m_undoStack.clear();
	m_redoStack.clear();
	emit undoAvailable(false);
	emit redoAvailable(false);
}
Пример #9
0
void Project::SetVisibleDomain(Domain *newDomain)
{
	if (newDomain)
    {
		visibleDomain = newDomain;
		if (glPanel)
			glPanel->SetActiveDomainNew(visibleDomain);

		Fort14 *currFort14 = visibleDomain->GetFort14();
		if (currFort14)
		{
			emit numElements(currFort14->GetNumElements());
			emit numNodes(currFort14->GetNumNodes());
		}

		emit undoAvailable(visibleDomain->UndoAvailable());
		emit redoAvailable(visibleDomain->RedoAvailable());

		if (displayOptions && displayOptions->isVisible())
		{
			displayOptions->SetActiveDomain(visibleDomain);
			displayOptions->update();
		}

		if (projectTree)
        {
			if (visibleDomain == fullDomain)
				projectTree->setCurrentItem(projectTree->findItems("Full Domain", Qt::MatchExactly | Qt::MatchRecursive).first());
			else
			{
				SubDomain *targetDomain = DetermineSubdomain(visibleDomain);
				if (targetDomain)
				{
					QString name = targetDomain->GetDomainName();
					projectTree->setCurrentItem(projectTree->findItems(name, Qt::MatchExactly | Qt::MatchRecursive).first());
				}
			}
		}

		if (editSubdomainList)
        {
			if (visibleDomain == fullDomain)
				editSubdomainList->clearSelection();
			else
			{
				SubDomain *targetDomain = DetermineSubdomain(visibleDomain);
				if (targetDomain)
				{
					QString name = targetDomain->GetDomainName();
					editSubdomainList->setCurrentItem(editSubdomainList->findItems(name, Qt::MatchExactly | Qt::MatchRecursive).first());
				}
			}
		}
	}
}
Пример #10
0
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();
}
Пример #11
0
void EditorWidgetQSci::checkUndoRedo()
{
    bool can = m_editor->isUndoAvailable();
    if(can ^ m_canUndo)
    {
        emit undoAvailable(can);
        m_canUndo = can;
    }

    can = m_editor->isRedoAvailable();
    if(can ^ m_canRedo)
    {
        emit redoAvailable(can);
        m_canRedo = can;
    }
}
Пример #12
0
/**
 * 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());
}
Пример #13
0
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;
}
Пример #14
0
int _editor::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QTextEdit::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: redoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 1: undoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 2: selectionChanged(); break;
        case 3: SoundOnEvent(); break;
        case 4: EVENT_OnEvent(); break;
        case 5: EVENT_OnEvent1((*reinterpret_cast< t_boolean(*)>(_a[1])),(*reinterpret_cast< t_boolean(*)>(_a[2])),(*reinterpret_cast< t_boolean(*)>(_a[3])),(*reinterpret_cast< t_boolean(*)>(_a[4]))); break;
        case 6: EVENT_OnCursorPositionChanged(); break;
        case 7: EVENT_OnSQLEvent(); break;
        case 8: frameChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 9: cursoranimation_frameChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        }
        _id -= 10;
    }
    return _id;
}
Пример #15
0
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)));
}
Пример #16
0
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;
}
Пример #17
0
void KickViewHeaderedWidget::loadButtonClicked()
{
  char dirname[260];
  sprintf(dirname, "%s/Config/KickEngine/", File::getBHDir());
  fileName = QFileDialog::getOpenFileName(this,
                                          tr("Open Kick Motion"), dirname, tr("Kick Motion Config Files (*.kmc)"));
  QString name;
  name = fileName.remove(0, fileName.lastIndexOf("/", fileName.lastIndexOf("/") - 1) + 1);

  InMapFile stream(name.toUtf8().constData());
  if(stream.exists())
  {
    stream >> parameters;
    name = name.remove(0, name.lastIndexOf("/") + 1);
    strcpy(parameters.name, name.remove(name.lastIndexOf("."), name.length()).toUtf8().constData());

    parameters.initFirstPhase();
    kickViewWidget->updateEditorView();
    undo.clear();
    redo.clear();
    emit undoAvailable(false);
    emit redoAvailable(false);
    emit saveAvailable(false);
  }
Пример #18
0
void Editor::onRedoAvailable(bool available)
{
    emit redoAvailable(available);
}
Пример #19
0
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"));
    }

}
Пример #20
0
// -------------------------------------------------------------------------------
void Editor::sendRedoAvailableSignal( void )
// -------------------------------------------------------------------------------
{
  if ( isRedoAvailable() )
    emit redoAvailable(true);
}
Пример #21
0
void UndoRedoStack::handleContentsChange(int pos, int removed, int added)
{
	if(m_actionInProgress || (added == 0 && removed == 0)){
		return;
	}
	// Qt Bug? Apparently, when contents is pasted at pos = 0, added and removed are too large by 1
	QTextCursor c(m_textEdit->textCursor());
	c.movePosition(QTextCursor::End);
	int len = c.position();
	if(pos == 0 && added > len){
		--added;
		--removed;
	}
	qDeleteAll(m_redoStack);
	m_redoStack.clear();
	if(removed > 0){
		m_textEdit->document()->undo();
		bool deleteWasUsed = (c.anchor() == c.position() && c.position() == pos);
		c.setPosition(pos);
		c.setPosition(pos + removed, QTextCursor::KeepAnchor);
		UndoableDelete* undoAction = new UndoableDelete(pos, pos + removed, c.selectedText(), deleteWasUsed);
		m_textEdit->document()->redo();
		if(m_undoStack.empty() || !dynamic_cast<UndoableDelete*>(m_undoStack.top())){
			m_undoStack.push(undoAction);
		}else{
			UndoableDelete* prevDelete = static_cast<UndoableDelete*>(m_undoStack.top());
			if(deleteMergeable(prevDelete, undoAction)){
				if(prevDelete->start == undoAction->start){ // Delete key used
					prevDelete->text += undoAction->text;
					prevDelete->end += (undoAction->end - undoAction->start);
				}else{ // Backspace used
					prevDelete->text = undoAction->text + prevDelete->text;
					prevDelete->start = undoAction->start;
				}
			}else{
				m_undoStack.push(undoAction);
			}
		}
	}
	if(added > 0){
		QTextCursor c(m_textEdit->textCursor());
		c.setPosition(pos);
		c.setPosition(pos + added, QTextCursor::KeepAnchor);
		UndoableInsert* undoAction = new UndoableInsert(pos, c.selectedText());
		if(m_undoStack.empty() || !dynamic_cast<UndoableInsert*>(m_undoStack.top())){
			m_undoStack.push(undoAction);
		}else{
			UndoableInsert* prevInsert = static_cast<UndoableInsert*>(m_undoStack.top());
			if(insertMergeable(prevInsert, undoAction)){
				prevInsert->text += undoAction->text;
			}else{
				m_undoStack.push(undoAction);
			}
		}
	}
	// We are only interested in the previous step for delete, no point in storing the rest
	if(added > 0 || removed > 0){
		m_textEdit->document()->clearUndoRedoStacks();
	}
	emit redoAvailable(false);
	emit undoAvailable(true);
}
Пример #22
0
void pEditor::textChanged()
{
    emit undoAvailable( isUndoAvailable() );
    emit redoAvailable( isRedoAvailable() );
}
int QTextDocument::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: contentsChange((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 1: contentsChanged(); break;
        case 2: undoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 3: redoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 4: undoCommandAdded(); break;
        case 5: modificationChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 6: cursorPositionChanged((*reinterpret_cast< const QTextCursor(*)>(_a[1]))); break;
        case 7: blockCountChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 8: documentLayoutChanged(); break;
        case 9: undo(); break;
        case 10: redo(); break;
        case 11: appendUndoItem((*reinterpret_cast< QAbstractUndoItem*(*)>(_a[1]))); break;
        case 12: setModified((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 13: setModified(); break;
        }
        _id -= 14;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = isUndoRedoEnabled(); break;
        case 1: *reinterpret_cast< bool*>(_v) = isModified(); break;
        case 2: *reinterpret_cast< QSizeF*>(_v) = pageSize(); break;
        case 3: *reinterpret_cast< QFont*>(_v) = defaultFont(); break;
        case 4: *reinterpret_cast< bool*>(_v) = useDesignMetrics(); break;
        case 5: *reinterpret_cast< QSizeF*>(_v) = size(); break;
        case 6: *reinterpret_cast< qreal*>(_v) = textWidth(); break;
        case 7: *reinterpret_cast< int*>(_v) = blockCount(); break;
        case 8: *reinterpret_cast< qreal*>(_v) = indentWidth(); break;
        case 9: *reinterpret_cast< QString*>(_v) = defaultStyleSheet(); break;
        case 10: *reinterpret_cast< int*>(_v) = maximumBlockCount(); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setUndoRedoEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 1: setModified(*reinterpret_cast< bool*>(_v)); break;
        case 2: setPageSize(*reinterpret_cast< QSizeF*>(_v)); break;
        case 3: setDefaultFont(*reinterpret_cast< QFont*>(_v)); break;
        case 4: setUseDesignMetrics(*reinterpret_cast< bool*>(_v)); break;
        case 6: setTextWidth(*reinterpret_cast< qreal*>(_v)); break;
        case 8: setIndentWidth(*reinterpret_cast< qreal*>(_v)); break;
        case 9: setDefaultStyleSheet(*reinterpret_cast< QString*>(_v)); break;
        case 10: setMaximumBlockCount(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 11;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}