From: Sven Hoexter Date: Mon, 11 Aug 2025 12:37:13 +0000 (+0200) Subject: New upstream version 2.9.588 X-Git-Tag: upstream/2.9.588 X-Git-Url: https://git.sven.stormbind.net/?a=commitdiff_plain;h=7ebb26827c20afad84d0abf2811993ebb92a81b8;p=sven%2Fvym.git New upstream version 2.9.588 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f5453b..800e4e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -project(ViewYourMind-develop LANGUAGES CXX) +project(vym LANGUAGES CXX) # See also https://doc.qt.io/qt-6.5/cmake-get-started.html @@ -137,6 +137,14 @@ message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}") message(STATUS "ts_files: ${ts_files}") message(STATUS "qm_files: ${qm_files}") +# Collection of files for later installation +file(GLOB vymDemos RELATIVE ${CMAKE_SOURCE_DIR} "demos/*.*") +file(GLOB vymMacros RELATIVE ${CMAKE_SOURCE_DIR} "macros/*.vys") +file(GLOB vymScripts RELATIVE ${CMAKE_SOURCE_DIR} "demos/scripts/*.*") +message(STATUS " vymDemos: ${vymDemos}") +message(STATUS " vymMacros: ${vymMacros}") +message(STATUS "vymScripts: ${vymScripts}") + ADD_COMPILE_DEFINITIONS(VYMBASEDIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}") add_executable(vym ${VymSources} vym.qrc ${qm_files}) @@ -151,18 +159,42 @@ endif() if(APPLE) message(STATUS "Detected APPLE") - set_target_properties(vym PROPERTIES MACOSX_BUNDLE TRUE ) - # Add property to Info.plist - set(MACOSX_BUNDLE_ICON_FILE vym.icns) + set(MACOSX_BUNDLE_EXECUTABLE_NAME ${PROJECT_NAME}) + + # Prepare Info.plist + set_target_properties(${PROJECT_NAME} PROPERTIES + MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}" + MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_GUI_IDENTIFIER "org.insilmaril.vym" + MACOSX_BUNDLE_ICON_FILE "vym.icns" + MACOSX_BUNDLE TRUE + ) + + set(vymIconMac ${CMAKE_CURRENT_SOURCE_DIR}/icons/vym.icns) + target_sources(vym PRIVATE ${vymIconMac}) + set_source_files_properties(${vymIconMac} PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources") - # tell CMake where to find and install the file itself - set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/icons/vym.icns) - set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES - MACOSX_PACKAGE_LOCATION "Resources") + target_sources(vym PRIVATE ${vymDemos}) + set_source_files_properties(${vymDemos} PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources/demos" + ) + target_sources(vym PRIVATE ${vymScripts}) + set_source_files_properties(${vymScripts} PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources/demos/scripts" + ) + + target_sources(vym PRIVATE ${vymMacros}) + set_source_files_properties(${vymMacros} PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources/macros" + ) + #add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + # COMMAND codesign -f -s - "${CMAKE_CURRENT_SOURC_DIR}/${PROJECT_NAME}.app" + # COMMENT "Signing the .app bundle" + #) -#FIXME-0 add_executable(vym MACOSX_BUNDLE main.cpp ${APP_ICON_MACOSX}) -target_sources(vym PUBLIC ${APP_ICON_MACOSX}) endif() add_custom_target(make-translations-directory ALL diff --git a/README.md b/README.md index a7d60f2..e3b6b10 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ priorities or reminds you after easily defined time spans. You can use the scripting capabilities for interesting presentations. VYM can also retrieve data from the Jira issue tracking system and -talk to the Concluence documentation system. +talk to the Confluence documentation system. VYM runs on Apple and Windows and of course most Linux platforms. diff --git a/demos/scripts/confluence-delete-labels.vys b/demos/scripts/confluence-delete-labels.vys index b6ae558..8f0edcc 100644 --- a/demos/scripts/confluence-delete-labels.vys +++ b/demos/scripts/confluence-delete-labels.vys @@ -1,16 +1,15 @@ vym.clearConsole(); map = vym.currentMap(); -map.newBranchIterator("it"); -b = map.nextBranch("it"); -vym.print ("Starting with branch: " + b.getHeading() ); +il = map.itemList(); +il.setModeSelectedSubtrees(); label = "deletion_candidate"; dc_count = 0; total_count = 0; -while (b) +while (b = il.nextBranch()) { total_count++; @@ -33,7 +32,6 @@ while (b) } } } - b = map.nextBranch("it"); } vym.print("Triggered removal of " + dc_count + " '" + label + "' labels in " + total_count + " pages"); \ No newline at end of file diff --git a/demos/scripts/confluence-find-labels.vys b/demos/scripts/confluence-find-labels.vys index 670a31a..0fe2eb5 100644 --- a/demos/scripts/confluence-find-labels.vys +++ b/demos/scripts/confluence-find-labels.vys @@ -1,16 +1,15 @@ vym.clearConsole(); map = vym.currentMap(); -map.newBranchIterator("it"); -b = map.nextBranch("it"); -vym.print ("Starting with branch: " + b.getHeading() ); +il = map.itemList(); +il.setModeSelectedSubtrees(); label = "deletion_candidate"; dc_count = 0; total_count = 0; -while (b) +while (b = il.nextBranch()) { total_count++; @@ -31,7 +30,6 @@ while (b) } } } - b = map.nextBranch("it"); } vym.print(dc_count + " deletion_candidate labels found in " + total_count + " pages"); \ No newline at end of file diff --git a/demos/scripts/examplescript.vys b/demos/scripts/examplescript.vys index 65790f5..3b338ba 100644 --- a/demos/scripts/examplescript.vys +++ b/demos/scripts/examplescript.vys @@ -1,16 +1,18 @@ //Example function definition + function foofunction(s) { - print ("Foofunction output: " + s); + vym.print ("Foofunction output: " + s); s = "changed par"; return {a: "ret-value", b: "bla"}; } par = "I am a parameter!"; -print (foofunction(par)); -print ("par is now: " + par); +vym.print (foofunction(par)); +vym.print ("par is now: " + par); //abort("xxx"); -print ("bar"); +vym.print ("bar"); -m=vym.currentMap(); -m.setHeadingPlainText("foobar"); -print( m.getHeadingPlainText()); \ No newline at end of file +map = vym.currentMap(); +branch = map.selectedBranch(); +branch.setHeadingText("foobar"); +vym.print( branch.headingText()); \ No newline at end of file diff --git a/demos/scripts/iterating-branches.vys b/demos/scripts/iterating-branches.vys index ff31fd5..38ed2cd 100644 --- a/demos/scripts/iterating-branches.vys +++ b/demos/scripts/iterating-branches.vys @@ -1,11 +1,39 @@ vym.clearConsole(); map = vym.currentMap(); -map.newBranchIterator("foobar"); -b = map.nextBranch("foobar"); -vym.print ("Starting with branch: " + b.headingText() ); +il = map.itemList(); +il.setModeBranches(); -while (map.nextBranch("foobar") ) +vym.print("Iterate over complete map (" + il.count() + " items)"); +while (b = il.nextBranch() ) { - vym.print ("Current branch: " + map.headingText() ); + vym.print (" - Current branch: " + b.headingText() ); } + +il.setModeBranches(true); +vym.print("Iterate over complete map, deep levels first (" + il.count() + " items)"); +while (b = il.nextBranch() ) +{ + vym.print (" - Current branch: " + b.headingText() ); +} + +il.setModeSelectedSubtrees(); +vym.print("Iterate over selected subtrees (" + il.count() + " items)"); +while (b = il.nextBranch() ) +{ + vym.print (" - Current branch: " + b.headingText() ); +} + +il.setModeSelectedSubtrees(true); +vym.print("Iterate over selected subtrees, deep levels first (" + il.count() + " items)"); +while (b = il.nextBranch() ) +{ + vym.print (" - Current branch: " + b.headingText() ); +} + +il.setModeSelectedBranches(); +vym.print("Iterate over selected branches without subtrees (" + il.count() + " items)"); +while (b = il.nextBranch() ) +{ + vym.print (" - Current branch: " + b.headingText() ); +} \ No newline at end of file diff --git a/flags/standard/help-content.svg b/flags/standard/help-content.svg new file mode 100644 index 0000000..8e582bc --- /dev/null +++ b/flags/standard/help-content.svg @@ -0,0 +1,334 @@ + + + + + + + image/svg+xml + + + 2005-03-10 + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + help + browser + documentation + docs + man + info + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flags/standard/help-contextual.svg b/flags/standard/help-contextual.svg deleted file mode 100644 index 09865e0..0000000 --- a/flags/standard/help-contextual.svg +++ /dev/null @@ -1,5817 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/macros/macros.vys b/macros/macros.vys index f60b1d7..f976638 100644 --- a/macros/macros.vys +++ b/macros/macros.vys @@ -269,54 +269,18 @@ function macro_shift_f9() } //! Macro Shift + F10: -// Useful for timestamps created on last entry function macro_shift_f10() { } -//! Macro Shift + F11: Replace "@..." by mutt aliases +//! Macro Shift + F11: function macro_shift_f11() { - map = vym.currentMap(); - lines = vym.loadFile("/home/uwe/.mutt/eb-aliases").split('\n'); - - - if (map.getHeadingPlainText() == "parts") { - map.setHeadingPlainText("Participants"); - } - - map.initIterator("foobar"); - - while (map.nextIterator("foobar") ) { - heading = map.getHeadingPlainText(); - - // Search for "@alias" at beginning of heading - if (heading.search(/^@\w/) == 0) { - alias_map = heading.replace(/@/,""); - - for(var i = 0;i < lines.length;i++){ - if (lines[i].search(/^alias/) == 0) { - if (lines[i].search(alias_map) == 6) { - name = lines[i].replace(/^.+?\"/, ""); - name = name.replace(/\".+/, ""); - - email = lines[i].replace(/^.+?.*/, ""); - - map.setHeadingPlainText(name); - } - } - } - } else { - print ("No alias found"); - } - } } //! Macro Shift + F12: function macro_shift_f12() { - vym.statusMessage("Macro F12 + Shift triggered"); } @@ -342,11 +306,11 @@ function macro_ctrl_f2() map = vym.currentMap(); b = map.selectedBranch(); status = "Subtree background off"; - if (b.getFrameType(true) == "NoFrame") { + if (b.getFrameType(false) == "NoFrame") { status = "Subtree background light green"; } - toggle_frame_branch ( map ); - b.setFrameBrushColor(true, "#bdffd6"); + toggle_frame_subtree ( map ); + b.setFrameBrushColor(false, "#bdffd6"); vym.statusMessage(status); } @@ -356,11 +320,11 @@ function macro_ctrl_f3() map = vym.currentMap(); b = map.selectedBranch(); status = "Subtree background off"; - if (b.getFrameType(true) == "NoFrame") { + if (b.getFrameType(false) == "NoFrame") { status = "SUbtree background light yellow"; } - toggle_frame_branch ( map ); - b.setFrameBrushColor(true, "#efefb3"); + toggle_frame_subtree ( map ); + b.setFrameBrushColor(false, "#efefb3"); vym.statusMessage(status); } @@ -370,11 +334,11 @@ function macro_ctrl_f4() map = vym.currentMap(); b = map.selectedBranch(); status = "Subtree background off"; - if (b.getFrameType(true) == "NoFrame") { - status = "SUbtree background light yellow"; + if (b.getFrameType(false) == "NoFrame") { + status = "Subtree background light bluex"; } - toggle_frame_branch ( map ); - b.setFrameBrushColor(true, "#efefb3"); + toggle_frame_subtree ( map ); + b.setFrameBrushColor(false, "#e2e6ff"); vym.statusMessage(status); } @@ -384,11 +348,11 @@ function macro_ctrl_f5() map = vym.currentMap(); b = map.selectedBranch(); status = "Subtree background off"; - if (b.getType(true) == "NoFrame") { + if (b.getFrameType(false) == "NoFrame") { status = "Subtree background light grey"; } - toggle_frame_branch ( map ); - b.setFrameBrushColor(true, "#d6d6d6"); + toggle_frame_subtree ( map ); + b.setFrameBrushColor(false, "#d6d6d6"); vym.statusMessage(status); } @@ -398,11 +362,11 @@ function macro_ctrl_f6() map = vym.currentMap(); b = map.selectedBranch(); status = "Subtree background off"; - if (b.getFrameType(true) == "NoFrame") { + if (b.getFrameType(false) == "NoFrame") { status = "Subtree background purple"; } - toggle_frame_branch ( map ); - b.setFrameBrushColor(true, "#ffaaff"); + toggle_frame_subtree ( map ); + b.setFrameBrushColor(false, "#ffaaff"); vym.statusMessage(status); } @@ -412,11 +376,11 @@ function macro_ctrl_f7() map = vym.currentMap(); b = map.selectedBranch(); status = "Subtree background off"; - if (b.getFrameType() == "NoFrame") { + if (b.getFrameType(false) == "NoFrame") { status = "Subtree background white"; } - toggle_frame_branch ( map ); - b.setFrameBrushColor("#ffffff"); + toggle_frame_subtree ( map ); + b.setFrameBrushColor(false, "#ffffff"); vym.statusMessage(status); } @@ -426,11 +390,11 @@ function macro_ctrl_f8() map = vym.currentMap(); b = map.selectedBranch(); status = "Subtree background off"; - if (b.getFrameType(true) == "NoFrame") { + if (b.getFrameType(false) == "NoFrame") { status = "Subtree background black"; } - toggle_frame_branch ( map ); - b.setFrameBrushColor(true, "#000000"); + toggle_frame_subtree ( map ); + b.setFrameBrushColor(false, "#000000"); vym.statusMessage(status); } diff --git a/src/branch-container.cpp b/src/branch-container.cpp index 9f3e912..ccc99b3 100644 --- a/src/branch-container.cpp +++ b/src/branch-container.cpp @@ -657,12 +657,11 @@ LinkContainer *BranchContainer::getLinkContainer() { return linkContainer; } void BranchContainer::linkTo(BranchContainer *pbc) { + originalParentBranchContainer = nullptr; if (!pbc) return; - originalParentBranchContainer = nullptr; - pbc->linkContainer->addLink(upLink); } @@ -805,10 +804,9 @@ void BranchContainer::updateUpLink() BranchContainer *pbc = nullptr; - if (tmpLinkedParentContainer) { + if (tmpLinkedParentContainer) // I am temporarily linked to tmpLinkedParentContainer pbc = tmpLinkedParentContainer; - } else if (originalParentBranchContainer) // I am moving with tmpParent, use original parent for link pbc = originalParentBranchContainer; @@ -862,7 +860,7 @@ void BranchContainer::updateUpLink() upLink->setLinkStyle(LinkObj::NoLink); else { upLink->setLinkStyle( - tmpParentBI->mapDesign()->linkStyle(tmpParentBI->depth())); + branchItem->mapDesign()->linkStyle(branchItem->depth())); } } @@ -1415,7 +1413,9 @@ void BranchContainer::reposition() // on MovingState if (pbc) { if (pbc->hasFloatingBranchesLayout()) { - if (pos().x() > 0) + if (scenePos().x() > pbc->scenePos().x()) // FIXME-2 problematic for rotated elements... + // but OTOH using relative coord + // often pos.x() == 0 orientation = RightOfParent; else orientation = LeftOfParent; diff --git a/src/branchitem.cpp b/src/branchitem.cpp index a518573..797bd83 100644 --- a/src/branchitem.cpp +++ b/src/branchitem.cpp @@ -491,6 +491,8 @@ BranchContainer *BranchItem::createBranchContainer(QGraphicsScene *scene) BranchContainer* BranchItem::getBranchContainer() { + if (this == rootItem && branchContainer) + qWarning() << __func__ << "rootItem should not have BranchCOntainer"; return branchContainer; } diff --git a/src/command.cpp b/src/command.cpp index 31d3ee5..374514f 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -5,7 +5,7 @@ Command::Command(const QString &n, SelectionType st, ParameterType retType) // F { nameInt = n; selectionTypeInt = st; - returnType = retType; + returnTypeInt = retType; } QString Command::name() { return nameInt; } @@ -18,7 +18,7 @@ QString Command::description() s += QString(" Comment: %1\n").arg(commentInt); if (objectTypeInt == MapObject) s += QString(" SelectionType: %1\n").arg(selectionTypeName()); - s += QString(" Return type: %1\n").arg(typeToString(returnType)); + s += QString(" Return type: %1\n").arg(typeToString(returnTypeInt)); s += QString(" Parameters: %1\n").arg(parameterCount()); // s+=QString(" Parameters: %1\n").arg(parameterCount() ); for (int i = 0; i < parameterCount(); i++) { @@ -38,7 +38,7 @@ QString Command::descriptionLaTeX() s += "\\begin{tabular}{rl}\n"; s += QString(" Comment: & %1\\\\\n").arg(commentInt); s += QString(" SelectionType: & %1\\\\\n").arg(selectionTypeName()); - s += QString(" Return Type: & %1\\\\\n").arg(typeToString(returnType)); + s += QString(" Return Type: & %1\\\\\n").arg(typeToString(returnTypeInt)); s += QString(" Parameters: & %1\\\\\n").arg(parameterCount()); for (int i = 0; i < parameterCount(); i++) { @@ -159,7 +159,7 @@ QString Command::objectTypeName() { } } -void Command::setComment(const QString &s) { +void Command::setComment(const QString &s) { commentInt = s; } @@ -167,3 +167,12 @@ QString Command::comment() { return commentInt; } +void Command::setReturnType(const ParameterType &type) +{ + returnTypeInt = type; +} + +Command::ParameterType Command::returnType() +{ + return returnTypeInt; +} diff --git a/src/command.h b/src/command.h index c9a8978..e5deebf 100644 --- a/src/command.h +++ b/src/command.h @@ -11,6 +11,7 @@ class Command { MapObject, BranchObject, ImageObject, + ItemListObject, XLinkObject }; enum ParameterType { @@ -21,6 +22,7 @@ class Command { ColorPar, DoublePar, ImagePar, + ItemListPar, IntPar, StringPar, StringListPar, @@ -54,13 +56,15 @@ class Command { QString objectTypeName(); void setComment(const QString&); QString comment(); + void setReturnType(const ParameterType &type); + ParameterType returnType(); private: QString nameInt; QString commentInt; SelectionType selectionTypeInt; QList parTypes; - ParameterType returnType; + ParameterType returnTypeInt; ObjectType objectTypeInt; QList parOpts; QStringList parComments; diff --git a/src/container.cpp b/src/container.cpp index 3cef802..700aa4b 100644 --- a/src/container.cpp +++ b/src/container.cpp @@ -751,11 +751,13 @@ void Container::reposition() // - I am in a floating layout or // - I am a MapCenter myself if ((parentContainer() && parentContainer()->hasFloatingLayout()) || !parentContainer() ) { - v_central = mapFromItem(centralContainer, centralContainer->rect().center()); - if (!v_central.isNull()) - foreach (Container *c, childContainers()) - if (!c->overlay) - c->setPos(c->pos() - v_central); + v_central = mapFromItem(centralContainer, centralContainer->rect().center()); + if (!v_central.isNull()) { + foreach (Container *c, childContainers()) { + if (!c->overlay) + c->setPos(c->pos() - v_central); + } + } } } diff --git a/src/export-html.cpp b/src/export-html.cpp index 5697327..e6c95c4 100644 --- a/src/export-html.cpp +++ b/src/export-html.cpp @@ -46,7 +46,7 @@ QString ExportHTML::getBranchText(BranchItem *current) if (dia.useTextColor) col = QString("style='color:%1'") .arg(current->headingColor().name()); - QString s = QString("") + QString s = QString("
") .arg(current->depth()) .arg(col) .arg(id); @@ -60,10 +60,9 @@ QString ExportHTML::getBranchText(BranchItem *current) if (task) { QString taskName = task->getIconString(); taskFlags += - QString("\"%2\"") + QString("\"%2\"") .arg(taskName) - .arg(QObject::tr("Flag: %1", "Alt tag in HTML export") - .arg(taskName)); + .arg(QObject::tr("Flag: %1", "Alt tag in HTML export").arg(taskName)); } } @@ -81,12 +80,9 @@ QString ExportHTML::getBranchText(BranchItem *current) if (f) flags += QString( - "\"%1\"") - .arg(QObject::tr("Flag: %1", - "Alt tag in HTML export") - .arg(f->getName())) - .arg(uid.toString() + - f->getImageContainer()->getExtension()); + "\"%1\"") + .arg(QObject::tr("Flag: %1", "Alt tag in HTML export").arg(f->getName())) + .arg(f->getImageContainer()->originalFilename()); } } @@ -97,7 +93,7 @@ QString ExportHTML::getBranchText(BranchItem *current) // URL if (!url.isEmpty()) { - s += QString("%2%2") .arg(url) .arg(number + taskFlags + heading + flags) @@ -117,7 +113,7 @@ QString ExportHTML::getBranchText(BranchItem *current) else s += number + taskFlags + heading + flags; - s += ""; + s += "
"; // Create imagemap if (vis && dia.includeMapImage) // FIXME-3 maybe use polygons instead of QRectF for shapes @@ -143,7 +139,7 @@ QString ExportHTML::getBranchText(BranchItem *current) s += "
\""getOriginalFilename()); + .arg(image->originalFilename()); s += "\">
"; } } @@ -289,7 +285,7 @@ QString ExportHTML::createTOC() return toc; } -void ExportHTML::doExport(bool useDialog) +void ExportHTML::doExport(bool useDialog) // FIXME-2 System flags not written. (URL, task, scrolled, ...) { // Setup dialog and read settings dia.setMapName(model->getMapName()); @@ -442,10 +438,9 @@ void ExportHTML::doExport(bool useDialog) f = userFlagsMaster->findFlagByUid(uid); if (f) { - ImageContainer *io = f->getImageContainer(); - if (io) - io->save(flagsBasePath + "/" + uid.toString() + - io->getExtension()); + ImageContainer *ic = f->getImageContainer(); + if (ic) + ic->save(flagsBasePath + "/" + ic->originalFilename()); } } diff --git a/src/file.cpp b/src/file.cpp index c8f22d3..bd36d93 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -4,21 +4,19 @@ #include #include #include +#include #include #include "file.h" -#if defined(Q_OS_WINDOWS) -#include "mkdtemp.h" -#include -#endif - #if defined(Q_OS_MACOS) #include "unistd.h" #endif extern QString vymName; extern QDir lastImageDir; +extern QDir vymUserDir; +extern QDir tmpVymDir; QString convertToRel(const QString &src, const QString &dst) { @@ -114,52 +112,25 @@ bool confirmDirectoryOverwrite(const QDir &dir) QString makeTmpDir(bool &ok, const QString &dirPath, const QString &prefix) { - QString path = makeUniqueDir(ok, dirPath + "/" + prefix + "-XXXXXX"); - return path; + QTemporaryDir tmpDir(dirPath + "/" + prefix + "-XXXXXX"); + tmpDir.setAutoRemove(false); + ok = tmpDir.isValid(); + return tmpDir.path(); } QString makeTmpDir(bool &ok, const QString &prefix) { - return makeTmpDir(ok, QDir::tempPath(), prefix); + + return makeTmpDir(ok, vymUserDir.path(), prefix); } bool isInTmpDir(QString fn) { - QString temp = QDir::tempPath(); + QString temp = tmpVymDir.path(); int l = temp.length(); return fn.left(l) == temp; } -QString makeUniqueDir(bool &ok, QString s) // FIXME-4 use QTemporaryDir -{ - ok = true; - - QString r; - -#if defined(Q_OS_WINDOWS) - r = mkdtemp(s); -#else - // On Linux and friends use cstdlib - - // Convert QString to string - ok = true; - char *p; - int bytes = s.length(); - p = (char *)malloc(bytes + 1); - int i; - for (i = 0; i < bytes; i++) - p[i] = s.at(i).unicode(); - p[bytes] = 0; - - r = mkdtemp(p); - free(p); -#endif - - if (r.isEmpty()) - ok = false; - return r; -} - bool removeDir(QDir d) { // This check should_ not be necessary, but proved to be useful ;-) @@ -169,6 +140,7 @@ bool removeDir(QDir d) return false; } + //qDebug() << __func__ << d.path(); return d.removeRecursively(); } diff --git a/src/file.h b/src/file.h index 43dbe11..a8380cd 100644 --- a/src/file.h +++ b/src/file.h @@ -22,7 +22,6 @@ bool confirmDirectoryOverwrite(const QDir &dir); QString makeTmpDir(bool &ok, const QString &dirPath, const QString &prefix); QString makeTmpDir(bool &ok, const QString &prefix); bool isInTmpDir(QString fn); -QString makeUniqueDir(bool &ok, QString); bool removeDir(QDir); bool copyDir(QDir src, QDir dst, const bool &override = false); bool subDirsExist(); diff --git a/src/flag.cpp b/src/flag.cpp index 4e1b407..246bea1 100644 --- a/src/flag.cpp +++ b/src/flag.cpp @@ -118,7 +118,7 @@ QString Flag::getDefinition(const QString &prefix) { if (type == Flag::UserFlag) { QString url = "flags/" + prefix + uuid.toString() + "-" + name + - imageContainer->getExtension(); + imageContainer->extension(); QStringList attributes; attributes << attribute("name", name); attributes << attribute("href", QString("file:%1").arg(url)); @@ -133,7 +133,7 @@ void Flag::saveDataToDir(const QString &dirPath) { if (imageContainer) { path = dirPath + "/" + uuid.toString() + "-" + name + - imageContainer->getExtension(); + imageContainer->extension(); imageContainer->save(path); } } diff --git a/src/flagrow-container.cpp b/src/flagrow-container.cpp index d93230f..477548e 100644 --- a/src/flagrow-container.cpp +++ b/src/flagrow-container.cpp @@ -70,7 +70,7 @@ void FlagRowContainer::activateFlag(Flag *flag) // qDebug() << "FRC::activateFlag visible="<< visible << " Qtvis=" << isVisible(); // Loading an image will *copy* it - // and thus read the flag from cash + // and will create a shared renderer fc->copy(flag->getImageContainer()); fc->setUuid(flag->getUuid()); fc->setZValue(QGraphicsItem::zValue()); diff --git a/src/image-container.cpp b/src/image-container.cpp index f8fad77..ca58c5e 100644 --- a/src/image-container.cpp +++ b/src/image-container.cpp @@ -28,8 +28,17 @@ ImageContainer::~ImageContainer() if (imageItem) imageItem->unlinkImageContainer(); } +QSvgRenderer* ImageContainer::svgRenderer() +{ + if (svgItem) + return svgItem->renderer(); + else + return nullptr; +} + void ImageContainer::copy(ImageContainer *other) { + //qDebug() << "IC::copy"; prepareGeometryChange(); if (imageType != ImageContainer::Undefined) qWarning() << "ImageContainer::copy into existing image of type " @@ -39,14 +48,19 @@ void ImageContainer::copy(ImageContainer *other) case ImageContainer::SVG: case ImageContainer::ClonedSVG: if (!other->svgCachePath.isEmpty()) { - // Loading here will also set imageType - load(other->svgCachePath, true); + //qDebug() << __func__ << "copying from " << other->svgCachePath; + svgItem = new QGraphicsSvgItem(this); + svgItem->setSharedRenderer(other->svgRenderer()); + imageType = ImageContainer::ClonedSVG; + QRectF r = svgItem->boundingRect(); + + // Center svg + svgItem->setPos( -r.width() / 2, - r.height() / 2); + setRect(mapFromItem(svgItem, svgItem->boundingRect()).boundingRect()); } else qWarning() << "ImgObj::copy svg: no svgCachePath available."; - svgItem->setParentItem(this); - setRect(other->rect()); break; case ImageContainer::Pixmap: { pixmapItem = new QGraphicsPixmapItem(); @@ -70,6 +84,8 @@ void ImageContainer::init() { containerType = Image; + originalFilenameInt = ""; + imageItem = nullptr; selectionContainer = nullptr; @@ -116,10 +132,9 @@ void ImageContainer::select() selectionContainer->setRect(QRectF(r.x() - d, r.y() - d, r.width() + 2 * d, r.height() + 2 * d)); } -bool ImageContainer::load(const QString &fn, bool createClone) +bool ImageContainer::load(const QString &fn) { - // qDebug() << "IC::load " << fn; - // createClone == true, if called via copy() + //qDebug() << "IC::load " << fn; if (imageType != ImageContainer::Undefined) { qWarning() << "ImageContainer::load (" << fn << ") into existing image of type " << imageType; @@ -129,23 +144,18 @@ bool ImageContainer::load(const QString &fn, bool createClone) if (fn.toLower().endsWith(".svg")) { svgItem = new QGraphicsSvgItem(fn, this); - if (createClone) { - imageType = ImageContainer::ClonedSVG; - svgCachePath = fn; - } else { - imageType = ImageContainer::SVG; - - // Copy original file to cache - QFile svgFile(fn); - QString newPath = cacheDir.path() + "/" + QString().number(imageID) + - "-" + basename(fn); - if (!svgFile.copy(newPath)) { - qWarning() << "ImageContainer::load (" << fn - << ") could not be copied to " << newPath; - } + imageType = ImageContainer::SVG; + + // Copy original file to cache + QFile svgFile(fn); + QString newPath = cacheDir.path() + "/" + QString().number(imageID) + + "-" + basename(fn); + if (!svgFile.copy(newPath)) { + qWarning() << "ImageContainer::load (" << fn + << ") could not be copied to " << newPath; + } - svgCachePath = newPath; - } // No clone created + svgCachePath = newPath; QRectF r = svgItem->boundingRect(); // Center svg @@ -170,6 +180,7 @@ bool ImageContainer::load(const QString &fn, bool createClone) setRect(mapFromItem(pixmapItem, pixmapItem->boundingRect()).boundingRect()); } + setOriginalFilename(fn); return true; } @@ -199,7 +210,18 @@ bool ImageContainer::save(const QString &fn) return false; } -QString ImageContainer::getExtension() +void ImageContainer::setOriginalFilename(const QString &fn) +{ + originalFilenameInt = fn; + // Set short name. Search from behind: + int i = originalFilenameInt.lastIndexOf("/"); + if (i >= 0) + originalFilenameInt = originalFilenameInt.remove(0, i + 1); +} + +QString ImageContainer::originalFilename() { return originalFilenameInt; } + +QString ImageContainer::extension() { QString s; switch (imageType) { diff --git a/src/image-container.h b/src/image-container.h index cac4d08..bc98854 100644 --- a/src/image-container.h +++ b/src/image-container.h @@ -25,6 +25,7 @@ class ImageContainer : public Container, public LinkableContainer, public Select ImageContainer(); virtual ~ImageContainer(); + virtual QSvgRenderer* svgRenderer(); virtual void copy(ImageContainer*); virtual void init(); void setWidth(qreal w); @@ -32,9 +33,11 @@ class ImageContainer : public Container, public LinkableContainer, public Select qreal scale(); void select(); - bool load(const QString &, bool createClone = false); + bool load(const QString &); bool save(const QString &); - QString getExtension(); + void setOriginalFilename(const QString &); + QString originalFilename(); + QString extension(); ImageType getType(); QIcon getIcon(); @@ -49,6 +52,8 @@ class ImageContainer : public Container, public LinkableContainer, public Select protected: ImageContainer::ImageType imageType; + QString originalFilenameInt; + QGraphicsSvgItem *svgItem; QString svgCachePath; diff --git a/src/imageitem.cpp b/src/imageitem.cpp index 92adc79..727a939 100644 --- a/src/imageitem.cpp +++ b/src/imageitem.cpp @@ -55,7 +55,6 @@ void ImageItem::init() imageWrapperInt = nullptr; setType(Image); hideLinkUnselectedInt = true; - originalFilename = "no original name available"; filePathInZipDir.clear(); } @@ -79,7 +78,7 @@ ImageWrapper* ImageItem::imageWrapper() void ImageItem::setFilePathInZipDir() { filePathInZipDir = model->zipDirPath() + "/images/" + - "image-" + QString().number(itemID) + imageContainer->getExtension(); + "image-" + QString().number(itemID) + imageContainer->extension(); } bool ImageItem::load(const QString &fname) @@ -87,9 +86,8 @@ bool ImageItem::load(const QString &fname) if (!imageContainer || !imageContainer->load(fname)) return false; - setOriginalFilename(fname); setFilePathInZipDir(); - setHeadingPlainText(originalFilename); + setHeadingPlainText(imageContainer->originalFilename()); return true; } @@ -189,21 +187,24 @@ qreal ImageItem::height() void ImageItem::setOriginalFilename(const QString &fn) { - originalFilename = fn; + if (!imageContainer) return; - // Set short name. Search from behind: - int i = originalFilename.lastIndexOf("/"); - if (i >= 0) - originalFilename = originalFilename.remove(0, i + 1); - setHeadingPlainText(originalFilename); + imageContainer->setOriginalFilename(fn); + setHeadingPlainText(imageContainer->originalFilename()); } -QString ImageItem::getOriginalFilename() { return originalFilename; } +QString ImageItem::originalFilename() +{ + if (!imageContainer) + return QString(); + else + return imageContainer->originalFilename(); +} QString ImageItem::getUniqueFilename() { if (imageContainer) - return "image-" + getUuid().toString() + imageContainer->getExtension(); + return "image-" + getUuid().toString() + imageContainer->extension(); else return QString(); } @@ -228,7 +229,7 @@ QString ImageItem::saveToDir(const QString &tmpdir) return QString(); QString url = "images/image-" + QString().number(itemID) + - imageContainer->getExtension(); + imageContainer->extension(); // And really save the image (svgs will be copied from cache!) QString currentPath = tmpdir + "/" + url; @@ -238,8 +239,8 @@ QString ImageItem::saveToDir(const QString &tmpdir) QString attributes; - if (!originalFilename.isEmpty()) - attributes += attribute("originalName", originalFilename); + if (!imageContainer->originalFilename().isEmpty()) + attributes += attribute("originalName", imageContainer->originalFilename()); attributes += attribute("href", QString("file:") + url); attributes += attribute("scale", QString().setNum(imageContainer->scale())); @@ -249,7 +250,7 @@ QString ImageItem::saveToDir(const QString &tmpdir) attributes += attribute("uuid", uuid.toString()); - if (originalFilename == headingPlain()) + if (imageContainer->originalFilename() == headingPlain()) return singleElement("floatimage", attributes); else { QString s = beginElement("floatimage", attributes); diff --git a/src/imageitem.h b/src/imageitem.h index 69f677f..0ce63ff 100644 --- a/src/imageitem.h +++ b/src/imageitem.h @@ -32,7 +32,6 @@ class ImageItem : public MapItem { protected: ImageContainer *imageContainer; ImageWrapper *imageWrapperInt; - QString originalFilename; QString filePathInZipDir; public: @@ -41,7 +40,7 @@ class ImageItem : public MapItem { qreal width(); qreal height(); void setOriginalFilename(const QString &); - QString getOriginalFilename(); + QString originalFilename(); QString getUniqueFilename(); bool saveImage(const QString &fn); QString saveToDir(const QString &tmpdir); diff --git a/src/itemlist-wrapper.cpp b/src/itemlist-wrapper.cpp new file mode 100644 index 0000000..109260b --- /dev/null +++ b/src/itemlist-wrapper.cpp @@ -0,0 +1,99 @@ +#include "itemlist-wrapper.h" + +#include + +#include "vymmodel.h" + +#include + +#include "branchitem.h" +#include "vymmodelwrapper.h" + +ItemListWrapper::ItemListWrapper(VymModel* model) +{ + std::cout << "Constr ItemListWrapper (VM) " << this << std::endl; + init(); + + modelInt = model; +} + +ItemListWrapper::~ItemListWrapper() +{ + std::cout << "Destr ItemListWrapper " << this << std::endl; +} + +void ItemListWrapper::init() +{ + QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); + itemList.clear(); + currentIndex = -1; + deepLevelsFirstInt = false; +} + +void ItemListWrapper::setModeBranches(bool deepLevelsFirst) +{ + init(); + + deepLevelsFirstInt = deepLevelsFirst; + BranchItem *cur = nullptr; + BranchItem *prev = nullptr; + modelInt->nextBranch(cur, prev, deepLevelsFirst); + while (cur) { + itemList << cur->getID(); + //qDebug() << " - adding: " << modelInt->headingText(cur); + modelInt->nextBranch(cur, prev, deepLevelsFirst); + } +} + +void ItemListWrapper::setModeSelectedBranches() +{ + init(); + + QList selbis = modelInt->getSelectedBranches(); + + foreach (BranchItem *bi, selbis) + itemList << bi->getID(); +} + +void ItemListWrapper::setModeSelectedSubtrees(bool deepLevelsFirst) +{ + init(); + + deepLevelsFirstInt = deepLevelsFirst; + + QList selbis = modelInt->getSelectedBranches(); + + foreach (BranchItem *bi, selbis) { + BranchItem *cur = nullptr; + BranchItem *prev = nullptr; + modelInt->nextBranch(cur, prev, deepLevelsFirst, bi); + while (cur) { + itemList << cur->getID(); + modelInt->nextBranch(cur, prev, deepLevelsFirst, bi); + } + } +} + +BranchWrapper* ItemListWrapper::nextBranch() // FIXME-3 assumes currently only branches in list +{ + if (itemList.count() == 0) + return nullptr; + + currentIndex++; + + if (currentIndex > itemList.count() - 1) + return nullptr; + + TreeItem *ti = modelInt->findID(itemList.at(currentIndex)); + + if (ti && ti->hasTypeBranch()) + return ((BranchItem*)ti)->branchWrapper(); + else + return nullptr; +} + +uint ItemListWrapper::count() +{ + return itemList.count(); +} + diff --git a/src/itemlist-wrapper.h b/src/itemlist-wrapper.h new file mode 100644 index 0000000..b6a8dfa --- /dev/null +++ b/src/itemlist-wrapper.h @@ -0,0 +1,34 @@ +#ifndef ITEMLIST_WRAPPER_H +#define ITEMLIST_WRAPPER_H + +#include + +class BranchWrapper; +class VymModel; +class VymModelWrapper; + +//Q_DECLARE_METATYPE(ItemListWrapper) +//Q_DECLARE_METATYPE(ItemListWrapper*) + +class ItemListWrapper : public QObject { + Q_OBJECT +public: + Q_INVOKABLE ItemListWrapper (VymModel*); + ~ItemListWrapper (); + void init(); + +public slots: + Q_INVOKABLE void setModeBranches(bool deepLevelsFirst = false); + Q_INVOKABLE void setModeSelectedBranches(); + Q_INVOKABLE void setModeSelectedSubtrees(bool deepLevelsFirst = false); + Q_INVOKABLE BranchWrapper* nextBranch(); + Q_INVOKABLE uint count(); + +private: + VymModel* modelInt; + QList itemList; + int currentIndex; + bool deepLevelsFirstInt; +}; + +#endif diff --git a/src/linkobj.cpp b/src/linkobj.cpp index 0403a0d..ab12e50 100644 --- a/src/linkobj.cpp +++ b/src/linkobj.cpp @@ -140,7 +140,9 @@ LinkObj::Style LinkObj::getLinkStyle() { return style; } LinkObj::Style LinkObj::styleFromString(const QString &s) { LinkObj::Style style; - if (s == "StyleLine") + if (s == "StyleNoLink") + return LinkObj::NoLink; + else if (s == "StyleLine") return LinkObj::Line; else if (s == "StyleParabel") return LinkObj::Parabel; diff --git a/src/main.cpp b/src/main.cpp index 86b8610..94e1488 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -69,15 +69,16 @@ FlagRowMaster *userFlagsMaster; Macros macros; -ulong itemLastID = 0; // Unique ID for all items in all models -ulong imageLastID = 0; // Unique ID for caching images, also flags not in tree +ulong itemLastID = 0; // Unique ID for all items in all models +ulong imageLastID = 0; // Unique ID for caching images, also flags not in tree -QDir tmpVymDir; // All temp files go there, created in mainwindow -QDir cacheDir; // tmp dir with cached svg files in tmpVymDir -QString clipboardDir; // Clipboard used in all mapEditors -QString clipboardFile; // Clipboard used in all mapEditors +QDir tmpVymDir; // All temp files go there, created in mainwindow +QDir cacheDir; // tmp dir with cached svg files in tmpVymDir +QDir clipboardDir; // Clipboard used in all mapEditors +QString clipboardFileName; // Clipboard used in all mapEditors QDir vymBaseDir; // Containing all styles, scripts, images, ... +QDir vymUserDir; // User directory with temporary files bool useActionLog; // Write logfile. No GUI yet to enable, only for debugging QString actionLogPath; // Path to logfile @@ -114,10 +115,11 @@ bool unzipToolAvailable = false; QString zipToolPath; // Platform dependant zip tool QString unzipToolPath; // Platform dependant unzip tool -QList vymCommands; -QList modelCommands; QList branchCommands; QList imageCommands; +QList itemListCommands; +QList modelCommands; +QList vymCommands; QList xlinkCommands; Options options; @@ -316,6 +318,60 @@ int main(int argc, char *argv[]) #endif } + // Temporary directories + + // vymUserDir has temporary files (later maybe more data) + // in users home to avoid deleting still + // required files by system (see #151) + + vymUserDir.setPath(QDir::homePath() + "/.vym"); + + bool ok; + if (!vymUserDir.exists()) { + ok = QDir::home().mkdir( + basename(vymUserDir.path()), + QFileDevice::ReadOwner| QFileDevice::WriteOwner | QFileDevice::ExeOwner); + if (!ok) { + QString msg = "Failed to create vymUserDir=" + vymUserDir.path(); + qWarning() << msg; + QMessageBox::warning(0, "Critical Error", msg); + exit (1); + } + } + + tmpVymDir.setPath(makeTmpDir(ok, "vym-tmp")); + if (!ok) { + QString msg = "Failed to create temporary directory tmpVymDir=" + tmpVymDir.path(); + qWarning() << msg; + QMessageBox::warning(0, "Critical Error", msg); + exit(1); + } + if (debug) + qDebug() << "tmpVymDirPath = " << tmpVymDir.path(); + + // Create directory for clipboard + clipboardDir.setPath(tmpVymDir.path() + "/clipboard"); + clipboardFileName = "clipboard"; + if (!clipboardDir.mkpath(clipboardDir.path())) { + QString msg = "Failed to create clipboardDir=" + clipboardDir.path(); + qWarning() << msg; + QMessageBox::warning(0, "Critical Error", msg); + exit(1); + } + + makeSubDirs(clipboardDir.path()); + + // Create directory for cached files, e.g. svg images + cacheDir.setPath(tmpVymDir.path() + "/cache"); + if (!tmpVymDir.mkpath(cacheDir.path())) { + QString msg = "Failed to create cache directory cacheDir=" + cacheDir.path(); + qWarning() << msg; + QMessageBox::warning(0, "Critical Error", msg); + exit(1); + } + + + // Platform specific settings vymPlatform = QSysInfo::prettyProductName(); @@ -588,17 +644,18 @@ int main(int argc, char *argv[]) m.runScript(scriptEditor->getScriptFile()); } - // For benchmarking we may want to quit instead of entering event loop - if (options.isActive("quit")) - return 0; - // Enable some last minute cleanup QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); - app.exec(); + // For benchmarking we may want to quit instead of entering event loop + if (options.isActive("quit")) + m.fileExitVYM(); + else + app.exec(); // Cleanup delete noteEditor; + removeDir(tmpVymDir); int s = warningCount + criticalCount + fatalCount; if (s > 0) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 43ca326..b46a4d3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -87,10 +87,6 @@ extern FindResultWidget *findResultWidget; extern TaskEditor *taskEditor; extern TaskModel *taskModel; extern Macros macros; -extern QDir tmpVymDir; -extern QDir cacheDir; -extern QString clipboardDir; -extern QString clipboardFile; extern FlagRowMaster *standardFlagsMaster; extern FlagRowMaster *userFlagsMaster; extern FlagRowMaster *systemFlagsMaster; @@ -114,6 +110,7 @@ extern QList vymCommands; extern QList modelCommands; extern QList branchCommands; extern QList imageCommands; +extern QList itemListCommands; extern QList xlinkCommands; extern bool usingDarkTheme; @@ -153,6 +150,7 @@ extern QColor vymBlueColor; Main::Main(QWidget *parent) : QMainWindow(parent) { + // qDebug() << "Constr. MainWindow"; mainWindow = this; setWindowTitle(vymName + " - View Your Mind"); @@ -162,37 +160,6 @@ Main::Main(QWidget *parent) : QMainWindow(parent) // Sometimes we may need to remember old selections prevSelection = QUuid(); - // Create unique temporary directory - bool ok; - QString tmpVymDirPath = makeTmpDir(ok, "vym"); - if (!ok) { - qWarning("Mainwindow: Could not create temporary directory, failed to " - "start vym"); - exit(1); - } - if (debug) - qDebug() << "tmpVymDirPath = " << tmpVymDirPath; - tmpVymDir.setPath(tmpVymDirPath); - - // Create direcctory for clipboard - clipboardDir = tmpVymDirPath + "/clipboard"; - clipboardFile = "clipboard"; - QDir d(clipboardDir); - d.mkdir(clipboardDir); - makeSubDirs(clipboardDir); - - // Create directory for cached files, e.g. svg images - if (!tmpVymDir.mkdir("cache")) { - qWarning( - "Mainwindow: Could not create cache directory, failed to start vym"); - exit(1); - } - cacheDir = QDir(tmpVymDirPath + "/cache"); - - // Remember PID of our friendly webbrowser - browserPID = new qint64; - *browserPID = 0; - // Define commands in API (used globally) setupAPI(); @@ -458,9 +425,6 @@ Main::~Main() delete standardFlagsMaster; delete userFlagsMaster; delete systemFlagsMaster; - - // Remove temporary directory - removeDir(tmpVymDir); } void Main::loadCmdLine() @@ -551,7 +515,8 @@ void Main::removeProgressCounter() void Main::closeEvent(QCloseEvent *event) { - if (fileExitVYM()) + if (tabWidget->count() > 0 && fileExitVYM()) + // Some problem when closing tabs event->ignore(); else event->accept(); @@ -635,8 +600,6 @@ void Main::setupAPI() c->setComment("Add MapCenter at position (x, y)"); modelCommands.append(c); - QString DEPRECATED(" DEPRECATED. Commands moved to branch or image. "); - c = new Command("addSlide", Command::BranchSel); modelCommands.append(c); @@ -723,10 +686,6 @@ void Main::setupAPI() c = new Command("getFileName", Command::AnySel, Command::StringPar); modelCommands.append(c); - c = new Command("getHeadingPlainText", Command::TreeItemSel, Command::StringPar); - c->setComment(DEPRECATED + "Branch::headingText()"); - modelCommands.append(c); - c = new Command("getIntAttribute", Command::BranchSel, Command::IntPar); c->addParameter(Command::StringPar, false, "Key of string attribute"); modelCommands.append(c); @@ -744,23 +703,19 @@ void Main::setupAPI() c->setComment("Returns 'DefaultColor' for links or 'HeadingColor'"); modelCommands.append(c); - c = new Command("getNotePlainText", Command::TreeItemSel, Command::StringPar); - c->setComment(DEPRECATED + " b.getNoteText"); - modelCommands.append(c); - - c = new Command("getNoteXML", Command::TreeItemSel, Command::StringPar); - c->setComment(DEPRECATED); + c = new Command("getSelectionString", Command::TreeItemSel, Command::StringPar); modelCommands.append(c); - c = new Command("getSelectionString", Command::TreeItemSel, Command::StringPar); + c = new Command("getZoom", Command::AnySel, Command::DoublePar); modelCommands.append(c); c = new Command("hasBackgroundImage", Command::AnySel, Command::BoolPar); c->setComment("Returns true, if map uses an image as background"); modelCommands.append(c); - c = new Command("hasRichTextNote", Command::BranchSel, Command::BoolPar); - c->setComment(DEPRECATED); + c = new Command("itemList", Command::AnySel, Command::BoolPar); + c->addParameter(Command::BoolPar, true, "Flag to go deep levels first (currently unused)"); + c->setComment("Create new itemList to iterate over branches"); modelCommands.append(c); c = new Command("loadBackgroundImage", Command::AnySel); @@ -774,15 +729,6 @@ void Main::setupAPI() c->setComment("Replace branch with data from given path"); modelCommands.append(c); - c = new Command("newBranchIterator", Command::BranchSel); - c->addParameter(Command::StringPar, false, "Name of iterator"); - c->addParameter(Command::BoolPar, true, "Flag to go deep levels first"); - modelCommands.append(c); - - c = new Command("isScrolled", Command::BranchSel, Command::BoolPar); - c->setComment(DEPRECATED); - modelCommands.append(c); - c = new Command("moveSlideDown", Command::AnySel); modelCommands.append(c); @@ -809,16 +755,6 @@ void Main::setupAPI() c = new Command("redo", Command::AnySel); modelCommands.append(c); - c = new Command("relinkTo", - Command::TreeItemSel, - Command::BoolPar); // FIXME different number of parameters for Image or Branch - c->setComment(DEPRECATED); - c->addParameter(Command::StringPar, false, "Selection string of parent"); - c->addParameter(Command::IntPar, false, "Index position"); - c->addParameter(Command::DoublePar, true, "Position x"); - c->addParameter(Command::DoublePar, true, "Position y"); - modelCommands.append(c); - c = new Command("remove", Command::TreeItemSel); modelCommands.append(c); @@ -848,12 +784,13 @@ void Main::setupAPI() c = new Command("repeatLastCommand", Command::AnySel); modelCommands.append(c); - c = new Command("saveSelection", Command::BranchOrImageSel); - c->addParameter(Command::StringPar, false, "Filename to save branch or image"); + c = new Command("resetBranchIterator", Command::BranchSel, Command::BoolPar); + c->addParameter(Command::StringPar, false, "Name of iterator"); + c->setComment("Move iterator to first MapCenter in map"); modelCommands.append(c); - c = new Command("scroll", Command::BranchSel); - c->setComment(DEPRECATED); + c = new Command("saveSelection", Command::BranchOrImageSel); + c->addParameter(Command::StringPar, false, "Filename to save branch or image"); modelCommands.append(c); c = new Command("select", Command::AnySel, Command::BoolPar); @@ -904,6 +841,7 @@ void Main::setupAPI() c = new Command("setLinkStyle", Command::AnySel); c->addParameter(Command::StringPar, false, "Link style in map"); + c->addParameter(Command::IntPar, true, "Depth of branch with this style"); modelCommands.append(c); c = new Command("setRotationView", Command::AnySel); @@ -947,17 +885,9 @@ void Main::setupAPI() c->addParameter(Command::StringPar, false, "Uid of flag to toggle"); modelCommands.append(c); - c = new Command("toggleScroll", Command::BranchSel); - c->setComment(DEPRECATED); - modelCommands.append(c); - c = new Command("undo", Command::AnySel); modelCommands.append(c); - c = new Command("unscroll", Command::BranchSel, Command::BoolPar); - c->setComment(DEPRECATED); - modelCommands.append(c); - c = new Command("unselectAll", Command::AnySel); modelCommands.append(c); @@ -1571,6 +1501,29 @@ void Main::setupAPI() c->setComment("Set color of xlink"); xlinkCommands.append(c); + // + // Below are the commands for an itemList + // + + c = new Command("count"); + c->setComment("Return number of items in list"); + c->setReturnType(Command::IntPar); + itemListCommands.append(c); + + c = new Command("setModeBranches"); + c->setComment("Set iteration mode to include all branches in map"); + c->addParameter(Command::BoolPar, true, "Deep levels first"); + itemListCommands.append(c); + + c = new Command("setModeSelectedBranches"); + c->setComment("Set iteration mode to include all selected branches in map"); + itemListCommands.append(c); + + c = new Command("setModeSelectedSubtrees"); + c->setComment("Set iteration mode to include all selected branches and their children in map"); + c->addParameter(Command::BoolPar, true, "Deep levels first"); + itemListCommands.append(c); + // Finally set objectTypes in all defined commands foreach (Command *c, vymCommands) c->setObjectType(Command::VymObject); @@ -1587,6 +1540,9 @@ void Main::setupAPI() foreach (Command *c, xlinkCommands) c->setObjectType(Command::XLinkObject); + foreach (Command *c, itemListCommands) + c->setObjectType(Command::ItemListObject); + } void Main::cloneActionMapEditor(QAction *a, QKeySequence ks) @@ -3369,7 +3325,6 @@ void Main::setupFlagActions() // Original khelpcenter.png setupFlag(":/flag-lifebelt.svg", Flag::StandardFlag, "lifebelt", tr("This will help", "Standardflag")); - // FIXME-2 lifebelt.svg seems to cause warnings about buffer size setupFlag(":/flag-phone.svg", Flag::StandardFlag, "phone", tr("Call...", "Standardflag")); @@ -4740,7 +4695,6 @@ void Main::fileSave(VymModel *m) { fileSave(m, File::CompleteMap); } void Main::fileSaveAs(const File::SaveMode &savemode) { - std::cout << __func__ << " ok0" << std::endl; // FIXME-2 debugging VymModel *m = currentModel(); if (!m) return; @@ -4753,9 +4707,10 @@ void Main::fileSaveAs(const File::SaveMode &savemode) // Get destination path QString fn = QFileDialog::getSaveFileName( - this, tr("Save map as"), lastMapDir.path(), filter, nullptr, - QFileDialog::DontConfirmOverwrite); - std::cout << __func__ << " ok1" << std::endl; // FIXME-2 debugging + this, + tr("Save map as"), + lastMapDir.path() + "/" + tr("Untitled", "Default name in FileSaveAs dialog") + ".vym", + filter, nullptr, QFileDialog::DontConfirmOverwrite); if (!fn.isEmpty()) { // Check for existing file if (QFile(fn).exists()) { @@ -5224,7 +5179,6 @@ void Main::filePrint() bool Main::fileExitVYM() { - // fileExit Vym calls itself via qApp->quit() and closeEvent() // Only save session if there still are tabs open if (tabWidget->count() > 0) fileSaveSession(); @@ -5323,8 +5277,7 @@ bool Main::openUrl(const QString &url, bool privateMode) // FIXME-3 settings fo QString browser = settings.value("/system/readerUrl").toString(); QStringList args; args << url; - if (!QProcess::startDetached(browser, args, QDir::currentPath(), - browserPID)) { + if (!QProcess::startDetached(browser, args, QDir::currentPath())) { // try to set path to browser QMessageBox::warning( 0, tr("Warning"), @@ -5975,14 +5928,10 @@ void Main::editDeleteSelection() m->deleteSelection(); } -void Main::editLoadImage() // FIXME-2 filter is not used +void Main::editLoadImage() { VymModel *m = currentModel(); if (m) { - QString filter = QString(tr("Images", "Filedialog") + - " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif " - "*.pnm *.svg *.svgz);;" + - tr("All", "Filedialog") + " (*.*)"); QStringList imagePaths = openImageDialog(tr("Load images")); if (!imagePaths.isEmpty()) @@ -6391,7 +6340,7 @@ void Main::formatSelectLinkColor() } } -void Main::formatSelectSelectionColor() // FIXME-2 no Pen/Brush support yet +void Main::formatSelectSelectionColor() // FEATURE #157 no Pen/Brush support yet { VymModel *m = currentModel(); if (m) { @@ -6565,8 +6514,6 @@ void Main::settingsMacroPath() fd.setNameFilters(filters); fd.setWindowTitle(vymName + " - " + tr("Load vym script")); fd.setAcceptMode(QFileDialog::AcceptOpen); - fd.show(); // FIXME-2 added to debug #146 - fd.activateWindow(); // FIXME-2 added to debug #146 if (fd.exec() == QDialog::Accepted) { if (macros.setPath( fd.selectedFiles().first())) @@ -7115,7 +7062,7 @@ void Main::updateActions() a->setEnabled(false); // Link style in context menu - switch (m->mapDesign()->linkStyle(0)) { // FIXME-4 Currently global for map, all depths + switch (m->mapDesign()->linkStyle(1)) { // FIXME-4 Currently global for map, all depths case LinkObj::Line: actionFormatLinkStyleLine->setChecked(true); break; @@ -7608,12 +7555,6 @@ void Main::testFunction1() //#include //qApp->setStyle(QStyleFactory::create("windowsvista")); - const char *s1 = "Foo"; - const char *s2 = "Foo"; - - qDebug() << strcmp(s1,s2); - return; - VymModel *m = currentModel(); if (m) { m->test(); diff --git a/src/mainwindow.h b/src/mainwindow.h index fd77089..15eee3a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -161,9 +161,9 @@ class Main : public QMainWindow { void fileExportLast(); bool fileCloseMap(int i = -1); // Optionally pass number of tab void filePrint(); - bool fileExitVYM(); public slots: + bool fileExitVYM(); void editUndo(); void editRedo(); void gotoHistoryStep(int); @@ -416,7 +416,6 @@ class Main : public QMainWindow { private: QString shortcutScope; //! For listing shortcuts QTabWidget *tabWidget; - qint64 *browserPID; QStringList imageTypes; diff --git a/src/mapeditor.cpp b/src/mapeditor.cpp index 3b5c232..e2ef231 100644 --- a/src/mapeditor.cpp +++ b/src/mapeditor.cpp @@ -23,8 +23,6 @@ #include "xlinkobj.h" extern Main *mainWindow; -extern QString clipboardDir; -extern QString clipboardFile; extern bool debug; extern QPrinter *printer; extern QDir tmpVymDir; @@ -305,8 +303,8 @@ void MapEditor::ensureAreaVisibleAnimated( qreal a = new_rotation / 180 * M_PI; qreal area_w_viewCoord = abs(sin(a) * area.height()) + abs(cos(a) * area.width()); qreal area_h_viewCoord = abs(sin(a) * area.width()) + abs(cos(a) * area.height()); - qreal z_x = 1.0 * visibleViewCoord.width() / area_w_viewCoord; - qreal z_y = 1.0 * visibleViewCoord.height() / area_h_viewCoord; + qreal z_x = abs(1.0 * visibleViewCoord.width() / area_w_viewCoord); + qreal z_y = abs(1.0 * visibleViewCoord.height() / area_h_viewCoord); qreal zf = min (z_x, z_y); @@ -317,8 +315,8 @@ void MapEditor::ensureAreaVisibleAnimated( int animDuration = 2000; QEasingCurve easingCurve = QEasingCurve::OutQuint; - //qDebug() << " zoom out: " << zoomOutRequired; - //qDebug() << " zoom in: " << zoomInRequired << " zoomFactor=" << zoomFactorInt << " zf=" << zf; + //qDebug() << __func__ << " zoom out: " << zoomOutRequired << " zoomFactor=" << zoomFactorInt << " zf=" << zf; + //qDebug() << "z_xy=" << toS(QPointF(z_x, z_y)); if (zoomOutRequired || scaled) { setViewCenterTarget( area.center(), @@ -589,6 +587,10 @@ void MapEditor::zoomOut() void MapEditor::setZoomFactorTarget(const qreal &zft) { + // qDebug() << __func__ << "zft=" << zft << " zf=" << zoomFactorInt; + if (zoomFactorTargetInt == zft) + return; + zoomFactorTargetInt = zft; if (zoomAnimation.state() == QAbstractAnimation::Running) zoomAnimation.stop(); @@ -607,15 +609,20 @@ void MapEditor::setZoomFactorTarget(const qreal &zft) setZoomFactor(zft); } -qreal MapEditor::zoomFactorTarget() { return zoomFactorTargetInt; } +qreal MapEditor::zoomFactorTarget() { + return zoomFactorTargetInt; +} void MapEditor::setZoomFactor(const qreal &zf) { + //qDebug() << __func__ << "zf=" << zf; zoomFactorInt = zf; updateMatrix(); } -qreal MapEditor::zoomFactor() { return zoomFactorInt; } +qreal MapEditor::zoomFactor() { + return zoomFactorInt; +} void MapEditor::setRotationTarget(const qreal &at) { @@ -696,6 +703,7 @@ void MapEditor::setViewCenterTarget(const QPointF &p, const qreal &zft, void MapEditor::setViewCenterTarget() { + qDebug() << __func__; MapItem *selti = (MapItem *)(model->getSelectedItem()); if (selti) { Container *c = nullptr; @@ -2206,9 +2214,10 @@ void MapEditor::moveObject(QMouseEvent *e, const QPointF &p_event) // Align tmpParentContainer if (targetBranchContainer->hasFloatingBranchesLayout()) { - // When temporary linking e.g. to MapCenter, position on a circle around MC + // When temporary linking e.g. to MapCenter, position on a circle + // bigger than ornamensContainer - qreal radius = 80; + qreal radius = 100 + targetBranchContainer->ornamentsRect().width(); QPointF center_sp = targetBranchContainer->getHeadingContainer()->mapToScene(QPointF(0,0)); qreal a = getAngle(p_event - center_sp); diff --git a/src/mkdtemp.cpp b/src/mkdtemp.cpp deleted file mode 100644 index 836b918..0000000 --- a/src/mkdtemp.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -#include -#include -#ifndef _WIN32 -#include - -extern "C" { -pid_t getpid(void); -} -#else -#include -#define getpid GetCurrentProcessId -#include -#include -#endif - -QString mkdtemp(QString tmpl) -{ - static const char letters[] = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - - static uint64_t value; - - const unsigned int ATTEMPTS_MIN = (62 * 62 * 62); - - if (tmpl.length() < 6 || !tmpl.endsWith("XXXXXX")) { - return QString(); - } - - uint64_t random_time_bits = time(nullptr); - - value += (random_time_bits ^ getpid()); - - unsigned int count; - for (count = 0; count < ATTEMPTS_MIN; value += 7777, ++count) { - uint64_t v = value; - QString XXXXXX; - XXXXXX.append(letters[v % 62]); - v /= 62; - XXXXXX.append(letters[v % 62]); - v /= 62; - XXXXXX.append(letters[v % 62]); - v /= 62; - XXXXXX.append(letters[v % 62]); - v /= 62; - XXXXXX.append(letters[v % 62]); - v /= 62; - XXXXXX.append(letters[v % 62]); - - tmpl.replace(tmpl.length() - 6, 6, XXXXXX); - QDir dir; - if (dir.exists(tmpl)) - continue; - if (dir.mkpath(tmpl)) { - return tmpl; - } - } - return QString(); -} diff --git a/src/mkdtemp.h b/src/mkdtemp.h deleted file mode 100644 index ea4ecc5..0000000 --- a/src/mkdtemp.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MKDTEMP_H -#define MKDTEMP_H - -extern QString mkdtemp(QString _template); - -#endif diff --git a/src/scripteditor.cpp b/src/scripteditor.cpp index bebe735..41f711e 100644 --- a/src/scripteditor.cpp +++ b/src/scripteditor.cpp @@ -16,10 +16,12 @@ #include "vymmodel.h" extern QString vymName; -extern QList vymCommands; -extern QList modelCommands; extern QList branchCommands; extern QList imageCommands; +extern QList itemListCommands; +extern QList modelCommands; +extern QList vymCommands; +extern QList xlinkCommands; extern QDir lastScriptDir; extern Macros macros; extern Main *mainWindow; @@ -85,6 +87,10 @@ ScriptEditor::ScriptEditor(QWidget *parent) : QWidget(parent) list.append(QString("\\b%1\\b").arg(c->name())); foreach (Command *c, imageCommands) list.append(QString("\\b%1\\b").arg(c->name())); + foreach (Command *c, itemListCommands) + list.append(QString("\\b%1\\b").arg(c->name())); + foreach (Command *c, xlinkCommands) + list.append(QString("\\b%1\\b").arg(c->name())); highlighterMacro->addKeywords(list); highlighterSlide->addKeywords(list); highlighterFile->addKeywords(list); diff --git a/src/taskeditor.cpp b/src/taskeditor.cpp index c1070cc..1e4cc8e 100644 --- a/src/taskeditor.cpp +++ b/src/taskeditor.cpp @@ -144,7 +144,8 @@ TaskEditor::TaskEditor(QWidget *) view->setDragEnabled(true); view->setAcceptDrops(true); view->setDropIndicatorShown(true); - view->setAutoScroll(false); + view->setAutoScroll(false); // Autopscroll while dragging tasks + view->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); blockExternalSelect = false; @@ -410,9 +411,11 @@ void TaskEditor::selectionChanged(const QItemSelection &selected, // Avoid segfault on quit, when selected is empty return; - QItemSelection sel0 = filterActiveModel->mapSelectionToSource(selected); - QModelIndex ix = sel0.indexes().first(); - Task *t = taskModel->getTask(ix); + QItemSelection selMapped = filterActiveModel->mapSelectionToSource(selected); + QModelIndex ixMapped = selMapped.indexes().first(); + Task *t = taskModel->getTask(ixMapped); + + // If ixMapped is invalid, returned t will be nullptr if (t) { BranchItem *bi = t->getBranch(); if (bi) { @@ -427,7 +430,6 @@ void TaskEditor::selectionChanged(const QItemSelection &selected, "; selection-color:" + bi->headingColor().name() + "}" + "QTableView:focus {" + editorFocusStyle + "}"); */ - view->scrollTo(selected.indexes().first()); } } } diff --git a/src/taskmodel.cpp b/src/taskmodel.cpp index 3e94efe..0f2bfc8 100644 --- a/src/taskmodel.cpp +++ b/src/taskmodel.cpp @@ -493,9 +493,15 @@ bool TaskModel::dropMimeData(const QMimeData *data, Qt::DropAction action, { Q_UNUSED(row); + //qDebug() << "TM::dropMimeData " << row << column << parent << data; if (action == Qt::IgnoreAction) return true; + if (!parent.isValid()) { + qWarning() << __func__ << " parent is invalid"; + return false; + } + if (!data->hasFormat("application/vnd.text.list")) return false; @@ -517,8 +523,12 @@ bool TaskModel::dropMimeData(const QMimeData *data, Qt::DropAction action, Task *dst = getTask(parent); Task *src = getTask(newItems[1].toInt()); - // qDebug() << "Dropping: " << src->getBranch()->headingPlain() << " on - // " << dst->getBranch()->headingPlain(); + if (!dst || !src) { + qWarning() << __func__ << " invalid src or dst"; + qDebug() << "dst=" << dst << " src=" << src; + return false; + } + //qDebug() << "Dropping: " << src->getBranch()->headingPlain() << " on " << dst->getBranch()->headingPlain(); int delta_p = dst->getPriority() - src->getPriority(); diff --git a/src/treemodel.cpp b/src/treemodel.cpp index 46fae4d..a6ed465 100644 --- a/src/treemodel.cpp +++ b/src/treemodel.cpp @@ -147,11 +147,9 @@ void TreeModel::nextBranch(BranchItem *¤t, BranchItem *&previous, if (start) { current = start; previous = current->parentBranch(); - } - else { + } else { previous = (BranchItem *)rootItem; current = previous->getFirstBranch(); - return; } } diff --git a/src/version.h b/src/version.h index 828ea49..c7f56e2 100644 --- a/src/version.h +++ b/src/version.h @@ -1,16 +1,16 @@ #ifndef VERSION_H #define VERSION_H -#define __VYM_VERSION "2.9.582" -#define __VYM_BUILD_DATE "2025-07-07" +#define __VYM_VERSION "2.9.588" +#define __VYM_BUILD_DATE "2025-08-07" #define __VYM_NAME "VYMng" // FIXME "next generation" in in window title #define __VYM_HOME "http://www.insilmaril.de/vym" // //#define __VYM_CODE_QUALITY "Production" -#define __VYM_CODE_QUALITY "*Experimental*" -//#define __VYM_CODE_QUALITY "*Beta*" -//#define __VYM_CODENAME "Beta release of upcoming 3.0.0" -#define __VYM_CODENAME "Debug version of upcoming 33.0.0" +//#define __VYM_CODE_QUALITY "*Experimental*" +#define __VYM_CODE_QUALITY "*Beta*" +#define __VYM_CODENAME "Beta release of upcoming 3.0.0" +//#define __VYM_CODENAME "Debug version of upcoming 3.0.0" #endif diff --git a/src/vymmodel.cpp b/src/vymmodel.cpp index bf1d889..59e0819 100644 --- a/src/vymmodel.cpp +++ b/src/vymmodel.cpp @@ -88,8 +88,8 @@ extern FlagRowMaster *userFlagsMaster; extern Options options; -extern QString clipboardDir; -extern QString clipboardFile; +extern QDir clipboardDir; +extern QString clipboardFileName; extern ImageIO imageIO; @@ -3559,7 +3559,7 @@ void VymModel::copy() QList itemList = getSelectedItems(); - QStringList clipboardFiles; + QStringList clipboardFileNames; if (itemList.count() > 0) { @@ -3570,22 +3570,22 @@ void VymModel::copy() foreach (TreeItem *ti, itemList) { uids << QString("\"%1\"").arg(ti->getUuid().toString()); fn = QString("%1/%2-%3.xml") - .arg(clipboardDir) - .arg(clipboardFile) + .arg(clipboardDir.path()) + .arg(clipboardFileName) .arg(i); - QString content = saveToDir(clipboardDir, clipboardFile, + QString content = saveToDir(clipboardDir.path(), clipboardFileName, FlagRowMaster::NoFlags, QPointF(), false, false, false, ti); if (!saveStringToDisk(fn, content)) qWarning() << "ME::saveStringToDisk failed: " << fn; else { i++; - clipboardFiles.append(fn); + clipboardFileNames.append(fn); } } QClipboard *clipboard = QApplication::clipboard(); QMimeData *mimeData = new QMimeData; - mimeData->setData("application/x-vym", clipboardFiles.join(",").toLatin1()); + mimeData->setData("application/x-vym", clipboardFileNames.join(",").toLatin1()); clipboard->setMimeData(mimeData); QString rc = QString("map.selectUids([%1]); map.copy();").arg(uids.join(",")); @@ -3620,7 +3620,7 @@ void VymModel::paste() if (selbi) { if (mimeData->formats().contains("application/x-vym")) { - QStringList clipboardFiles = QString(mimeData->data("application/x-vym")).split(","); + QStringList clipboardFileNames = QString(mimeData->data("application/x-vym")).split(","); QString bv = setBranchVar(selbi); QString uc = bv + QString("map.loadBranchReplace(\"UNDO_PATH\", b);"); @@ -3632,7 +3632,7 @@ void VymModel::paste() saveState(uc, rc, comment, selbi, selbi); bool zippedOrg = zipped; - foreach(QString fn, clipboardFiles) { + foreach(QString fn, clipboardFileNames) { if (!loadMap(fn, File::ImportAdd, File::VymMap, @@ -3646,7 +3646,7 @@ void VymModel::paste() } else if (mimeData->hasImage()) { //qDebug() << "VM::paste mimeData->hasImage"; QImage image = qvariant_cast(mimeData->imageData()); - QString fn = clipboardDir + "/" + "image.png"; + QString fn = clipboardDir.path() + "/" + "image.png"; if (!image.save(fn)) logWarning("Could not save copy of image in system clipboard " + fn, __func__); else { @@ -3811,10 +3811,7 @@ void VymModel::moveDownDiagonally() } } -void VymModel::detach(BranchItem *bi) // FIXME-2 Various issues - // sometines linkSpaceCont and/or reposition missing - // -1 does not remove link for MainBranch - // does not save old position in relinkBranch() +void VymModel::detach(BranchItem *bi) { QList selbis; if (bi) @@ -3823,7 +3820,11 @@ void VymModel::detach(BranchItem *bi) // FIXME-2 Various issues selbis = getSelectedBranches(); foreach (BranchItem *selbi, selbis) { if (selbi->depth() > 0) { + BranchContainer *bc = selbi->getBranchContainer(); + if (bc) + bc->setOriginalPos(); relinkBranch(selbi, rootItem, -1); + bc->updateUpLink(); } } } @@ -4534,11 +4535,12 @@ bool VymModel::relinkBranches(QList branches, BranchItem *dst, int BranchItem *pbi = bi->parentBranch(); if (pbi == rootItem) { - // Remember position of MapCenter + // Remember position before MapCenter is relinked rememberPos = true; } else { BranchContainer *pbc = pbi->getBranchContainer(); if (pbc->hasFloatingBranchesLayout()) + // Remember position, if relinked branch is floating rememberPos = true; } @@ -4547,16 +4549,13 @@ bool VymModel::relinkBranches(QList branches, BranchItem *dst, int BranchContainer *dstBC = dst->getBranchContainer(); // might be nullptr for MC! // Keep position when detaching - bool keepPos; + bool detaching; QPointF preDetachPos; if (dst == rootItem) { - keepPos = true; + detaching = true; preDetachPos = bc->getHeadingContainer()->scenePos(); } else - keepPos = false; - - // What kind of relinking are we doing? Important for style updates - MapDesign::UpdateMode updateMode = MapDesign::RelinkedByUser; // FIXME-2 not used later also not considering detaching + detaching = false; BranchItem *branchpi = bi->parentBranch(); @@ -4610,11 +4609,9 @@ bool VymModel::relinkBranches(QList branches, BranchItem *dst, int // reset parObj, fonts, frame, etc in related branch-container or other view-objects applyDesign(MapDesign::RelinkedByUser, bi); - // Keep position when detaching - if (keepPos) { + if (detaching) bc->setPos(preDetachPos); - } // Savestate, but not if just moving up/down if (!saveStateBlocked) { @@ -5217,7 +5214,7 @@ ItemList VymModel::getLinkedMaps() s.replace(re, " "); re.setPattern("\\s+"); s.replace(re, " "); - re.setPattern("\\s+"); + re.setPattern("^\\s+"); s.replace(re, ""); QStringList sl; @@ -6581,7 +6578,7 @@ MapDesign* VymModel::mapDesign() return mapDesignInt; } -void VymModel::applyDesign( // FIXME-2 Check handling of autoDesign option +void VymModel::applyDesign( MapDesign::UpdateMode updateMode, BranchItem *bi) { @@ -6708,37 +6705,49 @@ void VymModel::setDefaultFont(const QFont &font) // FIXME-3 no saveState, no mapDesignInt->setFont(font); } -bool VymModel::setLinkStyle(const QString &newStyleString, int depth) // FIXME-2 saveState needs to be adapted, command new param depth - // See also mainWindow->updateActions context menu - // FIXME MapDesign setting with depth passed as argument is moved to MapDesign when parsing .xml - // Somehow MD needs to return undo command when setting an element +bool VymModel::setLinkStyle(const QString &newStyleString, int depth) { - // Default depth == -1 is used for legacy styles from version < 2.9.518 - // or for using global setting from context menu + auto style = LinkObj::styleFromString(newStyleString); if (depth >= 0) { QString currentStyleString = LinkObj::styleString(mapDesignInt->linkStyle(depth)); - QString uc = QString("map.setLinkStyle (\"%1\");").arg(newStyleString); - QString rc = QString("map.setLinkStyle (\"%1\");").arg(currentStyleString); - QString com = QString("Set map link style (\"%1\")").arg(newStyleString); + QString uc = QString("map.setLinkStyle (\"%1\", %2);").arg(newStyleString, depth); + QString rc = QString("map.setLinkStyle (\"%1\", %2);").arg(currentStyleString, depth); + QString com = QString("Set map link style (\"%1\", %2)").arg(newStyleString, depth); logAction(rc, com, __func__); saveState(uc, rc, com); - } + mapDesignInt->setLinkStyle(style, depth); + } else { + // Default depth == -1 is used for legacy styles from version < 2.9.518 + // or for using global setting from context menu + // Only apply the "thick" part on first level + QString com = QString("Set link styles for map to \"%1\"").arg(newStyleString); + QString currentStyleString0 = LinkObj::styleString(mapDesignInt->linkStyle(0)); + QString currentStyleString1 = LinkObj::styleString(mapDesignInt->linkStyle(1)); + QString currentStyleString2 = LinkObj::styleString(mapDesignInt->linkStyle(2)); + QString uc0 = QString("map.setLinkStyle (\"%1\", 0);").arg(currentStyleString0); + QString uc1 = QString("map.setLinkStyle (\"%1\", 1);").arg(currentStyleString1); + QString uc2 = QString("map.setLinkStyle (\"%1\", 2);").arg(currentStyleString2); - auto style = LinkObj::styleFromString(newStyleString); + QString rc0 = QString("map.setLinkStyle (\"StyleNoLink\", 0);"); + mapDesignInt->setLinkStyle(LinkObj::NoLink, 0); - mapDesignInt->setLinkStyle(style, depth); + QString rc1 = QString("map.setLinkStyle (\"%1\", 1);").arg(newStyleString); + mapDesignInt->setLinkStyle(style, 1); - // If whole map is used e.g. for legacy maps, only apply the "thick" part - // on first level - if (depth < 0) { - if (style == LinkObj::PolyLine) - mapDesignInt->setLinkStyle(LinkObj::Line, 1); - else if (style == LinkObj::PolyParabel) - mapDesignInt->setLinkStyle(LinkObj::Parabel, 1); + QString rc2; + if (style == LinkObj::PolyLine) { + rc2 = QString("map.setLinkStyle (\"StyleLine\", 2);"); + mapDesignInt->setLinkStyle(LinkObj::Line, 2); + } else if (style == LinkObj::PolyParabel) { + rc2 = QString("map.setLinkStyle (\"StyleParabel\", 2);"); + mapDesignInt->setLinkStyle(LinkObj::Parabel, 2); + } + saveState(uc0 + uc1 + uc2, rc0 + rc1 + rc2, com); } + applyDesignRecursively(MapDesign::LinkStyleChanged, rootItem); reposition(); @@ -7228,52 +7237,6 @@ QColor VymModel::getSelectionBrushColor() { return mapDesignInt->selectionBrush().color(); } -void VymModel::newBranchIterator( - const QString &itname, - BranchItem *bi, - bool deepLevelsFirst) -{ - Q_UNUSED(deepLevelsFirst); - - // Remove existing iterators first - branchIterators.remove(itname); - branchIteratorsCurrentIndex.remove(itname); - branchIteratorsCurrentIndex[itname] = -1; - - BranchItem *cur = nullptr; - BranchItem *prev = nullptr; - nextBranch(cur, prev, true, bi); - while (cur) { - branchIterators[itname].append(cur->getUuid()); - //qDebug() << "VM::newBranchIterator Adding " << headingText(cur) << " to " << itname; - nextBranch(cur, prev, true, bi); - } -} - -BranchItem* VymModel::nextBranchIterator(const QString &itname) -{ - //qDebug() << "VM::nextBranchIterator itname=" << itname << " index=" << branchIteratorsCurrentIndex; - if (branchIterators.keys().indexOf(itname) < 0) { - qWarning() - << QString("VM::nextIterator couldn't find %1 in hash of iterators") - .arg(itname); - return nullptr; - } - - branchIteratorsCurrentIndex[itname]++; - - if (branchIteratorsCurrentIndex[itname] < 0 || branchIteratorsCurrentIndex[itname] > branchIterators[itname].size() - 1) - return nullptr; - - BranchItem *bi = (BranchItem *)(findUuid(branchIterators[itname].at(branchIteratorsCurrentIndex[itname]))); - if (!bi) { - qWarning() << "VM::nextIterator couldn't find branch with Uuid in list."; - return nullptr; - } - - return bi; -} - void VymModel::setHideTmpMode(TreeItem::HideTmpMode mode) { if (hideMode == mode) diff --git a/src/vymmodel.h b/src/vymmodel.h index ff711c2..c779737 100644 --- a/src/vymmodel.h +++ b/src/vymmodel.h @@ -36,6 +36,8 @@ class ZipAgent; class QGraphicsScene; class QJsonObject; +// Used for getTargets() and getLinkedMaps() +// For each ID store heading and optionally also vymLink typedef QMap ItemList; class VymModel : public TreeModel { @@ -900,18 +902,6 @@ class VymModel : public TreeModel { void setSelectionBrushColor(QColor); QColor getSelectionBrushColor(); - //////////////////////////////////////////// - // Iterating and selecting branches - //////////////////////////////////////////// - public: - void newBranchIterator(const QString &itname, - BranchItem *bi = nullptr, //! All branches or only subtree - bool deepLevelsFirst = false); //! Named iterator - BranchItem* nextBranchIterator(const QString &itname); //! next branch via iterator - private: - QHash > branchIterators; - QHash branchIteratorsCurrentIndex; - //////////////////////////////////////////// // Slide related //////////////////////////////////////////// diff --git a/src/vymmodelwrapper.cpp b/src/vymmodelwrapper.cpp index f38c096..4022208 100644 --- a/src/vymmodelwrapper.cpp +++ b/src/vymmodelwrapper.cpp @@ -10,7 +10,9 @@ #include "branch-wrapper.h" #include "imageitem.h" #include "image-wrapper.h" +#include "itemlist-wrapper.h" #include "mainwindow.h" +#include "mapeditor.h" #include "misc.h" #include "vym-wrapper.h" #include "scripting-xlink-wrapper.h" @@ -25,7 +27,7 @@ VymModelWrapper::VymModelWrapper(VymModel *m) { //std::cout << "Constr VMWrapper" << this << endl; QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); - model = m; + modelInt = m; } VymModelWrapper::~VymModelWrapper() @@ -35,32 +37,32 @@ VymModelWrapper::~VymModelWrapper() void VymModelWrapper::addMapCenterAtPos(qreal x, qreal y) { - if (!model->addMapCenterAtPos(QPointF(x, y))) + if (!modelInt->addMapCenterAtPos(QPointF(x, y))) mainWindow->abortScript( QJSValue::GenericError, "Couldn't add mapcenter"); } -void VymModelWrapper::addSlide() { model->addSlide(); } +void VymModelWrapper::addSlide() { modelInt->addSlide(); } int VymModelWrapper::centerCount() { - int r = model->centerCount(); + int r = modelInt->centerCount(); mainWindow->setScriptResult(r); return r; } void VymModelWrapper::centerOnID(const QString &id) { - if (!model->centerOnID(id)) + if (!modelInt->centerOnID(id)) mainWindow->abortScript( QJSValue::GenericError, QString("Could not center on ID %1").arg(id)); } -void VymModelWrapper::copy() { model->copy(); } +void VymModelWrapper::copy() { modelInt->copy(); } -void VymModelWrapper::cut() { model->cut(); } +void VymModelWrapper::cut() { modelInt->cut(); } bool VymModelWrapper::exportMap(QJSValueList args) { @@ -81,7 +83,7 @@ bool VymModelWrapper::exportMap(QJSValueList args) if (argumentsCount == 1) { if (format == "Last") { - model->exportLast(); + modelInt->exportLast(); r = true; } else mainWindow->abortScript( @@ -96,13 +98,13 @@ bool VymModelWrapper::exportMap(QJSValueList args) filePath = args[1].toString(); if (format == "AO") { - model->exportAO(filePath, false); + modelInt->exportAO(filePath, false); } else if (format == "ASCII") { bool listTasks = false; if (argumentsCount == 3 && args[2].toString() == "true") listTasks = true; - model->exportASCII(filePath, listTasks, false); + modelInt->exportASCII(filePath, listTasks, false); } else if (format == "ConfluenceNewPage") { // 0: General export format @@ -120,7 +122,7 @@ bool VymModelWrapper::exportMap(QJSValueList args) QString url = args[2].toString(); QString pageName = args[3].toString(); - model->exportConfluence(true, url, pageName, false); + modelInt->exportConfluence(true, url, pageName, false); } else if (format == "ConfluenceUpdatePage") { // 0: General export format @@ -140,9 +142,9 @@ bool VymModelWrapper::exportMap(QJSValueList args) title = args[2].toString(); } - model->exportConfluence(false, url, title, false); + modelInt->exportConfluence(false, url, title, false); } else if (format == "CSV") { - model->exportCSV(filePath, false); + modelInt->exportCSV(filePath, false); } else if (format == "HTML") { if (argumentsCount < 3) { mainWindow->abortScript( @@ -152,7 +154,7 @@ bool VymModelWrapper::exportMap(QJSValueList args) return r; } QString dpath = args[2].toString(); - model->exportHTML(filePath, dpath, false); + modelInt->exportHTML(filePath, dpath, false); } else if (format == "Image") { QString imgFormat; if (argumentsCount == 2) @@ -175,7 +177,7 @@ bool VymModelWrapper::exportMap(QJSValueList args) mainWindow->setScriptResult(r); return r; } - model->exportImage(filePath, false, imgFormat); + modelInt->exportImage(filePath, false, imgFormat); } else if (format == "Impress") { if (argumentsCount < 3) { mainWindow->abortScript( @@ -185,23 +187,23 @@ bool VymModelWrapper::exportMap(QJSValueList args) return r; } QString templ = args[2].toString(); - model->exportImpress(filePath, templ, false); + modelInt->exportImpress(filePath, templ, false); } else if (format == "LaTeX") { - model->exportLaTeX(filePath, false); + modelInt->exportLaTeX(filePath, false); } else if (format == "Markdown") { - model->exportMarkdown(filePath, false); + modelInt->exportMarkdown(filePath, false); } else if (format == "OrgMode") { - model->exportOrgMode(filePath, false); + modelInt->exportOrgMode(filePath, false); } else if (format == "PDF") { - model->exportPDF(filePath, false); + modelInt->exportPDF(filePath, false); r = true; } else if (format == "SVG") { - model->exportSVG(filePath, false); + modelInt->exportSVG(filePath, false); r = true; } else if (format == "TaskJuggler") { - model->exportTaskJuggler(filePath, false); + modelInt->exportTaskJuggler(filePath, false); } else if (format == "XML") { - model->exportXML(filePath, false); + modelInt->exportXML(filePath, false); r = true; } else { mainWindow->abortScript( @@ -218,7 +220,7 @@ BranchWrapper* VymModelWrapper::findBranchByAttribute( const QString &key, const QString &value) { - BranchItem *bi = model->findBranchByAttribute(key, value); + BranchItem *bi = modelInt->findBranchByAttribute(key, value); if (bi) return bi->branchWrapper(); else @@ -227,7 +229,7 @@ BranchWrapper* VymModelWrapper::findBranchByAttribute( AttributeWrapper* VymModelWrapper::findAttributeById(const QString &u) { - TreeItem *ti = model->findUuid(QUuid(u)); + TreeItem *ti = modelInt->findUuid(QUuid(u)); if (ti && ti->hasTypeAttribute()) return ((AttributeItem*)ti)->attributeWrapper(); else @@ -236,7 +238,7 @@ AttributeWrapper* VymModelWrapper::findAttributeById(const QString &u) BranchWrapper* VymModelWrapper::findBranchById(const QString &u) { - TreeItem *ti = model->findUuid(QUuid(u)); + TreeItem *ti = modelInt->findUuid(QUuid(u)); if (ti && ti->hasTypeBranch()) return ((BranchItem*)ti)->branchWrapper(); else @@ -245,7 +247,7 @@ BranchWrapper* VymModelWrapper::findBranchById(const QString &u) BranchWrapper* VymModelWrapper::findBranchBySelection(const QString &s) { - TreeItem *ti = model->findBySelectString(s); + TreeItem *ti = modelInt->findBySelectString(s); if (ti && ti->hasTypeBranch()) return ((BranchItem*)ti)->branchWrapper(); else @@ -254,7 +256,7 @@ BranchWrapper* VymModelWrapper::findBranchBySelection(const QString &s) ImageWrapper* VymModelWrapper::findImageById(const QString &u) { - TreeItem *ti = model->findUuid(QUuid(u)); + TreeItem *ti = modelInt->findUuid(QUuid(u)); if (ti && ti->hasTypeImage()) return ((ImageItem*)ti)->imageWrapper(); else @@ -263,7 +265,7 @@ ImageWrapper* VymModelWrapper::findImageById(const QString &u) ImageWrapper* VymModelWrapper::findImageBySelection(const QString &s) { - TreeItem *ti = model->findBySelectString(s); + TreeItem *ti = modelInt->findBySelectString(s); if (ti && ti->hasTypeImage()) return ((ImageItem*)ti)->imageWrapper(); else @@ -272,7 +274,7 @@ ImageWrapper* VymModelWrapper::findImageBySelection(const QString &s) XLinkWrapper* VymModelWrapper::findXLinkById(const QString &u) { - TreeItem *ti = model->findUuid(QUuid(u)); + TreeItem *ti = modelInt->findUuid(QUuid(u)); if (ti && ti->hasTypeXLink()) return ((XLinkItem*)ti)->getXLink()->xlinkWrapper(); else @@ -281,83 +283,88 @@ XLinkWrapper* VymModelWrapper::findXLinkById(const QString &u) QString VymModelWrapper::getBackgroundColor() { - QString r = model->backgroundColor().name(); + QString r = modelInt->backgroundColor().name(); mainWindow->setScriptResult(r); return r; } QString VymModelWrapper::getBackgroundImageName() { - QString r = model->backgroundImageName(); + QString r = modelInt->backgroundImageName(); mainWindow->setScriptResult(r); return r; } QString VymModelWrapper::getDestPath() { - QString r = model->getDestPath(); + QString r = modelInt->getDestPath(); mainWindow->setScriptResult(r); return r; } QString VymModelWrapper::getFileDir() { - QString r = model->getFileDir(); + QString r = modelInt->getFileDir(); mainWindow->setScriptResult(r); return r; } QString VymModelWrapper::getFileName() { - QString r = model->getFileName(); + QString r = modelInt->getFileName(); mainWindow->setScriptResult(r); return r; } QString VymModelWrapper::getAuthor() { - QString r = model->mapAuthor(); + QString r = modelInt->mapAuthor(); mainWindow->setScriptResult(r); return r; } QString VymModelWrapper::getComment() { - QString r = model->mapComment(); + QString r = modelInt->mapComment(); mainWindow->setScriptResult(r); return r; } QString VymModelWrapper::getLinkColorHint() { - LinkObj::ColorHint hint = model->mapDesign()->linkColorHint(); + LinkObj::ColorHint hint = modelInt->mapDesign()->linkColorHint(); return LinkObj::linkColorHintName(hint); } QString VymModelWrapper::getTitle() { - QString r = model->mapTitle(); + QString r = modelInt->mapTitle(); mainWindow->setScriptResult(r); return r; } QString VymModelWrapper::getSelectionString() { - QString r = model->getSelectString(); + QString r = modelInt->getSelectString(); mainWindow->setScriptResult(r); return r; } +double VymModelWrapper::getZoom() +{ + return modelInt->getMapEditor()->zoomFactorTarget(); +} + bool VymModelWrapper::hasBackgroundImage() { - bool r = model->hasBackgroundImage(); + bool r = modelInt->hasBackgroundImage(); mainWindow->setScriptResult(r); return r; } bool VymModelWrapper::loadBackgroundImage(const QString &imagePath) { - bool r =model->loadBackgroundImage(imagePath); + bool r =modelInt->loadBackgroundImage(imagePath); if (!r) mainWindow->abortScript( QJSValue::GenericError, @@ -370,7 +377,7 @@ bool VymModelWrapper::loadBranchReplace(QString fileName, BranchWrapper *bw) if (QDir::isRelativePath(fileName)) fileName = QDir::currentPath() + "/" + fileName; - bool r = model->addMapReplace(fileName, bw->branchItem()); + bool r = modelInt->addMapReplace(fileName, bw->branchItem()); mainWindow->setScriptResult(r); return r; } @@ -381,36 +388,19 @@ bool VymModelWrapper::loadDataInsert(QString fileName, int pos, BranchWrapper *b fileName = QDir::currentPath() + "/" + fileName; BranchItem * bi = bw ? bw->branchItem() : nullptr; - bool r = model->addMapInsert(fileName, pos, bi); + bool r = modelInt->addMapInsert(fileName, pos, bi); mainWindow->setScriptResult(r); return r; } -void VymModelWrapper::newBranchIterator(const QString &itname, bool deepLevelsFirst) +ItemListWrapper* VymModelWrapper::itemList() { - BranchItem *bi = model->getSelectedBranch(); - if (!bi) { - mainWindow->abortScript( - QJSValue::GenericError, - "No branch selected"); - return; - } - - model->newBranchIterator(itname, bi, deepLevelsFirst); -} - -BranchWrapper* VymModelWrapper::nextBranch(const QString &itname) -{ - BranchItem *bi = model->nextBranchIterator(itname); - if (bi) - return bi->branchWrapper(); - else - return nullptr; + return new ItemListWrapper(modelInt); } void VymModelWrapper::moveSlideDown(int n) { - if (!model->moveSlideDown(n)) + if (!modelInt->moveSlideDown(n)) mainWindow->abortScript( QJSValue::GenericError, "Could not move slide down"); @@ -420,7 +410,7 @@ void VymModelWrapper::moveSlideDown() { moveSlideDown(-1); } void VymModelWrapper::moveSlideUp(int n) { - if (!model->moveSlideUp(n)) + if (!modelInt->moveSlideUp(n)) mainWindow->abortScript( QJSValue::GenericError, "Could not move slide up"); @@ -428,11 +418,11 @@ void VymModelWrapper::moveSlideUp(int n) void VymModelWrapper::moveSlideUp() { moveSlideUp(-1); } -void VymModelWrapper::paste() { model->paste(); } +void VymModelWrapper::paste() { modelInt->paste(); } -void VymModelWrapper::redo() { model->redo(); } +void VymModelWrapper::redo() { modelInt->redo(); } -void VymModelWrapper::remove() { model->deleteSelection(); } +void VymModelWrapper::remove() { modelInt->deleteSelection(); } void VymModelWrapper::removeAttribute(AttributeWrapper *aw) { @@ -442,7 +432,7 @@ void VymModelWrapper::removeAttribute(AttributeWrapper *aw) "VymModelWrapper::removeAttribute(a) a is invalid"); return; } - model->deleteSelection(aw->attributeItem()->getID()); + modelInt->deleteSelection(aw->attributeItem()->getID()); } void VymModelWrapper::removeBranch(BranchWrapper *bw) @@ -453,7 +443,7 @@ void VymModelWrapper::removeBranch(BranchWrapper *bw) "VymModelWrapper::removeBranch(b) b is invalid"); return; } - model->deleteSelection(bw->branchItem()->getID()); + modelInt->deleteSelection(bw->branchItem()->getID()); } void VymModelWrapper::removeImage(ImageWrapper *iw) @@ -464,17 +454,17 @@ void VymModelWrapper::removeImage(ImageWrapper *iw) "VymModelWrapper::removeImage(i) i is invalid"); return; } - model->deleteSelection(iw->imageItem()->getID()); + modelInt->deleteSelection(iw->imageItem()->getID()); } void VymModelWrapper::removeKeepChildren(BranchWrapper *bw) { - model->deleteKeepChildren(bw->branchItem()); + modelInt->deleteKeepChildren(bw->branchItem()); } void VymModelWrapper::removeSlide(int n) { - if (n < 0 || n >= model->slideCount() - 1) + if (n < 0 || n >= modelInt->slideCount() - 1) mainWindow->abortScript( QJSValue::GenericError, QString("Slide '%1' not available.").arg(n)); @@ -488,18 +478,18 @@ void VymModelWrapper::removeXLink(XLinkWrapper *xlw) "VymModelWrapper::removeXLink(xl) xlink is invalid"); return; } - model->deleteXLink(xlw->xlink()); + modelInt->deleteXLink(xlw->xlink()); } QVariant VymModelWrapper::repeatLastCommand() { - return model->repeatLastCommand(); + return modelInt->repeatLastCommand(); } bool VymModelWrapper::saveSelection(const QString &filename) { - QString filename_org = model->getFilePath(); // Restore filename later - if (!model->renameMap(filename)) { + QString filename_org = modelInt->getFilePath(); // Restore filename later + if (!modelInt->renameMap(filename)) { QString s = tr("Saving the selection in map failed:\nCouldn't rename map to %1").arg(filename); QMessageBox::critical(0, tr("Critical Error"), s); @@ -507,9 +497,9 @@ bool VymModelWrapper::saveSelection(const QString &filename) return false; } - bool r = model->saveMap(File::PartOfMap); + bool r = modelInt->saveMap(File::PartOfMap); - if (!model->renameMap(filename_org)) { + if (!modelInt->renameMap(filename_org)) { QString s = tr("Saving the selection in map failed:\nCouldn't rename map to %1").arg(filename); QMessageBox::critical(0, tr("Critical Error"), s); @@ -522,7 +512,7 @@ bool VymModelWrapper::saveSelection(const QString &filename) bool VymModelWrapper::select(const QString &s) { - bool r = model->select(s); + bool r = modelInt->select(s); if (!r) mainWindow->abortScript( QJSValue::GenericError, @@ -533,7 +523,7 @@ bool VymModelWrapper::select(const QString &s) AttributeWrapper* VymModelWrapper::selectedAttribute() { - AttributeItem *ai = model->getSelectedAttribute(); + AttributeItem *ai = modelInt->getSelectedAttribute(); if (ai) return ai->attributeWrapper(); @@ -543,7 +533,7 @@ AttributeWrapper* VymModelWrapper::selectedAttribute() BranchWrapper* VymModelWrapper::selectedBranch() { - BranchItem *selbi = model->getSelectedBranch(); + BranchItem *selbi = modelInt->getSelectedBranch(); if (selbi) return selbi->branchWrapper(); @@ -553,7 +543,7 @@ BranchWrapper* VymModelWrapper::selectedBranch() XLinkWrapper* VymModelWrapper::selectedXLink() { - XLinkItem *xli = model->getSelectedXLinkItem(); + XLinkItem *xli = modelInt->getSelectedXLinkItem(); if (xli) return xli->getXLink()->xlinkWrapper(); @@ -578,7 +568,7 @@ bool VymModelWrapper::selectUids(QJSValueList args) foreach (auto arg, args) uids << arg.toString(); - r = model->selectUids(uids); + r = modelInt->selectUids(uids); if (!r) mainWindow->abortScript( QJSValue::GenericError, @@ -589,7 +579,7 @@ bool VymModelWrapper::selectUids(QJSValueList args) bool VymModelWrapper::selectLatestAdded() { - bool r = model->selectLatestAdded(); + bool r = modelInt->selectLatestAdded(); if (!r) mainWindow->abortScript( QJSValue::GenericError, @@ -607,22 +597,22 @@ void VymModelWrapper::setAnimCurve(int n) else { QEasingCurve c; c.setType((QEasingCurve::Type)n); - model->setMapAnimCurve(c); + modelInt->setMapAnimCurve(c); } } void VymModelWrapper::setAnimDuration(int n) { - model->setMapAnimDuration(n); + modelInt->setMapAnimDuration(n); } -void VymModelWrapper::setAuthor(const QString &s) { model->setMapAuthor(s); } +void VymModelWrapper::setAuthor(const QString &s) { modelInt->setMapAuthor(s); } void VymModelWrapper::setBackgroundColor(const QString &color) { QColor col(color); if (col.isValid()) { - model->setBackgroundColor(col); + modelInt->setBackgroundColor(col); } else mainWindow->abortScript( @@ -632,14 +622,14 @@ void VymModelWrapper::setBackgroundColor(const QString &color) void VymModelWrapper::setBackgroundImageName(const QString &name) { - model->setBackgroundImageName(name); + modelInt->setBackgroundImageName(name); } void VymModelWrapper::setDefaultLinkColor(const QString &color) { QColor col(color); if (col.isValid()) { - model->setDefaultLinkColor(col); + modelInt->setDefaultLinkColor(col); } else mainWindow->abortScript( @@ -647,27 +637,27 @@ void VymModelWrapper::setDefaultLinkColor(const QString &color) QString("Could not set color to %1").arg(color)); } -void VymModelWrapper::setComment(const QString &s) { model->setMapComment(s); } +void VymModelWrapper::setComment(const QString &s) { modelInt->setMapComment(s); } void VymModelWrapper::setLinkColorHint(const QString &hintName) { LinkObj::ColorHint hint = LinkObj::linkColorHint(hintName); - model->setLinkColorHint(hint); + modelInt->setLinkColorHint(hint); } -void VymModelWrapper::setLinkStyle(const QString &style) +void VymModelWrapper::setLinkStyle(const QString &style, int depth) { - if (!model->setLinkStyle(style)) + if (!modelInt->setLinkStyle(style, depth)) mainWindow->abortScript( QJSValue::GenericError, - QString("Could not set linkstyle to %1").arg(style)); + QString("Could not set linkstyle to %1 with d=%2").arg(style, depth)); } -void VymModelWrapper::setRotationView(float a) { model->setMapRotation(a); } +void VymModelWrapper::setRotationView(float a) { modelInt->setMapRotation(a); } -void VymModelWrapper::setTitle(const QString &s) { model->setMapTitle(s); } +void VymModelWrapper::setTitle(const QString &s) { modelInt->setMapTitle(s); } -void VymModelWrapper::setZoom(float z) { model->setMapZoomFactor(z); } +void VymModelWrapper::setZoom(float z) { modelInt->setMapZoomFactor(z); } void VymModelWrapper::setSelectionBrushColor(const QString &color) { @@ -678,7 +668,7 @@ void VymModelWrapper::setSelectionBrushColor(const QString &color) QJSValue::GenericError, QString("Could not set color to %1").arg(color)); else - model->setSelectionBrushColor(col); + modelInt->setSelectionBrushColor(col); } void VymModelWrapper::setSelectionPenColor(const QString &color) @@ -689,12 +679,12 @@ void VymModelWrapper::setSelectionPenColor(const QString &color) QJSValue::GenericError, QString("Could not set color to %1").arg(color)); else - model->setSelectionPenColor(col); + modelInt->setSelectionPenColor(col); } void VymModelWrapper::setSelectionPenWidth(const qreal &w) { - model->setSelectionPenWidth(w); + modelInt->setSelectionPenWidth(w); } void VymModelWrapper::sleep(int n) @@ -706,16 +696,16 @@ void VymModelWrapper::sleep(int n) int VymModelWrapper::slideCount() { - int r = model->slideCount(); + int r = modelInt->slideCount(); mainWindow->setScriptResult(r); return r; } -void VymModelWrapper::undo() { model->undo(); } +void VymModelWrapper::undo() { modelInt->undo(); } -void VymModelWrapper::unselectAll() { model->unselectAll(); } +void VymModelWrapper::unselectAll() { modelInt->unselectAll(); } void VymModelWrapper::unsetBackgroundImage() { - model->unsetBackgroundImage(); + modelInt->unsetBackgroundImage(); } diff --git a/src/vymmodelwrapper.h b/src/vymmodelwrapper.h index 9ff5af1..21f9061 100644 --- a/src/vymmodelwrapper.h +++ b/src/vymmodelwrapper.h @@ -10,6 +10,7 @@ class BranchItem; class AttributeWrapper; class BranchWrapper; class ImageWrapper; +class ItemListWrapper; class VymModel; class XLinkWrapper; @@ -44,6 +45,7 @@ class VymModelWrapper : public QObject { QString getTitle(); QString getLinkColorHint(); QString getSelectionString(); + double getZoom(); bool hasBackgroundImage(); bool loadBackgroundImage(const QString &imagePath); bool loadBranchReplace(QString filename, BranchWrapper *bw); @@ -52,8 +54,7 @@ class VymModelWrapper : public QObject { void moveSlideDown(); void moveSlideUp(int n); void moveSlideUp(); - void newBranchIterator(const QString &itname, bool deepLevelsFirst = false); - Q_INVOKABLE BranchWrapper* nextBranch(const QString &itname); + Q_INVOKABLE ItemListWrapper* itemList(); void paste(); void redo(); void remove(); @@ -78,7 +79,7 @@ class VymModelWrapper : public QObject { void setBackgroundColor(const QString &color); void setBackgroundImageName(const QString &name); void setComment(const QString &s); - void setLinkStyle(const QString &style); + void setLinkStyle(const QString &style, int depth = -1); void setLinkColorHint(const QString &hint); void setRotationView(float a); void setTitle(const QString &s); @@ -93,7 +94,7 @@ class VymModelWrapper : public QObject { void unsetBackgroundImage(); private: - VymModel *model; + VymModel *modelInt; }; #endif diff --git a/styles/vym-dark.css b/styles/vym-dark.css new file mode 100644 index 0000000..51471ce --- /dev/null +++ b/styles/vym-dark.css @@ -0,0 +1,170 @@ +html { + font-family:arial,sans-serif; +} + +body { + margin:0; + padding:10px; + font-family:arial, + sans-serif; + align:center; + background-color:#1B1E20; +} + +a, a:visited, a:link, a:active { + color:#666666; + text-decoration:none; +} + +a:hover { + text-decoration:underline; +} + +/* VYM specific elements*/ + +.vym-header{ + width:96%; + padding:2%; + margin-bottom:10px; + border:solid 1px black; + background-color:#f0f0f0; + text-align:center; + vertical-align:center; + font-size: 2em; +} +.vym-toc{ + background-color: #F9F9F9; + border: 1px solid #AAAAAA; + font-size: 95%; + padding: 5px +} +.vym-toc-title{ + background-color: #F9F9F9; + font-size: 100%; +} +.vym-toc-branch-0{ text-indent: 0em; } +.vym-toc-branch-1{ text-indent: 1em; } +.vym-toc-branch-2{ text-indent: 2em; } +.vym-toc-branch-3{ text-indent: 3em; } +.vym-toc-branch-4{ text-indent: 4em; } +.vym-toc-branch-5{ text-indent: 5em; } +.vym-toc-branch-6{ text-indent: 6em; } +.vym-toc-branch-7{ text-indent: 7em; } +.vym-toc-branch-8{ text-indent: 8em; } +.vym-toc-branch-9{ text-indent: 9em; } +.vym-toc-number{ } +.vym-toc-text{ } +.vym-imagemap{ + width:96%; + padding:2%; + margin-bottom:10px; + border: 0px; + text-align:center; + vertical-align:center; +} +.imagemap{ + border: 0px; +} +.vym-BoxBottom { + padding:10px; + font-size:0.7em; + border:solid 1px black; + margin:0; + background-color:#f0f0f0; +} +.vym-BoxBottomR +{ + padding-top:1em; + color:#676767; + text-align:right; +} +.vym-footer { + width:100%; + border:1; +} +.vym-footerL { font-size:0.7em; color:#676767; text-align:left; width:33%} +.vym-footerC { font-size:0.7em; color:#676767; text-align:center; width:33%} +.vym-footerR { font-size:0.7em; color:#676767; text-align:right; width:33%} + +.vym-url {} + +.vym-branch-0 { +} +.vym-branch-1{ +} +.vym-branch-2{ + font-size: small; + font-weight: normal; +} +.vym-branch-3{ + font-size: small; + font-weight: normal; +} +.vym-branch-4{ + font-size: small; + font-weight: normal; +} +.vym-branch-5{ + font-size: small; + font-weight: normal; +} +.vym-branch-6{ + font-size: small; + font-weight: normal; +} +.vym-branch-7{ + font-size: small; + font-weight: normal; +} + +.vym-branch-8{ + font-size: small; + font-weight: normal; +} +.vym-branch-9{ + font-size: small; + font-weight: normal; +} +.vym-note { + width:80%; + border: solid 1px black; + border-radius: 0.6em 0.6em 0.6em 0.6em; + border-color: #000000; + background-color: #eeeeee; + font-size: small; + font-weight: normal; + overflow: auto; + padding: 0em 1em; +} + +.vym-note-flag { + vertical-align:top; + width:30px; + height:30px; + background-image: url("flags/flag-note.png"); + background-repeat: no-repeat; + background-position: left top; +} + +.vym-note-paragraph { + margin-top: 0px; + margin-bottom: 1em; +} + +.vym-fixed-note-paragraph { + margin: 0; +} +.standardflag { + margin-left: 5px; +} + +.vym-list-ul-0 { + list-style-type: none; + list-style-position: inside; +} + +.vym-list-ul-1 { + list-style-type: none; + list-style-position: outside; +} + diff --git a/vym.qrc b/vym.qrc index 593d4af..0296628 100644 --- a/vym.qrc +++ b/vym.qrc @@ -15,7 +15,7 @@ flags/standard/dialog-ok-apply.svg flags/standard/help-about.svg flags/standard/Dialog-information_on.svg - flags/standard/help-contextual.svg + flags/standard/help-content.svg flags/system/no-arrow-up.png flags/system/klipper.svg flags/standard/internet-telephony.svg