Skip to content

Commit

Permalink
Merge bd80883 into 7eca997
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Jun 8, 2018
2 parents 7eca997 + bd80883 commit 7217a7e
Show file tree
Hide file tree
Showing 15 changed files with 489 additions and 285 deletions.
2 changes: 1 addition & 1 deletion doc/downloads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var jsonData = { "versions": [
}
],
"changes": [
{ "change": "<strong>Text-based editors:</strong> prevent infinite \"Replace all\" actions (see issue <a href=\"https://github.com/opencor/opencor/issues/1677\">#1677</a>). Now have word-wrap alignment <a href=\"https://github.com/opencor/opencor/issues/1680\">#1680</a>)." },
{ "change": "<strong>Text-based editors:</strong> prevent infinite \"Replace all\" actions (see issue <a href=\"https://github.com/opencor/opencor/issues/1677\">#1677</a>). Sped up our highlight/replace all method (see issue <a href=\"https://github.com/opencor/opencor/issues/1679\">#1679</a>). Now have word-wrap alignment <a href=\"https://github.com/opencor/opencor/issues/1680\">#1680</a>)." },
{ "change": "<strong>Third-party libraries:</strong> upgraded <a href=\"https://libgit2.github.com/\">libgit2</a> to version 0.27.1 (see issue <a href=\"https://github.com/opencor/opencor/issues/1672\">#1672</a>)." }
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ void CellMLEditingViewPlugin::updateGui(Plugin *pViewPlugin,
EditingViewInterface *editingViewInterface = pViewPlugin?qobject_cast<EditingViewInterface *>(pViewPlugin->instance()):0;

if (editingViewInterface) {
EditorWidget::EditorWidget *editorWidget = editingViewInterface->editorWidget(pFileName);
EditorWidget::EditorWidget *editor = editingViewInterface->editorWidget(pFileName);

if (editorWidget) {
editorWidget->setContextMenu(editorWidget->contextMenu()->actions() << mEditReformatSeparator
<< mEditReformatAction
<< mToolsCellmlValidationSeparator
<< mToolsCellmlValidationAction);
if (editor) {
editor->setContextMenu(editor->contextMenu()->actions() << mEditReformatSeparator
<< mEditReformatAction
<< mToolsCellmlValidationSeparator
<< mToolsCellmlValidationAction);
}
}

Expand Down
42 changes: 19 additions & 23 deletions src/plugins/editing/CellMLTextView/src/cellmltextviewwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "corecliutils.h"
#include "coreguiutils.h"
#include "editorlistwidget.h"
#include "editorwidget.h"
#include "editorwidgeteditorwidget.h"
#include "filemanager.h"
#include "mathmlviewerwidget.h"
Expand Down Expand Up @@ -239,7 +238,7 @@ bool CellmlTextViewWidgetEditingWidget::handleEditorKeyPressEvent(QKeyEvent *pEv
// line, so start by retrieving the position of our cursor within our
// editor

EditorWidget::EditorWidgetEditorWidget *editor = editorWidget()->editor();
EditorWidget::EditorWidget *editor = editorWidget();
int line, column;

editor->cursorPosition(line, column);
Expand All @@ -252,9 +251,9 @@ bool CellmlTextViewWidgetEditingWidget::handleEditorKeyPressEvent(QKeyEvent *pEv

int lineFrom, columnFrom, lineTo, columnTo;

editor->getSelection(&lineFrom, &columnFrom, &lineTo, &columnTo);
editor->selection(lineFrom, columnFrom, lineTo, columnTo);

int selectedTextEndPosition = editor->positionFromLineIndex(lineTo, columnTo);
int selectedTextEndPosition = editor->position(lineTo, columnTo);
QString editorEolString = editor->eolString();

if ( !columnFrom
Expand Down Expand Up @@ -355,13 +354,13 @@ bool CellmlTextViewWidgetEditingWidget::handleEditorKeyPressEvent(QKeyEvent *pEv
// case we need to update it

if (!column)
editor->QsciScintilla::setCursorPosition(line, column+SingleLineCommentLength);
editor->setCursorPosition(line, column+SingleLineCommentLength);
} else {
// We uncommented the line, so go back to our original
// position (since uncommenting the line will have shifted
// it a bit)

editor->QsciScintilla::setCursorPosition(line, column-SingleLineCommentLength);
editor->setCursorPosition(line, column-SingleLineCommentLength);
}
}
}
Expand All @@ -376,35 +375,29 @@ bool CellmlTextViewWidgetEditingWidget::handleEditorKeyPressEvent(QKeyEvent *pEv

//==============================================================================

bool CellmlTextViewWidgetEditingWidget::commentOrUncommentLine(QScintillaSupport::QScintillaWidget *pEditorWidget,
bool CellmlTextViewWidgetEditingWidget::commentOrUncommentLine(EditorWidget::EditorWidget *pEditor,
int pLineNumber,
bool pCommentLine)
{
// (Un)comment the current line

QString line = pEditorWidget->text(pLineNumber).trimmed();
QString line = pEditor->text(pLineNumber).trimmed();

if (line.isEmpty())
return false;

// We are not dealing with an empty line, so we can (un)comment it

if (pCommentLine) {
pEditorWidget->insertAt(SingleLineCommentString, pLineNumber, 0);
pEditor->insertText(SingleLineCommentString, pLineNumber, 0);
} else {
// Uncomment the line, should it be commented

if (line.startsWith(SingleLineCommentString)) {
int commentLineNumber, commentColumnNumber;

pEditorWidget->lineIndexFromPosition(pEditorWidget->findTextInRange(pEditorWidget->positionFromLineIndex(pLineNumber, 0),
pEditorWidget->contentsSize(), SingleLineCommentString,
false, false, false),
&commentLineNumber, &commentColumnNumber);

pEditorWidget->setSelection(commentLineNumber, commentColumnNumber,
commentLineNumber, commentColumnNumber+SingleLineCommentLength);
pEditorWidget->removeSelectedText();
pEditor->removeText(pEditor->findTextInRange(pEditor->position(pLineNumber, 0),
pEditor->contentsSize(), SingleLineCommentString,
false, false, false),
SingleLineCommentLength);
}
}

Expand Down Expand Up @@ -516,7 +509,7 @@ void CellmlTextViewWidget::initialize(const QString &pFileName, bool pUpdate)
// The conversion was successful, so we can apply our CellML Text
// lexer to our editor

editingWidget->editorWidget()->editor()->setLexer(new CellmlTextViewLexer(this));
editingWidget->editorWidget()->setLexer(new CellmlTextViewLexer(this));

// Update our viewer whenever necessary

Expand All @@ -543,7 +536,7 @@ void CellmlTextViewWidget::initialize(const QString &pFileName, bool pUpdate)

// Apply an XML lexer to our editor

editingWidget->editorWidget()->editor()->setLexer(new QsciLexerXML(this));
editingWidget->editorWidget()->setLexer(new QsciLexerXML(this));
}

// Keep track of our editing widget (and of whether the conversion was
Expand Down Expand Up @@ -1162,10 +1155,13 @@ QString CellmlTextViewWidget::statement(int pPosition) const
void CellmlTextViewWidget::updateViewer()
{
// Make sure that we still have an editing widget (i.e. it hasn't been
// closed since the signal was emitted)
// closed since the signal was emitted) and that its editor allows us to
// handle connections

if (!mEditingWidget)
if ( !mEditingWidget
|| !mEditingWidget->editorWidget()->handleEditorChanges()) {
return;
}

// Retrieve the statement, if any, around our current position

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class CellmlTextViewWidgetEditingWidget : public CellMLEditingView::CellmlEditin
bool handleEditorKeyPressEvent(QKeyEvent *pEvent) override;

private:
bool commentOrUncommentLine(QScintillaSupport::QScintillaWidget *pEditorWidget,
bool commentOrUncommentLine(EditorWidget::EditorWidget *pEditor,
int pLineNumber, bool pCommentLine);
};

Expand Down
17 changes: 16 additions & 1 deletion src/plugins/editing/EditingView/src/editingviewplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "coreguiutils.h"
#include "editingviewinterface.h"
#include "editingviewplugin.h"
#include "editorwidget.h"
#include "editorwidgeteditorwidget.h"
#include "filemanager.h"

//==============================================================================
Expand Down Expand Up @@ -470,6 +470,11 @@ void EditingViewPlugin::clipboardDataChanged()

void EditingViewPlugin::updateUndoAndRedoActions()
{
// Make sure that our editor allows us to handle connections

if (!mEditor->handleEditorChanges())
return;

// Update our undo/redo actions, and update the modified state of the
// current file

Expand All @@ -488,6 +493,11 @@ void EditingViewPlugin::updateUndoAndRedoActions()

void EditingViewPlugin::updateEditingActions()
{
// Make sure that our editor allows us to handle connections

if (!mEditor->handleEditorChanges())
return;

// Update our editing actions

if (mEditingViewInterface) {
Expand Down Expand Up @@ -519,6 +529,11 @@ void EditingViewPlugin::updateFindPreviousNextActions()

void EditingViewPlugin::updateSelectAllAction()
{
// Make sure that our editor allows us to handle connections

if (!mEditor->handleEditorChanges())
return;

// Update our select all action

if (mEditingViewInterface)
Expand Down
9 changes: 6 additions & 3 deletions src/plugins/editing/RawCellMLView/src/rawcellmlviewwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "cellmleditingviewwidget.h"
#include "corecliutils.h"
#include "editorlistwidget.h"
#include "editorwidget.h"
#include "editorwidgeteditorwidget.h"
#include "filemanager.h"
#include "mathmlviewerwidget.h"
#include "rawcellmlviewwidget.h"
Expand Down Expand Up @@ -489,10 +489,13 @@ QString RawCellmlViewWidget::retrieveContentMathmlEquation(const QString &pConte
void RawCellmlViewWidget::updateViewer()
{
// Make sure that we still have an editing widget (i.e. it hasn't been
// closed since the signal was emitted)
// closed since the signal was emitted) and that its editor allows us to
// handle connections

if (!mEditingWidget)
if ( !mEditingWidget
|| !mEditingWidget->editorWidget()->handleEditorChanges()) {
return;
}

// Retrieve the Content MathML block around our current position, if any

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ void SEDMLEditingViewPlugin::updateGui(Plugin *pViewPlugin,
EditingViewInterface *editingViewInterface = pViewPlugin?qobject_cast<EditingViewInterface *>(pViewPlugin->instance()):0;

if (editingViewInterface) {
EditorWidget::EditorWidget *editorWidget = editingViewInterface->editorWidget(pFileName);
EditorWidget::EditorWidget *editor = editingViewInterface->editorWidget(pFileName);

if (editorWidget) {
editorWidget->setContextMenu(editorWidget->contextMenu()->actions() << mEditReformatSeparator
<< mEditReformatAction
<< mToolsSedmlValidationSeparator
<< mToolsSedmlValidationAction);
if (editor) {
editor->setContextMenu(editor->contextMenu()->actions() << mEditReformatSeparator
<< mEditReformatAction
<< mToolsSedmlValidationSeparator
<< mToolsSedmlValidationAction);
}
}

Expand Down

0 comments on commit 7217a7e

Please sign in to comment.