From: Sven Hoexter Date: Fri, 3 May 2024 12:10:12 +0000 (+0200) Subject: Import Upstream version 2.6.11 X-Git-Tag: upstream/2.6.11^0 X-Git-Url: https://git.sven.stormbind.net/?a=commitdiff_plain;h=7dfa3fe589d1722d49681f42cdb0bf1e6efb5223;p=sven%2Fvym.git Import Upstream version 2.6.11 --- 7dfa3fe589d1722d49681f42cdb0bf1e6efb5223 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..81102ba --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,334 @@ +project( vym ) +cmake_minimum_required( VERSION 2.6 ) + +if( NOT CMAKE_BUILD_TYPE ) + set( CMAKE_BUILD_TYPE Debug ) +endif( NOT CMAKE_BUILD_TYPE ) + +if( CMAKE_COMPILER_IS_GNUCXX ) + add_definitions ( -Wall ) +endif( CMAKE_COMPILER_IS_GNUCXX ) + +if( UNIX AND NOT APPLE ) + set( NO_DBUS_DEFAULT OFF ) +else( UNIX AND NOT APPLE ) + set( NO_DBUS_DEFAULT ON ) +endif( UNIX AND NOT APPLE ) + +option( NO_DBUS "Build vym without dbus support" ${NO_DBUS_DEFAULT} ) + +find_package ( Qt4 REQUIRED ) +include ( ${QT_USE_FILE} ) +add_definitions( ${QT_DEFINITIONS} ) + +if( WIN32 ) + add_definitions( -DUNICODE -D_USE_MATH_DEFINES ) + if( MSVC ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-" ) + endif( MSVC ) +endif( WIN32 ) + +find_package( cppcheck ) +if(CPPCHECK_FOUND) + set(_cppcheck_args) + list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${CMAKE_SOURCE_DIR}) +# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTCORE_INCLUDE_DIR}) +# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTDBUS_INCLUDE_DIR}) +# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTGUI_INCLUDE_DIR}) +# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTNETWORK_INCLUDE_DIR}) +# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTXML_INCLUDE_DIR}) +# list(APPEND _cppcheck_args ${CPPCHECK_INCLUDEPATH_ARG} ${QT_QTSVG_INCLUDE_DIR}) + + list(APPEND _cppcheck_args "enable" "all") + + add_custom_target( + cppcheck + COMMAND + "${CPPCHECK_EXECUTABLE}" + ${CPPCHECK_TEMPLATE_ARG} + ${CPPCHECK_QUIET_ARG} + "--force" +# "--std=c++11" + ${_cppcheck_args} + ${CMAKE_SOURCE_DIR} + ) + + message(STATUS "cppcheck target added.") +endif(CPPCHECK_FOUND) + +include_directories ( + ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} + ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTXML_INCLUDE_DIR} ${QT_QTSVG_INCLUDE_DIR} + ) + +if(NOT NO_DBUS ) + include_directories( ${QT_QTDBUS_INCLUDE_DIR} ) +endif(NOT NO_DBUS ) + +set ( vym_HDRS + aboutdialog.h + taskfiltermodel.h + animpoint.h + attribute.h + attributeitem.h + # attributedelegate.h + # attributedialog.h + # attributewidget.h + branchitem.h + branchobj.h + branchpropeditor.h + bugagent.h + command.h + dockeditor.h + downloadagent.h + editxlinkdialog.h + exportoofiledialog.h + exporthtmldialog.h + exports.h + extrainfodialog.h + file.h + findwidget.h + findresultwidget.h + findresultitem.h + findresultmodel.h + flag.h + flagobj.h + flagrowobj.h + flagrow.h + floatimageobj.h + floatobj.h + frameobj.h + geometry.h + headingeditor.h + headingobj.h + highlighter.h + historywindow.h + imageitem.h + imageobj.h + imports.h + lineeditdialog.h + linkablemapobj.h + macros.h + mainwindow.h + mapeditor.h + mapitem.h + mapobj.h + misc.h + mysortfilterproxymodel.h + noteeditor.h + noteobj.h + options.h + ornamentedobj.h + parser.h + process.h + scripteditor.h + settings.h + shortcuts.h + showtextdialog.h + slidecontrolwidget.h + slideeditor.h + slideitem.h + slidemodel.h + task.h + taskeditor.h + taskmodel.h + treedelegate.h + treeeditor.h + treeitem.h + treemodel.h + texteditor.h + version.h + vymmodel.h + vymview.h + winter.h + warningdialog.h + xlink.h + xlinkitem.h + xlinkobj.h + xml-base.h + xml-vym.h + xml-freemind.h + xmlobj.h + xsltproc.h + ) + +set ( vym_SRCS + aboutdialog.cpp + taskfiltermodel.cpp + animpoint.cpp + attribute.cpp + attributeitem.cpp + # attributedelegate.cpp + # attributedialog.cpp + # attributewidget.cpp + branchitem.cpp + branchobj.cpp + branchpropeditor.cpp + bugagent.cpp + command.cpp + dockeditor.cpp + downloadagent.cpp + editxlinkdialog.cpp + exportoofiledialog.cpp + exports.cpp + exporthtmldialog.cpp + extrainfodialog.cpp + file.cpp + findwidget.cpp + findresultwidget.cpp + findresultitem.cpp + findresultmodel.cpp + flag.cpp + flagobj.cpp + flagrow.cpp + flagrowobj.cpp + floatimageobj.cpp + floatobj.cpp + frameobj.cpp + geometry.cpp + headingeditor.cpp + headingobj.cpp + highlighter.cpp + historywindow.cpp + imageitem.cpp + imageobj.cpp + imports.cpp + lineeditdialog.cpp + linkablemapobj.cpp + macros.cpp + main.cpp + mainwindow.cpp + mapeditor.cpp + mapitem.cpp + mapobj.cpp + misc.cpp + mysortfilterproxymodel.cpp + noteeditor.cpp + noteobj.cpp + options.cpp + ornamentedobj.cpp + parser.cpp + process.cpp + scripteditor.cpp + settings.cpp + shortcuts.cpp + showtextdialog.cpp + slidecontrolwidget.cpp + slideeditor.cpp + slideitem.cpp + slidemodel.cpp + task.cpp + taskeditor.cpp + taskmodel.cpp + texteditor.cpp + treedelegate.cpp + treeeditor.cpp + treeitem.cpp + treemodel.cpp + version.cpp + vymmodel.cpp + vymview.cpp + winter.cpp + warningdialog.cpp + xlink.cpp + xlinkitem.cpp + xlinkobj.cpp + xml-base.cpp + xml-vym.cpp + xml-freemind.cpp + xmlobj.cpp + xsltproc.cpp + ) + +set ( vym_UIS + attributewidget.ui + branchpropeditor.ui + exporthtmldialog.ui + extrainfodialog.ui + editxlinkdialog.ui + historywindow.ui + lineeditdialog.ui + scripteditor.ui + showtextdialog.ui + warningdialog.ui + ) +QT4_WRAP_UI(UIS ${vym_UIS}) + +set ( vym_TRS + lang/vym_de_DE.ts + lang/vym_en.ts + lang/vym_es.ts + lang/vym_fr.ts + lang/vym_it.ts + lang/vym_pt_BR.ts + lang/vym_ru.ts + lang/vym_sv.ts + lang/vym_zh_CN.ts + lang/vym_zh_TW.ts + lang/vym_cs_CZ.ts + ) +QT4_ADD_TRANSLATION(TRS ${vym_TRS}) + +set ( vym_MOCS + aboutdialog.h + branchpropeditor.h + bugagent.h + dockeditor.h + downloadagent.h + editxlinkdialog.h + exportoofiledialog.h + exporthtmldialog.h + extrainfodialog.h + findwidget.h + findresultwidget.h + findresultmodel.h + headingeditor.h + highlighter.h + historywindow.h + lineeditdialog.h + mainwindow.h + mapeditor.h + mysortfilterproxymodel.h + noteeditor.h + process.h + scripteditor.h + showtextdialog.h + slidecontrolwidget.h + slideeditor.h + slidemodel.h + taskeditor.h + taskmodel.h + treedelegate.h + treeeditor.h + treemodel.h + texteditor.h + vymmodel.h + vymview.h + winter.h + warningdialog.h + ) +if( NOT NO_DBUS ) + add_definitions(-DVYM_DBUS) + list(APPEND vym_HDRS adaptormodel.h adaptorvym.h) + list(APPEND vym_SRCS adaptormodel.cpp adaptorvym.cpp) + list(APPEND vym_MOCS adaptormodel.h adaptorvym.h) +endif( NOT NO_DBUS ) +QT4_WRAP_CPP(MOCS ${vym_MOCS}) + + + +if( WIN32 ) + set( vym_SRCS ${vym_SRCS} mkdtemp.cpp vym.rc ) +endif( WIN32 ) + +add_executable ( vym WIN32 ${vym_SRCS} ${UIS} ${RSCS} ${TRS} ${MOCS} ) +target_link_libraries ( vym ${QT_QTMAIN_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTSVG_LIBRARY} ) +if( NOT NO_DBUS ) + target_link_libraries( vym ${QT_QTDBUS_LIBRARY} ) +endif( NOT NO_DBUS ) + +install( TARGETS vym RUNTIME DESTINATION bin ) + +set( _installfolders demos exports flags icons macros scripts styles ) +install( DIRECTORY ${_installfolders} DESTINATION share/vym ) +install( FILES ${TRS} DESTINATION share/vym/lang ) diff --git a/INSTALL.txt b/INSTALL.txt new file mode 100644 index 0000000..ad33349 --- /dev/null +++ b/INSTALL.txt @@ -0,0 +1,18 @@ +Installation of vym - view your mind +==================================== + +Mac OSX: + +Drag the vym application to your desktop, or if you have admin rights, +directly to your Application folder + + +Please check the vym webpage for installation tipps: + + http://www.insilmaril.de/vym + +For general questions please contact the vym mailinglist: + + vym-forum@lists.sourceforge.net + + diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..586634e --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,307 @@ + VYM - View Your Mind + Copyright (C) 2004-2016 Uwe Drechsel + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as published by + the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License below for more details. + + In addition, as a special exception, Uwe Drechsel + gives permission to link the code of this program with the QT + libraries from trolltech.com (or with modified versions of QT that + use the same license as QT), and distribute linked combinations + including the two. You must obey the GNU General Public License in + all respects for all of the code used other than QT. If you modify + this file, you may extend this exception to your version of the + file, but you are not obligated to do so. If you do not wish to do + so, delete this exception statement from your version. + + + Uwe Drechsel can be contacted at + +----------------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md new file mode 100644 index 0000000..6334cde --- /dev/null +++ b/README.md @@ -0,0 +1,83 @@ +###VYM - View Your Mind (c) 2004-2017 by Uwe Drechsel### + +Documentation +------------- + +* PDF + + The complete documentation of vym is available as PDF document in + english and spanish. (The spanish version is not really up to date, + translators are welcome). It can be accessed directly from vym via + the help section It also can be downloaded from the vym site at + Sourceforge: + + https://sourceforge.net/projects/vym/ + +* Screencasts + + There are several screencasts available on YouTube, which show some + feature of vym and how to use them: + + http://www.youtube.com/user/ViewYourMind + + +Download +-------- + +The official downloads for all platforms are available at the project +site: + + https://sourceforge.net/projects/vym/ + +The latest binaries for Linux (currently mainly openSUSE) are found in the +Open Build Service project of Uwe Drechsel (aka insilmaril): + + http://download.opensuse.org/repositories/home%3A//insilmaril/ + + + +Installation +------------ + +* Binaries + + Installation depends on the platform you use, please check the + homepage for details: + + http://www.insilmaril.de/vym + +* Compiling + + Compiling vym from scratch is pretty easy, if you have the + development packages of the Qt5 toolkit installed. (Check also the + homepage above for details): + + qmake + make + make install + +* Testing (without installing!) + + You can also run vym virtually in your webbrowser: vym is available + as appliance in SUSE Studio. SUSE Studio is a very easy way to + create appliances, which are customized Linux operating systems. + + All you need is to quickly create a free account and search for + "vym" by user "insilmaril" in the gallery: + + http://susestudio.com + + The appliance can be downloaded as installable iso image, or run in + the testdrive - in your webbrowser! That's a bit slow, but gives you + an idea without having to install anything at all on your system. + + +Questions and feedback +---------------------- + +Please direct questions to the mailinglist first: + + vym-forum@lists.sourceforge.net + + + diff --git a/aboutdialog.cpp b/aboutdialog.cpp new file mode 100644 index 0000000..8d3ae05 --- /dev/null +++ b/aboutdialog.cpp @@ -0,0 +1,251 @@ +#include +#include +#include +#include + +#include "aboutdialog.h" +#include "settings.h" + + +extern Settings settings; +extern QString iconPath; // FIXME-4 embed vym logo as ressource? +extern QString vymVersion; +extern QString vymBuildDate; +extern QString vymCodeName; + +AboutDialog::AboutDialog( QWidget *parent) + : QDialog( parent) +{ + + mainLayout=new QVBoxLayout( this); + + tabs=new QTabWidget (this); + credits=new AboutTextBrowser (parent); + + credits->setHtml( QString( + "
" + "

VYM - View Your Mind

" + "

A tool to put the things you have got in your mind into a map.

" + "

(c) 2004-%1 by Uwe Drechsel (vym@InSilmaril.de)

" + "

Version " +vymVersion+" - " +vymBuildDate+"

" + "

" +vymCodeName+"

" + "
    " + "
  • Contact
  • " + "" + "
  • Credits " + "
      " + "
    • Documentation" + "
        " + "
      • Peter Adams: documentation proofreading and polishing
      • " + "
      " + "
    • " + "
    • Translation" + "
        " + "
      • Brasilian: Amadeu Júnior
      • " + "
      • Chinese (simplified): Moligaloo
      • " + "
      • Chinese (traditional): Wei-Lun Chao
      • " + "
      • Croatian: Damir BraÅ¡nić
      • " + "
      • Czech: Pavel Fric
      • " + "
      • French: Marc Sert, Philippe Caillaud and Claude
      • " + "
      • Greek: Yannis Kaskamanidis
      • " + "
      • Interlingua: Giovanni Sora
      • " + "
      • Italian: Giovanni Sora, Seyed Puria Nafisi Azizi
      • " + "
      • Japanese: Tsuren Tsuchiya
      • " + "
      • Russian: Anton Olenev
      • " + "
      • Spanish: " + " ACLibre (Academia y Conocimiento Libre) and David Amian
      • " + "
      " + "
    • " + "
    • Patches" + "
        " + "
      • Darren Lissimore: Windows compiler patch
      • " + "
      • Konstantin Goudkov: sort branches
      • " + "
      • Jakob Hilmer: image drag and drop in 1.8.1, "About vym" window patch
      • " + "
      • Edward Wang: adding close tab buttons
      • " + "
      • p0llox (Pierre): various patches for Debian packaging
      • " + "
      " + "
    • " + "
    • Patches in previous vym versions" + "
        " + "
      • Łukasz Pietrzak, Scott Dillman and Patrick Spendrin, Andrew Ng, " + "Juha Ruotsalainen and Thomas Kriener: windows patches
      • " + "
      • Thomas Schraitle for the stylesheet" + " formerly used for XHTML-export and help with XML processing in general
      • " + "
      • Matt from www.satbp.com: " + " Taskjuggler export
      • " + "
      " + "
    • " + "
    • Packaging" + "
    • " + "
        " + "
      • Jon Ciesla: Sourceforge file releases
      • " + "
      • Xavier Oswald, Christoph Thielecke, Pierre, and Steffen Joeris: Debian packaging
      • " + "
      " + "
    • General" + "
        " + "
      • CMake setup by Costantino Giuliodori and Patrick Spendrin
      • " + "
      • All the guys at Trolltech (now Digia) for their Qt toolkit
      • " + "
      • All the guys at SUSE Linux for openSUSE Linux and support," + " e.g. to get Linux running on PowerPC and also Macbooks
      • " + "
      " + "
    • " + "
    " + "
  • ").arg( QDate::currentDate().year() ) );; + credits->setFrameStyle( QFrame::Panel | QFrame::Plain ); + tabs->addTab (credits, tr("Credits","Help->About vym dialog")); + + license=new AboutTextBrowser (parent); + license->setText ( QString( + "
    " + "

    VYM - View Your Mind

    " + "

    Copyright (C) 2004-%1 Uwe Drechsel

    " + "
    " + + "

    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

    " + + "

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License below for more details.

    " + + "

    In addition, as a special exception, Uwe Drechsel gives permission to link the code of this program with the QT libraries from trolltech.com (or with modified versions of QT that use the same license as QT), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than QT. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.

    " + + "

    Uwe Drechsel can be contacted at vym@insilmaril.de

    " + + "
    " + + "

    GNU GENERAL PUBLIC LICENSE
    " +"Version 2, June 1991

    " + +"

    Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

    " + +"

    Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

    " + +"

    Preamble

    " + +"

    The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

    " + +"

    When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

    " + +"

    To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

    " + +"

    For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

    " + +"

    We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

    " + +"

    Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

    " + +"

    Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

    " + +"

    The precise terms and conditions for copying, distribution and modification follow.

    " + +"

    GNU GENERAL PUBLIC LICENSE

    " +"

    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

    " + +"

    0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The \"Program\", below, refers to any such program or work, and a \"work based on the Program\" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term \"modification\".) Each licensee is addressed as \"you\".

    " + +"

    Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

    " + +"

    1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

    " + +"

    You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

    " + +"

    2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:" +"

      " + "
    1. You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
    2. " + + "
    3. You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
    4. " + + "
    5. If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
    6. " +"
    " +"

    " + +"

    These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

    " + +"

    Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

    " + +"

    In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

    " + +"

    3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:" "

      " + +"
    1. Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
    2. " + +"
    3. Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
    4. " + +"
    5. Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
    6. " +"

    " + +"

    The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

    " + +"

    If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

    " + +"

    4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

    " + +"

    5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.

    " + +"

    6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

    " + +"

    7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

    " + +"

    If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

    " + +"

    It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

    " + +"

    This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

    " + +"

    8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.

    " + +"

    9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

    " + +"

    Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and \"any later version\", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

    " + +"

    10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

    " + +"

    NO WARRANTY

    " + +"

    11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

    " + +"

    12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

    " + +"

    END OF TERMS AND CONDITIONS

    ").arg( QDate::currentDate().year() ) ); + + credits->setFrameStyle( QFrame::Panel | QFrame::Plain ); + tabs->addTab (license, tr("License","Help->About vym dialog")); + + mainLayout->addWidget (tabs); + + okbutton =new QPushButton (this); + okbutton->setText (tr("Ok","Ok Button")); + okbutton->setMaximumSize (QSize (50,30)); + okbutton->setAutoDefault (true); + mainLayout->addWidget( okbutton); + + connect( okbutton, SIGNAL( clicked() ), this, SLOT( accept() ) ); +} + +AboutTextBrowser::AboutTextBrowser(QWidget *parent) + : QTextBrowser(parent) +{ +} + +void AboutTextBrowser::setSource(const QUrl &url ) +{ + QProcess *proc= new QProcess (); + proc->start( settings.value("/system/readerURL").toString(),QStringList ()<waitForStarted() &&mainWindow->settingsURL() ) setSource(url); + if (!proc->waitForStarted() ) + QMessageBox::warning(0, + tr("Warning","About window"), + tr("Couldn't find a viewer to open %1.\n","About window").arg(url.toString())+ + tr("Please use Settings->")+tr("Set application to open an URL...")); + +} diff --git a/aboutdialog.h b/aboutdialog.h new file mode 100644 index 0000000..c5a0dfd --- /dev/null +++ b/aboutdialog.h @@ -0,0 +1,72 @@ +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include +#include +#include +#include +#include +#include +#include + +class AboutTextBrowser; + +/*! \mainpage View Your Mind - Development documentation + + \section intro_sec Introduction + +VYM (View Your Mind) is a tool to generate and manipulate maps which +show your thoughts. Such maps can help you to improve your creativity +and effectivity. You can use them for time management, to organize +tasks, to get an overview over complex contexts, to sort your ideas +etc. Some people even think it is fun to work with such maps... + + + \section install_sec Installation + + Please look at the INSTALL.TXT file + + \section doc_sec Documentation + + The complete documentation is available as a PDF file. Please look + into the doc subdirectory. + +*/ + + + +/*! \brief Dialog showing authors, version and license +*/ + + +class AboutDialog :public QDialog +{ + Q_OBJECT + +public: + AboutDialog(QWidget* parent = 0); + +private: + QTabWidget *tabs; + AboutTextBrowser *credits; + AboutTextBrowser *license; + + QLayout *mainLayout; + QLayout *topLayout; + QLayout *bottomLayout; + QPushButton *okbutton; + +}; + +/*! \brief Overloaded QTextBrowser which is used in AboutDialog +*/ +class AboutTextBrowser : public QTextBrowser +{ + Q_OBJECT; + public: + AboutTextBrowser(QWidget *parent); + public slots: + virtual void setSource(const QUrl &url); +}; + +#endif diff --git a/adaptormodel.cpp b/adaptormodel.cpp new file mode 100644 index 0000000..27ddd8f --- /dev/null +++ b/adaptormodel.cpp @@ -0,0 +1,68 @@ +#include "adaptormodel.h" +#include +#include +#include + +#include "branchitem.h" +#include "mainwindow.h" +#include "vymmodel.h" + +extern QString vymInstanceName; +extern Main *mainWindow; + +AdaptorModel::AdaptorModel(QObject *obj) + : QDBusAbstractAdaptor(obj) +{ + model=static_cast (obj); + setAutoRelaySignals (true); +} + +void AdaptorModel::setModel(VymModel *vm) +{ + model=vm; +} + +QString AdaptorModel::caption() +{ + return m_caption; +} + +void AdaptorModel::setCaption (const QString &newCaption) +{ + m_caption=newCaption; +} + +QDBusVariant AdaptorModel::getCurrentModelID() +{ + return QDBusVariant (mainWindow->currentModelID()); +} + +QDBusVariant AdaptorModel::branchCount() +{ + BranchItem *selbi=model->getSelectedBranch(); + if (selbi) + return QDBusVariant (selbi->branchCount() ); + else + return QDBusVariant (-1 ); +} + +QDBusVariant AdaptorModel::execute (const QString &s) +{ + return QDBusVariant (model->execute (s)); +} + +QDBusVariant AdaptorModel::errorLevel() +{ + return QDBusVariant (model->parser.errorLevel() ); +} + +QDBusVariant AdaptorModel::errorDescription() +{ + return QDBusVariant (model->parser.errorDescription() ); +} + +QDBusVariant AdaptorModel::listCommands () +{ + return QDBusVariant (model->parser.getCommands().join(",") ); +} + diff --git a/adaptormodel.h b/adaptormodel.h new file mode 100644 index 0000000..eeb61e6 --- /dev/null +++ b/adaptormodel.h @@ -0,0 +1,39 @@ +#ifndef ADAPTORModel_H +#define ADAPTORModel_H + +#include +#include + +class VymModel; +class QString; + +class AdaptorModel: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.insilmaril.vym.model.adaptor") + +private: + VymModel *model; + +public: + AdaptorModel(QObject *obj); + void setModel (VymModel *vm); + +public: // PROPERTIES + QString m_caption; + QString caption(); + void setCaption(const QString &newCaption); + +public slots: // METHODS + QDBusVariant getCurrentModelID(); + QDBusVariant branchCount(); + QDBusVariant execute (const QString &s); + QDBusVariant errorLevel(); + QDBusVariant errorDescription(); + QDBusVariant listCommands(); + +Q_SIGNALS: // SIGNALS + void crashed(); +}; + +#endif diff --git a/adaptorvym.cpp b/adaptorvym.cpp new file mode 100644 index 0000000..5bff85c --- /dev/null +++ b/adaptorvym.cpp @@ -0,0 +1,41 @@ +#include +#include +#include + +#include "adaptorvym.h" +#include "mainwindow.h" + +extern QString vymInstanceName; +extern QString vymVersion; +extern Main *mainWindow; + +AdaptorVym::AdaptorVym(QObject *obj) + : QDBusAbstractAdaptor(obj) +{ + setAutoRelaySignals (true); +} + +QDBusVariant AdaptorVym::modelCount() +{ + return QDBusVariant (mainWindow->modelCount() ); +} + +void AdaptorVym::gotoModel(const int &n) +{ + mainWindow->gotoWindow (n); +} + +QDBusVariant AdaptorVym::getInstanceName() +{ + return QDBusVariant (vymInstanceName); +} + +QDBusVariant AdaptorVym::getVersion() +{ + return QDBusVariant (vymVersion); +} + +QDBusVariant AdaptorVym::execute(const QString &s) +{ + return QDBusVariant (mainWindow->execute (s) ); +} diff --git a/adaptorvym.h b/adaptorvym.h new file mode 100644 index 0000000..6e867f3 --- /dev/null +++ b/adaptorvym.h @@ -0,0 +1,28 @@ +#ifndef ADAPTORVYM_H +#define ADAPTORVYM_H + +#include +#include + +class MainWindow; + +class AdaptorVym: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.insilmaril.vym.main.adaptor") + +public: + AdaptorVym (QObject *obj); + +public slots: // METHODS + QDBusVariant modelCount (); + void gotoModel (const int &n); + QDBusVariant getInstanceName(); + QDBusVariant getVersion(); + QDBusVariant execute ( const QString &s); + +Q_SIGNALS: // SIGNALS + void crashed(); +}; + +#endif diff --git a/animpoint.cpp b/animpoint.cpp new file mode 100644 index 0000000..530b459 --- /dev/null +++ b/animpoint.cpp @@ -0,0 +1,140 @@ +#include "animpoint.h" + +#include + +AnimPoint::AnimPoint() +{ + init(); +} + +void AnimPoint::operator= ( const AnimPoint & other ) +{ + copy (other); +} + +void AnimPoint::operator= ( const QPointF & other ) +{ + init(); + setX (other.x() ); + setY (other.x() ); +} + +bool AnimPoint::operator== ( const QPointF& other ) +{ + QPointF p( x(),y()); + return p == other; +} + +bool AnimPoint::operator== ( AnimPoint other ) +{ + if (rx() != other.rx() ) return false; + if (ry() != other.ry() ) return false; + if (startPos != other.startPos) return false; + if (destPos != other.destPos) return false; + if (animated != other.animated ) return false; + + return true; +} + +void AnimPoint::init () +{ + animated=false; + n=0; + startPos=QPointF(0,0); + destPos=QPointF(0,0); + vector=QPointF(0,0); + animTicks=10; +} + +void AnimPoint::copy (AnimPoint other) +{ + setX (other.x() ); + setY (other.x() ); + startPos=other.startPos; + destPos=other.destPos; + vector=other.vector; + animated=other.animated; + n=other.n; + animTicks=other.animTicks; +} + +void AnimPoint::setStart(const QPointF &p) +{ + startPos=p; + initVector(); +} + +QPointF AnimPoint::getStart() +{ + return startPos; +} + + +void AnimPoint::setDest(const QPointF &p) +{ + destPos=p; + initVector(); +} + +QPointF AnimPoint::getDest() +{ + return destPos; +} + +void AnimPoint::setTicks (const uint &t) +{ + animTicks=t; +} + +uint AnimPoint::getTicks() +{ + return (uint) animTicks; +} + +void AnimPoint::setAnimated(bool b) +{ + animated=b; + if (b) n=0; +} + +bool AnimPoint::isAnimated() +{ + return animated; +} + +bool AnimPoint::animate() +{ + if (!animated) return false; + n++; + if (n>animTicks) + { + vector=QPointF(0,0); + animated=false; + setX (destPos.x() ); + setY (destPos.y() ); + return false; + } + + // Some math to slow down the movement in the end + qreal f=1-n/(qreal)animTicks; + qreal ff=1-f*f*f; + setX (startPos.x() + vector.x()*ff ); + setY (startPos.y() + vector.y()*ff ); + + return animated; +} + +void AnimPoint::stop() +{ + animated=false; + setX (destPos.x()); + setY (destPos.y()); +} + +void AnimPoint::initVector() +{ + vector.setX (destPos.x()-startPos.x() ); + vector.setY (destPos.y()-startPos.y() ); +} + + diff --git a/animpoint.h b/animpoint.h new file mode 100644 index 0000000..a7c6435 --- /dev/null +++ b/animpoint.h @@ -0,0 +1,39 @@ +#ifndef ANIMPOINT_H +#define ANIMPOINT_H + +#include + +class AnimPoint: public QPointF +{ +public: + AnimPoint(); + void operator= ( const AnimPoint & ); + void operator= ( const QPointF & ); + bool operator== ( const QPointF & ); + bool operator== ( AnimPoint ); + void init(); + void copy(AnimPoint other); + void setStart (const QPointF &); + QPointF getStart(); + void setDest (const QPointF &); + QPointF getDest(); + void setTicks (const uint &t); + uint getTicks(); + void setAnimated(bool); + bool isAnimated (); + bool animate(); + void stop(); + +private: + void initVector(); + + QPointF startPos; + QPointF destPos; + QPointF vector; + qreal n; + uint animTicks; + bool animated; + +}; + +#endif diff --git a/arrowobj.cpp b/arrowobj.cpp new file mode 100644 index 0000000..67f6c0e --- /dev/null +++ b/arrowobj.cpp @@ -0,0 +1,218 @@ +#include "arrowobj.h" +#include "misc.h" + +#include +#include + +///////////////////////////////////////////////////////////////// +// ArrowObj +///////////////////////////////////////////////////////////////// + +ArrowObj::ArrowObj (MapObj* parent):MapObj(parent) +{ + init(); +} + +ArrowObj::~ArrowObj () +{ + delete arrowBegin; + delete arrowEnd; + delete line; +} + +void ArrowObj::init () +{ + QPen pen; + + pen.setStyle (Qt::SolidLine); + arrowBegin=scene()->addPolygon (QPolygonF(), pen ); + arrowBegin->setZValue (dZ_XLINK); + arrowEnd=scene()->addPolygon (QPolygonF(), pen ); + arrowEnd->setZValue (dZ_XLINK); + + line=scene()->addLine ( QLineF(), pen ); + line->setZValue (dZ_XLINK); + + arrowSize=4; + useFixedLength=false; + setStyleBegin (None); + setStyleEnd (HeadFull); +} + +void ArrowObj::setPen (QPen p) +{ + pen = p; + line->setPen( pen); + + // end shall have same style as xlink + QPen pen_solid = pen; + pen_solid.setStyle (Qt::SolidLine); + arrowBegin->setPen( pen_solid ); + arrowEnd->setPen( pen_solid ); + + setStyleBegin( styleBegin ); + setStyleEnd( styleEnd ); +} + +QPen ArrowObj::getPen() +{ + return pen; +} + +void ArrowObj::setArrowSize(qreal r) +{ + arrowSize = r; +} + +qreal ArrowObj::getArrowSize() +{ + return arrowSize; +} + +void ArrowObj::setUseFixedLength( bool b) +{ + useFixedLength = b; +} + +bool ArrowObj::getUseFixedLength() +{ + return useFixedLength; +} + +void ArrowObj::setFixedLength(int i) +{ + fixedLength = i; +} + +int ArrowObj::getFixedLength() +{ + return fixedLength; +} + +void ArrowObj::show() +{ + setVisibility( true ); +} + +void ArrowObj::hide() +{ + setVisibility( false ); +} + +void ArrowObj::setVisibility (bool b) +{ + MapObj::setVisibility (b); + if (b) + { + if (styleEnd != None) + arrowEnd->show(); + else + arrowEnd->hide(); + if (useFixedLength && fixedLength == 0) + line->hide(); + else + line->show(); + } + else + { + arrowEnd->hide(); + line->hide(); + } +} + +void ArrowObj::setEndPoint (QPointF p) +{ + endPoint = p; + + line->setLine(absPos.x(),absPos.y(), p.x(), p.y()); + arrowEnd->setPos(absPos); + + qreal a = getAngle( endPoint - absPos ); + arrowEnd->setRotation( -a / 6.28 * 360); + arrowEnd->setPos( endPoint ); +} + +QPointF ArrowObj::getEndPoint () +{ + return endPoint; +} + +void ArrowObj::setStyleBegin (const QString &s) +{ + if (s=="HeadFull") + setStyleBegin( ArrowObj::HeadFull ); + else + setStyleBegin( ArrowObj::None ); +} + +void ArrowObj::setStyleBegin (OrnamentStyle os) +{ + styleBegin = os; + switch (styleBegin) + { + case HeadFull: + arrowEnd->setPolygon( getArrowHead() ); + arrowBegin->setBrush( pen.color() ); + break; + case Foot: break; + case None: + arrowBegin->setPolygon( QPolygonF() ); + break; + } +} + +ArrowObj::OrnamentStyle ArrowObj::getStyleBegin() +{ + return styleBegin; +} + +void ArrowObj::setStyleEnd (const QString &s) +{ + if (s=="HeadFull") + setStyleEnd( ArrowObj::HeadFull ); + else + setStyleEnd( ArrowObj::None ); +} + +void ArrowObj::setStyleEnd (OrnamentStyle os) +{ + styleEnd = os; + switch (styleEnd) + { + case HeadFull: + arrowEnd->setPolygon( getArrowHead() ); + arrowEnd->setBrush( pen.color() ); + break; + case Foot: break; + case None: + arrowEnd->setPolygon( QPolygonF() ); + break; + } +} + +QPolygonF ArrowObj::getArrowHead() +{ + QPointF a,b,c; + QPolygonF pa; + b = a + QPointF( -arrowSize *2, -arrowSize); + c = a + QPointF( -arrowSize *2, +arrowSize); + pa << a << b << c; + return pa; +} + +ArrowObj::OrnamentStyle ArrowObj::getStyleEnd() +{ + return styleEnd; +} + +QString ArrowObj::styleToString(const OrnamentStyle &os) +{ + switch (os) + { + case HeadFull: return "HeadFull"; break; + case None: return "None"; break; + default: qWarning()<<"ArrowObj::styleToString unknown style "< + +/*! \brief arrows are used to indicate partially hidden ends of xlinks and + also the ends of xlinks. +*/ + +///////////////////////////////////////////////////////////////////////////// + +class ArrowObj:public MapObj { +public: + enum OrnamentStyle {None, HeadFull, Foot}; + ArrowObj (MapObj* parent); + virtual ~ArrowObj (); + virtual void init (); + void setPen( QPen pen ); + QPen getPen(); + void setArrowSize(qreal r); + qreal getArrowSize(); + void setFixedLength(int i); + int getFixedLength(); + void setUseFixedLength(bool b); + bool getUseFixedLength(); + void show(); + void hide(); + void setVisibility (bool b); + void setEndPoint (QPointF p); + QPointF getEndPoint (); + void setStyleBegin (OrnamentStyle os); + void setStyleBegin (const QString &s); + OrnamentStyle getStyleBegin (); + void setStyleEnd (const QString &s); + void setStyleEnd (OrnamentStyle os); + OrnamentStyle getStyleEnd (); + static QString styleToString(const OrnamentStyle &os); + +private: + QPolygonF getArrowHead(); + QPen pen; + qreal arrowSize; + int fixedLength; + bool useFixedLength; + QGraphicsPolygonItem *arrowEnd; + QGraphicsPolygonItem *arrowBegin; + QGraphicsLineItem *line; + QPointF endPoint; + + OrnamentStyle styleBegin; + OrnamentStyle styleEnd; +}; + +#endif diff --git a/attribute.cpp b/attribute.cpp new file mode 100644 index 0000000..95edd99 --- /dev/null +++ b/attribute.cpp @@ -0,0 +1,296 @@ +#include +#include + +#include "attribute.h" + +using namespace std; + +extern bool debug; + +Attribute::Attribute() +{ + table=NULL; + definition=NULL; +} + +void Attribute::setKey (const QString &k, const AttributeType &t) +{ + if (!table) + { + qWarning ()<< QString("Attribute::setKey (%1) No table defined!\n").arg(k).toUtf8(); + return; + } + + if (!definition) + { + definition=table->getDef(k); + if (!definition) + { + table->addKey (k,t); + return; + } + } + qWarning ()<< QString("Attribute::setKey (%1) attribute already defined!\n").arg(k).toUtf8(); +} + +QString Attribute::getKey () +{ + if (!table) + { + qWarning ("Attribute::getKey () No table defined!"); + return QString(); + } + if (!definition) + { + qWarning ("Attribute::getKey () No attribute defined!"); + return QString (); + } + return definition->getKey(); +} + +void Attribute::setValue(const QString &v) +{ + if (!table) + { + qWarning ()<setValue (v); +} + +QVariant Attribute::getValue() +{ + if (!table) + { + qWarning ("Attribute::getValue No table defined!"); + return QString(); + } + if (!definition) + { + qWarning()<<"Attribute::getValue No attribute defined!"; + return QString(); + } + QVariant v= definition->getValue(); + return v; +} + +void Attribute::setType (const AttributeType &t) +{ + if (!table) + { + qWarning ()<<"Attribute::setType No table defined!"; + return; + } + if (!definition) + { + qWarning()<<"Attribute::setType No attribute defined!"; + return; + } + definition->setType (t); +} + +AttributeType Attribute::getType() +{ + if (!table) + { + qWarning ()<<"Attribute::getType No table defined!"; + return Undefined; + } + if (!definition) + { + qWarning ()<<"Attribute::getType No attribute defined!"; + return Undefined; + } + return definition->getType(); +} + +QString Attribute::getTypeString() +{ + if (!table) + { + qWarning ()<<"Attribute::getTypeString No table defined!"; + return "Undefined"; + } + if (!definition) + { + qWarning ()<<"Attribute::getTypeString No attribute defined!"; + return "Undefined"; + } + return definition->getTypeString(); +} + +void Attribute::setTable (AttributeTable *at) +{ + if (at) + table=at; + else + qWarning ()<<"Attribute::setTable table==NULL"; + +} + +AttributeTable* Attribute::getTable() +{ + return table; +} + +QString Attribute::getDataXML() +{ + QString a=beginElement ("attribute"); + a+=attribut ("key",getKey()); + a+=attribut ("value",getValue().toString() ); + a+=attribut ("type",getTypeString () ); + return a; +} + + +/////////////////////////////////////////////////////////////// +AttributeDef::AttributeDef() +{ +} + +AttributeDef::~AttributeDef() +{ +} + +void AttributeDef::setType (const AttributeType &t) +{ + type=t; +} + +AttributeType AttributeDef::getType () +{ + return type; +} + +QString AttributeDef::getTypeString () +{ + if (type==StringList) + return "StringList"; + else if (type==FreeString) + return "FreeString"; + else if (type==UniqueString) + return "UniqueString"; + return "Undefined"; +} + +void AttributeDef::setKey (const QString &k) +{ + key=k; +} + +void AttributeDef::setValue (const QString &) +{ +} + +void AttributeDef::setValue (const QVariant &v) +{ + if (type==Undefined) + qWarning ()<<"AttributeDef::setValue No type defined!"; + else if (type==StringList) + value=v; + else if (type==UniqueString) + value=v; + else + qWarning ()<<"AttributeDef::setValue Unknown type???"; + +} + +QVariant AttributeDef::getValue () +{ + return QVariant (); +} + +QString AttributeDef::getKey () +{ + return key; +} + +/////////////////////////////////////////////////////////////// +AttributeTable::AttributeTable() +{ + typeList + << "Undefined" + << "IntList" + << "FreeInt" + << "StringList" + << "FreeString" + << "UniqueString"; +} + +AttributeTable::~AttributeTable() +{ + clear(); +} + +void AttributeTable::clear () +{ + attdefs.clear(); +} + +AttributeDef* AttributeTable::addKey (const QString &k, const AttributeType &t) +{ + for (int i=0; igetKey()==k ) + { + qWarning () << QString ("AttributeTable::addKey (%1) already in table\n").arg(k).toUtf8(); + return NULL; + } + } + AttributeDef *ad=new AttributeDef; + ad->setKey (k); + ad->setType (t); + attdefs.append (ad); + return ad; +} + +void AttributeTable::removeKey (const QString &k) +{ + for (int i=0; igetKey()==k ) + { + + delete (attdefs.at(i)); + attdefs.removeAt (i); + return ; + } + } + qWarning () << QString ("AttributeTable::removeKey (%1) key not in table\n").arg(k).toUtf8(); +} + +AttributeDef* AttributeTable::getDef(const QString &key) +{ + for (int i=0; igetKey()==key ) return attdefs.at(i); + qWarning () << QString ("AttributeTable::getDef (%1) key not in table\n").arg(key).toUtf8(); + return NULL; +} + +int AttributeTable::countKeys() +{ + return attdefs.count(); +} + +QStringList AttributeTable::getKeys () +{ + QStringList kl; + for (int i=0; igetKey()); + return kl; +} + +QStringList AttributeTable::getTypes () +{ + return typeList; +} + +QString AttributeTable::getDataXML() +{ + return valueElement ("attributeList","key","value"); +} diff --git a/attribute.h b/attribute.h new file mode 100644 index 0000000..636fee3 --- /dev/null +++ b/attribute.h @@ -0,0 +1,93 @@ +#ifndef ATTRIBUTE_H +#define ATTRIBUTE_H + +#include +#include + +#include "xmlobj.h" + +class AttributeTable; //FIXME-3 remove from CVS +class AttributeDef; //FIXME-3 remove from CVS + +enum AttributeType { + Undefined, //!< Undefined type + IntList, //!< Free integer + FreeInt, //!< Free integer + StringList, //!< List of strings, one can be attribute value + FreeString, //!< Any string can be attribute value, not unique + UniqueString//!< UniqueString, e.g. for IDs +}; + +/*! \brief A key and a value + The data itself is stored in Attribute Definitions (AttributeDef). + A list of these tables AttributeTable is maintained for every MapEditor. +*/ +class Attribute:public XMLObj { +public: + Attribute(); + void setKey (const QString &k, const AttributeType &t); + QString getKey (); + void setValue (const QString &v); + QVariant getValue (); + void setType (const AttributeType &t); + AttributeType getType (); + QString getTypeString (); + void setTable (AttributeTable *at); + AttributeTable* getTable(); + QString getDataXML(); +protected: + AttributeTable *table; + AttributeDef *definition; + QString freeString; //!< String value for type FreeString +}; + + +/*! \brief + Attribute definition, defines possible values and type of attribute. +*/ +class AttributeDef { +public: + AttributeDef(); + ~AttributeDef(); + void setType (const AttributeType &t); + AttributeType getType(); + QString getTypeString (); + void setKey (const QString &k); + QString getKey (); + void setValue (const QString &v); + void setValue (const QVariant &v); + QVariant getValue (); +private: + QString key; + AttributeType type; + + QVariant value; //!< value (except FreeString, FreeInt ... +}; + +/*! \brief A table containing a list of keys and each of these keys has + a list of default values. The keys and the values for each key are + unique. +*/ + +class AttributeTable:public XMLObj{ +public: + AttributeTable(); + ~AttributeTable(); + void clear(); + AttributeDef* addKey (const QString &k, const AttributeType &t); //!< Adds a key to the table + void removeKey (const QString &k); //!< Removes key and its default values + AttributeDef* getDef(const QString &k); //!< Get defintion of attribute + int countKeys(); //!< Return number of keys + QStringList getKeys (); + QStringList getTypes(); + QString getDataXML(); + +protected: + QList attdefs; + QStringList typeList; +}; + + + +#endif + diff --git a/attributedelegate.cpp b/attributedelegate.cpp new file mode 100644 index 0000000..bd807a7 --- /dev/null +++ b/attributedelegate.cpp @@ -0,0 +1,138 @@ +#include + +#include "attributedelegate.h" +#include + +using namespace::std; + +AttributeDelegate::AttributeDelegate(QObject *parent) + : QItemDelegate(parent) +{ +} + +QWidget *AttributeDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem &/* option */, + const QModelIndex & index ) const +{ + int col=index.column(); + int row=index.row(); + + if (col==0 && row==index.model()->rowCount() -1 ) + { + //We are editing a new attribute, starting with attribute name + QComboBox *editor = new QComboBox(parent); + editor->insertItems (0,attributeTable->getKeys()); + return editor; + } + if (col==1 && row==index.model()->rowCount() -1 ) + { + qDebug()<< "Edit value now..."; + //We are editing a new attribute, starting with attribute name + QComboBox *editor = new QComboBox(parent); + editor->insertItems (0,attributeTable->getKeys()); + return editor; + + } + + // Is there already an atttribute defined or + // do we need to create a new one? + + QVariant var=index.model()->data(index.model()->index(row,2,QModelIndex())); + QString typeName=var.toString(); + qDebug()<< "AttrDel::createEditor type="<setMinimum(0); + editor->setMaximum(5); + return editor; + } else if (typeName=="FreeInt") + { + QSpinBox *editor = new QSpinBox(parent); + editor->setMinimum(0); + editor->setMaximum(100); + return editor; + } else if (typeName=="FreeString") + { + QComboBox *editor = new QComboBox(parent); + return editor; + } else if (typeName=="StringList") + { + QComboBox *editor = new QComboBox(parent); + return editor; + } + + return NULL; +} + +void AttributeDelegate::setEditorData(QWidget *editor, + const QModelIndex &index) const +{ + QVariant value= index.model()->data(index, Qt::DisplayRole); + switch (value.type()) + { + case QVariant::Int: + { + int value = index.model()->data(index, Qt::DisplayRole).toInt(); + QSpinBox *spinBox = static_cast(editor); + spinBox->setValue(value); + break; + } + /* + { + QString value = index.model()->data(index, Qt::DisplayRole).toString(); + QLineEdit *le= static_cast(editor); + le->setText(value); + break; + } + */ + case QVariant::String: + { + QComboBox *cb= static_cast(editor); + QStringList sl; + sl<< index.model()->data(index, Qt::DisplayRole).toString(); + cb->insertStringList (sl); + break; + } + default: + break; + } +} + +void AttributeDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const +{ + QVariant value= index.model()->data(index, Qt::DisplayRole); + switch (value.type()) + { + case QVariant::Int: + { + QSpinBox *spinBox = static_cast(editor); + spinBox->interpretText(); + model->setData(index, spinBox->value(), Qt::EditRole); + break; + } + case QVariant::String: + { + QComboBox *cb = static_cast(editor); + model->setData(index, cb->currentText(), Qt::EditRole); + break; + } + default: + break; + } + +} + +void AttributeDelegate::updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &/* index */) const +{ + editor->setGeometry(option.rect); +} + +void AttributeDelegate::setAttributeTable (AttributeTable *table) +{ + attributeTable=table; +} + diff --git a/attributedelegate.h b/attributedelegate.h new file mode 100644 index 0000000..5b15382 --- /dev/null +++ b/attributedelegate.h @@ -0,0 +1,37 @@ + +#ifndef ATTRIBUTEDELEGATE_H +#define ATTRIBUTEDELEGATE_H + +#include +#include +#include +#include +#include +#include + +#include "attribute.h" + +class AttributeDelegate : public QItemDelegate +{ + Q_OBJECT + +enum EditorType {Undefined,SpinBox,LineEdit,ComboBox}; + +public: + AttributeDelegate(QObject *parent = 0); + + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + + void setEditorData(QWidget *editor, const QModelIndex &index) const ; + void setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const ; + + void updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &index) const; + void setAttributeTable(AttributeTable *table); +private: + AttributeTable *attributeTable; +}; + +#endif diff --git a/attributedialog.cpp b/attributedialog.cpp new file mode 100644 index 0000000..c7bd614 --- /dev/null +++ b/attributedialog.cpp @@ -0,0 +1,118 @@ +#include "attributedialog.h" + +#include "attributewidget.h" + +#include +#include + +AttributeDialog::AttributeDialog (QWidget *parent):QDialog (parent) +{ + if (this->objectName().isEmpty()) + this->setObjectName(QString::fromUtf8("AttributeDialog")); + QSize size(468, 75); + size = size.expandedTo(this->minimumSizeHint()); + this->resize(size); + QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth()); + this->setSizePolicy(sizePolicy); + + vboxLayout = new QVBoxLayout(this); + vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); + + tableLayout = new QVBoxLayout(); + tableLayout->setObjectName(QString::fromUtf8("tableLayout")); + + hboxLayout = new QHBoxLayout(); + hboxLayout->setObjectName(QString::fromUtf8("hboxLayout")); + addButton = new QPushButton(this); + addButton->setObjectName(QString::fromUtf8("addButton")); + + hboxLayout->addWidget(addButton); + + spacerItem = new QSpacerItem(111, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + + hboxLayout->addItem(spacerItem); + + closeButton = new QPushButton(this); + closeButton->setObjectName(QString::fromUtf8("closeButton")); + + hboxLayout->addWidget(closeButton); + + vboxLayout->addLayout(tableLayout); + vboxLayout->addLayout(hboxLayout); + + + + setWindowTitle(QApplication::translate("AttributeDialog", "Attributes", 0, QApplication::UnicodeUTF8)); + addButton->setText(QApplication::translate("AttributeDialog", "Add key", 0, QApplication::UnicodeUTF8)); + closeButton->setText(QApplication::translate("AttributeDialog", "Close", 0, QApplication::UnicodeUTF8)); + + connect (addButton, SIGNAL (clicked()), this, SLOT (addKey())); + connect (closeButton, SIGNAL (clicked()), this, SLOT (accept())); + + table=NULL; +} + +void AttributeDialog::setTable (AttributeTable *t) +{ + table=t; +} + +void AttributeDialog::setBranch (BranchObj *bo) +{ + branch=bo; +} + +void AttributeDialog::setMode (const AttributeDialogMode &m) +{ + mode=m; + + QString title; + if (mode==Definition) + title= QApplication::translate("Attribute Dialog","AttributeDialog - Edit definitions", 0, QApplication::UnicodeUTF8); + else + title= QApplication::translate("Attribute Dialog","AttributeDialog - Edit %1", 0, QApplication::UnicodeUTF8).arg("objname"); + setWindowTitle(title); +} + +void AttributeDialog::updateTable() +{ + if (table) + { + // Update list of keys and values + QStringList keyList=table->getKeys(); + AttributeWidget *aw; + for (int i=0; isetKey (keyList.at(i) ); + // TODO aw->setValues (table->getValues (keyList.at(i) )); + aw->show(); + tableLayout->addWidget (aw); + } + + // Update attributes in dialog from data in selected branch + + // TODO + } + +} +void AttributeDialog::addKey() +{ + AttributeWidget *aw1=new AttributeWidget (this); + aw1->show(); + tableLayout->addWidget (aw1); + +} + +void AttributeDialog::closeEvent( QCloseEvent* ce ) +{ + ce->accept(); // can be reopened with show() + hide(); + emit (windowClosed() ); + return; +} + + diff --git a/attributedialog.h b/attributedialog.h new file mode 100644 index 0000000..b56cf80 --- /dev/null +++ b/attributedialog.h @@ -0,0 +1,49 @@ +#ifndef ATTRIBUTEDIALOG_H +#define ATTRIBUTEDIALOG_H + +#include "attribute.h" +#include "branchobj.h" + +#include +#include +#include +#include +#include +#include + + +/*! \brief Set the dialog mode */ +enum AttributeDialogMode { + Definition, //!< Edit attribute definitions (AttributeDef) + Object //!< Edit attributes of OrnamentedObj +}; + +class AttributeDialog:public QDialog +{ + Q_OBJECT +public: + AttributeDialog (QWidget *parent=0 ); + void setTable (AttributeTable *table=0); + void setBranch (BranchObj *bo); + void setMode (const AttributeDialogMode &m); + void updateTable(); +signals: + void windowClosed(); +private slots: + void addKey(); +protected: + void closeEvent(QCloseEvent*); +private: + QVBoxLayout *vboxLayout; + QVBoxLayout *tableLayout; + QHBoxLayout *hboxLayout; + QPushButton *addButton; + QSpacerItem *spacerItem; + QPushButton *closeButton; + + AttributeDialogMode mode; + AttributeTable *table; + BranchObj *branch; +}; + +#endif diff --git a/attributedialog.ui b/attributedialog.ui new file mode 100644 index 0000000..fc16698 --- /dev/null +++ b/attributedialog.ui @@ -0,0 +1,60 @@ + + AttributeDialog + + + + 0 + 0 + 468 + 75 + + + + + 0 + 0 + + + + Attributes + + + + + + + + + + + Add key + + + + + + + Qt::Horizontal + + + + 111 + 20 + + + + + + + + Close + + + + + + + + + + diff --git a/attributeitem.cpp b/attributeitem.cpp new file mode 100644 index 0000000..af014f2 --- /dev/null +++ b/attributeitem.cpp @@ -0,0 +1,195 @@ +#include "attributeitem.h" + + +extern bool debug; + +AttributeItem::AttributeItem(const QList &data, TreeItem *parent):BranchItem (data,parent) +{ + TreeItem::setType (Attribute); + internal=false; +} + +AttributeItem::~AttributeItem() +{ +} + +void AttributeItem::set (const QString &k, const QString &v, const Type &) +{ + key=k; + value=QVariant (v); + createHeading(); +} + +void AttributeItem::get (QString &k, QString &v, Type &t) +{ + k=key; + v=value.toString(); + t=attrType; +} + +void AttributeItem::setKey (const QString &k) +{ +/* + if (!table) + { + qWarning (QString("AttributeItem::setKey (%1) No table defined!\n").arg(k).ascii()); + return; + } + + if (!definition) + { + definition=table->getDef(k); + if (!definition) + { + table->addKey (k,t); + return; + } + } + qWarning (QString("AttributeItem::setKey (%1) attribute already defined!\n").arg(k).ascii()); + */ + key=k; + createHeading(); +} + +QString AttributeItem::getKey () +{ +/* + if (!table) + { + qWarning ("AttributeItem::getKey () No table defined!"); + return QString(); + } + if (!definition) + { + qWarning ("AttributeItem::getKey () No attribute defined!"); + return QString (); + } + return definition->getKey(); + */ + return key; +} + +void AttributeItem::setValue(const QString &v) +{ +/* + if (!table) + { + qWarning (QString ("AttributeItem::setValue (%1) No table defined!").arg(v)); + return; + } + if (!definition) + { + qWarning (QString ("AttributeItem::setValue (%1) No attribute defined!").arg(v)); + return; + } + definition->setValue (v); +*/ + value=v; + createHeading(); +} + +QVariant AttributeItem::getValue() +{ +/* + if (!table) + { + qWarning ("AttributeItem::getValue No table defined!"); + return QString(); + } + if (!definition) + { + qWarning ("AttributeItem::getValue No attribute defined!"); + return QString(); + } + QVariant v= definition->getValue(); + return v; + */ + return value; +} + +void AttributeItem::setType (const Type &t) +{ +/* + if (!table) + { + qWarning ("AttributeItem::setType No table defined!"); + return; + } + if (!definition) + { + qWarning ("Attribute::setType No attribute defined!"); + return; + } + definition->setType (t); +*/ + attrType=t; +} + +AttributeItem::Type AttributeItem::getAttributeType() +{ +/* + if (!table) + { + qWarning ("AttributeItem::getType No table defined!"); + return Undefined; + } + if (!definition) + { + qWarning ("AttributeItem::getType No attribute defined!"); + return Undefined; + } + return definition->getType(); +*/ + return attrType; +} + +QString AttributeItem::getTypeString() +{ +/* + if (!table) + { + qWarning ("AttributeItem::getTypeString No table defined!"); + return "Undefined"; + } + if (!definition) + { + qWarning ("Attribute::getTypeString No AttributeItem defined!"); + return "Undefined"; + } + return definition->getTypeString(); +*/ + switch (attrType) + { + case IntList: return "IntList"; + case FreeInt: return "FreeInt"; + case StringList:return "StringList"; + case FreeString:return "FreeString"; + case UniqueString: return "UniqueString"; + default: return "Undefined"; + } +} + +void AttributeItem::setInternal(bool b) +{ + internal=b; +} + +bool AttributeItem::isInternal() +{ + return internal; +} + +QString AttributeItem::getDataXML() +{ + QString a; + a=attribut ("key",getKey()); + a+=attribut ("value",getValue().toString() ); + a+=attribut ("type",getTypeString () ); + return singleElement ("attribute",a); +} + +void AttributeItem::createHeading() +{ + setHeadingPlainText (QString ("K: %1 | V: %2").arg(key).arg(value.toString())); +} + diff --git a/attributeitem.h b/attributeitem.h new file mode 100644 index 0000000..a1c4767 --- /dev/null +++ b/attributeitem.h @@ -0,0 +1,48 @@ +#ifndef ATTRIBUTEITEM_H +#define ATTRIBUTEITEM_H + +#include +#include + +#include "branchitem.h" + +/*! \brief A key and a value + The data itself is stored in Attribute Definitions (AttributeDef). + A list of these tables AttributeTable is maintained for every MapEditor. +*/ +class AttributeItem:public BranchItem { +public: +enum Type { + Undefined, //!< Undefined type + IntList, //!< Integer + FreeInt, //!< Integer + StringList, //!< List of strings + FreeString, //!< String + UniqueString//!< String which is unique in a map, e.g. for IDs +}; + + AttributeItem(const QList &data, TreeItem *parent = 0); + virtual ~AttributeItem(); + void set (const QString &k, const QString &v, const Type &t); + void get (QString &k, QString &v, Type &t); + void setKey (const QString &k); + QString getKey (); + void setValue (const QString &v); + QVariant getValue (); + using BranchItem::setType; + virtual void setType (const Type &t); + AttributeItem::Type getAttributeType (); + QString getTypeString (); + void setInternal (bool b); + bool isInternal(); + QString getDataXML(); +protected: + void createHeading(); + bool internal; //!< Internal attributes cannot be edited by user + QString key; + QVariant value; + Type attrType; +}; + +#endif + diff --git a/attributewidget.cpp b/attributewidget.cpp new file mode 100644 index 0000000..65e7a18 --- /dev/null +++ b/attributewidget.cpp @@ -0,0 +1,39 @@ +#include "attributewidget.h" + +AttributeWidget::AttributeWidget (QWidget *parent):QWidget (parent) +{ + ui.setupUi (this); + //ui.keyComboBox->setEditable (true); + ui.valueComboBox->setEditable (true); +} + +void AttributeWidget::setTable(AttributeTable *at) +{ + table=at; +} + +void AttributeWidget::setKey (const QString &k) +{ + key=k; + ui.keyComboBox->insertItem (ui.keyComboBox->count(), key); +} + +void AttributeWidget::setValues(const QStringList &vl) +{ + ui.valueComboBox->clear(); + ui.valueComboBox->insertStringList(vl); +} + +/* +void AttributeWidget::setValue (const QString &v) +{ +} +*/ + +void AttributeWidget::keyTextChanged(const QString &t) +{ +} + +void AttributeWidget::valueTextChanged(const QString &t) +{ +} diff --git a/attributewidget.h b/attributewidget.h new file mode 100644 index 0000000..065fd78 --- /dev/null +++ b/attributewidget.h @@ -0,0 +1,28 @@ +#ifndef ATTRIBUTEWIDGET_H +#define ATTRIBUTEWIDGET_H + +#include "ui_attributewidget.h" + +#include "attribute.h" + +#include + +class AttributeWidget: public QWidget +{ + Q_OBJECT +public: + AttributeWidget (QWidget *parent=0); + void setTable (AttributeTable *at=0); + void setKey (const QString &k); + void setValues (const QStringList &vl); + +public slots: + virtual void keyTextChanged(const QString &t); + virtual void valueTextChanged(const QString &t); + +private: + Ui::AttributeWidget ui; + AttributeTable *table; + QString key; +}; +#endif diff --git a/attributewidget.ui b/attributewidget.ui new file mode 100644 index 0000000..3327fee --- /dev/null +++ b/attributewidget.ui @@ -0,0 +1,51 @@ + + + AttributeWidget + + + + 0 + 0 + 400 + 115 + + + + Form + + + + 0 + + + + + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + diff --git a/branchitem.cpp b/branchitem.cpp new file mode 100644 index 0000000..ed97e5d --- /dev/null +++ b/branchitem.cpp @@ -0,0 +1,575 @@ +#include "branchitem.h" + +#include "attributeitem.h" +#include "branchobj.h" +#include "task.h" +#include "taskmodel.h" +#include "vymmodel.h" +#include "xlink.h" +#include "xlinkitem.h" + +extern TaskModel *taskModel; + +//#include + +BranchItem::BranchItem(const QList &data, TreeItem *parent):MapItem (data,parent) +{ + //qDebug()<< "Constr. BranchItem this="<deleteTask (task); +} + +void BranchItem::copy (BranchItem *other) // TODO lacks most of data... +{ + scrolled=other->scrolled; + tmpUnscrolled=other->tmpUnscrolled; +} + +BranchItem* BranchItem::parentBranch () +{ + return (BranchItem*) parentItem; +} + +void BranchItem::insertBranch (int pos, BranchItem *branch) +{ + if (pos<0) pos=0; + if (pos>branchCounter) pos=branchCounter; + childItems.insert(pos+branchOffset,branch); + branch->parentItem=this; + branch->rootItem=rootItem; + branch->setModel (model); + if (parentItem==rootItem) + setType (MapCenter); + else + setType (Branch); + + + if (branchCounter==0) + branchOffset=childItems.count()-1; + branchCounter++; +} + +QString BranchItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset, QList &tmpLinks ) +{ + // Cloudy stuff can be hidden during exports + if (hidden) return QString(); + + // Save uuid + QString idAttr=attribut("uuid",uuid.toString()); + + QString s,a; + + // Update of note is usually done while unselecting a branch + + QString scrolledAttr; + if (scrolled) + scrolledAttr=attribut ("scrolled","yes"); + else + scrolledAttr=""; + + // save area, if not scrolled // not needed if HTML is rewritten... + // also we could check if _any_ of parents is scrolled + QString areaAttr; + if (mo && parentItem->isBranchLikeType() && !((BranchItem*)parentItem)->isScrolled() ) + { + qreal x=mo->getAbsPos().x(); + qreal y=mo->getAbsPos().y(); + areaAttr= + attribut("x1",QString().setNum(x-offset.x())) + + attribut("y1",QString().setNum(y-offset.y())) + + attribut("x2",QString().setNum(x+mo->width()-offset.x())) + + attribut("y2",QString().setNum(y+mo->height()-offset.y())); + + } else + areaAttr=""; + + QString elementName; + if (parentItem==rootItem) + elementName="mapcenter"; + else + elementName="branch"; + + // Free positioning of children + QString layoutAttr; + if (childrenLayout == BranchItem::FreePositioning) + layoutAttr += attribut ("childrenFreePos","true"); + + // Save rotation + QString rotAttr; + if (mo && mo->getRotation() !=0 ) + rotAttr=attribut ("rotation",QString().setNum (mo->getRotation() ) ); + + s=beginElement (elementName + + getMapAttr() + + getGeneralAttr() + + scrolledAttr + + getIncludeImageAttr() + + rotAttr + + layoutAttr + + idAttr + ); + incIndent(); + + // save heading + s += heading.saveToDir(); + + // Save frame // not saved if there is no MO + if (mo) + { + // Avoid saving NoFrame for objects other than MapCenter + if (depth() == 0 || ((OrnamentedObj*)mo)->getFrame()->getFrameType()!=FrameObj::NoFrame) + s+=((OrnamentedObj*)mo)->getFrame()->saveToDir (); + } + + // save names of flags set + s+=standardFlags.saveToDir(tmpdir,prefix,0); + + // Save Images + for (int i=0; isaveToDir (tmpdir,prefix); + + // save attributes + for (int i=0; igetDataXML(); + + // save note + if (!note.isEmpty() ) + s+=note.saveToDir(); + + // save task + if (task) + s+=task->saveToDir(); + + // Save branches + int i=0; + TreeItem *ti=getBranchNum(i); + while (ti) + { + s+=getBranchNum(i)->saveToDir(tmpdir,prefix,offset,tmpLinks); + i++; + ti=getBranchNum(i); + } + + // Mark Links for save + for (int i=0; igetLink(); + if (l && !tmpLinks.contains (l)) tmpLinks.append (l); + } + decIndent(); + s += endElement (elementName); + return s; +} + +void BranchItem::updateVisibility() +{ + // Needed to hide relinked branch, if parent is scrolled + if (mo) + { + if (hasScrolledParent(this) || hidden) + mo->setVisibility (false); + else + mo->setVisibility (true); + } +} + +void BranchItem::setHeadingColor (QColor color) +{ + TreeItem::setHeadingColor (color); + if (mo) ((BranchObj*)mo)->setColor (color); +} + +void BranchItem::updateTaskFlag() +{ + systemFlags.deactivateGroup ("system-tasks"); + if (task) + { + QString s="system-" + task->getIconString(); + systemFlags.activate (s); + model->emitDataChanged(this); + } +} + +void BranchItem::setTask(Task *t) +{ + task=t; + updateTaskFlag(); +} + +Task* BranchItem::getTask() +{ + return task; +} + +void BranchItem::unScroll() +{ + if (tmpUnscrolled) resetTmpUnscroll(); + if (scrolled) toggleScroll(); +} + +bool BranchItem::toggleScroll() +{ + // MapCenters are not scrollable + if (depth()==0) return false; + + BranchObj *bo; + if (scrolled) + { + scrolled=false; + systemFlags.deactivate("system-scrolledright"); + if (branchCounter>0) + for (int i=0;igetMO()); + if (bo) bo->setVisibility(true); + } + } else + { + scrolled=true; + systemFlags.activate("system-scrolledright"); + if (branchCounter>0) + for (int i=0;igetMO()); + if (bo) bo->setVisibility(false); + } + } + return true; +} + +bool BranchItem::isScrolled() +{ + return scrolled; +} + +bool BranchItem::hasScrolledParent(BranchItem *start) +{ + // Calls parents recursivly to + // find out, if we are scrolled at all. + // But ignore myself, just look at parents. + + if (!start) start=this; + + if (this !=start && scrolled) return true; + + BranchItem* bi=(BranchItem*)parentItem; + if (bi && bi!=rootItem ) + return bi->hasScrolledParent(start); + else + return false; +} + +bool BranchItem::tmpUnscroll(BranchItem *start) +{ + bool result=false; + + if (!start) start=this; + + // Unscroll parent (recursivly) + BranchItem * pi=(BranchItem*)parentItem; + if (pi && pi->isBranchLikeType() ) result=pi->tmpUnscroll(start); + + // Unscroll myself + if (start !=this && scrolled) + { + tmpUnscrolled=true; + systemFlags.activate("system-tmpUnscrolledRight"); + toggleScroll(); + model->emitDataChanged (this); + result=true; + } + return result; +} + +bool BranchItem::resetTmpUnscroll() +{ + bool result=false; + + // Unscroll parent (recursivly) + BranchItem * pi=(BranchItem*)parentItem; + if (pi && pi->isBranchLikeType() ) result=pi->resetTmpUnscroll(); + + // Unscroll myself + if (tmpUnscrolled) + { + tmpUnscrolled=false; + systemFlags.deactivate("system-tmpUnscrolledRight"); + toggleScroll(); + model->emitDataChanged (this); + result=true; + } + return result; +} + +void BranchItem::sortChildren(bool inverse) //FIXME-4 optimize by not using moveUp/Down +{ + int childCount=branchCounter; + int curChildIndex; + bool madeChanges=false; + do + { + madeChanges=false; + for(curChildIndex=1;curChildIndexgetHeadingPlain().compare(curChild->getHeadingPlain())<0) + { + model->moveUp (curChild); + madeChanges=true; + } + } else + if (prevChild->getHeadingPlain().compare(curChild->getHeadingPlain())>0) + { + model->moveUp (curChild); + madeChanges=true; + } + } + }while(madeChanges); +} + +void BranchItem::setChildrenLayout(BranchItem::LayoutHint layoutHint) +{ + childrenLayout = layoutHint; +} + +BranchItem::LayoutHint BranchItem::getChildrenLayout() +{ + return childrenLayout; +} + +void BranchItem::setIncludeImagesVer(bool b) +{ + includeImagesVer=b; +} + +bool BranchItem::getIncludeImagesVer() +{ + return includeImagesVer; +} + +void BranchItem::setIncludeImagesHor(bool b) +{ + includeImagesHor=b; +} + +bool BranchItem::getIncludeImagesHor() +{ + return includeImagesHor; +} + +QString BranchItem::getIncludeImageAttr() +{ + QString a; + if (includeImagesVer) + a=attribut ("incImgV","true"); + if (includeImagesHor) + a+=attribut ("incImgH","true"); + return a; +} + +BranchItem* BranchItem::getFramedParentBranch(BranchItem *start) +{ + BranchObj *bo=getBranchObj(); + if (bo && bo->getFrameType() != FrameObj::NoFrame) + { + if (bo->getFrame()->getFrameIncludeChildren() ) return this; + if (this == start) return this; + } + BranchItem* bi=(BranchItem*)parentItem; + if (bi && bi!=rootItem ) + return bi->getFramedParentBranch(start); + else + return NULL; +} + +void BranchItem::setFrameIncludeChildren(bool b) +{ + includeChildren=b; // FIXME-4 ugly: same information stored in FrameObj + BranchObj *bo=getBranchObj(); + if (bo) bo->getFrame()->setFrameIncludeChildren(b); +} + +bool BranchItem::getFrameIncludeChildren() +{ + BranchObj *bo=getBranchObj(); + if (bo) + return bo->getFrame()->getFrameIncludeChildren(); + else + return includeChildren; +} + +void BranchItem::setLastSelectedBranch() +{ + int d=depth(); + if (d>=0) + { + if (d==1) + // Hack to save an additional lastSelected for mapcenters in MapEditor + // depending on orientation + // this allows to go both left and right from there + if (mo && ((BranchObj*)mo)->getOrientation()==LinkableMapObj::LeftOfCenter) + { + ((BranchItem*)parentItem)->lastSelectedBranchNumAlt=parentItem->num(this); + return; + } + ((BranchItem*)parentItem)->lastSelectedBranchNum=parentItem->num(this); + } +} + +void BranchItem::setLastSelectedBranch(int i) +{ + lastSelectedBranchNum=i; +} + +BranchItem* BranchItem::getLastSelectedBranch() +{ + if (lastSelectedBranchNum>=branchCounter) + return getBranchNum (branchCounter-1); + else + return getBranchNum (lastSelectedBranchNum); +} + +BranchItem* BranchItem::getLastSelectedBranchAlt() +{ + return getBranchNum (lastSelectedBranchNumAlt); +} + + + + +TreeItem* BranchItem::findMapItem (QPointF p, TreeItem* excludeTI) +{ + // Search branches + TreeItem *ti; + for (int i=0; ifindMapItem(p, excludeTI); + if (ti != NULL) return ti; + } + + // Search images + ImageItem *ii; + for (int i=0; igetMO(); + if (mo && mo->isInClickBox(p) && + (ii != excludeTI) && + this!= excludeTI && + mo->isVisibleObj() + ) return ii; + } + + // Search myself + if (getBranchObj()->isInClickBox (p) && (this != excludeTI) && getBranchObj()->isVisibleObj() ) + return this; + + + // Search attributes + AttributeItem *ai; + for (int i=0; igetMO(); + if (mo && mo->isInClickBox(p) && + (ai != excludeTI) && + this!= excludeTI && + mo->isVisibleObj() + ) return ai; + } + return NULL; +} + +void BranchItem::updateStyles(const bool &keepFrame) +{ + // Update styles when relinking branches + if (mo) + { + BranchObj *bo=getBranchObj(); + if ( parentItem != rootItem) + bo->setParObj ( (LinkableMapObj*) ( ((MapItem*)parentItem)->getMO() ) ); + else + bo->setParObj (NULL); + bo->setDefAttr(BranchObj::MovedBranch,keepFrame); + } +} + +BranchObj* BranchItem::getBranchObj() +{ + return (BranchObj*)mo; +} + +BranchObj* BranchItem::createMapObj(QGraphicsScene *scene) +{ + BranchObj *newbo; + + if (parentItem==rootItem) + { + newbo=new BranchObj(NULL,this); + mo=newbo; + scene->addItem (newbo); + } else + { + newbo=new BranchObj( ((MapItem*)parentItem)->getMO(),this); + mo=newbo; + // Set visibility depending on parents + if (parentItem!=rootItem && + ( ((BranchItem*)parentItem)->scrolled || !((MapItem*)parentItem)->getLMO()->isVisibleObj() ) ) + newbo->setVisibility (false); + if (depth()==1) + { + qreal r=190; + qreal a= -M_PI_4 + M_PI_2 * (num()) + (M_PI_4/2)*(num()/4 % 4); + QPointF p (r*cos (a), r*sin (a)); + newbo->setRelPos (p); + } + } + newbo->setDefAttr(BranchObj::NewBranch); + initLMO(); + + if (!getHeading().isEmpty() ) + { + newbo->updateData(); + newbo->setColor (heading.getColor()); + } + + return newbo; +} + diff --git a/branchitem.h b/branchitem.h new file mode 100644 index 0000000..207ab0c --- /dev/null +++ b/branchitem.h @@ -0,0 +1,89 @@ +#ifndef BRANCHITEM_H +#define BRANCHITEM_H + +#include "mapitem.h" +#include "task.h" + +#include + +class QString; +class QGraphicsScene; +class BranchObj; +class Link; +class XLinkItem; + +class BranchItem:public MapItem +{ +public: + enum LayoutHint {AutoPositioning, FreePositioning}; + + BranchItem(const QList &data, TreeItem *parent = 0); + virtual ~BranchItem(); + virtual void clear(); + virtual void copy (BranchItem *item); + virtual BranchItem* parentBranch(); + + virtual void insertBranch (int pos,BranchItem *branch); + + virtual QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset,QList &tmpLinks); + + virtual void updateVisibility(); + + virtual void setHeadingColor (QColor color); //!Overloaded from TreeItem to update QGraphicsView + +protected: + bool scrolled; // true if all children are scrolled and thus invisible + bool tmpUnscrolled; // can only be true (temporary) for a scrolled subtree + +public: + void updateTaskFlag(); + void setTask (Task* t); + Task* getTask(); +private: + Task* task; + +public: + virtual void unScroll(); + virtual bool toggleScroll(); // scroll or unscroll + virtual bool isScrolled(); // returns scroll state + virtual bool hasScrolledParent(BranchItem* start=NULL); // true, if any of the parents is scrolled + virtual bool tmpUnscroll(BranchItem* start=NULL); // unscroll scrolled parents temporary e.g. during "find" process + virtual bool resetTmpUnscroll(); // scroll all tmp scrolled parents again e.g. when unselecting + virtual void sortChildren(bool inverse=false); //! Sort children + virtual void setChildrenLayout(BranchItem::LayoutHint layoutHint); + virtual BranchItem::LayoutHint getChildrenLayout(); + +protected: + bool includeImagesVer; //! include floatimages in bbox vertically + bool includeImagesHor; //! include floatimages in bbox horizontally + bool includeChildren; //! include children in frame + LayoutHint childrenLayout; //! should children be positioned freely? + +public: + void setIncludeImagesVer(bool); + bool getIncludeImagesVer(); + void setIncludeImagesHor(bool); + bool getIncludeImagesHor(); + QString getIncludeImageAttr(); + BranchItem* getFramedParentBranch(BranchItem *start); + void setFrameIncludeChildren(bool); + bool getFrameIncludeChildren(); + +protected: + int lastSelectedBranchNum; + int lastSelectedBranchNumAlt; +public: + virtual void setLastSelectedBranch(); //! Set myself as last selected in parent + virtual void setLastSelectedBranch(int i); //! Set last selected branch directly + virtual BranchItem* getLastSelectedBranch(); //! Returns last selected branch usually + virtual BranchItem* getLastSelectedBranchAlt(); //! Used to return last selected branch left of a mapcenter + +public: + TreeItem* findMapItem (QPointF p,TreeItem* excludeTI); //! search map for branches or images. Ignore excludeTI, where search is started + + virtual void updateStyles (const bool &keepFrame=false); //! update related fonts, parObjects, links, ... + virtual BranchObj* getBranchObj(); + virtual BranchObj* createMapObj(QGraphicsScene *scene); //! Create classic object in GraphicsView +}; + +#endif diff --git a/branchobj.cpp b/branchobj.cpp new file mode 100644 index 0000000..8615ab8 --- /dev/null +++ b/branchobj.cpp @@ -0,0 +1,737 @@ +#include + +#include "branchobj.h" + +#include "attributeitem.h" +#include "branchitem.h" +#include "geometry.h" +#include "mapeditor.h" +#include "mainwindow.h" +#include "misc.h" + +extern FlagRow *standardFlagsMaster; +extern FlagRow *systemFlagsMaster; +extern bool debug; + +///////////////////////////////////////////////////////////////// +// BranchObj +///////////////////////////////////////////////////////////////// + +BranchObj::BranchObj (QGraphicsItem *parent,TreeItem *ti):OrnamentedObj (parent,ti) +{ + //qDebug ()<< "Const BranchObj (s,ti) ti="<parent()); + if (pi && pi!=ti->getModel()->getRootItem() ) + parObj=pi->getLMO(); + else + parObj=NULL; + init(); +} + +BranchObj::~BranchObj () +{ + //qDebug()<< "Destr BranchObj of "<getModel(); + model->stopAnimation (this); + } + + clear(); +} + +void BranchObj::init () +{ + if (parObj) absPos=parObj->getChildRefPos(); +} + +void BranchObj::copy (BranchObj* other) +{ + OrnamentedObj::copy(other); + + setVisibility (other->visible); + + positionBBox(); +} + +void BranchObj::clear() +{ +} + +void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off) +{ + // Temporary link to dst + // m is position of mouse pointer + // offset 0: default 1: below dst -1 above dst (if possible) + + BranchItem *dsti=(BranchItem*)(dst->getTreeItem()); + + BranchItem *pi=(BranchItem*)(dsti->parent()); + int pi_depth=pi->depth(); + BranchObj* bodst=(BranchObj*)dst; + + if (!tmpParent) + { + tmpParent=true; + parObjTmpBuf=parObj; + } + + if (pi_depth<1) off=0; + if (off==0) + link2ParPos=false; + else + link2ParPos=true; + parObj=bodst; + + setLinkStyle (dst->getDefLinkStyle (dsti)); + + // Move temporary to new position at destination + // Usually the positioning would be done by reposition(), + // but then also the destination branch would "Jump" around... + // Better just do it approximately + if (dsti->depth()==0) + { // new parent is a mapcenter + Vector v= ( m - bodst->getChildRefPos()); + v.normalize(); + v.scale (150); + move2RelPos (v.toQPointF()); + } else + { + qreal y; + if (off==0) + { + // Below is needed e.g. in a freshly loaded map, + // bboxTotal seems not to be correct yet + // relinking positions too far below then + calcBBoxSizeWithChildren(); + + // new parent is just a branch, link to it + bodst->calcBBoxSizeWithChildren(); + QRectF t = bodst->getTotalBBox(); + if (dsti->getLastBranch()) + // Move below children of destination + y = t.y() + t.height() ; + else + // Move left or right to destination + y = t.y() ; + } else + { + if (off < 0) + // we want to link above dst + y = bodst->y() - height() + 12; + else + // we want to link below dst + // Bottom of sel should be 5 pixels above + // the bottom of the branch _below_ the target: + // Don't try to find that branch, guess 12 pixels + y = bodst->getChildRefPos().y() -height() + 12; + } + if (bodst->getOrientation()==LinkableMapObj::LeftOfCenter) + move ( bodst->getChildRefPos().x() - linkwidth - bboxTotal.width(), y ); + else + move ( bodst->getChildRefPos().x() + linkwidth, y ); + } + + // updateLinkGeometry is called implicitly in move + requestReposition(); +} + +void BranchObj::unsetParObjTmp() +{ + if (tmpParent) + { + tmpParent=false; + link2ParPos=false; + parObj=parObjTmpBuf; + parObjTmpBuf=NULL; + setLinkStyle (getDefLinkStyle(treeItem->parent() ) ); + updateLinkGeometry(); + } +} + +void BranchObj::setVisibility(bool v, int toDepth) +{ + BranchItem *bi=(BranchItem*)treeItem; + if (bi->depth() <= toDepth) + { + frame->setVisibility(v); + heading->setVisibility(v); + systemFlags->setVisibility(v); + standardFlags->setVisibility(v); + LinkableMapObj::setVisibility (v); + int i; + for (i=0; iimageCount(); ++i) + treeItem->getImageObjNum(i)->setVisibility (v); + for (i=0; ixlinkCount(); ++i) + treeItem->getXLinkObjNum(i)->setVisibility (); + + // Only change children, if I am not scrolled + if (! bi->isScrolled() && (bi->depth() < toDepth)) + { + // Now go recursivly through all children + for (i=0; ibranchCount(); ++i) + treeItem->getBranchObjNum(i)->setVisibility (v,toDepth); + } + } +} + +void BranchObj::setVisibility(bool v) +{ + setVisibility (v,MAX_DEPTH); +} + + +void BranchObj::setLinkColor () +{ + // Overloaded from LinkableMapObj + // BranchObj can use color of heading + + VymModel *model=treeItem->getModel(); + if (model) + { + if (model->getMapLinkColorHint()==HeadingColor) + LinkableMapObj::setLinkColor (heading->getColor() ); + else + LinkableMapObj::setLinkColor (); + } +} + +void BranchObj::positionContents() +{ + OrnamentedObj::positionContents(); + updateLinkGeometry();// required before positioning images + for (int i=0; iimageCount(); ++i) + treeItem->getImageObjNum(i)->reposition(); +} + +void BranchObj::move (double x, double y) +{ + OrnamentedObj::move (x,y); +} + +void BranchObj::move (QPointF p) +{ + move (p.x(), p.y()); +} + +void BranchObj::moveBy (double x, double y) +{ + OrnamentedObj::moveBy (x,y); + for (int i=0; ibranchCount(); ++i) + treeItem->getBranchObjNum(i)->moveBy (x,y); + positionBBox(); +} + +void BranchObj::moveBy (QPointF p) +{ + moveBy (p.x(), p.y()); +} + +void BranchObj::positionBBox() // FIXME-3 consider dimensions of frame (thickness, geometry, padding... +{ + QPointF ap=getAbsPos(); + bbox.moveTopLeft (ap); + positionContents(); // this positions FIOs + + //Update links to other branches + XLinkObj *xlo; + for (int i=0; ixlinkCount(); ++i) + { + xlo=treeItem->getXLinkObjNum(i); + if (xlo) xlo->updateXLink(); + } +} + +void BranchObj::calcBBoxSize() +{ + QSizeF heading_r=heading->getSize(); + qreal heading_w=(qreal) heading_r.width() ; + qreal heading_h=(qreal) heading_r.height() ; + QSizeF sysflags_r=systemFlags->getSize(); + qreal sysflags_h=sysflags_r.height(); + qreal sysflags_w=sysflags_r.width(); + QSizeF stanflags_r=standardFlags->getSize(); + qreal stanflags_h=stanflags_r.height(); + qreal stanflags_w=stanflags_r.width(); + qreal w; + qreal h; + + // set width to sum of all widths + w=heading_w + sysflags_w + stanflags_w; + + // set height to maximum needed height + h=max (sysflags_h,stanflags_h); + h=max (h,heading_h); + + // Save the dimension of flags and heading + ornamentsBBox.setSize ( QSizeF(w,h)); + + // clickBox includes Flags and Heading + clickPoly=QPolygonF (ornamentsBBox); + + // Floatimages + QPointF rp; + + topPad = botPad = leftPad = rightPad = 0; + bool incV=((BranchItem*)treeItem)->getIncludeImagesVer(); + bool incH=((BranchItem*)treeItem)->getIncludeImagesHor(); + if (incH || incV) + { + FloatImageObj *fio; + for (int i=0; iimageCount(); ++i ) + { + fio=treeItem->getImageObjNum(i); + rp=fio->getRelPos(); + if (incV) + { + qreal y; + if (rp.y() > 0) + { + y = rp.y() + fio->height()/2 - ornamentsBBox.height()/2; + botPad = max(botPad, y); + } else + { + y=-rp.y() + fio->height()/2 - ornamentsBBox.height()/2; + topPad=max(topPad, y); + } + } + if (incH) + { + qreal x; + if (rp.x() > 0) + { + x=rp.x() + fio->width()/2 - ornamentsBBox.width()/2; + rightPad=max(rightPad, x); + } else + { + x=-rp.x() + fio->width()/2 - ornamentsBBox.width()/2; + leftPad=max(leftPad, x); + } + } + } + h += topPad + botPad; + w += leftPad + rightPad; + } + + // Frame thickness + w += frame->getTotalPadding() * 2; + h += frame->getTotalPadding() * 2; + + // Finally set size + bbox.setSize (QSizeF (w,h)); + //if (debug) qDebug()<<"BO: calcBBox "<getHeading()<<" bbox="<getType() == TreeItem::MapCenter) + { + // set childRefPos to middle of MapCenterObj + QRectF r=clickPoly.boundingRect(); + childRefPos.setX( r.topLeft().x() + r.width()/2 ); + childRefPos.setY( r.topLeft().y() + r.height()/2 ); + parPos=childRefPos; + for (int i=0; ibranchCount(); ++i) + treeItem->getBranchObjNum(i)->updateLinkGeometry(); + } else + { + if (orientation == LinkableMapObj::LeftOfCenter ) + { + // Left of center + if ( ((BranchItem*)treeItem)->getFrameIncludeChildren() ) + { + childRefPos=QPointF (ornamentsBBox.bottomLeft().x() - leftPad, bottomlineY); + parPos=QPointF (bboxTotal.bottomRight().x()-frame->getPadding()/2, bottomlineY); + } else + { + childRefPos=QPointF (ornamentsBBox.bottomLeft().x() - frame->getPadding(), bottomlineY); + parPos=QPointF (ornamentsBBox.bottomRight().x(), bottomlineY); + } + } else + { + // Right of center + if ( ((BranchItem*)treeItem)->getFrameIncludeChildren() ) + { + childRefPos=QPointF(ornamentsBBox.bottomRight().x() + rightPad , bottomlineY); + parPos=QPointF ( bboxTotal.bottomLeft().x()+frame->getPadding()/2, bottomlineY); + } else + { + childRefPos=QPointF(ornamentsBBox.bottomRight().x() + frame->getPadding(), bottomlineY); + parPos=QPointF ( ornamentsBBox.bottomLeft().x(), bottomlineY); + } + } + } +} + +void BranchObj::updateData() +{ + if (!treeItem) + { + qWarning ("BranchObj::udpateHeading treeItem==NULL"); + return; + } + QString s = treeItem->getHeadingText(); + if ( s!=heading->text()) heading->setText (s); + + QStringList TIactiveFlags=treeItem->activeStandardFlagNames(); + + // Add missing standard flags active in TreeItem + for (int i=0;i<=TIactiveFlags.size()-1;i++) + { + if (!standardFlags->isActive (TIactiveFlags.at(i) )) + { + Flag *f=standardFlagsMaster->getFlag(TIactiveFlags.at(i)); + if (f) standardFlags->activate (f); + } + } + // Remove standard flags no longer active in TreeItem + QStringList BOactiveFlags=standardFlags->activeFlagNames(); + for (int i=0;ideactivate (BOactiveFlags.at(i)); + + // Add missing system flags active in TreeItem + TIactiveFlags=treeItem->activeSystemFlagNames(); + for (int i=0;iisActive (TIactiveFlags.at(i) )) + { + Flag *f=systemFlagsMaster->getFlag(TIactiveFlags.at(i)); + if (f) systemFlags->activate (f); + } + } + // Remove system flags no longer active in TreeItem + BOactiveFlags=systemFlags->activeFlagNames(); + for (int i=0;ideactivate (BOactiveFlags.at(i)); + } + calcBBoxSize(); +} + +void BranchObj::setDefAttr (BranchModification mod, bool keepFrame) +{ + QFont font=treeItem->getModel()->getMapDefaultFont(); + qreal fontsize=font.pointSizeF(); + switch (treeItem->depth()) + { + case 0: + break; + case 1: + fontsize=fontsize-2; + break; + case 2: + fontsize=fontsize-4; + break; + default: + fontsize=fontsize-6; + break; + } + setLinkStyle(getDefLinkStyle(treeItem->parent() )); + setLinkColor (); + font.setPointSizeF (fontsize); + heading->setFont(font ); + + if (mod==NewBranch && !keepFrame) + { + if (treeItem->depth()==0) + setFrameType (FrameObj::Rectangle); + else + setFrameType (FrameObj::NoFrame); + } + if (mod==NewBranch) + setColor (treeItem->getHeadingColor() ); + else + { + // Relinked mapcenters + if (!keepFrame && getFrameType()!=FrameObj::NoFrame) + setFrameType (FrameObj::NoFrame); + + // Also set styles for children + for (int i=0; ibranchCount(); ++i) + treeItem->getBranchObjNum(i)->setDefAttr(MovedBranch, keepFrame); + } + calcBBoxSize(); +} + +void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf) +{ + // Define some heights + qreal th = bboxTotal.height(); + qreal ch=0; // Sum of childrens heights + for (int i=0; ibranchCount(); ++i) + ch+=treeItem->getBranchObjNum(i)->getTotalBBox().height(); + + int depth = 0; + BranchItem::LayoutHint layoutHint = BranchItem::AutoPositioning; + if (parObj) + { + TreeItem *pi = parObj->getTreeItem(); + depth = 1 + pi->depth(); + layoutHint = ((BranchItem*)treeItem)->parentBranch()->getChildrenLayout(); + } + + // set useRelPos, depending on layout + if (depth > 1) + { + if (layoutHint == BranchItem::FreePositioning) + { + if (!useRelPos) + { + useRelPos = true; + // if we used relPos before, set known positions + // "known" means any position != (0,0) + if (relPos == QPointF(0,0) ) + // use current position to get relPos() + setRelPos(); + } + } + else + useRelPos = false; + } + +// TODO testing +/* + if (debug) + { + QString o; + switch (orientation) + { + case UndefinedOrientation: o = "UndefOrientation"; break; + case LeftOfCenter: o = "LeftOfCenter"; break; + case RightOfCenter: o = "RightOfCenter"; break; + } + + QString h=QString (depth+1,' '); + h += treeItem->getHeadingPlain(); + h += QString (25,' '); + h.truncate (25); + QPointF pp; + if (parObj) pp = parObj->getChildRefPos(); + qDebug() << "BO::alignRelTo for "<