Skip to content

Commit

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

Closes #747, #746, #742, and #735

See merge request devel/studio!181
  • Loading branch information
MrMontag committed Sep 28, 2018
2 parents 1752c5e + 705df84 commit 9abfa4f
Show file tree
Hide file tree
Showing 31 changed files with 574 additions and 458 deletions.
30 changes: 22 additions & 8 deletions jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
def artifactVersion() {
def data = readFile('version')
def major = data.findAll($/(?m)^STUDIO_MAJOR_VERSION=(\d+)/$).first().split('=').last()
def minor = data.findAll($/(?m)^STUDIO_MINOR_VERSION=(\d+)/$).first().split('=').last()
def patch = data.findAll($/(?m)^STUDIO_PATCH_LEVEL=(\d+)/$).first().split('=').last()
return major + "." + minor + "." + patch
}

pipeline {
agent any

Expand Down Expand Up @@ -137,13 +145,14 @@ pipeline {
./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/studio.desktop -appimage -bundle-non-qt-libs -no-translations -extra-plugins=iconengines -exclude-libs=libnss3,libnssutil3
'''
script {
def versionData = artifactVersion()
if (env.BRANCH_NAME != 'master') {
sh "mv GAMS_Studio-x86_64.AppImage ${env.BRANCH_NAME}-studio.AppImage"
sh "mv GAMS_Studio-x86_64.AppImage ${env.BRANCH_NAME}-studio-${versionData}-x86_64.AppImage"
} else {
sh "mv GAMS_Studio-x86_64.AppImage studio.AppImage"
sh "mv GAMS_Studio-x86_64.AppImage GAMS_Studio-${versionData}-x86_64.AppImage"
}
}
archiveArtifacts artifacts: '**/*studio*.AppImage', fingerprint: true
archiveArtifacts artifacts: '*.AppImage', fingerprint: true
}
},
windowsX86: {
Expand All @@ -160,10 +169,11 @@ pipeline {
'''
}
script {
def versionData = artifactVersion()
if (env.BRANCH_NAME != 'master') {
zip zipFile: "${env.BRANCH_NAME}-studio-x86.zip", archive: true, dir: 'tmp'
zip zipFile: "${env.BRANCH_NAME}-studio-${versionData}-x86_32.zip", archive: true, dir: 'tmp'
} else {
zip zipFile: 'studio-x86.zip', archive: true, dir: 'tmp'
zip zipFile: 'GAMS_Studio-${versionData}-x86_32.zip', archive: true, dir: 'tmp'
}
}
}
Expand All @@ -182,10 +192,11 @@ pipeline {
'''
}
script {
def versionData = artifactVersion()
if (env.BRANCH_NAME != 'master') {
zip zipFile: "${env.BRANCH_NAME}-studio-x64.zip", archive: true, dir: 'tmp'
zip zipFile: "${env.BRANCH_NAME}-studio-${versionData}-x86_64.zip", archive: true, dir: 'tmp'
} else {
zip zipFile: 'studio-x64.zip', archive: true, dir: 'tmp'
zip zipFile: 'GAMS_Studio-${versionData}-x86_64.zip', archive: true, dir: 'tmp'
}
}
}
Expand All @@ -207,8 +218,11 @@ pipeline {
mv "src/bin/GAMS Studio.dmg" studio.dmg
'''
script {
def versionData = artifactVersion()
if (env.BRANCH_NAME != 'master') {
sh "mv studio.dmg ${env.BRANCH_NAME}-studio.dmg"
sh "mv studio.dmg ${env.BRANCH_NAME}-studio-${versionData}-x86_64.dmg"
} else {
sh "mv studio.dmg GAMS_Studio-${versionData}-x86_64.dmg"
}
}
archiveArtifacts artifacts: '*.dmg', fingerprint: true
Expand Down
1 change: 1 addition & 0 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void Application::openAssociatedFiles()
{
mMainWindow->delayedFileRestoration();
mMainWindow->openFiles(mCmdParser.files());
mMainWindow->watchProjectTree();
}

void Application::showExceptionMessage(const QString &title, const QString &message) {
Expand Down
2 changes: 2 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum struct FileKind {
Gsp,
Gms,
Txt,
TxtRO,
Lst,
Lxi,
Log,
Expand All @@ -93,6 +94,7 @@ enum struct EditorType {
undefined = 0,
source = 1,
log = 2,
txt = 3,
lxiLst = 5,
gdx = 6,
ref = 7,
Expand Down
4 changes: 2 additions & 2 deletions src/editors/codeedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ void CodeEdit::keyPressEvent(QKeyEvent* e)
<< Qt::Key_Left << Qt::Key_Right << Qt::Key_PageUp << Qt::Key_PageDown;
if (moveKeys.contains(e->key())) mSmartType = false;

QString opening = "<([{/'\"";
QString closing = ">)]}/'\"";
QString opening = "([{/'\"";
QString closing = ")]}/'\"";
int index = opening.indexOf(e->text());
int indexClosing = closing.indexOf(e->text());

Expand Down
18 changes: 13 additions & 5 deletions src/editors/processlogedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "processlogedit.h"
#include <QMenu>

namespace gams {
namespace studio {
Expand All @@ -36,10 +37,8 @@ void ProcessLogEdit::mouseDoubleClickEvent(QMouseEvent *event)
|| (event->type() == QEvent::MouseButtonRelease && mouseEvent->modifiers()==Qt::ControlModifier)) ) {
} else*/

}


void ProcessLogEdit::mouseReleaseEvent(QMouseEvent *event)
{
AbstractEdit::mouseReleaseEvent(event);
Expand Down Expand Up @@ -72,13 +71,22 @@ void ProcessLogEdit::jumpToLst(QPoint pos, bool fuzzy)
}
}
}
if (linkMark) {
if (linkMark)
linkMark->jumpToRefMark(true);
// setFocus();
}
}
}

void ProcessLogEdit::contextMenuEvent(QContextMenuEvent *e)
{
QMenu *menu = createStandardContextMenu();
QAction act("Clear Log", this);
connect(&act, &QAction::triggered, this, &ProcessLogEdit::clear);
menu->insertAction(menu->actions().at(1), &act);

menu->exec(e->globalPos());
delete menu;
}

AbstractEdit::EditorType ProcessLogEdit::type()
{
return EditorType::ProcessLog;
Expand Down
2 changes: 2 additions & 0 deletions src/editors/processlogedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class ProcessLogEdit : public AbstractEdit
void mouseDoubleClickEvent(QMouseEvent *event) override;

void jumpToLst(QPoint pos, bool fuzzy);
void contextMenuEvent(QContextMenuEvent *e) override;

};

}
Expand Down
44 changes: 27 additions & 17 deletions src/file/dynamicfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
namespace gams {
namespace studio {

DynamicFile::DynamicFile(QString fileName, int backups, QObject *parent): QObject(parent)
DynamicFile::DynamicFile(QString fileName, int backups, QObject *parent): QObject(parent), mBackups(backups)
{
mFile.setFileName(QDir::toNativeSeparators(fileName));
if (mFile.exists())
handleExisting(backups);
runBackupCircle();

mCloseTimer.setSingleShot(true);
mCloseTimer.setInterval(1000);
Expand Down Expand Up @@ -60,6 +60,7 @@ void DynamicFile::closeFile()
mFile.flush();
mFile.close();
mCloseTimer.stop();
runBackupCircle();
}
}

Expand All @@ -73,25 +74,34 @@ void DynamicFile::openFile()
}
}

void DynamicFile::handleExisting(int backups)
void DynamicFile::runBackupCircle()
{
int bkMaxExist = 0;
for (int i = 1; i <= backups; ++i) {
bkMaxExist = i;
if (!QFile(mFile.fileName()+"~"+QString::number(i)).exists())
break;
QStringList names;
int dot = mFile.fileName().lastIndexOf(".")+1;
QString fileBase = mFile.fileName().left(dot);
QString suffix = mFile.fileName().right(mFile.fileName().length()-dot);
names << (fileBase + suffix);
// if filename has a temp-marker add non-temp filename to backup-circle
if (suffix.contains('~')) names.prepend(fileBase + suffix.remove('~'));

// add all backup filenames until the last doesn't exist
for (int i = 1; i <= mBackups; ++i) {
names.prepend(fileBase+suffix+"~"+QString::number(i));
if (!QFile(names.first()).exists()) break;
}
QString destName(mFile.fileName()+"~"+QString::number(bkMaxExist));
QFile file(destName);
if (bkMaxExist == backups)
file.remove();
for (int i = backups-1; i >= 0; --i) {
QString sourceName = mFile.fileName()+ ((i>0) ? "~"+QString::number(i) : "");
file.setFileName(sourceName);
if (file.exists()) file.rename(destName);
// last backup will be overwritten - if it exists, delete it
QFile file(names.first());
if (file.exists()) file.remove();

//
QString destName;
for (QString sourceName: names) {
if (!destName.isEmpty()) {
file.setFileName(sourceName);
if (file.exists()) file.rename(destName);
}
destName = sourceName;
}
if (mFile.exists()) mFile.remove();
}

} // namespace studio
Expand Down
3 changes: 2 additions & 1 deletion src/file/dynamicfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ private slots:

private:
void openFile();
void handleExisting(int backups);
void runBackupCircle();

private:
QMutex mMutex;
QFile mFile;
QTimer mCloseTimer;
int mBackups = 0;
};

} // namespace studio
Expand Down
Loading

0 comments on commit 9abfa4f

Please sign in to comment.