Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Develop

See merge request devel/studio!296
  • Loading branch information
rgoltermann committed Jun 28, 2019
2 parents 5f2f53e + 03f1f7a commit 8bd3baf
Show file tree
Hide file tree
Showing 109 changed files with 12,304 additions and 1,196 deletions.
31 changes: 13 additions & 18 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
Version 0.11.3
Version 0.12.0
========================

# General
- fixed status bar cursor position not updating in lst files
## General
- **added GAMS Solver Option Editor (requires GAMS 27.0)**
- fixed crash when running studio with --ignore-settings and double clicking a word (fixes #1031)
- fixed freeze when exiting studio during startup procedure
- added Ctrl+H to focus main editor
- added Ctrl+Shift+G to focus logs
- added Esc to close several widgets
- added icons to toolbar to show/hide project explorer, logs, and help
- adjusted row height of all tables to be equal (#1002)
- discarded file stays marked as modified (fixes #1018)

# GDX Viewer
- added column auto-shrink for table view
- added shortcut for auto-shrink (Ctrl+R)

# Search
- many improvements and bug fixes to highlighting of search results
- general fixes of bugs, crashes, etc.
- added shortcut Ctrl+Enter for "Search All"
- improved tab order in search dialog. now repolace textfield comes right after search textfield
- added ability to replace in more than one file at a time. there is a safety dialog showing how many files are being affected and the user can start a search to find all matches being affected.
- Find Next/Previous now respects all search options and will jump to the next file if there are also matches
- lst files now also have a match counter when stepping through with Find Next/Previous
- results view now supports enter key to select and jump to a result
- changed position of search dialog
- minor layout adjustments to search dialog
## Search
- fixed cursor not jumping to first match on first try in lst file (fixes #1039)

1 change: 1 addition & 0 deletions icons/clipboard-list.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/comment-alt-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@
<file alias="minus">minus.svg</file>
<file alias="move-up">move-up.svg</file>
<file alias="move-down">move-down.svg</file>
<file alias="output">comment-alt-lines.svg</file>
<file alias="paste">paste.svg</file>
<file alias="pause">pause.svg</file>
<file alias="pen">pen-alt.svg</file>
<file alias="play">play.svg</file>
<file alias="plus">plus.svg</file>
<file alias="question">question.svg</file>
<file alias="project">clipboard-list.svg</file>
<file alias="question">question-square.svg</file>
<file alias="redo">redo.svg</file>
<file alias="ref-file">ref-file.svg</file>
<file alias="run-gdx">play-gdx.svg</file>
Expand All @@ -71,6 +73,8 @@
<file alias="camera">camera.png</file>
<file alias="show">angle-double-down.svg</file>
<file alias="hide">angle-double-up.svg</file>
<file alias="square-darkyellow">square-darkyellow.svg</file>
<file alias="option-file">option.svg</file>
</qresource>
<qresource prefix="/data">
<file>style.css</file>
Expand Down
7 changes: 7 additions & 0 deletions icons/option.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/question-square.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 0 additions & 10 deletions icons/question.svg

This file was deleted.

9 changes: 9 additions & 0 deletions icons/square-darkyellow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions jenkinsfile-ci
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,4 @@ pipeline {
}
}
}

5 changes: 4 additions & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ enum class FileKind {
Lxi,
Log,
Gdx,
Ref
Ref,
Opt
};
Q_ENUM_NS(FileKind)

Expand All @@ -107,6 +108,7 @@ enum class EditorType {
lxiLst = 6,
gdx = 7,
ref = 8,
opt = 9,
};
Q_ENUM_NS(EditorType)

Expand All @@ -130,6 +132,7 @@ operator<<(QTextStream &dbg, T enumValue)
}

const int MAX_SEARCH_RESULTS = 50000;
const double TABLE_ROW_HEIGHT = 1.6;

}
}
Expand Down
2 changes: 2 additions & 0 deletions src/editors/abstractedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ void AbstractEdit::keyPressEvent(QKeyEvent *e)
if (!mMarksAtMouse.isEmpty()) mMarksAtMouse.first()->cursorShape(&shape, true);
}
viewport()->setCursor(shape);

QWidget::keyPressEvent(e);
}

void AbstractEdit::keyReleaseEvent(QKeyEvent *e)
Expand Down
7 changes: 1 addition & 6 deletions src/editors/processlogedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "processlogedit.h"
#include <QMenu>
#include <QScrollBar>
#include <QDebug>

namespace gams {
namespace studio {
Expand Down Expand Up @@ -91,12 +92,6 @@ void ProcessLogEdit::extraSelCurrentLine(QList<QTextEdit::ExtraSelection> &selec
return;
}

//void ProcessLogEdit::extraSelMarks(QList<QTextEdit::ExtraSelection> &selections)
//{
// Q_UNUSED(selections);
// return;
//}

AbstractEdit::EditorType ProcessLogEdit::type()
{
return EditorType::ProcessLog;
Expand Down
1 change: 0 additions & 1 deletion src/editors/processlogedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class ProcessLogEdit : public AbstractEdit
void jumpToLst(QPoint pos, bool fuzzy);
void contextMenuEvent(QContextMenuEvent *e) override;
void extraSelCurrentLine(QList<QTextEdit::ExtraSelection> &selections) override;
// void extraSelMarks(QList<QTextEdit::ExtraSelection> &selections) override;

};

Expand Down
8 changes: 8 additions & 0 deletions src/editors/viewhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "textview.h"
#include "gdxviewer/gdxviewer.h"
#include "lxiviewer/lxiviewer.h"
#include "option/solveroptionwidget.h"
#include "reference/referenceviewer.h"
#include <QWidget>

Expand Down Expand Up @@ -54,6 +55,10 @@ class ViewHelper
if(w) w->setProperty("EditorType", int(EditorType::ref));
return w;
}
inline static option::SolverOptionWidget* initEditorType(option::SolverOptionWidget * w) {
if(w) w->setProperty("EditorType", int(EditorType::opt));
return w;
}

inline static EditorType editorType(QWidget* w) {
QVariant v = w ? w->property("EditorType") : QVariant();
Expand Down Expand Up @@ -89,6 +94,9 @@ class ViewHelper
inline static reference::ReferenceViewer* toReferenceViewer(QWidget* w) {
return (editorType(w) == EditorType::ref) ? static_cast<reference::ReferenceViewer*>(w) : nullptr;
}
inline static option::SolverOptionWidget* toSolverOptionEdit(QWidget* w) {
return (editorType(w) == EditorType::opt) ? static_cast<option::SolverOptionWidget*>(w) : nullptr;
}


};
Expand Down
95 changes: 73 additions & 22 deletions src/file/filemeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <QPlainTextDocumentLayout>
#include <QTextCodec>
#include <QScrollBar>
#include <QMessageBox>

namespace gams {
namespace studio {
Expand Down Expand Up @@ -123,18 +122,29 @@ void FileMeta::setEditPositions(QVector<QPoint> edPositions)

void FileMeta::internalSave(const QString &location)
{
QFile file(location);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
EXCEPT() << "Can't save " << location;
QTextStream out(&file);
if (mCodec) out.setCodec(mCodec);
mActivelySaved = true;
out << document()->toPlainText();
out.flush();
file.close();
mData = Data(location, mData.type);
document()->setModified(false);
mFileRepo->watch(this);
if (document()) {
QFile file(location);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
EXCEPT() << "Can't save " << location;
QTextStream out(&file);
if (mCodec) out.setCodec(mCodec);
mActivelySaved = true;
out << document()->toPlainText();
out.flush();
file.close();
mData = Data(location, mData.type);
setModified(false);
mFileRepo->watch(this);
} else if (kind() == FileKind::Opt) {
option::SolverOptionWidget* solverOptionWidget = ViewHelper::toSolverOptionEdit( mEditors.first() );
if (solverOptionWidget) {
mActivelySaved = true;
solverOptionWidget->saveOptionFile(location);
mData = Data(location, mData.type);
setModified(false);
mFileRepo->watch(this);
}
}
}

bool FileMeta::checkActivelySavedAndReset()
Expand Down Expand Up @@ -308,6 +318,7 @@ void FileMeta::addEditor(QWidget *edit)
ViewHelper::setLocation(edit, location());
ViewHelper::setFileId(edit, id());
AbstractEdit* aEdit = ViewHelper::toAbstractEdit(edit);
option::SolverOptionWidget* soEdit = ViewHelper::toSolverOptionEdit(edit);

if (aEdit) {
if (!mDocument)
Expand All @@ -331,6 +342,9 @@ void FileMeta::addEditor(QWidget *edit)
connect(tv->edit(), &AbstractEdit::jumpToNextBookmark, mFileRepo, &FileMetaRepo::jumpToNextBookmark);
tv->setMarks(mFileRepo->textMarkRepo()->marks(mId));
}
if (soEdit) {
connect(soEdit, &option::SolverOptionWidget::modificationChanged, this, &FileMeta::modificationChanged);
}
if (mEditors.size() == 1) emit documentOpened();
if (aEdit)
aEdit->setMarks(mFileRepo->textMarkRepo()->marks(mId));
Expand All @@ -348,6 +362,7 @@ void FileMeta::removeEditor(QWidget *edit)

AbstractEdit* aEdit = ViewHelper::toAbstractEdit(edit);
CodeEdit* scEdit = ViewHelper::toCodeEdit(edit);
option::SolverOptionWidget* soEdit = ViewHelper::toSolverOptionEdit(edit);
mEditors.removeAt(i);

if (aEdit) {
Expand All @@ -369,6 +384,9 @@ void FileMeta::removeEditor(QWidget *edit)
disconnect(tv->edit(), &AbstractEdit::toggleBookmark, mFileRepo, &FileMetaRepo::toggleBookmark);
disconnect(tv->edit(), &AbstractEdit::jumpToNextBookmark, mFileRepo, &FileMetaRepo::jumpToNextBookmark);
}
if (soEdit) {
disconnect(soEdit, &option::SolverOptionWidget::modificationChanged, this, &FileMeta::modificationChanged);
}

if (mEditors.isEmpty()) {
mFileRepo->textMarkRepo()->removeMarks(id(), QSet<TextMark::Type>() << TextMark::bookmark);
Expand Down Expand Up @@ -419,7 +437,19 @@ void FileMeta::load(int codecMib, bool init)
}
return;
}

if (kind() == FileKind::Opt) {
bool textOptEditor = true;
for (QWidget *wid : mEditors) {
option::SolverOptionWidget *so = ViewHelper::toSolverOptionEdit(wid);
if (so) {
textOptEditor = false;
mCodec = QTextCodec::codecForMib(codecMib);
so->on_reloadSolverOptionFile(mCodec);
}
}
if (!textOptEditor)
return;
}

QFile file(location());
bool canOpen = true;
Expand Down Expand Up @@ -458,7 +488,7 @@ void FileMeta::load(int codecMib, bool init)
SysLogLocator::systemLog()->append("System doesn't contain codec for MIB " + QString::number(codecMib), LogMsgType::Info);
}
file.close();
document()->setModified(false);
setModified(false);
return;
}
return;
Expand Down Expand Up @@ -574,7 +604,16 @@ void FileMeta::reloadDelayed()

bool FileMeta::isModified() const
{
return mDocument ? mDocument->isModified() : false;
if (mDocument) {
return mDocument->isModified();
} else if (kind() == FileKind::Opt) {
for (QWidget *wid: mEditors) {
option::SolverOptionWidget *solverOptionWidget = ViewHelper::toSolverOptionEdit(wid);
if (solverOptionWidget)
return solverOptionWidget->isModified();
}
}
return false;
}

bool FileMeta::isReadOnly() const
Expand Down Expand Up @@ -603,6 +642,18 @@ void FileMeta::resetTempReloadState()
mTempAutoReloadTimer.start(1500);
}

void FileMeta::setModified(bool modified)
{
if (document()) {
document()->setModified(modified);
} else if (kind() == FileKind::Opt) {
for (QWidget *e : mEditors) {
option::SolverOptionWidget *so = ViewHelper::toSolverOptionEdit(e);
if (so) so->setModified(modified);
}
}
}

QTextDocument *FileMeta::document() const
{
return mDocument;
Expand All @@ -620,8 +671,8 @@ void FileMeta::setCodecMib(int mib)
DEB() << "TextCodec not found for MIB " << mib;
return;
}
if (document() && !isReadOnly() && codec != mCodec) {
document()->setModified();
if (!isReadOnly() && codec != mCodec) {
setModified(true);
}
setCodec(codec);
}
Expand Down Expand Up @@ -656,24 +707,24 @@ bool FileMeta::isOpen() const
return !mEditors.isEmpty();
}

QWidget* FileMeta::createEdit(QTabWidget *tabWidget, ProjectRunGroupNode *runGroup, int codecMib)
QWidget* FileMeta::createEdit(QTabWidget *tabWidget, ProjectRunGroupNode *runGroup, int codecMib, bool forcedAsTextEdit)
{
QWidget* res = nullptr;
if (codecMib == -1) codecMib = FileMeta::codecMib();
if (codecMib == -1) codecMib = QTextCodec::codecForLocale()->mibEnum();
mCodec = QTextCodec::codecForMib(codecMib);
if (kind() == FileKind::Gdx) {
res = ViewHelper::initEditorType(new gdxviewer::GdxViewer(location(), CommonPaths::systemDir(), mCodec, tabWidget));
} else if (kind() == FileKind::Ref) {
// TODO: multiple ReferenceViewers share one Reference Object of the same file
// instead of holding individual Reference Object
} else if (kind() == FileKind::Ref && !forcedAsTextEdit) {
res = ViewHelper::initEditorType(new reference::ReferenceViewer(location(), mCodec, tabWidget));
} else if (kind() == FileKind::TxtRO || kind() == FileKind::Lst) {
TextView* tView = ViewHelper::initEditorType(new TextView(tabWidget));
res = tView;
tView->loadFile(location(), codecMib, true);
if (kind() == FileKind::Lst)
res = ViewHelper::initEditorType(new lxiviewer::LxiViewer(tView, location(), tabWidget));
} else if (kind() == FileKind::Opt && !forcedAsTextEdit) {
res = ViewHelper::initEditorType(new option::SolverOptionWidget(QFileInfo(name()).completeBaseName(), location(), id(), mCodec, tabWidget));
} else {
AbstractEdit *edit = nullptr;
CodeEdit *codeEdit = nullptr;
Expand Down
Loading

0 comments on commit 8bd3baf

Please sign in to comment.