diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad13a95..b4fe7d2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,20 +1,8 @@ stages: - build - - bundle - -.win_build_template: &win_build_definition - stage: build - script: - - if not exist "build" mkdir build - - if not exist "ide" mkdir ide - - cd build - - echo set -x; export PATH=`cygpath -u %QTDIR%/bin`:$PATH; qmake "CONFIG+=bundled" "DEFINES+=MINIZINC_IDE_BUILD=\\\\\\\"\"${CI_PIPELINE_ID}\\\\\\\"\"" ../MiniZincIDE/MiniZincIDE.pro; nmake; cp release/MiniZincIDE.exe ../ide; cd ../ide; windeployqt --no-translations --no-compiler-runtime --no-system-d3d-compiler MiniZincIDE.exe > build.sh - - d2u build.sh - - bash build.sh - artifacts: - paths: - - ide/ + - package +# ----------- Build MiniZincIDE ----------- build:linux: stage: build @@ -26,65 +14,269 @@ build:linux: - make -j4 INSTALL_ROOT=../ide install; find ../ide/ - cd .. - linuxdeployqt ide/usr/bin/MiniZincIDE -bundle-non-qt-libs -no-translations -no-copy-copyright-files - tags: - - linux - - docker + # Workaround for: https://github.com/probonopd/linuxdeployqt/issues/35 + - "repoquery -l nss-softokn | grep lib64 | grep '.so\\|.chk' | xargs -i cp -R {} ./ide/usr/lib/" + tags: [linux, docker] artifacts: - paths: - - ide/ - cache: - key: "linux_$CI_COMMIT_REF_SLUG" - paths: - - build/ + paths: [ide/] build:osx: stage: build - variables: - QTDIR: "$OSXQTDIR" script: - - export PATH="$QTDIR/bin:$PATH" - mkdir -p build; cd build - qmake -makefile "CONFIG+=bundled" "DEFINES+=MINIZINC_IDE_BUILD=\\\\\\\"\"${CI_PIPELINE_ID}\\\\\\\"\"" ../MiniZincIDE/MiniZincIDE.pro - make -j4 - cp -r MiniZincIDE.app .. - tags: - - osx - - cpp - - qt + tags: [osx, cpp, qt] artifacts: - paths: - - MiniZincIDE.app - cache: - key: "osx_$CI_COMMIT_REF_SLUG" - paths: - - build/ + paths: [MiniZincIDE.app] -.build:win32: #DISABLED - <<: *win_build_definition - variables: - QTDIR: "$WINQTDIR" +build:win64: + stage: build + script: + - if not exist "build" mkdir build + - if not exist "ide" mkdir ide + - cd build + - qmake "CONFIG+=bundled" "DEFINES+=MINIZINC_IDE_BUILD=\\\\\\\"\"%CI_PIPELINE_ID%\\\\\\\"\"" ../MiniZincIDE/MiniZincIDE.pro + - nmake + - cp release/MiniZincIDE.exe ../ide + - cd ../ide + - windeployqt --no-translations --no-compiler-runtime --no-system-d3d-compiler MiniZincIDE.exe + tags: [win64, cpp, qt] + artifacts: + paths: [ide/] + +# ----------- MiniZinc Packaging ----------- +.packaging_setup: &packaging_setup before_script: - - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0/VC/vcvarsall.bat" - tags: - - win32 - - cpp - - qt - cache: - key: "win32_$CI_COMMIT_REF_SLUG" - paths: - - build/ + ### Set the MZNVERSION variable + - "if [ -n \"$CI_COMMIT_TAG\" ]; then MZNVERSION=\"$CI_COMMIT_TAG\"; else MZNVERSION=\"build$CI_PIPELINE_ID\"; fi" + ### Choose the MiniZinc compiler branch + - "if [ -n \"$CI_COMMIT_TAG\" ]; then MZNREF=\"$CI_COMMIT_TAG\"; elif [ \"$CI_COMMIT_REF_NAME\" = \"master\" ]; then MZNREF=\"master\"; else MZNREF=\"develop\"; fi" + ### Download Dependencies + - curl --silent -o minizinc.zip --location --header "PRIVATE-TOKEN:$ACCESS_TOKEN" "https://gitlab.com/api/v4/projects/minizinc%2Fminizinc/jobs/artifacts/$MZNREF/download?job=build:$MZNARCH" + - unzip -q minizinc.zip + - "[ ${DOWNLOAD_SOLVERS:-1} -eq 1 ] && curl --silent -o vendor.zip --location --header \"PRIVATE-TOKEN:$ACCESS_TOKEN\" \"https://gitlab.com/api/v4/projects/minizinc%2Fvendor/jobs/artifacts/master/download?job=bundle:$MZNARCH\" && unzip -q vendor.zip" + - "[ ${DOWNLOAD_GLOBALIZER:-0} -eq 1 ] && curl --silent -o globalizer.zip --location --header \"PRIVATE-TOKEN:$ACCESS_TOKEN\" \"https://gitlab.com/api/v4/projects/minizinc%2FGlobalizer/jobs/artifacts/master/download?job=build:$MZNARCH\" && unzip -q globalizer.zip" + - "[ ${DOWNLOAD_FINDMUS:-0} -eq 1 ] && curl --silent -o findmus.zip --location --header \"PRIVATE-TOKEN:$ACCESS_TOKEN\" \"https://gitlab.com/api/v4/projects/minizinc%2FFindMUS/jobs/artifacts/master/download?job=build:$MZNARCH\" && unzip -q findmus.zip" -build:win64: - <<: *win_build_definition +package:linux: + stage: package + image: dekker1/minibuild:package + variables: + MZNARCH: "linux" + DOWNLOAD_GLOBALIZER: 1 + DOWNLOAD_FINDMUS: 1 + <<: *packaging_setup + script: + - PACKAGE=MiniZincIDE-${MZNVERSION}-bundle-linux + - mkdir -p $PACKAGE/ + ### Package IDE + - mv ide/usr/* $PACKAGE/ + - cp resources/scripts/MiniZincIDE.sh $PACKAGE/ + ### Package MiniZinc + - mv minizinc/bin/* $PACKAGE/bin/ + - mv minizinc/share $PACKAGE/share + ### Package vendor solvers + - mv vendor/gecode/bin/fzn-gecode $PACKAGE/bin/ + - mv vendor/gecode/share/gecode/mznlib $PACKAGE/share/minizinc/gecode + - mv vendor/chuffed/bin/fzn-chuffed $PACKAGE/bin/ + - mv vendor/chuffed/share/chuffed/mznlib $PACKAGE/share/minizinc/chuffed + ### Package Globalizer + - mv globalizer/bin/minizinc-globalizer $PACKAGE/bin/ + - mv globalizer/share/globalizer/mznlib $PACKAGE/share/minizinc/globalizer + ### Package findMUS + - mv findMUS/bin/findMUS $PACKAGE/bin/ + ### Package solver scripts + - cp resources/scripts/fzn-gecode-gist $PACKAGE/bin/ + ### Package default settings + - mkdir -p $PACKAGE/share/minizinc/solvers/ + - cp resources/solvers/*.msc $PACKAGE/share/minizinc/solvers/ + - cp resources/Preferences.json $PACKAGE/share/minizinc/ + ### Strip included binaries + - (cd $PACKAGE/bin; strip minizinc fzn-gecode fzn-chuffed findMUS minizinc-globalizer mzn2doc) + - cp resources/misc/README $PACKAGE + ### Compress package + - tar -czf $PACKAGE.tgz $PACKAGE + ### Generate checksum + - sha256sum $PACKAGE.tgz > $PACKAGE.sha256 + artifacts: + name: "minizinc_bundle_linux_${CI_PIPELINE_ID}" + paths: [MiniZincIDE*.tgz, MiniZincIDE*.sha256] + dependencies: ["build:linux"] + tags: [linux, docker] + +package:osx: + stage: package + variables: + MZNARCH: "osx" + DOWNLOAD_GLOBALIZER: 1 + DOWNLOAD_FINDMUS: 1 + <<: *packaging_setup + script: + - "DIR=MiniZincIDE.app/Contents/Resources; MZNDIR=$DIR/share/minizinc" + - mkdir -p $MZNDIR/solvers + ### Package MiniZinc + - mv minizinc/bin/* $DIR/ + - mv minizinc/share/minizinc/* $MZNDIR/ + ### Package vendor solvers + - mkdir -p $DIR/bin/ + - mv vendor/gecode/bin/fzn-gecode $DIR/bin/ + - (cd $DIR; ln -s gecode/fzn-gecode) + - mv vendor/gecode/share/gecode/mznlib $MZNDIR/gecode + - mv vendor/chuffed/bin/fzn-chuffed $DIR/bin/ + - mv vendor/chuffed/share/chuffed/mznlib $MZNDIR/chuffed + ### Package Globalizer + - mv globalizer/bin/minizinc-globalizer $DIR/bin/ + - mv globalizer/share/globalizer/mznlib $MZNDIR/globalizer + ### Package findMUS + - mv findMUS/bin/findMUS $DIR/bin/ + ### Package solver scripts + - cp resources/scripts/fzn-gecode-gist $DIR/bin/ + ### Package default settings + - cp resources/solvers/*.msc $MZNDIR/solvers + - cp resources/Preferences.json $MZNDIR/ + ### Run automated Qt deployment tool + - macdeployqt ./MiniZincIDE.app -executable=$DIR/bin/fzn-gecode + artifacts: + name: "minizinc_bundle_mac_${CI_PIPELINE_ID}" + paths: [MiniZincIDE.app] + dependencies: ["build:osx"] + tags: [osx, qt] + +package:win64: + stage: package variables: - QTDIR: "$WINQTDIR" + MZNARCH: "win64" + MSVCREDIST: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Redist/MSVC/14.16.27012/x64/Microsoft.VC141.CRT" + UCRTREDIST: "C:/Program Files (x86)/Windows Kits/10/Redist/ucrt/DLLs/x64" + ISSARCH: "x64" + ISSARCHALLOWED: "x64" before_script: - - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0/VC/vcvarsall.bat" amd64 - tags: - - win64 - - cpp - - qt - cache: - key: "win64_$CI_COMMIT_REF_SLUG" - paths: - - build/ + ### Set the MZNVERSION variable + - if defined CI_COMMIT_TAG (set MZNVERSION=%CI_COMMIT_TAG%) else (set MZNVERSION=%CI_PIPELINE_ID%) + ### Choose the MiniZinc compiler branch + - if defined CI_COMMIT_TAG (set MZNREF=%CI_COMMIT_TAG%) else if %CI_COMMIT_REF_NAME%==master (set MZNREF=master) else (set MZNREF=develop) + ### Download Dependencies + - curl --silent -o minizinc.zip --location --header "PRIVATE-TOKEN:%ACCESS_TOKEN%" "https://gitlab.com/api/v4/projects/minizinc%%2Fminizinc/jobs/artifacts/%MZNREF%/download?job=build:%MZNARCH%" + - unzip -q minizinc.zip + - curl --silent -o vendor.zip --location --header "PRIVATE-TOKEN:%ACCESS_TOKEN%" "https://gitlab.com/api/v4/projects/minizinc%%2Fvendor/jobs/artifacts/master/download?job=bundle:%MZNARCH%" + - unzip -q vendor.zip + - curl --silent -o globalizer.zip --location --header "PRIVATE-TOKEN:%ACCESS_TOKEN%" "https://gitlab.com/api/v4/projects/minizinc%%2Fglobalizer/jobs/artifacts/master/download?job=build:%MZNARCH%" + - unzip -q globalizer.zip + - curl --silent -o findmus.zip --location --header "PRIVATE-TOKEN:%ACCESS_TOKEN%" "https://gitlab.com/api/v4/projects/minizinc%%2FFindMus/jobs/artifacts/master/download?job=build:%MZNARCH%" + - unzip -q findmus.zip + script: + - "\"C:/Program Files (x86)/Inno Setup 5/ISCC.exe\" /dMyAppVersion=\"%MZNVERSION%\" /dMyMZNVersion=\"%MZNVERSION%\" /dMyAppDirectory=\"%CI_PROJECT_DIR%\" /dMyMSVCRedist=\"%MSVCREDIST%\" /dMyUCRTRedist=\"%UCRTREDIST%\" /dMyAPPArch=\"%MZNARCH%\" /dMyApp64Bit=\"%ISSARCH%\" /dMyAppArchitectures=\"%ISSARCHALLOWED%\" /O\"%CI_PROJECT_DIR%\" resources/pkg_config/minizinc-bundle.iss" + ### Generate checksum + - certutil -hashfile MiniZincIDE-%MZNVERSION%-bundled-setup-%MZNARCH%.exe SHA256 > MiniZincIDE-%MZNVERSION%-bundled-setup-%MZNARCH%.sha256 + artifacts: + name: "minizinc_bundle_windows_%CI_PIPELINE_ID%" + paths: [MiniZincIDE*.exe, MiniZincIDE*.sha256] + dependencies: ["build:win64"] + tags: [win64] + +package:appimage: + stage: package + image: dekker1/minibuild:appimage + variables: + MZNARCH: "linux" + DOWNLOAD_GLOBALIZER: 1 + DOWNLOAD_FINDMUS: 1 + PACKAGE: "MiniZinc.AppDir" + <<: *packaging_setup + script: + - mkdir -p $PACKAGE/usr/ + ### Package IDE + - mv ide/usr/* $PACKAGE/usr/ + ### Package MiniZinc + - mv minizinc/bin/* $PACKAGE/usr/bin/ + - mv minizinc/share $PACKAGE/usr/share + ### Package vendor solvers + - mv vendor/gecode/bin/fzn-gecode $PACKAGE/usr/bin/ + - mv vendor/gecode/share/gecode/mznlib $PACKAGE/usr/share/minizinc/gecode + - mv vendor/chuffed/bin/fzn-chuffed $PACKAGE/usr/bin/ + - mv vendor/chuffed/share/chuffed/mznlib $PACKAGE/usr/share/minizinc/chuffed + ### Package Globalizer + - mv globalizer/bin/minizinc-globalizer $PACKAGE/usr/bin/ + - mv globalizer/share/globalizer/mznlib $PACKAGE/usr/share/minizinc/globalizer + ### Package findMUS + - mv findMUS/bin/findMUS $PACKAGE/usr/bin/ + ### Package solver scripts + - cp resources/scripts/fzn-gecode-gist $PACKAGE/usr/bin/ + ### Package default settings + - mkdir -p $PACKAGE/usr/share/minizinc/solvers/ + - cp resources/solvers/*.msc $PACKAGE/usr/share/minizinc/solvers/ + - cp resources/Preferences.json $PACKAGE/usr/share/minizinc/ + ### Strip included binaries + - (cd $PACKAGE/usr/bin; strip minizinc fzn-gecode fzn-chuffed findMUS minizinc-globalizer mzn2doc) + - cp resources/misc/README $PACKAGE + ### Assemble AppImage + - cp resources/scripts/AppRun $PACKAGE + - cp resources/misc/minizinc.desktop $PACKAGE/minizinc.desktop + - cp resources/icon.png $PACKAGE/minizinc.png + - ARCH=x86_64 appimagetool $PACKAGE MiniZincIDE-${MZNVERSION}-x86_64.AppImage + ### Generate checksum + - sha256sum MiniZincIDE*.AppImage > MiniZincIDE-${MZNVERSION}-x86_64.sha256 + artifacts: + name: "minizinc_appimage_${CI_PIPELINE_ID}" + paths: [MiniZincIDE*.AppImage, MiniZincIDE*.sha256] + dependencies: ["build:linux"] + tags: [linux, docker] + +package:docker_alpine: + stage: package + variables: + MZNARCH: "musl" + <<: *packaging_setup + script: + - docker build -f resources/pkg_config/alpine.Dockerfile -t minizinc_alpine . + - if [ -n "$CI_COMMIT_TAG" ]; then docker tag minizinc_alpine minizinc/minizinc:$CI_COMMIT_TAG && docker push minizinc/minizinc:$CI_COMMIT_TAG; fi + - if [ "$CI_COMMIT_REF_NAME" = "master" ]; then docker tag minizinc_alpine minizinc/minizinc:latest && docker push minizinc/minizinc:latest; fi + - if [ "$CI_COMMIT_REF_NAME" = "develop" ]; then docker tag minizinc_alpine minizinc/minizinc:edge && docker push minizinc/minizinc:edge; fi + dependencies: [] + only: [tags, master, develop] + tags: [docker-cli] + +package:docker_ubuntu: + stage: package + variables: + MZNARCH: "linux" + DOWNLOAD_SOLVERS: 0 + <<: *packaging_setup + script: + - curl --silent -o gecode.zip --location --header "PRIVATE-TOKEN:$ACCESS_TOKEN" "https://gitlab.com/api/v4/projects/minizinc%2Fvendor/jobs/artifacts/master/download?job=gecode:$MZNARCH" + - unzip -q gecode.zip + - curl --silent -o chuffed.zip --location --header "PRIVATE-TOKEN:$ACCESS_TOKEN" "https://gitlab.com/api/v4/projects/minizinc%2Fvendor/jobs/artifacts/master/download?job=chuffed:$MZNARCH" + - unzip -q chuffed.zip + - docker build -f resources/pkg_config/ubuntu.Dockerfile -t minizinc_ubuntu . + - if [ -n "$CI_COMMIT_TAG" ]; then docker tag minizinc_ubuntu minizinc/minizinc:ubuntu_$CI_COMMIT_TAG && docker push minizinc/minizinc:ubuntu_$CI_COMMIT_TAG; fi + - if [ "$CI_COMMIT_REF_NAME" = "master" ]; then docker tag minizinc_ubuntu minizinc/minizinc:ubuntu_latest && docker push minizinc/minizinc:ubuntu_latest; fi + - if [ "$CI_COMMIT_REF_NAME" = "develop" ]; then docker tag minizinc_ubuntu minizinc/minizinc:ubuntu_edge && docker push minizinc/minizinc:ubuntu_edge; fi + dependencies: [] + only: [tags, master, develop] + tags: [docker-cli] + +package:snap: + stage: package + image: dekker1/minibuild:snap + variables: + MZNARCH: "linux" + DOWNLOAD_GLOBALIZER: 1 + DOWNLOAD_FINDMUS: 1 + <<: *packaging_setup + script: + - strip minizinc/bin/minizinc vendor/gecode/bin/fzn-gecode vendor/chuffed/bin/fzn-chuffed findMUS/bin/findMUS globalizer/bin/minizinc-globalizer minizinc/bin/mzn2doc + - cp resources/pkg_config/snapcraft.yaml . + - echo "$MZNVERSION" > version.txt + - apt-get update -y + - snapcraft + - echo "$SNAPLOGIN" > login.pass + - snapcraft login --with login.pass + - snapcraft push --release=edge minizinc*.snap + artifacts: + name: "minizinc_snap_${CI_PIPELINE_ID}" + paths: [minizinc*.snap] + dependencies: [] + only: [tags, develop] + tags: [linux, docker] diff --git a/MiniZincIDE.pro b/MiniZincIDE.pro new file mode 100644 index 0000000..c78812d --- /dev/null +++ b/MiniZincIDE.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs + +SUBDIRS = MiniZincIDE + +libminizinc { + SUBDIRS += libminizinc + MiniZincIDE.depends = libminizinc +} diff --git a/MiniZincIDE/CHANGES b/MiniZincIDE/CHANGES index 5a1afa8..666f154 100644 --- a/MiniZincIDE/CHANGES +++ b/MiniZincIDE/CHANGES @@ -1,3 +1,17 @@ + v2.3.0 + - The IDE will now check MiniZinc code for syntax and type errors + - The editor performs simple code completion for MiniZinc keywords + - Ensure cursor is visible (editor scrolls to cursor position) when pressing + tab or enter. Fixes #71. + - Replace find dialog with inline widget and incremental search. + - Support dark mode on macOS. + - Add support for extra solver flags (parsed from solver configuration). + - IDE now only uses minizinc executable (not mzn2fzn and solns2out). + - Re-dock configuration editor when closing un-docked window. + - Handle quotes when parsing additional solver command line arguments. + Fixes #77. + - Add workaround for the missing libnss requirements + - Allow spaces in $DIR in MiniZincIDE.sh (Fixes #81) v2.2.3 - Only run solution checker if it is enabled in the solver configuration dialog. v2.2.2 diff --git a/MiniZincIDE/MiniZincIDE.pro b/MiniZincIDE/MiniZincIDE.pro index 43a1d46..f60301d 100644 --- a/MiniZincIDE/MiniZincIDE.pro +++ b/MiniZincIDE/MiniZincIDE.pro @@ -19,16 +19,18 @@ greaterThan(QT_MAJOR_VERSION, 4): { TARGET = MiniZincIDE TEMPLATE = app -VERSION = 2.2.3 +VERSION = 2.3.0 DEFINES += MINIZINC_IDE_VERSION=\\\"$$VERSION\\\" bundled { DEFINES += MINIZINC_IDE_BUNDLED } +CONFIG += c++11 + macx { ICON = mznide.icns - OBJECTIVE_SOURCES += rtfexporter.mm + OBJECTIVE_SOURCES += macos_extras.mm QT += macextras LIBS += -framework Cocoa macx-xcode { @@ -43,13 +45,12 @@ RC_ICONS = mznide.ico CONFIG += embed_manifest_exe SOURCES += main.cpp\ - mainwindow.cpp \ + mainwindow.cpp \ codeeditor.cpp \ highlighter.cpp \ fzndoc.cpp \ solverdialog.cpp \ gotolinedialog.cpp \ - finddialog.cpp \ paramdialog.cpp \ outputdockwidget.cpp \ checkupdatedialog.cpp \ @@ -64,14 +65,13 @@ HEADERS += mainwindow.h \ codeeditor.h \ highlighter.h \ fzndoc.h \ + macos_extras.h \ solverdialog.h \ gotolinedialog.h \ - finddialog.h \ paramdialog.h \ outputdockwidget.h \ checkupdatedialog.h \ project.h \ - rtfexporter.h \ htmlwindow.h \ htmlpage.h \ moocsubmission.h \ @@ -82,7 +82,6 @@ FORMS += \ mainwindow.ui \ solverdialog.ui \ gotolinedialog.ui \ - finddialog.ui \ paramdialog.ui \ checkupdatedialog.ui \ htmlwindow.ui \ diff --git a/MiniZincIDE/cheat_sheet.mzn b/MiniZincIDE/cheat_sheet.mzn index 13250df..2da0f87 100644 --- a/MiniZincIDE/cheat_sheet.mzn +++ b/MiniZincIDE/cheat_sheet.mzn @@ -25,16 +25,18 @@ output ["Solution:\n", "x = ", show(x), % output list of strings ***********************/ int: i; -3..5: j; % integer +3..5: j; % integer float: f; -3.0..5.0: g; % floating point number +3.0..5.0: g; % floating point number -bool: b; % boolean +bool: b; % boolean -set of int: s; % set +set of int: s; % set set of 3..5: t; +enum E = { Boat, Airplane }; % enumerated type + /*********************** * Type-insts * ***********************/ @@ -48,7 +50,7 @@ array[1..4,1..10] of var 0.0..100.0: f; % declare 2d array of float variables var opt 1..10: ox; % declare optional int variable (can be 1..10 or - % absent) + % "absent", written <>) /********************* * Basic Constraints * @@ -117,7 +119,7 @@ array[int,int] of float: x = solve maximize sum(x); % optimization solve minimize sum(x); -solve ::int_search([x,y,z], input_order, indomain_min, complete) satisfy; +solve ::int_search([x,y,z], input_order, indomain_min) satisfy; % search annotation % variable selection (examples): % input_order, first_fail, max_regret, smallest @@ -126,8 +128,8 @@ solve ::int_search([x,y,z], input_order, indomain_min, complete) satisfy; % indomain_split, indomain_reverse_split % similar for bool_search, set_search, float_search -solve ::seq_search([int_search(x, first_fail, indomain, complete), - int_search(y, input_order, indomain_min, complete)]) +solve ::seq_search([int_search(x, first_fail, indomain), + int_search(y, input_order, indomain_min)]) satisfy; % first search x, then y diff --git a/MiniZincIDE/codeeditor.cpp b/MiniZincIDE/codeeditor.cpp index 4664bc5..c57eb0e 100755 --- a/MiniZincIDE/codeeditor.cpp +++ b/MiniZincIDE/codeeditor.cpp @@ -27,6 +27,7 @@ CodeEditor::initUI(QFont& font) connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(setLineNumbers(QRect,int))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(cursorChange())); connect(document(), SIGNAL(modificationChanged(bool)), this, SLOT(docChanged(bool))); + connect(document(), SIGNAL(contentsChanged()), this, SLOT(contentsChanged())); setLineNumbersWidth(0); cursorChange(); @@ -43,7 +44,7 @@ CodeEditor::initUI(QFont& font) CodeEditor::CodeEditor(QTextDocument* doc, const QString& path, bool isNewFile, bool large, QFont& font, bool darkMode0, QTabWidget* t, QWidget *parent) : - QPlainTextEdit(parent), loadContentsButton(NULL), tabs(t), darkMode(darkMode0) + QPlainTextEdit(parent), loadContentsButton(NULL), tabs(t), darkMode(darkMode0), modifiedSinceLastCheck(true) { if (doc) { QPlainTextEdit::setDocument(doc); @@ -62,6 +63,27 @@ CodeEditor::CodeEditor(QTextDocument* doc, const QString& path, bool isNewFile, connect(pb, SIGNAL(clicked()), this, SLOT(loadContents())); loadContentsButton = pb; } + completer = new QCompleter(this); + QStringList completionList; + completionList << "annotation" << "array" << "bool" << "constraint" + << "diff" << "else" << "elseif" << "endif" << "enum" << "float" + << "function" << "include" << "intersect" << "maximize" << "minimize" + << "output" << "predicate" << "satisfy" << "solve" << "string" + << "subset" << "superset" << "symdiff" << "test" << "then" + << "union" << "where"; + completionList.sort(); + completionModel.setStringList(completionList); + completer->setModel(&completionModel); + completer->setCaseSensitivity(Qt::CaseSensitive); + completer->setModelSorting(QCompleter::CaseSensitivelySortedModel); + completer->setWrapAround(false); + completer->setWidget(this); + completer->setCompletionMode(QCompleter::PopupCompletion); + QObject::connect(completer, SIGNAL(activated(QString)), this, SLOT(insertCompletion(QString))); + + modificationTimer.setSingleShot(true); + QObject::connect(&modificationTimer, SIGNAL(timeout()), this, SLOT(contentsChangedWithTimeout())); + setAcceptDrops(false); installEventFilter(this); } @@ -71,6 +93,16 @@ void CodeEditor::loadContents() static_cast(qApp)->loadLargeFile(filepath,this); } +void CodeEditor::insertCompletion(const QString &completion) +{ + QTextCursor tc = textCursor(); + int extra = completion.length() - completer->completionPrefix().length(); + tc.movePosition(QTextCursor::Left); + tc.movePosition(QTextCursor::EndOfWord); + tc.insertText(completion.right(extra)); + setTextCursor(tc); +} + void CodeEditor::loadedLargeFile() { setReadOnly(false); @@ -129,12 +161,38 @@ void CodeEditor::docChanged(bool c) } } +void CodeEditor::contentsChanged() +{ + if (!modifiedSinceLastCheck) { + modificationTimer.start(500); + } +} + +void CodeEditor::contentsChangedWithTimeout() +{ + modifiedSinceLastCheck = true; +} + void CodeEditor::keyPressEvent(QKeyEvent *e) { + if (completer->popup()->isVisible()) { + switch (e->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: + case Qt::Key_Escape: + case Qt::Key_Tab: + case Qt::Key_Backtab: + e->ignore(); + return; // let the completer do default behavior + default: + break; + } + } if (e->key() == Qt::Key_Tab) { e->accept(); QTextCursor cursor(textCursor()); cursor.insertText(" "); + ensureCursorVisible(); } else if (e->key() == Qt::Key_Return) { e->accept(); QTextCursor cursor(textCursor()); @@ -144,8 +202,33 @@ void CodeEditor::keyPressEvent(QKeyEvent *e) if (leadingWhitespace.indexIn(curLine) != -1) { cursor.insertText(leadingWhitespace.cap(1)); } + ensureCursorVisible(); } else { - QPlainTextEdit::keyPressEvent(e); + bool isShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_E); // CTRL+E + if (!isShortcut) // do not process the shortcut when we have a completer + QPlainTextEdit::keyPressEvent(e); + const bool ctrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier); + if (ctrlOrShift && e->text().isEmpty()) + return; + static QString eow("~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-="); // end of word + bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift; + + QTextCursor tc = textCursor(); + tc.select(QTextCursor::WordUnderCursor); + QString completionPrefix = tc.selectedText(); + if (!isShortcut && (hasModifier || e->text().isEmpty()|| completionPrefix.length() < 3 + || eow.contains(e->text().right(1)))) { + completer->popup()->hide(); + return; + } + if (completionPrefix != completer->completionPrefix()) { + completer->setCompletionPrefix(completionPrefix); + completer->popup()->setCurrentIndex(completer->completionModel()->index(0, 0)); + } + QRect cr = cursorRect(); + cr.setWidth(completer->popup()->sizeHintForColumn(0) + + completer->popup()->verticalScrollBar()->sizeHint().width()); + completer->complete(cr); // popup it up! } } @@ -198,7 +281,14 @@ void CodeEditor::resizeEvent(QResizeEvent *e) void CodeEditor::cursorChange() { + QList allExtraSels = extraSelections(); + QList extraSelections; + foreach (QTextEdit::ExtraSelection sel, allExtraSels) { + if (sel.format.underlineColor()==Qt::red) { + extraSelections.append(sel); + } + } BracketData* bd = static_cast(textCursor().block().userData()); @@ -356,10 +446,13 @@ void CodeEditor::paintLineNumbers(QPaintEvent *event) while (block.isValid() && top <= event->rect().bottom()) { if (block.isVisible() && bottom >= event->rect().top()) { QString number = QString::number(blockNumber + 1); - if (blockNumber == curLine) + if (errorLines.contains(blockNumber)) { + painter.setPen(Qt::red); + } else if (blockNumber == curLine) { painter.setPen(foregroundActiveColor); - else + } else { painter.setPen(foregroundInactiveColor); + } int textTop = top+fontMetrics().leading()+heightDiff; painter.drawText(0, textTop, lineNumbers->width(), fm2.height(), Qt::AlignRight, number); @@ -391,6 +484,38 @@ bool CodeEditor::eventFilter(QObject *, QEvent *ev) cut(); return true; } + } else if (ev->type() == QEvent::ToolTip) { + QHelpEvent* helpEvent = static_cast(ev); + QPoint evPos = helpEvent->pos(); + evPos = QPoint(evPos.x()-lineNumbersWidth(),evPos.y()); + if (evPos.x() >= 0) { + QTextCursor cursor = cursorForPosition(evPos); + cursor.movePosition(QTextCursor::PreviousCharacter); + bool foundError = false; + foreach (CodeEditorError cee, errors) { + if (cursor.position() >= cee.startPos && cursor.position() <= cee.endPos) { + QToolTip::showText(helpEvent->globalPos(), cee.msg); + foundError = true; + break; + } + } + if (!foundError) { + cursor.select(QTextCursor::WordUnderCursor); + QString loc(filename+":"); + loc += QString().number(cursor.block().blockNumber()+1); + loc += "."; + loc += QString().number(cursor.selectionStart()-cursor.block().position()+1); + QHash::iterator idMapIt = idMap.find(loc); + if (idMapIt != idMap.end()) { + QToolTip::showText(helpEvent->globalPos(), idMapIt.value()); + } else { + QToolTip::hideText(); + } + } + } else { + QToolTip::hideText(); + } + return true; } return false; } @@ -406,3 +531,46 @@ void CodeEditor::cut() highlighter->copyHighlightedToClipboard(textCursor()); textCursor().removeSelectedText(); } + +void CodeEditor::checkFile(const QVector& mznErrors) +{ + QList allExtraSels = extraSelections(); + + QList extraSelections; + foreach (QTextEdit::ExtraSelection sel, allExtraSels) { + if (sel.format.underlineColor()!=Qt::red) { + extraSelections.append(sel); + } + } + + errors.clear(); + errorLines.clear(); + for (unsigned int i=0; ifindBlockByNumber(mznErrors[i].first_line-1); + QTextBlock endblock = document()->findBlockByNumber(mznErrors[i].last_line-1); + if (block.isValid() && endblock.isValid()) { + QTextCursor cursor = textCursor(); + cursor.setPosition(block.position()); + int firstCol = mznErrors[i].first_col < mznErrors[i].last_col ? (mznErrors[i].first_col-1) : (mznErrors[i].last_col-1); + int lastCol = mznErrors[i].first_col < mznErrors[i].last_col ? (mznErrors[i].last_col) : (mznErrors[i].first_col); + cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, firstCol); + int startPos = cursor.position(); + cursor.setPosition(endblock.position(), QTextCursor::KeepAnchor); + cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, lastCol); + int endPos = cursor.position(); + sel.cursor = cursor; + sel.format = format; + extraSelections.append(sel); + CodeEditorError cee(startPos,endPos,mznErrors[i].msg); + errors.append(cee); + for (int j=mznErrors[i].first_line; j<=mznErrors[i].last_line; j++) { + errorLines.insert(j-1); + } + } + } + setExtraSelections(extraSelections); +} diff --git a/MiniZincIDE/codeeditor.h b/MiniZincIDE/codeeditor.h index 9487232..72a993b 100644 --- a/MiniZincIDE/codeeditor.h +++ b/MiniZincIDE/codeeditor.h @@ -15,9 +15,31 @@ #include #include +#include +#include +#include #include "highlighter.h" +class CodeEditorError { +public: + int startPos; + int endPos; + QString msg; + CodeEditorError(int startPos0, int endPos0, const QString& msg0) + : startPos(startPos0), endPos(endPos0), msg(msg0) {} +}; + +struct MiniZincError { + QString filename; + int first_line; + int last_line; + int first_col; + int last_col; + QString msg; +}; + + class CodeEditor : public QPlainTextEdit { Q_OBJECT @@ -32,6 +54,8 @@ class CodeEditor : public QPlainTextEdit void setDocument(QTextDocument *document); void setDarkMode(bool); Highlighter& getHighlighter(); + bool modifiedSinceLastCheck; + void checkFile(const QVector& errors); protected: void resizeEvent(QResizeEvent *event); void initUI(QFont& font); @@ -42,13 +66,22 @@ private slots: void cursorChange(); void setLineNumbers(const QRect &, int); void docChanged(bool); + void contentsChanged(); + void contentsChangedWithTimeout(); void loadContents(); + void insertCompletion(const QString& completion); private: QWidget* lineNumbers; QWidget* loadContentsButton; QTabWidget* tabs; Highlighter* highlighter; + QCompleter* completer; + QStringListModel completionModel; bool darkMode; + QList errors; + QSet errorLines; + QHash idMap; + QTimer modificationTimer; int matchLeft(QTextBlock block, QChar b, int i, int n); int matchRight(QTextBlock block, QChar b, int i, int n); signals: diff --git a/MiniZincIDE/finddialog.cpp b/MiniZincIDE/finddialog.cpp deleted file mode 100644 index 4e30ae2..0000000 --- a/MiniZincIDE/finddialog.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Author: - * Guido Tack - * - * Copyright: - * NICTA 2013 - */ - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "finddialog.h" -#include "ui_finddialog.h" -#include "codeeditor.h" -#include - -FindDialog::FindDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::FindDialog), - codeEditor(NULL) -{ - ui->setupUi(this); -} - -FindDialog::~FindDialog() -{ - delete ui; -} - -void FindDialog::show() -{ - ui->not_found->setText(""); - QDialog::show(); -} - -void FindDialog::setEditor(CodeEditor* e) -{ - codeEditor = e; -} - -void FindDialog::find(bool fwd) -{ - const QString& toFind = ui->find->text(); - QTextDocument::FindFlags flags; - if (!fwd) - flags |= QTextDocument::FindBackward; - bool ignoreCase = ui->check_case->isChecked(); - if (!ignoreCase) - flags |= QTextDocument::FindCaseSensitively; - bool wrap = ui->check_wrap->isChecked(); - - QTextCursor cursor(codeEditor->textCursor()); - int hasWrapped = wrap ? 0 : 1; - while (hasWrapped < 2) { - if (ui->check_re->isChecked()) { - QRegExp re(toFind, ignoreCase ? Qt::CaseInsensitive : Qt::CaseSensitive); - if (!re.isValid()) { - ui->not_found->setText("invalid"); - return; - } - cursor = codeEditor->document()->find(re,cursor,flags); - } else { - cursor = codeEditor->document()->find(toFind,cursor,flags); - } - if (cursor.isNull()) { - hasWrapped++; - cursor = codeEditor->textCursor(); - if (fwd) { - cursor.setPosition(0); - } else { - cursor.movePosition(QTextCursor::End); - } - } else { - ui->not_found->setText(""); - codeEditor->setTextCursor(cursor); - break; - } - } - if (hasWrapped==2) { - ui->not_found->setText("not found"); - } -} - -void FindDialog::on_b_next_clicked() -{ - find(true); -} - -void FindDialog::on_b_prev_clicked() -{ - find(false); -} - -void FindDialog::on_b_replacefind_clicked() -{ - QTextCursor cursor = codeEditor->textCursor(); - if (cursor.hasSelection()) { - cursor.insertText(ui->replace->text()); - } - find(true); -} - -void FindDialog::on_b_replace_clicked() -{ - QTextCursor cursor = codeEditor->textCursor(); - if (cursor.hasSelection()) { - cursor.insertText(ui->replace->text()); - } -} - -void FindDialog::on_b_replaceall_clicked() -{ - int counter = 0; - QTextCursor cursor = codeEditor->textCursor(); - if (!cursor.hasSelection()) { - find(true); - cursor = codeEditor->textCursor(); - } - cursor.beginEditBlock(); - while (cursor.hasSelection()) { - counter++; - cursor.insertText(ui->replace->text()); - find(true); - cursor = codeEditor->textCursor(); - } - cursor.endEditBlock(); - if (counter > 0) { - ui->not_found->setText(QString().number(counter)+" replaced"); - } -} diff --git a/MiniZincIDE/finddialog.h b/MiniZincIDE/finddialog.h deleted file mode 100644 index 0ad59a2..0000000 --- a/MiniZincIDE/finddialog.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Author: - * Guido Tack - * - * Copyright: - * NICTA 2013 - */ - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef FINDDIALOG_H -#define FINDDIALOG_H - -#include - -namespace Ui { -class FindDialog; -} - -class CodeEditor; - -class FindDialog : public QDialog -{ - Q_OBJECT - -public: - explicit FindDialog(QWidget *parent = 0); - ~FindDialog(); - - void setEditor(CodeEditor* doc); -public slots: - void on_b_next_clicked(); - - void on_b_prev_clicked(); - - void on_b_replacefind_clicked(); - - void on_b_replace_clicked(); - - void on_b_replaceall_clicked(); - - void show(); - -private: - Ui::FindDialog *ui; - CodeEditor* codeEditor; - - void find(bool fwd); -}; - -#endif // FINDDIALOG_H diff --git a/MiniZincIDE/finddialog.ui b/MiniZincIDE/finddialog.ui deleted file mode 100644 index 63fc639..0000000 --- a/MiniZincIDE/finddialog.ui +++ /dev/null @@ -1,206 +0,0 @@ - - - FindDialog - - - - 0 - 0 - 589 - 161 - - - - Find - - - - - 84 - 23 - 27 - 16 - - - - Find - - - - - - 119 - 22 - 450 - 21 - - - - - 300 - 0 - - - - - - - 62 - 56 - 49 - 16 - - - - Replace - - - - - - 119 - 53 - 450 - 21 - - - - - 300 - 0 - - - - - - - 144 - 81 - 151 - 20 - - - - - 0 - 0 - - - - Regular expression - - - - - - 305 - 81 - 101 - 20 - - - - Ignore case - - - - - - 435 - 81 - 111 - 20 - - - - Wrap around - - - - - - 10 - 120 - 114 - 32 - - - - Replace all - - - - - - 130 - 120 - 81 - 32 - - - - Replace - - - - - - 220 - 120 - 141 - 32 - - - - Replace and find - - - - - - 424 - 120 - 81 - 32 - - - - Previous - - - - - - 504 - 120 - 71 - 32 - - - - Next - - - true - - - - - - 20 - 83 - 91 - 20 - - - - not found - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - diff --git a/MiniZincIDE/highlighter.cpp b/MiniZincIDE/highlighter.cpp index 0c965c8..90283e9 100644 --- a/MiniZincIDE/highlighter.cpp +++ b/MiniZincIDE/highlighter.cpp @@ -14,7 +14,6 @@ #include "highlighter.h" - Highlighter::Highlighter(QFont& font, bool dm, QTextDocument *parent) : QSyntaxHighlighter(parent) { diff --git a/MiniZincIDE/rtfexporter.h b/MiniZincIDE/macos_extras.h similarity index 95% rename from MiniZincIDE/rtfexporter.h rename to MiniZincIDE/macos_extras.h index 5577216..7690831 100644 --- a/MiniZincIDE/rtfexporter.h +++ b/MiniZincIDE/macos_extras.h @@ -25,5 +25,7 @@ class MyRtfMime : QMacPasteboardMime { QList convertFromMime(const QString &mime, QVariant data, QString flav); }; +int hasDarkMode(void); +int isDark(void); #endif // RTFEXPORTER_H diff --git a/MiniZincIDE/rtfexporter.mm b/MiniZincIDE/macos_extras.mm similarity index 83% rename from MiniZincIDE/rtfexporter.mm rename to MiniZincIDE/macos_extras.mm index 3fcc618..21375aa 100644 --- a/MiniZincIDE/rtfexporter.mm +++ b/MiniZincIDE/macos_extras.mm @@ -1,5 +1,5 @@ #import -#include "rtfexporter.h" +#include "macos_extras.h" NSData* ba_toNSData(const QByteArray& data) { return [NSData dataWithBytes:data.constData() length:data.size()]; @@ -46,3 +46,13 @@ QByteArray ba_fromNSData(const NSData *data) ret << ba_fromNSData(rtfData); return ret; } + +int isDark(void) { + id appObjects[] = { NSAppearanceNameAqua, NSAppearanceNameDarkAqua }; + NSArray* appearances = [NSArray arrayWithObjects: appObjects count:2]; + return [[NSAppearance currentAppearance] bestMatchFromAppearancesWithNames: appearances] == NSAppearanceNameDarkAqua; +} + +int hasDarkMode(void) { + return (NSAppKitVersionNumber > NSAppKitVersionNumber10_13); +} diff --git a/MiniZincIDE/mainwindow.cpp b/MiniZincIDE/mainwindow.cpp index d06f075..1ba8764 100755 --- a/MiniZincIDE/mainwindow.cpp +++ b/MiniZincIDE/mainwindow.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -23,7 +24,6 @@ #include "ui_mainwindow.h" #include "codeeditor.h" #include "fzndoc.h" -#include "finddialog.h" #include "gotolinedialog.h" #include "paramdialog.h" #include "checkupdatedialog.h" @@ -40,7 +40,7 @@ #ifdef Q_OS_MAC #define fileDialogSuffix "/*" #define MZNOS "mac" -#include "rtfexporter.h" +#include "macos_extras.h" #else #define fileDialogSuffix "/" #define MZNOS "linux" @@ -472,7 +472,7 @@ void IDE::openFile(const QString& fileName0) { QString fileName = fileName0; if (fileName.isEmpty()) { - fileName = QFileDialog::getOpenFileName(NULL, tr("Open File"), getLastPath(), "MiniZinc Files (*.mzn *.dzn *.fzn *.mzp)"); + fileName = QFileDialog::getOpenFileName(NULL, tr("Open File"), getLastPath(), "MiniZinc Files (*.mzn *.dzn *.fzn *.mzp *.mzc);;Other (*)"); if (!fileName.isNull()) { setLastPath(QFileInfo(fileName).absolutePath()+fileDialogSuffix); } @@ -684,6 +684,7 @@ MainWindow::MainWindow(const QString& project) : curEditor(NULL), curHtmlWindow(-1), process(NULL), + check_process(NULL), outputProcess(NULL), tmpDir(NULL), saveBeforeRunning(false), @@ -700,6 +701,7 @@ MainWindow::MainWindow(const QStringList& files) : curEditor(NULL), curHtmlWindow(-1), process(NULL), + check_process(NULL), outputProcess(NULL), tmpDir(NULL), saveBeforeRunning(false), @@ -748,6 +750,18 @@ void MainWindow::init(const QString& projectFile) IDE::instance()->mainWindows.insert(this); ui->setupUi(this); ui->tabWidget->removeTab(0); +#ifndef Q_OS_MAC + ui->menuFile->addAction(ui->actionQuit); +#else + if (hasDarkMode()) { + ui->menuView->removeAction(ui->actionDark_mode); + } +#endif + + // initialise find widget + ui->findFrame->hide(); + connect(ui->find, SIGNAL(escPressed(void)), this, SLOT(on_closeFindWidget_clicked())); + QWidget* solverConfFrame = new QWidget; QVBoxLayout* solverConfFrameLayout = new QVBoxLayout; @@ -788,9 +802,6 @@ void MainWindow::init(const QString& projectFile) newFileCounter = 1; - findDialog = new FindDialog(this); - findDialog->setModal(false); - paramDialog = new ParamDialog(this); fakeRunAction = new QAction(this); @@ -820,6 +831,9 @@ void MainWindow::init(const QString& projectFile) solverTimeout = new QTimer(this); solverTimeout->setSingleShot(true); connect(solverTimeout, SIGNAL(timeout()), this, SLOT(on_actionStop_triggered())); + checkTimer = new QTimer(this); + connect(checkTimer, SIGNAL(timeout()), this, SLOT(check_code())); + checkTimer->start(1000); progressBar = new QProgressBar; progressBar->setRange(0, 100); progressBar->setSizePolicy(QSizePolicy::Policy::Minimum, QSizePolicy::Policy::Minimum); @@ -854,6 +868,7 @@ void MainWindow::init(const QString& projectFile) editorFont.fromString(settings.value("editorFont", defaultFont.toString()).value()); darkMode = settings.value("darkMode", false).value(); ui->actionDark_mode->setChecked(darkMode); + on_actionDark_mode_toggled(darkMode); ui->outputConsole->setFont(editorFont); resize(settings.value("size", QSize(800, 600)).toSize()); move(settings.value("pos", QPoint(100, 100)).toPoint()); @@ -1176,7 +1191,7 @@ void MainWindow::openFile(const QString &path, bool openAsModified, bool focus) QString fileName = path; if (fileName.isNull()) { - fileName = QFileDialog::getOpenFileName(this, tr("Open File"), getLastPath(), "MiniZinc Files (*.mzn *.dzn *.fzn *.mzp)"); + fileName = QFileDialog::getOpenFileName(this, tr("Open File"), getLastPath(), "MiniZinc Files (*.mzn *.dzn *.fzn *.mzp *.mzc);;Other (*)"); if (!fileName.isNull()) { setLastPath(QFileInfo(fileName).absolutePath()+fileDialogSuffix); } @@ -1308,6 +1323,17 @@ void MainWindow::dropEvent(QDropEvent* event) { event->acceptProposedAction(); } +#ifdef Q_OS_MAC +void MainWindow::paintEvent(QPaintEvent *) { + if (hasDarkMode()) { + bool newDark = isDark(); + if (newDark != darkMode) { + on_actionDark_mode_toggled(newDark); + } + } +} +#endif + void MainWindow::tabChange(int tab) { if (curEditor) { disconnect(ui->actionCopy, SIGNAL(triggered()), curEditor, SLOT(copy())); @@ -1383,7 +1409,6 @@ void MainWindow::tabChange(int tab) { ui->actionRedo->setEnabled(curEditor->document()->isRedoAvailable()); updateUiProcessRunning(processRunning); - findDialog->setEditor(curEditor); ui->actionFind->setEnabled(true); ui->actionFind_next->setEnabled(true); ui->actionFind_previous->setEnabled(true); @@ -1405,6 +1430,55 @@ void MainWindow::on_actionOpen_triggered() openFile(QString()); } +QStringList parseArgList(const QString& s) { + QStringList ret; + bool hadEscape = false; + bool inSingleQuote = false; + bool inDoubleQuote = false; + QString currentArg; + foreach (const QChar c, s) { + if (hadEscape) { + currentArg += c; + hadEscape = false; + } else { + if (c=='\\') { + hadEscape = true; + } else if (c=='"') { + if (inDoubleQuote) { + inDoubleQuote=false; + ret.push_back(currentArg); + currentArg = ""; + } else if (inSingleQuote) { + currentArg += c; + } else { + inDoubleQuote = true; + } + } else if (c=='\'') { + if (inSingleQuote) { + inSingleQuote=false; + ret.push_back(currentArg); + currentArg = ""; + } else if (inDoubleQuote) { + currentArg += c; + } else { + inSingleQuote = true; + } + } else if (!inSingleQuote && !inDoubleQuote && c==' ') { + if (currentArg.size() > 0) { + ret.push_back(currentArg); + currentArg = ""; + } + } else { + currentArg += c; + } + } + } + if (currentArg.size() > 0) { + ret.push_back(currentArg); + } + return ret; +} + QStringList MainWindow::parseConf(const ConfMode& confMode, const QString& modelFile, bool isOptimisation) { Solver& currentSolver = *getCurrentSolver(); @@ -1418,7 +1492,7 @@ QStringList MainWindow::parseConf(const ConfMode& confMode, const QString& model bool haveOutputHtml = currentSolver.stdFlags.contains("--output-html"); bool haveNeedsPaths = currentSolver.needsPathsFile; - bool isMiniZinc = (confMode!=CONF_RUN && !currentSolver.supportsMzn) || currentSolver.executable.isEmpty(); + bool isMiniZinc = (confMode!=CONF_RUN && !currentSolver.supportsMzn) || currentSolver.executable.isEmpty() || !currentSolver.supportsFzn; bool haveCompilerVerbose = isMiniZinc || (currentSolver.supportsMzn && currentSolver.stdFlags.contains("-v")); bool haveCompilerStats = isMiniZinc || currentSolver.stdFlags.contains("-s"); bool haveCompilerOpt[6]; @@ -1466,8 +1540,7 @@ QStringList MainWindow::parseConf(const ConfMode& confMode, const QString& model } if ((confMode==CONF_COMPILE || confMode==CONF_CHECKARGS) && !ui->conf_mzn2fzn_params->text().isEmpty()) { - QStringList compilerArgs = - ui->conf_mzn2fzn_params->text().split(" ", QString::SkipEmptyParts); + QStringList compilerArgs = parseArgList(ui->conf_mzn2fzn_params->text()); ret << compilerArgs; } @@ -1499,10 +1572,60 @@ QStringList MainWindow::parseConf(const ConfMode& confMode, const QString& model if (confMode==CONF_RUN && ui->conf_solver_verbose->isChecked() && haveSolverVerbose) ret << (isMiniZinc ? "--verbose-solving" : "-v"); if (confMode==CONF_RUN && !ui->conf_solverFlags->text().isEmpty()) { - QStringList solverArgs = - ui->conf_solverFlags->text().split(" ", QString::SkipEmptyParts); + QStringList solverArgs = parseArgList(ui->conf_solverFlags->text()); ret << solverArgs; } + if (confMode==CONF_RUN && ui->extraOptionsBox->isChecked()) { + for (auto& ef : extraSolverFlags) { + if (ef.first.t==SolverFlag::T_SOLVER) { + + } else { + switch (ef.first.t) { + case SolverFlag::T_BOOL: + if (static_cast(ef.second)->isChecked()) { + ret << ef.first.name; + } + break; + case SolverFlag::T_BOOL_ONOFF: + if (static_cast(ef.second)->isChecked()) { + ret << ef.first.name << ef.first.options[0]; + } else { + ret << ef.first.name << ef.first.options[1]; + } + break; + case SolverFlag::T_OPT: + case SolverFlag::T_SOLVER: + { + QString s = static_cast(ef.second)->currentText(); + if (!s.isEmpty() && s!=ef.first.def) { + ret << ef.first.name << s; + } + } + break; + case SolverFlag::T_INT: + case SolverFlag::T_FLOAT: + case SolverFlag::T_STRING: + { + QString s = static_cast(ef.second)->text(); + if (!s.isEmpty() && s!=ef.first.def) { + ret << ef.first.name << s; + } + } + break; + case SolverFlag::T_INT_RANGE: + { + ret << ef.first.name << QString().number(static_cast(ef.second)->value()); + } + break; + case SolverFlag::T_FLOAT_RANGE: + { + ret << ef.first.name << QString().number(static_cast(ef.second)->value()); + } + break; + } + } + } + } if (confMode==CONF_COMPILE || confMode==CONF_CHECKARGS) { ret << "--solver" << currentSolver.id+(currentSolver.version.startsWith("start(mzn2fzn_executable,args,getMznDistribPath()); + process->start(minizinc_executable,args,getMznDistribPath()); } } @@ -1630,8 +1753,8 @@ void MainWindow::on_actionRun_triggered() void MainWindow::compileOrRun() { - if (mzn2fzn_executable=="") { - int ret = QMessageBox::warning(this,"MiniZinc IDE","Could not find the mzn2fzn executable.\nDo you want to open the solver settings dialog?", + if (minizinc_executable=="") { + int ret = QMessageBox::warning(this,"MiniZinc IDE","Could not find the minizinc executable.\nDo you want to open the solver settings dialog?", QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Ok) on_actionManage_solvers_triggered(); @@ -1855,7 +1978,7 @@ void MainWindow::readOutput() hiddenSolutions.back() += l; } if (solutionLimit != 0 && solutionCount == solutionLimit) { - addOutput("
[ "+QString().number(solutionLimit-1)+" more solutions ]
"); + addOutput("
[ "+QString().number(solutionLimit-1)+" more solutions ]
"); for (int i=std::max(0,hiddenSolutions.size()-2); i 1) { - addOutput("
[ "+QString().number(solutionCount-1)+" more solutions ]
"); + addOutput("
[ "+QString().number(solutionCount-1)+" more solutions ]
"); } for (int i=std::max(0,hiddenSolutions.size()-2); isetHidden(true); process = new MznProcess(this); - processName = mzn2fzn_executable; + processName = minizinc_executable; bool standalone = false; if (!compileOnly) { // Check if we need to run a stand-alone solver (no mzn2fzn or solns2out) - if (currentSolver.supportsMzn) { + if (currentSolver.supportsMzn || !currentSolver.supportsFzn) { standalone = true; } } @@ -2097,7 +2220,7 @@ void MainWindow::compileAndRun(const QString& modelPath, const QString& addition if (!additionalCmdlineParams.isEmpty()) { compiling += ", additional arguments " + additionalCmdlineParams; } - addOutput("
"+compiling+"
"); + addOutput("
"+compiling+"
"); time = 0; timer->start(500); elapsedTime.start(); @@ -2247,7 +2370,7 @@ void MainWindow::outputProcFinished(int exitCode, bool showTime) { JSONOutput.clear(); if (!hiddenSolutions.isEmpty()) { if (solutionLimit != 0 && solutionCount!=solutionLimit && solutionCount > 1) { - addOutput("
[ "+QString().number(solutionCount-1)+" more solutions ]
"); + addOutput("
[ "+QString().number(solutionCount-1)+" more solutions ]
"); } for (int i=std::max(0,hiddenSolutions.size()-2); iFinished in "+elapsedTime+""); + addOutput("
Finished in "+elapsedTime+"
"); } delete tmpDir; tmpDir = NULL; @@ -2285,7 +2408,7 @@ void MainWindow::procFinished(int exitCode, bool showTime) { inJSONHandler = false; JSONOutput.clear(); if (showTime) { - addOutput("
Finished in "+elapsedTime+"
"); + addOutput("
Finished in "+elapsedTime+"
"); } delete tmpDir; tmpDir = NULL; @@ -2439,7 +2562,7 @@ void MainWindow::on_actionStop_triggered() process->terminate(); delete process; process = NULL; - addOutput("
Stopped.
"); + addOutput("
Stopped.
"); procFinished(0); } } @@ -2510,14 +2633,14 @@ void MainWindow::runCompiledFzn(int exitcode, QProcess::ExitStatus exitstatus) args << currentFznTarget; if (s->isGUIApplication) { - addOutput("
Running "+curEditor->filename+" (detached)
"); + addOutput("
Running "+curEditor->filename+" (detached)
"); MznProcess* detached_process = new MznProcess(this); detached_process->setWorkingDirectory(QFileInfo(curEditor->filepath).absolutePath()); QString executable = s->executable_resolved; if (ui->conf_solver_verbose->isChecked()) { - addOutput("
Command line:
"); + addOutput("
Command line:
"); QString cmdline = executable; QRegExp white("\\s"); for (int i=0; iRunning "+QFileInfo(curFilePath).fileName()+""); + addOutput("
Running "+QFileInfo(curFilePath).fileName()+"
"); QString executable = s->executable_resolved; if (ui->conf_solver_verbose->isChecked()) { - addOutput("
Command line:
"); + addOutput("
Command line:
"); QString cmdline = executable; QRegExp white("\\s"); for (int i=0; iconf_solver_timing->isChecked()) { outargs << "--output-time"; } - outargs << currentFznTarget.left(currentFznTarget.length()-4)+".ozn"; - outputProcess->start("solns2out",outargs,getMznDistribPath()); + outargs << "--ozn-file" << currentFznTarget.left(currentFznTarget.length()-4)+".ozn"; + outputProcess->start(minizinc_executable,outargs,getMznDistribPath()); } time = 0; timer->start(500); @@ -2711,6 +2834,7 @@ void MainWindow::updateSolverConfigs() ui->menuSolver_configurations->clear(); solverConfCombo->clear(); int idx = -1; + currentSolverConfig = -1; for (int i=0; iconf_solver_conf->addItem(projectSolverConfigs[i].name); solverConfCombo->addItem(projectSolverConfigs[i].name); @@ -2742,6 +2866,17 @@ void MainWindow::updateSolverConfigs() setCurrentSolverConfig(idx); } +void clearLayout(QLayout* l) { + QLayoutItem *toRemove; + while ((toRemove = l->takeAt(0)) != 0) { + if (toRemove->layout()) + clearLayout(toRemove->layout()); + delete toRemove->widget(); + delete toRemove; + } + +} + void MainWindow::setCurrentSolverConfig(int idx) { if (idx==-1 || idx >= projectSolverConfigs.size()+builtinSolverConfigs.size()) @@ -2775,6 +2910,31 @@ void MainWindow::setCurrentSolverConfig(int idx) oldConf.verboseSolving = ui->conf_solver_verbose->isChecked(); oldConf.solvingStats = ui->conf_stats->isChecked(); oldConf.runSolutionChecker = ui->conf_check_solutions->isChecked(); + oldConf.useExtraOptions = ui->extraOptionsBox->isChecked(); + oldConf.extraOptions.clear(); + for (auto& ef : extraSolverFlags) { + switch (ef.first.t) { + case SolverFlag::T_BOOL: + case SolverFlag::T_BOOL_ONOFF: + oldConf.extraOptions[ef.first.name] = static_cast(ef.second)->isChecked() ? "true" : "false"; + break; + case SolverFlag::T_OPT: + case SolverFlag::T_SOLVER: + oldConf.extraOptions[ef.first.name] = static_cast(ef.second)->currentText(); + break; + case SolverFlag::T_INT: + case SolverFlag::T_FLOAT: + case SolverFlag::T_STRING: + oldConf.extraOptions[ef.first.name] = static_cast(ef.second)->text(); + break; + case SolverFlag::T_INT_RANGE: + oldConf.extraOptions[ef.first.name] = static_cast(ef.second)->text(); + break; + case SolverFlag::T_FLOAT_RANGE: + oldConf.extraOptions[ef.first.name] = static_cast(ef.second)->text(); + break; + } + } } } currentSolverConfig = idx; @@ -2812,6 +2972,8 @@ void MainWindow::setCurrentSolverConfig(int idx) ui->conf_stats->setChecked(conf.solvingStats); ui->conf_check_solutions->setChecked(conf.runSolutionChecker); + // Remove all extra options + clearLayout(ui->extraOptionsLayout); if (solverIdx < solvers.size()) { Solver& currentSolver = solvers[solverIdx]; ui->conf_nthreads->setEnabled(currentSolver.stdFlags.contains("-p")); @@ -2826,6 +2988,122 @@ void MainWindow::setCurrentSolverConfig(int idx) ui->conf_solver_free->setEnabled(currentSolver.stdFlags.contains("-f")); ui->conf_solver_verbose->setEnabled((!currentSolver.supportsMzn && !currentSolver.executable.isEmpty()) || currentSolver.stdFlags.contains("-v")); + + ui->extraOptionsBox->setVisible(!currentSolver.extraFlags.empty()); + extraSolverFlags.clear(); + for (auto f : currentSolver.extraFlags) { + switch (f.t) { + case SolverFlag::T_INT: + { + QHBoxLayout* hb = new QHBoxLayout(); + QLineEdit* le = new QLineEdit(this); + le->setText(conf.extraOptions.contains(f.name) ? conf.extraOptions[f.name] : f.def); + le->setValidator(new QIntValidator(this)); + hb->addWidget(new QLabel(f.description)); + hb->addWidget(le); + ui->extraOptionsLayout->addLayout(hb); + extraSolverFlags.push_back(qMakePair(f,le)); + } + break; + case SolverFlag::T_INT_RANGE: + { + QHBoxLayout* hb = new QHBoxLayout(); + QSpinBox* le = new QSpinBox(this); + le->setRange(f.min, f.max); + le->setValue(conf.extraOptions.contains(f.name) ? conf.extraOptions[f.name].toInt() : f.def.toInt()); + hb->addWidget(new QLabel(f.description)); + hb->addWidget(le); + ui->extraOptionsLayout->addLayout(hb); + extraSolverFlags.push_back(qMakePair(f,le)); + } + break; + case SolverFlag::T_BOOL: + { + QCheckBox* cb = new QCheckBox(f.description,this); + cb->setChecked(conf.extraOptions.contains(f.name) ? (conf.extraOptions[f.name]=="true") : (f.def=="true")); + ui->extraOptionsLayout->addWidget(cb); + extraSolverFlags.push_back(qMakePair(f,cb)); + } + break; + case SolverFlag::T_BOOL_ONOFF: + { + QCheckBox* cb = new QCheckBox(f.description,this); + cb->setChecked(conf.extraOptions.contains(f.name) ? (conf.extraOptions[f.name]=="true") : (f.def==f.options[0])); + ui->extraOptionsLayout->addWidget(cb); + extraSolverFlags.push_back(qMakePair(f,cb)); + } + break; + case SolverFlag::T_FLOAT: + { + QHBoxLayout* hb = new QHBoxLayout(); + QLineEdit* le = new QLineEdit(this); + le->setText(conf.extraOptions.contains(f.name) ? conf.extraOptions[f.name] : f.def); + le->setValidator(new QDoubleValidator(this)); + hb->addWidget(new QLabel(f.description)); + hb->addWidget(le); + ui->extraOptionsLayout->addLayout(hb); + extraSolverFlags.push_back(qMakePair(f,le)); + } + break; + case SolverFlag::T_FLOAT_RANGE: + { + QHBoxLayout* hb = new QHBoxLayout(); + QDoubleSpinBox* le = new QDoubleSpinBox(this); + le->setRange(f.min, f.max); + le->setValue(conf.extraOptions.contains(f.name) ? conf.extraOptions[f.name].toDouble() : f.def.toDouble()); + hb->addWidget(new QLabel(f.description)); + hb->addWidget(le); + ui->extraOptionsLayout->addLayout(hb); + extraSolverFlags.push_back(qMakePair(f,le)); + } + break; + case SolverFlag::T_STRING: + { + QHBoxLayout* hb = new QHBoxLayout(); + QLineEdit* le = new QLineEdit(this); + le->setText(conf.extraOptions.contains(f.name) ? conf.extraOptions[f.name] : f.def); + hb->addWidget(new QLabel(f.description)); + hb->addWidget(le); + ui->extraOptionsLayout->addLayout(hb); + extraSolverFlags.push_back(qMakePair(f,le)); + } + break; + case SolverFlag::T_OPT: + { + QHBoxLayout* hb = new QHBoxLayout(); + QComboBox* cb = new QComboBox(this); + for (auto o : f.options) { + cb->addItem(o); + } + cb->setCurrentText(conf.extraOptions.contains(f.name) ? conf.extraOptions[f.name] : f.def); + hb->addWidget(new QLabel(f.description)); + hb->addWidget(cb); + hb->addItem(new QSpacerItem(0,0,QSizePolicy::Expanding)); + ui->extraOptionsLayout->addLayout(hb); + extraSolverFlags.push_back(qMakePair(f,cb)); + } + break; + case SolverFlag::T_SOLVER: + { + QHBoxLayout* hb = new QHBoxLayout(); + QComboBox* cb = new QComboBox(this); + for (auto s : projectSolverConfigs) { + cb->addItem(s.name); + } + for (auto s : builtinSolverConfigs) { + cb->addItem(s.name); + } + cb->setCurrentText(conf.extraOptions.contains(f.name) ? conf.extraOptions[f.name] : f.def); + hb->addWidget(new QLabel(f.description)); + hb->addWidget(cb); + hb->addItem(new QSpacerItem(0,0,QSizePolicy::Expanding)); + ui->extraOptionsLayout->addLayout(hb); + extraSolverFlags.push_back(qMakePair(f,cb)); + } + break; + } + } + on_extraOptionsBox_toggled(conf.useExtraOptions); } if (idx < projectSolverConfigs.size()) { @@ -2869,6 +3147,50 @@ void MainWindow::setCurrentSolverConfig(int idx) project.solverConfigs(projectSolverConfigs,false); } +void MainWindow::find(bool fwd) +{ + const QString& toFind = ui->find->text(); + QTextDocument::FindFlags flags; + if (!fwd) + flags |= QTextDocument::FindBackward; + bool ignoreCase = ui->check_case->isChecked(); + if (!ignoreCase) + flags |= QTextDocument::FindCaseSensitively; + bool wrap = ui->check_wrap->isChecked(); + + QTextCursor cursor(curEditor->textCursor()); + int hasWrapped = wrap ? 0 : 1; + while (hasWrapped < 2) { + if (ui->check_re->isChecked()) { + QRegExp re(toFind, ignoreCase ? Qt::CaseInsensitive : Qt::CaseSensitive); + if (!re.isValid()) { + ui->not_found->setText("invalid"); + return; + } + cursor = curEditor->document()->find(re,cursor,flags); + } else { + cursor = curEditor->document()->find(toFind,cursor,flags); + } + if (cursor.isNull()) { + hasWrapped++; + cursor = curEditor->textCursor(); + if (fwd) { + cursor.setPosition(0); + } else { + cursor.movePosition(QTextCursor::End); + } + } else { + ui->not_found->setText(""); + curEditor->setTextCursor(cursor); + break; + } + } + if (hasWrapped==2) { + ui->not_found->setText("not found"); + } + +} + void MainWindow::on_conf_solver_conf_currentIndexChanged(int index) { if (projectSolverConfigs.size() != 0 && index >= projectSolverConfigs.size()) @@ -3221,16 +3543,27 @@ void MainWindow::on_conf_default_toggled(bool checked) void MainWindow::on_actionFind_triggered() { - findDialog->raise(); - findDialog->show(); - findDialog->activateWindow(); + incrementalFindCursor = curEditor->textCursor(); + incrementalFindCursor.setPosition(std::min(curEditor->textCursor().anchor(), curEditor->textCursor().position())); + if (curEditor->textCursor().hasSelection()) { + ui->find->setText(curEditor->textCursor().selectedText()); + } + ui->not_found->setText(""); + ui->findFrame->raise(); + ui->findFrame->show(); + ui->find->setFocus(); } void MainWindow::on_actionReplace_triggered() { - findDialog->raise(); - findDialog->show(); - findDialog->activateWindow(); + incrementalFindCursor = curEditor->textCursor(); + incrementalFindCursor.setPosition(std::min(curEditor->textCursor().anchor(), curEditor->textCursor().position())); + if (curEditor->textCursor().hasSelection()) { + ui->find->setText(curEditor->textCursor().selectedText()); + } + ui->not_found->setText(""); + ui->findFrame->raise(); + ui->findFrame->show(); } void MainWindow::on_actionSelect_font_triggered() @@ -3265,15 +3598,15 @@ void MainWindow::on_actionGo_to_line_triggered() void MainWindow::checkMznPath() { QString ignoreVersionString; - SolverDialog::checkMznExecutable(mznDistribPath,mzn2fzn_executable,ignoreVersionString,solvers,userSolverConfigDir,userConfigFile,mznStdlibDir); + SolverDialog::checkMznExecutable(mznDistribPath,minizinc_executable,ignoreVersionString,solvers,userSolverConfigDir,userConfigFile,mznStdlibDir); - if (mzn2fzn_executable.isEmpty()) { + if (minizinc_executable.isEmpty()) { int ret = QMessageBox::warning(this,"MiniZinc IDE","Could not find the minizinc executable.\nDo you want to open the settings dialog?", QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Ok) on_actionManage_solvers_triggered(); } - bool haveMzn = (!mzn2fzn_executable.isEmpty() && solvers.size() > 0); + bool haveMzn = (!minizinc_executable.isEmpty() && solvers.size() > 0); ui->actionRun->setEnabled(haveMzn); ui->actionCompile->setEnabled(haveMzn); ui->actionEditSolverConfig->setEnabled(haveMzn); @@ -3499,6 +3832,14 @@ void MainWindow::saveProject(const QString& f) projConf["outputTiming"] = sc.outputTiming; projConf["solvingStats"] = sc.solvingStats; projConf["runSolutionChecker"] = sc.runSolutionChecker; + projConf["useExtraOptions"] = sc.useExtraOptions; + if (!sc.extraOptions.empty()) { + QJsonObject extraOptions; + for (auto& k : sc.extraOptions.keys()) { + extraOptions[k] = sc.extraOptions[k]; + } + projConf["extraOptions"] = extraOptions; + } projectConfigs.append(projConf); } confObject["projectSolverConfigs"] = projectConfigs; @@ -3537,6 +3878,14 @@ void MainWindow::saveProject(const QString& f) projConf["outputTiming"] = sc.outputTiming; projConf["solvingStats"] = sc.solvingStats; projConf["runSolutionChecker"] = sc.runSolutionChecker; + projConf["useExtraOptions"] = sc.useExtraOptions; + if (!sc.extraOptions.empty()) { + QJsonObject extraOptions; + for (auto& k : sc.extraOptions.keys()) { + extraOptions[k] = sc.extraOptions[k]; + } + projConf["extraOptions"] = extraOptions; + } builtinConfigs.append(projConf); } } @@ -3629,9 +3978,18 @@ namespace { if (sco["solvingStats"].isBool()) { newSc.solvingStats = sco["solvingStats"].toBool(); } - if (sco["runSolutionChecker"].toBool()) { + if (sco["runSolutionChecker"].isBool()) { newSc.runSolutionChecker = sco["runSolutionChecker"].toBool(); } + if (sco["useExtraOptions"].isBool()) { + newSc.useExtraOptions = sco["useExtraOptions"].toBool(); + } + if (sco["extraOptions"].isObject()) { + QJsonObject extraOptions = sco["extraOptions"].toObject(); + for (auto& k : extraOptions.keys()) { + newSc.extraOptions[k] = extraOptions[k].toString(); + } + } return newSc; } } @@ -3944,12 +4302,12 @@ void MainWindow::on_actionClose_project_triggered() void MainWindow::on_actionFind_next_triggered() { - findDialog->on_b_next_clicked(); + on_b_next_clicked(); } void MainWindow::on_actionFind_previous_triggered() { - findDialog->on_b_prev_clicked(); + on_b_prev_clicked(); } void MainWindow::on_actionSave_all_triggered() @@ -4117,6 +4475,61 @@ void MainWindow::on_actionCheat_Sheet_triggered() IDE::instance()->cheatSheet->activateWindow(); } +void MainWindow::checkModelFinished(int, QProcess::ExitStatus) +{ + if (curCheckEditor==curEditor) { + bool inRelevantError = false; + MiniZincError curError; + QVector mznErrors; + while (check_process->canReadLine()) { + QString l = check_process->readLine(); + QRegExp errexp("^(.*):(([0-9]+)(\\.([0-9]+)(-([0-9]+)(\\.([0-9]+))?)?)?):\\s*$"); + if (errexp.indexIn(l) != -1) { + inRelevantError = false; + QString errFile = errexp.cap(1).trimmed(); + if (errFile=="stdin") { + inRelevantError = true; + curError.filename = errFile; + curError.first_line = errexp.cap(3).toInt(); + curError.first_col = errexp.cap(5).isEmpty() ? 1 : errexp.cap(5).toInt(); + curError.last_line = + (errexp.cap(7).isEmpty() || errexp.cap(9).isEmpty()) ? curError.first_line : errexp.cap(7).toInt(); + curError.last_col = + errexp.cap(7).isEmpty() ? 1 : (errexp.cap(9).isEmpty() ? errexp.cap(7).toInt(): errexp.cap(9).toInt()); + } + } else { + if (inRelevantError && (l.startsWith("MiniZinc:") || l.startsWith("Error:"))) { + curError.msg = l.trimmed(); + mznErrors.push_back(curError); + } + } + } + curEditor->checkFile(mznErrors); + } + delete check_process; + check_process = NULL; +} + +void MainWindow::check_code() +{ + if (check_process==NULL && minizinc_executable!="" && + ui->actionRun->isEnabled() && + curEditor && curEditor->modifiedSinceLastCheck) { + curEditor->modifiedSinceLastCheck = false; + curCheckEditor = curEditor; + check_process = new MznProcess(this); + check_process->setWorkingDirectory(curEditor->filepath); + check_process->setProcessChannelMode(QProcess::MergedChannels); + connect(check_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(checkModelFinished(int,QProcess::ExitStatus))); + + QStringList args = parseConf(CONF_CHECKARGS, "", false); + args << "-c" << "--model-check-only" << "-"; + check_process->start(minizinc_executable,args,getMznDistribPath()); + check_process->write(curEditor->document()->toPlainText().toUtf8()); + check_process->closeWriteChannel(); + } +} + void MainWindow::on_actionDark_mode_toggled(bool enable) { darkMode = enable; @@ -4129,6 +4542,12 @@ void MainWindow::on_actionDark_mode_toggled(bool enable) ce->setDarkMode(darkMode); } static_cast(IDE::instance()->cheatSheet->centralWidget())->setDarkMode(darkMode); + + if (darkMode) { + ui->outputConsole->document()->setDefaultStyleSheet(".mznnotice { color : green }"); + } else { + ui->outputConsole->document()->setDefaultStyleSheet(".mznnotice { color : blue }"); + } } void MainWindow::on_actionEditSolverConfig_triggered() @@ -4149,7 +4568,75 @@ void MainWindow::on_conf_dock_widget_visibilityChanged(bool visible) } } -void MainWindow::on_conf_check_solutions_toggled(bool checked) +void MainWindow::on_conf_check_solutions_toggled(bool) { tabChange(ui->tabWidget->currentIndex()); } + + + +void MainWindow::on_b_next_clicked() +{ + find(true); + incrementalFindCursor.setPosition(std::min(curEditor->textCursor().anchor(), curEditor->textCursor().position())); +} + +void MainWindow::on_b_prev_clicked() +{ + find(false); + incrementalFindCursor.setPosition(std::min(curEditor->textCursor().anchor(), curEditor->textCursor().position())); +} + +void MainWindow::on_b_replacefind_clicked() +{ + on_b_replace_clicked(); + find(true); + incrementalFindCursor.setPosition(std::min(curEditor->textCursor().anchor(), curEditor->textCursor().position())); +} + +void MainWindow::on_b_replace_clicked() +{ + QTextCursor cursor = curEditor->textCursor(); + if (cursor.hasSelection()) { + cursor.insertText(ui->replace->text()); + } +} + +void MainWindow::on_b_replaceall_clicked() +{ + int counter = 0; + QTextCursor cursor = curEditor->textCursor(); + if (!cursor.hasSelection()) { + find(true); + cursor = curEditor->textCursor(); + } + cursor.beginEditBlock(); + while (cursor.hasSelection()) { + counter++; + cursor.insertText(ui->replace->text()); + find(true); + cursor = curEditor->textCursor(); + } + cursor.endEditBlock(); + if (counter > 0) { + ui->not_found->setText(QString().number(counter)+" replaced"); + } + incrementalFindCursor.setPosition(std::min(curEditor->textCursor().anchor(), curEditor->textCursor().position())); +} + +void MainWindow::on_closeFindWidget_clicked() +{ + ui->findFrame->hide(); + curEditor->setFocus(); +} + +void MainWindow::on_find_textEdited(const QString &) +{ + curEditor->setTextCursor(incrementalFindCursor); + find(true); +} + +void MainWindow::on_extraOptionsBox_toggled(bool isActive) +{ + ui->extraOptionsWidget->setVisible(isActive); +} diff --git a/MiniZincIDE/mainwindow.h b/MiniZincIDE/mainwindow.h index c571c43..5812a00 100755 --- a/MiniZincIDE/mainwindow.h +++ b/MiniZincIDE/mainwindow.h @@ -168,6 +168,7 @@ private slots: void checkArgs(QString filepath); void checkArgsOutput(); void checkArgsFinished(int exitcode, QProcess::ExitStatus exitstatus); + void checkModelFinished(int exitcode, QProcess::ExitStatus exitstatus); void readOutput(); @@ -284,6 +285,7 @@ private slots: void windowMenuSelected(QAction*); void closeHTMLWindow(int); void on_actionCheat_Sheet_triggered(); + void check_code(); void on_actionDark_mode_toggled(bool arg1); @@ -309,10 +311,29 @@ private slots: void on_conf_check_solutions_toggled(bool checked); + void on_b_next_clicked(); + + void on_b_prev_clicked(); + + void on_b_replacefind_clicked(); + + void on_b_replace_clicked(); + + void on_b_replaceall_clicked(); + + void on_closeFindWidget_clicked(); + + void on_find_textEdited(const QString &arg1); + + void on_extraOptionsBox_toggled(bool arg1); + protected: virtual void closeEvent(QCloseEvent*); virtual void dragEnterEvent(QDragEnterEvent *); virtual void dropEvent(QDropEvent *); +#ifdef Q_OS_MAC + virtual void paintEvent(QPaintEvent *); +#endif bool eventFilter(QObject *, QEvent *); void openJSONViewer(void); void finishJSONViewer(void); @@ -335,8 +356,10 @@ private slots: QVector htmlWindows; QVector htmlWindowModels; MznProcess* process; + MznProcess* check_process; QString processName; QString curModelFilepath; + CodeEditor* curCheckEditor; MznProcess* outputProcess; bool processWasStopped; int solutionCount; @@ -352,6 +375,7 @@ private slots: QVector JSONOutput; QTimer* timer; QTimer* solverTimeout; + QTimer* checkTimer; int time; QElapsedTimer elapsedTime; QProgressBar* progressBar; @@ -374,14 +398,14 @@ private slots: QTemporaryDir* tmpDir; QVector cleanupTmpDirs; QVector cleanupProcesses; - FindDialog* findDialog; + QTextCursor incrementalFindCursor; QString projectPath; bool saveBeforeRunning; QString compileErrors; ParamDialog* paramDialog; bool compileOnly; int runTimeout; - QString mzn2fzn_executable; + QString minizinc_executable; Project project; QSortFilterProxyModel* projectSort; QMenu* projectContextMenu; @@ -405,6 +429,7 @@ private slots: QToolButton* runButton; QVector projectSolverConfigs; QVector builtinSolverConfigs; + QVector> extraSolverFlags; int currentSolverConfig; bool renamingSolverConf; @@ -427,6 +452,7 @@ private slots: QVector collectCodeEditors(QVector& locs); void updateSolverConfigs(void); void setCurrentSolverConfig(int idx); + void find(bool fwd); public: void addOutput(const QString& s, bool html=true); void openProject(const QString& fileName); diff --git a/MiniZincIDE/mainwindow.ui b/MiniZincIDE/mainwindow.ui index 71a58c8..4b8f89c 100755 --- a/MiniZincIDE/mainwindow.ui +++ b/MiniZincIDE/mainwindow.ui @@ -6,7 +6,7 @@ 0 0 - 1087 + 1490 1609 @@ -76,6 +76,180 @@ + + + + + 16777215 + 80 + + + + QFrame::NoFrame + + + QFrame::Raised + + + 0 + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + + + 0 + + + + + not found + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Next + + + true + + + + + + + Replace && find + + + + + + + Replace + + + + + + + Previous + + + + + + + + 0 + 0 + + + + Regular expression + + + + + + + + 300 + 20 + + + + + + + + + 300 + 20 + + + + + + + + Find + + + + + + + Wrap around + + + + + + + Replace + + + + + + + Ignore case + + + + + + + Replace all + + + + + + + Close + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + @@ -83,7 +257,7 @@ 0 0 - 1087 + 1490 22 @@ -125,7 +299,6 @@ - @@ -359,7 +532,7 @@ - + 0 @@ -369,7 +542,7 @@ 700 - 132 + 147 @@ -401,9 +574,9 @@ 0 - 0 - 676 - 1019 + -279 + 661 + 1074 @@ -865,11 +1038,11 @@ - + Solver options - + @@ -977,6 +1150,53 @@ conf_stats conf_solver_verbose conf_solver_free + + + + + + + + + + 0 + 40 + + + + Extra solver options + + + true + + + false + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 20 + + + + + + diff --git a/MiniZincIDE/solverconfiguration.cpp b/MiniZincIDE/solverconfiguration.cpp index 7ca3087..d47eaf4 100644 --- a/MiniZincIDE/solverconfiguration.cpp +++ b/MiniZincIDE/solverconfiguration.cpp @@ -26,6 +26,7 @@ SolverConfiguration SolverConfiguration::defaultConfig() { def.outputTiming = false; def.solvingStats = false; def.runSolutionChecker = true; + def.useExtraOptions = false; return def; } @@ -72,8 +73,12 @@ void SolverConfiguration::defaultConfigs(const QVector& solvers, def.name = n.name+" "+n.version; def.solverId = n.id; def.solverVersion = n.version; + def.extraOptions.clear(); if (n.isDefaultSolver) defaultSolverIdx = solverConfigs.size(); + for (auto ef : n.extraFlags) { + def.extraOptions[ef.name] = ef.def; + } solverConfigs.push_back(def); } } @@ -102,5 +107,6 @@ bool SolverConfiguration::operator==(const SolverConfiguration &sc) const sc.verboseSolving==verboseSolving && sc.outputTiming==outputTiming && sc.solvingStats==solvingStats && - sc.runSolutionChecker==runSolutionChecker; + sc.runSolutionChecker==runSolutionChecker && + sc.useExtraOptions==useExtraOptions; } diff --git a/MiniZincIDE/solverconfiguration.h b/MiniZincIDE/solverconfiguration.h index 15d0ceb..68ef865 100644 --- a/MiniZincIDE/solverconfiguration.h +++ b/MiniZincIDE/solverconfiguration.h @@ -34,6 +34,8 @@ class SolverConfiguration bool outputTiming; bool solvingStats; bool runSolutionChecker; + bool useExtraOptions; + QMap extraOptions; static void defaultConfigs(const QVector& solvers, QVector& solverConfigs, int& defaultSolverIdx); static SolverConfiguration defaultConfig(void); diff --git a/MiniZincIDE/solverdialog.cpp b/MiniZincIDE/solverdialog.cpp index 7d487df..2693e1c 100755 --- a/MiniZincIDE/solverdialog.cpp +++ b/MiniZincIDE/solverdialog.cpp @@ -366,8 +366,6 @@ void SolverDialog::on_updateButton_clicked() } ui->solvers_combo->setCurrentIndex(index); } - QString mzn2fzn_executable; - QString mzn2fzn_version; editingFinished(false); } @@ -418,8 +416,8 @@ void SolverDialog::on_check_updates_stateChanged(int checkstate) } void SolverDialog::checkMznExecutable(const QString& mznDistribPath, - QString& mzn2fzn_executable, - QString& mzn2fzn_version_string, + QString& minizinc_executable, + QString& minizinc_version_string, QVector& solvers, QString& userSolverConfigDir, QString& userConfigFile, @@ -428,23 +426,18 @@ void SolverDialog::checkMznExecutable(const QString& mznDistribPath, MznProcess p; QStringList args; args << "--version"; - mzn2fzn_executable = ""; - mzn2fzn_version_string = ""; + minizinc_executable = ""; + minizinc_version_string = ""; p.start("minizinc", args, mznDistribPath); if (!p.waitForStarted() || !p.waitForFinished()) { - p.start("mzn2fzn.bat", args, mznDistribPath); - if (!p.waitForStarted() || !p.waitForFinished()) { - return; - } else { - mzn2fzn_executable = "mzn2fzn.bat"; - } + return; } else { - mzn2fzn_executable = "minizinc"; + minizinc_executable = "minizinc"; } - mzn2fzn_version_string = p.readAllStandardOutput()+p.readAllStandardError(); + minizinc_version_string = p.readAllStandardOutput()+p.readAllStandardError(); QRegExp reVersion("version ([0-9]+)\\.([0-9]+)\\.\\S+"); - if (reVersion.indexIn(mzn2fzn_version_string)==-1) { - mzn2fzn_executable = ""; + if (reVersion.indexIn(minizinc_version_string)==-1) { + minizinc_executable = ""; return; } else { bool ok; @@ -452,15 +445,15 @@ void SolverDialog::checkMznExecutable(const QString& mznDistribPath, if (ok) { int curVersionMinor = reVersion.cap(2).toInt(&ok); if (curVersionMajor<2 || (curVersionMajor<3 && curVersionMinor<2)) { - mzn2fzn_executable = ""; + minizinc_executable = ""; return; } } } - if (!mzn2fzn_executable.isEmpty()) { + if (!minizinc_executable.isEmpty()) { args.clear(); args << "--config-dirs"; - p.start(mzn2fzn_executable, args, mznDistribPath); + p.start(minizinc_executable, args, mznDistribPath); if (p.waitForStarted() && p.waitForFinished()) { QString allOutput = p.readAllStandardOutput(); QJsonDocument jd = QJsonDocument::fromJson(allOutput.toUtf8()); @@ -473,7 +466,7 @@ void SolverDialog::checkMznExecutable(const QString& mznDistribPath, } args.clear(); args << "--solvers-json"; - p.start(mzn2fzn_executable, args, mznDistribPath); + p.start(minizinc_executable, args, mznDistribPath); if (p.waitForStarted() && p.waitForFinished()) { QString allOutput = p.readAllStandardOutput(); QJsonDocument jd = QJsonDocument::fromJson(allOutput.toUtf8()); @@ -512,6 +505,62 @@ void SolverDialog::checkMznExecutable(const QString& mznDistribPath, s.stdFlags.push_back(sf.toString()); } } + if (sj["extraFlags"].isArray()) { + QJsonArray sfs = sj["extraFlags"].toArray(); + for (auto sf : sfs) { + if (sf.isArray()) { + QJsonArray extraFlagA = sf.toArray(); + if (extraFlagA.size()==4) { + SolverFlag extraFlag; + extraFlag.min=1.0; + extraFlag.max=0.0; + extraFlag.name = extraFlagA[0].toString(); + QRegularExpression re_opt("^(int|float|bool)(:([0-9a-zA-Z.-]+):([0-9a-zA-Z.-]+))?"); + QRegularExpressionMatch re_opt_match = re_opt.match(extraFlagA[2].toString()); + if (re_opt_match.hasMatch()) { + if (re_opt_match.captured(1)=="int") { + if (re_opt_match.captured(3).isEmpty()) { + extraFlag.t = SolverFlag::T_INT; + } else { + extraFlag.t = SolverFlag::T_INT_RANGE; + extraFlag.min = re_opt_match.captured(3).toInt(); + extraFlag.max = re_opt_match.captured(4).toInt(); + } + } else if (re_opt_match.captured(1)=="float") { + if (re_opt_match.captured(3).isEmpty()) { + extraFlag.t = SolverFlag::T_FLOAT; + } else { + extraFlag.t = SolverFlag::T_FLOAT_RANGE; + extraFlag.min = re_opt_match.captured(3).toDouble(); + extraFlag.max = re_opt_match.captured(4).toDouble(); + } + } else if (re_opt_match.captured(1)=="bool") { + if (re_opt_match.captured(3).isEmpty()) { + extraFlag.t = SolverFlag::T_BOOL; + } else { + extraFlag.t = SolverFlag::T_BOOL_ONOFF; + extraFlag.options = QStringList({re_opt_match.captured(3),re_opt_match.captured(4)}); + } + } + } else { + if (extraFlagA[2].toString()=="string") { + extraFlag.t = SolverFlag::T_STRING; + } else if (extraFlagA[2].toString().startsWith("opt:")) { + extraFlag.t = SolverFlag::T_OPT; + extraFlag.options = extraFlagA[2].toString().mid(4).split(":"); +// } else if (extraFlagA[2].toString()=="solver") { +// extraFlag.t = SolverFlag::T_SOLVER; + } else { + continue; + } + } + extraFlag.description = extraFlagA[1].toString(); + extraFlag.def = extraFlagA[3].toString(); + s.extraFlags.push_back(extraFlag); + } + } + } + } s.isGUIApplication = sj["isGUIApplication"].toBool(false); s.needsMznExecutable = sj["needsMznExecutable"].toBool(false); s.needsStdlibDir = sj["needsStdlibDir"].toBool(false); @@ -531,25 +580,25 @@ void SolverDialog::checkMznExecutable(const QString& mznDistribPath, void SolverDialog::editingFinished(bool showError) { - QString mzn2fzn_executable; - QString mzn2fzn_version; + QString minizinc_executable; + QString minizinc_version; for (int i=0; isolvers_combo->removeItem(0); } solvers.clear(); - checkMznExecutable(ui->mznDistribPath->text(),mzn2fzn_executable,mzn2fzn_version,solvers,userSolverConfigDir,userConfigFile,mznStdlibDir); - if (mzn2fzn_executable.isEmpty()) { + checkMznExecutable(ui->mznDistribPath->text(),minizinc_executable,minizinc_version,solvers,userSolverConfigDir,userConfigFile,mznStdlibDir); + if (minizinc_executable.isEmpty()) { if (showError) { - QMessageBox::warning(this,"MiniZinc IDE","Could not find the mzn2fzn executable.", + QMessageBox::warning(this,"MiniZinc IDE","Could not find the minizinc executable.", QMessageBox::Ok); } - if (mzn2fzn_version.isEmpty()) { + if (minizinc_version.isEmpty()) { ui->mzn2fzn_version->setText("None"); } else { - ui->mzn2fzn_version->setText("None. Error message:\n"+mzn2fzn_version); + ui->mzn2fzn_version->setText("None. Error message:\n"+minizinc_version); } } else { - ui->mzn2fzn_version->setText(mzn2fzn_version); + ui->mzn2fzn_version->setText(minizinc_version); for (int i=solvers.size(); i--;) { ui->solvers_combo->insertItem(0,solvers[i].name+" "+solvers[i].version,i); } diff --git a/MiniZincIDE/solverdialog.h b/MiniZincIDE/solverdialog.h index b27d70e..76a3d59 100755 --- a/MiniZincIDE/solverdialog.h +++ b/MiniZincIDE/solverdialog.h @@ -25,6 +25,16 @@ namespace Ui { class SolverDialog; } +struct SolverFlag { + QString name; + QString description; + enum { T_INT, T_INT_RANGE, T_BOOL, T_BOOL_ONOFF, T_FLOAT, T_FLOAT_RANGE, T_STRING, T_OPT, T_SOLVER } t; + double min; + double max; + QStringList options; + QString def; +}; + struct Solver { QString configFile; QString id; @@ -46,7 +56,7 @@ struct Solver { bool needsStdlibDir; bool needsPathsFile; QStringList stdFlags; - QStringList extraFlags; + QList extraFlags; QStringList requiredFlags; QStringList defaultFlags; QStringList tags; diff --git a/resources/Preferences.json b/resources/Preferences.json new file mode 100644 index 0000000..791f229 --- /dev/null +++ b/resources/Preferences.json @@ -0,0 +1,5 @@ +{ + "tagDefaults": [ + ["", "org.gecode.gecode"] + ] +} diff --git a/resources/README.md b/resources/README.md new file mode 100644 index 0000000..56cc6e9 --- /dev/null +++ b/resources/README.md @@ -0,0 +1,7 @@ +# Packaging Resources + +This folder contains packaging resources for the MiniZinc bundle distributions. +These files are used in the continuous integration of the MiniZinc tool chain +and are not used in the compilation of the MiniZinc IDE. Resources in this +folder are packaged depending on the targeted platform and are not available on +all platforms. diff --git a/resources/icon.png b/resources/icon.png new file mode 100644 index 0000000..e2cedc6 Binary files /dev/null and b/resources/icon.png differ diff --git a/COMBINED_LICENSE.txt b/resources/misc/COMBINED_LICENSE.txt old mode 100644 new mode 100755 similarity index 95% rename from COMBINED_LICENSE.txt rename to resources/misc/COMBINED_LICENSE.txt index a110f80..d27cb4f --- a/COMBINED_LICENSE.txt +++ b/resources/misc/COMBINED_LICENSE.txt @@ -1,1986 +1,1986 @@ -The MiniZinc IDE is copyright NICTA and Monash University. -It is distributed under the Mozilla Public License Version 2.0 (see below). -The MiniZinc IDE uses the Qt toolkit, which is distributed under the LGPL license (see below). - -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. - - GNU LESSER GENERAL PUBLIC LICENSE - - - - - - The Qt Toolkit is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - - - Contact: http://www.qt-project.org/legal - - - - - - You may use, distribute and copy the Qt GUI Toolkit under the terms of - - - GNU Lesser General Public License version 2.1, which is displayed below. - - - - - -------------------------------------------------------------------------- - - - - - - GNU LESSER GENERAL PUBLIC LICENSE - - - Version 2.1, February 1999 - - - - - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - - - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - - Everyone is permitted to copy and distribute verbatim copies - - - of this license document, but changing it is not allowed. - - - - - -[This is the first released version of the Lesser GPL. It also counts - - - as the successor of the GNU Library Public License, version 2, hence - - - the version number 2.1.] - - - - - - Preamble - - - - - - The licenses for most software are designed to take away your - - -freedom to share and change it. By contrast, the GNU General Public - - -Licenses are intended to guarantee your freedom to share and change - - -free software--to make sure the software is free for all its users. - - - - - - This license, the Lesser General Public License, applies to some - - -specially designated software packages--typically libraries--of the - - -Free Software Foundation and other authors who decide to use it. You - - -can use it too, but we suggest you first think carefully about whether - - -this license or the ordinary General Public License is the better - - -strategy to use in any particular case, based on the explanations below. - - - - - - When we speak of free software, we are referring to freedom of use, - - -not price. Our General Public Licenses are designed to make sure that - - -you have the freedom to distribute copies of free software (and charge - - -for this service if you wish); that you receive source code or can get - - -it if you want it; that you can change the software and use pieces of - - -it in new free programs; and that you are informed that you can do - - -these things. - - - - - - To protect your rights, we need to make restrictions that forbid - - -distributors to deny you these rights or to ask you to surrender these - - -rights. These restrictions translate to certain responsibilities for - - -you if you distribute copies of the library or if you modify it. - - - - - - For example, if you distribute copies of the library, whether gratis - - -or for a fee, you must give the recipients all the rights that we gave - - -you. You must make sure that they, too, receive or can get the source - - -code. If you link other code with the library, you must provide - - -complete object files to the recipients, so that they can relink them - - -with the library after making changes to the library and recompiling - - -it. And you must show them these terms so they know their rights. - - - - - - We protect your rights with a two-step method: (1) we copyright the - - -library, and (2) we offer you this license, which gives you legal - - -permission to copy, distribute and/or modify the library. - - - - - - To protect each distributor, we want to make it very clear that - - -there is no warranty for the free library. Also, if the library is - - -modified by someone else and passed on, the recipients should know - - -that what they have is not the original version, so that the original - - -author's reputation will not be affected by problems that might be - - -introduced by others. - - - - - - Finally, software patents pose a constant threat to the existence of - - -any free program. We wish to make sure that a company cannot - - -effectively restrict the users of a free program by obtaining a - - -restrictive license from a patent holder. Therefore, we insist that - - -any patent license obtained for a version of the library must be - - -consistent with the full freedom of use specified in this license. - - - - - - Most GNU software, including some libraries, is covered by the - - -ordinary GNU General Public License. This license, the GNU Lesser - - -General Public License, applies to certain designated libraries, and - - -is quite different from the ordinary General Public License. We use - - -this license for certain libraries in order to permit linking those - - -libraries into non-free programs. - - - - - - When a program is linked with a library, whether statically or using - - -a shared library, the combination of the two is legally speaking a - - -combined work, a derivative of the original library. The ordinary - - -General Public License therefore permits such linking only if the - - -entire combination fits its criteria of freedom. The Lesser General - - -Public License permits more lax criteria for linking other code with - - -the library. - - - - - - We call this license the "Lesser" General Public License because it - - -does Less to protect the user's freedom than the ordinary General - - -Public License. It also provides other free software developers Less - - -of an advantage over competing non-free programs. These disadvantages - - -are the reason we use the ordinary General Public License for many - - -libraries. However, the Lesser license provides advantages in certain - - -special circumstances. - - - - - - For example, on rare occasions, there may be a special need to - - -encourage the widest possible use of a certain library, so that it becomes - - -a de-facto standard. To achieve this, non-free programs must be - - -allowed to use the library. A more frequent case is that a free - - -library does the same job as widely used non-free libraries. In this - - -case, there is little to gain by limiting the free library to free - - -software only, so we use the Lesser General Public License. - - - - - - In other cases, permission to use a particular library in non-free - - -programs enables a greater number of people to use a large body of - - -free software. For example, permission to use the GNU C Library in - - -non-free programs enables many more people to use the whole GNU - - -operating system, as well as its variant, the GNU/Linux operating - - -system. - - - - - - Although the Lesser General Public License is Less protective of the - - -users' freedom, it does ensure that the user of a program that is - - -linked with the Library has the freedom and the wherewithal to run - - -that program using a modified version of the Library. - - - - - - The precise terms and conditions for copying, distribution and - - -modification follow. Pay close attention to the difference between a - - -"work based on the library" and a "work that uses the library". The - - -former contains code derived from the library, whereas the latter must - - -be combined with the library in order to run. - - - - - - GNU LESSER GENERAL PUBLIC LICENSE - - - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - - - - - 0. This License Agreement applies to any software library or other - - -program which contains a notice placed by the copyright holder or - - -other authorized party saying it may be distributed under the terms of - - -this Lesser General Public License (also called "this License"). - - -Each licensee is addressed as "you". - - - - - - A "library" means a collection of software functions and/or data - - -prepared so as to be conveniently linked with application programs - - -(which use some of those functions and data) to form executables. - - - - - - The "Library", below, refers to any such software library or work - - -which has been distributed under these terms. A "work based on the - - -Library" means either the Library or any derivative work under - - -copyright law: that is to say, a work containing the Library or a - - -portion of it, either verbatim or with modifications and/or translated - - -straightforwardly into another language. (Hereinafter, translation is - - -included without limitation in the term "modification".) - - - - - - "Source code" for a work means the preferred form of the work for - - -making modifications to it. For a library, complete source code means - - -all the source code for all modules it contains, plus any associated - - -interface definition files, plus the scripts used to control compilation - - -and installation of the library. - - - - - - Activities other than copying, distribution and modification are not - - -covered by this License; they are outside its scope. The act of - - -running a program using the Library is not restricted, and output from - - -such a program is covered only if its contents constitute a work based - - -on the Library (independent of the use of the Library in a tool for - - -writing it). Whether that is true depends on what the Library does - - -and what the program that uses the Library does. - - - - - - 1. You may copy and distribute verbatim copies of the Library's - - -complete source code as you receive it, in any medium, provided that - - -you conspicuously and appropriately publish on each copy an - - -appropriate copyright notice and disclaimer of warranty; keep intact - - -all the notices that refer to this License and to the absence of any - - -warranty; and distribute a copy of this License along with the - - -Library. - - - - - - You may charge a fee for the physical act of transferring a copy, - - -and you may at your option offer warranty protection in exchange for a - - -fee. - - - - - - 2. You may modify your copy or copies of the Library or any portion - - -of it, thus forming a work based on the Library, and copy and - - -distribute such modifications or work under the terms of Section 1 - - -above, provided that you also meet all of these conditions: - - - - - - a) The modified work must itself be a software library. - - - - - - b) You must cause the files modified to carry prominent notices - - - stating that you changed the files and the date of any change. - - - - - - c) You must cause the whole of the work to be licensed at no - - - charge to all third parties under the terms of this License. - - - - - - d) If a facility in the modified Library refers to a function or a - - - table of data to be supplied by an application program that uses - - - the facility, other than as an argument passed when the facility - - - is invoked, then you must make a good faith effort to ensure that, - - - in the event an application does not supply such function or - - - table, the facility still operates, and performs whatever part of - - - its purpose remains meaningful. - - - - - - (For example, a function in a library to compute square roots has - - - a purpose that is entirely well-defined independent of the - - - application. Therefore, Subsection 2d requires that any - - - application-supplied function or table used by this function must - - - be optional: if the application does not supply it, the square - - - root function must still compute square roots.) - - - - - -These requirements apply to the modified work as a whole. If - - -identifiable sections of that work are not derived from the Library, - - -and can be reasonably considered independent and separate works in - - -themselves, then this License, and its terms, do not apply to those - - -sections when you distribute them as separate works. But when you - - -distribute the same sections as part of a whole which is a work based - - -on the Library, the distribution of the whole must be on the terms of - - -this License, whose permissions for other licensees extend to the - - -entire whole, and thus to each and every part regardless of who wrote - - -it. - - - - - -Thus, it is not the intent of this section to claim rights or contest - - -your rights to work written entirely by you; rather, the intent is to - - -exercise the right to control the distribution of derivative or - - -collective works based on the Library. - - - - - -In addition, mere aggregation of another work not based on the Library - - -with the Library (or with a work based on the Library) on a volume of - - -a storage or distribution medium does not bring the other work under - - -the scope of this License. - - - - - - 3. You may opt to apply the terms of the ordinary GNU General Public - - -License instead of this License to a given copy of the Library. To do - - -this, you must alter all the notices that refer to this License, so - - -that they refer to the ordinary GNU General Public License, version 2, - - -instead of to this License. (If a newer version than version 2 of the - - -ordinary GNU General Public License has appeared, then you can specify - - -that version instead if you wish.) Do not make any other change in - - -these notices. - - - - - - Once this change is made in a given copy, it is irreversible for - - -that copy, so the ordinary GNU General Public License applies to all - - -subsequent copies and derivative works made from that copy. - - - - - - This option is useful when you wish to copy part of the code of - - -the Library into a program that is not a library. - - - - - - 4. You may copy and distribute the Library (or a portion or - - -derivative of it, under Section 2) in object code or executable form - - -under the terms of Sections 1 and 2 above provided that you accompany - - -it with the complete corresponding machine-readable source code, which - - -must be distributed under the terms of Sections 1 and 2 above on a - - -medium customarily used for software interchange. - - - - - - If distribution of object code is made by offering access to copy - - -from a designated place, then offering equivalent access to copy the - - -source code from the same place satisfies the requirement to - - -distribute the source code, even though third parties are not - - -compelled to copy the source along with the object code. - - - - - - 5. A program that contains no derivative of any portion of the - - -Library, but is designed to work with the Library by being compiled or - - -linked with it, is called a "work that uses the Library". Such a - - -work, in isolation, is not a derivative work of the Library, and - - -therefore falls outside the scope of this License. - - - - - - However, linking a "work that uses the Library" with the Library - - -creates an executable that is a derivative of the Library (because it - - -contains portions of the Library), rather than a "work that uses the - - -library". The executable is therefore covered by this License. - - -Section 6 states terms for distribution of such executables. - - - - - - When a "work that uses the Library" uses material from a header file - - -that is part of the Library, the object code for the work may be a - - -derivative work of the Library even though the source code is not. - - -Whether this is true is especially significant if the work can be - - -linked without the Library, or if the work is itself a library. The - - -threshold for this to be true is not precisely defined by law. - - - - - - If such an object file uses only numerical parameters, data - - -structure layouts and accessors, and small macros and small inline - - -functions (ten lines or less in length), then the use of the object - - -file is unrestricted, regardless of whether it is legally a derivative - - -work. (Executables containing this object code plus portions of the - - -Library will still fall under Section 6.) - - - - - - Otherwise, if the work is a derivative of the Library, you may - - -distribute the object code for the work under the terms of Section 6. - - -Any executables containing that work also fall under Section 6, - - -whether or not they are linked directly with the Library itself. - - - - - - 6. As an exception to the Sections above, you may also combine or - - -link a "work that uses the Library" with the Library to produce a - - -work containing portions of the Library, and distribute that work - - -under terms of your choice, provided that the terms permit - - -modification of the work for the customer's own use and reverse - - -engineering for debugging such modifications. - - - - - - You must give prominent notice with each copy of the work that the - - -Library is used in it and that the Library and its use are covered by - - -this License. You must supply a copy of this License. If the work - - -during execution displays copyright notices, you must include the - - -copyright notice for the Library among them, as well as a reference - - -directing the user to the copy of this License. Also, you must do one - - -of these things: - - - - - - a) Accompany the work with the complete corresponding - - - machine-readable source code for the Library including whatever - - - changes were used in the work (which must be distributed under - - - Sections 1 and 2 above); and, if the work is an executable linked - - - with the Library, with the complete machine-readable "work that - - - uses the Library", as object code and/or source code, so that the - - - user can modify the Library and then relink to produce a modified - - - executable containing the modified Library. (It is understood - - - that the user who changes the contents of definitions files in the - - - Library will not necessarily be able to recompile the application - - - to use the modified definitions.) - - - - - - b) Use a suitable shared library mechanism for linking with the - - - Library. A suitable mechanism is one that (1) uses at run time a - - - copy of the library already present on the user's computer system, - - - rather than copying library functions into the executable, and (2) - - - will operate properly with a modified version of the library, if - - - the user installs one, as long as the modified version is - - - interface-compatible with the version that the work was made with. - - - - - - c) Accompany the work with a written offer, valid for at - - - least three years, to give the same user the materials - - - specified in Subsection 6a, above, for a charge no more - - - than the cost of performing this distribution. - - - - - - d) If distribution of the work is made by offering access to copy - - - from a designated place, offer equivalent access to copy the above - - - specified materials from the same place. - - - - - - e) Verify that the user has already received a copy of these - - - materials or that you have already sent this user a copy. - - - - - - For an executable, the required form of the "work that uses the - - -Library" must include any data and utility programs needed for - - -reproducing the executable from it. However, as a special exception, - - -the materials to be distributed need not include anything that is - - -normally distributed (in either source or binary form) with the major - - -components (compiler, kernel, and so on) of the operating system on - - -which the executable runs, unless that component itself accompanies - - -the executable. - - - - - - It may happen that this requirement contradicts the license - - -restrictions of other proprietary libraries that do not normally - - -accompany the operating system. Such a contradiction means you cannot - - -use both them and the Library together in an executable that you - - -distribute. - - - - - - 7. You may place library facilities that are a work based on the - - -Library side-by-side in a single library together with other library - - -facilities not covered by this License, and distribute such a combined - - -library, provided that the separate distribution of the work based on - - -the Library and of the other library facilities is otherwise - - -permitted, and provided that you do these two things: - - - - - - a) Accompany the combined library with a copy of the same work - - - based on the Library, uncombined with any other library - - - facilities. This must be distributed under the terms of the - - - Sections above. - - - - - - b) Give prominent notice with the combined library of the fact - - - that part of it is a work based on the Library, and explaining - - - where to find the accompanying uncombined form of the same work. - - - - - - 8. You may not copy, modify, sublicense, link with, or distribute - - -the Library except as expressly provided under this License. Any - - -attempt otherwise to copy, modify, sublicense, link with, or - - -distribute the Library is void, and will automatically terminate your - - -rights under this License. However, parties who have received copies, - - -or rights, from you under this License will not have their licenses - - -terminated so long as such parties remain in full compliance. - - - - - - 9. You are not required to accept this License, since you have not - - -signed it. However, nothing else grants you permission to modify or - - -distribute the Library or its derivative works. These actions are - - -prohibited by law if you do not accept this License. Therefore, by - - -modifying or distributing the Library (or any work based on the - - -Library), you indicate your acceptance of this License to do so, and - - -all its terms and conditions for copying, distributing or modifying - - -the Library or works based on it. - - - - - - 10. Each time you redistribute the Library (or any work based on the - - -Library), the recipient automatically receives a license from the - - -original licensor to copy, distribute, link with or modify the Library - - -subject to these terms and conditions. You may not impose any further - - -restrictions on the recipients' exercise of the rights granted herein. - - -You are not responsible for enforcing compliance by third parties with - - -this License. - - - - - - 11. If, as a consequence of a court judgment or allegation of patent - - -infringement or for any other reason (not limited to patent issues), - - -conditions are imposed on you (whether by court order, agreement or - - -otherwise) that contradict the conditions of this License, they do not - - -excuse you from the conditions of this License. If you cannot - - -distribute so as to satisfy simultaneously your obligations under this - - -License and any other pertinent obligations, then as a consequence you - - -may not distribute the Library at all. For example, if a patent - - -license would not permit royalty-free redistribution of the Library by - - -all those who receive copies directly or indirectly through you, then - - -the only way you could satisfy both it and this License would be to - - -refrain entirely from distribution of the Library. - - - - - -If any portion of this section is held invalid or unenforceable under any - - -particular circumstance, the balance of the section is intended to apply, - - -and the section as a whole is intended to apply in other circumstances. - - - - - -It is not the purpose of this section to induce you to infringe any - - -patents or other property right claims or to contest validity of any - - -such claims; this section has the sole purpose of protecting the - - -integrity of the free software distribution system which is - - -implemented by public license practices. Many people have made - - -generous contributions to the wide range of software distributed - - -through that system in reliance on consistent application of that - - -system; it is up to the author/donor to decide if he or she is willing - - -to distribute software through any other system and a licensee cannot - - -impose that choice. - - - - - -This section is intended to make thoroughly clear what is believed to - - -be a consequence of the rest of this License. - - - - - - 12. If the distribution and/or use of the Library is restricted in - - -certain countries either by patents or by copyrighted interfaces, the - - -original copyright holder who places the Library under this License may add - - -an explicit geographical distribution limitation excluding those countries, - - -so that distribution is permitted only in or among countries not thus - - -excluded. In such case, this License incorporates the limitation as if - - -written in the body of this License. - - - - - - 13. The Free Software Foundation may publish revised and/or new - - -versions of the Lesser General Public License from time to time. - - -Such new versions will be similar in spirit to the present version, - - -but may differ in detail to address new problems or concerns. - - - - - -Each version is given a distinguishing version number. If the Library - - -specifies a version number of this License which applies to it and - - -"any later version", you have the option of following the terms and - - -conditions either of that version or of any later version published by - - -the Free Software Foundation. If the Library does not specify a - - -license version number, you may choose any version ever published by - - -the Free Software Foundation. - - - - - - 14. If you wish to incorporate parts of the Library into other free - - -programs whose distribution conditions are incompatible with these, - - -write to the author to ask for permission. For software which is - - -copyrighted by the Free Software Foundation, write to the Free - - -Software Foundation; we sometimes make exceptions for this. Our - - -decision will be guided by the two goals of preserving the free status - - -of all derivatives of our free software and of promoting the sharing - - -and reuse of software generally. - - - - - - NO WARRANTY - - - - - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO - - -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. - - -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR - - -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY - - -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE - - -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - - -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE - - -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME - - -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - - - - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN - - -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY - - -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU - - -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR - - -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE - - -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING - - -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A - - -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF - - -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - - -DAMAGES. - - - - - - END OF TERMS AND CONDITIONS - - - - - - How to Apply These Terms to Your New Libraries - - - - - - If you develop a new library, and you want it to be of the greatest - - -possible use to the public, we recommend making it free software that - - -everyone can redistribute and change. You can do so by permitting - - -redistribution under these terms (or, alternatively, under the terms of the - - -ordinary General Public License). - - - - - - To apply these terms, attach the following notices to the library. It is - - -safest to attach them to the start of each source file to most effectively - - -convey the exclusion of warranty; and each file should have at least the - - -"copyright" line and a pointer to where the full notice is found. - - - - - - - - - Copyright (C) - - - - - - This library is free software; you can redistribute it and/or - - - modify it under the terms of the GNU Lesser General Public - - - License as published by the Free Software Foundation; either - - - version 2.1 of the License, or (at your option) any later version. - - - - - - This library is distributed in the hope that it will be useful, - - - but WITHOUT ANY WARRANTY; without even the implied warranty of - - - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - - - Lesser General Public License for more details. - - - - - - You should have received a copy of the GNU Lesser General Public - - - License along with this library; if not, write to the Free Software - - - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - - - - -Also add information on how to contact you by electronic and paper mail. - - - - - -You should also get your employer (if you work as a programmer) or your - - -school, if any, to sign a "copyright disclaimer" for the library, if - - -necessary. Here is a sample; alter the names: - - - - - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - - - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - - - - - , 1 April 1990 - - - Ty Coon, President of Vice - - - - - -That's all there is to it! - - - - - - - - -Digia Qt LGPL Exception version 1.1 - - - - - -As an additional permission to the GNU Lesser General Public License version - - -2.1, the object code form of a "work that uses the Library" may incorporate - - -material from a header file that is part of the Library. You may distribute - - -such object code under terms of your choice, provided that: - - - (i) the header files of the Library have not been modified; and - - - (ii) the incorporated material is limited to numerical parameters, data - - - structure layouts, accessors, macros, inline functions and - - - templates; and - - - (iii) you comply with the terms of Section 6 of the GNU Lesser General - - - Public License version 2.1. - - - - - -Moreover, you may apply this exception to a modified version of the Library, - - -provided that such modification does not involve copying material from the - - -Library into the modified Library's header files unless such material is - - -limited to (i) numerical parameters; (ii) data structure layouts; - - -(iii) accessors; and (iv) small macros, templates and inline functions of - - -five lines or less in length. - - - - - -Furthermore, you are not required to apply this additional permission to a - - -modified version of the Library. - - +The MiniZinc IDE is copyright NICTA and Monash University. +It is distributed under the Mozilla Public License Version 2.0 (see below). +The MiniZinc IDE uses the Qt toolkit, which is distributed under the LGPL license (see below). + +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. + + GNU LESSER GENERAL PUBLIC LICENSE + + + + + + The Qt Toolkit is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + + + Contact: http://www.qt-project.org/legal + + + + + + You may use, distribute and copy the Qt GUI Toolkit under the terms of + + + GNU Lesser General Public License version 2.1, which is displayed below. + + + + + +------------------------------------------------------------------------- + + + + + + GNU LESSER GENERAL PUBLIC LICENSE + + + Version 2.1, February 1999 + + + + + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + + + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + + Everyone is permitted to copy and distribute verbatim copies + + + of this license document, but changing it is not allowed. + + + + + +[This is the first released version of the Lesser GPL. It also counts + + + as the successor of the GNU Library Public License, version 2, hence + + + the version number 2.1.] + + + + + + Preamble + + + + + + The licenses for most software are designed to take away your + + +freedom to share and change it. By contrast, the GNU General Public + + +Licenses are intended to guarantee your freedom to share and change + + +free software--to make sure the software is free for all its users. + + + + + + This license, the Lesser General Public License, applies to some + + +specially designated software packages--typically libraries--of the + + +Free Software Foundation and other authors who decide to use it. You + + +can use it too, but we suggest you first think carefully about whether + + +this license or the ordinary General Public License is the better + + +strategy to use in any particular case, based on the explanations below. + + + + + + When we speak of free software, we are referring to freedom of use, + + +not price. Our General Public Licenses are designed to make sure that + + +you have the freedom to distribute copies of free software (and charge + + +for this service if you wish); that you receive source code or can get + + +it if you want it; that you can change the software and use pieces of + + +it in new free programs; and that you are informed that you can do + + +these things. + + + + + + To protect your rights, we need to make restrictions that forbid + + +distributors to deny you these rights or to ask you to surrender these + + +rights. These restrictions translate to certain responsibilities for + + +you if you distribute copies of the library or if you modify it. + + + + + + For example, if you distribute copies of the library, whether gratis + + +or for a fee, you must give the recipients all the rights that we gave + + +you. You must make sure that they, too, receive or can get the source + + +code. If you link other code with the library, you must provide + + +complete object files to the recipients, so that they can relink them + + +with the library after making changes to the library and recompiling + + +it. And you must show them these terms so they know their rights. + + + + + + We protect your rights with a two-step method: (1) we copyright the + + +library, and (2) we offer you this license, which gives you legal + + +permission to copy, distribute and/or modify the library. + + + + + + To protect each distributor, we want to make it very clear that + + +there is no warranty for the free library. Also, if the library is + + +modified by someone else and passed on, the recipients should know + + +that what they have is not the original version, so that the original + + +author's reputation will not be affected by problems that might be + + +introduced by others. + + + + + + Finally, software patents pose a constant threat to the existence of + + +any free program. We wish to make sure that a company cannot + + +effectively restrict the users of a free program by obtaining a + + +restrictive license from a patent holder. Therefore, we insist that + + +any patent license obtained for a version of the library must be + + +consistent with the full freedom of use specified in this license. + + + + + + Most GNU software, including some libraries, is covered by the + + +ordinary GNU General Public License. This license, the GNU Lesser + + +General Public License, applies to certain designated libraries, and + + +is quite different from the ordinary General Public License. We use + + +this license for certain libraries in order to permit linking those + + +libraries into non-free programs. + + + + + + When a program is linked with a library, whether statically or using + + +a shared library, the combination of the two is legally speaking a + + +combined work, a derivative of the original library. The ordinary + + +General Public License therefore permits such linking only if the + + +entire combination fits its criteria of freedom. The Lesser General + + +Public License permits more lax criteria for linking other code with + + +the library. + + + + + + We call this license the "Lesser" General Public License because it + + +does Less to protect the user's freedom than the ordinary General + + +Public License. It also provides other free software developers Less + + +of an advantage over competing non-free programs. These disadvantages + + +are the reason we use the ordinary General Public License for many + + +libraries. However, the Lesser license provides advantages in certain + + +special circumstances. + + + + + + For example, on rare occasions, there may be a special need to + + +encourage the widest possible use of a certain library, so that it becomes + + +a de-facto standard. To achieve this, non-free programs must be + + +allowed to use the library. A more frequent case is that a free + + +library does the same job as widely used non-free libraries. In this + + +case, there is little to gain by limiting the free library to free + + +software only, so we use the Lesser General Public License. + + + + + + In other cases, permission to use a particular library in non-free + + +programs enables a greater number of people to use a large body of + + +free software. For example, permission to use the GNU C Library in + + +non-free programs enables many more people to use the whole GNU + + +operating system, as well as its variant, the GNU/Linux operating + + +system. + + + + + + Although the Lesser General Public License is Less protective of the + + +users' freedom, it does ensure that the user of a program that is + + +linked with the Library has the freedom and the wherewithal to run + + +that program using a modified version of the Library. + + + + + + The precise terms and conditions for copying, distribution and + + +modification follow. Pay close attention to the difference between a + + +"work based on the library" and a "work that uses the library". The + + +former contains code derived from the library, whereas the latter must + + +be combined with the library in order to run. + + + + + + GNU LESSER GENERAL PUBLIC LICENSE + + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + + + + + 0. This License Agreement applies to any software library or other + + +program which contains a notice placed by the copyright holder or + + +other authorized party saying it may be distributed under the terms of + + +this Lesser General Public License (also called "this License"). + + +Each licensee is addressed as "you". + + + + + + A "library" means a collection of software functions and/or data + + +prepared so as to be conveniently linked with application programs + + +(which use some of those functions and data) to form executables. + + + + + + The "Library", below, refers to any such software library or work + + +which has been distributed under these terms. A "work based on the + + +Library" means either the Library or any derivative work under + + +copyright law: that is to say, a work containing the Library or a + + +portion of it, either verbatim or with modifications and/or translated + + +straightforwardly into another language. (Hereinafter, translation is + + +included without limitation in the term "modification".) + + + + + + "Source code" for a work means the preferred form of the work for + + +making modifications to it. For a library, complete source code means + + +all the source code for all modules it contains, plus any associated + + +interface definition files, plus the scripts used to control compilation + + +and installation of the library. + + + + + + Activities other than copying, distribution and modification are not + + +covered by this License; they are outside its scope. The act of + + +running a program using the Library is not restricted, and output from + + +such a program is covered only if its contents constitute a work based + + +on the Library (independent of the use of the Library in a tool for + + +writing it). Whether that is true depends on what the Library does + + +and what the program that uses the Library does. + + + + + + 1. You may copy and distribute verbatim copies of the Library's + + +complete source code as you receive it, in any medium, provided that + + +you conspicuously and appropriately publish on each copy an + + +appropriate copyright notice and disclaimer of warranty; keep intact + + +all the notices that refer to this License and to the absence of any + + +warranty; and distribute a copy of this License along with the + + +Library. + + + + + + You may charge a fee for the physical act of transferring a copy, + + +and you may at your option offer warranty protection in exchange for a + + +fee. + + + + + + 2. You may modify your copy or copies of the Library or any portion + + +of it, thus forming a work based on the Library, and copy and + + +distribute such modifications or work under the terms of Section 1 + + +above, provided that you also meet all of these conditions: + + + + + + a) The modified work must itself be a software library. + + + + + + b) You must cause the files modified to carry prominent notices + + + stating that you changed the files and the date of any change. + + + + + + c) You must cause the whole of the work to be licensed at no + + + charge to all third parties under the terms of this License. + + + + + + d) If a facility in the modified Library refers to a function or a + + + table of data to be supplied by an application program that uses + + + the facility, other than as an argument passed when the facility + + + is invoked, then you must make a good faith effort to ensure that, + + + in the event an application does not supply such function or + + + table, the facility still operates, and performs whatever part of + + + its purpose remains meaningful. + + + + + + (For example, a function in a library to compute square roots has + + + a purpose that is entirely well-defined independent of the + + + application. Therefore, Subsection 2d requires that any + + + application-supplied function or table used by this function must + + + be optional: if the application does not supply it, the square + + + root function must still compute square roots.) + + + + + +These requirements apply to the modified work as a whole. If + + +identifiable sections of that work are not derived from the Library, + + +and can be reasonably considered independent and separate works in + + +themselves, then this License, and its terms, do not apply to those + + +sections when you distribute them as separate works. But when you + + +distribute the same sections as part of a whole which is a work based + + +on the Library, the distribution of the whole must be on the terms of + + +this License, whose permissions for other licensees extend to the + + +entire whole, and thus to each and every part regardless of who wrote + + +it. + + + + + +Thus, it is not the intent of this section to claim rights or contest + + +your rights to work written entirely by you; rather, the intent is to + + +exercise the right to control the distribution of derivative or + + +collective works based on the Library. + + + + + +In addition, mere aggregation of another work not based on the Library + + +with the Library (or with a work based on the Library) on a volume of + + +a storage or distribution medium does not bring the other work under + + +the scope of this License. + + + + + + 3. You may opt to apply the terms of the ordinary GNU General Public + + +License instead of this License to a given copy of the Library. To do + + +this, you must alter all the notices that refer to this License, so + + +that they refer to the ordinary GNU General Public License, version 2, + + +instead of to this License. (If a newer version than version 2 of the + + +ordinary GNU General Public License has appeared, then you can specify + + +that version instead if you wish.) Do not make any other change in + + +these notices. + + + + + + Once this change is made in a given copy, it is irreversible for + + +that copy, so the ordinary GNU General Public License applies to all + + +subsequent copies and derivative works made from that copy. + + + + + + This option is useful when you wish to copy part of the code of + + +the Library into a program that is not a library. + + + + + + 4. You may copy and distribute the Library (or a portion or + + +derivative of it, under Section 2) in object code or executable form + + +under the terms of Sections 1 and 2 above provided that you accompany + + +it with the complete corresponding machine-readable source code, which + + +must be distributed under the terms of Sections 1 and 2 above on a + + +medium customarily used for software interchange. + + + + + + If distribution of object code is made by offering access to copy + + +from a designated place, then offering equivalent access to copy the + + +source code from the same place satisfies the requirement to + + +distribute the source code, even though third parties are not + + +compelled to copy the source along with the object code. + + + + + + 5. A program that contains no derivative of any portion of the + + +Library, but is designed to work with the Library by being compiled or + + +linked with it, is called a "work that uses the Library". Such a + + +work, in isolation, is not a derivative work of the Library, and + + +therefore falls outside the scope of this License. + + + + + + However, linking a "work that uses the Library" with the Library + + +creates an executable that is a derivative of the Library (because it + + +contains portions of the Library), rather than a "work that uses the + + +library". The executable is therefore covered by this License. + + +Section 6 states terms for distribution of such executables. + + + + + + When a "work that uses the Library" uses material from a header file + + +that is part of the Library, the object code for the work may be a + + +derivative work of the Library even though the source code is not. + + +Whether this is true is especially significant if the work can be + + +linked without the Library, or if the work is itself a library. The + + +threshold for this to be true is not precisely defined by law. + + + + + + If such an object file uses only numerical parameters, data + + +structure layouts and accessors, and small macros and small inline + + +functions (ten lines or less in length), then the use of the object + + +file is unrestricted, regardless of whether it is legally a derivative + + +work. (Executables containing this object code plus portions of the + + +Library will still fall under Section 6.) + + + + + + Otherwise, if the work is a derivative of the Library, you may + + +distribute the object code for the work under the terms of Section 6. + + +Any executables containing that work also fall under Section 6, + + +whether or not they are linked directly with the Library itself. + + + + + + 6. As an exception to the Sections above, you may also combine or + + +link a "work that uses the Library" with the Library to produce a + + +work containing portions of the Library, and distribute that work + + +under terms of your choice, provided that the terms permit + + +modification of the work for the customer's own use and reverse + + +engineering for debugging such modifications. + + + + + + You must give prominent notice with each copy of the work that the + + +Library is used in it and that the Library and its use are covered by + + +this License. You must supply a copy of this License. If the work + + +during execution displays copyright notices, you must include the + + +copyright notice for the Library among them, as well as a reference + + +directing the user to the copy of this License. Also, you must do one + + +of these things: + + + + + + a) Accompany the work with the complete corresponding + + + machine-readable source code for the Library including whatever + + + changes were used in the work (which must be distributed under + + + Sections 1 and 2 above); and, if the work is an executable linked + + + with the Library, with the complete machine-readable "work that + + + uses the Library", as object code and/or source code, so that the + + + user can modify the Library and then relink to produce a modified + + + executable containing the modified Library. (It is understood + + + that the user who changes the contents of definitions files in the + + + Library will not necessarily be able to recompile the application + + + to use the modified definitions.) + + + + + + b) Use a suitable shared library mechanism for linking with the + + + Library. A suitable mechanism is one that (1) uses at run time a + + + copy of the library already present on the user's computer system, + + + rather than copying library functions into the executable, and (2) + + + will operate properly with a modified version of the library, if + + + the user installs one, as long as the modified version is + + + interface-compatible with the version that the work was made with. + + + + + + c) Accompany the work with a written offer, valid for at + + + least three years, to give the same user the materials + + + specified in Subsection 6a, above, for a charge no more + + + than the cost of performing this distribution. + + + + + + d) If distribution of the work is made by offering access to copy + + + from a designated place, offer equivalent access to copy the above + + + specified materials from the same place. + + + + + + e) Verify that the user has already received a copy of these + + + materials or that you have already sent this user a copy. + + + + + + For an executable, the required form of the "work that uses the + + +Library" must include any data and utility programs needed for + + +reproducing the executable from it. However, as a special exception, + + +the materials to be distributed need not include anything that is + + +normally distributed (in either source or binary form) with the major + + +components (compiler, kernel, and so on) of the operating system on + + +which the executable runs, unless that component itself accompanies + + +the executable. + + + + + + It may happen that this requirement contradicts the license + + +restrictions of other proprietary libraries that do not normally + + +accompany the operating system. Such a contradiction means you cannot + + +use both them and the Library together in an executable that you + + +distribute. + + + + + + 7. You may place library facilities that are a work based on the + + +Library side-by-side in a single library together with other library + + +facilities not covered by this License, and distribute such a combined + + +library, provided that the separate distribution of the work based on + + +the Library and of the other library facilities is otherwise + + +permitted, and provided that you do these two things: + + + + + + a) Accompany the combined library with a copy of the same work + + + based on the Library, uncombined with any other library + + + facilities. This must be distributed under the terms of the + + + Sections above. + + + + + + b) Give prominent notice with the combined library of the fact + + + that part of it is a work based on the Library, and explaining + + + where to find the accompanying uncombined form of the same work. + + + + + + 8. You may not copy, modify, sublicense, link with, or distribute + + +the Library except as expressly provided under this License. Any + + +attempt otherwise to copy, modify, sublicense, link with, or + + +distribute the Library is void, and will automatically terminate your + + +rights under this License. However, parties who have received copies, + + +or rights, from you under this License will not have their licenses + + +terminated so long as such parties remain in full compliance. + + + + + + 9. You are not required to accept this License, since you have not + + +signed it. However, nothing else grants you permission to modify or + + +distribute the Library or its derivative works. These actions are + + +prohibited by law if you do not accept this License. Therefore, by + + +modifying or distributing the Library (or any work based on the + + +Library), you indicate your acceptance of this License to do so, and + + +all its terms and conditions for copying, distributing or modifying + + +the Library or works based on it. + + + + + + 10. Each time you redistribute the Library (or any work based on the + + +Library), the recipient automatically receives a license from the + + +original licensor to copy, distribute, link with or modify the Library + + +subject to these terms and conditions. You may not impose any further + + +restrictions on the recipients' exercise of the rights granted herein. + + +You are not responsible for enforcing compliance by third parties with + + +this License. + + + + + + 11. If, as a consequence of a court judgment or allegation of patent + + +infringement or for any other reason (not limited to patent issues), + + +conditions are imposed on you (whether by court order, agreement or + + +otherwise) that contradict the conditions of this License, they do not + + +excuse you from the conditions of this License. If you cannot + + +distribute so as to satisfy simultaneously your obligations under this + + +License and any other pertinent obligations, then as a consequence you + + +may not distribute the Library at all. For example, if a patent + + +license would not permit royalty-free redistribution of the Library by + + +all those who receive copies directly or indirectly through you, then + + +the only way you could satisfy both it and this License would be to + + +refrain entirely from distribution of the Library. + + + + + +If any portion of this section is held invalid or unenforceable under any + + +particular circumstance, the balance of the section is intended to apply, + + +and the section as a whole is intended to apply in other circumstances. + + + + + +It is not the purpose of this section to induce you to infringe any + + +patents or other property right claims or to contest validity of any + + +such claims; this section has the sole purpose of protecting the + + +integrity of the free software distribution system which is + + +implemented by public license practices. Many people have made + + +generous contributions to the wide range of software distributed + + +through that system in reliance on consistent application of that + + +system; it is up to the author/donor to decide if he or she is willing + + +to distribute software through any other system and a licensee cannot + + +impose that choice. + + + + + +This section is intended to make thoroughly clear what is believed to + + +be a consequence of the rest of this License. + + + + + + 12. If the distribution and/or use of the Library is restricted in + + +certain countries either by patents or by copyrighted interfaces, the + + +original copyright holder who places the Library under this License may add + + +an explicit geographical distribution limitation excluding those countries, + + +so that distribution is permitted only in or among countries not thus + + +excluded. In such case, this License incorporates the limitation as if + + +written in the body of this License. + + + + + + 13. The Free Software Foundation may publish revised and/or new + + +versions of the Lesser General Public License from time to time. + + +Such new versions will be similar in spirit to the present version, + + +but may differ in detail to address new problems or concerns. + + + + + +Each version is given a distinguishing version number. If the Library + + +specifies a version number of this License which applies to it and + + +"any later version", you have the option of following the terms and + + +conditions either of that version or of any later version published by + + +the Free Software Foundation. If the Library does not specify a + + +license version number, you may choose any version ever published by + + +the Free Software Foundation. + + + + + + 14. If you wish to incorporate parts of the Library into other free + + +programs whose distribution conditions are incompatible with these, + + +write to the author to ask for permission. For software which is + + +copyrighted by the Free Software Foundation, write to the Free + + +Software Foundation; we sometimes make exceptions for this. Our + + +decision will be guided by the two goals of preserving the free status + + +of all derivatives of our free software and of promoting the sharing + + +and reuse of software generally. + + + + + + NO WARRANTY + + + + + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO + + +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. + + +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR + + +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY + + +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE + + +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + + +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE + + +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME + + +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + + + + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + + +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY + + +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU + + +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR + + +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE + + +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING + + +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A + + +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF + + +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + + +DAMAGES. + + + + + + END OF TERMS AND CONDITIONS + + + + + + How to Apply These Terms to Your New Libraries + + + + + + If you develop a new library, and you want it to be of the greatest + + +possible use to the public, we recommend making it free software that + + +everyone can redistribute and change. You can do so by permitting + + +redistribution under these terms (or, alternatively, under the terms of the + + +ordinary General Public License). + + + + + + To apply these terms, attach the following notices to the library. It is + + +safest to attach them to the start of each source file to most effectively + + +convey the exclusion of warranty; and each file should have at least the + + +"copyright" line and a pointer to where the full notice is found. + + + + + + + + + Copyright (C) + + + + + + This library is free software; you can redistribute it and/or + + + modify it under the terms of the GNU Lesser General Public + + + License as published by the Free Software Foundation; either + + + version 2.1 of the License, or (at your option) any later version. + + + + + + This library is distributed in the hope that it will be useful, + + + but WITHOUT ANY WARRANTY; without even the implied warranty of + + + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + + + Lesser General Public License for more details. + + + + + + You should have received a copy of the GNU Lesser General Public + + + License along with this library; if not, write to the Free Software + + + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + + + + +Also add information on how to contact you by electronic and paper mail. + + + + + +You should also get your employer (if you work as a programmer) or your + + +school, if any, to sign a "copyright disclaimer" for the library, if + + +necessary. Here is a sample; alter the names: + + + + + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + + + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + + + + + , 1 April 1990 + + + Ty Coon, President of Vice + + + + + +That's all there is to it! + + + + + + + + +Digia Qt LGPL Exception version 1.1 + + + + + +As an additional permission to the GNU Lesser General Public License version + + +2.1, the object code form of a "work that uses the Library" may incorporate + + +material from a header file that is part of the Library. You may distribute + + +such object code under terms of your choice, provided that: + + + (i) the header files of the Library have not been modified; and + + + (ii) the incorporated material is limited to numerical parameters, data + + + structure layouts, accessors, macros, inline functions and + + + templates; and + + + (iii) you comply with the terms of Section 6 of the GNU Lesser General + + + Public License version 2.1. + + + + + +Moreover, you may apply this exception to a modified version of the Library, + + +provided that such modification does not involve copying material from the + + +Library into the modified Library's header files unless such material is + + +limited to (i) numerical parameters; (ii) data structure layouts; + + +(iii) accessors; and (iv) small macros, templates and inline functions of + + +five lines or less in length. + + + + + +Furthermore, you are not required to apply this additional permission to a + + +modified version of the Library. + + diff --git a/resources/misc/MiniZincIDE.desktop b/resources/misc/MiniZincIDE.desktop new file mode 100644 index 0000000..5addd28 --- /dev/null +++ b/resources/misc/MiniZincIDE.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Terminal=false +Exec=minizinc.ide +Name=MiniZincIDE +Icon=$SNAP/meta/gui/icon.png +Categories=Science;Development;Education; diff --git a/resources/misc/README b/resources/misc/README new file mode 100644 index 0000000..76aee6b --- /dev/null +++ b/resources/misc/README @@ -0,0 +1,11 @@ +MiniZinc bundled binary distribution for Linux +============================================== + +This package contains MiniZinc binaries for Ubuntu 16.04. If you want +to run MiniZinc on other versions of Linux that are not compatible +with Ubuntu 16.04, you may have to compile MiniZinc from the source +code which is available at http://www.minizinc.org. + +To run the MiniZinc IDE, just execute MiniZincIDE.sh. + +To use the MiniZinc command line tools, add this directory to your PATH. diff --git a/resources/misc/minizinc.desktop b/resources/misc/minizinc.desktop new file mode 100644 index 0000000..7b5d90c --- /dev/null +++ b/resources/misc/minizinc.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=MiniZincIDE +Exec=minizinc +Icon=minizinc +Type=Application +Categories=Science;Development;Education; +Terminal=false diff --git a/resources/pkg_config/alpine.Dockerfile b/resources/pkg_config/alpine.Dockerfile new file mode 100644 index 0000000..ea981d9 --- /dev/null +++ b/resources/pkg_config/alpine.Dockerfile @@ -0,0 +1,29 @@ +FROM alpine:latest AS composer + +# Install MiniZinc toolchain +COPY minizinc/bin/* /usr/local/bin/ +COPY minizinc/share/minizinc /usr/local/share/minizinc + +# Install vendor solvers +COPY vendor/gecode/bin/fzn-gecode /usr/local/bin/ +COPY vendor/gecode/share/gecode/mznlib /usr/local/share/minizinc/gecode +COPY resources/solvers/gecode.msc /usr/local/share/minizinc/solvers/ + +COPY vendor/chuffed/bin/fzn-chuffed /usr/local/bin/ +COPY vendor/chuffed/share/chuffed/mznlib /usr/local/share/minizinc/chuffed +COPY resources/solvers/chuffed.msc /usr/local/share/minizinc/solvers/ + +# Copy MiniZinc settings files +COPY resources/Preferences.json /usr/local/share/minizinc/ + +# Strip all binaries +RUN apk add --no-cache binutils +RUN cd /usr/local/bin && strip minizinc mzn2doc fzn-chuffed fzn-gecode + +# Generate resulting Docker image +FROM alpine:latest + +RUN apk add --no-cache libstdc++ + +COPY --from=composer /usr/local/bin/* /usr/local/bin/ +COPY --from=composer /usr/local/share/minizinc /usr/local/share/minizinc diff --git a/resources/pkg_config/minizinc-bundle.iss b/resources/pkg_config/minizinc-bundle.iss new file mode 100755 index 0000000..1a1e52c --- /dev/null +++ b/resources/pkg_config/minizinc-bundle.iss @@ -0,0 +1,90 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "MiniZinc IDE" +#define MyAppPublisher "Data61 and Monash University" +#define MyAppURL "http://www.minizinc.org" +#define MyAppExeName "MiniZincIDE.exe" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{80FFFA5B-5C33-442E-8C26-A8CD257EFD97} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +LicenseFile={#MyAppDirectory}\resources\misc\COMBINED_LICENSE.txt +DefaultDirName={pf}\MiniZinc +DefaultGroupName={#MyAppName} +AllowNoIcons=yes +OutputBaseFilename=MiniZincIDE-{#MyAppVersion}-bundled-setup-{#MyAppArch} +Compression=lzma +SolidCompression=yes +ChangesAssociations=yes +ArchitecturesInstallIn64BitMode={#MyApp64Bit} +ArchitecturesAllowed={#MyAppArchitectures} + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "{#MyAppDirectory}\ide\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs + +Source: "{#MyAppDirectory}\vendor\openssl\*.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#MyAppDirectory}\resources\scripts\fzn-gecode-gist.bat"; DestDir: "{app}\bin"; Flags: ignoreversion + +Source: "{#MyAppDirectory}\minizinc\bin\*.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#MyAppDirectory}\minizinc\share\minizinc\*"; DestDir: "{app}\share\minizinc"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "{#MyAppDirectory}\resources\solvers\*.msc"; DestDir: "{app}\share\minizinc\solvers"; Flags: ignoreversion +Source: "{#MyAppDirectory}\resources\Preferences.json"; DestDir: "{app}\share\minizinc"; Flags: ignoreversion + +Source: "{#MyAppDirectory}\vendor\gecode\bin\*"; DestDir: "{app}\bin"; Flags: ignoreversion +Source: "{#MyAppDirectory}\vendor\gecode\share\gecode\mznlib\*"; DestDir: "{app}\share\minizinc\gecode"; Flags: ignoreversion recursesubdirs createallsubdirs + +Source: "{#MyAppDirectory}\vendor\chuffed\bin\fzn-chuffed.exe"; DestDir:"{app}\bin"; Flags: ignoreversion +Source: "{#MyAppDirectory}\vendor\chuffed\share\chuffed\mznlib\*"; DestDir: "{app}\share\minizinc\chuffed"; Flags: ignoreversion recursesubdirs createallsubdirs + +Source: "{#MyAppDirectory}\globalizer\bin\minizinc-globalizer.exe"; DestDir:"{app}\bin"; Flags: ignoreversion +Source: "{#MyAppDirectory}\globalizer\share\globalizer\mznlib\*"; DestDir: "{app}\share\minizinc\globalizer"; Flags: ignoreversion recursesubdirs createallsubdirs + +Source: "{#MyAppDirectory}\findMUS\bin\findMUS.exe"; DestDir:"{app}\bin"; Flags: ignoreversion + +Source: "{#MyMSVCRedist}\*.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#MyUCRTRedist}\*.dll"; DestDir: "{app}"; Flags: ignoreversion +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" +Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon + +[Run] +Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent + +[Registry] +Root: HKCR; Subkey: ".mzp"; ValueType: string; ValueName: ""; ValueData: "MiniZincProjectFile"; Flags: uninsdeletevalue; +Root: HKCR; Subkey: "MiniZincProjectFile"; ValueType: string; ValueName: ""; ValueData: "MiniZinc project"; Flags: uninsdeletevalue; +Root: HKCR; Subkey: "MiniZincProjectFile\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0" +Root: HKCR; Subkey: "MiniZincProjectFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" + +Root: HKCR; Subkey: ".mzn"; ValueType: string; ValueName: ""; ValueData: "MiniZincModelFile"; Flags: uninsdeletevalue; +Root: HKCR; Subkey: "MiniZincModelFile"; ValueType: string; ValueName: ""; ValueData: "MiniZinc model"; Flags: uninsdeletevalue; +Root: HKCR; Subkey: "MiniZincModelFile\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0" +Root: HKCR; Subkey: "MiniZincModelFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" + +Root: HKCR; Subkey: ".dzn"; ValueType: string; ValueName: ""; ValueData: "MiniZincDataFile"; Flags: uninsdeletevalue; +Root: HKCR; Subkey: "MiniZincDataFile"; ValueType: string; ValueName: ""; ValueData: "MiniZinc data"; Flags: uninsdeletevalue; +Root: HKCR; Subkey: "MiniZincDataFile\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0" +Root: HKCR; Subkey: "MiniZincDataFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" + +Root: HKCR; Subkey: ".fzn"; ValueType: string; ValueName: ""; ValueData: "MiniZincFlatZincFile"; Flags: uninsdeletevalue; +Root: HKCR; Subkey: "MiniZincFlatZincFile"; ValueType: string; ValueName: ""; ValueData: "FlatZinc instance"; Flags: uninsdeletevalue; +Root: HKCR; Subkey: "MiniZincFlatZincFile\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0" +Root: HKCR; Subkey: "MiniZincFlatZincFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" diff --git a/resources/pkg_config/snapcraft.yaml b/resources/pkg_config/snapcraft.yaml new file mode 100644 index 0000000..dc6442a --- /dev/null +++ b/resources/pkg_config/snapcraft.yaml @@ -0,0 +1,73 @@ +name: minizinc +version: latest +version-script: cat version.txt +summary: The MiniZinc bundle +icon: resources/icon.png +description: | + MiniZinc is a free and open-source constraint modeling language. You can + use MiniZinc to model constraint satisfaction and optimization problems in + a high-level, solver-independent way, taking advantage of a large library + of pre-defined constraints. Your model is then compiled into FlatZinc, a + solver input language that is understood by a wide range of solvers. + +confinement: classic +base: core18 + +apps: + minizinc: + command: usr/bin/minizinc + ide: + command: bin/desktop-launch $SNAP/usr/bin/MiniZincIDE + desktop: usr/share/applications/MiniZincIDE.desktop + +parts: + ide: + plugin: qmake + source: MiniZincIDE/ + qt-version: qt5 + after: [desktop-qt5] + build-packages: + - qtwebengine5-dev + stage-packages: + - qtwebengine5-dev + organize: + bin/*: usr/bin/ + minizinc: + plugin: dump + source: minizinc/ + organize: + bin/*: usr/bin/ + share/minizinc/*: usr/share/minizinc/ + stage: [usr/] + vendor: + plugin: dump + source: vendor/ + organize: + gecode/bin/fzn-gecode: usr/bin/ + gecode/share/gecode/mznlib: usr/share/minizinc/gecode + chuffed/bin/fzn-chuffed: usr/bin/ + chuffed/share/chuffed/mznlib: usr/share/minizinc/chuffed + stage: [usr/] + globalizer: + plugin: dump + source: globalizer/ + organize: + bin/minizinc-globalizer: usr/bin/ + share/globalizer/mznlib: usr/share/minizinc/globalizer + stage: [usr/] + findmus: + plugin: dump + source: findMUS/ + organize: + bin/findMUS: usr/bin/ + stage: [usr/] + resources: + plugin: dump + source: resources/ + organize: + scripts/fzn-gecode-gist: usr/bin/ + solvers/*.msc: usr/share/minizinc/solvers/ + Preferences.json: usr/share/minizinc/ + misc/MiniZincIDE.desktop: usr/share/applications/ + scripts/MiniZincIDE.sh: usr/ + stage: [usr/] diff --git a/resources/pkg_config/ubuntu.Dockerfile b/resources/pkg_config/ubuntu.Dockerfile new file mode 100644 index 0000000..f16d074 --- /dev/null +++ b/resources/pkg_config/ubuntu.Dockerfile @@ -0,0 +1,27 @@ +FROM ubuntu:latest AS composer + +# Install MiniZinc toolchain +COPY minizinc/bin/* /usr/local/bin/ +COPY minizinc/share/minizinc /usr/local/share/minizinc + +# Install vendor solvers +COPY vendor/gecode/bin/fzn-gecode /usr/local/bin/ +COPY vendor/gecode/share/gecode/mznlib /usr/local/share/minizinc/gecode +COPY resources/solvers/gecode.msc /usr/local/share/minizinc/solvers/ + +COPY vendor/chuffed/bin/fzn-chuffed /usr/local/bin/ +COPY vendor/chuffed/share/chuffed/mznlib /usr/local/share/minizinc/chuffed +COPY resources/solvers/chuffed.msc /usr/local/share/minizinc/solvers/ + +# Copy MiniZinc settings files +COPY resources/Preferences.json /usr/local/share/minizinc/ + +# Strip all binaries +RUN apt-get update -y && apt-get install -y binutils +RUN cd /usr/local/bin && strip minizinc mzn2doc fzn-chuffed fzn-gecode + +# Generate resulting Docker image +FROM ubuntu:latest + +COPY --from=composer /usr/local/bin/* /usr/local/bin/ +COPY --from=composer /usr/local/share/minizinc /usr/local/share/minizinc diff --git a/resources/scripts/AppRun b/resources/scripts/AppRun new file mode 100755 index 0000000..3b0653a --- /dev/null +++ b/resources/scripts/AppRun @@ -0,0 +1,53 @@ +#!/bin/sh + +HERE="$(dirname "$(readlink -f "${0}")")" + +export PATH=$HERE/usr/bin:$PATH +export LD_LIBRARY_PATH=$HERE/usr/lib:$LD_LIBRARY_PATH +export QT_PLUGIN_PATH=$HERE/usr/plugins + +if [ ! -z $APPIMAGE ]; then + BINARY_NAME=$(basename "$ARGV0") + if [ -e "$HERE/usr/bin/$BINARY_NAME" ]; then + exec "$HERE/usr/bin/$BINARY_NAME" "$@" + elif [ "$1" = "install" ]; then + + set -e + if [ -z $BIN_LOCATION ]; then + BIN_LOCATION="/usr/local/bin" + fi + if [ -z $DESKTOP_LOCATION ]; then + DESKTOP_LOCATION="$HOME/.local/share" + fi + echo "Installing minizinc and MiniZincIDE binaries to $BIN_LOCATION (set BIN_LOCATION)." + echo "Installing MiniZinc desktop file and icon in $DESKTOP_LOCATION/{applications,icons} (set DESKTOP_LOCATION)." + echo "Files with the same name may be overwritten." + if [ ! -z $PS1 ] || [ "${NONINTERACTIVE:-0}" -eq "1" ]; then + echo -n "Do you want to continue? [Y/n] " + read answer + if [ "${answer#[Yy]}" != "" ] ;then + exit 1 + fi + fi + + BPERM="" + if [ ! -w "$BIN_LOCATION" ]; then + BPERM="sudo" + fi + eval $BPERM ln -sf $APPIMAGE $BIN_LOCATION/minizinc + eval $BPERM ln -sf $APPIMAGE $BIN_LOCATION/MiniZincIDE + + DPERM="" + if [ ! -w "$DESKTOP_LOCATION" ]; then + DPERM="sudo" + fi + eval $DPERM sed 's/Exec=.*/Exec=MiniZincIDE/g' $HERE/minizinc.desktop > $DESKTOP_LOCATION/applications/MiniZincIDE.desktop + eval $DPERM mkdir -p $DESKTOP_LOCATION/icons/hicolor/256x256/apps + eval $DPERM cp $HERE/minizinc.png $DESKTOP_LOCATION/icons/hicolor/256x256/apps/minizinc.png + + else + exec "$HERE/usr/bin/MiniZincIDE" "$@" + fi +else + exec "$HERE/usr/bin/MiniZincIDE" "$@" +fi diff --git a/resources/scripts/MiniZincIDE.sh b/resources/scripts/MiniZincIDE.sh new file mode 100755 index 0000000..f95f095 --- /dev/null +++ b/resources/scripts/MiniZincIDE.sh @@ -0,0 +1,6 @@ +#!/bin/sh +DIR=$(dirname $(readlink -f "$0")) +[ -n "$XDG_RUNTIME_DIR" ] && mkdir -p $XDG_RUNTIME_DIR -m 700 +export LD_LIBRARY_PATH="$DIR"/lib:$LD_LIBRARY_PATH +export QT_PLUGIN_PATH="$DIR"/plugins +exec "$DIR"/bin/MiniZincIDE $@ diff --git a/resources/scripts/fzn-gecode-gist b/resources/scripts/fzn-gecode-gist new file mode 100755 index 0000000..1413617 --- /dev/null +++ b/resources/scripts/fzn-gecode-gist @@ -0,0 +1,3 @@ +#!/bin/bash +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +exec "$DIR"/fzn-gecode -mode gist "$@" diff --git a/resources/scripts/fzn-gecode-gist.bat b/resources/scripts/fzn-gecode-gist.bat new file mode 100755 index 0000000..e534f62 --- /dev/null +++ b/resources/scripts/fzn-gecode-gist.bat @@ -0,0 +1,3 @@ +@echo off +setlocal +fzn-gecode -mode gist %* diff --git a/resources/solvers/chuffed.msc b/resources/solvers/chuffed.msc new file mode 100644 index 0000000..ede1f37 --- /dev/null +++ b/resources/solvers/chuffed.msc @@ -0,0 +1,53 @@ +{ + "id": "org.chuffed.chuffed", + "name": "Chuffed", + "description": "Chuffed FlatZinc executable", + "version": "0.10.4", + "mznlib": "-Gchuffed", + "executable": "../../../bin/fzn-chuffed", + "tags": ["cp","lcg","int"], + "stdFlags": ["-a","-f","-n","-r","-s","-t","-v"], + "extraFlags": [ + ["--prop-fifo", "Use FIFO queues for propagation", "bool", "false"], + ["--vsids", "Use activity-based search on the Boolean variables", "bool", "false"], + ["--toggle-vsids", "Alternate search between user-specified and activity-based one", "bool", "false"], + ["--restart", "Restart sequence type (chuffed, none, constant, linear, luby, geometric)", "string", "chuffed"], + ["--restart-base", "Base for geometric restart sequence", "float", "1.5"], + ["--restart-scale", "Scale factor for restart sequence", "int", "1000000000"], + ["--switch-to-vsids-after", "Search starts with the user-specified one and switches to the activity-based one after a specified number of conflicts", "int", "1000000000"], + ["--branch-random", "Use random variable selection for tie breaking instead of input order", "bool", "false"], + ["--sat-polarity", "Selection of the polarity of Boolean variables (0 = default, 1 = same, 2 = anti, 3 = random)", "int", "0"], + ["--lazy", "Allow clause generation for domain update", "bool", "true"], + ["--finesse", "Try to generated stronger clauses", "bool", "true"], + ["--learn", "Compute nogoods when a conflict is encountered", "bool", "true"], + ["--eager-limit", "The maximal domain size of eager integer variables", "int", "1000"], + ["--sat-var-limit", "The maximal number of Boolean variables", "int", "2000000"], + ["--n-of-learnts", "The maximal number of learnt clauses", "int", "100000"], + ["--learnts-mlimit", "The maximal memory limit for learnt clauses in Bytes", "int", "500000000"], + ["--sort-learnt-level", "Sort literals in a learnt clause based on their decision level", "bool", "false"], + ["--one-watch", "Watch only one literal in a learn clause", "bool", "true"], + ["--bin-clause-opt", "Optimise learnt clauses of length 2", "bool", "true"], + ["--introduced-heuristic", "Decide if variable is introduced based on its name", "bool", "false"], + ["--use-var-is-introduced", "Decide if variable is introduced based on var_is_introduced annotation", "bool", "false"], + ["--exclude-introduced", "Exclude introduced variables from learnt clauses", "bool", "false"], + ["--decide-introduced", "Allow search decisions on introduced variables and their derived internal variables", "bool", "true"], + ["--fd-simplify", "Remove FD propagators that are satisfied globally", "bool", "true"], + ["--sat-simplify", "Remove of clauses that are satisfied globally", "bool", "true"], + ["--cumu-global", "Use the global cumulative propagator if possible", "bool", "true"], + ["--disj-edge-find", "Use the edge-finding propagator for disjunctive constraints", "bool", "true"], + ["--disj-set-bp", "Use the set bounds propagator for disjunctive constraints", "bool", "true"], + ["--mdd", "Use the MDD propagator if possible", "bool", "false"], + ["--mip", "Use the MIP propagator if possible", "bool", "false"], + ["--mip-branch", "Use MIP branching as the branching strategy", "bool", "false"], + ["--sym-static", "Use static symmetry breaking constraints", "bool", "false"], + ["--ldsb", "Use lightweight dynamic symmetry breaking constraints '1UIP crippled'", "bool", "false"], + ["--ldsbta", "Use lightweight dynamic symmetry breaking constraints '1UIP'", "bool", "false"], + ["--ldsbad", "Use lightweight dynamic symmetry breaking constraints 'all decision clause'", "bool", "false"], + ], + "supportsMzn": false, + "supportsFzn": true, + "needsSolns2Out": true, + "needsMznExecutable": false, + "needsStdlibDir": false, + "isGUIApplication": false +} diff --git a/resources/solvers/findmus.msc b/resources/solvers/findmus.msc new file mode 100644 index 0000000..7ece457 --- /dev/null +++ b/resources/solvers/findmus.msc @@ -0,0 +1,36 @@ +{ + "id": "org.minizinc.findmus", + "name": "findMUS", + "executable": "../../../bin/findMUS", + "isGUIApplication": false, + "mznlib": "", + "supportsMzn": true, + "version": "0.5.0", + "needsSolns2Out": false, + "needsStdlibDir": true, + "needsPathsFile": false, + "needsMznExecutable": false, + "stdFlags": ["--output-html", "-v", "-s", "-a", "-n", "-t"], + "extraFlags": [ + ["--paramset", "Preset parameters", "opt:hint:mzn:fzn", "hint"], + ["--solver", "Which solver to use for SAT checking", "string", "gecode"], + ["--structure", "Alter initial structure", "opt:flat:gen:normal:mix:idx:idxmix", "gen"], + ["--no-binarize", "Disable binarization", "bool", "false"], + ["--shrink-alg", "Select MUS shrink algorithm", "opt:lin:map_lin:qx:map_qx", "map_qx"], + ["--depth", "Abstraction level of MUSes", "opt:mzn:fzn:1:5:25:100", "mzn"], + ["--output-brief", "Do not output traces.", "bool", "false"], + ["--restart", "Enable restart to leaves behaviour", "bool", "false"], + ["--output-json", "Print MUSes in JSON format", "bool", "false"], + ["--verbose", "Verbose output", "bool", "false"], + ["--verbose-subsolve", "Verbosity level for subsolving", "int:0:1", "0"], + ["--verbose-enum", "Verbosity level for enumeration", "int:0:1", "0"], + ["--verbose-map", "Verbosity level for map calls", "int:0:1", "0"], + ["--stdlib-dir", "Location of MiniZinc stdlib directory.", "string", ""], + ["--no-progress", "Disable mzn-progress output for IDE", "bool", "false"], + ["--filter-path", "Filter constraints based on comma separated substrings of path", "string", ""], + ["--filter-name", "Filter constraints based on comma separated substrings of expression and constraint names", "string", ""], + ["--dump-dot", "Write tree to GraphViz file", "string", ""], + ["--soft-defines", "Consider functional constraints as part of MUSes.", "bool", "false"], + ["--help", "Extra help information", "bool", "false"], + ] +} diff --git a/resources/solvers/gecode-gist.msc b/resources/solvers/gecode-gist.msc new file mode 100644 index 0000000..85c8fe7 --- /dev/null +++ b/resources/solvers/gecode-gist.msc @@ -0,0 +1,28 @@ +{ + "id": "org.gecode.gist", + "name": "Gecode Gist", + "description": "Gecode Gist FlatZinc executable", + "version": "6.1.1", + "mznlib": "-Ggecode", + "executable": "../../../bin/fzn-gecode-gist", + "tags": ["cp","int", "float", "set", "restart"], + "stdFlags": ["-a","-n","-s","-p","-r","-f"], + "extraFlags": [ + ["-c-d", "Recomputation commit distance", "int", "8"], + ["-a-d", "Recomputation adaption distance", "int", "2"], + ["-decay", "Decay factor", "float", "0.99"], + ["-node", "Node cutoff", "int", "0"], + ["-fail", "Failure cutoff", "int", "0"], + ["-restart", "Restart sequence type (none, constant, linear, luby, geometric)", "string", "none"], + ["-restart-base", "Base for geometric restart sequence", "float", "1.5"], + ["-restart-scale", "Scale factor for restart sequence", "int", "250"], + ["-nogoods", "Use no-goods from restarts", "bool", "false"], + ["-nogoods-limit", "Depth limit for no-good extraction", "int", "128"], + ], + "supportsMzn": false, + "supportsFzn": true, + "needsSolns2Out": true, + "needsMznExecutable": false, + "needsStdlibDir": false, + "isGUIApplication": true +} diff --git a/resources/solvers/gecode.msc b/resources/solvers/gecode.msc new file mode 100644 index 0000000..7b06c42 --- /dev/null +++ b/resources/solvers/gecode.msc @@ -0,0 +1,28 @@ +{ + "id": "org.gecode.gecode", + "name": "Gecode", + "description": "Gecode FlatZinc executable", + "version": "6.1.1", + "mznlib": "-Ggecode", + "executable": "../../../bin/fzn-gecode", + "tags": ["cp","int", "float", "set", "restart"], + "stdFlags": ["-a","-f","-n","-p","-r","-s","-t"], + "extraFlags": [ + ["-c-d", "Recomputation commit distance", "int", "8"], + ["-a-d", "Recomputation adaption distance", "int", "2"], + ["-decay", "Decay factor", "float", "0.99"], + ["-node", "Node cutoff", "int", "0"], + ["-fail", "Failure cutoff", "int", "0"], + ["-restart", "Restart sequence type (none, constant, linear, luby, geometric)", "string", "none"], + ["-restart-base", "Base for geometric restart sequence", "float", "1.5"], + ["-restart-scale", "Scale factor for restart sequence", "int", "250"], + ["-nogoods", "Use no-goods from restarts", "bool", "false"], + ["-nogoods-limit", "Depth limit for no-good extraction", "int", "128"], + ], + "supportsMzn": false, + "supportsFzn": true, + "needsSolns2Out": true, + "needsMznExecutable": false, + "needsStdlibDir": false, + "isGUIApplication": false +} diff --git a/resources/solvers/globalizer.msc b/resources/solvers/globalizer.msc new file mode 100644 index 0000000..54b8100 --- /dev/null +++ b/resources/solvers/globalizer.msc @@ -0,0 +1,30 @@ +{ + "executable": "../../../bin/minizinc-globalizer", + "id": "org.minizinc.globalizer", + "isGUIApplication": false, + "mznlib": "-Gglobalizer", + "name": "Globalizer", + "supportsMzn": true, + "version": "0.1.6.0", + "needsStdlibDir": false, + "needsMznExecutable": true, + "stdFlags": ["--output-html", "-v", "-p"], + "tags": ["experimental", "tool"], + "extraFlags": [ + ["--maxConstraints", "Max constraints per set (2)", "int"], + ["--randomSolutions", "Number of solutions for submodel (30)", "int"], + ["--sampleSolutions", "Number of solutions for scoring (30)", "int"], + ["--solvingTimeout", "Solver timeout 1000(ms)", "int"], + ["--constraintfilter", "Consider only these comma separated substrings", "string"], + ["--no-initial-pass", "Don't check for channeling opportunities", "bool"], + ["--free-search", "Don't use random heuristics", "bool"] + ["--debug-args", "Debugging info for argument generation", "bool"], + ["--debug-constraints", "Debugging info for constraint checking", "bool"], + ["--debug-scoring", "Debugging info for constraint scoring", "bool"], + ["--debug-checking", "Debugging info for constraint checking", "bool"], + ["--debug-norm", "Debuginging info for model normalization", "bool"], + ["--debug-solving", "Debugging info for model solving", "bool"], + ["--debug-model", "Debugging info for group models", "bool"], + ["--debug-high", "Debugging info for high-level progress", "bool"], + ] +}