# HG changeset patch
# User insilmaril
# Date 1107089927 0
# Node ID 7a96bd401351c600aaa980f89970e74142fcc3dd
Initial import.
diff -r 000000000000 -r 7a96bd401351 LICENSE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSE Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,308 @@
+ VYM - View Your Mind
+ Copyright (C) 2004 Uwe Drechsel
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ 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 -r 000000000000 -r 7a96bd401351 Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,737 @@
+#############################################################################
+# Makefile for building: vym
+# Generated by qmake (1.07a) (Qt 3.3.1) on: Tue Jan 4 10:40:21 2005
+# Project: vym.pro
+# Template: app
+# Command: $(QMAKE) -o Makefile vym.pro
+#############################################################################
+
+####### Compiler, tools and options
+
+CC = gcc
+CXX = g++
+LEX = flex
+YACC = yacc
+CFLAGS = -pipe -O2 -fmessage-length=0 -Wall -fPIC -Wall -W -O2 -fmessage-length=0 -Wall -fPIC -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT
+CXXFLAGS = -pipe -O2 -fmessage-length=0 -Wall -fPIC -Wall -W -O2 -fmessage-length=0 -Wall -fPIC -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT
+LEXFLAGS =
+YACCFLAGS= -d
+INCPATH = -I/usr/lib/qt3/mkspecs/linux-g++ -I. -I/usr/include -I$(QTDIR)/include
+LINK = g++
+LFLAGS =
+LIBS = $(SUBLIBS) -L/usr/lib64/ -L$(QTDIR)/lib64/ -L/usr/X11R6/lib64/ -lqt-mt -lXext -lX11 -lm
+AR = ar cqs
+RANLIB =
+MOC = $(QTDIR)/bin/moc
+UIC = $(QTDIR)/bin/uic
+QMAKE = qmake
+TAR = tar -cf
+GZIP = gzip -9f
+COPY = cp -f
+COPY_FILE= $(COPY)
+COPY_DIR = $(COPY) -r
+INSTALL_FILE= $(COPY_FILE)
+INSTALL_DIR = $(COPY_DIR)
+DEL_FILE = rm -f
+SYMLINK = ln -sf
+DEL_DIR = rmdir
+MOVE = mv -f
+CHK_DIR_EXISTS= test -d
+MKDIR = mkdir -p
+
+####### Output directory
+
+OBJECTS_DIR = ./
+
+####### Files
+
+HEADERS = branchobj.h \
+ exports.h \
+ findwindow.h \
+ flagobj.h \
+ flagrowobj.h \
+ floatimageobj.h \
+ floatobj.h \
+ frameobj.h \
+ headingobj.h \
+ imageobj.h \
+ linkablemapobj.h \
+ mainwindow.h \
+ mapcenterobj.h \
+ mapeditor.h \
+ mapobj.h \
+ misc.h \
+ noteobj.h \
+ ornamentedobj.h \
+ process.h \
+ selection.h \
+ texteditor.h \
+ version.h \
+ xml.h \
+ settings.h \
+ options.h
+SOURCES = branchobj.cpp \
+ exports.cpp \
+ findwindow.cpp \
+ flagobj.cpp \
+ flagrowobj.cpp \
+ floatimageobj.cpp \
+ floatobj.cpp \
+ frameobj.cpp \
+ headingobj.cpp \
+ imageobj.cpp \
+ linkablemapobj.cpp \
+ main.cpp \
+ mainwindow.cpp \
+ mapcenterobj.cpp \
+ mapeditor.cpp \
+ mapobj.cpp \
+ misc.cpp \
+ noteobj.cpp \
+ ornamentedobj.cpp \
+ process.cpp \
+ selection.cpp \
+ texteditor.cpp \
+ xml.cpp \
+ settings.cpp \
+ options.cpp
+OBJECTS = branchobj.o \
+ exports.o \
+ findwindow.o \
+ flagobj.o \
+ flagrowobj.o \
+ floatimageobj.o \
+ floatobj.o \
+ frameobj.o \
+ headingobj.o \
+ imageobj.o \
+ linkablemapobj.o \
+ main.o \
+ mainwindow.o \
+ mapcenterobj.o \
+ mapeditor.o \
+ mapobj.o \
+ misc.o \
+ noteobj.o \
+ ornamentedobj.o \
+ process.o \
+ selection.o \
+ texteditor.o \
+ xml.o \
+ settings.o \
+ options.o \
+ exporthtmldialog.o \
+ exportxhtmldialog.o \
+ showtextdialog.o \
+ extrainfodialog.o
+FORMS = exporthtmldialog.ui \
+ exportxhtmldialog.ui \
+ showtextdialog.ui \
+ extrainfodialog.ui
+UICDECLS = exporthtmldialog.h \
+ exportxhtmldialog.h \
+ showtextdialog.h \
+ extrainfodialog.h
+UICIMPLS = exporthtmldialog.cpp \
+ exportxhtmldialog.cpp \
+ showtextdialog.cpp \
+ extrainfodialog.cpp
+SRCMOC = moc_findwindow.cpp \
+ moc_linkablemapobj.cpp \
+ moc_mainwindow.cpp \
+ moc_mapeditor.cpp \
+ moc_ornamentedobj.cpp \
+ moc_process.cpp \
+ moc_texteditor.cpp \
+ moc_exporthtmldialog.cpp \
+ moc_exportxhtmldialog.cpp \
+ moc_showtextdialog.cpp \
+ moc_extrainfodialog.cpp
+OBJMOC = moc_findwindow.o \
+ moc_linkablemapobj.o \
+ moc_mainwindow.o \
+ moc_mapeditor.o \
+ moc_ornamentedobj.o \
+ moc_process.o \
+ moc_texteditor.o \
+ moc_exporthtmldialog.o \
+ moc_exportxhtmldialog.o \
+ moc_showtextdialog.o \
+ moc_extrainfodialog.o
+DIST = vym.pro
+QMAKE_TARGET = vym
+DESTDIR =
+TARGET = vym
+
+first: all
+####### Implicit rules
+
+.SUFFIXES: .c .o .cpp .cc .cxx .C
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
+
+####### Build rules
+
+all: Makefile $(TARGET)
+
+$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
+ $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(OBJCOMP) $(LIBS)
+
+mocables: $(SRCMOC)
+uicables: $(UICDECLS) $(UICIMPLS)
+
+$(MOC):
+ ( cd $(QTDIR)/src/moc && $(MAKE) )
+
+Makefile: vym.pro /usr/lib/qt3/mkspecs/linux-g++/qmake.conf /usr/lib/qt3/lib64/libqt-mt.prl
+ $(QMAKE) -o Makefile vym.pro
+qmake:
+ @$(QMAKE) -o Makefile vym.pro
+
+dist:
+ @mkdir -p .tmp/vym && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .tmp/vym/ && $(COPY_FILE) --parents vym_de.ts .tmp/vym/ && $(COPY_FILE) --parents exporthtmldialog.ui.h exportxhtmldialog.ui.h showtextdialog.ui.h extrainfodialog.ui.h .tmp/vym/ && ( cd `dirname .tmp/vym` && $(TAR) vym.tar vym && $(GZIP) vym.tar ) && $(MOVE) `dirname .tmp/vym`/vym.tar.gz . && $(DEL_FILE) -r .tmp/vym
+
+mocclean:
+ -$(DEL_FILE) $(OBJMOC)
+ -$(DEL_FILE) $(SRCMOC)
+
+uiclean:
+ -$(DEL_FILE) $(UICIMPLS) $(UICDECLS)
+
+yaccclean:
+lexclean:
+clean: mocclean uiclean
+ -$(DEL_FILE) $(OBJECTS)
+ -$(DEL_FILE) *~ core *.core
+
+
+####### Sub-libraries
+
+distclean: clean
+ -$(DEL_FILE) $(TARGET) $(TARGET)
+
+
+FORCE:
+
+####### Compile
+
+branchobj.o: branchobj.cpp branchobj.h \
+ texteditor.h \
+ mapeditor.h \
+ mainwindow.h \
+ floatimageobj.h \
+ linkablemapobj.h \
+ ornamentedobj.h \
+ floatobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h \
+ mapcenterobj.h \
+ version.h \
+ xml.h \
+ findwindow.h
+
+exports.o: exports.cpp exports.h \
+ linkablemapobj.h \
+ mapcenterobj.h \
+ branchobj.h \
+ version.h \
+ floatimageobj.h \
+ ornamentedobj.h \
+ floatobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h
+
+findwindow.o: findwindow.cpp findwindow.h
+
+flagobj.o: flagobj.cpp flagobj.h \
+ mapobj.h \
+ imageobj.h \
+ misc.h
+
+flagrowobj.o: flagrowobj.cpp flagrowobj.h \
+ mapobj.h \
+ flagobj.h \
+ misc.h \
+ imageobj.h
+
+floatimageobj.o: floatimageobj.cpp floatimageobj.h \
+ branchobj.h \
+ floatobj.h \
+ linkablemapobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h \
+ ornamentedobj.h
+
+floatobj.o: floatobj.cpp floatobj.h \
+ linkablemapobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h
+
+frameobj.o: frameobj.cpp frameobj.h \
+ mapobj.h \
+ misc.h
+
+headingobj.o: headingobj.cpp headingobj.h \
+ mapobj.h \
+ misc.h
+
+imageobj.o: imageobj.cpp imageobj.h \
+ mapobj.h \
+ misc.h
+
+linkablemapobj.o: linkablemapobj.cpp linkablemapobj.h \
+ branchobj.h \
+ mapeditor.h \
+ version.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h \
+ floatimageobj.h \
+ ornamentedobj.h \
+ floatobj.h \
+ mapcenterobj.h
+
+main.o: main.cpp settings.h \
+ options.h \
+ mainwindow.h \
+ icons/vym-48x48.xpm \
+ icons/vym-editor.xpm \
+ flagrowobj.h \
+ misc.h \
+ xml.h \
+ texteditor.h \
+ mapeditor.h \
+ findwindow.h \
+ mapcenterobj.h \
+ branchobj.h \
+ version.h \
+ floatimageobj.h \
+ linkablemapobj.h \
+ ornamentedobj.h \
+ floatobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ mapobj.h \
+ flagobj.h \
+ imageobj.h
+
+mainwindow.o: mainwindow.cpp mainwindow.h \
+ version.h \
+ icons/filenew.xpm \
+ icons/fileopen.xpm \
+ icons/filesave.xpm \
+ icons/fileprint.xpm \
+ icons/editundo.xpm \
+ icons/editcopy.xpm \
+ icons/editcut.xpm \
+ icons/editpaste.xpm \
+ icons/editmoveup.xpm \
+ icons/editmovedown.xpm \
+ icons/formatcoloritem.xpm \
+ icons/formatcolorbranch.xpm \
+ icons/formatcolorpicker.xpm \
+ icons/viewzoomreset.xpm \
+ icons/viewzoomin.xpm \
+ icons/viewzoomout.xpm \
+ icons/vym-48x48.xpm \
+ icons/flag-note.xpm \
+ icons/flag-url.xpm \
+ icons/flag-vymlink.xpm \
+ icons/flag-scrolled-right.xpm \
+ flagrowobj.h \
+ texteditor.h \
+ mapeditor.h \
+ exporthtmldialog.h \
+ exportxhtmldialog.h \
+ showtextdialog.h \
+ process.h \
+ settings.h \
+ options.h \
+ xml.h \
+ findwindow.h \
+ mapcenterobj.h \
+ branchobj.h \
+ floatimageobj.h \
+ linkablemapobj.h \
+ ornamentedobj.h \
+ floatobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h
+
+mapcenterobj.o: mapcenterobj.cpp mapcenterobj.h \
+ floatimageobj.h \
+ mapeditor.h \
+ branchobj.h \
+ version.h \
+ linkablemapobj.h \
+ ornamentedobj.h \
+ floatobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h
+
+mapeditor.o: mapeditor.cpp mapeditor.h \
+ version.h \
+ xml.h \
+ texteditor.h \
+ linkablemapobj.h \
+ exports.h \
+ misc.h \
+ mainwindow.h \
+ extrainfodialog.h \
+ settings.h \
+ icons/flag-note.xpm \
+ icons/flag-url.xpm \
+ icons/flag-vymlink.xpm \
+ icons/flag-scrolled-right.xpm \
+ icons/flag-tmpUnscrolled-right.xpm \
+ icons/flag-questionmark.xpm \
+ icons/flag-exclamationmark.xpm \
+ icons/flag-hook-green.xpm \
+ icons/flag-cross-red.xpm \
+ icons/flag-stopsign.xpm \
+ icons/flag-smiley-good.xpm \
+ icons/flag-smiley-sad.xpm \
+ icons/flag-clock.xpm \
+ icons/flag-lamp.xpm \
+ icons/flag-arrow-up.xpm \
+ icons/flag-arrow-down.xpm \
+ icons/flag-thumb-up.xpm \
+ icons/flag-thumb-down.xpm \
+ icons/flag-heart.xpm \
+ icons/flag-flash.xpm \
+ icons/flag-lifebelt.xpm \
+ mapcenterobj.h \
+ branchobj.h \
+ floatimageobj.h \
+ ornamentedobj.h \
+ floatobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ flagobj.h \
+ imageobj.h \
+ findwindow.h
+
+mapobj.o: mapobj.cpp mapobj.h \
+ misc.h
+
+misc.o: misc.cpp misc.h
+
+noteobj.o: noteobj.cpp noteobj.h \
+ misc.h
+
+ornamentedobj.o: ornamentedobj.cpp ornamentedobj.h \
+ texteditor.h \
+ mapeditor.h \
+ linkablemapobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h \
+ mapcenterobj.h \
+ branchobj.h \
+ version.h \
+ floatimageobj.h \
+ floatobj.h
+
+process.o: process.cpp process.h
+
+selection.o: selection.cpp selection.h \
+ linkablemapobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h
+
+texteditor.o: texteditor.cpp texteditor.h \
+ icons/fileopen.xpm \
+ icons/filesave.xpm \
+ icons/fileprint.xpm \
+ icons/editundo.xpm \
+ icons/editredo.xpm \
+ icons/editcopy.xpm \
+ icons/editcut.xpm \
+ icons/editpaste.xpm \
+ icons/edittrash.xpm \
+ icons/formatfixedfont.xpm \
+ icons/formattextbold.xpm \
+ icons/formattextitalic.xpm \
+ icons/formattextunder.xpm \
+ icons/formattextleft.xpm \
+ icons/formattextcenter.xpm \
+ icons/formattextright.xpm \
+ icons/formattextjustify.xpm
+
+xml.o: xml.cpp xml.h \
+ misc.h \
+ settings.h \
+ version.h \
+ mapcenterobj.h \
+ mapeditor.h \
+ branchobj.h \
+ floatimageobj.h \
+ linkablemapobj.h \
+ ornamentedobj.h \
+ floatobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ flagobj.h \
+ imageobj.h
+
+settings.o: settings.cpp settings.h \
+ misc.h
+
+options.o: options.cpp options.h
+
+exporthtmldialog.h: exporthtmldialog.ui showtextdialog.h
+ $(UIC) exporthtmldialog.ui -o exporthtmldialog.h
+
+exporthtmldialog.cpp: exporthtmldialog.h exporthtmldialog.ui showtextdialog.h
+ $(UIC) exporthtmldialog.ui -i exporthtmldialog.h -o exporthtmldialog.cpp
+
+exportxhtmldialog.h: exportxhtmldialog.ui process.h \
+ showtextdialog.h
+ $(UIC) exportxhtmldialog.ui -o exportxhtmldialog.h
+
+exportxhtmldialog.cpp: exportxhtmldialog.h exportxhtmldialog.ui process.h \
+ showtextdialog.h
+ $(UIC) exportxhtmldialog.ui -i exportxhtmldialog.h -o exportxhtmldialog.cpp
+
+showtextdialog.h: showtextdialog.ui
+ $(UIC) showtextdialog.ui -o showtextdialog.h
+
+showtextdialog.cpp: showtextdialog.h showtextdialog.ui
+ $(UIC) showtextdialog.ui -i showtextdialog.h -o showtextdialog.cpp
+
+extrainfodialog.h: extrainfodialog.ui
+ $(UIC) extrainfodialog.ui -o extrainfodialog.h
+
+extrainfodialog.cpp: extrainfodialog.h extrainfodialog.ui
+ $(UIC) extrainfodialog.ui -i extrainfodialog.h -o extrainfodialog.cpp
+
+exporthtmldialog.o: exporthtmldialog.cpp settings.h \
+ misc.h \
+ icons/flag-url.xpm \
+ exporthtmldialog.ui.h \
+ exporthtmldialog.h
+
+exportxhtmldialog.o: exportxhtmldialog.cpp settings.h \
+ icons/flag-url.xpm \
+ exportxhtmldialog.ui.h \
+ exportxhtmldialog.h
+
+showtextdialog.o: showtextdialog.cpp showtextdialog.ui.h \
+ showtextdialog.h
+
+extrainfodialog.o: extrainfodialog.cpp extrainfodialog.ui.h \
+ extrainfodialog.h
+
+moc_findwindow.o: moc_findwindow.cpp findwindow.h
+
+moc_linkablemapobj.o: moc_linkablemapobj.cpp linkablemapobj.h frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h
+
+moc_mainwindow.o: moc_mainwindow.cpp mainwindow.h xml.h \
+ texteditor.h \
+ mapeditor.h \
+ findwindow.h \
+ mapcenterobj.h \
+ branchobj.h \
+ version.h \
+ floatimageobj.h \
+ linkablemapobj.h \
+ ornamentedobj.h \
+ floatobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h
+
+moc_mapeditor.o: moc_mapeditor.cpp mapeditor.h mapcenterobj.h \
+ misc.h \
+ branchobj.h \
+ version.h \
+ floatimageobj.h \
+ linkablemapobj.h \
+ ornamentedobj.h \
+ floatobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ flagobj.h \
+ imageobj.h
+
+moc_ornamentedobj.o: moc_ornamentedobj.cpp ornamentedobj.h linkablemapobj.h \
+ frameobj.h \
+ noteobj.h \
+ headingobj.h \
+ flagrowobj.h \
+ mapobj.h \
+ misc.h \
+ flagobj.h \
+ imageobj.h
+
+moc_process.o: moc_process.cpp process.h
+
+moc_texteditor.o: moc_texteditor.cpp texteditor.h
+
+moc_exporthtmldialog.o: moc_exporthtmldialog.cpp exporthtmldialog.h showtextdialog.h
+
+moc_exportxhtmldialog.o: moc_exportxhtmldialog.cpp exportxhtmldialog.h process.h \
+ showtextdialog.h
+
+moc_showtextdialog.o: moc_showtextdialog.cpp showtextdialog.h
+
+moc_extrainfodialog.o: moc_extrainfodialog.cpp extrainfodialog.h
+
+moc_findwindow.cpp: $(MOC) findwindow.h
+ $(MOC) findwindow.h -o moc_findwindow.cpp
+
+moc_linkablemapobj.cpp: $(MOC) linkablemapobj.h
+ $(MOC) linkablemapobj.h -o moc_linkablemapobj.cpp
+
+moc_mainwindow.cpp: $(MOC) mainwindow.h
+ $(MOC) mainwindow.h -o moc_mainwindow.cpp
+
+moc_mapeditor.cpp: $(MOC) mapeditor.h
+ $(MOC) mapeditor.h -o moc_mapeditor.cpp
+
+moc_ornamentedobj.cpp: $(MOC) ornamentedobj.h
+ $(MOC) ornamentedobj.h -o moc_ornamentedobj.cpp
+
+moc_process.cpp: $(MOC) process.h
+ $(MOC) process.h -o moc_process.cpp
+
+moc_texteditor.cpp: $(MOC) texteditor.h
+ $(MOC) texteditor.h -o moc_texteditor.cpp
+
+moc_exporthtmldialog.cpp: $(MOC) exporthtmldialog.h
+ $(MOC) exporthtmldialog.h -o moc_exporthtmldialog.cpp
+
+moc_exportxhtmldialog.cpp: $(MOC) exportxhtmldialog.h
+ $(MOC) exportxhtmldialog.h -o moc_exportxhtmldialog.cpp
+
+moc_showtextdialog.cpp: $(MOC) showtextdialog.h
+ $(MOC) showtextdialog.h -o moc_showtextdialog.cpp
+
+moc_extrainfodialog.cpp: $(MOC) extrainfodialog.h
+ $(MOC) extrainfodialog.h -o moc_extrainfodialog.cpp
+
+####### Install
+
+install_target: all
+ @$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)/usr/bin/" || $(MKDIR) "$(INSTALL_ROOT)/usr/bin/"
+ -$(INSTALL_FILE) "$(QMAKE_TARGET)" "$(INSTALL_ROOT)/usr/bin/$(QMAKE_TARGET)"
+
+uninstall_target:
+ -$(DEL_FILE) "$(INSTALL_ROOT)/usr/bin/$(QMAKE_TARGET)"
+ -$(DEL_DIR) "$(INSTALL_ROOT)/usr/bin/"
+
+
+install_support: all
+ @$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)/usr/share/vym/" || $(MKDIR) "$(INSTALL_ROOT)/usr/share/vym/"
+ -$(INSTALL_DIR) "styles" "$(INSTALL_ROOT)/usr/share/vym/"
+ -$(INSTALL_DIR) "scripts" "$(INSTALL_ROOT)/usr/share/vym/"
+ -$(INSTALL_DIR) "icons" "$(INSTALL_ROOT)/usr/share/vym/"
+
+
+uninstall_support:
+ -$(DEL_FILE) -r "$(INSTALL_ROOT)/usr/share/vym/styles"
+ -$(DEL_FILE) -r "$(INSTALL_ROOT)/usr/share/vym/scripts"
+ -$(DEL_FILE) -r "$(INSTALL_ROOT)/usr/share/vym/icons"
+ -$(DEL_DIR) "$(INSTALL_ROOT)/usr/share/vym/"
+
+
+install_demo: all
+ @$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)/usr/share/vym/" || $(MKDIR) "$(INSTALL_ROOT)/usr/share/vym/"
+ -$(INSTALL_DIR) "demos" "$(INSTALL_ROOT)/usr/share/vym/"
+
+
+uninstall_demo:
+ -$(DEL_FILE) -r "$(INSTALL_ROOT)/usr/share/vym/demos"
+ -$(DEL_DIR) "$(INSTALL_ROOT)/usr/share/vym/"
+
+
+install: install_target install_support install_demo
+
+uninstall: uninstall_target uninstall_support uninstall_demo
+
diff -r 000000000000 -r 7a96bd401351 branchobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/branchobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,1184 @@
+#include "branchobj.h"
+#include "texteditor.h"
+#include "mapeditor.h"
+#include "mainwindow.h"
+
+extern TextEditor *textEditor;
+extern Main *mainWindow;
+extern FlagRowObj *standardFlagsDefault;
+extern QAction *actionEditOpenURL;
+
+
+/////////////////////////////////////////////////////////////////
+// BranchObj
+/////////////////////////////////////////////////////////////////
+
+BranchObj* BranchObj::itLast=NULL;
+
+
+BranchObj::BranchObj () :OrnamentedObj()
+{
+// cout << "Const BranchObj ()\n";
+ setParObj (this);
+ init();
+ depth=-1;
+}
+
+BranchObj::BranchObj (QCanvas* c):OrnamentedObj (c)
+{
+// cout << "Const BranchObj (c) called from MapCenterObj (c)\n";
+ canvas=c;
+}
+
+BranchObj::BranchObj (QCanvas* c, LinkableMapObj* p):OrnamentedObj (c)
+{
+// cout << "Const BranchObj (c,p)\n";
+ canvas=c;
+ setParObj (p);
+ depth=p->getDepth()+1;
+ if (depth==1)
+ // Calc angle to mapCenter if I am a mainbranch
+ // needed for reordering the mainbranches clockwise
+ // around mapcenter
+ angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
+ (int)(y() - parObj->getChildPos().y() ) ) );
+ init();
+}
+
+BranchObj::~BranchObj ()
+{
+ //cout << "Destr BranchObj\n";
+ // Check, if this branch was the last child to be deleted
+ // If so, unset the scrolled flags
+
+ BranchObj *po=(BranchObj*)(parObj);
+ if (po)
+ {
+ BranchObj *bo=((BranchObj*)(parObj))->getLastBranch();
+ if (!bo) po->unScroll();
+ }
+}
+
+bool BranchObj::operator< ( const BranchObj & other )
+{
+ return angle < other.angle;
+}
+
+bool BranchObj::operator== ( const BranchObj & other )
+{
+ return angle == other.angle;
+}
+
+int BranchObjPtrList::compareItems ( QPtrCollection::Item i, QPtrCollection::Item j)
+{
+ // Make sure PtrList::find works
+ if (i==j) return 0;
+
+ if ( ((BranchObj*)(i))->angle > ((BranchObj*)(j))->angle )
+ return 1;
+ else
+ return -1;
+}
+
+void BranchObj::init ()
+{
+ branch.setAutoDelete (true);
+ floatimage.setAutoDelete (true);
+
+ absPos=getRandPos();
+ absPos+=parObj->getChildPos();
+
+ // TODO This should be done in TextObj later
+ QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
+// font.setPointSize(12);
+ heading->setFont(font );
+// heading->setText(QObject::tr("new branch"));
+
+ lastSelectedBranch=-1;
+
+ setChildObj(this);
+
+ scrolled=false;
+ tmpUnscrolled=false;
+
+ url="";
+ vymLink="";
+}
+
+void BranchObj::copy (BranchObj* other)
+{
+ OrnamentedObj::copy(other);
+
+ branch.clear();
+ BranchObj* b;
+ for (b=other->branch.first(); b;b=other->branch.next() )
+ // Make deep copy of b
+ // Because addBranch again calls copy for the childs,
+ // Those will get a deep copy, too
+ addBranch(b);
+
+ FloatImageObj *fi;
+ for (fi=other->floatimage.first(); fi;fi=other->floatimage.next() )
+ addFloatImage (fi);
+
+ scrolled=other->scrolled;
+ tmpUnscrolled=other->tmpUnscrolled;
+ setVisibility (other->visible);
+
+ url=other->url;
+ vymLink=other->vymLink;
+
+ angle=other->angle;
+
+ positionBBox();
+}
+
+void BranchObj::clear()
+{
+ branch.clear();
+ floatimage.clear();
+}
+
+int BranchObj::getNum()
+{
+ if (parObj)
+ return ((BranchObj*)(parObj))->getNum ((BranchObj*)(this));
+ else
+ return 0;
+}
+
+int BranchObj::getNum(BranchObj *bo)
+{
+ return branch.findRef (bo);
+}
+
+int BranchObj::getFloatImageNum(FloatImageObj *fio)
+{
+ return floatimage.findRef (fio);
+}
+
+int BranchObj::countBranches()
+{
+ return branch.count();
+}
+
+int BranchObj::countFloatImages()
+{
+ return floatimage.count();
+}
+
+void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
+{
+ // Temporary link to lmo
+ // m is position of mouse pointer
+ // offset 0: default 1: below lmo -1 above lmo (if possible)
+
+
+ BranchObj* o=(BranchObj*)(lmo);
+ if (!parObjTmpBuf)
+ parObjTmpBuf=parObj;
+
+ // ignore mapcenter and mainbranch
+ if (lmo->getDepth()<2) off=0;
+ if (off==0)
+ {
+ link2ParPos=false;
+ parObj=o;
+ }
+ else
+ {
+ link2ParPos=true;
+ if (off>0)
+ parObj=o->getParObj();
+ else
+ parObj=o->getParObj();
+ parObj=o;
+ }
+
+ depth=parObj->getDepth()+1;
+
+ // setLinkStyle calls updateLink, only set it once
+ if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
+
+ // 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 (depth==1)
+ { // new parent is the mapcenter itself
+
+ QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
+ m.y() - o->getChildPos().y() ));
+ if (p.x()<0) p.setX( p.x()-bbox.width() );
+ move2RelPos (p);
+ } else
+ {
+ int y;
+ if (off==0)
+ {
+ // new parent is just a branch, link to it
+ QRect t=o->getBBoxSizeWithChilds();
+ if (o->getLastBranch())
+ y=t.y() + t.height() ;
+ else
+ y=t.y();
+
+ } else
+ {
+ if (off<0)
+ // we want to link above lmo
+ y=o->y() - height() + 5;
+ else
+ // we want to link below lmo
+ // 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=o->getChildPos().y() -height() + 12;
+ }
+ if (o->getOrientation()==OrientLeftOfCenter)
+ move ( o->getChildPos().x() - linkwidth, y );
+ else
+ move (o->getChildPos().x() + linkwidth, y );
+ }
+
+ // updateLink is called implicitly in move
+ reposition(); // FIXME shouldn't be this a request?
+}
+
+void BranchObj::unsetParObjTmp()
+{
+ if (parObjTmpBuf)
+ {
+ link2ParPos=false;
+ parObj=parObjTmpBuf;
+ parObjTmpBuf=NULL;
+ depth=parObj->getDepth()+1;
+ setLinkStyle (getDefLinkStyle() );
+ }
+}
+
+void BranchObj::unScroll()
+{
+ if (tmpUnscrolled) resetTmpUnscroll();
+ if (scrolled) toggleScroll();
+}
+
+void BranchObj::toggleScroll()
+{
+ BranchObj *bo;
+ if (scrolled)
+ {
+ scrolled=false;
+ systemFlags->deactivate("scrolledright");
+ for (bo=branch.first(); bo; bo=branch.next() )
+ {
+ bo->setVisibility(true);
+ }
+ } else
+ {
+ scrolled=true;
+ systemFlags->activate("scrolledright");
+ for (bo=branch.first(); bo; bo=branch.next() )
+ {
+ bo->setVisibility(false);
+ }
+ }
+ calcBBoxSize();
+ positionBBox();
+ move (absPos.x(), absPos.y() );
+ forceReposition();
+}
+
+bool BranchObj::isScrolled()
+{
+ return scrolled;
+}
+
+bool BranchObj::hasScrolledParent(BranchObj *start)
+{
+ // Calls parents recursivly to
+ // find out, if we are scrolled at all.
+ // But ignore myself, just look at parents.
+
+ if (this !=start && scrolled) return true;
+
+ BranchObj* bo=(BranchObj*)(parObj);
+ if (bo)
+ return bo->hasScrolledParent(start);
+ else
+ return false;
+}
+
+void BranchObj::tmpUnscroll()
+{
+ // Unscroll parent (recursivly)
+ BranchObj* bo=(BranchObj*)(parObj);
+ if (bo) bo->tmpUnscroll();
+
+ // Unscroll myself
+ if (scrolled)
+ {
+ tmpUnscrolled=true;
+ systemFlags->activate("tmpUnscrolledright");
+ toggleScroll();
+ }
+}
+
+void BranchObj::resetTmpUnscroll()
+{
+ // Unscroll parent (recursivly)
+ BranchObj* bo=(BranchObj*)(parObj);
+ if (bo)
+ bo->resetTmpUnscroll();
+
+ // Unscroll myself
+ if (tmpUnscrolled)
+ {
+ tmpUnscrolled=false;
+ systemFlags->deactivate("tmpUnscrolledright");
+ toggleScroll();
+ }
+}
+
+void BranchObj::setVisibility(bool v, int toDepth)
+{
+ if (depth <= toDepth)
+ {
+ frame->setVisibility(v);
+ heading->setVisibility(v);
+ systemFlags->setVisibility(v);
+ standardFlags->setVisibility(v);
+ LinkableMapObj::setVisibility (v);
+
+ if (!scrolled && (depth < toDepth))
+ {
+ // Now go recursivly through all childs
+ BranchObj* b;
+ for (b=branch.first(); b;b=branch.next() )
+ b->setVisibility (v,toDepth);
+ FloatImageObj *fio;
+ for (fio=floatimage.first(); fio; fio=floatimage.next())
+ fio->setVisibility (v);
+ }
+ } // depth <= toDepth
+ move (absPos.x(), absPos.y() );
+ requestReposition();
+}
+
+void BranchObj::setVisibility(bool v)
+{
+ setVisibility (v,MAX_DEPTH);
+}
+
+
+void BranchObj::setLinkColor ()
+{
+ // Overloaded from LinkableMapObj
+ // BranchObj can use color of heading
+
+ if (mapEditor->getLinkColorHint()==HeadingColor)
+ LinkableMapObj::setLinkColor (heading->getColor() );
+ else
+ LinkableMapObj::setLinkColor ();
+}
+
+void BranchObj::setColor (QColor col, bool colorChilds)
+{
+ heading->setColor(col);
+ setLinkColor();
+ if (colorChilds)
+ {
+ BranchObj *bo;
+ for (bo=branch.first(); bo; bo=branch.next() )
+ bo->setColor(col,colorChilds);
+ }
+}
+
+
+BranchObj* BranchObj::first()
+{
+ itLast=NULL;
+ return this;
+}
+
+BranchObj* BranchObj::next()
+{
+ BranchObj *lmo;
+ BranchObj *bo=branch.first();
+ BranchObj *po=(BranchObj*)(parObj);
+
+ if (!itLast)
+ { // We are just beginning at the mapCenter
+ if (bo)
+ {
+ itLast=this;
+ return bo;
+ }
+ else
+ {
+ itLast=NULL;
+ return NULL;
+ }
+ }
+
+ if (itLast==parObj)
+ { // We come from above
+ if (bo)
+ {
+ // there are childs, go there
+ itLast=this;
+ return bo;
+ }
+ else
+ { // no childs, try to go up again
+ if (po)
+ {
+ // go up
+ itLast=this;
+ lmo=po->next();
+ itLast=this;
+ return lmo;
+
+ }
+ else
+ {
+ // can't go up, I am mapCenter
+ itLast=NULL;
+ return NULL;
+ }
+ }
+ }
+
+ // Try to find last child, we came from, in my own childs
+ bool searching=true;
+ while (bo && searching)
+ {
+ if (itLast==bo) searching=false;
+ bo=branch.next();
+ }
+ if (!searching)
+ { // found lastLMO in my childs
+ if (bo)
+ {
+ // found a brother of lastLMO
+ itLast=this;
+ return bo;
+ }
+ else
+ {
+ if (po)
+ {
+ // go up
+ itLast=this;
+ lmo=po->next();
+ itLast=this;
+ return lmo;
+ }
+ else
+ {
+ // can't go up, I am mapCenter
+ itLast=NULL;
+ return NULL;
+ }
+ }
+ }
+
+ // couldn't find last child, it must be a nephew of mine
+ bo=branch.first();
+ if (bo)
+ {
+ // proceed with my first child
+ itLast=this;
+ return bo;
+ }
+ else
+ {
+ // or go back to my parents
+ if (po)
+ {
+ // go up
+ itLast=this;
+ lmo=po->next();
+ itLast=this;
+ return lmo;
+ }
+ else
+ {
+ // can't go up, I am mapCenter
+ itLast=NULL;
+ return NULL;
+ }
+ }
+}
+
+BranchObj* BranchObj::getLastIterator()
+{
+ return itLast;
+}
+
+void BranchObj::setLastIterator(BranchObj* it)
+{
+ itLast=it;
+}
+
+
+void BranchObj::move (double x, double y)
+{
+ OrnamentedObj::move (x,y);
+ positionBBox();
+}
+
+void BranchObj::move (QPoint p)
+{
+ move (p.x(), p.y());
+}
+
+void BranchObj::moveBy (double x, double y)
+{
+ OrnamentedObj::moveBy (x,y);
+ positionBBox();
+ BranchObj* b;
+ for (b=branch.first(); b;b=branch.next() )
+ b->moveBy (x,y);
+}
+
+void BranchObj::moveBy (QPoint p)
+{
+ moveBy (p.x(), p.y());
+}
+
+
+void BranchObj::positionBBox()
+{
+
+ heading->positionBBox();
+ systemFlags->positionBBox();
+ standardFlags->positionBBox();
+ // It seems that setting x,y also affects width,height
+ int w_old=bbox.width();
+ int h_old=bbox.height();
+ bbox.setX (absPos.x() );
+ bbox.setY (absPos.y() );
+ bbox.setWidth(w_old);
+ bbox.setHeight(h_old);
+
+
+ setSelBox();
+
+ // set the frame
+ frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
+}
+
+void BranchObj::calcBBoxSize()
+{
+ QSize heading_r=heading->getSize();
+ int heading_w=static_cast (heading_r.width() );
+ int heading_h=static_cast (heading_r.height() );
+ QSize sysflags_r=systemFlags->getSize();
+ int sysflags_h=sysflags_r.height();
+ int sysflags_w=sysflags_r.width();
+ QSize stanflags_r=standardFlags->getSize();
+ int stanflags_h=stanflags_r.height();
+ int stanflags_w=stanflags_r.width();
+ int w;
+ int 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);
+
+ w+=frame->getBorder();
+ h+=frame->getBorder();
+ bbox.setSize (QSize (w,h));
+}
+
+LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
+{
+ // Search branches
+ BranchObj *b;
+ LinkableMapObj *lmo;
+ for (b=branch.first(); b; b=branch.next() )
+ {
+ lmo=b->findMapObj(p, excludeLMO);
+ if (lmo != NULL) return lmo;
+ }
+
+ // Search myself
+ if (inBBox (p) && (this != excludeLMO) && isVisibleObj() )
+ return this;
+
+ // Search float images
+ FloatImageObj *foi;
+ for (foi=floatimage.first(); foi; foi=floatimage.next() )
+ if (foi->inBBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
+
+ return NULL;
+}
+
+void BranchObj::setHeading(QString s)
+{
+ // Adjusting font size
+ QFont font=heading->getFont();
+ if (depth==0)
+ font.setPointSize(16);
+ else
+ if (depth>1)
+ font.setPointSize(10);
+ else
+ font.setPointSize(12);
+ heading->setFont(font);
+ heading->setText(s); // set new heading
+ calcBBoxSize(); // recalculate bbox
+ positionBBox(); // rearrange contents
+ requestReposition();
+}
+
+void BranchObj::setURL(QString s)
+{
+ url=s;
+ if (!url.isEmpty())
+ systemFlags->activate("url");
+ else
+ systemFlags->deactivate("url");
+ calcBBoxSize(); // recalculate bbox
+ positionBBox(); // rearrange contents
+ forceReposition();
+}
+
+QString BranchObj::getURL()
+{
+ return url;
+}
+
+void BranchObj::setVymLink(QString s)
+{
+ if (!s.isEmpty())
+ {
+ // We need the relative (from loading)
+ // or absolute path (from User event)
+ // and build the absolute path.
+ // Note: If we have relative, use path of
+ // current map to build absolute path
+ QDir d(s);
+ if (!d.path().startsWith ("/"))
+ {
+ QString p=mapEditor->getDestPath();
+ int i=p.findRev("/",-1);
+ d.setPath(p.left(i)+"/"+s);
+ d.convertToAbs();
+ }
+ vymLink=d.path();
+ systemFlags->activate("vymLink");
+ }
+ else
+ {
+ systemFlags->deactivate("vymLink");
+ vymLink="";
+ }
+ calcBBoxSize(); // recalculate bbox
+ positionBBox(); // rearrange contents
+ forceReposition();
+}
+
+QString BranchObj::getVymLink()
+{
+ return vymLink;
+}
+
+QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
+{
+ QString s,a;
+ QString scrolledAttr;
+ if (scrolled)
+ scrolledAttr=attribut ("scrolled","yes");
+ else
+ scrolledAttr="";
+
+ QString posAttr;
+ if (depth<2) posAttr=
+ attribut("absPosX",QString().setNum(absPos.x(),10)) +
+ attribut("absPosY",QString().setNum(absPos.y(),10));
+ else
+ posAttr="";
+
+ QString urlAttr;
+ if (!url.isEmpty())
+ urlAttr=attribut ("url",url);
+
+ QString vymLinkAttr;
+ if (!vymLink.isEmpty())
+ vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
+
+ QString frameAttr;
+ if (frame->getFrameType()!=NoFrame)
+ frameAttr=attribut ("frameType",frame->getFrameTypeName());
+ else
+ frameAttr="";
+
+ // save area, if not scrolled
+ QString areaAttr;
+ if (!((BranchObj*)(parObj))->isScrolled() )
+ {
+ areaAttr=
+ attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
+ attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
+ attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
+ attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
+
+ } else
+ areaAttr="";
+
+ s=beginElement ("branch" +scrolledAttr +posAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr);
+ incIndent();
+
+ // save heading
+ s=s+valueElement("heading", getHeading(),
+ attribut ("textColor",QColor(heading->getColor()).name()));
+
+ // save names of flags set
+ s+=standardFlags->saveToDir(tmpdir,prefix,0);
+
+ // save note
+ if (!note.isEmpty() )
+ s+=note.saveToDir();
+
+ // Save branches
+ BranchObj *bo;
+ for (bo=branch.first(); bo; bo=branch.next() )
+ s+=bo->saveToDir(tmpdir,prefix,offset);
+ decIndent();
+
+ // Save FloatImages
+ FloatImageObj *fio;
+ for (fio=floatimage.first(); fio; fio=floatimage.next() )
+ s+=fio->saveToDir (tmpdir,prefix);
+
+ s+=endElement ("branch");
+ return s;
+}
+
+LinkableMapObj* BranchObj::addFloatImage ()
+{
+ FloatImageObj *newfi=new FloatImageObj (canvas,this);
+ floatimage.append (newfi);
+ if (hasScrolledParent(this) )
+ newfi->setVisibility (false);
+ else
+ newfi->setVisibility(visible);
+ requestReposition();
+ return newfi;
+}
+
+LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
+{
+ FloatImageObj *newfi=new FloatImageObj (canvas,this);
+ floatimage.append (newfi);
+ newfi->copy (fio);
+ if (hasScrolledParent(this) )
+ newfi->setVisibility (false);
+ else
+ newfi->setVisibility(visible);
+ requestReposition();
+ return newfi;
+}
+
+FloatImageObj* BranchObj::getFirstFloatImage ()
+{
+ return floatimage.first();
+}
+
+FloatImageObj* BranchObj::getLastFloatImage ()
+{
+ return floatimage.last();
+}
+
+FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
+{
+ return floatimage.at(i);
+}
+
+void BranchObj::removeFloatImage (FloatImageObj *fio)
+{
+ floatimage.remove (fio);
+ requestReposition();
+}
+
+void BranchObj::savePosInAngle ()
+{
+ // Save position in angle
+ BranchObj *b;
+ int i=0;
+ for (b=branch.first(); b; b=branch.next() )
+ {
+ b->angle=i;
+ i++;
+ }
+}
+
+BranchObj* BranchObj::addBranch()
+{
+ BranchObj* newbo=new BranchObj(canvas,this);
+ branch.append (newbo);
+ newbo->setParObj(this);
+ newbo->setColor(getColor(),false);
+ newbo->setLinkColor();
+ newbo->setHeading ("new");
+ newbo->setLinkStyle (newbo->getDefLinkStyle());
+ if (scrolled)
+ newbo->setVisibility (false);
+ else
+ newbo->setVisibility(visible);
+ requestReposition();
+ return newbo;
+}
+
+BranchObj* BranchObj::addBranch(BranchObj* bo)
+{
+ BranchObj* newbo=new BranchObj(canvas,this);
+ branch.append (newbo);
+ newbo->copy(bo);
+ newbo->setParObj(this);
+ newbo->setHeading (newbo->getHeading()); // adjust fontsize to depth
+ newbo->setLinkStyle (newbo->getDefLinkStyle());
+ if (scrolled)
+ newbo->setVisibility (false);
+ else
+ newbo->setVisibility(bo->visible);
+ requestReposition();
+ return newbo;
+}
+
+BranchObj* BranchObj::insertBranch(int pos)
+{
+ savePosInAngle();
+ // Add new bo and resort branches
+ BranchObj *newbo=addBranch ();
+ newbo->angle=pos-0.5;
+ branch.sort();
+ return newbo;
+}
+
+BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
+{
+ savePosInAngle();
+ // Add new bo and resort branches
+ bo->angle=pos-0.5;
+ BranchObj *newbo=addBranch (bo);
+ branch.sort();
+ return newbo;
+}
+
+void BranchObj::removeBranch(BranchObj* bo)
+{
+ // if bo is not in branch remove returns false, we
+ // don't care...
+ branch.remove (bo);
+ requestReposition();
+}
+
+void BranchObj::setLastSelectedBranch (BranchObj* bo)
+{
+ lastSelectedBranch=branch.find(bo);
+}
+
+BranchObj* BranchObj::getLastSelectedBranch ()
+{
+ if (lastSelectedBranch>=0)
+ {
+ BranchObj* bo=branch.at(lastSelectedBranch);
+ if (bo) return bo;
+ }
+ return branch.first();
+}
+
+BranchObj* BranchObj::getFirstBranch ()
+{
+ return branch.first();
+}
+
+BranchObj* BranchObj::getLastBranch ()
+{
+ return branch.last();
+}
+
+BranchObj* BranchObj::getBranchNum (const uint &i)
+{
+ return branch.at(i);
+}
+
+
+BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
+{
+ savePosInAngle();
+ int i=branch.find(bo1);
+ if (i>0)
+ { // -1 if bo1 not found
+ branch.at(i)->angle--;
+ branch.at(i-1)->angle++;
+ branch.sort();
+ return branch.at(i-1);
+ } else
+ return branch.at(i);
+}
+
+BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
+{
+ savePosInAngle();
+ int i=branch.find(bo1);
+ int j;
+ if (branch.next())
+ {
+ j = branch.at();
+ branch.at(i)->angle++;
+ branch.at(j)->angle--;
+ branch.sort();
+ return branch.at(j);
+ } else
+ return branch.at(i);
+}
+
+void BranchObj::alignRelativeTo (QPoint ref)
+{
+/* FIXME testing
+ if (!getHeading().isEmpty())
+ cout << "BO::alignRelTo "<reposition();
+
+ if (scrolled) return;
+
+ // Set reference point for alignment of childs
+ QPoint ref2;
+ if (orientation==OrientLeftOfCenter)
+ ref2.setX(childPos.x() - linkwidth);
+ else
+ ref2.setX(childPos.x() + linkwidth);
+
+ if (depth==1)
+ ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
+ else
+ ref2.setY(ref.y() );
+
+ // Align the childs depending on reference point
+ BranchObj *b;
+ for (b=branch.first(); b; b=branch.next() )
+ {
+ b->alignRelativeTo (ref2);
+ ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
+ }
+}
+
+
+void BranchObj::reposition()
+{
+/* FIXME testing
+ if (!getHeading().isEmpty())
+ cout << "BO::reposition "<getTotalBBox(),r);
+
+ FloatImageObj* fio;
+ for (fio=floatimage.first();fio ;fio=floatimage.next() )
+ r=addBBox(fio->getTotalBBox(),r);
+
+ return r;
+}
+
+QRect BranchObj::getBBoxSizeWithChilds()
+{
+ return bboxTotal;
+}
+
+void BranchObj::calcBBoxSizeWithChilds()
+{
+ // This is called only from reposition and
+ // and only for mapcenter. So it won't be
+ // called more than once for a single user
+ // action
+
+ // Calculate size of LMO including all childs (to align them later)
+
+ bboxTotal.setX(bbox.x() );
+ bboxTotal.setY(bbox.y() );
+
+ // if branch is scrolled, ignore childs, but still consider floatimages
+ if (scrolled)
+ {
+ bboxTotal.setWidth (bbox.width());
+ bboxTotal.setHeight(bbox.height());
+ return;
+ }
+
+ QRect r(0,0,0,0);
+ QRect br;
+ // Now calculate recursivly
+ // sum of heights
+ // maximum of widths
+ // minimum of y
+ BranchObj* b;
+ for (b=branch.first();b ;b=branch.next() )
+ {
+ b->calcBBoxSizeWithChilds();
+ br=b->getBBoxSizeWithChilds();
+ r.setWidth( max (br.width(), r.width() ));
+ r.setHeight(br.height() + r.height() );
+ if (br.y()setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
+}
+
+void BranchObj::select()
+{
+ LinkableMapObj::select();
+ // Tell parent that I am selected now:
+ BranchObj* po=(BranchObj*)(parObj);
+ if (po) // TODO Try to get rid of this cast...
+ po->setLastSelectedBranch(this);
+
+ // temporary unscroll, if we have scrolled parents somewhere
+ if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
+
+ // set Text in Editor
+ textEditor->setText(note.getNote() );
+ textEditor->setFilename(note.getFilenameHint() );
+ textEditor->setFontHint (note.getFontHint() );
+ connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag() ) );
+ connect (textEditor, SIGNAL (fontSizeHasChanged() ), this, SLOT (updateNoteFlag() ) );
+
+ // Show URL and link in statusbar
+ QString status;
+ if (!url.isEmpty()) status+="URL: "+url+" ";
+ if (!vymLink.isEmpty()) status+="Link: "+vymLink;
+ if (!status.isEmpty()) mainWindow->statusMessage (status);
+
+ // Update Toolbar
+ standardFlags->updateToolBar();
+
+ // Update Browserbutton
+ if (!url.isEmpty())
+ actionEditOpenURL->setEnabled (true);
+ else
+ actionEditOpenURL->setEnabled (false);
+
+ // Update actions in mapeditor
+ mapEditor->updateActions();
+}
+
+void BranchObj::unselect()
+{
+ LinkableMapObj::unselect();
+ // Delete any messages like vymLink in StatusBar
+ mainWindow->statusMessage ("");
+
+ // save note from editor and set flag
+ // text is done by updateNoteFlag(), just save
+ // filename here
+ note.setFilenameHint (textEditor->getFilename());
+
+ // reset temporary unscroll, if we have scrolled parents somewhere
+ if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
+
+ // Disconnect textEditor from this LMO
+ disconnect( textEditor, SIGNAL(textHasChanged()), 0, 0 );
+ disconnect( textEditor, SIGNAL (fontSizeHasChanged()),0,0 );
+
+ // Erase content of editor
+ textEditor->setInactive();
+
+ // unselect all buttons in toolbar
+ standardFlagsDefault->updateToolBar();
+}
+
+QString BranchObj::getSelectString()
+{
+ QString s;
+ if (parObj)
+ {
+ if (parObj->getDepth()==0)
+ s= "bo:" + QString("%1").arg(getNum());
+ else
+ s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());
+ } else
+ {
+ s="mc:";
+ }
+
+ return s;
+}
+
diff -r 000000000000 -r 7a96bd401351 branchobj.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/branchobj.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,113 @@
+#ifndef BRANCHOBJ_H
+#define BRANCHOBJ_H
+
+#include "floatimageobj.h"
+#include "linkablemapobj.h"
+#include "ornamentedobj.h"
+
+class BranchObjPtrList : public QPtrList
+{
+ virtual int compareItems (QPtrCollection::Item i, QPtrCollection::Item j);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+class BranchObj:public OrnamentedObj {
+public:
+ BranchObj ();
+ BranchObj (QCanvas*);
+ BranchObj (QCanvas*, LinkableMapObj* parent);
+ ~BranchObj ();
+ bool operator< ( const BranchObj & );
+ bool operator== ( const BranchObj & );
+ virtual void init ();
+ virtual void copy (BranchObj*);
+ void clear();
+ virtual int getNum(); // return number of this in parent
+ virtual int getNum(BranchObj*); // return number of this in parent
+ virtual int getFloatImageNum(FloatImageObj*);
+ virtual int countBranches();
+ virtual int countFloatImages();
+ virtual void setParObjTmp (LinkableMapObj*,QPoint,int);// Only for moving Obj around
+ virtual void unsetParObjTmp(); // reuse original ParObj
+
+ virtual void unScroll();
+ virtual void toggleScroll(); // scroll or unscroll
+ virtual bool isScrolled(); // returns scroll state
+ virtual bool hasScrolledParent(BranchObj*); // true, if any of the parents is scrolled
+ virtual void tmpUnscroll(); // unscroll scrolled parents temporary e.g. during "find" process
+ virtual void resetTmpUnscroll(); // scroll all tmp scrolled parents again e.g. when unselecting
+
+ virtual void setVisibility(bool,int); // set visibility
+ virtual void setVisibility(bool); // set vis. for w
+ virtual void setLinkColor(); // set the color of link
+ virtual void setColor(QColor,bool); // set the color of heading
+
+
+ BranchObj* first (); // set Iterator to first LMO
+ BranchObj* next (); // find next LMO after given one
+ BranchObj* getLastIterator(); // to interrupt and resume next iteration
+ void setLastIterator (BranchObj*); // needed by next()
+
+ virtual void move (double x,double y);
+ virtual void move (QPoint);
+ virtual void moveBy (double x,double y);
+ virtual void moveBy (QPoint);
+ virtual void positionBBox();
+ virtual void calcBBoxSize();
+ virtual LinkableMapObj* findMapObj(QPoint,LinkableMapObj*); // find MapObj
+ virtual void setHeading (QString);
+ virtual void setURL (QString);
+ virtual QString getURL ();
+ virtual void setVymLink (QString);
+ virtual QString getVymLink ();
+ virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data recursivly to tempdir
+ virtual LinkableMapObj* addFloatImage();
+ virtual LinkableMapObj* addFloatImage(FloatImageObj*);
+ virtual void removeFloatImage(FloatImageObj*);
+ virtual FloatImageObj* getFirstFloatImage();
+ virtual FloatImageObj* getLastFloatImage();
+ virtual FloatImageObj* getFloatImageNum(const uint &);
+protected:
+ virtual void savePosInAngle(); // write pos in angle for resorting
+public:
+ virtual BranchObj* addBranch();
+ virtual BranchObj* addBranch(BranchObj*); // makes deep copy of BranchObj
+ virtual BranchObj* insertBranch(int);
+ virtual BranchObj* insertBranch(BranchObj*,int);
+ virtual void removeBranch(BranchObj*);
+ virtual void setLastSelectedBranch(BranchObj*);
+ virtual BranchObj* getLastSelectedBranch();
+ virtual BranchObj* getFirstBranch();
+ virtual BranchObj* getLastBranch();
+ virtual BranchObj* getBranchNum(const uint &);
+ virtual BranchObj* moveBranchUp(BranchObj*);
+ virtual BranchObj* moveBranchDown(BranchObj*);
+
+ virtual void alignRelativeTo(const QPoint );
+ virtual void reposition();
+
+ virtual QRect getTotalBBox(); // return BBox including childs
+ virtual QRect getBBoxSizeWithChilds(); // return size of BBox including childs
+ virtual void calcBBoxSizeWithChilds(); // calc size of BBox including childs recursivly
+
+ virtual void select();
+ virtual void unselect();
+ virtual QString getSelectString();
+
+protected:
+ static BranchObj* itLast; // iterator for first(), next()
+ BranchObjPtrList branch; // all child branches
+ QPtrList floatimage; // child images
+public:
+ float angle; // used in mainbranch to reorder mainbranches
+protected:
+ int lastSelectedBranch; // for going deeper into tree
+ bool scrolled; // true if all childs are scrolled and thus invisible
+ bool tmpUnscrolled; // can only be true (temporary) for a scrolled subtree
+ QString url; // url to external doc
+ QString vymLink; // path to another map
+};
+
+
+#endif
+
diff -r 000000000000 -r 7a96bd401351 doc/vym.pdf
Binary file doc/vym.pdf has changed
diff -r 000000000000 -r 7a96bd401351 exporthtmldialog.ui
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exporthtmldialog.ui Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,321 @@
+
+ExportHTMLDialog
+Uwe Drechsel
+
+
+ ExportHTMLDialog
+
+
+
+ 0
+ 0
+ 364
+ 346
+
+
+
+ Export HTML
+
+
+ false
+
+
+
+ unnamed
+
+
+
+ layout33
+
+
+
+ unnamed
+
+
+
+ textLabel1
+
+
+ Directory:
+
+
+
+
+ lineEdit1
+
+
+
+
+ browseButton
+
+
+ Browse
+
+
+
+
+
+
+ buttonGroup2
+
+
+
+ 3
+ 5
+ 0
+ 0
+
+
+
+
+ 0
+ 230
+
+
+
+ Options
+
+
+
+ unnamed
+
+
+
+ checkBox4
+
+
+ Include image of map
+
+
+
+
+ checkBox5_2
+
+
+ create image only
+
+
+
+
+ checkBox5
+
+
+ use WIKI style
+
+
+
+
+ checkBox4_2
+
+
+ use heading for URLs (instead of link target)
+
+
+
+
+ checkBox6
+
+
+ use image of earth to mark URLs in text
+
+
+
+
+ checkBox7
+
+
+ use default CSS file
+
+
+
+
+ checkBox3
+
+
+
+ 1
+ 0
+ 0
+ 0
+
+
+
+ show output of external scripts
+
+
+
+
+
+
+ spacer6
+
+
+ Vertical
+
+
+ Expanding
+
+
+
+ 21
+ 60
+
+
+
+
+
+ layout17
+
+
+
+ unnamed
+
+
+
+ spacer5
+
+
+ Horizontal
+
+
+ Expanding
+
+
+
+ 61
+ 21
+
+
+
+
+
+ pushButton4
+
+
+ Export
+
+
+ true
+
+
+
+
+ pushButton5
+
+
+ Cancel
+
+
+
+
+
+
+
+
+ pushButton5
+ pressed()
+ ExportHTMLDialog
+ reject()
+
+
+ pushButton4
+ clicked()
+ ExportHTMLDialog
+ accept()
+
+
+ browseButton
+ pressed()
+ ExportHTMLDialog
+ browseDirectory()
+
+
+ checkBox4
+ toggled(bool)
+ ExportHTMLDialog
+ includeImage(bool)
+
+
+ checkBox5
+ toggled(bool)
+ ExportHTMLDialog
+ useWIKIpressed(bool)
+
+
+ lineEdit1
+ textChanged(const QString&)
+ ExportHTMLDialog
+ dirChanged()
+
+
+ checkBox3
+ toggled(bool)
+ ExportHTMLDialog
+ showOut(bool)
+
+
+ checkBox4_2
+ toggled(bool)
+ ExportHTMLDialog
+ useHeadingPressed(bool)
+
+
+ checkBox5_2
+ toggled(bool)
+ ExportHTMLDialog
+ imgOnly(bool)
+
+
+ checkBox6
+ toggled(bool)
+ ExportHTMLDialog
+ useURLImagePressed(bool)
+
+
+
+ showtextdialog.h
+ qprocess.h
+ iostream
+ settings.h
+ qfiledialog.h
+ qmessagebox.h
+ misc.h
+ icons/flag-url.xpm
+ exporthtmldialog.ui.h
+
+
+ QString css;
+ QString xsl;
+ QString scriptpath;
+ QString stylepath;
+ QString dir;
+ bool image;
+ bool wikistyle;
+ QString script;
+ bool showOutput;
+ QProcess *proc;
+ ShowTextDialog *dia;
+ bool imageOnly;
+ bool useHeading;
+ bool useURLImage;
+
+
+ browseDirectory()
+ useWIKIpressed( bool b )
+ includeImage( bool b )
+ imgOnly( bool b )
+ useHeadingPressed( bool b )
+ useURLImagePressed( bool b )
+ showOut( bool b )
+ dirChanged()
+ doExport( const QString & mapname )
+ getDir()
+ readOutput()
+
+
+ init()
+ destroy()
+
+
+
+
diff -r 000000000000 -r 7a96bd401351 exporthtmldialog.ui.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exporthtmldialog.ui.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,218 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** Qt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+
+extern Settings settings;
+
+void ExportHTMLDialog::init()
+{
+ dir=settings.readEntry ("/vym/export/html/dir","" );
+ lineEdit1->setText(dir);
+
+ if ( settings.readEntry ("/vym/export/html/image","yes")=="yes")
+ image=true;
+ else
+ image=false;
+ checkBox4->setChecked(image);
+
+ if ( settings.readEntry ("/vym/export/html/imageOnly","no")=="yes")
+ imageOnly=true;
+ else
+ imageOnly=false;
+ checkBox5_2->setChecked(imageOnly);
+
+ if ( settings.readEntry ("/vym/export/html/wiki","no")=="yes")
+ wikistyle=true;
+ else
+ wikistyle=false;
+ checkBox5->setChecked(wikistyle);
+
+ if ( settings.readEntry ("/vym/export/html/useHeading","no")=="yes")
+ useHeading=true;
+ else
+ useHeading=false;
+ checkBox4_2->setChecked(useHeading);
+
+ if ( settings.readEntry ("/vym/export/html/useURLImage","yes")=="yes")
+ useURLImage=true;
+ else
+ useURLImage=false;
+ checkBox6->setChecked(useURLImage);
+
+ if ( settings.readEntry ("/vym/export/html/showOutput","no")=="yes")
+ showOutput=true;
+ else
+ showOutput=false;
+ checkBox3->setChecked(showOutput);
+
+ stylepath=settings.readEntry
+ ("/vym/export/html/styles","styles");
+ scriptpath=settings.readEntry
+ ("/vym/export/html/scripts","scripts");
+ xsl=settings.readEntry
+ ("/vym/export/html/xsl","vym2html.xsl");
+ css=settings.readEntry
+ ("/vym/export/html/css","vym.css");
+ script=settings.readEntry
+ ("/vym/export/html/script","vym2html.sh");
+
+ proc = new QProcess( this );
+ connect( proc, SIGNAL(readyReadStdout()),
+ this, SLOT(readOutput()) );
+
+ dia=new ShowTextDialog ();
+}
+
+void ExportHTMLDialog::destroy()
+{
+ delete (proc);
+ delete (dia);
+}
+
+void ExportHTMLDialog::browseDirectory()
+{
+ QFileDialog fd( this, tr("VYM - Export HTML to directory"));
+ fd.setMode (QFileDialog::DirectoryOnly);
+ fd.setCaption(tr("VYM - Export HTML to directory"));
+ fd.setModal (true);
+ fd.show();
+
+ if ( fd.exec() == QDialog::Accepted )
+ {
+ dir=fd.selectedFile();
+ lineEdit1->setText (dir );
+ }
+}
+
+void ExportHTMLDialog::useWIKIpressed(bool b)
+{
+ wikistyle=b;
+}
+
+void ExportHTMLDialog::includeImage(bool b)
+{
+ image=b;
+}
+
+void ExportHTMLDialog::imgOnly(bool b)
+{
+ imageOnly=b;
+}
+
+void ExportHTMLDialog::useHeadingPressed(bool b)
+{
+ useHeading=b;
+}
+
+void ExportHTMLDialog::useURLImagePressed(bool b)
+{
+ useURLImage=b;
+}
+
+void ExportHTMLDialog::showOut(bool b)
+{
+ showOutput=b;
+}
+
+void ExportHTMLDialog::dirChanged()
+{
+ dir=lineEdit1->text();
+}
+
+
+
+
+void ExportHTMLDialog::doExport (const QString &mapname)
+{
+ // Save options to settings file
+ // (but don't save at destructor, which
+ // is called for "cancel", too)
+ settings.writeEntry ("/vym/export/html/dir",lineEdit1->text() );
+
+ if (wikistyle)
+ settings.writeEntry ("/vym/export/html/wiki","yes");
+ else
+ settings.writeEntry ("/vym/export/html/wiki","no");
+
+ if (image)
+ settings.writeEntry ("/vym/export/html/image","yes");
+ else
+ settings.writeEntry ("/vym/export/html/image","no");
+
+ if (imageOnly)
+ settings.writeEntry ("/vym/export/html/imageOnly","yes");
+ else
+ settings.writeEntry ("/vym/export/html/imageOnly","no");
+
+ if (useHeading)
+ settings.writeEntry ("/vym/export/html/useHeading","yes");
+ else
+ settings.writeEntry ("/vym/export/html/useHeading","no");
+
+ if (showOutput)
+ settings.writeEntry ("/vym/export/html/showOutput","yes");
+ else
+ settings.writeEntry ("/vym/export/html/showOutput","no");
+
+ settings.writeEntry
+ ("/vym/export/html/styles",stylepath);
+ settings.writeEntry
+ ("/vym/export/html/scripts",scriptpath);
+ settings.writeEntry
+ ("/vym/export/html/xsl",xsl);
+ settings.writeEntry
+ ("/vym/export/html/css",css);
+ settings.writeEntry
+ ("/vym/export/html/script",script);
+
+ proc->addArgument (scriptpath + "/" + script );
+ proc->addArgument(dir + maskPath(mapname) + ".xml");
+ proc->addArgument("-sp=" + stylepath +"/" + xsl );
+ proc->addArgument("-css=" + css );
+ if (image) proc->addArgument("-image" );
+ if (wikistyle) proc->addArgument("-wikistyle" );
+ if (useHeading) proc->addArgument("-useURLHeading" );
+ if (useURLImage)
+ {
+ proc->addArgument("-useURLImage" );
+ QPixmap pm (flag_url_xpm);
+ pm.save (dir + "/flags/url.png","PNG");
+ }
+
+ dia->append ("vym is executing: " + proc->arguments().join(" ") );
+ if ( !proc->start() )
+ {
+ // error handling
+ dia->show();
+ QString s;
+ QStringList list = proc->arguments();
+ QStringList::Iterator it = list.begin();
+ while( it != list.end() )
+ {
+ s+= ( *it ) + "\n";
+ ++it;
+ }
+ QMessageBox::critical(0, tr("Critcal export error"),"Couldn't start script to export:\n"+s);
+ } else
+ if (showOutput) dia->exec();
+
+
+}
+
+
+QString ExportHTMLDialog::getDir()
+{
+ return dir;
+}
+
+
+void ExportHTMLDialog::readOutput()
+{
+ dia->append (proc->readStdout() );
+}
diff -r 000000000000 -r 7a96bd401351 exports.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exports.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,132 @@
+#include "exports.h"
+
+#include "linkablemapobj.h"
+
+
+Export::Export()
+{
+ indentPerDepth=" ";
+}
+
+bool Export::setOutputDir(QString dirname)
+{
+ outdir.setPath (dirname);
+ if ( outdir.exists() )
+ {
+ // FIXME
+ // ask for confirmation
+ // then delete outdir
+ return true;
+ } else
+ {
+ // try to create directory
+ //return outdir.mkdir (outdir.absPath());
+ // FIXME
+ return true;
+ }
+}
+
+void Export::setPath (const QString &p)
+{
+ filepath=p;
+}
+
+void Export::setMapCenter(MapCenterObj *mc)
+{
+ mapCenter=mc;
+}
+
+void Export::exportMap()
+{
+ QFile file (filepath);
+ if ( !file.open( IO_WriteOnly ) )
+ {
+ // FIXME
+ cout << "Export::exportMap couldn't open "<first();
+ while (bo)
+ {
+ // Make indentstring
+ for (i=0;igetDepth();i++) actIndent+= indentPerDepth;
+
+ // Write heading
+ // write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
+ if (bo->getDepth()==1)
+ ts << (getSectionString(bo) + bo->getHeading()+ "\n");
+ else
+ ts << (actIndent + " - " + bo->getHeading()+ "\n");
+
+ // If necessary, write note
+ if (!bo->getNote().isEmpty())
+ {
+ ts << ("-------------------Begin of Note-----------------\n");
+ ts << (bo->getNote());
+ ts << ("\n");
+ ts << ("-------------------End of Note-------------------\n");
+ }
+
+ bo=bo->next();
+ actIndent="";
+ }
+ file.close();
+}
+
+QString Export::getSectionString(BranchObj *bostart)
+{
+ QString r;
+ BranchObj *bo=bostart;
+ int depth=bo->getDepth();
+ while (depth>0)
+ {
+ r=QString("%1").arg(1+bo->getNum(),0,10)+"." + r;
+ bo=(BranchObj*)(bo->getParObj());
+ depth=bo->getDepth();
+ }
+ if (r.isEmpty())
+ return r;
+ else
+ return r + " ";
+}
+
+void Export::exportAsHTML()
+{
+ // FIXME just testing...
+ // Main loop over all branches
+ QString s;
+ QString actIndent("");
+ int i;
+ BranchObj *bo;
+ bo=mapCenter->first();
+ while (bo)
+ {
+ // Make indentstring
+ for (i=0;igetDepth();i++) actIndent+= indentPerDepth;
+
+ // Write heading
+ write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
+
+ // If necessary, write note
+ if (!bo->getNote().isEmpty())
+ {
+ write (bo->getNote());
+ }
+
+ bo=bo->next();
+ actIndent="";
+ }
+}
+
+void Export::write(QString s)
+{
+ cout << s;
+}
+
diff -r 000000000000 -r 7a96bd401351 exports.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exports.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,34 @@
+#ifndef EXPORTS_H
+#define EXPORTS_H
+
+#include
+#include
+#include
+
+#include "mapcenterobj.h"
+
+using namespace std;
+
+/////////////////////////////////////////////////////////////////////////////
+class Export
+{
+public:
+ Export();
+ bool setOutputDir (QString);
+ void setPath(const QString &);
+ void setMapCenter (MapCenterObj*);
+ void setIndentPerDepth (QString);
+ void exportMap();
+ void exportAsHTML();
+protected:
+ QString getSectionString (BranchObj*);
+ void write (QString);
+
+private:
+ QDir outdir;
+ QString filepath;
+ MapCenterObj *mapCenter;
+ QString indentPerDepth;
+};
+
+#endif
diff -r 000000000000 -r 7a96bd401351 exportxhtmldialog.ui
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exportxhtmldialog.ui Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,555 @@
+
+ExportXHTMLDialog
+
+
+ ExportXHTMLDialog
+
+
+
+ 0
+ 0
+ 582
+ 599
+
+
+
+
+ 0
+ 130
+
+
+
+ Export XHTML
+
+
+
+ unnamed
+
+
+
+ layout33
+
+
+
+ unnamed
+
+
+
+ textLabel1
+
+
+ Export to directory:
+
+
+
+
+ lineEditDir
+
+
+
+
+ browseExportDirButton
+
+
+ Browse
+
+
+
+
+
+
+ buttonGroup2
+
+
+
+ 3
+ 3
+ 0
+ 0
+
+
+
+
+ 0
+ 160
+
+
+
+ Options
+
+
+
+ unnamed
+
+
+
+ imageButton
+
+
+ Include image
+
+
+
+
+ textColorButton
+
+
+ Colored headings in text
+
+
+
+
+ saveSettingsInMapButton
+
+
+ Save settings in map
+
+
+
+
+ warningsButton
+
+
+ showWarnings e.g. if directory is not empty
+
+
+
+
+ outputButton
+
+
+
+ 1
+ 0
+ 0
+ 0
+
+
+
+ show output of external scripts
+
+
+
+
+
+
+ buttonGroup2_2
+
+
+
+ 3
+ 3
+ 0
+ 0
+
+
+
+ Stylesheets
+
+
+
+ layout7
+
+
+
+ 10
+ 30
+ 540
+ 84
+
+
+
+
+ unnamed
+
+
+
+ layout5
+
+
+
+ unnamed
+
+
+
+ textLabel1_2
+
+
+ CSS:
+
+
+
+
+ lineEditCSS
+
+
+
+
+ browseCSSButton
+
+
+ Browse
+
+
+
+
+
+
+ layout6
+
+
+
+ unnamed
+
+
+
+ textLabel2
+
+
+ XSL:
+
+
+
+
+ lineEditXSL
+
+
+
+
+ browseXSLButton
+
+
+ Browse
+
+
+
+
+
+
+
+
+
+ groupBox1
+
+
+ Scripts
+
+
+
+ textLabel1_3
+
+
+
+ 12
+ 22
+ 110
+ 36
+
+
+
+ Before export:
+
+
+
+
+ lineEditPreScript
+
+
+
+ 128
+ 26
+ 322
+ 28
+
+
+
+
+
+ browsePreExportButton
+
+
+
+ 456
+ 22
+ 94
+ 36
+
+
+
+ Browse
+
+
+
+
+ textLabel2_2
+
+
+
+ 11
+ 61
+ 99
+ 36
+
+
+
+ After Export:
+
+
+
+
+ lineEditPostScript
+
+
+
+ 116
+ 65
+ 333
+ 28
+
+
+
+
+
+ browsePostExportButton
+
+
+
+ 455
+ 61
+ 94
+ 36
+
+
+
+ Browse
+
+
+
+
+
+ spacer3
+
+
+ Vertical
+
+
+ Expanding
+
+
+
+ 20
+ 31
+
+
+
+
+
+ layout17
+
+
+
+ unnamed
+
+
+
+ spacer5
+
+
+ Horizontal
+
+
+ Expanding
+
+
+
+ 61
+ 21
+
+
+
+
+
+ exportButton
+
+
+ Export
+
+
+ true
+
+
+
+
+ cancelButton
+
+
+ Cancel
+
+
+
+
+
+
+
+
+ outputButton
+ toggled(bool)
+ ExportXHTMLDialog
+ outputButtonPressed(bool)
+
+
+ exportButton
+ pressed()
+ ExportXHTMLDialog
+ accept()
+
+
+ cancelButton
+ pressed()
+ ExportXHTMLDialog
+ close()
+
+
+ browseExportDirButton
+ pressed()
+ ExportXHTMLDialog
+ browseDirectoryPressed()
+
+
+ browseXSLButton
+ pressed()
+ ExportXHTMLDialog
+ browseXSLPressed()
+
+
+ browseCSSButton
+ pressed()
+ ExportXHTMLDialog
+ browseCSSPressed()
+
+
+ imageButton
+ toggled(bool)
+ ExportXHTMLDialog
+ imageButtonPressed(bool)
+
+
+ textColorButton
+ toggled(bool)
+ ExportXHTMLDialog
+ textcolorButtonPressed(bool)
+
+
+ lineEditDir
+ textChanged(const QString&)
+ ExportXHTMLDialog
+ dirChanged()
+
+
+ lineEditCSS
+ textChanged(const QString&)
+ ExportXHTMLDialog
+ cssChanged()
+
+
+ lineEditXSL
+ textChanged(const QString&)
+ ExportXHTMLDialog
+ xslChanged()
+
+
+ browsePreExportButton
+ pressed()
+ ExportXHTMLDialog
+ browsePreExportButtonPressed()
+
+
+ browsePostExportButton
+ pressed()
+ ExportXHTMLDialog
+ browsePostExportButtonPressed()
+
+
+ lineEditPreScript
+ textChanged(const QString&)
+ ExportXHTMLDialog
+ prescriptChanged()
+
+
+ lineEditPostScript
+ textChanged(const QString&)
+ ExportXHTMLDialog
+ postscriptChanged()
+
+
+ warningsButton
+ toggled(bool)
+ ExportXHTMLDialog
+ warningsButtonPressed(bool)
+
+
+ saveSettingsInMapButton
+ toggled(bool)
+ ExportXHTMLDialog
+ saveSettingsInMapButtonPressed(bool)
+
+
+
+ process.h
+ showtextdialog.h
+ qfiledialog.h
+ qmessagebox.h
+ settings.h
+ icons/flag-url.xpm
+ exportxhtmldialog.ui.h
+
+
+ bool useTextColor;
+ bool showWarnings;
+ QString xsl;
+ QString css;
+ bool useImage;
+ bool showOutput;
+ Process *xsltProc;
+ ShowTextDialog *dia;
+ QString dir;
+ QString xsltprocessor;
+ QString filepath;
+ QString prescript;
+ QString postscript;
+ bool settingsChanged;
+ QString mapname;
+ bool saveSettingsInMap;
+
+
+ readSettings()
+ dirChanged()
+ browseDirectoryPressed()
+ imageButtonPressed( bool b )
+ textcolorButtonPressed( bool b )
+ saveSettingsInMapButtonPressed( bool b )
+ warningsButtonPressed( bool b )
+ outputButtonPressed( bool b )
+ cssChanged()
+ browseCSSPressed()
+ xslChanged()
+ prescriptChanged()
+ browseXSLPressed()
+ postscriptChanged()
+ browsePreExportButtonPressed()
+ browsePostExportButtonPressed()
+ doExport( const QString & mapname )
+ setFilePath( const QString & s )
+ setMapName( const QString & s )
+
+
+ init()
+ destroy()
+ getDir()
+ warnings()
+ hasChanged()
+ runScript( QString spath, QString fpath )
+
+
+
+
diff -r 000000000000 -r 7a96bd401351 exportxhtmldialog.ui.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exportxhtmldialog.ui.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,412 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** Qt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+
+extern Settings settings;
+
+void ExportXHTMLDialog::init()
+{
+ dia=new ShowTextDialog ();
+ xsltprocessor="xsltproc";
+ filepath="";
+ settingsChanged=false;
+}
+
+void ExportXHTMLDialog::readSettings()
+{
+
+ dir=settings.readLocalEntry (filepath,"/vym/export/xhtml/exportDir","./" );
+ lineEditDir->setText(dir);
+
+
+ if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useImage","yes")=="yes")
+ useImage=true;
+ else
+ useImage=false;
+ imageButton->setChecked(useImage);
+
+ if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no")=="yes")
+ useTextColor=true;
+ else
+ useTextColor=false;
+ textColorButton->setChecked(useTextColor);
+
+/* FIXME this was used in old html export, is not yet in new stylesheet
+ if ( settings.readEntry ("/vym/export/html/useHeading","no")=="yes")
+ useHeading=true;
+ else
+ useHeading=false;
+ checkBox4_2->setChecked(useHeading);
+*/
+
+ if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/saveSettingsInMap","no")=="yes")
+ saveSettingsInMap=true;
+ else
+ saveSettingsInMap=false;
+ saveSettingsInMapButton->setChecked(saveSettingsInMap);
+
+ if ( settings.readEntry ("/vym/export/xhtml/showWarnings","yes")=="yes")
+ showWarnings=true;
+ else
+ showWarnings=false;
+ warningsButton->setChecked(showWarnings);
+
+ if ( settings.readEntry ("/vym/export/xhtml/showOutput","no")=="yes")
+ showOutput=true;
+ else
+ showOutput=false;
+ outputButton->setChecked(showOutput);
+
+ xsl=settings.readLocalEntry
+ (filepath,"/vym/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl");
+ lineEditXSL->setText(xsl);
+
+ css=settings.readLocalEntry
+ (filepath,"/vym/export/xhtml/css","/usr/share/vym/styles/vym.css");
+ lineEditCSS->setText(css);
+
+ prescript=settings.readLocalEntry
+ (filepath,"/vym/export/xhtml/prescript","");
+ lineEditPreScript->setText (prescript);
+
+ postscript=settings.readLocalEntry
+ (filepath,"/vym/export/xhtml/postscript","");
+ lineEditPostScript->setText (postscript);
+
+ if (!prescript.isEmpty() || !postscript.isEmpty())
+ {
+ QMessageBox::warning( 0, tr( "Warning" ),tr(
+ "The settings saved in the map "
+ "would like to run scripts:\n\n") +
+ prescript +" "+postscript +"\n\n"+
+ tr("Please check, if you really\n"
+ "want to allow this in your system!"));
+
+ }
+}
+
+void ExportXHTMLDialog::destroy()
+{
+ delete (dia);
+}
+
+void ExportXHTMLDialog::dirChanged()
+{
+ dir=lineEditDir->text();
+ if (dir.right(1)!="/")
+ dir+="/";
+ settingsChanged=true;
+}
+
+void ExportXHTMLDialog::browseDirectoryPressed()
+{
+ QFileDialog fd( this, tr("VYM - Export HTML to directory"));
+ fd.setMode (QFileDialog::DirectoryOnly);
+ fd.setCaption(tr("VYM - Export HTML to directory"));
+ fd.setModal (true);
+ fd.show();
+
+ if ( fd.exec() == QDialog::Accepted )
+ {
+ dir=fd.selectedFile();
+ lineEditDir->setText (dir );
+ settingsChanged=true;
+ }
+}
+
+void ExportXHTMLDialog::imageButtonPressed(bool b)
+{
+ useImage=b;
+ settingsChanged=true;
+}
+
+void ExportXHTMLDialog::textcolorButtonPressed(bool b)
+{
+ useTextColor=b;
+ settingsChanged=true;
+}
+
+void ExportXHTMLDialog::saveSettingsInMapButtonPressed(bool b)
+{
+ saveSettingsInMap=b;
+ settingsChanged=true;
+}
+
+void ExportXHTMLDialog::warningsButtonPressed(bool b)
+{
+ showWarnings=b;
+ settingsChanged=true;
+}
+
+
+void ExportXHTMLDialog::outputButtonPressed(bool b)
+{
+ showOutput=b;
+ settingsChanged=true;
+}
+
+void ExportXHTMLDialog::cssChanged()
+{
+ css=lineEditCSS->text();
+ settingsChanged=true;
+}
+
+void ExportXHTMLDialog::browseCSSPressed()
+{
+ QFileDialog fd( this, tr("VYM - Path to CSS file"));
+ fd.setModal (true);
+ fd.addFilter ("Cascading Stylesheet (*.css)");
+ fd.show();
+
+ if ( fd.exec() == QDialog::Accepted )
+ {
+ css=fd.selectedFile();
+ lineEditCSS->setText (css );
+ settingsChanged=true;
+ }
+}
+
+void ExportXHTMLDialog::xslChanged()
+{
+ xsl=lineEditXSL->text();
+ settingsChanged=true;
+}
+
+void ExportXHTMLDialog::prescriptChanged()
+{
+ prescript=lineEditPreScript->text();
+ settingsChanged=true;
+}
+
+void ExportXHTMLDialog::browseXSLPressed()
+{
+ QFileDialog fd( this, tr("VYM - Path to XSL file"));
+ fd.setModal (true);
+ fd.addFilter ("Extensible Styleshee Language (*.xsl)");
+ fd.show();
+
+ if ( fd.exec() == QDialog::Accepted )
+ {
+ xsl=fd.selectedFile();
+ lineEditXSL->setText (xsl );
+ settingsChanged=true;
+ }
+}
+
+void ExportXHTMLDialog::postscriptChanged()
+{
+ postscript=lineEditPostScript->text();
+ settingsChanged=true;
+}
+
+void ExportXHTMLDialog::browsePreExportButtonPressed()
+{
+ QFileDialog fd( this, tr("VYM - Path to pre export script"));
+ fd.setModal (true);
+ fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
+ fd.show();
+
+ if ( fd.exec() == QDialog::Accepted )
+ {
+ prescript=fd.selectedFile();
+ lineEditPreScript->setText (prescript );
+ settingsChanged=true;
+ }
+
+}
+
+void ExportXHTMLDialog::browsePostExportButtonPressed()
+{
+ QFileDialog fd( this, tr("VYM - Path to post export script"));
+ fd.setModal (true);
+ fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
+ fd.show();
+
+ if ( fd.exec() == QDialog::Accepted )
+ {
+ postscript=fd.selectedFile();
+ lineEditPostScript->setText (postscript );
+ settingsChanged=true;
+ }
+}
+
+
+void ExportXHTMLDialog::doExport (const QString &mapname)
+{
+ // Save options to settings file
+ // (but don't save at destructor, which
+ // is called for "cancel", too)
+ settings.setLocalEntry (filepath,"/vym/export/xhtml/exportDir",dir);
+
+ settings.setLocalEntry (filepath,"/vym/export/xhtml/prescript",prescript);
+ settings.setLocalEntry (filepath,"/vym/export/xhtml/postscript",postscript);
+
+ if (useImage)
+ settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","yes");
+ else
+ settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","no");
+
+ if (useTextColor)
+ settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","yes");
+ else
+ settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no");
+
+ if (showWarnings)
+ settings.writeEntry ("/vym/export/xhtml/showWarnings","yes");
+ else
+ settings.writeEntry ("/vym/export/xhtml/showWarnings","no");
+
+ if (showOutput)
+ settings.writeEntry ("/vym/export/xhtml/showOutput","yes");
+ else
+ settings.writeEntry ("/vym/export/xhtml/showOutput","no");
+
+ settings.setLocalEntry
+ (filepath,"/vym/export/xhtml/xsl",xsl);
+ settings.setLocalEntry
+ (filepath,"/vym/export/xhtml/css",css);
+
+ //FIXME add option for url image (globe flag) here
+ if (true)
+ {
+ QPixmap pm (flag_url_xpm);
+ pm.save (dir + "/flags/url.png","PNG");
+ }
+
+ if (!saveSettingsInMap)
+ settings.clearLocal("/vym/export/xhtml");
+ else
+ settings.setLocalEntry
+ (filepath,"/vym/export/xhtml/saveSettingsInMap","yes");
+
+ // Copy CSS file
+ QFile css_src (css);
+ QFile css_dst (dir+"vym.css");
+ if (!css_src.open ( IO_ReadOnly))
+ QMessageBox::warning( 0, tr( "Warning" ),css +tr(" could not be opened!"));
+ else
+ {
+ if (!css_dst.open( IO_WriteOnly))
+ QMessageBox::warning( 0, tr( "Warning" ), dir+"vym.css" +tr(" could not be opened!"));
+ else
+ {
+
+ QTextStream tsout( &css_dst);
+ QTextStream tsin ( &css_src);
+ QString s= tsin.read();
+ tsout << s;
+ css_dst.close();
+ }
+ css_src.close();
+ }
+
+ if (!prescript.isEmpty()) runScript (prescript,dir+mapname+".xml");
+
+ Process *xsltProc=new Process ();
+ xsltProc->clearArguments();
+ xsltProc->addArgument (xsltprocessor);
+ if (useImage)
+ {
+ xsltProc->addArgument ("--stringparam");
+ xsltProc->addArgument ("imagemap");
+ xsltProc->addArgument ("images/"+mapname+".png");
+ }
+ if (useTextColor)
+ {
+ xsltProc->addArgument ("--stringparam");
+ xsltProc->addArgument ("use.textcolor");
+ xsltProc->addArgument ("1");
+ }
+ xsltProc->addArgument ("--stringparam");
+ xsltProc->addArgument ("mapname");
+ xsltProc->addArgument (mapname+".vym");
+
+ xsltProc->addArgument ("--output");
+ xsltProc->addArgument (dir+mapname+".html");
+ xsltProc->addArgument (xsl);
+ xsltProc->addArgument (dir+mapname+".xml");
+ dia->append ("vym is executing: \n" + xsltProc->arguments().join(" ") );
+ if (!xsltProc->start() )
+ {
+ QMessageBox::critical( 0, tr( "Critical Error" ),
+ tr("Couldn't start ") + xsltprocessor );
+ } else
+ {
+ xsltProc->waitFinished();
+ if (!xsltProc->normalExit() )
+ QMessageBox::critical( 0, tr( "Critical Error" ),
+ xsltprocessor +" " +tr("didn't exit normally") +
+ xsltProc->getErrout() );
+ else
+ if (xsltProc->exitStatus()>0) showOutput=true;
+
+ }
+ dia->append ("\n");
+ dia->append (xsltProc->getErrout());
+ dia->append (xsltProc->getStdout());
+
+ if (!postscript.isEmpty()) runScript (postscript,dir+mapname+".html");
+
+ if (showOutput) dia->exec();
+}
+
+void ExportXHTMLDialog::setFilePath(const QString &s)
+{
+ filepath=s;
+}
+
+void ExportXHTMLDialog::setMapName(const QString &s)
+{
+ mapname=s;
+}
+
+QString ExportXHTMLDialog::getDir()
+{
+ return dir;
+}
+
+bool ExportXHTMLDialog::warnings()
+{
+ return showWarnings;
+}
+
+bool ExportXHTMLDialog::hasChanged()
+{
+ return settingsChanged;
+}
+
+
+void ExportXHTMLDialog::runScript(QString spath, QString fpath)
+{
+ spath.replace ("%f",fpath);
+ QStringList args=QStringList::split (' ',spath,false);
+
+ Process *scriptProc=new Process ();
+ scriptProc->clearArguments();
+ scriptProc->setArguments (args);
+ dia->append ("vym is executing: \n" + scriptProc->arguments().join(" ") );
+ if (!scriptProc->start() )
+ {
+ QMessageBox::critical( 0, tr( "Critical Error" ),
+ tr("Couldn't start ") + spath );
+ } else
+ {
+ scriptProc->waitFinished();
+ if (!scriptProc->normalExit() )
+ QMessageBox::critical( 0, tr( "Critical Error" ),
+ spath +" " +tr("didn't exit normally") +
+ scriptProc->getErrout() );
+ else
+ if (scriptProc->exitStatus()>0) showOutput=true;
+
+ }
+ dia->append ("\n");
+ dia->append (scriptProc->getErrout());
+ dia->append (scriptProc->getStdout());
+}
diff -r 000000000000 -r 7a96bd401351 extrainfodialog.ui
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/extrainfodialog.ui Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,204 @@
+
+ExtraInfoDialog
+Uwe Drechsel
+
+
+ ExtraInfoDialog
+
+
+
+ 0
+ 0
+ 338
+ 410
+
+
+
+ VYM - Info
+
+
+
+ unnamed
+
+
+
+ textLabel1_2
+
+
+ Map:
+
+
+
+
+ lineEdit7
+
+
+
+ 225
+ 225
+ 225
+
+
+
+ WidgetOrigin
+
+
+ true
+
+
+
+
+ textLabel1
+
+
+ Author:
+
+
+
+
+ lineEdit2
+
+
+
+
+ textLabel2
+
+
+ Comment:
+
+
+
+
+ textEdit4
+
+
+
+ 7
+ 4
+ 0
+ 0
+
+
+
+
+ 32767
+ 76
+
+
+
+
+
+ textLabel2_2
+
+
+ Statistics:
+
+
+
+
+ textEdit4_2
+
+
+
+ 225
+ 225
+ 225
+
+
+
+
+ Courier
+ 12
+
+
+
+ PlainText
+
+
+ true
+
+
+
+
+ layout21
+
+
+
+ unnamed
+
+
+
+ spacer10
+
+
+ Horizontal
+
+
+ Expanding
+
+
+
+ 160
+ 21
+
+
+
+
+
+ pushButton13
+
+
+ Cancel
+
+
+
+
+ pushButton7
+
+
+ Close
+
+
+
+
+
+
+
+
+ pushButton7
+ clicked()
+ ExtraInfoDialog
+ accept()
+
+
+ pushButton13
+ clicked()
+ ExtraInfoDialog
+ reject()
+
+
+
+ lineEdit2
+ textEdit4
+ pushButton7
+ pushButton13
+ lineEdit7
+ textEdit4_2
+
+
+ qstring.h
+ extrainfodialog.ui.h
+
+
+ setMapName( const QString & s )
+ setComment( const QString & s )
+ setAuthor( const QString & s )
+
+
+ getComment()
+ getAuthor()
+ setStats( const QString & s )
+
+
+
+
diff -r 000000000000 -r 7a96bd401351 extrainfodialog.ui.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/extrainfodialog.ui.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,39 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** Qt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+void ExtraInfoDialog::setMapName(const QString &s)
+{
+ lineEdit7->setText (s);
+}
+
+void ExtraInfoDialog::setComment (const QString &s)
+{
+ textEdit4->setText (s);
+}
+
+QString ExtraInfoDialog::getComment()
+{
+ return textEdit4->text();
+}
+
+
+void ExtraInfoDialog::setAuthor(const QString &s)
+{
+ lineEdit2->setText (s);
+}
+
+QString ExtraInfoDialog::getAuthor()
+{
+ return lineEdit2->text();
+}
+
+void ExtraInfoDialog::setStats(const QString &s)
+{
+ textEdit4_2->setText (s);
+}
diff -r 000000000000 -r 7a96bd401351 findwindow.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/findwindow.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,85 @@
+#include
+
+#include "findwindow.h"
+
+
+FindWindow::FindWindow(QWidget* parent, const char* name, WFlags f)
+ : QGroupBox( 0, Horizontal, "Find", parent, name )
+
+{
+ setCaption ("VYM - Find Text");
+ //resize (180,130);
+ move (130,130);
+
+ setMargin( 100 );
+
+ QVBoxLayout* box = new QVBoxLayout( layout() );
+
+ QHBoxLayout *row1 = new QHBoxLayout( box );
+ row1->setMargin( 10 );
+
+ // Create a Label
+ QLabel* label = new QLabel( "Text to find: ", this);
+ row1->addWidget( label );
+
+ // Create LineEdit (here QComboBox)
+ QHBoxLayout *row2 = new QHBoxLayout( box );
+ row2->setMargin( 10 );
+ findcombo = new QComboBox( true, this );
+ findcombo->setMinimumWidth(150);
+ row2->addWidget( findcombo );
+ connect ( findcombo, SIGNAL( highlighted(int) ),
+ this, SLOT( findPressed() ) );
+ connect ( findcombo, SIGNAL( textChanged(const QString &) ),
+ this, SLOT( findTextChanged(const QString&) ) );
+ //findcombo->insertItem( "Normal", -1 );
+
+ // Create Buttons
+ QHBoxLayout *row3 = new QHBoxLayout( box );
+ row3->setMargin( 10 );
+ clearbutton = new QPushButton (tr("Clear"),this);
+ connect ( clearbutton, SIGNAL( clicked() ),
+ findcombo, SLOT( clearEdit() ) );
+ row3->addWidget (clearbutton);
+
+ QSpacerItem *si1= new QSpacerItem (10,0,QSizePolicy::Minimum, QSizePolicy::Expanding );
+ row3->addItem(si1);
+
+ cancelbutton = new QPushButton (tr("Cancel"),this);
+ cancelbutton->setAccel (Key_Escape);
+ connect ( cancelbutton, SIGNAL( clicked() ),
+ this, SLOT( cancelPressed() ) );
+ row3->addWidget (cancelbutton);
+
+ QSpacerItem *si2= new QSpacerItem (10,0,QSizePolicy::Fixed, QSizePolicy::Fixed);
+ row3->addItem(si2);
+
+ findbutton = new QPushButton (tr("Find"),this);
+ findbutton->setDefault (true);
+ connect ( findbutton, SIGNAL( clicked() ),
+ this, SLOT( findPressed() ) );
+ row3->add(findbutton);
+
+ findcombo->setFocus();
+}
+
+void FindWindow::popup()
+{
+ findcombo->lineEdit()->selectAll();
+ show();
+}
+
+void FindWindow::cancelPressed()
+{
+ hide();
+}
+
+void FindWindow::findPressed()
+{
+ emit (findButton(findcombo->currentText() ) );
+}
+
+void FindWindow::findTextChanged(const QString&)
+{
+ emit (somethingChanged() );
+}
diff -r 000000000000 -r 7a96bd401351 findwindow.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/findwindow.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,38 @@
+#ifndef FINDWINDOW_H
+#define FINDWINDOW_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+class FindWindow : public QGroupBox
+{
+ Q_OBJECT
+
+public:
+ FindWindow (QWidget* parent=0, const char* namme=0, WFlags f=0);
+
+public slots:
+ void popup();
+ void cancelPressed();
+ void findPressed();
+ void findTextChanged(const QString&);
+
+signals:
+ void findButton(QString); // emit to mainwindow
+ void somethingChanged(); // emit to mainwindow
+
+private:
+ QGroupBox *findbox;
+ QComboBox *findcombo;
+ QPushButton *clearbutton;
+ QPushButton *findbutton;
+ QPushButton *cancelbutton;
+};
+
+
+#endif
diff -r 000000000000 -r 7a96bd401351 flagobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flagobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,201 @@
+#include "flagobj.h"
+
+/////////////////////////////////////////////////////////////////
+// FlagObj
+/////////////////////////////////////////////////////////////////
+FlagObj::FlagObj()
+{
+// cout << "Const FlagObj ()\n";
+ init ();
+}
+
+FlagObj::FlagObj(QCanvas* c):MapObj(c)
+{
+// cout << "Const FlagObj\n";
+ init ();
+}
+
+FlagObj::FlagObj (FlagObj* io)
+{
+ copy (io);
+}
+
+FlagObj::~FlagObj()
+{
+// cout << "Destr FlagObj " << name << "\n";
+ delete (icon);
+}
+
+
+void FlagObj::init ()
+{
+ name="undefined";
+
+ icon=new ImageObj (canvas);
+ icon->move (absPos.x(), absPos.y() );
+ button=NULL;
+ state=false;
+}
+
+void FlagObj::copy (FlagObj* other)
+{
+ MapObj::copy(other);
+ name=other->name;
+ tooltip=other->tooltip;
+ state=other->state;
+ icon->copy(other->icon);
+ setVisibility (other->isVisibleObj() );
+ // button is not copied, because
+ // we won't copy to a parentRow and
+ // all others don't need a button
+}
+
+void FlagObj::move(double x, double y)
+{
+ MapObj::move(x,y);
+ icon->move(x,y);
+ positionBBox();
+}
+
+void FlagObj::moveBy(double x, double y)
+{
+ move (x+absPos.x(),y+absPos.y() );
+}
+
+void FlagObj::setVisibility (bool v)
+{
+ MapObj::setVisibility(v);
+ if (v && state)
+ icon->setVisibility(true);
+ else
+ icon->setVisibility(false);
+}
+
+void FlagObj::load (const QString &fn)
+{
+ icon->load(fn);
+ calcBBoxSize();
+ positionBBox();
+}
+
+void FlagObj::load (const QPixmap &pm)
+{
+ icon->load(pm);
+ calcBBoxSize();
+ positionBBox();
+}
+
+void FlagObj::setName(const QString &n)
+{
+ name=n;
+}
+
+const QString FlagObj::getName()
+{
+ return name;
+}
+
+void FlagObj::setToolTip(const QString &n)
+{
+ tooltip=n;
+}
+
+const QString FlagObj::getToolTip()
+{
+ return tooltip;
+}
+
+void FlagObj::setButton(QAction* b)
+{
+ button=b;
+}
+
+void FlagObj::updateButton()
+{
+ if (button)
+ button->setOn(state);
+ else
+ qWarning ("FlagObj::updateButton no button defined");
+}
+
+QPixmap FlagObj::getPixmap()
+{
+ return icon->getPixmap();
+}
+
+bool FlagObj::isActive()
+{
+ return state;
+}
+
+void FlagObj::toggle()
+{
+ if (state)
+ deactivate();
+ else
+ activate();
+}
+
+void FlagObj::activate()
+{
+ state=true;
+ // only show icon, if flag itself is visible
+ if (visible)
+ {
+ icon->setVisibility (true);
+ calcBBoxSize();
+ }
+}
+
+void FlagObj::deactivate()
+{
+ state=false;
+ // if flag itself is invisible we don't need to call
+ if (visible)
+ {
+ icon->setVisibility (false);
+ calcBBoxSize();
+ }
+}
+
+void FlagObj::setEnabled(bool b)
+{
+ button->setEnabled (b);
+}
+
+
+void FlagObj::setUsed (bool b)
+{
+ used=b;
+}
+
+bool FlagObj::isUsed()
+{
+ return used;
+}
+
+void FlagObj::saveToDir (const QString &tmpdir, const QString &prefix)
+{
+ QString fn=tmpdir + prefix + name + ".png";
+ icon->save (fn,"PNG");
+}
+
+void FlagObj::positionBBox()
+{
+ bbox.setX (absPos.x() );
+ bbox.setY (absPos.y() );
+}
+
+void FlagObj::calcBBoxSize()
+{
+ if (visible && state)
+ {
+ bbox.setSize ( QSize(
+ icon->boundingRect().width(),
+ icon->boundingRect().height() ) );
+ } else
+ {
+ bbox.setSize (QSize(0,0));
+ }
+}
+
diff -r 000000000000 -r 7a96bd401351 flagobj.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flagobj.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,53 @@
+#ifndef FLAGOBJ_H
+#define FLAGOBJ_H
+
+
+#include
+#include
+
+#include "mapobj.h"
+#include "imageobj.h"
+
+/////////////////////////////////////////////////////////////////////////////
+class FlagObj:public MapObj {
+public:
+ FlagObj ();
+ FlagObj (QCanvas*);
+ FlagObj (FlagObj*);
+ ~FlagObj ();
+ virtual void init ();
+ virtual void copy (FlagObj*);
+ virtual void move (double x,double y); // move to absolute Position
+ virtual void moveBy (double x,double y); // move to relative Position
+ virtual void setVisibility(bool);
+ void load (const QString&);
+ void load (const QPixmap&);
+ void setName (const QString&);
+ const QString getName ();
+ void setToolTip(const QString&);
+ const QString getToolTip();
+ void setButton (QAction*);
+ void updateButton ();
+ QPixmap getPixmap();
+ bool isActive();
+ void toggle();
+ void activate();
+ void deactivate();
+ void setEnabled (bool);
+ void setUsed (bool);
+ bool isUsed();
+ void saveToDir (const QString&, const QString&);
+
+protected:
+ QString name;
+ QString tooltip;
+ bool state;
+ bool used;
+ virtual void positionBBox();
+ virtual void calcBBoxSize();
+private:
+ ImageObj* icon;
+ QAction* button;
+};
+
+#endif
diff -r 000000000000 -r 7a96bd401351 flagrowobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flagrowobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,322 @@
+#include "flagrowobj.h"
+
+/////////////////////////////////////////////////////////////////
+// FlagRowObj
+/////////////////////////////////////////////////////////////////
+FlagRowObj::FlagRowObj()
+{
+ cout << "Const FlagRowObj ()\n";
+ init ();
+}
+
+FlagRowObj::FlagRowObj(QCanvas* c):MapObj(c)
+{
+// cout << "Const FlagRowObj\n";
+ init ();
+}
+
+FlagRowObj::~FlagRowObj()
+{
+// cout << "Destr FlagRowObj\n";
+ flag.clear();
+}
+
+void FlagRowObj::init ()
+{
+ flag.setAutoDelete (true);
+ parentRow=NULL;
+}
+
+void FlagRowObj::copy (FlagRowObj* other)
+{
+ MapObj::copy(other);
+ parentRow=other->parentRow;
+ flag.clear();
+ FlagObj *fo;
+ for (fo=other->flag.first(); fo; fo=other->flag.next() )
+ addFlag (fo);
+}
+
+void FlagRowObj::clone (FlagRowObj* pr)
+{
+ // Difference to copy:
+ // We don't copy the flags here, they
+ // are created on the fly by toggle and activate
+ // This saves lots of canvas objects.
+ MapObj::copy(pr);
+ flag.clear();
+ parentRow=pr;
+}
+
+void FlagRowObj::move(double x, double y)
+{
+ MapObj::move(x,y);
+ int dx=0;
+ FlagObj *fo;
+ for (fo=flag.first(); fo; fo=flag.next() )
+ {
+ fo->move(x+dx,y);
+ dx+=QSize(fo->getSize() ).width();
+ }
+}
+
+void FlagRowObj::moveBy(double x, double y)
+{
+ move (x+absPos.x(),y+absPos.y() );
+}
+
+void FlagRowObj::setVisibility (bool v)
+{
+ MapObj::setVisibility(v);
+ FlagObj *fo;
+ for (fo=flag.first(); fo; fo=flag.next() )
+ fo->setVisibility (v);
+}
+
+FlagObj* FlagRowObj::addFlag (FlagObj *fo)
+{
+ FlagObj *newfo=new FlagObj (canvas);
+ newfo->move (absPos.x() + bbox.width(), absPos.y() );
+ newfo->copy (fo); // create a deep copy of fo
+ flag.append(newfo);
+ calcBBoxSize();
+ positionBBox();
+ return newfo;
+}
+
+void FlagRowObj::positionBBox()
+{
+ bbox.setX (absPos.x() );
+ bbox.setY (absPos.y() );
+}
+
+void FlagRowObj::calcBBoxSize()
+{
+ QSize size(0,0);
+ QSize boxsize(0,0);
+ FlagObj *fo;
+ for (fo=flag.first(); fo; fo=flag.next() )
+ {
+ size=fo->getSize();
+ // add widths
+ boxsize.setWidth(boxsize.width() + size.width() );
+ // maximize height
+ if (size.height() > boxsize.height() )
+ boxsize.setHeight(size.height() );
+ }
+ bbox.setSize (QSize(boxsize.width(), boxsize.height() ));
+}
+
+QString FlagRowObj::getFlagName (const QPoint &p)
+{
+ if (!inBBox (p)) return "";
+ FlagObj *fo;
+ for (fo=flag.first();fo; fo=flag.next() )
+ if (fo->inBBox (p)) return fo->getName();
+ return "";
+
+
+}
+
+bool FlagRowObj::isActive (const QString &foname)
+{
+ FlagObj *fo=findFlag (foname);
+ if (parentRow)
+ {
+ if (fo)
+ return fo->isActive();
+ else
+ qWarning ("FlagRowObj::isActive of "+name+" couldn't find "+foname);
+
+ } else
+ if (fo) return true;
+ return false;
+}
+
+void FlagRowObj::toggle (const QString &foname)
+{
+ FlagObj *fo=findFlag (foname);
+ if (fo)
+ {
+ // FlagObj is here, it will be active, too.
+ // Deactivate it by removing it from this row.
+ flag.remove (fo);
+ } else
+ {
+ // FlagObj is not present in this row.
+ // Copy it from parentRow
+ fo=parentRow->findFlag (foname);
+ if (fo)
+ {
+ fo=addFlag (fo);
+ fo->activate();
+ } else
+ qWarning ("FlagRowObj ("+name+")::toggle ("+foname+") failed - could not find it in parentRow");
+ }
+ calcBBoxSize();
+ positionBBox();
+}
+
+void FlagRowObj::activate (const QString &foname)
+{
+ FlagObj *fo=findFlag (foname);
+ if (parentRow)
+ {
+ if (!fo)
+ {
+ // FlagObj is not present in this row.
+ // Copy it from parentRow and activate there
+ fo=parentRow->findFlag (foname);
+ if (fo)
+ {
+ fo=addFlag (fo);
+ fo->activate();
+ fo->setVisibility (visible);
+ calcBBoxSize();
+ positionBBox();
+ } else
+ qWarning ("FlagRowObj ("+name+")::activate ("+foname+") failed - could not find it in parentRow");
+ }
+ } else
+ {
+ // I am the parentRow, mark flag as used
+ if (fo)
+ {
+ fo->setUsed(true);
+ fo->activate();
+ }
+ else
+ qWarning ("FlagRowObj::activate no FlagObj \""+foname+"\" found in parentRow");
+ }
+}
+
+void FlagRowObj::deactivate (const QString &foname)
+{
+ FlagObj *fo=findFlag (foname);
+ if (fo) flag.remove(fo);
+ calcBBoxSize();
+ positionBBox();
+}
+
+void FlagRowObj::deactivateAll ()
+{
+ if (!parentRow)
+ {
+ FlagObj *fo;
+ for (fo=flag.first();fo; fo=flag.next() )
+ {
+ fo->deactivate();
+ }
+ } else
+ qWarning ("FlagRowObj::deactivateAll mustn't be called for ordinary rows");
+}
+
+void FlagRowObj::setEnabled (bool b)
+{
+ // If we have no parent, we are the default FlagRowObj
+ // and have QToolbarButtons
+ if (!parentRow)
+ {
+ FlagObj *fo;
+ for (fo=flag.first();fo; fo=flag.next() )
+ fo->setEnabled (b);
+ }
+}
+
+void FlagRowObj::resetUsedCounter()
+{
+ FlagObj *fo;
+ for (fo=flag.first();fo; fo=flag.next() )
+ fo->setUsed (false);
+}
+
+QString FlagRowObj::saveToDir (const QString &tmpdir,const QString &prefix, bool writeflags)
+{
+ // Build xml string
+ QString s;
+ FlagObj *fo;
+ if (parentRow)
+ for (fo=flag.first();fo; fo=flag.next() )
+ {
+ // save flag to xml, if flag is set
+ s+=valueElement("standardflag",fo->getName() );
+
+ // and tell parentRow, that this flag is used
+ parentRow->activate(fo->getName() );
+ }
+ else
+ // Save icons to dir, if verbose is set (xml export)
+ // and I am a parentRow
+ // and this flag is really used somewhere
+ if (writeflags)
+ for (fo=flag.first();fo; fo=flag.next() )
+ if (fo->isUsed()) fo->saveToDir (tmpdir,prefix);
+ return s;
+
+}
+
+void FlagRowObj::setName (const QString &n)
+{
+ name=n;
+}
+
+void FlagRowObj::makeToolbar (QMainWindow *w, const QString &n)
+{
+ if (!parentRow)
+ {
+ // create bar and buttons
+ QToolBar* tb = new QToolBar( w);
+ tb->setLabel (n);
+ QAction *a;
+ FlagObj *fo;
+ for (fo=flag.first();fo; fo=flag.next() )
+ {
+ a=new QAction (
+ fo->getToolTip(),
+ fo->getPixmap(),
+ fo->getName(),
+ 0,
+ w,
+ fo->getName()
+ );
+ a->setToggleAction(true);
+ // FIXME should not be enabled by default, later in updateToolbar
+ a->setEnabled(true);
+ a->addTo (tb);
+ fo->setButton (a);
+ connect(a, SIGNAL( activated() ),
+ w, SLOT( standardFlagChanged() ) );
+ }
+ } else
+ qWarning ("FlagRowObj::makeToolbar mustn't be called for ordinary rows");
+}
+
+void FlagRowObj::updateToolBar()
+{
+ FlagObj *fo;
+ if (parentRow)
+ {
+ // We are just a branch, not the toolbar default
+ parentRow->deactivateAll();
+ // In parentRow activate all existing (==active) flags
+ for (fo=flag.first();fo; fo=flag.next() )
+ parentRow->activate(fo->getName());
+ parentRow->updateToolBar();
+ } else
+ {
+ // We are the toolbar default
+ for (fo=flag.first();fo; fo=flag.next() )
+ fo->updateButton();
+ }
+}
+
+FlagObj* FlagRowObj::findFlag (const QString &name)
+{
+ FlagObj *fo;
+ for (fo=flag.first();fo; fo=flag.next() )
+ {
+ if (fo->getName()==name) return fo;
+ }
+ return NULL;
+}
+
diff -r 000000000000 -r 7a96bd401351 flagrowobj.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flagrowobj.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,41 @@
+#ifndef FLAGROWOBJ_H
+#define FLAGROWOBJ_H
+
+#include
+
+#include "mapobj.h"
+#include "flagobj.h"
+
+class FlagRowObj:public QObject,public MapObj {
+public:
+ FlagRowObj ();
+ FlagRowObj (QCanvas*);
+ ~FlagRowObj ();
+ virtual void init ();
+ virtual void copy (FlagRowObj*);
+ virtual void clone(FlagRowObj*);
+ virtual void move (double,double);
+ virtual void moveBy (double,double);
+ virtual void setVisibility(bool);
+ virtual FlagObj* addFlag (FlagObj *fo); // make deep copy of FlagObj
+ virtual void positionBBox();
+ virtual void calcBBoxSize();
+ virtual QString getFlagName (const QPoint &p); // Find flag by position
+ bool isActive(const QString&);
+ void toggle (const QString&);
+ void activate(const QString&);
+ void deactivate(const QString&);
+ void deactivateAll();
+ void setEnabled (bool);
+ void resetUsedCounter();
+ QString saveToDir (const QString &,const QString &,bool);
+ void setName (const QString&); // prefix for exporting flags to dir
+ void makeToolbar (QMainWindow*, const QString &); // Create Toolbar buttons
+ void updateToolBar(); // Update Toolbar buttons
+private:
+ FlagRowObj* parentRow; // look for flags in this row
+ FlagObj* findFlag (const QString&);
+ QPtrList flag;
+ QString name;
+};
+#endif
diff -r 000000000000 -r 7a96bd401351 floatimageobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/floatimageobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,219 @@
+#include "floatimageobj.h"
+#include "branchobj.h"
+#include
+
+
+/////////////////////////////////////////////////////////////////
+// FloatImageObj
+/////////////////////////////////////////////////////////////////
+
+int FloatImageObj::counter=0; // make instance
+
+
+FloatImageObj::FloatImageObj ():FloatObj()
+{
+// cout << "Const FloatImageObj ()\n";
+ setParObj (this);
+ init();
+ depth=-1;
+}
+
+FloatImageObj::FloatImageObj (QCanvas* c):FloatObj(c)
+{
+ // cout << "Const FloatImageObj (c) called from MapCenterObj (c)\n";
+ setParObj (this);
+ init();
+ depth=-1;
+}
+
+FloatImageObj::FloatImageObj (QCanvas* c, LinkableMapObj* p):FloatObj(c,p)
+{
+ // cout << "Const FloatImageObj (c,p)\n";
+ init();
+}
+
+FloatImageObj::~FloatImageObj ()
+{
+// cout << "Destr FloatImageObj "<move (absPos.x(), absPos.y() );
+ icon->setVisibility (true);
+ bbox.setSize (QSize(icon->size().width(), icon->size().height()));
+ filename="";
+ originalFilename="no original name available";
+ filetype="";
+ saveInMap=true;
+}
+
+void FloatImageObj::copy (FloatImageObj* other)
+{
+ FloatObj::copy (other);
+ icon->copy (other->icon);
+ filename=other->filename;
+ saveInMap=other->saveInMap;
+ positionBBox();
+}
+
+void FloatImageObj::setZ (const int &i)
+{
+ icon->setZ (i);
+ zPlane=i;
+}
+
+int FloatImageObj::z ()
+{
+ return lrint (icon->z());
+}
+
+bool FloatImageObj::load (const QString &fn)
+{
+ if( icon->load (fn))
+ {
+ bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
+ positionBBox();
+ filename=fn;
+ filetype=QPixmap::imageFormat (fn);
+ return true;
+ } else
+ return false;
+
+}
+
+void FloatImageObj::save (const QString &fn, const char *format)
+{
+ icon->save (fn,format);
+}
+
+void FloatImageObj::setOriginalFilename(const QString & fn)
+{
+ originalFilename=fn;
+}
+
+QString FloatImageObj::getOriginalFilename()
+{
+ return originalFilename;
+}
+
+void FloatImageObj::setVisibility(bool v)
+{
+ LinkableMapObj::setVisibility(v);
+ if (v)
+ icon->setVisibility(true);
+ else
+ icon->setVisibility(false);
+}
+
+void FloatImageObj::move (double x, double y)
+{
+ FloatObj::move(x,y);
+ icon->move (x+4,y+4);
+ positionBBox();
+}
+
+void FloatImageObj::move (QPoint p)
+{
+ move (p.x(), p.y());
+}
+
+void FloatImageObj::positionBBox()
+{
+ // TODO
+}
+
+void FloatImageObj::calcBBoxSize()
+{
+ // TODO
+}
+
+QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix)
+{
+ counter++;
+
+ QString posAttr=
+ attribut("relPosX",QString().setNum(relPos.x(),10)) +
+ attribut("relPosY",QString().setNum(relPos.y(),10));
+
+ QString useOrientAttr;
+ if (useOrientation)
+ useOrientAttr=attribut ("useOrientation","true");
+ else
+ useOrientAttr=attribut ("useOrientation","false");
+
+ QString saveInMapAttr;
+ if (saveInMap)
+ saveInMapAttr=attribut ("saveInMap","true");
+ else
+
+ saveInMapAttr=attribut ("saveInMap","false");
+
+ QString exportAttr;
+ if (floatExport)
+ exportAttr=attribut ("floatExport","true");
+ else
+ exportAttr=attribut ("floatExport","false");
+
+ QString zAttr=attribut ("zPlane",QString().setNum(zPlane));
+ QString url;
+
+ // prevent saving as GIF
+ if (filetype=="GIF")
+ filetype="PNG";
+
+ url="images/"+prefix+"image-" + QString().number(counter,10) + "." +filetype;
+
+ // And really save the image
+ icon->save (tmpdir + "/" + url, filetype);
+
+ return singleElement ("floatimage",
+ posAttr +
+ useOrientAttr +
+ saveInMapAttr +
+ exportAttr +
+ zAttr +
+ attribut ("href",QString ("file:")+url)
+ );
+}
+
+void FloatImageObj::resetSaveCounter()
+{
+ counter=0;
+}
+
+
+QRect FloatImageObj::getTotalBBox()
+{
+ return bbox;
+}
+
+QRect FloatImageObj::getBBoxSizeWithChilds()
+{
+ //FIXME abstract in linkablemapobj.h, not calculated
+ return bboxTotal;
+}
+
+void FloatImageObj::calcBBoxSizeWithChilds()
+{
+ //FIXME abstract in linkablemapobj.h
+}
+
+QString FloatImageObj::getSelectString()
+{
+ QString s;
+ if (parObj)
+ {
+ if (parObj->getDepth()==0)
+ s= "fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));
+ else
+ s= ((BranchObj*)(parObj))->getSelectString() + ",fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));
+ } else
+ s="mc:";
+
+ return s;
+
+}
+
diff -r 000000000000 -r 7a96bd401351 floatimageobj.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/floatimageobj.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,44 @@
+#ifndef FLOATIMAGEOBJ_H
+#define FLOATIMAGEOBJ_H
+
+#include "floatobj.h"
+
+/////////////////////////////////////////////////////////////////////////////
+class FloatImageObj:public FloatObj {
+public:
+ FloatImageObj ();
+ FloatImageObj (QCanvas*);
+ FloatImageObj (QCanvas*, LinkableMapObj* parent);
+ ~FloatImageObj ();
+ virtual void init ();
+ virtual void copy (FloatImageObj*);
+ virtual void setZ (const int&);
+ virtual int z();
+
+ virtual bool load (const QString &);
+ virtual void save (const QString &, const char *);
+ virtual void setOriginalFilename(const QString &);
+ virtual QString getOriginalFilename();
+ virtual void setVisibility(bool); // set vis. for w
+ virtual void move (double x,double y);
+ virtual void move (QPoint);
+ virtual void positionBBox();
+ virtual void calcBBoxSize();
+ virtual QRect getTotalBBox(); // return BBox including childs
+ virtual QRect getBBoxSizeWithChilds(); // return size of BBox including childs
+ virtual void calcBBoxSizeWithChilds(); // calc size of BBox including childs recursivly
+ virtual QString saveToDir(const QString &,const QString&);
+ virtual void resetSaveCounter();
+ virtual QString getSelectString();
+
+
+protected:
+ ImageObj *icon;
+ bool saveInMap;
+ static int counter; // numerate the files during saveToDir
+ QString filetype;
+ QString filename;
+ QString originalFilename;
+};
+
+#endif
diff -r 000000000000 -r 7a96bd401351 floatobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/floatobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,163 @@
+#include "floatobj.h"
+
+extern QAction* actionEditToggleFloatExport;
+
+/////////////////////////////////////////////////////////////////
+// FloatObj
+/////////////////////////////////////////////////////////////////
+
+FloatObj::FloatObj ():LinkableMapObj()
+{
+// cout << "Const FloatObj ()\n";
+ setParObj (this);
+ init();
+ depth=-1;
+}
+
+FloatObj::FloatObj (QCanvas* c):LinkableMapObj(c)
+{
+// cout << "Const FloatObj (c) called from MapCenterObj (c)\n";
+ setParObj (this);
+ init();
+ depth=-1;
+}
+
+FloatObj::FloatObj (QCanvas* c, LinkableMapObj* p):LinkableMapObj (c)
+{
+// cout << "Const FloatObj (c,p)\n";
+ setParObj (p);
+ depth=p->getDepth()+1;
+ init();
+}
+
+FloatObj::~FloatObj ()
+{
+// cout << "Destr FloatObj\n";
+}
+
+void FloatObj::init ()
+{
+ setChildObj(this);
+ relPos=getRandPos();
+ useOrientation=true;
+ floatExport=true;
+ zPlane=Z_ICON;
+}
+
+void FloatObj::copy (FloatObj* other)
+{
+ LinkableMapObj::copy (other);
+ relPos=other->relPos;
+ useOrientation=other->useOrientation;
+ setVisibility (other->visible);
+}
+
+void FloatObj::setRelPos()
+{
+ if (useOrientation)
+ {
+ if (parObj->getOrientation()==OrientLeftOfCenter)
+ relPos.setX ( parObj->x() +parObj->width() - bbox.width() -absPos.x());
+ else
+ relPos.setX (absPos.x() - parObj->x() );
+ }
+ else
+ relPos.setX (absPos.x() - parObj->x() );
+ relPos.setY (absPos.y() - parObj->y() );
+}
+
+void FloatObj::setRelPos(const QPoint &p)
+{
+ relPos=p;
+}
+
+void FloatObj::setZ(const int &i)
+{
+ zPlane=i;
+}
+
+int FloatObj::z()
+{
+ return zPlane;
+}
+
+
+void FloatObj::setUseOrientation (const bool &b)
+{
+ if (useOrientation!=b)
+ {
+ useOrientation=b;
+ requestReposition();
+ }
+}
+
+void FloatObj::setFloatExport(const bool& b)
+{
+ floatExport=b;
+}
+
+bool FloatObj::getFloatExport()
+{
+ return floatExport;
+}
+
+void FloatObj::move (double x, double y)
+{
+ MapObj::move(x,y);
+ selbox->move(x,y);
+}
+
+void FloatObj::move (QPoint p)
+{
+ move (p.x(), p.y());
+}
+
+void FloatObj::reposition()
+{
+ if (useOrientation)
+ {
+ if (parObj->getOrientation()==OrientLeftOfCenter)
+ move (parObj->x() - relPos.x() + parObj->width() - bbox.width(), parObj->y()+relPos.y());
+ else
+ move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
+ }
+ else
+ move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
+ updateLink();
+}
+
+QRect FloatObj::getTotalBBox()
+{
+ return bbox;
+}
+
+QRect FloatObj::getBBoxSizeWithChilds()
+{
+ return bboxTotal;
+}
+
+void FloatObj::select()
+{
+ LinkableMapObj::select();
+ // Temporary draw the link while FO is selected
+ if (style==StyleUndef)
+ {
+ setLinkStyle(getDefLinkStyle());
+ setLinkColor(parObj->getLinkColor());
+ }
+
+ // Update FloatExport switch in context menu
+ if (floatExport)
+ actionEditToggleFloatExport->setEnabled (true);
+ else
+ actionEditToggleFloatExport->setEnabled (true);
+
+
+}
+
+void FloatObj::unselect()
+{
+ LinkableMapObj::unselect();
+ setLinkStyle (StyleUndef);
+}
+
diff -r 000000000000 -r 7a96bd401351 floatobj.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/floatobj.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,45 @@
+#ifndef FLOATOBJ_H
+#define FLOATOBJ_H
+
+#include "linkablemapobj.h"
+
+/////////////////////////////////////////////////////////////////////////////
+class FloatObj:public LinkableMapObj {
+public:
+ FloatObj ();
+ FloatObj (QCanvas*);
+ FloatObj (QCanvas*, LinkableMapObj* parent);
+ ~FloatObj ();
+ virtual void init ();
+ virtual void copy (FloatObj*);
+ virtual bool load (const QString&)=0;
+ virtual void setRelPos(); // set relPos to current parentPos
+ virtual void setRelPos(const QPoint&);
+ virtual void setZ(const int&); // set zPlane
+ virtual int z();
+ virtual void setUseOrientation (const bool &);
+ virtual void setFloatExport (const bool &);
+ virtual bool getFloatExport ();
+
+ virtual void move (double,double);
+ virtual void move (QPoint);
+
+ virtual void reposition();
+
+ virtual QRect getTotalBBox(); // return BBox including childs
+ virtual QRect getBBoxSizeWithChilds(); // return size of BBox including childs
+
+ virtual QString saveToDir(const QString &,const QString&)=0;
+ virtual void resetSaveCounter()=0;
+
+ virtual void select();
+ virtual void unselect();
+
+protected:
+ QPoint relPos;
+ bool useOrientation;
+ bool floatExport;
+ int zPlane;
+};
+
+#endif
diff -r 000000000000 -r 7a96bd401351 frameobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/frameobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,146 @@
+#include "frameobj.h"
+
+#include
+
+/////////////////////////////////////////////////////////////////
+// FrameObj
+/////////////////////////////////////////////////////////////////
+FrameObj::FrameObj() : MapObj()
+{
+// cout << "Const FrameObj ()\n";
+ init ();
+}
+
+FrameObj::FrameObj(QCanvas* c) :MapObj(c)
+{
+// cout << "Const FrameObj\n";
+ init ();
+}
+
+FrameObj::~FrameObj()
+{
+ clear();
+}
+
+void FrameObj::init()
+{
+ type=NoFrame;
+ border=0;
+}
+
+void FrameObj::clear()
+{
+ switch (type)
+ {
+ case NoFrame:
+ break;
+ case Rectangle:
+ delete rectFrame;
+ break;
+ }
+ type=NoFrame;
+ border=0;
+}
+
+void FrameObj::move(double x, double y)
+{
+ switch (type)
+ {
+ case NoFrame:
+ break;
+ case Rectangle:
+ rectFrame->move (x,y);
+ break;
+ }
+}
+
+void FrameObj::moveBy(double x, double y)
+{
+ MapObj::moveBy (x,y);
+}
+
+void FrameObj::positionBBox()
+{
+}
+
+void FrameObj::calcBBoxSize()
+{
+}
+
+void FrameObj::setRect(const QRect &r)
+{
+ bbox=r;
+ switch (type)
+ {
+ case NoFrame:
+ break;
+ case Rectangle:
+ rectFrame->setX (bbox.x() );
+ rectFrame->setY (bbox.y() );
+ rectFrame->setSize (bbox.width(),bbox.height() );
+ break;
+ }
+}
+
+int FrameObj::getBorder()
+{
+ return border;
+}
+
+FrameType FrameObj::getFrameType()
+{
+ return type;
+}
+
+QString FrameObj::getFrameTypeName()
+{
+ switch (type)
+ {
+ case Rectangle:
+ return "Rectangle";
+ break;
+ default:
+ return "NoFrame";
+ }
+}
+
+void FrameObj::setFrameType(const FrameType &t)
+{
+ if (t!=type)
+ {
+ clear();
+ type=t;
+ switch (type)
+ {
+ case NoFrame:
+ border=0;
+ break;
+ case Rectangle:
+ border=10;
+ rectFrame = new QCanvasRectangle (canvas);
+ rectFrame->setZ(Z_FRAME);
+ rectFrame->setBrush( QColor("white") );
+ rectFrame->setPen( QPen(QColor("black") ));
+ if (visible)
+ rectFrame->show();
+ else
+ rectFrame->hide();
+ break;
+ }
+ }
+}
+
+void FrameObj::setFrameType(const QString &t)
+{
+ if (t=="Rectangle")
+ FrameObj::setFrameType (Rectangle);
+ else
+ FrameObj::setFrameType (NoFrame);
+}
+
+void FrameObj::setVisibility (bool v)
+{
+ MapObj::setVisibility(v);
+ setFrameType (type); // changes on visibility depend on type...
+}
+
diff -r 000000000000 -r 7a96bd401351 frameobj.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/frameobj.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,33 @@
+#ifndef FRAMEOBJ_H
+#define FRAMEOBJ_H
+
+#include "mapobj.h"
+
+enum FrameType {NoFrame,Rectangle};
+
+class FrameObj:public MapObj {
+public:
+ FrameObj();
+ FrameObj(QCanvas*);
+ ~FrameObj();
+ void init();
+ void clear();
+ void move (double x,double y); // move to absolute Position
+ void moveBy (double x,double y); // move to relative Position
+ void positionBBox();
+ void calcBBoxSize();
+ void setRect (const QRect &); // set dimensions
+ int getBorder();
+ FrameType getFrameType ();
+ QString getFrameTypeName ();
+ void setFrameType (const FrameType &);
+ void setFrameType (const QString &);
+ void setVisibility(bool);
+
+protected:
+ FrameType type;
+ QCanvasRectangle* rectFrame;
+ int border; // distance text - frame
+};
+#endif
+
diff -r 000000000000 -r 7a96bd401351 headingobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/headingobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,246 @@
+#include "headingobj.h"
+
+/////////////////////////////////////////////////////////////////
+// HeadingObj
+/////////////////////////////////////////////////////////////////
+HeadingObj::HeadingObj() : MapObj()
+{
+// cout << "Const HeadingObj ()\n";
+ init ();
+}
+
+HeadingObj::HeadingObj(QCanvas* c) :MapObj(c)
+{
+// cout << "Const HeadingObj\n";
+ init ();
+}
+
+HeadingObj::~HeadingObj()
+{
+ textline.clear();
+}
+
+void HeadingObj::init()
+{
+ textline.setAutoDelete (TRUE);
+ textwidth=40;
+ color=QColor ("black");
+ font=QFont();
+}
+
+void HeadingObj::copy(HeadingObj *other)
+{
+ MapObj::copy (other);
+ textwidth=other->textwidth;
+ color=other->color;
+ font=other->font;
+ setText (other->text() );
+}
+
+void HeadingObj::move(double x, double y)
+{
+ MapObj::move(x,y);
+ int h; // height of a textline
+ int ho; // offset of height while drawing all lines
+ if (textline.first() )
+ h=textline.first()->boundingRect().height();
+ else
+ h=2;
+ QCanvasText *t;
+ ho=0;
+ for (t=textline.first(); t; t=textline.next() )
+ {
+ t->move(x,y+ho);
+ ho=ho+h;
+ }
+}
+
+
+void HeadingObj::moveBy(double x, double y)
+{
+ move (x+absPos.x(),y+absPos.y() );
+}
+
+void HeadingObj::positionBBox()
+{
+ bbox.setX (absPos.x());
+ bbox.setY (absPos.y());
+}
+
+void HeadingObj::calcBBoxSize()
+{
+ int w=0;
+ int h=0;
+ // Using Backspace an empty heading might easily be created, then there
+ // would be textline.first()==NULL This can be worked around by the following, but
+ // then no selection would be visible, thus we prevent it in ::setText()
+ if (!textline.isEmpty() )
+ {
+ QCanvasText *t;
+ for (t=textline.first(); t; t=textline.next() )
+ {
+ h+=t->boundingRect().height();
+ if (wboundingRect().width() )
+ w=t->boundingRect().width();
+ }
+ }
+ bbox.setSize (QSize(w,h));
+}
+
+QCanvasText* HeadingObj::newLine(QString s)
+{
+ QCanvasText *t;
+ t = new QCanvasText(canvas);
+ t->setFont (font);
+ t->setColor (color);
+ t->setZ(Z_TEXT);
+ t->setText(s);
+ t->show();
+ return t;
+}
+
+void HeadingObj::setText (QString s)
+{
+ heading=s;
+
+ // remove old textlines and prepare generating new ones
+ textline.clear();
+
+ // prevent empty textline, so at least a small selection stays
+ // visible for this heading
+ if (s.length()==0) s=" ";
+
+ int i=0; // index for actual search for ws
+ int j=0; // index of last ws
+ int k=0; // index of " " or similar linebreak
+ int br=0; // width of found break, e.g. for it is 4
+
+ // set the text and wrap lines
+ while (s.length()>0)
+ {
+ // ok, some people wanted manual linebreaks, here we go
+ k=s.find (" ",i,false);
+ if (k>=0)
+ {
+ br=4;
+ i=k;
+ } else
+ i=s.find (" ",i,false);
+ if (i<0 && j==0)
+ { // no ws found at all in s
+ // append whole s
+ textline.append (newLine(s));
+ s="";
+ } else
+ {
+ if (i<0 && j>0)
+ { // no ws found in actual search
+ if (s.length()<=textwidth)
+ {
+ textline.append (newLine(s));
+ s="";
+ } else
+ {
+ textline.append (newLine(s.left(j)));
+ s=s.mid(j+1,s.length());
+ j=0;
+ }
+ } else
+ {
+ if (i>= 0 && i<=static_cast (textwidth))
+ { // there is a ws in textwidth
+ if (br>0)
+ {
+ // here is a linebreak
+ textline.append (newLine(s.left(i)));
+ s=s.mid(i+br,s.length());
+ i=0;
+ j=0;
+ br=0;
+ } else
+ {
+ j=i;
+ i++;
+ }
+ } else
+ {
+ if (i>static_cast (textwidth) )
+ {
+ if (j>0)
+ { // a ws out of textwidth, but we have also one in
+ textline.append (newLine(s.left(j)));
+ s=s.mid(j+1,s.length());
+ i=0;
+ j=0;
+ } else
+ { // a ws out of text, but none in
+ textline.append (newLine(s.left(i)));
+ s=s.mid(i+1,s.length());
+ i=0;
+ }
+ }
+ }
+ }
+ }
+ }
+ setVisibility (visible);
+ calcBBoxSize();
+}
+
+QString HeadingObj::text ()
+{
+ return heading;
+}
+
+void HeadingObj::setFont (QFont f)
+{
+ if (font!=f)
+ {
+ font=f;
+ setText (text());
+ }
+}
+
+QFont HeadingObj::getFont()
+{
+ return font;
+}
+
+
+void HeadingObj::setColor (QColor c)
+{
+ if (color!=c)
+ {
+ color=c;
+ QCanvasText *t;
+ for (t=textline.first(); t; t=textline.next() )
+ t->setColor(c);
+ }
+}
+
+QColor HeadingObj::getColor()
+{
+ return color;
+}
+
+void HeadingObj::setVisibility (bool v)
+{
+ MapObj::setVisibility(v);
+ QCanvasText *t;
+ for (t=textline.first(); t; t=textline.next() )
+ if (v)
+ t->show();
+ else
+ t->hide();
+}
+
+int HeadingObj::getHeight ()
+{
+ return bbox.height();
+}
+
+int HeadingObj::getWidth()
+{
+ return bbox.width();
+}
+
diff -r 000000000000 -r 7a96bd401351 headingobj.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/headingobj.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,37 @@
+#ifndef HEADINGOBJ_H
+#define HEADINGOBJ_H
+
+#include "mapobj.h"
+
+class HeadingObj:public MapObj {
+public:
+ HeadingObj();
+ HeadingObj(QCanvas*);
+ virtual ~HeadingObj();
+ virtual void init();
+ virtual void copy(HeadingObj*);
+ virtual void move (double x,double y); // move to absolute Position
+ virtual void moveBy (double x,double y); // move to relative Position
+ virtual void positionBBox();
+ virtual void calcBBoxSize();
+private:
+ QCanvasText* newLine(QString); // generate new textline
+public:
+ virtual void setText(QString);
+ virtual QString text();
+ virtual void setFont(QFont);
+ virtual QFont getFont();
+ virtual void setColor(QColor);
+ virtual QColor getColor();
+ virtual void setVisibility(bool);
+ virtual int getHeight();
+ virtual int getWidth();
+
+protected:
+ QString heading;
+ uint textwidth; // width for formatting text
+ QPtrList textline; // a part of e.g. the parabel
+ QColor color;
+ QFont font;
+};
+#endif
diff -r 000000000000 -r 7a96bd401351 imageobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/imageobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,100 @@
+#include "imageobj.h"
+
+/////////////////////////////////////////////////////////////////
+// ImageObj
+/////////////////////////////////////////////////////////////////
+ImageObj::ImageObj( QCanvas *canvas )
+ : QCanvasRectangle( canvas )
+{
+// cout << "Const ImageObj (canvas)\n";
+ setZ(Z_ICON);
+ type=undef;
+}
+
+ImageObj::~ImageObj()
+{
+// cout << "Destr ImageObj\n";
+}
+
+void ImageObj::copy(ImageObj* other)
+{
+ setSize (other->width(), other->height() );
+ setVisibility (other->isVisible() );
+ type=other->type;
+// if (type==qimage)
+ image=other->image;
+// if (type==qpixmap)
+ pixmap=other->pixmap;
+}
+
+void ImageObj::setVisibility (bool v)
+{
+ if (v)
+ show();
+ else
+ hide();
+}
+
+void ImageObj::save(const QString &fn, const char *format)
+{
+ switch (type)
+ {
+ case undef: qWarning("undef");break;
+ case qimage: image.save (fn,format,-1);break;
+ case qpixmap: pixmap.save (fn,format,-1);break;
+ }
+}
+
+bool ImageObj::load (const QString &fn)
+{
+ if (!image.load( fn) )
+ //cout << "Fatal Error in ImageObj::load ("<
+#include
+#include
+
+#include "mapobj.h"
+
+enum ImageType {qimage,qpixmap,undef};
+
+class ImageObj: public QCanvasRectangle
+{
+public:
+ ImageObj( QCanvas *canvas );
+ ~ImageObj();
+ virtual void copy (ImageObj*);
+ virtual void setVisibility(bool);
+ void save (const QString &, const char *);
+ bool load (const QString &);
+ bool load (QPixmap);
+ void setImage(QImage img);
+ QPixmap getPixmap();
+protected:
+ void drawShape( QPainter & );
+private:
+ QImage image;
+ QPixmap pixmap;
+ ImageType type;
+};
+#endif
diff -r 000000000000 -r 7a96bd401351 linkablemapobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/linkablemapobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,693 @@
+//#include
+
+#include "linkablemapobj.h"
+#include "branchobj.h"
+#include "mapeditor.h"
+
+#include "version.h"
+
+
+/////////////////////////////////////////////////////////////////
+// LinkableMapObj
+/////////////////////////////////////////////////////////////////
+
+LinkableMapObj::LinkableMapObj():MapObj()
+{
+ // cout << "Const LinkableMapObj ()\n";
+ init ();
+}
+
+LinkableMapObj::LinkableMapObj(QCanvas* c) :MapObj(c)
+{
+// cout << "Const LinkableMapObj\n";
+ init ();
+}
+
+LinkableMapObj::LinkableMapObj (LinkableMapObj* lmo) : MapObj (lmo->canvas)
+{
+ copy (lmo);
+}
+
+LinkableMapObj::~LinkableMapObj()
+{
+ delete (bottomline);
+ delete (selbox);
+ delete (frame);
+ delLink();
+}
+
+void LinkableMapObj::delLink()
+{
+ switch (style)
+ {
+ case StyleLine:
+ delete (l);
+ break;
+ case StyleParabel:
+ segment.clear();
+ break;
+ case StylePolyLine:
+ delete (p);
+ delete (l);
+ break;
+ case StylePolyParabel:
+ delete (p);
+ segment.clear();
+ break;
+ default:
+ break;
+ }
+}
+
+void LinkableMapObj::init ()
+{
+ depth=-1;
+ childObj=NULL;
+ parObj=NULL;
+ parObjTmpBuf=NULL;
+ parPos=QPoint(0,0);
+ childPos=QPoint(0,0);
+ link2ParPos=false;
+ l=NULL;
+ orientation=OrientUndef;
+ linkwidth=20;
+ thickness_start=8;
+ style=StyleUndef;
+ linkpos=LinkBottom;
+ segment.setAutoDelete (TRUE);
+ arcsegs=13;
+ QPointArray pa(arcsegs*2+2);
+
+ bottomline=new QCanvasLine(canvas);
+ bottomline->setPen( QPen(linkcolor, 1) );
+ bottomline->setZ(Z_LINK);
+ bottomline->show();
+
+ // Prepare showing the selection of a MapObj
+ selbox = new QCanvasRectangle (canvas);
+ selbox->setZ(Z_SELBOX);
+ selbox->setBrush( QColor(255,255,0) );
+ selbox->setPen( QPen(QColor(255,255,0) ));
+ selbox->hide();
+ selected=false;
+
+ // initialize frame
+ frame = new FrameObj (canvas);
+
+ repositionRequest=false;
+}
+
+void LinkableMapObj::copy (LinkableMapObj* other)
+{
+ MapObj::copy(other);
+ bboxTotal=other->bboxTotal;
+// linkwidth=other->linkwidth;
+
+ setLinkStyle(other->style);
+ setLinkColor (other->linkcolor);
+}
+
+void LinkableMapObj::setChildObj(LinkableMapObj* o)
+{
+ childObj=o;
+}
+
+void LinkableMapObj::setParObj(LinkableMapObj* o)
+{
+ parObj=o;
+ mapEditor=parObj->getMapEditor();
+}
+
+void LinkableMapObj::setParObjTmp(LinkableMapObj*,QPoint,int)
+{
+}
+
+void LinkableMapObj::unsetParObjTmp()
+{
+}
+
+LinkStyle LinkableMapObj::getDefLinkStyle ()
+{
+ LinkStyle ls=mapEditor->getLinkStyle();
+ switch (ls)
+ {
+ case StyleLine:
+ return ls;
+ break;
+ case StyleParabel:
+ return ls;
+ break;
+ case StylePolyLine:
+ if (depth>1)
+ return StyleLine;
+ else
+ return ls;
+ break;
+ case StylePolyParabel:
+ if (depth>1)
+ return StyleParabel;
+ else
+ return ls;
+ break;
+ default:
+ break;
+ }
+ return StyleUndef;
+}
+
+void LinkableMapObj::setLinkStyle(LinkStyle newstyle)
+{
+ delLink();
+
+ style=newstyle;
+
+ if (childObj!=NULL && parObj != NULL)
+ {
+ int i;
+ QCanvasLine* cl;
+ switch (style)
+ {
+ case StyleUndef:
+ bottomline->hide();
+ break;
+ case StyleLine:
+ l = new QCanvasLine(canvas);
+ l->setPen( QPen(linkcolor, 1) );
+ l->setZ(Z_LINK);
+ if (visible)
+ l->show();
+ else
+ l->hide();
+ break;
+ case StyleParabel:
+ for (i=0;isetPen( QPen(linkcolor, 1) );
+ cl->setPoints( 0,0,i*10,100);
+ cl->setZ(Z_LINK);
+ if (visible)
+ cl->show();
+ else
+ cl->hide();
+ segment.append(cl);
+ }
+ pa0.resize (arcsegs+1);
+ break;
+ case StylePolyLine:
+ p = new QCanvasPolygon(canvas);
+ p->setBrush( linkcolor );
+ p->setZ(Z_LINK);
+ if (visible)
+ p->show();
+ else
+ p->hide();
+ pa0.resize (3);
+ // TODO
+ // a bit awkward: draw the lines additionally to polygon, to avoid
+ // missing pixels, when polygon is extremly flat
+ l = new QCanvasLine(canvas);
+ l->setPen( QPen(linkcolor, 1) );
+ l->setZ(Z_LINK);
+ if (visible)
+ l->show();
+ else
+ l->hide();
+ break;
+ case StylePolyParabel:
+ p = new QCanvasPolygon(canvas);
+ p->setBrush( linkcolor );
+ p->setZ(Z_LINK);
+ if (visible)
+ p->show();
+ else
+ p->hide();
+ pa0.resize (arcsegs*2+2);
+ pa1.resize (arcsegs+1);
+ pa2.resize (arcsegs+1);
+
+ // TODO
+ // a bit awkward: draw the lines additionally
+ // to polygon, to avoid missing pixels,
+ // if polygon is extremly flat
+ for (i=0;isetPen( QPen(linkcolor, 1) );
+ cl->setPoints( 0,0,i*10,100);
+ cl->setZ(Z_LINK);
+ if (visible)
+ cl->show();
+ else
+ cl->hide();
+ segment.append(cl);
+ }
+ break;
+ default:
+ break;
+ }
+ } else
+ {
+ cout << "Error: ChildObj or parObj == NULL in LinkableMapObj::setLinkStyle\n";
+ }
+}
+
+LinkStyle LinkableMapObj::getLinkStyle()
+{
+ return style;
+}
+
+void LinkableMapObj::setLinkPos(LinkPos lp)
+{
+ linkpos=lp;
+}
+
+LinkPos LinkableMapObj::getLinkPos()
+{
+ return linkpos;
+}
+
+
+void LinkableMapObj::setLinkColor()
+{
+ // Overloaded in BranchObj and childs
+ // here only set default color
+ setLinkColor (mapEditor->getDefLinkColor());
+}
+
+void LinkableMapObj::setLinkColor(QColor col)
+{
+ linkcolor=col;
+ bottomline->setPen( QPen(linkcolor, 1) );
+ QCanvasLine *cl;
+ switch (style)
+ {
+ case StyleLine:
+ l->setPen( QPen(col,1));
+ break;
+ case StyleParabel:
+ for (cl=segment.first(); cl; cl=segment.next() )
+ cl->setPen( QPen(col,1));
+ break;
+ case StylePolyLine:
+ p->setBrush( QBrush(col));
+ l->setPen( QPen(col,1));
+ break;
+ case StylePolyParabel:
+ p->setBrush( QBrush(col));
+ for (cl=segment.first(); cl; cl=segment.next() )
+ cl->setPen( QPen(col,1));
+ break;
+ default:
+ break;
+ } // switch (style)
+ updateLink();
+}
+
+QColor LinkableMapObj::getLinkColor()
+{
+ return linkcolor;
+}
+
+FrameType LinkableMapObj::getFrameType()
+{
+ return frame->getFrameType();
+}
+
+void LinkableMapObj::setFrameType(const FrameType &t)
+{
+ frame->setFrameType(t);
+ calcBBoxSize();
+ positionBBox();
+ requestReposition();
+}
+
+void LinkableMapObj::setFrameType(const QString &t)
+{
+ frame->setFrameType(t);
+ calcBBoxSize();
+ positionBBox();
+ requestReposition();
+}
+
+void LinkableMapObj::setVisibility (bool v)
+{
+ MapObj::setVisibility (v);
+ if (visible)
+ {
+ bottomline->show();
+ // FIXME lines and segments should be done in LMO?
+ if (style==StyleLine && l)
+ {
+ l->show();
+ } else
+ {
+ QCanvasLine* cl;
+ for (cl=segment.first(); cl; cl=segment.next() )
+ cl->show();
+ }
+ } else
+ {
+ bottomline->hide();
+ if (style==StyleLine && l)
+ {
+ l->hide();
+ } else
+ {
+ QCanvasLine* cl;
+ for (cl=segment.first(); cl; cl=segment.next() )
+ cl->hide();
+ }
+ }
+}
+
+void LinkableMapObj::updateLink()
+{
+ // needs:
+ // childPos of parent
+ // orient of parent
+ // style
+ //
+ // sets:
+ // orientation
+ // childPos
+ // parPos
+ // offset
+ // drawing of the link itself
+
+
+ // updateLink is called from move, but called from constructor we don't
+ // have parents yet...
+ if (style==StyleUndef) return;
+
+ if (frame->getFrameType() == NoFrame)
+ linkpos=LinkBottom;
+ else
+ linkpos=LinkMiddle;
+ switch (linkpos)
+ {
+ case LinkMiddle:
+ offset=bbox.height() /2;
+ break;
+ default :
+ offset=bbox.height()-1; // draw link to bottom of bbox
+ break;
+ }
+
+ double p2x,p2y; // Set P2 Before setting
+ if (!link2ParPos)
+ {
+ p2x=QPoint( parObj->getChildPos() ).x(); // P1, we have to look at
+ p2y=QPoint( parObj->getChildPos() ).y(); // orientation
+ } else
+ {
+ p2x=QPoint( parObj->getParPos() ).x();
+ p2y=QPoint( parObj->getParPos() ).y();
+ }
+
+ LinkOrient orientOld=orientation;
+
+ // Set orientation, first look for orientation of parent
+ if (parObj->getOrientation() != OrientUndef )
+ // use the orientation of the parent:
+ orientation=parObj->getOrientation();
+ else
+ {
+ // calc orientation depending on position rel to mapCenter
+ if (absPos.x() < QPoint(parObj->getChildPos() ).x() )
+ orientation=OrientLeftOfCenter;
+ else
+ orientation=OrientRightOfCenter;
+ }
+
+ if ((orientation!=orientOld) && (orientOld!= OrientUndef))
+ {
+ // Orientation just changed. Reorient this subbranch, because move is called
+ // before updateLink => Position is still the old one, which could lead to
+ // linking of subranch to itself => segfault
+ //
+ // Also possible: called in BranchObj::init(), then orientOld==OrientUndef,
+ // no need to reposition now
+ reposition();
+ }
+
+ if (orientation==OrientLeftOfCenter )
+ {
+ childPos=QPoint (absPos.x(),absPos.y()+offset);
+ parPos=QPoint (absPos.x()+ bbox.width(), absPos.y() + offset );
+ } else
+ {
+ childPos=QPoint (absPos.x()+ bbox.width(), absPos.y() + offset );
+ parPos=QPoint (absPos.x(),absPos.y()+offset);
+ }
+ /* FIXME
+ cout << " LMO::updateLink absPos="<setPoints( lrint (parPos.x()),
+ lrint(parPos.y()),
+ lrint(p2x),
+ lrint(p2y) );
+ break;
+ case StyleParabel:
+ parabel (pa0, p1x,p1y,p2x,p2y);
+ i=0;
+ for (cl=segment.first(); cl; cl=segment.next() )
+ {
+ cl->setPoints( pa0.point(i).x(), pa0.point(i).y(),pa0.point(i+1).x(),pa0.point(i+1).y());
+ i++;
+ }
+ break;
+ case StylePolyLine:
+ pa0[0]=QPoint (lrint(p2x+tp.x()), lrint(p2y+tp.y()));
+ pa0[1]=QPoint (lrint(p2x-tp.x()), lrint(p2y-tp.y()));
+ pa0[2]=QPoint (lrint (parPos.x()), lrint(parPos.y()) );
+ p->setPoints (pa0);
+ // here too, draw line to avoid missing pixels
+ l->setPoints( lrint (parPos.x()),
+ lrint(parPos.y()),
+ lrint(p2x),
+ lrint(p2y) );
+ break;
+ case StylePolyParabel:
+ parabel (pa1, p1x,p1y,p2x+tp.x(),p2y+tp.y());
+ parabel (pa2, p1x,p1y,p2x-tp.x(),p2y-tp.y());
+ for (i=0;i<=arcsegs;i++)
+ {
+ // Combine the arrays to a single one
+ pa0[i]=pa1[i];
+ pa0[i+arcsegs+1]=pa2[arcsegs-i];
+ }
+ p->setPoints (pa0);
+ i=0;
+ for (cl=segment.first(); cl; cl=segment.next() )
+ {
+ cl->setPoints( pa1.point(i).x(), pa1.point(i).y(),pa1.point(i+1).x(),pa1.point(i+1).y());
+ i++;
+ }
+ break;
+ default:
+ break;
+ } // switch (style)
+}
+
+LinkableMapObj* LinkableMapObj::getChildObj()
+{
+ return childObj;
+}
+
+LinkableMapObj* LinkableMapObj::getParObj()
+{
+ return parObj;
+}
+
+QPoint LinkableMapObj::getChildPos()
+{
+ return childPos;
+}
+
+QPoint LinkableMapObj::getParPos()
+{
+ return parPos;
+}
+
+QPoint LinkableMapObj::getRelPos()
+{
+ if (!parObj) return QPoint (0,0);
+ return QPoint(
+ absPos.x() - parObj->x(),
+ absPos.y() - parObj->y()
+ );
+}
+
+LinkOrient LinkableMapObj::getOrientation()
+{
+ return orientation;
+}
+
+int LinkableMapObj::getDepth()
+{
+ return depth;
+}
+
+void LinkableMapObj::setMapEditor (MapEditor *me)
+{
+ mapEditor=me;
+}
+
+MapEditor* LinkableMapObj::getMapEditor ()
+{
+ return mapEditor;
+}
+
+QPoint LinkableMapObj::getRandPos()
+{
+ // Choose a random position with given distance to parent:
+ double a=rand()%360 * 2 * M_PI / 360;
+ return QPoint ( (int)( + 150*cos (a)),
+ (int)( + 150*sin (a)));
+}
+
+void LinkableMapObj::alignRelativeTo (QPoint ref)
+{
+}
+
+void LinkableMapObj::reposition()
+{
+cout << "LMO::reposition ???"<requestReposition();
+ }
+}
+
+void LinkableMapObj::forceReposition()
+{
+ // Sometimes a reposition has to be done immediatly: For example
+ // if the note editor flag changes, there is no user event in mapeditor
+ // which could collect requests for a reposition.
+ // Then we have to call forceReposition()
+ // But no rule without exception: While loading a map or undoing it,
+ // we want to block expensive repositioning, but just do it once at
+ // the end, thus check first:
+
+ if (mapEditor->blockReposition()) return;
+
+ // Pass on the request to parental objects, if this hasn't been done yet
+
+ if (parObj)
+ parObj->forceReposition();
+ else
+ reposition(); }
+
+bool LinkableMapObj::repositionRequested()
+{
+ return repositionRequest;
+}
+
+
+void LinkableMapObj::setSelBox()
+{
+ selbox->setX (bbox.x() );
+ selbox->setY (bbox.y() );
+ selbox->setSize (bbox.width(), bbox.height() );
+}
+
+void LinkableMapObj::select()
+{
+ setSelBox();
+ selected=true;
+ selbox->show();
+}
+
+
+void LinkableMapObj::unselect()
+{
+ selected=false;
+ selbox->hide();
+}
+
+void LinkableMapObj::parabel (QPointArray &ya, double p1x, double p1y, double p2x, double p2y)
+
+{
+ double vx=p2x - p1x; // V=P2-P1
+ double vy=p2y - p1y;
+
+ double dx; // delta x during calculation of parabel
+
+ double pnx; // next point
+ double pny;
+ double m;
+
+ if (vx > -0.0001 && vx < 0.0001)
+ m=0;
+ else
+ m=(vy / (vx*vx));
+ dx=vx/(arcsegs);
+ int i;
+ ya.setPoint (0,QPoint (lrint(p1x),lrint(p1y)));
+ for (i=1;i<=arcsegs;i++)
+ {
+ pnx=p1x+dx;
+ pny=m*(pnx-parPos.x())*(pnx-parPos.x())+parPos.y();
+ ya.setPoint (i,QPoint (lrint(pnx),lrint(pny)));
+ p1x=pnx;
+ p1y=pny;
+ }
+}
+
diff -r 000000000000 -r 7a96bd401351 linkablemapobj.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/linkablemapobj.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,113 @@
+#ifndef LINKABLEMAPOBJ_H
+#define LINKABLEMAPOBJ_H
+
+#include "frameobj.h"
+#include "noteobj.h"
+#include "headingobj.h"
+#include "flagrowobj.h"
+
+#define MAX_DEPTH 999
+
+enum LinkOrient {OrientUndef,OrientLeftOfCenter, OrientRightOfCenter};
+enum LinkStyle {
+ StyleUndef,
+ StyleLine,
+ StyleParabel,
+ StylePolyLine,
+ StylePolyParabel
+};
+enum LinkPos {LinkMiddle,LinkBottom};
+enum LinkColorHint {DefaultColor,HeadingColor};
+
+class LinkableMapObj:public QObject, public MapObj {
+ Q_OBJECT
+public:
+ LinkableMapObj ();
+ LinkableMapObj (QCanvas*);
+ LinkableMapObj (LinkableMapObj*);
+ ~LinkableMapObj ();
+ virtual void delLink();
+ virtual void init ();
+ virtual void copy (LinkableMapObj*);
+ void setChildObj (LinkableMapObj*);
+ virtual void setParObj (LinkableMapObj*);
+ virtual void setParObjTmp (LinkableMapObj*,QPoint,int); // Only for moving Obj around
+ virtual void unsetParObjTmp(); // reuse original ParObj
+ LinkStyle getDefLinkStyle();
+ void setLinkStyle(LinkStyle);
+ LinkStyle getLinkStyle();
+ void setLinkPos (LinkPos);
+ LinkPos getLinkPos ();
+
+ virtual void setLinkColor(); // sets color according to colorhint, overloaded
+ virtual void setLinkColor(QColor);
+ QColor getLinkColor();
+ virtual FrameType getFrameType ();
+ virtual void setFrameType (const FrameType &);
+ virtual void setFrameType (const QString &);
+ virtual void setVisibility (bool);
+ virtual void updateLink(); // update parPos and childPos
+ // depending on pos
+ // redraw link with given style
+ LinkableMapObj* getChildObj(); // returns pointer to fromObj
+ LinkableMapObj* getParObj(); // returns pointer to toObj
+ QPoint getChildPos(); // returns pos where childs dock
+ QPoint getParPos(); // returns pos where parents dock
+ QPoint getRelPos(); // get position relative to parent (or (0,0))
+ LinkOrient getOrientation(); // get orientation
+ virtual int getDepth(); // return depth
+ virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag)
+ virtual MapEditor* getMapEditor(); // get MapEditor (usually from parent);
+ virtual QPoint getRandPos(); // make randomised position
+
+ virtual void alignRelativeTo(const QPoint );
+ virtual void reposition();
+ virtual void requestReposition(); // do reposition after next user event
+ virtual void forceReposition(); // to force a reposition now (outside
+ // of mapeditor e.g. in noteeditor
+ virtual bool repositionRequested();
+
+ virtual QRect getTotalBBox()=0; // return BBox including childs
+ virtual QRect getBBoxSizeWithChilds()=0;// return size of BBox including childs
+ virtual void calcBBoxSizeWithChilds()=0;// calc size of BBox including childs recursivly
+
+ virtual void setSelBox();
+ virtual void select();
+ virtual void unselect();
+ virtual QString getSelectString()=0;
+
+protected:
+ void parabel(QPointArray &,double,double,double,double); // Create Parabel connecting two points
+ QPoint childPos;
+ QPoint parPos;
+ bool link2ParPos; // While moving around, sometimes link to parent
+ MapEditor* mapEditor; // for updateNoteFlag() and toggleScroll()
+ LinkOrient orientation;
+ int linkwidth; // width of a link
+ int depth; // depth: undef=-1 mapCenter=0 branch=1..n
+ QRect bboxTotal; // bounding box including childs
+
+ LinkableMapObj* childObj;
+ LinkableMapObj* parObj;
+ LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent
+ int offset; // vertical offset of dockpos to pos
+
+ int thickness_start; // for StylePoly*
+ LinkStyle style;
+ LinkPos linkpos;
+ QColor linkcolor; // Link color
+ QCanvasLine* l; // line style
+ QCanvasPolygon* p; // poly styles
+ int arcsegs; // arc: number of segments
+ QPtrList segment; // a part of e.g. the parabel
+ QPointArray pa0; // For drawing of PolyParabel and PolyLine
+ QPointArray pa1; // For drawing of PolyParabel
+ QPointArray pa2; // For drawing of PolyParabel
+ QCanvasLine* bottomline; // on bottom of BBox
+ bool repositionRequest; //
+
+ bool selected; // Used for marking the selection
+ QCanvasRectangle* selbox;
+ FrameObj *frame; // frame around object
+};
+#endif
diff -r 000000000000 -r 7a96bd401351 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,177 @@
+#include
+#include
+#include
+
+#include "settings.h"
+#include "options.h"
+#include "mainwindow.h"
+
+#include "icons/vym-48x48.xpm"
+#include "icons/vym-editor.xpm"
+
+#include "flagrowobj.h"
+
+// Global variables
+TextEditor *textEditor; // used in Constr. of LinkableMapObj
+ // initialized in mainwindow
+
+Main *mainWindow; // used in BranchObj::select()
+MapEditor *clipboardME;
+FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
+FlagRowObj *standardFlagsDefault;
+
+// Actions which change sometimes
+QAction *actionFileSave;
+QAction *actionFilePrint;
+QAction *actionEditUndo;
+QAction *actionEditCopy;
+QAction *actionEditCut;
+QAction *actionEditPaste;
+QAction *actionEditMoveUp;
+QAction *actionEditMoveDown;
+QAction *actionEditToggleScroll;
+QAction *actionEditOpenURL;
+QAction *actionEditURL;
+QAction *actionEditHeading2URL;
+QAction *actionEditBugzilla2URL;
+QAction *actionEditOpenVymLink;
+QAction *actionEditVymLink;
+QAction *actionEditDeleteVymLink;
+QAction *actionEditMapInfo;
+QAction *actionEditHeading;
+QAction *actionEditDelete;
+QAction *actionEditAddBranch;
+QAction *actionEditAddBranchAbove;
+QAction *actionEditAddBranchBelow;
+QAction *actionEditImportAdd;
+QAction *actionEditImportReplace;
+QAction *actionEditSaveBranch;
+QAction *actionEditSelectFirst;
+QAction *actionEditSelectLast;
+QAction *actionEditLoadImage;
+QAction *actionEditToggleFloatExport;
+
+QAction *actionFormatColor;
+QAction *actionFormatPickColor;
+QAction *actionFormatColorBranch;
+QAction *actionFormatColorSubtree;
+QAction *actionFormatBackColor;
+QAction *actionFormatLinkColorHint;
+QAction *actionFormatLinkColor;
+
+QActionGroup *actionGroupFormatFrameTypes;
+QAction *actionFormatFrameNone;
+QAction *actionFormatFrameRectangle;
+
+QActionGroup *actionGroupFormatLinkStyles;
+QAction *actionFormatLinkStyleLine;
+QAction *actionFormatLinkStyleParabel;
+QAction *actionFormatLinkStylePolyLine;
+QAction *actionFormatLinkStylePolyParabel;
+
+QAction *actionViewToggleNoteEditor;
+
+QAction *actionSettingsAutoselectHeading;
+QAction *actionSettingsAutoselectText;
+QAction *actionSettingsPasteNewHeading;
+QAction *actionSettingsAutoedit;
+QAction *actionSettingsUseDelKey;
+
+QPopupMenu *branchContextMenu;
+QPopupMenu *floatimageContextMenu;
+QPopupMenu *saveImageFormatMenu;
+QPopupMenu *canvasContextMenu;
+QPopupMenu *lastMapsMenu;
+QPopupMenu *exportMenu;
+QPopupMenu *exportImageFormatMenu;
+
+
+Settings settings;
+Options options;
+
+int statusbarTime=3500;
+
+int main(int argc, char** argv)
+{
+ QApplication app(argc,argv);
+
+
+ // Initialize translations
+ QTranslator translator (0);
+ translator.load( "vym_de", "." );
+ app.installTranslator( &translator );
+
+ // Initializing the row of system flags
+ // is done in first call to MapEditor(),
+ // because we need at least one canvas first
+ systemFlagsDefault=NULL;
+ standardFlagsDefault=NULL;
+
+ // Reading and initializing options commandline options
+ options.add ("version", SwitchOption, "v","version");
+ options.add ("help", SwitchOption, "h", "help");
+ options.add ("quit", SwitchOption, "q", "quit");
+ options.add ("test", StringOption, "t", "test");
+ options.setHelpText (
+ "VYM - View Your Mind\n"
+ "--------------------\n\n"
+ "Information about vym can be found in vym.pdf,\n"
+ "which should be part of the vym package.\n"
+ "It is also available at the project homepage:\n\n"
+ "http://www.InSilmaril.de/vym\n");
+ if (options.parse())
+ {
+ cout << endl << options.getHelpText()<setIcon (QPixmap (vym_editor_xpm));
+ if (textEditor->showWithMain()) textEditor->show();
+
+ clipboardME = new MapEditor();
+ clipboardME->resize (800,600);
+ clipboardME->setCaption("VYM - clipboard");
+ clipboardME->hide();
+
+ // Initialize mainwindow after Mapeditors (because of Flags)
+ Main m;
+ //m.resize(m.sizeHint());
+ m.setIcon (QPixmap (vym_logo_xpm));
+ m.show();
+ m.fileNew();
+ m.loadCmdLine();
+
+ // For benchmarking we may want to quit immediatly after drawing
+ if (options.isOn ("quit"))
+ {
+ return 0;
+ }
+
+ QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
+
+ return app.exec();
+}
+
diff -r 000000000000 -r 7a96bd401351 mainwindow.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mainwindow.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,2213 @@
+#include "mainwindow.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+#include
+#include
+#include
+
+#include "version.h"
+
+#include "icons/filenew.xpm"
+#include "icons/fileopen.xpm"
+#include "icons/filesave.xpm"
+#include "icons/fileprint.xpm"
+#include "icons/editundo.xpm"
+//#include "icons/editredo.xpm" // TODO
+#include "icons/editcopy.xpm"
+#include "icons/editcut.xpm"
+#include "icons/editpaste.xpm"
+#include "icons/editmoveup.xpm"
+#include "icons/editmovedown.xpm"
+#include "icons/formatcoloritem.xpm"
+#include "icons/formatcolorbranch.xpm"
+#include "icons/formatcolorpicker.xpm"
+#include "icons/viewzoomreset.xpm"
+#include "icons/viewzoomin.xpm"
+#include "icons/viewzoomout.xpm"
+#include "icons/vym-48x48.xpm"
+#include "icons/flag-note.xpm"
+#include "icons/flag-url.xpm"
+#include "icons/flag-vymlink.xpm"
+#include "icons/flag-scrolled-right.xpm"
+
+#include "flagrowobj.h"
+#include "texteditor.h"
+#include "mapeditor.h"
+#include "exporthtmldialog.h"
+#include "exportxhtmldialog.h"
+#include "showtextdialog.h"
+#include "process.h"
+#include "settings.h"
+#include "options.h"
+
+extern TextEditor *textEditor;
+extern Main *mainWindow;
+extern int statusbarTime;
+extern MapEditor *clipboardME;
+extern FlagRowObj* standardFlagsDefault;
+
+extern QAction* actionFileSave;
+extern QAction* actionFilePrint;
+extern QAction* actionEditUndo;
+extern QAction *actionEditCopy;
+extern QAction *actionEditCut;
+extern QAction *actionEditPaste;
+extern QAction *actionEditMoveUp;
+extern QAction *actionEditMoveDown;
+extern QAction *actionEditToggleScroll;
+extern QAction* actionEditOpenURL;
+extern QAction* actionEditURL;
+extern QAction* actionEditHeading2URL;
+extern QAction* actionEditBugzilla2URL;
+extern QAction *actionEditOpenVymLink;
+extern QAction *actionEditVymLink;
+extern QAction *actionEditDeleteVymLink;
+extern QAction *actionEditMapInfo;
+extern QAction *actionEditHeading;
+extern QAction *actionEditDelete;
+extern QAction *actionEditAddBranch;
+extern QAction *actionEditAddBranchAbove;
+extern QAction *actionEditAddBranchBelow;
+extern QAction *actionEditImportAdd;
+extern QAction *actionEditImportReplace;
+extern QAction *actionEditSaveBranch;
+extern QAction *actionEditSelectFirst;
+extern QAction *actionEditSelectLast;
+extern QAction *actionEditLoadImage;
+extern QAction *actionEditToggleFloatExport;
+
+extern QAction* actionFormatColor;
+extern QAction* actionFormatPickColor;
+extern QAction* actionFormatColorBranch;
+extern QAction* actionFormatColorSubtree;
+extern QAction* actionFormatLinkColorHint;
+extern QAction* actionFormatBackColor;
+extern QAction* actionFormatLinkColor;
+
+extern QActionGroup *actionGroupFormatFrameTypes;
+extern QAction *actionFormatFrameNone;
+extern QAction *actionFormatFrameRectangle;
+
+extern QActionGroup *actionGroupFormatLinkStyles;
+extern QAction *actionFormatLinkStyleLine;
+extern QAction *actionFormatLinkStyleParabel;
+extern QAction *actionFormatLinkStylePolyLine;
+extern QAction *actionFormatLinkStylePolyParabel;
+
+extern QAction *actionViewToggleNoteEditor;
+
+extern QAction* actionSettingsAutoedit;
+extern QAction* actionSettingsAutoselectHeading;
+extern QAction* actionSettingsAutoselectHeading;
+extern QAction* actionSettingsAutoselectText;
+extern QAction* actionSettingsPasteNewHeading;
+extern QAction* actionSettingsUseDelKey;
+
+extern QPopupMenu* branchContextMenu;
+extern QPopupMenu* floatimageContextMenu;
+extern QPopupMenu* saveImageFormatMenu;
+extern QPopupMenu* canvasContextMenu;
+extern QPopupMenu* lastMapsMenu;
+extern QPopupMenu* exportMenu;
+extern QPopupMenu* exportImageFormatMenu;
+
+
+extern Settings settings;
+extern Options options;
+
+#if defined(Q_OS_LINUX)
+extern void qt_wait_for_window_manager( QWidget* w );
+#endif
+
+Main::Main(QWidget* parent, const char* name, WFlags f) :
+ QMainWindow(parent,name,f)
+{
+ mainWindow=this;
+
+ setCaption ("VYM - View Your Mind");
+
+ // Load window settings
+ resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
+ settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
+ move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
+ settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
+
+
+ // Initialize some settings, which are platform dependant
+ QString p,s;
+
+ // application to open URLs
+ p="/vym/mainwindow/readerURL";
+ #if defined(Q_OS_LINUX)
+ s=settings.readEntry (p,"konqueror");
+ #else
+ #if defined(Q_OS_MACX)
+ s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
+ #else
+ s=settings.readEntry (p,"mozilla");
+ #endif
+ #endif
+ settings.writeEntry( p,s);
+
+ // application to open PDFs
+ p="/vym/mainwindow/readerPDF";
+ #if defined(Q_OS_LINUX)
+ s=settings.readEntry (p,"acroread");
+ #else
+ #if defined(Q_OS_MACX)
+ s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
+ #else
+ s=settings.readEntry (p,"acroread");
+ #endif
+ #endif
+ settings.writeEntry( p,s);
+
+
+ maxLastMaps=9;
+
+ // Create tab widget which holds the maps
+ tabWidget= new QTabWidget (this);
+ connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
+ this, SLOT( editorChanged( QWidget * ) ) );
+
+ setCentralWidget(tabWidget);
+
+ setupFileActions();
+ setupEditActions();
+ setupFormatActions();
+ setupViewActions();
+ setupFlagActions();
+ setupSettingsActions();
+ setupContextMenus();
+ if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
+ setupHelpActions();
+
+ // After menu is created, we can enable some actions
+ actionFilePrint->setEnabled (true);
+
+ statusBar();
+
+ // Create the default map into first tab
+// fileNew();
+// tabWidget->addTab (new MapEditor(tabWidget,true), "unnamed");
+// currentMapEditor()->show();
+
+ // Initialize Find window
+ findWindow=new FindWindow(NULL,"findwindow");
+ connect (findWindow, SIGNAL( findButton(QString) ),
+ this, SLOT(editFind(QString) ) );
+ connect (findWindow, SIGNAL( somethingChanged() ),
+ this, SLOT(editFindChanged() ) );
+
+ updateGeometry();
+}
+
+Main::~Main()
+{
+ // Save Settings
+ settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
+ settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
+ settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
+ settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
+
+ settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
+ settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
+
+ settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
+ settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
+ settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
+ settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
+ settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
+
+ QString s;
+ int maps=lastMaps.count();
+ settings.writeEntry( "/vym/lastMaps/number",maps );
+ for (int i=1;i<=maps;i++)
+ {
+ QStringList::Iterator it = lastMaps.at(i-1);
+ s=QString("/vym/lastMaps/map-%1").arg(i);
+ if (!s.isEmpty() && i<=maxLastMaps)
+ settings.writeEntry (s, *it);
+ }
+
+
+ // To make the texteditor save its settings, call the destructor
+ delete (textEditor);
+}
+
+void Main::loadCmdLine()
+{
+ /* TODO draw some kind of splashscreen while loading...
+ if (qApp->argc()>1)
+ {
+ }
+ */
+
+ QStringList flist=options.getFileList();
+ QStringList::Iterator it=flist.begin();
+
+ while (it !=flist.end() )
+ {
+ fileLoad (*it, NewMap);
+ *it++;
+ }
+}
+
+
+void Main::statusMessage(const QString &s)
+{
+ statusBar()->message (s);
+}
+
+void Main::closeEvent (QCloseEvent* )
+{
+ fileExitVYM();
+}
+
+// File Actions
+void Main::setupFileActions()
+{
+ QToolBar *tb = new QToolBar( this );
+ tb->setLabel( "File Actions" );
+ QPopupMenu *menu = new QPopupMenu( this );
+ menuBar()->insertItem( tr( "&File" ), menu );
+
+ // Keycodes: /usr/lib64/qt3/include/qnamespace.h
+
+ QAction *a;
+ a = new QAction( tr( "New map" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
+ a->addTo( tb );
+ a->addTo( menu );
+
+ a = new QAction( tr( "Open" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
+ a->addTo( tb );
+ a->addTo( menu );
+
+ lastMapsMenu = new QPopupMenu (this);
+
+ menu->insertItem (tr("Open Recent"),lastMapsMenu );
+ menu->insertSeparator();
+
+ a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
+ a->addTo( tb );
+ a->addTo( menu );
+ actionFileSave=a;
+
+ a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
+ a->addTo( menu );
+
+ menu->insertSeparator();
+
+ a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir" ), 0, this, "export" );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
+ a->addTo( menu );
+
+ exportMenu = new QPopupMenu (this);
+ menu->insertItem (tr("Export"),exportMenu );
+
+ menu->insertSeparator();
+
+
+ a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
+ connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
+ a->addTo( tb );
+ a->addTo( menu );
+ actionFilePrint=a;
+
+ a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
+ a->addTo( menu );
+
+ a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
+ a->addTo( menu );
+}
+
+
+//Edit Actions
+void Main::setupEditActions()
+{
+ QToolBar *tb = new QToolBar( this );
+ tb->setLabel( "Edit Actions" );
+ QPopupMenu *menu = new QPopupMenu( this );
+ menuBar()->insertItem( tr( "&Edit" ), menu );
+
+ QAction *a;
+ a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
+ a->setEnabled (false);
+ a->addTo( tb );
+ a->addTo( menu );
+ actionEditUndo=a;
+ /*
+ a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
+ a->addTo( tb );
+ a->addTo( menu );
+ */
+ menu->insertSeparator();
+ a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
+ a->setEnabled (false);
+ a->addTo( tb );
+ a->addTo( menu );
+ actionEditCopy=a;
+ a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
+ a->setEnabled (false);
+ a->addTo( tb );
+ a->addTo( menu );
+ actionEditCut=a;
+ a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
+ a->setEnabled (false);
+ a->addTo( tb );
+ a->addTo( menu );
+ actionEditPaste=a;
+ a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
+ a->setEnabled (false);
+ a->addTo( tb );
+ a->addTo( menu );
+ actionEditMoveUp=a;
+ a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
+ a->setEnabled (false);
+ a->addTo( tb );
+ a->addTo( menu );
+ actionEditMoveDown=a;
+
+ a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
+ a->setEnabled (false);
+ a->addTo( tb );
+ a->addTo( menu );
+ actionEditToggleScroll=a;
+
+ a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
+ a->addTo( menu );
+
+ menu->insertSeparator();
+
+ a = new QAction( tr( "Find" ), QPixmap(), tr( "Find" ), CTRL + Key_F, this, "find" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
+ a->addTo( menu );
+
+ menu->insertSeparator();
+
+ a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
+ a->addTo( menu );
+ a->addTo( tb );
+ a->setEnabled (false);
+ actionEditOpenURL=a;
+
+ a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL" ), SHIFT + CTRL + Key_U, this, "url" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
+ a->addTo( menu );
+ a->setEnabled (false);
+ actionEditURL=a;
+
+ a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
+ a->addTo( menu );
+ a->setEnabled (false);
+ actionEditHeading2URL=a;
+
+ a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
+ a->setEnabled (false);
+ actionEditBugzilla2URL=a;
+
+ menu->insertSeparator();
+
+ a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flag_vymlink_xpm), tr( "Jump to map" ), 0, this, "jumpMap" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
+ a->addTo( menu );
+ a->addTo( tb );
+ a->setEnabled (false);
+ actionEditOpenVymLink=a;
+
+ a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link" ), 0, this, "editLinkMap" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
+ a->addTo( menu );
+ a->setEnabled (false);
+ actionEditVymLink=a;
+
+ a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
+ a->addTo( menu );
+ a->setEnabled (false);
+ actionEditDeleteVymLink=a;
+
+ menu->insertSeparator();
+
+ a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info" ), 0, this, "editMapInfo" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
+ a->addTo( menu );
+ a->setEnabled (true);
+ actionEditMapInfo=a;
+
+ menu->insertSeparator();
+
+ // Shortcuts to modify heading:
+ a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
+ a->setEnabled (false);
+ a->addTo ( menu );
+ actionEditHeading=a;
+ a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
+ //a->addTo ( menu );
+
+ // Shortcut to delete selection
+ a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
+ a->setEnabled (false);
+ a->addTo ( menu );
+ actionEditDelete=a;
+
+ // Shortcut to add branch
+ #if defined (Q_OS_MACX)
+ a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), CTRL + Key_I, this, "newBranch" );
+ #else
+ a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
+ #endif
+ connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
+ a->setEnabled (false);
+ a->addTo ( menu );
+ actionEditAddBranch=a;
+
+ // Add branch above
+ a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
+ a->setEnabled (false);
+ a->addTo ( menu );
+ actionEditAddBranchAbove=a;
+
+ // Add branch below
+ a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
+ a->setEnabled (false);
+ a->addTo ( menu );
+ actionEditAddBranchBelow=a;
+
+ // Import at selection (adding to selection)
+ a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
+ a->setEnabled (false);
+ a->addTo ( menu );
+ actionEditImportAdd=a;
+
+ // Import at selection (replacing selection)
+ a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
+ a->setEnabled (false);
+ a->addTo ( menu );
+ actionEditImportReplace=a;
+
+ // Save selection
+ a = new QAction( tr( "Save selction" ),tr( "Save selection" ), 0, this, "saveSelection" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
+ a->setEnabled (false);
+ a->addTo ( menu );
+ actionEditSaveBranch=a;
+
+ // Shortcuts for navigating with cursor:
+ a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
+ a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
+ a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
+ a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
+ a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
+ a->setEnabled (false);
+ a->addTo ( menu );
+ actionEditSelectFirst=a;
+ connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
+ a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
+ a->setEnabled (false);
+ a->addTo ( menu );
+ actionEditSelectLast=a;
+
+ a = new QAction( tr( "Add Image" ),tr( "Add Image" ), 0, this, "loadImage" );
+ connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
+ actionEditLoadImage=a;
+}
+
+// Format Actions
+void Main::setupFormatActions()
+{
+ QPopupMenu *menu = new QPopupMenu( this );
+ menuBar()->insertItem( tr( "&Format" ), menu );
+
+ QToolBar *tb = new QToolBar( this );
+ QAction *a;
+ QPixmap pix( 16,16);
+ pix.fill (black);
+ actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" ), 0, this, "formatColor" );
+ connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
+ actionFormatColor->addTo( tb );
+ actionFormatColor->addTo( menu );
+ a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(formatcolorpicker_xpm), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" );
+ connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
+ a->setEnabled (false);
+ a->addTo( tb );
+ a->addTo( menu );
+ actionFormatPickColor=a;
+ a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
+ connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
+ a->setEnabled (false);
+ a->addTo( tb );
+ a->addTo( menu );
+ actionFormatColorBranch=a;
+ a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
+ connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
+ a->setEnabled (false);
+ a->addTo( menu );
+ a->addTo( tb );
+ actionFormatColorSubtree=a;
+
+ menu->insertSeparator();
+ actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
+ actionGroupFormatLinkStyles->setExclusive (true);
+ a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
+ a->setToggleAction(true);
+ connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
+ actionFormatLinkStyleLine=a;
+ a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
+ a->setToggleAction(true);
+ connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
+ actionFormatLinkStyleParabel=a;
+ a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
+ a->setToggleAction(true);
+ connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
+ actionFormatLinkStylePolyLine=a;
+ a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
+ a->setToggleAction(true);
+ connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
+ actionFormatLinkStylePolyParabel=a;
+ actionGroupFormatLinkStyles->addTo (menu);
+
+ actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
+ actionGroupFormatFrameTypes->setExclusive (true);
+ a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
+ a->setToggleAction(true);
+ connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
+ actionFormatFrameNone=a;
+ a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
+ a->setToggleAction(true);
+ connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
+ actionFormatFrameRectangle=a;
+
+ menu->insertSeparator();
+ a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
+ a->setToggleAction(true);
+ connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
+ a->addTo( menu );
+ actionFormatLinkColorHint=a;
+ pix.fill (white);
+ actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color" ), 0, this, "formatLinkColor" );
+ connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
+ actionFormatLinkColor->addTo( menu );
+ actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" ), 0, this, "formatBackColor" );
+ connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
+ actionFormatBackColor->addTo( menu );
+}
+
+// View Actions
+void Main::setupViewActions()
+{
+ QToolBar *tb = new QToolBar( this );
+ tb->setLabel( "View Actions" );
+ QPopupMenu *menu = new QPopupMenu( this );
+ menuBar()->insertItem( tr( "&View" ), menu );
+
+ QAction *a;
+ a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), 0, this, "zoomReset" );
+ connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
+ a->addTo( tb );
+ a->addTo( menu );
+ a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
+ connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
+ a->addTo( tb );
+ a->addTo( menu );
+ a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
+ connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
+ a->addTo( tb );
+ a->addTo( menu );
+ a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
+ connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
+ a->setToggleAction(true);
+ if (textEditor->showWithMain())
+ a->setOn(true);
+ else
+ a->setOn(false);
+ a->addTo( tb );
+ a->addTo( menu );
+ actionViewToggleNoteEditor=a;
+ a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
+ connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
+ a->addTo( menu );
+ a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
+ connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
+ a->addTo( menu );
+}
+
+// Flag Actions
+void Main::setupFlagActions()
+{
+ standardFlagsDefault->makeToolbar(this, "Standard Flags");
+}
+
+// Settings Actions
+void Main::setupSettingsActions()
+{
+ QPopupMenu *menu = new QPopupMenu( this );
+ menuBar()->insertItem( tr( "&Settings" ), menu );
+
+ QAction *a;
+
+
+ a = new QAction( tr( "Set application to open pdf files" ), QPixmap(), tr( "Set application to open pdf files" ), 0, this, "setPDF" );
+ connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
+ a->addTo( menu );
+
+ a = new QAction( tr( "Set application to open an URL" ), QPixmap(), tr( "Set application to open an URL" ), 0, this, "setURL" );
+ connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
+ a->addTo( menu );
+
+ menu->insertSeparator();
+ a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
+ a->setToggleAction(true);
+ a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
+ a->addTo( menu );
+ actionSettingsAutoedit=a;
+
+ a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
+ a->setToggleAction(true);
+ a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
+ a->addTo( menu );
+ actionSettingsAutoselectHeading=a;
+
+ a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
+ a->setToggleAction(true);
+ a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
+ a->addTo( menu );
+ actionSettingsAutoselectText=a;
+
+ a= new QAction( tr( "Enable pasting into new branch" ), QPixmap(), tr( "Enable pasting into new branch" ), 0, this, "pastenewheading" );
+ a->setToggleAction(true);
+ a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
+ a->addTo( menu );
+ actionSettingsPasteNewHeading=a;
+
+ a= new QAction( tr( "Enable Delete key for deleting branches" ), QPixmap(), tr( "Enable Delete key" ), 0, this, "delkey" );
+ a->setToggleAction(true);
+ a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
+ a->addTo( menu );
+ actionSettingsUseDelKey=a;
+}
+
+// Test Actions
+void Main::setupTestActions()
+{
+ QPopupMenu *menu = new QPopupMenu( this );
+ menuBar()->insertItem( tr( "&Test" ), menu );
+
+ QAction *a;
+ a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
+ connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
+ a->addTo( menu );
+
+ a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" );
+ connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) );
+ a->addTo( menu );
+}
+
+// Help Actions
+void Main::setupHelpActions()
+{
+ QPopupMenu *menu = new QPopupMenu( this );
+ menuBar()->insertItem( tr( "&Help" ), menu );
+
+ QAction *a;
+ a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
+ connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
+ a->addTo( menu );
+
+ a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
+ connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
+ a->addTo( menu );
+
+ a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
+ connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
+ a->addTo( menu );
+}
+
+// Context Menus
+void Main::setupContextMenus()
+{
+ QAction*a;
+
+ // Context Menu for branch or mapcenter
+ branchContextMenu =new QPopupMenu (this);
+ actionEditAddBranch->addTo ( branchContextMenu );
+ actionEditAddBranchAbove->addTo ( branchContextMenu );
+ actionEditAddBranchBelow->addTo ( branchContextMenu );
+ actionEditSaveBranch->addTo( branchContextMenu );
+ branchContextMenu->insertSeparator();
+ actionEditImportAdd->addTo ( branchContextMenu );
+ actionEditImportReplace->addTo ( branchContextMenu );
+ branchContextMenu->insertSeparator();
+ actionEditOpenURL->addTo ( branchContextMenu );
+ actionEditURL->addTo ( branchContextMenu );
+ actionEditHeading2URL->addTo ( branchContextMenu );
+ if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
+ actionEditBugzilla2URL->addTo( branchContextMenu );
+ branchContextMenu->insertSeparator();
+ actionEditOpenVymLink->addTo ( branchContextMenu );
+ actionEditVymLink->addTo ( branchContextMenu );
+ actionEditDeleteVymLink->addTo ( branchContextMenu );
+ branchContextMenu->insertSeparator();
+ actionEditLoadImage->addTo( branchContextMenu );
+ branchContextMenu->insertSeparator();
+ actionEditCopy->addTo( branchContextMenu );
+ actionEditCut->addTo( branchContextMenu );
+ actionEditPaste->addTo( branchContextMenu );
+ branchContextMenu->insertSeparator();
+ actionGroupFormatFrameTypes->addTo( branchContextMenu );
+
+ // Context menu for floatimage
+ floatimageContextMenu =new QPopupMenu (this);
+ saveImageFormatMenu=new QPopupMenu (this);
+ exportImageFormatMenu=new QPopupMenu (this);
+
+ QStrList fmt = QImage::outputFormats();
+ for (const char* f = fmt.first(); f; f = fmt.next())
+ {
+ saveImageFormatMenu->insertItem( f );
+ exportImageFormatMenu->insertItem( f );
+ }
+ connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
+ connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
+ floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
+
+ floatimageContextMenu->insertSeparator();
+ actionEditCopy->addTo( floatimageContextMenu );
+ actionEditCut->addTo( floatimageContextMenu );
+
+ floatimageContextMenu->insertSeparator();
+ a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
+ a->setToggleAction(true);
+ connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
+ a->addTo( floatimageContextMenu);
+ actionEditToggleFloatExport=a;
+
+
+
+ // Context menu for exports
+ exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
+
+ a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" ), 0, this, "exportASCII" );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
+ a->addTo( exportMenu );
+
+ a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ), 0, this, "exportXML" );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
+ a->addTo( exportMenu );
+
+ if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
+ {
+ a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export HTML" ), 0, this, "exportHTML" );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
+ a->addTo( exportMenu );
+ }
+
+ a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" ), ALT + Key_X, this, "exportXHTML" );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
+ a->addTo( exportMenu );
+
+
+ // Context menu for canvas
+ canvasContextMenu =new QPopupMenu (this);
+ actionEditMapInfo->addTo( canvasContextMenu );
+ canvasContextMenu->insertSeparator();
+ actionGroupFormatLinkStyles->addTo( canvasContextMenu );
+ canvasContextMenu->insertSeparator();
+ actionFormatLinkColorHint->addTo( canvasContextMenu );
+ actionFormatLinkColor->addTo( canvasContextMenu );
+ actionFormatBackColor->addTo( canvasContextMenu );
+
+ // Menu for last opened files
+ // Read settings initially
+ QString s;
+ int j=settings.readNumEntry( "/vym/lastMaps/number",0);
+ for (int i=1;i<=j;i++)
+ {
+ s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
+ if (!s.isEmpty() && j<=maxLastMaps)
+ lastMaps.append(s);
+ }
+ setupLastMapsMenu();
+ connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
+}
+
+void Main::setupLastMapsMenu()
+{
+ // Remove double entries
+ QStringList::Iterator it=lastMaps.begin();
+ QStringList::Iterator jt;
+ while (it!=lastMaps.end() )
+ {
+ jt=it;
+ ++jt;
+ while (jt!=lastMaps.end() )
+ {
+ if (*it == *jt)
+ jt=lastMaps.remove(jt);
+ else
+ jt++;
+ }
+ it++;
+ }
+
+ // Limit length of list to maxLastMaps
+ while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
+
+ // build Menu from lastMaps string list
+ lastMapsMenu->clear();
+ for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
+ lastMapsMenu->insertItem (*it );
+
+}
+
+void Main::hideEvent (QHideEvent * )
+{
+ if (!textEditor->isMinimized() ) textEditor->hide();
+}
+
+void Main::showEvent (QShowEvent * )
+{
+ if (textEditor->showWithMain()) textEditor->show();
+}
+
+bool Main::reallyWriteDirectory(const QString &dir)
+{
+ QStringList eList = QDir(dir).entryList();
+ if (eList.first() ==".") eList.pop_front(); // remove "."
+ if (eList.first() =="..") eList.pop_front(); // remove "."
+ if (!eList.isEmpty())
+ {
+ QMessageBox mb( "VYM",
+ tr("The directory ") + dir +
+ tr(" is not empty. Do you risk to overwrite its contents?"),
+ QMessageBox::Warning,
+ QMessageBox::Yes ,
+ QMessageBox::Cancel | QMessageBox::Default,
+ QMessageBox::QMessageBox::NoButton );
+
+ mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
+ mb.setButtonText( QMessageBox::No, tr("Cancel"));
+ switch( mb.exec() )
+ {
+ case QMessageBox::Yes:
+ // save
+ return true;
+ case QMessageBox::Cancel:
+ // do nothing
+ return false;
+ }
+ }
+ return true;
+}
+
+QString Main::browseDirectory (const QString &caption)
+{
+ QFileDialog fd(this,caption);
+ fd.setMode (QFileDialog::DirectoryOnly);
+ fd.setCaption("VYM - "+caption);
+ fd.show();
+
+ if ( fd.exec() == QDialog::Accepted )
+ return fd.selectedFile();
+ else
+ return "";
+}
+
+MapEditor* Main::currentMapEditor() const
+{
+ if ( tabWidget->currentPage() &&
+ tabWidget->currentPage()->inherits( "MapEditor" ) )
+ return (MapEditor*)tabWidget->currentPage();
+ return NULL;
+}
+
+//TODO not used now, maybe use this for overview window later
+void Main::newView()
+{
+ // Open a new view... have it delete when closed.
+ Main *m = new Main(0, 0, WDestructiveClose);
+ qApp->setMainWidget(m);
+ m->show();
+ qApp->setMainWidget(0);
+}
+
+void Main::editorChanged(QWidget *)
+{
+ // Unselect all possibly selected objects
+ // (Important to update note editor)
+ int i;
+ MapEditor *me;
+ for (i=0;i<=tabWidget->count() -1;i++)
+ {
+
+ me=(MapEditor*)tabWidget->page(i);
+ me->unselect();
+ }
+ currentMapEditor()->reselect();
+
+ // Update actions to in menus and toolbars according to editor
+ currentMapEditor()->updateActions();
+}
+
+void Main::fileNew()
+{
+ QString fn="unnamed";
+ MapEditor* medit = new MapEditor (tabWidget, true);
+ tabWidget->addTab (medit,fn);
+ tabWidget->showPage(medit);
+ medit->viewport()->setFocus();
+ medit->select("mc:");
+}
+
+void Main::fileLoad(QString fn, const LoadMode &lmode)
+{
+ // Error codes
+ enum errorCode {success,aborted};
+ errorCode err=success;
+
+ // fn is usually the archive, mapfile the file after uncompressing
+ QString mapfile;
+
+ // Make fn absolute (needed for unzip)
+ fn=QDir (fn).absPath();
+
+ MapEditor *me;
+
+ if (lmode==NewMap)
+ {
+ // Check, if map is already loaded
+ int i=0;
+ while (i<=tabWidget->count() -1)
+ {
+ me=(MapEditor*)tabWidget->page(i);
+ if (me->getFilePath() == fn)
+ {
+ // Already there, ask for confirmation
+ QMessageBox mb( "VYM",
+ tr("The map ") + fn + tr ("\n is already opened."
+ "Opening the same map in multiple editors may lead \n"
+ "to confusion when finishing working with vym."
+ "Do you want to"),
+ QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::Cancel | QMessageBox::Escape,
+ QMessageBox::QMessageBox::NoButton);
+ mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
+ mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
+ switch( mb.exec() )
+ {
+ case QMessageBox::Yes:
+ // load anyway
+ i=tabWidget->count();
+ break;
+ case QMessageBox::Cancel:
+ // do nothing
+ return;
+ break;
+ }
+ }
+ i++;
+ }
+ }
+
+
+ // Try to load map
+ if ( !fn.isEmpty() )
+ {
+ me = currentMapEditor();
+ int tabIndex=tabWidget->currentPageIndex();
+ // Check first, if mapeditor exists
+ // If it is not default AND we want a new map,
+ // create a new mapeditor in a new tab
+ if ( lmode==NewMap && (!me || !me->isDefault() ) )
+ {
+ me = new MapEditor (tabWidget,true);
+ tabWidget->addTab (me,fn);
+ tabIndex=tabWidget->indexOf (me);
+ tabWidget->setCurrentPage (tabIndex);
+ }
+
+ // Check, if file exists (important for creating new files
+ // from command line
+ if (!QFile(fn).exists() )
+ {
+ QMessageBox mb( "VYM",
+ tr("The map") + fn +
+ tr(" does not exist.\n Do you want to create a new one?"),
+ QMessageBox::Question,
+ QMessageBox::Yes ,
+ QMessageBox::Cancel | QMessageBox::Default,
+ QMessageBox::QMessageBox::NoButton );
+
+ mb.setButtonText( QMessageBox::Yes, tr("Create"));
+ mb.setButtonText( QMessageBox::No, tr("Cancel"));
+ switch( mb.exec() )
+ {
+ case QMessageBox::Yes:
+ // Create new map
+ currentMapEditor()->setFilePath(fn);
+ tabWidget->setTabLabel (currentMapEditor(),
+ currentMapEditor()->getFileName() );
+ statusBar()->message( "Created " + fn , statusbarTime );
+ return;
+
+ case QMessageBox::Cancel:
+ // don't create new map
+ statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
+ fileCloseMap();
+ return;
+ }
+ }
+
+
+ //tabWidget->currentPage() won't be NULL here, because of above...
+ tabWidget->showPage(me);
+ me->viewport()->setFocus();
+
+ // Create temporary directory for packing
+ char tmpdir1[]="/tmp/vym-XXXXXX";
+ QString tmpMapDir=mkdtemp(tmpdir1);
+
+ // Try to unzip file
+ Process *zipProc=new Process ();
+ zipProc->clearArguments();
+ zipProc->setWorkingDirectory (QDir(tmpMapDir));
+ zipProc->addArgument ("unzip");
+ zipProc->addArgument (fn );
+ zipProc->addArgument ("-d");
+ zipProc->addArgument (tmpMapDir);
+
+ if (!zipProc->start() )
+ {
+ QMessageBox::critical( 0, tr( "Critical Load Error" ),
+ tr("Couldn't start unzip to decompress data."));
+ err=aborted;
+
+ } else
+ {
+ zipProc->waitFinished();
+ if (!zipProc->normalExit() )
+ {
+ QMessageBox::critical( 0, tr( "Critical Load Error" ),
+ tr("unzip didn't exit normally") +
+ zipProc->getErrout() );
+ err=aborted;
+ } else
+ {
+ if (zipProc->exitStatus()>0)
+ {
+ if (zipProc->exitStatus()==9)
+ {
+ // no zipped file, but maybe .xml or old version? Try again.
+ mapfile=fn;
+ me->setZipped(false);
+ }
+ else
+ {
+ QMessageBox::critical( 0, tr( "Critical Load Error" ),
+ QString("unzip exit code: %1").arg(zipProc->exitStatus() ) +
+ zipProc->getErrout() );
+ err=aborted;
+ }
+ } else
+ { // Uncompressing was successfull,
+ // load from uncompressed temporary directory
+
+ me->setZipped(true);
+
+
+ // Look for mapname.xml
+ mapfile= fn.left(fn.findRev(".",-1,true));
+ mapfile=mapfile.section( '/', -1 );
+ QFile file( tmpMapDir + "/" + mapfile + ".xml");
+ if (!file.exists() )
+ {
+ // mapname.xml does not exist, well,
+ // maybe some renamed the mapname.vym file...
+ // Try to find any .xml in the toplevel
+ // directory of the .vym file
+ QStringList flist=QDir (tmpMapDir).entryList("*.xml");
+ if (flist.count()==1)
+ {
+ // Only one entry, take this one
+ mapfile=tmpMapDir + "/"+flist.first();
+ } else
+ {
+ for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
+ *it=tmpMapDir + "/" + *it;
+ // FIXME
+ // Multiple entries, load all (but only the first one into this ME)
+ //mainWindow->fileLoadFromTmp (flist);
+ //returnCode=1; // Silently forget this attempt to load
+ qWarning ("MainWindow::load (fn) multimap found...");
+ }
+
+ if (flist.isEmpty() )
+ {
+ QMessageBox::critical( 0, tr( "Critical Load Error" ),
+ tr("Couldn't find a map (*.xml) in .vym archive.\n"));
+ err=aborted;
+ }
+ } //file doesn't exist
+ else
+ mapfile=file.name();
+ } // Uncompressing successfull
+ }
+ }
+
+ // Finally load map into mapEditor
+ me->setFilePath (mapfile,fn);
+ if (me->load(mapfile,lmode))
+ err=aborted;
+
+ // Delete tmpDir
+ system ( "rm -rf "+tmpMapDir);
+
+ // Check for errors
+ if (err==success)
+ {
+ if (lmode==NewMap)
+ {
+ me->setFilePath (fn);
+ tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
+ lastMaps.prepend(me->getFilePath() );
+ setupLastMapsMenu();
+ actionFilePrint->setEnabled (true);
+ }
+ statusBar()->message( "Loaded " + fn, statusbarTime );
+ return;
+ } else
+ {
+ if (lmode==NewMap)
+ fileCloseMap();
+ }
+
+
+ }
+ statusBar()->message( "Could not load " + fn, statusbarTime );
+}
+
+
+void Main::fileLoad(const LoadMode &lmode)
+{
+ QFileDialog *fd=new QFileDialog( this);
+ if (!lastFileDir.isEmpty())
+ fd->setDir (lastFileDir);
+ fd->addFilter ("XML (*.xml)");
+ fd->addFilter ("VYM map (*.vym *.vyp)");
+ switch (lmode)
+ {
+ case NewMap:
+ fd->setCaption(tr("Load vym map"));
+ break;
+ case ImportAdd:
+ fd->setCaption(tr("Import: Add vym map to selection"));
+ break;
+ case ImportReplace:
+ fd->setCaption(tr("Import: Replace selection with vym map"));
+ break;
+ }
+ fd->show();
+
+ QString fn;
+ if ( fd->exec() == QDialog::Accepted )
+ {
+ lastFileDir=fd->dirPath();
+ fn = fd->selectedFile();
+ fileLoad(fn, lmode);
+ }
+}
+
+void Main::fileLoad()
+{
+ fileLoad (NewMap);
+}
+
+void Main::fileLoadLast(int i)
+{
+ fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
+}
+
+void Main::fileSave(const SaveMode &savemode)
+{
+ // tmp dir for zipping
+ QString tmpMapDir;
+
+ // Error codes
+ enum errorCode {success,aborted};
+ errorCode err=success;
+
+ QString safeFilePath;
+
+ bool saveZipped=currentMapEditor()->saveZipped();
+
+ if (currentMapEditor())
+ {
+ QString fn=currentMapEditor()->getFilePath();
+ // filename=unnamed, filepath="" in constructor...
+ if ( !fn.isEmpty() )
+ {
+ // We have a filepath, go on saving
+ // First remove existing file, we
+ // don't want to add to old zip archives
+ QFile f(fn);
+ if (f.exists() )
+ if (!f.remove())
+ QMessageBox::warning( 0, tr( "Save Error" ),
+ fn+ tr("\ncould not be removed before saving"));
+
+ // Look, if we should zip the data:
+ if (!saveZipped)
+ {
+ QMessageBox mb( "VYM",
+ tr("The map ") + fn +
+ tr ("\ndid not use the compressed "
+ "vym file format.\nWriting it uncompressed will also write images \n"
+ "and flags and thus may overwrite files in the "
+ "given directory\n\nDo you want to write the map"),
+ QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::No ,
+ QMessageBox::Cancel | QMessageBox::Escape);
+ mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
+ mb.setButtonText( QMessageBox::No, tr("uncompressed") );
+ mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
+ switch( mb.exec() )
+ {
+ case QMessageBox::Yes:
+ // save compressed (default file format)
+ saveZipped=true;
+ break;
+ case QMessageBox::No:
+ // save uncompressed
+ saveZipped=false;
+ break;
+ case QMessageBox::Cancel:
+ // do nothing
+ return;
+ break;
+ }
+ }
+
+ if (saveZipped)
+ {
+ char tmpdir1[]="/tmp/vym-XXXXXX";
+ tmpMapDir=mkdtemp(tmpdir1);
+
+ safeFilePath=currentMapEditor()->getFilePath();
+ currentMapEditor()->setFilePath (tmpMapDir+"/"+
+ currentMapEditor()->getMapName()+ ".xml",
+ safeFilePath);
+ currentMapEditor()->save (savemode);
+ currentMapEditor()->setFilePath (safeFilePath);
+
+ // zip the temporary directory
+ Process *zipProc=new Process ();
+ zipProc->clearArguments();
+ zipProc->setWorkingDirectory (QDir(tmpMapDir));
+ zipProc->addArgument ("zip");
+ zipProc->addArgument ("-r");
+ zipProc->addArgument (fn);
+ zipProc->addArgument (".");
+
+ if (!zipProc->start() )
+ {
+ // zip could not be started
+ QMessageBox::critical( 0, tr( "Critical Save Error" ),
+ tr("Couldn't start zip to compress data."));
+ err=aborted;
+ } else
+ {
+ // zip could be started
+ zipProc->waitFinished();
+ if (!zipProc->normalExit() )
+ {
+ QMessageBox::critical( 0, tr( "Critical Save Error" ),
+ tr("zip didn't exit normally")+
+ "\n" + zipProc->getErrout());
+ err=aborted;
+ } else
+ {
+ if (zipProc->exitStatus()>0)
+ {
+ QMessageBox::critical( 0, tr( "Critical Save Error" ),
+ QString("zip exit code: %1").arg(zipProc->exitStatus() )+
+ "\n" + zipProc->getErrout() );
+ err=aborted;
+ }
+ }
+ } // zip could be started
+ } // save zipped
+ else
+ {
+ // Save unzipped.
+ safeFilePath=currentMapEditor()->getFilePath();
+ currentMapEditor()->setFilePath (fn, safeFilePath);
+ currentMapEditor()->save (savemode);
+ currentMapEditor()->setFilePath (safeFilePath);
+ } // save zipped
+ } // filepath available
+ else
+ {
+ // We have no filepath yet,
+ // call fileSaveAs() now, this will call fileSave()
+ // again.
+ fileSaveAs(savemode);
+ }
+ }
+
+ if (currentMapEditor()->saveZipped())
+ {
+ // Delete tmpDir
+ system ( "rm -rf "+ tmpMapDir );
+ }
+
+ if (err==success)
+ statusBar()->message(
+ tr("Saved")+" " + currentMapEditor()->getFilePath(),
+ statusbarTime );
+ else
+ statusBar()->message(
+ tr("Couldn't save")+" " + currentMapEditor()->getFilePath(),
+ statusbarTime );
+}
+
+void Main::fileSave()
+{
+ fileSave (CompleteMap);
+}
+
+void Main::fileSaveAs(const SaveMode& savemode)
+{
+ QString tmpMapDir;
+ QString fn;
+
+ if (currentMapEditor())
+ {
+ if (savemode==CompleteMap)
+ fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
+ else
+ fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
+ if ( !fn.isEmpty() )
+ {
+ // Check for existing file
+ if (QFile (fn).exists())
+ {
+ QMessageBox mb( "VYM",
+ tr("The file ") + fn + tr ("\nexists already. Do you want to"),
+ QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::Cancel | QMessageBox::Escape,
+ QMessageBox::QMessageBox::NoButton);
+ mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
+ mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
+ switch( mb.exec() )
+ {
+ case QMessageBox::Yes:
+ // save
+ break;
+ case QMessageBox::Cancel:
+ // do nothing
+ return;
+ break;
+ }
+ } else
+ {
+ // New file, add extension to filename, if missing
+ // This is always .vym or .vyp, depending on savemode
+ if (savemode==CompleteMap)
+ {
+ if (!fn.contains (".vym") && !fn.contains (".xml"))
+ fn +=".vym";
+ } else
+ {
+ if (!fn.contains (".vyp") && !fn.contains (".xml"))
+ fn +=".vyp";
+ }
+ }
+
+
+
+
+ // Save now
+ currentMapEditor()->setFilePath(fn);
+ fileSave(savemode);
+
+ // Set name of tab
+ tabWidget->setTabLabel (currentMapEditor(),
+ currentMapEditor()->getFileName() );
+ return;
+ }
+ }
+}
+
+void Main::fileSaveAs()
+{
+ fileSaveAs (CompleteMap);
+}
+
+void Main::fileImportDir()
+{
+ if (currentMapEditor())
+ currentMapEditor()->importDir();
+}
+
+void Main::fileExportXML()
+{
+ if (currentMapEditor())
+ {
+ QString dir=browseDirectory(tr("Export XML to directory"));
+ if (dir !="" && reallyWriteDirectory(dir) )
+ currentMapEditor()->exportXML(dir);
+ }
+}
+
+void Main::fileExportHTML()
+{
+ if (currentMapEditor())
+ {
+ ExportHTMLDialog dia(this);
+
+ if (dia.exec()==QDialog::Accepted)
+ {
+ QString dir=dia.getDir();
+ if (reallyWriteDirectory(dir) )
+ {
+ currentMapEditor()->exportXML (dia.getDir() );
+ dia.doExport(currentMapEditor()->getMapName() );
+ }
+ }
+ }
+}
+
+void Main::fileExportXHTML()
+{
+ QString dir;
+ if (currentMapEditor())
+ {
+ ExportXHTMLDialog dia(this);
+ dia.setFilePath (currentMapEditor()->getFilePath() );
+ dia.setMapName (currentMapEditor()->getMapName() );
+ dia.readSettings();
+
+ if (dia.exec()==QDialog::Accepted)
+ {
+ QString dir=dia.getDir();
+ // Check, if warnings should be used before overwriting
+ // the output directory
+ bool ok;
+ if (dia.warnings())
+ ok=reallyWriteDirectory(dir);
+ else
+ ok=true;
+
+ if (ok)
+ {
+ currentMapEditor()->exportXML (dia.getDir() );
+ dia.doExport(currentMapEditor()->getMapName() );
+ if (dia.hasChanged())
+ currentMapEditor()->setChanged();
+ }
+ }
+ }
+}
+
+void Main::fileExportImage(int item)
+{
+ if (currentMapEditor())
+ {
+ QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
+ this );
+ if ( !fn.isEmpty() )
+ {
+ currentMapEditor()->exportImage(fn,item);
+ } else {
+ statusBar()->message( tr("Couldn't save") + fn, statusbarTime );
+ }
+ }
+}
+
+void Main::fileExportASCII()
+{
+ if (currentMapEditor())
+ currentMapEditor()->exportASCII();
+}
+
+void Main::fileCloseMap()
+{
+ if (currentMapEditor())
+ {
+ if (currentMapEditor()->hasChanged())
+ {
+ QMessageBox mb( "VYM",
+ tr("The map ") + currentMapEditor()->getFileName() +
+ tr(" has been modified but not saved yet. Do you want to"),
+ QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::No,
+ QMessageBox::Cancel | QMessageBox::Escape );
+ mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
+ mb.setButtonText( QMessageBox::No, tr("Discard changes"));
+ switch( mb.exec() )
+ {
+ case QMessageBox::Yes:
+ // save and close
+ fileSave(CompleteMap);
+ break;
+ case QMessageBox::No:
+ // close without saving
+ break;
+ case QMessageBox::Cancel:
+ // do nothing
+ return;
+ }
+ }
+ currentMapEditor()->closeMap();
+ tabWidget->removePage(currentMapEditor());
+ if (tabWidget->count()==0)
+ actionFilePrint->setEnabled (false);
+ }
+}
+
+void Main::filePrint()
+{
+ if (currentMapEditor())
+ currentMapEditor()->print();
+}
+
+void Main::fileExitVYM()
+{
+ // Check if one or more editors have changed
+ MapEditor *me;
+ int i;
+ for (i=0;i<=tabWidget->count() -1;i++)
+ {
+
+ me=(MapEditor*)tabWidget->page(i);
+
+ // If something changed, ask what to do
+ if (me->isUnsaved())
+ {
+ tabWidget->setCurrentPage(i);
+ QMessageBox mb( "VYM",
+ tr("This map is not saved yet. Do you want to"),
+ QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::No,
+ QMessageBox::Cancel | QMessageBox::Escape );
+ mb.setButtonText( QMessageBox::Yes, tr("Save map") );
+ mb.setButtonText( QMessageBox::No, tr("Discard changes") );
+ mb.show();
+ // Call undocumented function: setActiveWindow is only
+ // possible, if widget is visible. This depends on
+ // windowmanager...
+#if defined(Q_OS_LINUX)
+ qt_wait_for_window_manager( this);
+#endif
+ mb.setActiveWindow();
+ switch( mb.exec() ) {
+ case QMessageBox::Yes:
+ // save (the changed editors) and exit
+ fileSave(CompleteMap);
+ break;
+ case QMessageBox::No:
+ // exit without saving
+ break;
+ case QMessageBox::Cancel:
+ // don't save and don't exit
+ return;
+ }
+ }
+ } // loop over all MEs
+ qApp->quit();
+}
+
+void Main::editUndo()
+{
+ if (currentMapEditor())
+ currentMapEditor()->undo();
+}
+
+void Main::editRedo() // TODO
+{
+}
+
+void Main::editCopy()
+{
+ if (currentMapEditor())
+ currentMapEditor()->copy();
+}
+
+void Main::editPaste()
+{
+ if (currentMapEditor())
+ currentMapEditor()->paste();
+}
+
+void Main::editCut()
+{
+ if (currentMapEditor())
+ currentMapEditor()->cut();
+}
+
+void Main::editOpenFindWindow()
+{
+ findWindow->popup();
+ findWindow->raise();
+
+ // Call undocumented function: setActiveWindow is only
+ // possible, if widget is visible. This depends on
+ // windowmanager...
+#if defined(Q_OS_LINUX)
+ qt_wait_for_window_manager( this);
+#endif
+ findWindow->setActiveWindow();
+}
+
+void Main::editFind(QString s)
+{
+ bool cs=false;
+ BranchObj *bo=currentMapEditor()->findText(s, cs);
+ if (bo)
+ {
+ statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
+ } else
+ {
+ QMessageBox::information( findWindow, tr( "VYM -Information:" ),
+ tr("No matches found for ")+
+ "'"+s+"'");
+ }
+}
+
+void Main::editFindChanged()
+{ // Notify editor, to abort the current find process
+ currentMapEditor()->findReset();
+}
+
+void Main::editOpenURL()
+{
+ if (currentMapEditor())
+ currentMapEditor()->openURL();
+}
+
+void Main::editURL()
+{
+ if (currentMapEditor())
+ currentMapEditor()->editURL();
+}
+
+void Main::editHeading2URL()
+{
+ if (currentMapEditor())
+ currentMapEditor()->editHeading2URL();
+}
+
+void Main::editBugzilla2URL()
+{
+ if (currentMapEditor())
+ currentMapEditor()->editBugzilla2URL();
+}
+
+void Main::editOpenVymLink()
+{
+ // Get current path to map
+ QString currentVymLink;
+ if (currentMapEditor())
+ {
+ currentVymLink=currentMapEditor()->getVymLink();
+ // compare path with already loaded maps
+ int index=-1;
+ int i;
+ MapEditor *me;
+ for (i=0;i<=tabWidget->count() -1;i++)
+ {
+ me=(MapEditor*)tabWidget->page(i);
+ if (currentVymLink==me->getFilePath() )
+ {
+ index=i;
+ break;
+ }
+ }
+ if (index<0)
+ // Load map
+ {
+ if (!QFile(currentVymLink).exists() )
+ QMessageBox::critical( 0, tr( "Critical Error" ),
+ tr("Couldn't open map " +currentVymLink)+".");
+ else
+ {
+ fileLoad (currentVymLink, NewMap);
+ tabWidget->setCurrentPage (tabWidget->count()-1);
+ }
+ } else
+ // Go to tab containing the map
+ tabWidget->setCurrentPage (index);
+ }
+}
+
+void Main::editVymLink()
+{
+ if (currentMapEditor())
+ currentMapEditor()->editVymLink();
+}
+
+void Main::editDeleteVymLink()
+{
+ if (currentMapEditor())
+ currentMapEditor()->deleteVymLink();
+}
+
+void Main::editMapInfo()
+{
+ if (currentMapEditor())
+ currentMapEditor()->editMapInfo();
+}
+
+void Main::editMoveUp()
+{
+ if (currentMapEditor())
+ currentMapEditor()->moveBranchUp();
+}
+
+void Main::editMoveDown()
+{
+ if (currentMapEditor())
+ currentMapEditor()->moveBranchDown();
+}
+
+void Main::editToggleScroll()
+{
+ if (currentMapEditor())
+ {
+ currentMapEditor()->toggleScroll();
+ }
+}
+
+void Main::editUnScrollAll()
+{
+ if (currentMapEditor())
+ {
+ currentMapEditor()->unScrollAll();
+ }
+}
+
+void Main::editHeading()
+{
+ if (currentMapEditor())
+ currentMapEditor()->editHeading();
+}
+
+void Main::editNewBranch()
+{
+ if (currentMapEditor())
+ currentMapEditor()->addNewBranch(0);
+}
+
+void Main::editNewBranchAbove()
+{
+ if (currentMapEditor())
+ currentMapEditor()->addNewBranch(-1);
+}
+
+void Main::editNewBranchBelow()
+{
+ if (currentMapEditor())
+ currentMapEditor()->addNewBranch(1);
+}
+
+void Main::editImportAdd()
+{
+ fileLoad (ImportAdd);
+}
+
+void Main::editImportReplace()
+{
+ fileLoad (ImportReplace);
+}
+
+void Main::editSaveBranch()
+{
+ fileSaveAs (PartOfMap);
+}
+
+void Main::editDeleteSelection()
+{
+ if (currentMapEditor())
+ currentMapEditor()->deleteSelection();
+}
+
+void Main::editUpperBranch()
+{
+ if (currentMapEditor())
+ currentMapEditor()->selectUpperBranch();
+}
+
+void Main::editLowerBranch()
+{
+ if (currentMapEditor())
+ currentMapEditor()->selectLowerBranch();
+}
+
+void Main::editLeftBranch()
+{
+ if (currentMapEditor())
+ currentMapEditor()->selectLeftBranch();
+}
+
+void Main::editRightBranch()
+{
+ if (currentMapEditor())
+ currentMapEditor()->selectRightBranch();
+}
+
+void Main::editFirstBranch()
+{
+ if (currentMapEditor())
+ currentMapEditor()->selectFirstBranch();
+}
+
+void Main::editLastBranch()
+{
+ if (currentMapEditor())
+ currentMapEditor()->selectLastBranch();
+}
+
+void Main::editLoadImage()
+{
+ if (currentMapEditor())
+ currentMapEditor()->loadFloatImage();
+}
+
+void Main::editSaveImage(int item)
+{
+ if (currentMapEditor())
+ currentMapEditor()->saveFloatImage(item);
+}
+
+void Main::editToggleFloatExport()
+{
+ if (currentMapEditor())
+ currentMapEditor()->toggleFloatExport();
+}
+
+void Main::formatSelectColor()
+{
+ if (currentMapEditor())
+ {
+ QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
+ if ( !col.isValid() ) return;
+ currentMapEditor()->setColor( col );
+ colorChanged( col );
+ }
+}
+
+void Main::formatPickColor()
+{
+ if (currentMapEditor())
+ colorChanged( currentMapEditor()->pickColor() );
+}
+
+void Main::colorChanged(QColor c)
+{
+ QPixmap pix( 16, 16 );
+ pix.fill( c );
+ actionFormatColor->setIconSet( pix );
+}
+
+void Main::formatColorItem()
+{
+ if (currentMapEditor())
+ currentMapEditor()->colorItem();
+}
+
+void Main::formatColorBranch()
+{
+ if (currentMapEditor())
+ currentMapEditor()->colorBranch();
+}
+
+void Main::formatLinkStyleLine()
+{
+ if (currentMapEditor())
+ currentMapEditor()->setLinkStyle(StyleLine);
+}
+
+void Main::formatLinkStyleParabel()
+{
+ if (currentMapEditor())
+ currentMapEditor()->setLinkStyle(StyleParabel);
+}
+
+void Main::formatLinkStylePolyLine()
+{
+ if (currentMapEditor())
+ currentMapEditor()->setLinkStyle(StylePolyLine);
+}
+
+void Main::formatLinkStylePolyParabel()
+{
+ if (currentMapEditor())
+ currentMapEditor()->setLinkStyle(StylePolyParabel);
+}
+
+void Main::formatSelectBackColor()
+{
+ if (currentMapEditor())
+ currentMapEditor()->selectBackgroundColor();
+}
+
+void Main::formatSelectLinkColor()
+{
+ if (currentMapEditor())
+ currentMapEditor()->selectLinkColor();
+}
+
+void Main::formatToggleLinkColorHint()
+{
+ currentMapEditor()->toggleLinkColorHint();
+}
+
+void Main::formatFrameNone()
+{
+ if (currentMapEditor())
+ currentMapEditor()->setFrame(NoFrame);
+}
+
+void Main::formatFrameRectangle()
+{
+ if (currentMapEditor())
+ currentMapEditor()->setFrame(Rectangle);
+}
+
+void Main::viewZoomReset()
+{
+ if (currentMapEditor())
+ {
+ QWMatrix m;
+ m.reset();
+ currentMapEditor()->setWorldMatrix( m );
+ currentMapEditor()->setViewCenter();
+ currentMapEditor()->adjustCanvasSize();
+ }
+}
+
+void Main::viewZoomIn()
+{
+ if (currentMapEditor())
+ {
+ QWMatrix m = currentMapEditor()->worldMatrix();
+ m.scale( 1.25, 1.25 );
+ currentMapEditor()->setWorldMatrix( m );
+ currentMapEditor()->setViewCenter();
+ currentMapEditor()->adjustCanvasSize();
+ }
+}
+
+void Main::viewZoomOut()
+{
+ if (currentMapEditor())
+ {
+ QWMatrix m = currentMapEditor()->worldMatrix();
+ m.scale( 0.8, 0.8 );
+ currentMapEditor()->setWorldMatrix( m );
+ currentMapEditor()->setViewCenter();
+ currentMapEditor()->adjustCanvasSize();
+ }
+}
+bool Main::settingsPDF()
+{
+ // Default browser is set in constructor
+ bool ok;
+ QString text = QInputDialog::getText(
+ "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
+ settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
+ if (ok)
+ settings.writeEntry ("/vym/mainwindow/readerPDF",text);
+ return ok;
+}
+
+
+bool Main::settingsURL()
+{
+ // Default browser is set in constructor
+ bool ok;
+ QString text = QInputDialog::getText(
+ "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
+ settings.readEntry("/vym/mainwindow/readerURL")
+ , &ok, this );
+ if (ok)
+ settings.writeEntry ("/vym/mainwindow/readerURL",text);
+ return ok;
+}
+
+void Main::windowToggleNoteEditor()
+{
+ if (textEditor->showWithMain() )
+ windowHideNoteEditor();
+ else
+ windowShowNoteEditor();
+}
+
+void Main::windowShowNoteEditor()
+{
+ textEditor->setShowWithMain(true);
+ textEditor->show();
+ actionViewToggleNoteEditor->setOn (true);
+}
+
+void Main::windowHideNoteEditor()
+{
+ textEditor->setShowWithMain(false);
+ textEditor->hide();
+ actionViewToggleNoteEditor->setOn (false);
+}
+
+void Main::windowNextEditor()
+{
+ if (tabWidget->currentPageIndex() < tabWidget->count())
+ tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
+}
+
+void Main::windowPreviousEditor()
+{
+ if (tabWidget->currentPageIndex() >0)
+ tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
+}
+
+void Main::standardFlagChanged()
+{
+ currentMapEditor()->toggleStandardFlag(sender()->name());
+}
+
+void Main::testFunction()
+{
+ //textEditor->stackUnder(this);
+ currentMapEditor()->testFunction();
+}
+
+void Main::testShowClipboard()
+{
+ clipboardME->show();
+}
+
+void Main::helpDoc()
+{
+ QString docpath;
+ // default path in SUSE LINUX
+ docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
+
+ if (!QFile (docpath).exists() )
+ {
+ // relative path for easy testing in tarball
+ docpath="doc/vym.pdf";
+ if (!QFile (docpath).exists() )
+ {
+ // relative path for testing while still writing vym.tex
+ docpath="doc/tex/vym.pdf";
+ if (!QFile (docpath).exists() )
+ {
+ QMessageBox::critical(0,
+ tr("Critcal error"),
+ tr("Couldn't find the documentation\n"
+ "vym.pdf in various places."));
+ return;
+ }
+ }
+ }
+
+ Process *pdfProc = new Process();
+ pdfProc->clearArguments();
+ pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
+ pdfProc->addArgument( docpath);
+
+ if ( !pdfProc->start() )
+ {
+ // error handling
+ QMessageBox::critical(0,
+ tr("Critcal error"),
+ tr("Couldn't find a viewer to read vym.pdf.\n"
+ "Please use Settings->")+tr("Set application to open pdf files"));
+ return;
+ }
+}
+
+
+void Main::helpAbout()
+{
+ static QMessageBox* about = new QMessageBox( "VYM",
+ "
VYM - View Your Mind
"
+ "
A tool to put the things you have got in your mind into a map.
"
+ "
"
+ "
(c) by Uwe Drechsel (vym@InSilmaril.de)
"
+ "
vym is released under the GPL (Gnu General Public License)"
+ ", with one exception (see the file \"LICENSE\"which "
+ "comes with vym). This exception is needed to build vym with QT libraries for proprietary operating systems.
", QMessageBox::Information, 1, 0, 0, this, 0, FALSE );
+ about->setButtonText( 1, "Dismiss" );
+ about->setMinimumSize(QSize(300,300));
+ about->setIconPixmap (QPixmap(vym_logo_xpm));
+ about->show();
+}
+
+void Main::helpAboutQT()
+{
+ QMessageBox::aboutQt( this, "Qt Application Example" );
+}
+
diff -r 000000000000 -r 7a96bd401351 mainwindow.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mainwindow.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,168 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "xml.h"
+#include "texteditor.h"
+#include "mapeditor.h"
+#include "findwindow.h"
+
+class Main : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ Main(QWidget* parent=0, const char* name=0, WFlags f=0);
+ ~Main();
+ void loadCmdLine();
+ void statusMessage (const QString &);
+
+public slots:
+ void fileNew();
+
+protected:
+ void closeEvent( QCloseEvent* );
+
+private:
+ void setupFileActions();
+ void setupEditActions();
+ void setupFormatActions();
+ void setupViewActions();
+ void setupWindowActions();
+ void setupFlagActions();
+ void setupSettingsActions();
+ void setupTestActions();
+ void setupHelpActions();
+ void setupContextMenus();
+ void setupLastMapsMenu();
+ void hideEvent (QHideEvent * );
+ void showEvent (QShowEvent * );
+ bool reallyWriteDirectory(const QString&);
+ QString browseDirectory(const QString&);
+ MapEditor* currentMapEditor() const;
+
+private slots:
+ void newView();
+ void editorChanged(QWidget*);
+
+ void fileLoad(QString ,const LoadMode &);
+ void fileLoad(const LoadMode &);
+ void fileLoad();
+ void fileLoadLast(int);
+ void fileSave(const SaveMode & );
+ void fileSave();
+ void fileSaveAs(const SaveMode &);
+ void fileSaveAs();
+ void fileImportDir();
+ void fileExportXML();
+ void fileExportHTML();
+ void fileExportXHTML();
+ void fileExportImage(int);
+ void fileExportASCII();
+ void fileCloseMap();
+ void filePrint();
+ void fileExitVYM();
+
+ void editUndo();
+ void editRedo();
+ void editCopy();
+ void editPaste();
+ void editCut();
+ void editOpenFindWindow();
+ void editFind(QString);
+ void editFindChanged();
+public slots:
+ void editOpenURL();
+private slots:
+ void editURL();
+ void editHeading2URL();
+ void editBugzilla2URL();
+ void editVymLink();
+public slots:
+ void editOpenVymLink();
+private slots:
+ void editDeleteVymLink();
+ void editMapInfo();
+ void editMoveUp();
+ void editMoveDown();
+ void editToggleScroll();
+ void editUnScrollAll();
+ void editHeading();
+ void editNewBranch();
+ void editNewBranchAbove();
+ void editNewBranchBelow();
+ void editImportAdd();
+ void editImportReplace();
+ void editSaveBranch();
+ void editDeleteSelection();
+ void editUpperBranch();
+ void editLowerBranch();
+ void editLeftBranch();
+ void editRightBranch();
+ void editFirstBranch();
+ void editLastBranch();
+ void editLoadImage();
+ void editSaveImage(int);
+ void editToggleFloatExport();
+
+ void formatSelectColor();
+ void formatPickColor();
+ void colorChanged(QColor);
+ void formatColorItem();
+ void formatColorBranch();
+ void formatLinkStyleLine();
+ void formatLinkStyleParabel();
+ void formatLinkStylePolyLine();
+ void formatLinkStylePolyParabel();
+ void formatSelectBackColor();
+ void formatSelectLinkColor();
+ void formatToggleLinkColorHint();
+ void formatFrameNone();
+ void formatFrameRectangle();
+
+ void viewZoomReset();
+ void viewZoomIn();
+ void viewZoomOut();
+
+public slots:
+ bool settingsPDF();
+ bool settingsURL();
+
+ void windowToggleNoteEditor();
+private slots:
+ void windowNextEditor();
+ void windowPreviousEditor();
+ void windowShowNoteEditor();
+ void windowHideNoteEditor();
+
+ void standardFlagChanged();
+
+ void testFunction();
+ void testShowClipboard();
+
+ void helpDoc();
+ void helpAbout();
+ void helpAboutQT();
+
+private:
+ QCanvas* canvas;
+ QTabWidget *tabWidget;
+ FindWindow *findWindow;
+ QStringList lastMaps;
+ int maxLastMaps;
+ QString lastFileDir;
+};
+
+
+#endif
+
diff -r 000000000000 -r 7a96bd401351 mapcenterobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mapcenterobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,235 @@
+#include
+
+#include "mapcenterobj.h"
+#include "floatimageobj.h"
+#include "mapeditor.h"
+
+/////////////////////////////////////////////////////////////////
+// MapCenterObj
+/////////////////////////////////////////////////////////////////
+MapCenterObj::MapCenterObj() : BranchObj ()
+{
+// cout << "Const MapCenterObj\n";
+ init();
+}
+
+MapCenterObj::MapCenterObj(QCanvas* c) : BranchObj (c)
+{
+// cout << "Const MapCenterObj canvas="<width()/2, canvas->height()/2);
+
+ // FIXME this should be done in TextObj later...
+ QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");
+ heading->setFont(font);
+
+ branch.setAutoDelete (TRUE);
+ floatimage.setAutoDelete (TRUE);
+
+ move (absPos.x(), absPos.y() );
+ depth=0;
+
+ scrolled=false;
+ tmpUnscrolled=false;
+
+ frame->setFrameType (Rectangle);
+}
+
+void MapCenterObj::move (double x, double y)
+{
+ BranchObj::move(x,y);
+ positionBBox();
+}
+
+void MapCenterObj::moveBy (double x, double y)
+{
+ BranchObj::moveBy(x,y);
+ positionBBox();
+}
+
+void MapCenterObj::moveAll (double x, double y)
+{
+ // Get rel. position
+ double dx=x-absPos.x();
+ double dy=y-absPos.y();
+
+ // Move myself and branches
+ moveAllBy (dx,dy);
+}
+
+void MapCenterObj::moveAllBy (double dx, double dy)
+{
+ // Move myself
+ moveBy(dx,dy);
+
+ positionBBox();
+}
+
+void MapCenterObj::updateLink()
+{
+ // set childPos to middle of MapCenterObj
+ childPos=QPoint(
+ absPos.x() + QSize(getSize() ).width()/2,
+ absPos.y() + QSize(getSize() ).height()/2);
+ parPos=childPos;
+ BranchObj *b;
+ for (b=branch.first(); b; b=branch.next() )
+ b->updateLink();
+}
+
+LinkableMapObj* MapCenterObj::findMapObj(QPoint p, LinkableMapObj *excludeLMO)
+ {
+ BranchObj *bo;
+ LinkableMapObj *lmo;
+
+ // Search through child branches
+ for (bo=branch.first(); bo; bo=branch.next() )
+ {
+ lmo = bo->findMapObj(p, excludeLMO);
+
+ if (lmo!= NULL)
+ {
+ return lmo;
+ }
+ }
+ // is p in MapCenter?
+ if (inBBox (p) && (this != excludeLMO) ) return this;
+
+ // Search float images
+ FloatImageObj *foi;
+ for (foi=floatimage.first(); foi; foi=floatimage.next() )
+ if (foi->inBBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
+
+ // nothing found
+ return NULL;
+}
+
+QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPoint &offset)
+{
+ QString s,a;
+
+ // save area, if not scrolled
+ QString areaAttr=
+ attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
+ attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
+ attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
+ attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
+
+ s=beginElement ("mapcenter"
+ +attribut("absPosX",QString().setNum(absPos.x(),10))
+ +attribut("absPosY",QString().setNum(absPos.y(),10))
+ +attribut("frameType",frame->getFrameTypeName())
+ +areaAttr
+ );
+
+ incIndent();
+ if (heading->getColor()!=QColor("black"))
+ a=attribut ("textColor",QColor(heading->getColor()).name() );
+ else
+ a="";
+
+ // Save flags. If verbose is set (export to xml dir), also write
+ // the flags as picture
+ s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
+ s=s+valueElement("heading", getHeading(),a);
+
+ // Reset the counters before saving
+ FloatImageObj (canvas).resetSaveCounter();
+
+ // add link to file in s
+ if (!note.isEmpty() )
+ s+=note.saveToDir();
+
+ // Save FloatImages
+ FloatImageObj *fio;
+ for (fio=floatimage.first(); fio; fio=floatimage.next() )
+ s+=fio->saveToDir (tmpdir,prefix);
+
+ // Save branches
+ BranchObj *bo;
+ for (bo=branch.first(); bo; bo=branch.next() )
+ s+=bo->saveToDir(tmpdir,prefix, offset);
+
+ decIndent();
+ s+=endElement ("mapcenter");
+ return s;
+}
+
+void MapCenterObj::setVersion (const QString &s)
+{
+ version=s;
+}
+
+bool MapCenterObj::checkVersion ()
+{
+ // returns true, if vym is able to read file regarding
+ // the version set with setVersion
+ QString s1=version.section (".",0,0);
+ QString s2=version.section (".",1,1);
+ QString s3=version.section (".",2,2);
+ bool ok;
+ int vv1 =QString(__VYM_VERSION__).section (".",0,0).toInt(&ok,10);
+ int vv2 =QString(__VYM_VERSION__).section (".",1,1).toInt(&ok,10);
+ int vv3 =QString(__VYM_VERSION__).section (".",2,2).toInt(&ok,10);
+ int mv1=0;
+ int mv2=0;
+ int mv3=0;
+ if (!s1.isEmpty() ) mv1=s1.toInt(&ok,10);
+ if (!s2.isEmpty() ) mv2=s2.toInt(&ok,10);
+ if (!s3.isEmpty() ) mv3=s3.toInt(&ok,10);
+
+ if (vv1 > mv1)
+ return true;
+ if (vv1 < mv1)
+ return false;
+ if (vv2 > mv2)
+ return true;
+ if (vv2 < mv2)
+ return false;
+ if (vv3 > mv3)
+ return true;
+ if (vv3 < mv3)
+ return false;
+ return true;
+}
+
+void MapCenterObj::setAuthor (const QString &s)
+{
+ author=s;
+}
+
+QString MapCenterObj::getAuthor()
+{
+ return author;
+}
+
+void MapCenterObj::setComment (const QString &s)
+{
+ comment=s;
+}
+
+QString MapCenterObj::getComment ()
+{
+ return comment;
+}
+
+QString MapCenterObj::getDate ()
+{
+ return QDate::currentDate().toString ("yyyy-MM-dd");
+}
diff -r 000000000000 -r 7a96bd401351 mapcenterobj.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mapcenterobj.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,35 @@
+#ifndef MAPCENTEROBJ_H
+#define MAPCENTEROBJ_H
+
+#include "branchobj.h"
+#include "version.h"
+
+/////////////////////////////////////////////////////////////////////////////
+class MapCenterObj:public BranchObj {
+public:
+ MapCenterObj ();
+ MapCenterObj (QCanvas*);
+ ~MapCenterObj ();
+ void clear();
+ void init();
+ virtual void move (double,double);
+ virtual void moveBy (double,double);
+ virtual void moveAll (double,double);
+ virtual void moveAllBy (double,double);
+ virtual void updateLink();
+ LinkableMapObj* findMapObj(QPoint,LinkableMapObj*); // find MapObj
+ virtual QString saveToDir (const QString&,const QString&,int, const QPoint&);// Save data recursivly to tempdir
+ void setVersion(const QString &);
+ bool checkVersion(); // check if program version is higher than saved version
+ void setAuthor (const QString &);
+ QString getAuthor ();
+ void setComment (const QString &);
+ QString getComment ();
+ QString getDate();
+private:
+ QString version; // version string saved in vym file
+ QString author;
+ QString comment;
+ QDate date;
+};
+#endif
diff -r 000000000000 -r 7a96bd401351 mapeditor.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mapeditor.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,3062 @@
+#include "mapeditor.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "version.h"
+
+#include "xml.h"
+#include "texteditor.h"
+#include "linkablemapobj.h"
+#include "exports.h"
+#include "misc.h"
+#include "mainwindow.h"
+#include "extrainfodialog.h"
+#include "settings.h"
+
+#include "icons/flag-note.xpm"
+#include "icons/flag-url.xpm"
+#include "icons/flag-vymlink.xpm"
+#include "icons/flag-scrolled-right.xpm"
+#include "icons/flag-tmpUnscrolled-right.xpm"
+#include "icons/flag-questionmark.xpm"
+#include "icons/flag-exclamationmark.xpm"
+#include "icons/flag-hook-green.xpm"
+#include "icons/flag-cross-red.xpm"
+#include "icons/flag-stopsign.xpm"
+#include "icons/flag-smiley-good.xpm"
+#include "icons/flag-smiley-sad.xpm"
+#include "icons/flag-clock.xpm"
+#include "icons/flag-lamp.xpm"
+#include "icons/flag-arrow-up.xpm"
+#include "icons/flag-arrow-down.xpm"
+#include "icons/flag-thumb-up.xpm"
+#include "icons/flag-thumb-down.xpm"
+#include "icons/flag-heart.xpm"
+#include "icons/flag-flash.xpm"
+#include "icons/flag-lifebelt.xpm"
+
+extern TextEditor *textEditor;
+extern int statusbarTime;
+extern Main *mainWindow;
+extern FlagRowObj *systemFlagsDefault;
+extern FlagRowObj *standardFlagsDefault;
+extern MapEditor *clipboardME;
+
+extern QAction *actionFileSave;
+extern QAction *actionEditUndo;
+extern QAction *actionEditCopy;
+extern QAction *actionEditCut;
+extern QAction *actionEditPaste;
+extern QAction *actionEditMoveUp;
+extern QAction *actionEditMoveDown;
+extern QAction *actionEditToggleScroll;
+extern QAction *actionEditOpenURL;
+extern QAction *actionEditURL;
+extern QAction *actionEditHeading2URL;
+extern QAction *actionEditBugzilla2URL;
+extern QAction *actionEditOpenVymLink;
+extern QAction *actionEditVymLink;
+extern QAction *actionEditDeleteVymLink;
+extern QAction *actionEditHeading;
+extern QAction *actionEditDelete;
+extern QAction *actionEditAddBranch;
+extern QAction *actionEditAddBranchAbove;
+extern QAction *actionEditAddBranchBelow;
+extern QAction *actionEditImportAdd;
+extern QAction *actionEditImportReplace;
+extern QAction *actionEditSaveBranch;
+extern QAction *actionEditSelectFirst;
+extern QAction *actionEditSelectLast;
+extern QAction *actionEditLoadImage;
+extern QAction *actionEditToggleFloatExport;
+
+extern QAction* actionFormatPickColor;
+extern QAction* actionFormatColorBranch;
+extern QAction* actionFormatColorSubtree;
+extern QAction *actionFormatLinkColorHint;
+extern QAction *actionFormatBackColor;
+extern QAction *actionFormatLinkColor;
+
+extern QActionGroup *actionGroupFormatFrameTypes;
+extern QAction *actionFormatFrameNone;
+extern QAction *actionFormatFrameRectangle;
+
+extern QActionGroup *actionGroupFormatLinkStyles;
+extern QAction *actionFormatLinkStyleLine;
+extern QAction *actionFormatLinkStyleParabel;
+extern QAction *actionFormatLinkStylePolyLine;
+extern QAction *actionFormatLinkStylePolyParabel;
+
+extern QAction *actionViewToggleNoteEditor;
+
+extern QAction *actionSettingsAutoedit;
+extern QAction *actionSettingsAutoselectHeading;
+extern QAction *actionSettingsAutoselectText;
+extern QAction *actionSettingsPasteNewHeading;
+
+extern QPopupMenu *branchContextMenu;
+extern QPopupMenu *floatimageContextMenu;
+extern QPopupMenu *saveImageFormatMenu;
+extern QPopupMenu *exportImageFormatMenu;
+extern QPopupMenu *canvasContextMenu;
+
+extern Settings settings;
+
+
+///////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////
+MapEditor::MapEditor(
+ QWidget* parent, bool interactive, const char* name, WFlags f) :
+ QCanvasView(parent,name,f)
+{
+ //cout << "Constructor ME "<setAdvancePeriod(30);
+
+ setCanvas (mapCanvas);
+
+ setVScrollBarMode ( QScrollView::AlwaysOn );
+ setHScrollBarMode ( QScrollView::AlwaysOn );
+
+ // Now create the _global_ system flags _once_:
+ // (Later all OrnamentedObj copy from this
+ // and set their own canvas)
+ if (!systemFlagsDefault)
+ {
+ systemFlagsDefault = new FlagRowObj (mapCanvas);
+ systemFlagsDefault->setVisibility (false);
+ systemFlagsDefault->setName ("systemFlagsDef");
+
+ FlagObj *fo = new FlagObj (mapCanvas);
+ fo->load(QPixmap(flag_note_xpm));
+ fo->setName("note");
+ fo->setToolTip(tr("Note"));
+ systemFlagsDefault->addFlag (fo); // makes deep copy
+
+ fo->load(QPixmap(flag_url_xpm));
+ fo->setName("url");
+ fo->setToolTip(tr("WWW Document (external)"));
+ systemFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_vymlink_xpm));
+ fo->setName("vymLink");
+ fo->setToolTip(tr("Link to another vym map"));
+ systemFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_scrolled_right_xpm));
+ fo->setName("scrolledright");
+ fo->setToolTip(tr("subtree is scrolled"));
+ systemFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
+ fo->setName("tmpUnscrolledright");
+ fo->setToolTip(tr("subtree is temporary scrolled"));
+ systemFlagsDefault->addFlag (fo);
+ delete (fo);
+ }
+ if (!standardFlagsDefault)
+ {
+ standardFlagsDefault = new FlagRowObj (mapCanvas);
+ standardFlagsDefault->setVisibility (false);
+ standardFlagsDefault->setName ("standardFlagsDef");
+
+ FlagObj *fo = new FlagObj (mapCanvas);
+ fo->load(QPixmap(flag_exclamationmark_xpm));
+ fo->setName("exclamationmark");
+ fo->setToolTip(tr("Take care!"));
+ standardFlagsDefault->addFlag (fo); // makes deep copy
+
+ fo->load(QPixmap(flag_questionmark_xpm));
+ fo->setName("questionmark");
+ fo->setToolTip(tr("Really?"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_hook_green_xpm));
+ fo->setName("hook-green");
+ fo->setToolTip(tr("ok!"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_cross_red_xpm));
+ fo->setName("cross-red");
+ fo->setToolTip(tr("Not ok!"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_stopsign_xpm));
+ fo->setName("stopsign");
+ fo->setToolTip(tr("This won't work!"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_smiley_good_xpm));
+ fo->setName("smiley-good");
+ fo->setToolTip(tr("Good"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_smiley_sad_xpm));
+ fo->setName("smiley-sad");
+ fo->setToolTip(tr("Bad"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_clock_xpm));
+ fo->setName("clock");
+ fo->setToolTip(tr("Time critical"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_lamp_xpm));
+ fo->setName("lamp");
+ fo->setToolTip(tr("Idea!"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_arrow_up_xpm));
+ fo->setName("arrow-up");
+ fo->setToolTip(tr("Important"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_arrow_down_xpm));
+ fo->setName("arrow-down");
+ fo->setToolTip(tr("Unimportant"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_thumb_up_xpm));
+ fo->setName("thumb-up");
+ fo->setToolTip(tr("I like this"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_thumb_down_xpm));
+ fo->setName("thumb-down");
+ fo->setToolTip(tr("I do not like this"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_heart_xpm));
+ fo->setName("heart");
+ fo->setToolTip(tr("I just love... "));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_flash_xpm));
+ fo->setName("flash");
+ fo->setToolTip(tr("Dangerous"));
+ standardFlagsDefault->addFlag (fo);
+
+ fo->load(QPixmap(flag_lifebelt_xpm));
+ fo->setName("lifebelt");
+ fo->setToolTip(tr("This will help"));
+ standardFlagsDefault->addFlag (fo);
+ delete (fo);
+
+ }
+
+ mapCenter = new MapCenterObj(mapCanvas);
+ mapCenter->setVisibility (true);
+ mapCenter->setMapEditor (this);
+ mapCenter->setHeading (tr("New Map"));
+
+ printer=NULL;
+
+ lineedit = new QLineEdit(this, "lineedit" );
+ connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEditNoSave() ) );
+ lineedit->hide();
+
+ actColor=black; setColor (actColor);
+ deflinkcolor=QColor (0,0,255);
+ linkcolorhint=DefaultColor;
+ linkstyle=StylePolyParabel;
+ mapCanvas->setBackgroundColor (white);
+
+ // Create bitmap cursors, patform dependant
+ #if defined(Q_OS_MACX)
+ #include "icons/cursorhandopen16.xpm"
+ #include "icons/cursorcolorpicker16.xpm"
+ QBitmap cb( 16, 16, chandopen, TRUE );
+ QBitmap cm( 16, 16, chandopenmask, TRUE );
+ handOpenCursor=QCursor ( cb, cm );
+ // set hot spot to tip of picker
+ pickColorCursor=QCursor ( cursorcolorpicker_xpm, 1,15 );
+ #else
+ #include "icons/cursorhandopen.xpm"
+ #include "icons/cursorcolorpicker.xpm"
+
+ QBitmap cb( 32, 32, chandopen, TRUE );
+ QBitmap cm( 32, 32, chandopenmask, TRUE );
+ handOpenCursor=QCursor ( cb, cm );
+ // set hot spot to tip of picker
+ pickColorCursor=QCursor ( cursorcolorpicker_xpm, 5,27 );
+ #endif
+
+
+ pickingColor=false;
+
+ editingBO=NULL;
+ selection=NULL;
+ selectionLast=NULL;
+ movingObj=NULL;
+
+ mapChanged=false;
+ mapDefault=true;
+ mapUnsaved=false;
+ undoSelection=NULL;
+
+ zipped=true;
+ filePath="";
+ fileName="unnamed";
+ mapName="";
+
+ // Initialize find routine
+ itFind=NULL;
+ EOFind=false;
+
+ printFrame=true;
+ printFooter=true;
+
+ blockreposition=false;
+ isInteractive=interactive;
+ if (isInteractive)
+ // Create temporary files
+ makeTmpDirs();
+
+ // Initially set movingCentre
+ updateViewCenter();
+
+ mapCenter->reposition(); // for positioning heading
+}
+
+MapEditor::~MapEditor()
+{
+ //cout <<"Destructor MapEditor\n";
+ if (isInteractive) delTmpDirs();
+
+ // Save Settings
+ //settings.writeEntry( "/vym/mapeditor/editmode/autoselect", );
+
+}
+
+QColor MapEditor::color()
+{
+ return actColor;
+}
+
+QColor MapEditor::backgroundColor()
+{
+ return mapCanvas->backgroundColor();
+}
+
+MapCenterObj* MapEditor::getMapCenter()
+{
+ return mapCenter;
+}
+
+QCanvas* MapEditor::getCanvas()
+{
+ return mapCanvas;
+}
+
+void MapEditor::adjustCanvasSize()
+{
+ // To adjust the canvas to map, viewport size and position, we have to
+ // do some coordinate magic...
+ //
+ // Get rectangle of (scroll-)view.
+ // We want to be in canvas coords, so
+ // we map. Important if view is zoomed...
+ QRect view = inverseWorldMatrix().mapRect( QRect( contentsX(), contentsY(),
+ visibleWidth(), visibleHeight()) );
+
+ // Now we need the bounding box of view AND map to calc the correct canvas size.
+ // Why? Because if the map itself is moved out of view, the view has to be enlarged
+ // to avoid jumping aroung...
+ QRect map=mapCenter->getTotalBBox();
+
+ // right edge - left edge
+ int cw= max(map.x() + map.width(), view.x() + view.width()) - min(map.x(), view.x());
+ int ch= max(map.y() + map.height(), view.y() + view.height()) - min(map.y(), view.y());
+
+
+ if ( (cw!=mapCanvas->width()) || (ch!=mapCanvas->height()) ||
+ !mapCanvas->onCanvas (map.topLeft()) || !mapCanvas->onCanvas (map.bottomRight())
+ )
+ {
+ // move the map on canvas (in order to not move it on screen) this is neccessary
+ // a) if topleft corner of canvas is left or above topleft corner of view and also left of
+ // above topleft corner of map. E.g. if map is completly inside view, but it would be possible
+ // to scroll to an empty area of canvas to the left.
+ // b) if topleft corner of map left of or above topleft of canvas
+ int dx=0;
+ int dy=0;
+
+ if (cw > mapCanvas->width() )
+ {
+ if (map.x()<0) dx=-map.x();
+ }
+ if (cw < mapCanvas->width() )
+ dx=-min (view.x(),map.x());
+ if (ch > mapCanvas->height() )
+ {
+ if (map.y()<0) dy=-map.y();
+ }
+ if (ch < mapCanvas->height() )
+ {
+ dy=-min (view.y(),map.y());
+ }
+ // We really have to resize now. Let's go...
+ mapCanvas->resize (cw,ch);
+ if ( (dx!=0) || (dy!=0) )
+ {
+ mapCenter->moveAllBy(dx,dy);
+ mapCenter->reposition();
+
+ // scroll the view (in order to not move map on screen)
+ scrollBy (dx,dy);
+ }
+ }
+}
+
+bool MapEditor::blockReposition()
+{
+ return blockreposition;
+}
+
+void MapEditor::makeTmpDirs()
+{
+ // Create unique temporary directories
+ char tmpdir[]="/tmp/vym-XXXXXX";
+ bakMapDir=mkdtemp(tmpdir);
+ makeSubDirs(bakMapDir);
+ // FIXME set permissions
+ // and maybe use QT method for portability
+}
+
+void MapEditor::delTmpDirs()
+{
+ //FIXME delete tmp directory, better use QT methods here:
+ system ( "rm -rf "+ bakMapDir );
+}
+
+
+void MapEditor::makeSubDirs(const QString &s)
+{
+ QDir d(s);
+ d.mkdir ("images");
+ d.mkdir ("flags");
+}
+
+
+QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, SaveMode savemode)
+{
+ // tmpdir temporary directory to which data will be writte
+ // prefix mapname, which will be appended to images etc.
+ // writeflags Only write flags for "real" save of map, not undo
+ // offset offset of bbox of whole map in canvas.
+ // Needed for XML export
+ // completeMap if false, only vympart will be written, without
+ // mapcenter
+
+ // Save Header
+ QString ls;
+ switch (linkstyle)
+ {
+ case StyleLine:
+ ls="StyleLine";
+ break;
+ case StyleParabel:
+ ls="StyleParabel";
+ break;
+ case StylePolyLine:
+ ls="StylePolyLine";
+ break;
+ default:
+ ls="StylePolyParabel";
+ break;
+ }
+
+ QString s="\n";
+ QString colhint="";
+ if (linkcolorhint==HeadingColor)
+ colhint=attribut("linkColorHint","HeadingColor");
+
+ QString mapAttr=attribut("version",__VYM_VERSION__);
+ if (savemode==CompleteMap)
+ mapAttr+= attribut("author",mapCenter->getAuthor()) +
+ attribut("comment",mapCenter->getComment()) +
+ attribut("date",mapCenter->getDate()) +
+ attribut("backgroundColor", mapCanvas->backgroundColor().name() ) +
+ attribut("linkStyle", ls ) +
+ attribut("linkColor", deflinkcolor.name() ) +
+ colhint;
+ s+=beginElement("vymmap",mapAttr);
+ incIndent();
+
+ // Find the used flags while traversing the tree
+ standardFlagsDefault->resetUsedCounter();
+
+ // Build xml recursivly
+ if (savemode==CompleteMap)
+ s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset);
+ else
+ {
+ if ( undoSelection &&
+ typeid(*undoSelection) == typeid(BranchObj) )
+ s+=((BranchObj*)(undoSelection))->saveToDir(tmpdir,prefix,offset);
+ }
+
+ // Save local settings
+ s+=settings.getXMLData (destPath);
+
+ // Save selection
+ if (selection)
+ s+=valueElement("select",selection->getSelectString());
+
+ decIndent();
+ s+=endElement("vymmap");
+
+ if (writeflags)
+ standardFlagsDefault->saveToDir (tmpdir+"/flags/","",writeflags);
+
+ return s;
+}
+
+void MapEditor::saveState()
+{
+ saveState (CompleteMap,NULL);
+}
+
+void MapEditor::saveState(const SaveMode &mode, LinkableMapObj *part)
+{
+ // all binary data is saved in bakMapDir (created in Constructor)
+ // the xml data itself is kept in memory in backupXML
+ //
+ // For faster write/read of data, a part of the map can be
+ // written. Then the undoSelection will mark, which part of the
+ // map should be replaced if an undo is wanted later.
+
+ if (mode==PartOfMap && part && (typeid(*part) == typeid (BranchObj) ) )
+ {
+ // Writing a vympart only is useful for BranchObj
+ undoSelection=part;
+ backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),PartOfMap);
+ } else
+ {
+ undoSelection=NULL;
+ backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),CompleteMap);
+ }
+}
+
+void MapEditor::finishedLineEditNoSave()
+{
+ // This is called by finishedLineEdit or any MapEditor method,
+ // which wants to assure, that lineedits finish, before e.g. a branch is
+ // deleted
+
+ // After calling LineEdit and using the clipboard, the
+ // focus is not any longer on the main widget, we
+ // have to restore it using parentWidget()->setFocus()
+
+ if (editingBO!=NULL)
+ {
+ editingBO->setHeading(lineedit->text() );
+ editingBO=NULL;
+ lineedit->releaseKeyboard();
+ lineedit->hide();
+ parentWidget()->setFocus();
+ mapCenter->reposition();
+ adjustCanvasSize();
+ ensureSelectionVisible();
+ }
+}
+
+
+bool MapEditor::isDefault()
+{
+ return mapDefault;
+}
+
+bool MapEditor::isUnsaved()
+{
+ return mapUnsaved;
+}
+
+bool MapEditor::hasChanged()
+{
+ return mapChanged;
+}
+
+void MapEditor::setChanged()
+{
+ mapChanged=true;
+ mapDefault=false;
+ mapUnsaved=true;
+ actionEditUndo->setEnabled (true);
+ actionFileSave->setEnabled (true);
+ findReset();
+}
+
+void MapEditor::closeMap()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ // Unselect before disabling the toolbar actions
+ if (selection) selection->unselect();
+ selection=NULL;
+ updateActions();
+
+ clear();
+ close();
+}
+
+void MapEditor::setFilePath(QString fname)
+{
+ setFilePath (fname,fname);
+}
+
+void MapEditor::setFilePath(QString fname, QString destname)
+{
+ filePath=fname;
+ fileName=fname;
+ destPath=destname;
+
+ // If fname is not an absolute path, complete it
+ filePath=QDir(fname).absPath();
+ fileDir=filePath.left (1+filePath.findRev ("/"));
+
+ // Set short name, too. Search from behind:
+ int i=fileName.findRev("/");
+ if (i>=0) fileName=fileName.remove (0,i+1);
+
+ // Forget the .vym (or .xml) for name of map
+ mapName=fileName.left(fileName.findRev(".",-1,true) );
+}
+
+QString MapEditor::getFilePath()
+{
+ return filePath;
+}
+
+QString MapEditor::getFileName()
+{
+ return fileName;
+}
+
+QString MapEditor::getMapName()
+{
+ return mapName;
+}
+
+QString MapEditor::getDestPath()
+{
+ return destPath;
+}
+
+int MapEditor::load (QString &fname, const LoadMode &lmode)
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ int returnCode=0;
+
+ if (lmode==NewMap)
+ {
+ if (selection) selection->unselect();
+ selection=NULL;
+ mapCenter->clear();
+ mapCenter->setMapEditor(this);
+ // (map state is set later at end of load...)
+ } else
+ {
+ setChanged();
+ saveState(PartOfMap,selection);
+ }
+
+
+ mapBuilderHandler handler;
+ QFile file( fname );
+
+ // I am paranoid: file should exist anyway
+ // according to check in mainwindow.
+ if (!file.exists() )
+ {
+ QMessageBox::critical( 0, tr( "Critical Parse Error" ),
+ tr("Couldn't open map " +fname)+".");
+ returnCode=1;
+ } else
+ {
+ blockreposition=true;
+ QXmlInputSource source( file);
+ QXmlSimpleReader reader;
+ reader.setContentHandler( &handler );
+ reader.setErrorHandler( &handler );
+ handler.setMapEditor( this );
+ handler.setTmpDir (filePath.left(filePath.findRev("/",-1))); // needed to load files with rel. path
+ handler.setLoadMode (lmode);
+ bool ok = reader.parse( source );
+ blockreposition=false;
+ file.close();
+ if ( ok )
+ {
+ mapCenter->reposition();
+ adjustCanvasSize();
+ if (lmode==NewMap)
+ {
+ mapDefault=false;
+ mapChanged=false;
+ mapUnsaved=false;
+ }
+ } else
+ {
+ QMessageBox::critical( 0, tr( "Critical Parse Error" ),
+ tr( handler.errorProtocol() ) );
+ // returnCode=1;
+ // Still return "success": the map maybe at least
+ // partially read by the parser
+ }
+ }
+ updateActions();
+ return returnCode;
+}
+
+int MapEditor::save (const SaveMode &savemode)
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ int returnCode=0;
+
+ // Create mapName and fileDir
+ makeSubDirs (fileDir);
+ QString fname;
+ if (saveZipped())
+ // save as .xml
+ fname=mapName+".xml";
+ else
+ // use name given by user, even if he chooses .doc
+ fname=fileName;
+
+
+ // Check if fname is writeable
+ QFile file( fileDir+fname);
+ if (!file.open( IO_WriteOnly ) )
+ {
+ QMessageBox::critical( 0, tr( "Critical Save Error" ),
+ tr("Couldn't write to ") +fileDir+fname);
+ return 1;
+ }
+ file.close();
+
+ QString saveFile;
+ saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),savemode);
+
+ file.setName ( fileDir + fname);
+ if ( !file.open( IO_WriteOnly ) )
+ {
+ // This should neverever happen
+ QMessageBox::critical(0, tr("Critcal save error"),"MapEditor::save() Couldn't open "+file.name());
+ return 1;
+ }
+
+ // Write it finally, and write in UTF8, no matter what
+ QTextStream ts( &file );
+ ts.setEncoding (QTextStream::UnicodeUTF8);
+ ts << saveFile;
+ file.close();
+
+ if (returnCode==0)
+ {
+ mapChanged=false;
+ mapUnsaved=false;
+ actionFileSave->setEnabled(false);
+ }
+
+ return returnCode;
+}
+
+void MapEditor::setZipped (bool z)
+{
+ zipped=z;
+}
+
+bool MapEditor::saveZipped ()
+{
+ return zipped;
+}
+
+void MapEditor::print()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ if ( !printer )
+ {
+ printer = new QPrinter;
+ printer->setColorMode (QPrinter::Color);
+ }
+
+ QRect totalBBox=mapCenter->getTotalBBox();
+
+ // Try to set orientation automagically
+ // Note: Interpretation of generated postscript is amibiguous, if
+ // there are problems with landscape mode, see
+ // http://sdb.suse.de/de/sdb/html/jsmeix_print-cups-landscape-81.html
+
+ if (totalBBox.width()>totalBBox.height())
+ // recommend landscape
+ printer->setOrientation (QPrinter::Landscape);
+ else
+ // recommend portrait
+ printer->setOrientation (QPrinter::Portrait);
+
+ if ( printer->setup(this) )
+ // returns false, if printing is canceled
+ {
+ QPainter pp(printer);
+
+ // Don't print the visualisation of selection
+ LinkableMapObj *oldselection=NULL;
+ if (selection)
+ {
+ oldselection=selection;
+ selection->unselect();
+ }
+
+ // Handle sizes of map and paper:
+ //
+ // setWindow defines which part of the canvas will be transformed
+ // setViewport defines area on paper in device coordinates (dpi)
+ // e.g. (0,50,700,700) is upper part on A4
+ // see also /usr/lib/qt3/doc/html/coordsys.html
+
+ QPaintDeviceMetrics metrics (printer);
+
+ double paperAspect = (double)metrics.width() / (double)metrics.height();
+ double mapAspect = (double)totalBBox.width() / (double)totalBBox.height();
+
+ QRect mapRect=mapCenter->getTotalBBox();
+ QCanvasRectangle *frame=NULL;
+ QCanvasText *footerFN=NULL;
+ QCanvasText *footerDate=NULL;
+ if (printFrame || printFooter)
+ {
+
+ if (printFrame)
+ {
+ // Print frame around map
+ mapRect.setRect (mapRect.x()-10, mapRect.y()-10,
+ mapRect.width()+20, mapRect.height()+20);
+ frame=new QCanvasRectangle (mapRect,mapCanvas);
+ frame->setBrush (QColor(white));
+ frame->setPen (QColor(black));
+ frame->setZ(0);
+ frame->show();
+ }
+ if (printFooter)
+ {
+ // Print footer below map
+ QFont font;
+ font.setPointSize(10);
+ footerFN=new QCanvasText (mapCanvas);
+ footerFN->setText ("VYM - " + fileName);
+ footerFN->setFont(font);
+ footerFN->move (mapRect.x(), mapRect.y() + mapRect.height() );
+ footerFN->setZ(Z_TEXT);
+ footerFN->show();
+ footerDate=new QCanvasText (mapCanvas);
+ footerDate->setText (QDate::currentDate().toString(Qt::TextDate));
+ footerDate->setFont(font);
+ footerDate->move (mapRect.x()+mapRect.width()-footerDate->boundingRect().width(), mapRect.y() + mapRect.height() );
+ footerDate->setZ(Z_TEXT);
+ footerDate->show();
+ mapRect.setRect (mapRect.x(), mapRect.y(),
+ mapRect.width(), mapRect.height()+20);
+ }
+ pp.setWindow (mapRect.x(), mapRect.y(), mapRect.width(), mapRect.height());
+ } else
+ {
+ pp.setWindow (mapRect);
+ }
+
+ if (mapAspect>=paperAspect)
+ {
+ // Fit horizontally to paper width
+ pp.setViewport(0,0, metrics.width(),(int)(metrics.width()/mapAspect) );
+ } else
+ {
+ // Fit vertically to paper height
+ pp.setViewport(0,0,(int)(metrics.height()*mapAspect),metrics.height());
+ }
+
+ mapCanvas->drawArea(mapRect, &pp); // draw Canvas to printer
+
+ // Delete Frame and footer
+ if (footerFN)
+ {
+ delete (footerFN);
+ delete (footerDate);
+ }
+ if (frame) delete (frame);
+
+ // Restore selection
+ if (oldselection)
+ {
+ selection=oldselection;
+ selection->select();
+ }
+ }
+}
+
+QPixmap MapEditor::getPixmap()
+{
+ QRect mapRect=mapCenter->getTotalBBox();
+ QPixmap pix (mapRect.size());
+ QPainter pp (&pix);
+
+ // Don't print the visualisation of selection
+ LinkableMapObj *oldselection=NULL;
+ if (selection)
+ {
+ oldselection=selection;
+ selection->unselect();
+ }
+
+ pp.setWindow (mapRect);
+
+ mapCanvas->drawArea(mapRect, &pp); // draw Canvas to painter
+
+
+ // Restore selection
+ if (oldselection)
+ {
+ selection=oldselection;
+ selection->select();
+ }
+
+ return pix;
+}
+
+void MapEditor::exportImage(QString fn)
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ QPixmap pix (getPixmap());
+ pix.save(fn, "PNG");
+}
+
+void MapEditor::exportImage(QString fn, int item)
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ QPixmap pix (getPixmap());
+ pix.save(fn, exportImageFormatMenu->text(item) );
+}
+
+void MapEditor::exportASCII()
+{
+ // FIXME still experimental
+ QFileDialog *fd=new QFileDialog( this, tr("VYM - Export (ASCII)"));
+ fd->addFilter ("TXT (*.txt)");
+ fd->setCaption("VYM - Export (ASCII) (still experimental)");
+ fd->setMode( QFileDialog::AnyFile );
+ fd->show();
+
+ if ( fd->exec() == QDialog::Accepted )
+ {
+ if (QFile (fd->selectedFile()).exists() )
+ {
+ QMessageBox mb( "VYM",
+ tr("The file ") + fd->selectedFile() +
+ tr(" exists already. Do you want to overwrite it?"),
+ QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::Cancel | QMessageBox::Escape,
+ QMessageBox::NoButton );
+
+ mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
+ mb.setButtonText( QMessageBox::No, tr("Cancel"));
+ Export ex;
+ switch( mb.exec() )
+ {
+ case QMessageBox::Yes:
+ // save
+ if (!ex.setOutputDir ("out"))
+ {
+ QMessageBox::critical (0,tr("Critical Export Error "),tr("Couldn't create directory ") + "out");
+ return;
+ }
+ break;;
+ case QMessageBox::Cancel:
+ // do nothing
+ return;
+ break;
+ }
+ }
+ Export ex;
+ ex.setPath (fd->selectedFile() );
+ ex.setMapCenter(mapCenter);
+ ex.exportMap();
+ }
+}
+
+
+void MapEditor::exportXML(const QString &dir)
+{
+ // Create subdirectories
+ makeSubDirs (dir);
+
+ // write to directory
+ QString saveFile=saveToDir (dir,mapName+"-",true,mapCenter->getTotalBBox().topLeft() ,CompleteMap);
+ QFile file;
+
+ file.setName ( dir + "/"+mapName+".xml");
+ if ( !file.open( IO_WriteOnly ) )
+ {
+ // This should neverever happen
+ QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open ")+file.name());
+ return;
+ }
+
+ // Write it finally, and write in UTF8, no matter what
+ QTextStream ts( &file );
+ ts.setEncoding (QTextStream::UnicodeUTF8);
+ ts << saveFile;
+ file.close();
+
+ // Now write image, too
+ exportImage (dir+"/images/"+mapName+".png");
+}
+
+void MapEditor::clear()
+{
+ if (selection)
+ {
+ selection->unselect();
+ selection=NULL;
+ }
+
+ mapCenter->clear();
+}
+
+void MapEditor::undo()
+{
+ QDir d;
+ d.setPath(bakMapDir);
+ if (d.exists() )
+ {
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ if (selection)
+ {
+ selection->unselect();
+ selection=NULL;
+ }
+
+ mapBuilderHandler handler;
+ QXmlInputSource source;
+ source.setData(backupXML);
+ QXmlSimpleReader reader;
+ reader.setContentHandler( &handler );
+ reader.setErrorHandler( &handler );
+ handler.setMapEditor( this );
+ handler.setTmpDir ( bakMapDir ); // needed to load files with rel. path
+ if (undoSelection)
+ {
+ selection=undoSelection;
+ selection->select();
+ handler.setLoadMode (ImportReplace);
+
+ } else
+ {
+ mapCenter->clear();
+ handler.setLoadMode (NewMap);
+ }
+ blockreposition=true;
+ bool ok = reader.parse( source );
+ blockreposition=false;
+ if ( ok )
+ mapCenter->reposition();
+
+ else
+ {
+ // This should never ever happen
+ QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ),
+ tr( handler.errorProtocol() )+" in "+backupXML );
+ }
+ // Undo not longer available now
+ actionEditUndo->setEnabled (false);
+ undoSelection=false;
+ mapChanged=false;
+ return;
+ } else
+ {
+ QMessageBox::critical( 0, tr( "Critical Error" ),
+ "Temporary directory " +bakMapDir +
+ tr (" used for undo is gone. \n"
+ "I will create a new one, but at the moment no undo is available.\n"
+ "Maybe you want to reload your original data.\n\n"
+ "Sorry for any inconveniences.") );
+ makeTmpDirs();
+ }
+}
+
+void MapEditor::copy()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ if (selection)
+ {
+ if (typeid(*selection) == typeid(BranchObj) )
+ {
+ BranchObj* to;
+ BranchObj* from;
+ clipboardME->clear();
+ clipboardME->getMapCenter()->addBranch();
+ to=clipboardME->getMapCenter()->getLastBranch();
+ if (to)
+ {
+ from=(BranchObj*)(selection);
+ to->copy(from);
+
+ // keep position relative to parent
+ to->move2RelPos ( from->getRelPos());
+
+ // select data in clipboard
+ clipboardME->select ("bo:0");
+
+ // repositioning makes testing nicer,
+ // but is not needed usually:
+ if (clipboardME->isVisible())
+ {
+ clipboardME->getMapCenter()->reposition();
+ }
+ else
+ clipboardME->hide();
+ }
+ }
+ if (typeid(*selection) == typeid(FloatImageObj) )
+ {
+ FloatImageObj* to;
+ FloatImageObj* from;
+ clipboardME->clear();
+ clipboardME->getMapCenter()->addFloatImage();
+ to=clipboardME->getMapCenter()->getLastFloatImage();
+ if (to)
+ {
+ from=(FloatImageObj*)(selection);
+ to->copy(from);
+
+ // select data in clipboard
+ clipboardME->select ("fi:0");
+
+ // repositioning makes testing nicer,
+ // but is not needed usually:
+ if (clipboardME->isVisible())
+ {
+ clipboardME->getMapCenter()->reposition();
+ }
+ else
+ clipboardME->hide();
+ }
+ }
+ }
+}
+
+LinkableMapObj* MapEditor::pasteNoSave()
+{
+ return pasteAtNoSave (-1);
+}
+
+LinkableMapObj* MapEditor::pasteAtNoSave(int pos)
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ LinkableMapObj *fromLMO=clipboardME->getSelection();
+ LinkableMapObj *returnLMO=NULL;
+
+ if (selection && fromLMO)
+ {
+
+ if (typeid(*fromLMO) == typeid(BranchObj) )
+ {
+ if (typeid(*selection) == typeid(MapCenterObj))
+ {
+ returnLMO=mapCenter->addBranch( (BranchObj*)(fromLMO) );
+ ((BranchObj*)(returnLMO))->move2RelPos(normalise(fromLMO->getRelPos() ) );
+ }
+ if (typeid(*selection) == typeid(BranchObj))
+ if (pos<0)
+ returnLMO=((BranchObj*)(selection))->addBranch((BranchObj*)(fromLMO) );
+ else
+ {
+ BranchObj *par=(BranchObj*)(selection->getParObj());
+ if (par) returnLMO=par->insertBranch((BranchObj*)(fromLMO),pos );
+ }
+ }
+
+ if (typeid(*fromLMO) == typeid(FloatImageObj) &&
+ (typeid(*selection) == typeid (BranchObj) ||
+ typeid(*selection)==typeid(MapCenterObj)) )
+ returnLMO=((BranchObj*) (selection))->addFloatImage ((FloatImageObj*)(fromLMO));
+
+ }
+ return returnLMO;
+}
+
+void MapEditor::cutNoSave()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ BranchObj* bo;
+ BranchObj* par;
+ if (selection != NULL) {
+ if (typeid(*selection) == typeid(BranchObj) )
+ {
+ bo=(BranchObj*)(selection);
+ par=(BranchObj*)(bo->getParObj());
+ bo->unselect();
+ selection=NULL;
+ par->removeBranch(bo);
+ selection=par;
+ selection->select();
+ }
+ if (typeid(*selection) == typeid(FloatImageObj) )
+ {
+ FloatImageObj* fio=(FloatImageObj*)(selection);
+ par=(BranchObj*)(fio->getParObj());
+ fio->unselect();
+ selection=NULL;
+ par->removeFloatImage(fio);
+ selection=par;
+ selection->select();
+ }
+ }
+}
+
+void MapEditor::paste()
+{
+ setChanged();
+ saveState(PartOfMap,selection);
+ pasteNoSave();
+ mapCenter->reposition();
+ adjustCanvasSize();
+}
+
+void MapEditor::cut()
+{
+ setChanged();
+ saveState(PartOfMap,selection->getParObj());
+ copy();
+ cutNoSave();
+ mapCenter->reposition();
+ adjustCanvasSize();
+}
+
+void MapEditor::moveBranchUp()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ BranchObj* bo;
+ BranchObj* par;
+ if (typeid(*selection) == typeid(BranchObj) )
+ {
+ setChanged();
+ saveState(PartOfMap,selection->getParObj());
+ bo=(BranchObj*)(selection);
+ par=(BranchObj*)(bo->getParObj());
+ selection->unselect();
+ selection=par->moveBranchUp (bo);
+ selection->select();
+ mapCenter->reposition();
+ ensureSelectionVisible();
+ }
+}
+
+void MapEditor::moveBranchDown()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ BranchObj* bo;
+ BranchObj* par;
+ if (typeid(*selection) == typeid(BranchObj) )
+ {
+ setChanged();
+ saveState(PartOfMap,selection->getParObj());
+ bo=(BranchObj*)(selection);
+ par=(BranchObj*)(bo->getParObj());
+ selection->unselect();
+ selection=par->moveBranchDown(bo);
+ selection->select();
+ mapCenter->reposition();
+ ensureSelectionVisible();
+ }
+}
+
+void MapEditor::editHeading()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ if (selection &&
+ (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj) ) )
+ {
+ setChanged();
+ saveState(PartOfMap,selection);
+
+ ensureSelectionVisible();
+ BranchObj *bo=(BranchObj*)(selection);
+ editingBO=(BranchObj*)(selection);
+ QPoint p = worldMatrix().map(QPoint (bo->x(),bo->y()));
+ lineedit->setGeometry(p.x()-contentsX(),p.y()-contentsY(),200,25);
+ QString s=bo->getHeading();
+ lineedit->setText(s);
+ lineedit->setCursorPosition(1);
+ if (actionSettingsAutoselectText->isOn() && !s.isEmpty() && actionSettingsPasteNewHeading->isOn() )
+ lineedit->selectAll();
+ lineedit->show();
+
+ lineedit->grabKeyboard();
+ lineedit->setFocus();
+ }
+}
+
+
+void MapEditor::addNewBranch(int pos)
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ if (selection &&
+ (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj) ) )
+ {
+ setChanged();
+ saveState(PartOfMap,selection);
+
+ BranchObj* bo1 = (BranchObj*) (selection);
+ bool wasScrolled=false;
+ BranchObj *newbo=NULL;
+ if (pos==0)
+ {
+ // save scroll state. If scrolled, automatically select
+ // new branch in order to tmp unscroll parent...
+ wasScrolled=bo1->isScrolled();
+ newbo=bo1->addBranch();
+ } else
+ {
+ BranchObj *parbo=(BranchObj*)(selection->getParObj());
+ if (parbo)
+ {
+ if (pos<0)
+ // add above selection
+ newbo=parbo->insertBranch(bo1->getNum());
+ else
+ // add below selection
+ newbo=parbo->insertBranch(bo1->getNum()+1);
+ } else
+ // This should not happen...
+ return;
+
+ }
+
+ LinkableMapObj *oldselection=selection;
+
+ mapCenter->reposition();
+ adjustCanvasSize();
+ if (actionSettingsAutoedit->isOn() ||
+ actionSettingsAutoselectHeading->isOn() )
+ {
+ selection->unselect();
+ selection=newbo;
+ selection->select();
+ if (actionSettingsPasteNewHeading->isOn() )
+ {
+ BranchObj *bo2= (BranchObj*)(selection);
+ bo2->setHeading("");
+ }
+ if (actionSettingsAutoedit->isOn() )
+ editHeading();
+ if (!actionSettingsAutoselectHeading->isOn()
+ && !wasScrolled)
+ {
+ selection->unselect();
+ selection=oldselection;
+ selection->select();
+ }
+ }
+ }
+}
+
+void MapEditor::deleteSelection()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ if (selection && typeid(*selection) ==typeid(BranchObj) )
+ {
+ setChanged();
+ saveState(PartOfMap,selection->getParObj());
+ BranchObj* bo=dynamic_cast (selection);
+ BranchObj* par=(BranchObj*)(bo->getParObj());
+ bo->unselect();
+ selection=NULL;
+ par->removeBranch(bo);
+ selection=par;
+ selection->select();
+ ensureSelectionVisible();
+ mapCenter->reposition();
+ adjustCanvasSize();
+ }
+ if (selection && typeid(*selection) ==typeid(FloatImageObj) )
+ {
+ setChanged();
+ saveState(PartOfMap,selection->getParObj());
+ FloatImageObj* fio=dynamic_cast (selection);
+ BranchObj* par=(BranchObj*)(fio->getParObj());
+ fio->unselect();
+ selection=NULL;
+ par->removeFloatImage(fio);
+ selection=par;
+ selection->select();
+ ensureSelectionVisible();
+ mapCenter->reposition();
+ adjustCanvasSize();
+ }
+}
+
+LinkableMapObj* MapEditor::getSelection()
+{
+ return selection;
+}
+
+bool MapEditor::select (QString s)
+{
+ LinkableMapObj *lmo=mapCenter;
+ QString part;
+ QString typ;
+ QString num;
+ while (!s.isEmpty() )
+ {
+ part=s.section(",",0,0);
+ typ=part.left (3);
+ num=part.right(part.length() - 3);
+
+ if (typ=="mc:")
+ {
+ if (num=="")
+ break;
+ else
+ lmo=mapCenter->getBranchNum (num.toUInt());
+ } else
+ if (typ=="bo:")
+ lmo=((BranchObj*)(lmo))->getBranchNum (num.toUInt());
+ else
+ if (typ=="fi:")
+ lmo=((BranchObj*)(lmo))->getFloatImageNum (num.toUInt());
+
+
+
+ if (!lmo) break;
+
+ if (s.contains(","))
+ s=s.right(s.length() - part.length() -1 );
+ else
+ break;
+ }
+
+ // Finally select the found object
+ if (lmo)
+ {
+ if (selection) selection->unselect();
+ selection=lmo;
+ selection->select();
+ adjustCanvasSize();
+ ensureSelectionVisible();
+ return true;
+ } else
+ return false;
+
+
+}
+
+void MapEditor::unselect()
+{
+ if (selection)
+ {
+ selectionLast=selection;
+ selection->unselect();
+ selection=NULL;
+ }
+}
+
+void MapEditor::reselect()
+{
+ if (selectionLast)
+ {
+ selection=selectionLast;
+ selection->select();
+ selectionLast=NULL;
+ }
+}
+
+void MapEditor::selectNextBranch()
+{
+ // Increase number of branch
+ if (selection)
+ {
+ QString s=selection->getSelectString();
+ QString part;
+ QString typ;
+ QString num;
+
+ // Where am I?
+ part=s.section(",",-1);
+ typ=part.left (3);
+ num=part.right(part.length() - 3);
+
+ s=s.left (s.length() -num.length());
+
+ // Go to next lmo
+ num=QString ("%1").arg(num.toUInt()+1);
+
+ s=s+num;
+
+ // Try to select this one
+ if (select (s)) return;
+
+ // We have no direct successor,
+ // try to increase the parental number in order to
+ // find a successor with same depth
+
+ int d=selection->getDepth();
+ int oldDepth=d;
+ int i;
+ bool found=false;
+ bool b;
+ while (!found && d>0)
+ {
+ s=s.section (",",0,d-1);
+ // replace substring of current depth in s with "1"
+ part=s.section(",",-1);
+ typ=part.left (3);
+ num=part.right(part.length() - 3);
+
+ if (d>1)
+ {
+ // increase number of parent
+ num=QString ("%1").arg(num.toUInt()+1);
+ s=s.section (",",0,d-2) + ","+ typ+num;
+ } else
+ {
+ // Special case, look at orientation
+ if (selection->getOrientation()==OrientRightOfCenter)
+ num=QString ("%1").arg(num.toUInt()+1);
+ else
+ num=QString ("%1").arg(num.toUInt()-1);
+ s=typ+num;
+ }
+
+ if (select (s))
+ // pad to oldDepth, select the first branch for each depth
+ for (i=d;icountBranches()>0)
+ s+=",bo:0";
+ else
+ break;
+ } else
+ break;
+ }
+
+ // try to select the freshly built string
+ found=select(s);
+ d--;
+ }
+ return;
+ }
+}
+
+void MapEditor::selectPrevBranch()
+{
+ // Decrease number of branch
+ if (selection)
+ {
+ QString s=selection->getSelectString();
+ QString part;
+ QString typ;
+ QString num;
+
+ // Where am I?
+ part=s.section(",",-1);
+ typ=part.left (3);
+ num=part.right(part.length() - 3);
+
+ s=s.left (s.length() -num.length());
+
+ // Go to next lmo
+ num=QString ("%1").arg(num.toUInt()-1);
+
+ s=s+num;
+
+ // Try to select this one
+ if (select (s)) return;
+
+ // We have no direct precessor,
+ // try to decrease the parental number in order to
+ // find a precessor with same depth
+
+ int d=selection->getDepth();
+ int oldDepth=d;
+ int i;
+ bool found=false;
+ bool b;
+ while (!found && d>0)
+ {
+ s=s.section (",",0,d-1);
+ // replace substring of current depth in s with "1"
+ part=s.section(",",-1);
+ typ=part.left (3);
+ num=part.right(part.length() - 3);
+
+ if (d>1)
+ {
+ // decrease number of parent
+ num=QString ("%1").arg(num.toUInt()-1);
+ s=s.section (",",0,d-2) + ","+ typ+num;
+ } else
+ {
+ // Special case, look at orientation
+ if (selection->getOrientation()==OrientRightOfCenter)
+ num=QString ("%1").arg(num.toUInt()-1);
+ else
+ num=QString ("%1").arg(num.toUInt()+1);
+ s=typ+num;
+ }
+
+ if (select(s))
+ // pad to oldDepth, select the last branch for each depth
+ for (i=d;icountBranches()>0)
+ s+=",bo:"+ QString ("%1").arg( ((BranchObj*)(selection))->countBranches()-1 );
+ else
+ break;
+ else
+ break;
+ }
+
+ // try to select the freshly built string
+ found=select(s);
+ d--;
+ }
+ return;
+ }
+}
+
+void MapEditor::selectUpperBranch()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ if (selection)
+ {
+ if (typeid(*selection) == typeid(BranchObj))
+ {
+ if (selection->getOrientation()==OrientRightOfCenter)
+ selectPrevBranch();
+ else
+ if (selection->getDepth()==1)
+ selectNextBranch();
+ else
+ selectPrevBranch();
+ }
+ }
+}
+
+void MapEditor::selectLowerBranch()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ if (selection)
+ {
+ if (typeid(*selection) == typeid(BranchObj))
+ {
+ if (selection->getOrientation()==OrientRightOfCenter)
+ selectNextBranch();
+ else
+ if (selection->getDepth()==1)
+ selectPrevBranch();
+ else
+ selectNextBranch();
+ }
+ }
+}
+
+
+void MapEditor::selectLeftBranch()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ BranchObj* bo;
+ BranchObj* par;
+ if (selection)
+ {
+ if (typeid(*selection) == typeid(MapCenterObj))
+ {
+ par= (BranchObj*) (selection);
+ bo=par->getLastSelectedBranch();
+ if (bo)
+ {
+ // Workaround for reselecting on left and right side
+ if (bo->getOrientation()==OrientRightOfCenter)
+ {
+ bo=par->getLastBranch();
+ }
+ if (bo)
+ {
+ par->unselect();
+ selection=bo;
+ selection->select();
+ adjustCanvasSize();
+ ensureSelectionVisible();
+ }
+ }
+ } else
+ {
+ par=(BranchObj*)(selection->getParObj());
+ if (selection->getOrientation()==OrientRightOfCenter)
+ {
+ if (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(FloatImageObj))
+ {
+ selection->unselect();
+ selection=par;
+ selection->select();
+ adjustCanvasSize();
+ ensureSelectionVisible();
+ }
+ } else
+ {
+ if (typeid(*selection) == typeid(BranchObj) )
+ {
+ bo=((BranchObj*)(selection))->getLastSelectedBranch();
+ if (bo)
+ {
+ selection->unselect();
+ selection=bo;
+ selection->select();
+ adjustCanvasSize();
+ ensureSelectionVisible();
+ }
+ }
+ }
+ }
+ }
+}
+
+void MapEditor::selectRightBranch()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ BranchObj* bo;
+ BranchObj* par;
+
+ if (selection)
+ {
+ if (typeid(*selection) == typeid(MapCenterObj))
+ {
+ par= (BranchObj*) (selection);
+ bo=par->getLastSelectedBranch();
+ if (bo)
+ {
+ // Workaround for relecting on left and right side
+ if (bo->getOrientation()==OrientLeftOfCenter)
+ bo=par->getFirstBranch();
+ if (bo)
+ {
+ par->unselect();
+ selection=bo;
+ selection->select();
+ ensureSelectionVisible();
+ }
+ }
+ } else
+ {
+ par=(BranchObj*)(selection->getParObj());
+ if (selection->getOrientation()==OrientLeftOfCenter)
+ {
+ if (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(FloatImageObj))
+ {
+ selection->unselect();
+ selection=par;
+ selection->select();
+ adjustCanvasSize();
+ ensureSelectionVisible();
+ }
+ } else
+ {
+ if (typeid(*selection) == typeid(BranchObj) )
+ {
+ bo=((BranchObj*)(selection))->getLastSelectedBranch();
+ if (bo)
+ {
+ selection->unselect();
+ selection=bo;
+ selection->select();
+ adjustCanvasSize();
+ ensureSelectionVisible();
+ }
+ }
+ }
+ }
+ }
+}
+
+void MapEditor::selectFirstBranch()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ BranchObj *bo1;
+ BranchObj *bo2;
+ BranchObj* par;
+ if (selection) {
+ if (typeid(*selection) == typeid(BranchObj))
+ {
+ bo1= (BranchObj*) (selection);
+ par=(BranchObj*)(bo1->getParObj());
+ bo2=par->getFirstBranch();
+ if (bo2) {
+ bo1->unselect();
+ selection=bo2;
+ selection->select();
+ ensureSelectionVisible();
+ }
+ }
+ adjustCanvasSize();
+ }
+}
+
+void MapEditor::selectLastBranch()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ BranchObj *bo1;
+ BranchObj *bo2;
+ BranchObj* par;
+ if (selection) {
+ if (typeid(*selection) == typeid(BranchObj))
+ {
+ bo1= (BranchObj*) (selection);
+ par=(BranchObj*)(bo1->getParObj());
+ bo2=par->getLastBranch();
+ if (bo2) {
+ bo1->unselect();
+ selection=bo2;
+ selection->select();
+ ensureSelectionVisible();
+ }
+ }
+ adjustCanvasSize();
+ }
+}
+
+void MapEditor::setColor(QColor c)
+{
+ actColor=c;
+}
+
+void MapEditor::selectBackgroundColor()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this );
+ if ( !col.isValid() ) return;
+ setBackgroundColor( col );
+ setChanged();
+}
+
+void MapEditor::setBackgroundColor(QColor c)
+{
+ mapCanvas->setBackgroundColor (c);
+}
+
+QColor MapEditor::pickColor()
+{
+ if (selection)
+ {
+ if (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj))
+ {
+ BranchObj *bo=(BranchObj*)(selection);
+ actColor=bo->getColor();
+ }
+ }
+ return actColor;
+}
+
+void MapEditor::colorItem()
+{
+ if (selection)
+ {
+ if (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj))
+ {
+ setChanged();
+ saveState(PartOfMap,selection);
+ BranchObj *bo=(BranchObj*)(selection);
+ bo->setColor(actColor, false); // color links, color childs
+ }
+ }
+}
+
+void MapEditor::colorBranch()
+{
+ if (selection)
+ {
+ if (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj))
+ {
+ setChanged();
+ saveState(PartOfMap,selection);
+ BranchObj *bo=(BranchObj*)(selection);
+ bo->setColor(actColor, true); // color links, color childs
+ }
+ }
+}
+
+
+void MapEditor::toggleStandardFlag(QString f)
+{
+ if (selection)
+ {
+ setChanged();
+ saveState(PartOfMap,selection);
+ ((BranchObj*)(selection))->toggleStandardFlag (f);
+ }
+}
+
+void MapEditor::setViewCenter()
+{
+ // transform to CanvasView Coord:
+ QPoint p=worldMatrix().map(movingCenter);
+ center ( p.x(), p.y());
+}
+
+
+BranchObj* MapEditor::findText (QString s, bool cs)
+{
+ if (!itFind)
+ { // Nothing found or new find process
+ if (EOFind)
+ // nothing found, start again
+ EOFind=false;
+ itFind=mapCenter->first();
+ }
+ bool searching=true;
+ bool foundNote=false;
+ while (searching && !EOFind)
+ {
+ if (itFind)
+ {
+ // Searching in Note
+ if (itFind->getNote().contains(s,cs))
+ {
+ if (selection!=itFind)
+ {
+ if (selection) ((BranchObj*)(selection))->unselect();
+ selection=itFind;
+ selection->select();
+ adjustCanvasSize();
+ ensureSelectionVisible();
+ }
+ if (textEditor->findText(s,cs))
+ {
+ searching=false;
+ foundNote=true;
+ }
+ }
+ // Searching in Heading
+ if (searching && itFind->getHeading().contains (s,cs) )
+ {
+ if (selection) ((BranchObj*)(selection))->unselect();
+ selection=itFind;
+ selection->select();
+ adjustCanvasSize();
+ ensureSelectionVisible();
+ searching=false;
+ }
+ }
+ if (!foundNote)
+ {
+ itFind=itFind->next();
+ if (!itFind) EOFind=true;
+ }
+ }
+ if (!searching)
+ {
+ adjustCanvasSize();
+ return (BranchObj*)(selection);
+ } else
+ return NULL;
+}
+
+void MapEditor::findReset()
+{ // Necessary if text to find changes during a find process
+ itFind=NULL;
+ EOFind=false;
+}
+
+void MapEditor::openURL()
+{
+ if (selection )
+ {
+ if (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj))
+ {
+ QString url=((BranchObj*)(selection))->getURL();
+
+ QProcess *proc = new QProcess( this );
+
+#if !defined(Q_OS_MACX)
+ proc->addArgument( settings.readEntry("/vym/mainwindow/readerURL","konqueror" ));
+#else
+ proc->addArgument( settings.readEntry("/vym/mainwindow/readerURL",
+ "/Applications/Safari.app/Contents/MacOS/Safari" ));
+#endif
+
+ proc->addArgument( url);
+
+ if ( !proc->start() )
+ // error handling
+ if (mainWindow->settingsURL() )
+ openURL();
+ }
+ }
+}
+
+void MapEditor::editURL()
+{
+ if (selection && (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj)) )
+ {
+ bool ok;
+ QString text = QInputDialog::getText(
+ "VYM", tr("Enter URL:"), QLineEdit::Normal,
+ ((BranchObj*)(selection))->getURL(), &ok, this );
+ if ( ok)
+ {
+ // user entered something and pressed OK
+ ((BranchObj*)(selection))->setURL (text);
+ updateActions();
+ setChanged();
+ }
+ }
+}
+
+void MapEditor::editHeading2URL()
+{
+ if (selection && (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj)) )
+ {
+ BranchObj *b=(BranchObj*)(selection);
+ b->setURL (b->getHeading());
+ updateActions();
+ setChanged();
+ }
+}
+
+void MapEditor::editBugzilla2URL()
+{
+ if (selection && (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj)) )
+ {
+ BranchObj *b=(BranchObj*)(selection);
+ b->setURL ("http://bugzilla.suse.de/show_bug.cgi?id="+b->getHeading());
+ updateActions();
+ setChanged();
+ }
+}
+
+void MapEditor::editVymLink()
+{
+ if (selection && (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj)) )
+ {
+ QFileDialog *fd=new QFileDialog( this,tr("VYM - Link to another map"));
+ fd->addFilter (QString (tr("vym map") + " (*.vym)"));
+ fd->setCaption(tr("VYM - Link to another map"));
+ if (! ((BranchObj*)(selection))->getVymLink().isEmpty() )
+ fd->setSelection( ((BranchObj*)(selection))->getVymLink() );
+ fd->show();
+
+ QString fn;
+ if ( fd->exec() == QDialog::Accepted )
+ ((BranchObj*)(selection))->setVymLink (fd->selectedFile() );
+ updateActions();
+ mapCenter->reposition();
+ adjustCanvasSize();
+ canvas()->update();
+ setChanged();
+ }
+}
+
+void MapEditor::deleteVymLink()
+{
+ if (selection && (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj)) )
+ {
+ ((BranchObj*)(selection))->setVymLink ("" );
+ updateActions();
+ mapCenter->reposition();
+ adjustCanvasSize();
+ canvas()->update();
+ setChanged();
+ }
+}
+
+QString MapEditor::getVymLink()
+{
+ if (selection && (typeid(*selection) == typeid(BranchObj) ||
+ typeid(*selection) == typeid(MapCenterObj)) )
+ {
+ return ((BranchObj*)(selection))->getVymLink();
+ }
+ return "";
+
+}
+
+void MapEditor::editMapInfo()
+{
+ ExtraInfoDialog dia;
+ dia.setMapName (getFileName() );
+ dia.setAuthor (mapCenter->getAuthor() );
+ dia.setComment(mapCenter->getComment() );
+
+ // Calc some stats
+ QString stats;
+ int i=0;
+ QCanvasItemList l=canvas()->allItems();
+ for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it)
+ i++;
+ stats+=QString ("%1 items on canvas\n").arg (i,6);
+
+ uint b=0;
+ uint f=0;
+ uint n=0;
+ BranchObj *bo;
+ bo=mapCenter->first();
+ while (bo)
+ {
+ if (!bo->getNote().isEmpty() ) n++;
+ f+= bo->countFloatImages();
+ b++;
+ bo=bo->next();
+ }
+ stats+=QString ("%1 branches\n").arg (b-1,6);
+ stats+=QString ("%1 notes\n").arg (n,6);
+ stats+=QString ("%1 images\n").arg (f,6);
+ dia.setStats (stats);
+
+ // Finally show dialog
+ if (dia.exec() == QDialog::Accepted)
+ {
+ mapCenter->setAuthor (dia.getAuthor() );
+ mapCenter->setComment (dia.getComment() );
+ setChanged();
+ }
+}
+
+void MapEditor::updateActions()
+{
+ if (getLinkColorHint()==HeadingColor)
+ actionFormatLinkColorHint->setOn(true);
+ else
+ actionFormatLinkColorHint->setOn(false);
+
+ switch (linkstyle)
+ {
+ case StyleLine:
+ actionFormatLinkStyleLine->setOn(true);
+ break;
+ case StyleParabel:
+ actionFormatLinkStyleParabel->setOn(true);
+ break;
+ case StylePolyLine:
+ actionFormatLinkStylePolyLine->setOn(true);
+ break;
+ case StylePolyParabel:
+ actionFormatLinkStylePolyParabel->setOn(true);
+ break;
+ default:
+ break;
+ }
+
+ QPixmap pix( 16, 16 );
+ pix.fill( mapCanvas->backgroundColor() );
+ actionFormatBackColor->setIconSet( pix );
+ pix.fill( deflinkcolor );
+ actionFormatLinkColor->setIconSet( pix );
+
+ actionEditUndo->setEnabled( mapChanged );
+ actionFileSave->setEnabled( mapUnsaved );
+
+ if (selection)
+ {
+ if ( (typeid(*selection) == typeid(BranchObj)) ||
+ (typeid(*selection) == typeid(MapCenterObj)) )
+ {
+ standardFlagsDefault->setEnabled (true);
+
+ if ( ((BranchObj*)(selection))->getURL().isEmpty() )
+ actionEditOpenURL->setEnabled (false);
+ else
+ actionEditOpenURL->setEnabled (true);
+ actionEditURL->setEnabled (true);
+ actionEditHeading2URL->setEnabled (true);
+ actionEditBugzilla2URL->setEnabled (true);
+
+ if ( ((BranchObj*)(selection))->getVymLink().isEmpty() )
+ {
+ actionEditOpenVymLink->setEnabled (false);
+ actionEditDeleteVymLink->setEnabled (false);
+ } else
+ {
+ actionEditOpenVymLink->setEnabled (true);
+ actionEditDeleteVymLink->setEnabled (true);
+ }
+ actionEditVymLink->setEnabled (true);
+
+ actionEditCopy->setEnabled (true);
+ actionEditCut->setEnabled (true);
+ actionEditPaste->setEnabled (true);
+ actionEditMoveUp->setEnabled (true);
+ actionEditMoveDown->setEnabled (true);
+ actionEditToggleScroll->setEnabled (true);
+ actionEditHeading->setEnabled (true);
+ actionEditDelete->setEnabled (true);
+ actionEditAddBranch->setEnabled (true);
+ actionEditAddBranchAbove->setEnabled (true);
+ actionEditAddBranchBelow->setEnabled (true);
+ actionEditImportAdd->setEnabled (true);
+ actionEditImportReplace->setEnabled (true);
+ actionEditSaveBranch->setEnabled (true);
+ actionEditSelectFirst->setEnabled (true);
+ actionEditSelectLast->setEnabled (true);
+ actionEditToggleFloatExport->setEnabled (false);
+ actionFormatPickColor->setEnabled (true);
+ actionFormatColorBranch->setEnabled (true);
+ actionFormatColorSubtree->setEnabled (true);
+ switch (selection->getFrameType())
+ {
+ case NoFrame:
+ actionFormatFrameNone->setOn(true);
+ break;
+ case Rectangle:
+ actionFormatFrameRectangle->setOn(true);
+ break;
+ default:
+ break;
+ }
+ }
+ if ( (typeid(*selection) == typeid(FloatImageObj)) )
+ {
+ standardFlagsDefault->setEnabled (false);
+
+ actionEditOpenURL->setEnabled (false);
+ actionEditURL->setEnabled (false);
+ actionEditHeading2URL->setEnabled (false);
+ actionEditBugzilla2URL->setEnabled (false);
+ actionEditOpenVymLink->setEnabled (false);
+ actionEditVymLink->setEnabled (false);
+ actionEditDeleteVymLink->setEnabled (false);
+
+ actionEditCopy->setEnabled (true);
+ actionEditCut->setEnabled (true);
+ actionEditPaste->setEnabled (false); //FIXME
+ actionEditMoveUp->setEnabled (false);
+ actionEditMoveDown->setEnabled (false);
+ actionEditToggleScroll->setEnabled (false);
+ actionEditHeading->setEnabled (false);
+ actionEditDelete->setEnabled (true);
+ actionEditAddBranch->setEnabled (false);
+ actionEditAddBranchAbove->setEnabled (false);
+ actionEditAddBranchBelow->setEnabled (false);
+ actionEditImportAdd->setEnabled (false);
+ actionEditSaveBranch->setEnabled (false);
+ actionEditImportReplace->setEnabled (false);
+ actionEditSelectFirst->setEnabled (false);
+ actionEditSelectLast->setEnabled (false);
+ actionEditToggleFloatExport->setOn
+ ( ((FloatImageObj*)(selection))->getFloatExport() );
+ actionFormatPickColor->setEnabled (false);
+ actionFormatColorBranch->setEnabled (false);
+ actionFormatColorSubtree->setEnabled (false);
+ }
+
+ } else
+ {
+ standardFlagsDefault->setEnabled (false);
+
+ actionEditCopy->setEnabled (false);
+ actionEditCut->setEnabled (false);
+ actionEditPaste->setEnabled (false);
+ actionEditMoveUp->setEnabled (false);
+ actionEditMoveDown->setEnabled (false);
+ actionEditToggleScroll->setEnabled (false);
+ actionEditOpenURL->setEnabled (false);
+ actionEditURL->setEnabled (false);
+ actionEditOpenVymLink->setEnabled (false);
+ actionEditVymLink->setEnabled (false);
+ actionEditDeleteVymLink->setEnabled (false);
+ actionEditHeading2URL->setEnabled (false);
+ actionEditBugzilla2URL->setEnabled (false);
+ actionEditHeading->setEnabled (false);
+ actionEditDelete->setEnabled (false);
+ actionEditAddBranch->setEnabled (false);
+ actionEditAddBranchAbove->setEnabled (false);
+ actionEditAddBranchBelow->setEnabled (false);
+ actionEditSaveBranch->setEnabled (false);
+ actionEditImportReplace->setEnabled (false);
+ actionEditSelectFirst->setEnabled (false);
+ actionEditSelectLast->setEnabled (false);
+ actionEditToggleFloatExport->setEnabled (false);
+ actionFormatPickColor->setEnabled (false);
+ actionFormatColorBranch->setEnabled (false);
+ actionFormatColorSubtree->setEnabled (false);
+ }
+}
+
+void MapEditor::setLinkStyle (LinkStyle ls)
+{
+ linkstyle=ls;
+
+ BranchObj *bo;
+ bo=mapCenter->first();
+ bo=bo->next();
+ while (bo)
+ {
+ bo->setLinkStyle(bo->getDefLinkStyle());
+ bo=bo->next();
+ }
+ //setChanged();
+ //saveState();
+}
+
+LinkStyle MapEditor::getLinkStyle ()
+{
+ return linkstyle;
+}
+
+void MapEditor::setLinkColor(QColor c)
+{
+ deflinkcolor=c;
+ updateActions();
+}
+
+void MapEditor::setLinkColorHint()
+{
+ // called from setLinkColorHint(lch) or at end of parse
+ BranchObj *bo;
+ bo=mapCenter->first();
+ while (bo)
+ {
+ bo->setLinkColor();
+ bo=bo->next();
+ }
+}
+
+void MapEditor::setLinkColorHint(LinkColorHint lch)
+{
+ linkcolorhint=lch;
+ setLinkColorHint();
+}
+
+void MapEditor::toggleLinkColorHint()
+{
+ if (linkcolorhint==HeadingColor)
+ linkcolorhint=DefaultColor;
+ else
+ linkcolorhint=HeadingColor;
+ BranchObj *bo;
+ bo=mapCenter->first();
+ while (bo)
+ {
+ bo->setLinkColor();
+ bo=bo->next();
+ }
+}
+
+LinkColorHint MapEditor::getLinkColorHint()
+{
+ return linkcolorhint;
+}
+
+QColor MapEditor::getDefLinkColor()
+{
+ return deflinkcolor;
+}
+
+void MapEditor::selectLinkColor()
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ QColor col = QColorDialog::getColor( deflinkcolor, this );
+ if ( !col.isValid() ) return;
+ setLinkColor( col );
+ setChanged();
+}
+
+void MapEditor::toggleScroll()
+{
+ if (selection && (typeid(*selection) == typeid(BranchObj)) )
+ {
+ BranchObj *bo=((BranchObj*)(selection));
+ if (bo->countBranches()==0) return;
+ if (bo->getDepth()==0) return;
+ setChanged();
+ saveState(PartOfMap,selection);
+ bo->toggleScroll();
+ adjustCanvasSize();
+ canvas()->update();
+ }
+}
+
+void MapEditor::unScrollAll()
+{
+ BranchObj *bo;
+ bo=mapCenter->first();
+ while (bo)
+ {
+ if (bo->isScrolled()) bo->toggleScroll();
+ bo=bo->next();
+ }
+}
+
+void MapEditor::loadFloatImage ()
+{
+ if (selection &&
+ (typeid(*selection) == typeid(BranchObj)) ||
+ (typeid(*selection) == typeid(MapCenterObj)) )
+ {
+ BranchObj *bo=((BranchObj*)(selection));
+
+ QFileDialog *fd=new QFileDialog( this,tr("vym - load image"));
+ fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
+ ImagePreview *p =new ImagePreview (fd);
+ fd->setContentsPreviewEnabled( TRUE );
+ fd->setContentsPreview( p, p );
+ fd->setPreviewMode( QFileDialog::Contents );
+ fd->setCaption(tr("vym - Load image"));
+ fd->setDir (lastImageDir);
+ fd->show();
+
+ QString fn;
+ if ( fd->exec() == QDialog::Accepted )
+ {
+ setChanged();
+ saveState(PartOfMap,selection);
+ QString fn=fd->selectedFile();
+ lastImageDir=fn.left(fn.findRev ("/"));
+ bo->addFloatImage();
+ // FIXME check if load was successful
+ bo->getLastFloatImage()->load(fn);
+ bo->getLastFloatImage()->setOriginalFilename(fn);
+ mapCenter->reposition();
+ adjustCanvasSize();
+ canvas()->update();
+ }
+ }
+}
+
+void MapEditor::saveFloatImage (int item)
+{
+ if (selection &&
+ (typeid(*selection) == typeid(FloatImageObj)) )
+ {
+ FloatImageObj *fio=((FloatImageObj*)(selection));
+ const char* fmt = saveImageFormatMenu->text(item);
+
+ QFileDialog *fd=new QFileDialog( this, tr("vym - save image as") + fmt);
+ fd->addFilter ("PNG (*.png)");
+ fd->addFilter ("BMP (*.bmp)");
+ fd->addFilter ("XBM (*.xbm)");
+ fd->addFilter ("JPG (*.jpg)");
+ fd->addFilter ("XPM (*.xpm)");
+ fd->addFilter ("GIF (*.gif)");
+ fd->addFilter ("PNM (*.pnm)");
+ fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
+ fd->setCaption(tr("vym - Save image as ") + fmt);
+ fd->setMode( QFileDialog::AnyFile );
+ fd->setSelection (fio->getOriginalFilename());
+ fd->show();
+
+ QString fn;
+ if ( fd->exec() == QDialog::Accepted )
+ {
+ if (QFile (fd->selectedFile()).exists() )
+ {
+ QMessageBox mb( "VYM",
+ tr("The file ") + fd->selectedFile() +
+ tr(" exists already. "
+ "Do you want to overwrite it?"),
+ QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::Cancel | QMessageBox::Escape,
+ QMessageBox::QMessageBox::NoButton );
+
+ mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
+ mb.setButtonText( QMessageBox::No, tr("Cancel"));
+ switch( mb.exec() )
+ {
+ case QMessageBox::Yes:
+ // save
+ break;;
+ case QMessageBox::Cancel:
+ // do nothing
+ return;
+ break;
+ }
+ }
+ fio->save (fd->selectedFile(),fmt);
+ }
+ }
+}
+
+void MapEditor::toggleFloatExport()
+{
+ if (selection &&
+ (typeid(*selection) == typeid(FloatImageObj))||
+ (typeid(*selection) == typeid(FloatObj)) )
+ {
+ FloatImageObj *fio=((FloatImageObj*)(selection));
+ fio->setFloatExport (actionEditToggleFloatExport->isOn() );
+ }
+}
+
+void MapEditor::setFrame(const FrameType &t)
+{
+ if (selection &&
+ (typeid(*selection) == typeid(BranchObj)) ||
+ (typeid(*selection) == typeid(MapCenterObj)) )
+ {
+ selection->setFrameType (t);
+ mapCenter->reposition();
+ selection->updateLink();
+ }
+}
+
+void MapEditor::importDir(BranchObj *dst, QDir d)
+{
+ if (selection &&
+ (typeid(*selection) == typeid(BranchObj)) ||
+ (typeid(*selection) == typeid(MapCenterObj)) )
+ {
+ BranchObj *bo;
+
+ // Traverse directories
+ d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks );
+ const QFileInfoList *dirlist = d.entryInfoList();
+ QFileInfoListIterator itdir( *dirlist );
+ QFileInfo *fi;
+
+ while ( (fi = itdir.current()) != 0 )
+ {
+ if (fi->fileName() != "." && fi->fileName() != ".." )
+ {
+ dst->addBranch();
+ bo=dst->getLastBranch();
+ bo->setHeading (fi->fileName() );
+ bo->setColor (QColor("blue"),false);
+ bo->toggleScroll();
+ if ( !d.cd(fi->fileName()) )
+ QMessageBox::critical (0,tr("Critical Import Error"),tr("Cannot find the directory"));
+ else
+ {
+ importDir (bo,d);
+ d.cdUp();
+ }
+ }
+ ++itdir;
+ }
+ // Traverse files
+ d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks );
+ const QFileInfoList *filelist = d.entryInfoList();
+ QFileInfoListIterator itfile( *filelist );
+
+ while ( (fi = itfile.current()) != 0 )
+ {
+ dst->addBranch();
+ bo=dst->getLastBranch();
+ bo->setHeading (fi->fileName() );
+ bo->setColor (QColor("black"),false);
+ ++itfile;
+ }
+ }
+}
+
+void MapEditor::importDir()
+{
+ if (selection &&
+ (typeid(*selection) == typeid(BranchObj)) ||
+ (typeid(*selection) == typeid(MapCenterObj)) )
+ {
+ QFileDialog *fd=new QFileDialog( this,tr("VYM - Choose directory structur to import"));
+ fd->setMode (QFileDialog::DirectoryOnly);
+ fd->addFilter (QString (tr("vym map") + " (*.vym)"));
+ fd->setCaption(tr("VYM - Choose directory structur to import"));
+ fd->show();
+
+ QString fn;
+ if ( fd->exec() == QDialog::Accepted )
+ {
+ BranchObj *bo=((BranchObj*)(selection));
+ importDir (bo,QDir(fd->selectedFile()) );
+ mapCenter->reposition();
+ adjustCanvasSize();
+ canvas()->update();
+ }
+ }
+}
+
+void MapEditor::testFunction()
+{
+ cout << "MapEditor::testFunction() called\n";
+}
+
+void MapEditor::ensureSelectionVisible()
+{
+ LinkableMapObj* lmo= dynamic_cast (selection);
+ QPoint p;
+ if (selection->getOrientation() == OrientLeftOfCenter)
+ p= worldMatrix().map(QPoint (lmo->x(),lmo->y()));
+ else
+ p= worldMatrix().map(QPoint (lmo->x()+lmo->width(),lmo->y()+lmo->height()));
+ ensureVisible (p.x(), p.y() );
+
+}
+
+void MapEditor::updateViewCenter()
+{
+ // Update movingCenter, so that we can zoom comfortably later
+ QRect rc = QRect( contentsX(), contentsY(),
+ visibleWidth(), visibleHeight() );
+ QRect canvasRect = inverseWorldMatrix().mapRect(rc);
+ movingCenter.setX((canvasRect.right() + canvasRect.left())/2);
+ movingCenter.setY((canvasRect.top() + canvasRect.bottom())/2);
+}
+
+void MapEditor::contentsContextMenuEvent ( QContextMenuEvent * e )
+{
+ // Lineedits are already closed by preceding
+ // mouseEvent, we don't need to close here.
+
+ QPoint p = inverseWorldMatrix().map(e->pos());
+ LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL);
+
+ if (lmo)
+ { // MapObj was found
+ if (selection != lmo)
+ {
+ // select the MapObj
+ if (selection) selection->unselect();
+ selection=lmo;
+ selection->select();
+ adjustCanvasSize();
+ }
+ // Context Menu
+ if (selection)
+ {
+ if (typeid(*selection)==typeid(BranchObj) ||
+ typeid(*selection)==typeid(MapCenterObj) )
+ {
+ // Context Menu on branch or mapcenter
+ updateActions();
+ branchContextMenu->popup(e->globalPos() );
+ }
+ if (typeid(*selection)==typeid(FloatImageObj))
+ {
+ // Context Menu on floatimage
+ updateActions();
+ floatimageContextMenu->popup(e->globalPos() );
+ }
+ }
+ } else
+ { // No MapObj found, we are on the Canvas itself
+ // Context Menu on Canvas
+ updateActions();
+ canvasContextMenu->popup(e->globalPos() );
+ }
+}
+
+void MapEditor::contentsMousePressEvent(QMouseEvent* e)
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ QPoint p = inverseWorldMatrix().map(e->pos());
+ LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL);
+
+ // Special case: CTRL is pressed, don't select anything
+ if (e->state() & QMouseEvent::ControlButton)
+ {
+ pickingColor=true;
+ setCursor (pickColorCursor);
+ return;
+ }
+
+ if (lmo)
+ { // MapObj was found
+ if (selection != lmo)
+ {
+ // select the MapObj
+ if (selection) selection->unselect();
+ selection=lmo;
+ selection->select();
+
+ adjustCanvasSize();
+ }
+
+ // Check, if systemFlag clicked
+ if (typeid(*selection)==typeid(BranchObj) ||
+ typeid(*selection)==typeid(MapCenterObj) )
+ {
+ QString foname=((BranchObj*)(selection))->getSystemFlagName(p);
+ if (!foname.isEmpty())
+ {
+ // Do not move, if systemFlag clicked
+ if (foname=="url")
+ openURL();
+ else
+ if (foname=="vymLink")
+ {
+ mainWindow->editOpenVymLink();
+ // tabWidget may change, better return now
+ // before segfaulting...
+ return;
+ } else
+ if (foname=="note")
+ mainWindow->windowToggleNoteEditor();
+ }
+ }
+
+ // Left Button Move Branches
+ if (e->button() == QMouseEvent::LeftButton )
+ {
+ movingObj=selection;
+ movingObj_start.setX( p.x() - selection->x() );
+ movingObj_start.setY( p.y() - selection->y() );
+ } else
+ // Middle Button Toggle Scroll
+ // (On Mac OS X this won't work, but we still have
+ // a button in the toolbar)
+ if (e->button() == QMouseEvent::MidButton )
+ {
+ toggleScroll();
+ }
+ updateActions();
+ } else
+ { // No MapObj found, we are on the Canvas itself
+ // Left Button move Pos of CanvasView
+ if (e->button() == QMouseEvent::LeftButton )
+ {
+ movingObj=NULL; // move Content not Obj
+ movingObj_start=e->globalPos();
+ movingCont_start=QPoint (contentsX(), contentsY() );
+ movingVec=QPoint(0,0);
+ setCursor(handOpenCursor);
+ }
+ }
+}
+
+void MapEditor::contentsMouseMoveEvent(QMouseEvent* e)
+{
+ // Move the selected MapObj
+ if ( selection && movingObj)
+ {
+ QPoint p = inverseWorldMatrix().map(e->pos());
+
+ // Now move the selection, but add relative position (movingObj_start)
+ // where selection
+ // was chosen with mousepointer. (This avoids flickering resp. jumping
+ // of selection back to absPos)
+
+ LinkableMapObj *lmosel;
+ lmosel = dynamic_cast (selection);
+
+ // Check if we could link
+ LinkableMapObj* lmo=mapCenter->findMapObj(p, lmosel);
+
+
+ if (typeid(*selection) == typeid(FloatImageObj))
+ {
+ setChanged();
+ saveState();
+ FloatObj *fo=(FloatObj*)(selection);
+ if (fo->getLinkStyle()==StyleUndef)
+ {
+ fo->setLinkStyle(fo->getDefLinkStyle());
+ fo->setLinkColor(fo->getParObj()->getLinkColor());
+ }
+ fo->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
+ fo->setRelPos();
+ fo->reposition();
+
+ // Relink float to new mapcenter or branch, if shift is pressed
+ // Only relink, if selection really has a new parent
+ if ( (e->state() & QMouseEvent::ShiftButton) && lmo &&
+ ( (typeid(*lmo)==typeid(BranchObj)) ||
+ (typeid(*lmo)==typeid(MapCenterObj)) ) &&
+ ( lmo != fo->getParObj())
+ )
+ {
+ if (typeid(*fo) == typeid(FloatImageObj))
+ {
+ FloatImageObj *fio=(FloatImageObj*)(fo);
+ ((BranchObj*)(lmo))->addFloatImage (fio);
+ fio->unselect();
+ ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
+ fio=((BranchObj*)(lmo))->getLastFloatImage();
+ fio->setRelPos();
+ fio->reposition();
+ selection=(LinkableMapObj*)(fio);
+ selection->select();
+ movingObj=(MapObj*)(fio);
+ // setLinkStyle calls updateLink, only set it once
+ if (fio->getLinkStyle()!=fio->getDefLinkStyle() )
+ fio->setLinkStyle (fio->getDefLinkStyle());
+
+ }
+ // TODO if (typeid(*selection) == typeid(FloatTextObj))
+ }
+ } else // selection != a FloatObj
+ {
+ if (lmosel->getDepth()==0)
+ {
+ if (e->state() == (LeftButton | !ShiftButton))
+ // If mapCenter is moved, move all the rest by default, too.
+ mapCenter->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
+ else
+ mapCenter->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
+ } else
+ {
+ if (lmosel->getDepth()==1)
+ {
+ // depth==1, mainbranch
+ setChanged();
+ saveState(PartOfMap,lmosel);
+ lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
+ } else
+ {
+ // depth>1
+ if (lmosel->getOrientation() == OrientLeftOfCenter)
+ // Add width of bbox here, otherwise alignRelTo will cause jumping around
+ lmosel->move(p.x() -movingObj_start.x()+lmosel->getBBox().width(),
+ p.y()-movingObj_start.y() );
+ else
+ lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
+ }
+ // reposition subbranch
+ lmosel->reposition();
+ ensureSelectionVisible();
+
+ if (lmo && (lmo!=selection) &&
+ (typeid(*lmo) == typeid(BranchObj) ||
+ (typeid(*lmo) == typeid(MapCenterObj) )
+ ) )
+ {
+ if (e->state() & QMouseEvent::ControlButton)
+ {
+ // Special case: CTRL to link below lmo
+ lmosel->setParObjTmp (lmo,p,+1);
+ }
+ else if (e->state() & QMouseEvent::ShiftButton)
+ lmosel->setParObjTmp (lmo,p,-1);
+ else
+ lmosel->setParObjTmp (lmo,p,0);
+ } else
+ {
+ if (lmo &&(lmo==selection))
+ // Could link to myself (happens sometimes...)
+ lmosel->unsetParObjTmp();
+ if (!lmo)
+ // no Obj under selection, go back to original Parent
+ lmosel->unsetParObjTmp();
+ }
+ } // depth>0
+
+ } // no FloatImageObj
+
+ canvas()->update();
+ return;
+ } // selection && moving_obj
+
+ // Move CanvasView
+ if (!movingObj && !pickingColor)
+ {
+ QPoint p=e->globalPos();
+ movingVec.setX(-p.x() + movingObj_start.x() );
+ movingVec.setY(-p.y() + movingObj_start.y() );
+ setContentsPos( movingCont_start.x() + movingVec.x(),
+ movingCont_start.y() + movingVec.y());
+
+ updateViewCenter();
+ }
+}
+
+
+void MapEditor::contentsMouseReleaseEvent(QMouseEvent* e)
+{
+ LinkableMapObj *dst;
+ // Have we been picking color?
+ if (pickingColor)
+ {
+ pickingColor=false;
+ setCursor (ArrowCursor);
+ // Check if we are over another branch
+ dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), NULL);
+ if (dst && selection)
+ {
+ if (e->state() & QMouseEvent::ShiftButton)
+ {
+ ((BranchObj*)(selection))->setColor (((BranchObj*)(dst))->getColor(),false);
+ ((BranchObj*)(selection))->setLinkColor ();
+ }
+ else
+ {
+ ((BranchObj*)(selection))->setColor (((BranchObj*)(dst))->getColor(),true);
+ ((BranchObj*)(selection))->setLinkColor ();
+ }
+ }
+ return;
+ }
+ // Have we been moving something?
+ if ( selection && movingObj )
+ {
+ // Check if we are over another branch, but ignore
+ // any found LMOs, which are FloatObjs
+ dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ),
+ ((LinkableMapObj*)(selection)) );
+
+ if (dst &&
+ (typeid(*dst)!=typeid(BranchObj)&&typeid(*dst)!=typeid(MapCenterObj)))
+ {
+ dst=NULL;
+ }
+
+ // Now check, if we have been moving a branch
+ if (typeid(*selection) == typeid(BranchObj) )
+ {
+ // save the position in case we link to mapcenter
+ QPoint savePos=QPoint (selection->x(),selection->y() );
+
+ // Reset the temporary drawn link to the original one
+ ((LinkableMapObj*)(selection))->unsetParObjTmp();
+
+ if (dst )
+ {
+ setChanged();
+ saveState();
+ // TODO we also could check, if dest and src are on same branch,
+ // then it would be sufficient to saveState of this branch
+
+ // FIXME better introduce BO::move to speed up and keep IDs
+ copy(); // copy selection to clipboard
+ cutNoSave(); // remove selection here
+
+ selection->unselect();
+ selection=dst;
+ // Modifiers allow to insert above/below dst
+ if (e->state() & QMouseEvent::ShiftButton)
+ {
+ selection=pasteAtNoSave (((BranchObj*)(dst))->getNum());
+ if (selection) selection->select();
+ }
+ else if (e->state() & QMouseEvent::ControlButton)
+ {
+ selection=pasteAtNoSave (((BranchObj*)(dst))->getNum()+1);
+ if (selection) selection->select();
+ }
+ else
+ {
+ selection=pasteNoSave();
+ selection->select();
+ if (dst->getDepth()==0)
+ ((BranchObj*)(selection))->move (savePos);
+ }
+ }
+ // Draw the original link, before selection was moved around
+ mapCenter->reposition();
+ }
+ // Finally resize canvas, if needed
+ adjustCanvasSize();
+ canvas()->update();
+ movingObj=NULL;
+ } else
+ { // maybe we moved View: set old cursor
+ setCursor (ArrowCursor);
+ }
+}
+
+void MapEditor::contentsMouseDoubleClickEvent(QMouseEvent* e)
+{
+ // Finish open lineEdits
+ if (lineedit) finishedLineEditNoSave();
+
+ if (e->button() == QMouseEvent::LeftButton )
+ {
+ QPoint p = inverseWorldMatrix().map(e->pos());
+ LinkableMapObj *lmo=mapCenter->findMapObj(p, NULL);
+ if (lmo) { // MapObj was found
+ // First select the MapObj than edit heading
+ if (selection) selection->unselect();
+ selection=lmo;
+ selection->select();
+ setChanged();
+ saveState(PartOfMap,selection);
+ editHeading();
+ }
+ }
+}
+
+void MapEditor::resizeEvent (QResizeEvent* e)
+{
+ QCanvasView::resizeEvent( e );
+
+ QString s="";
+ if (!fileName.isEmpty()) s=fileName;
+ adjustCanvasSize();
+}
+
diff -r 000000000000 -r 7a96bd401351 mapeditor.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mapeditor.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,197 @@
+#ifndef MAPEDITOR_H
+#define MAPEDITOR_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "mapcenterobj.h"
+#include "misc.h"
+
+class MapEditor : public QCanvasView , public xmlObj {
+ Q_OBJECT
+
+public:
+ MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, WFlags f=0);
+ ~MapEditor();
+ QColor color();
+ QColor backgroundColor();
+ MapCenterObj* getMapCenter();
+ QCanvas* getCanvas();
+ void adjustCanvasSize();// adjust canvas size to map and scrollview
+ bool blockReposition(); // block while load or undo
+
+private:
+ void makeTmpDirs(); // create temporary directories
+ void delTmpDirs(); // delete temporary directories
+ void makeSubDirs(const QString&);
+ // create subdirs in dir
+ QString saveToDir(const QString&,const QString &,bool, const QPoint
+ &,SaveMode);
+ void saveState(); // save actual state to backup
+ void saveState(const SaveMode&, LinkableMapObj *);
+
+private slots:
+ void finishedLineEditNoSave();
+
+public:
+ bool isDefault(); // false, if map was changed once
+ bool isUnsaved(); // save necessary
+ bool hasChanged(); // undo possible
+ void setChanged(); // called from NoteEditor via LMO
+ void closeMap();
+ void setFilePath (QString);
+ void setFilePath (QString,QString);
+ QString getFilePath (); // Full path e.g. "/home/tux/map.xml"
+ QString getFileName (); // e.g. "map.xml"
+ QString getMapName (); // e.g. "map"
+ QString getDestPath (); // e.g. "/home/tux/map.vym"
+ int load (QString&, const LoadMode &); // newmap, import/replace selection
+ int save(const SaveMode &); // Save map
+ void setZipped(bool); // save map zipped
+ bool saveZipped(); // 1 if file will be saved zipped
+ void print(); // print canvas
+private:
+ QPixmap getPixmap();
+public:
+ void exportImage (QString fn); // export as PNG
+ void exportImage (QString fn, int); // export in given format
+ void exportASCII();
+ void exportXML(const QString&); // export to directory
+ void clear(); // clear map
+ void undo(); // undo last action
+ void copy(); // copy branch to clipboard
+private:
+ LinkableMapObj* pasteNoSave(); // paste clipboard to branch
+ LinkableMapObj* pasteAtNoSave(int); // paste clipboard to branch at position i
+ void cutNoSave(); // cut to clipboard
+public:
+ void paste(); // paste clipboard to branch and backup
+ void cut(); // cut to clipboard and backup
+ void moveBranchUp();
+ void moveBranchDown();
+ void editHeading();
+ void addNewBranch(int); // pos allows to add above/below selection
+ void deleteSelection();
+ LinkableMapObj* getSelection(); // returns selection
+ bool select(QString ); // Select
+ void unselect(); // before changing current noteedit
+ void reselect(); // after changing current noteedit
+private:
+ void selectNextBranch(); // Increment number of branch
+ void selectPrevBranch(); // Decrement number of branch
+public:
+ void selectUpperBranch();
+ void selectLowerBranch();
+ void selectLeftBranch();
+ void selectRightBranch();
+ void selectFirstBranch();
+ void selectLastBranch();
+ void setColor(QColor);
+ void selectBackgroundColor();
+ void setBackgroundColor(QColor);
+ QColor pickColor();
+ void colorItem();
+ void colorBranch();
+ void toggleStandardFlag(QString);
+ virtual void setViewCenter(); // needed for zooming
+ BranchObj* findText(QString,bool); // Find object
+ void findReset(); // Reset Find
+ void openURL(); // open URL in external browser
+ void editURL(); // edit the URL
+ void editHeading2URL(); // copy heading to URL
+ void editBugzilla2URL(); // create URL to Bugzilla
+ void editVymLink(); // edit link to another map
+ void deleteVymLink(); // delete link to another map
+ QString getVymLink(); // return path to map
+ void editMapInfo(); // dialog to enter author, ...
+ void updateActions(); // update e.g. format buttons
+ void setLinkStyle (LinkStyle); // Set style of link
+ LinkStyle getLinkStyle (); // requested in LMO
+ void setLinkColor(QColor); // default color of links
+ void setLinkColorHint(); // color of links
+ void setLinkColorHint(LinkColorHint); // color of links
+ LinkColorHint getLinkColorHint();
+ QColor getDefLinkColor();
+ void toggleLinkColorHint(); // after changing linkStyles
+ void selectLinkColor();
+ void toggleScroll();
+ void unScrollAll();
+ void loadFloatImage ();
+ void saveFloatImage (int);
+ void toggleFloatExport();
+ void setFrame(const FrameType &);
+private:
+ void importDir(BranchObj *,QDir);
+public:
+ void importDir();
+ void testFunction(); // FIXME just testing
+
+protected:
+ void ensureSelectionVisible();
+ virtual void updateViewCenter(); // needed for zooming
+ virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
+ virtual void contentsMousePressEvent(QMouseEvent*);
+ virtual void contentsMouseReleaseEvent(QMouseEvent*);
+ virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
+ virtual void contentsMouseMoveEvent(QMouseEvent*);
+
+private:
+ QCanvas* mapCanvas;
+ MapCenterObj* mapCenter;
+
+ bool adjustCanvasRequested; // collect requests until end of user event
+ BranchObj *editingBO; // entering Text into BO
+ QLineEdit* lineedit;
+
+ QColor actColor; // actual color
+ QColor deflinkcolor; // default color for links
+ LinkColorHint linkcolorhint;// use heading color or own color
+ LinkStyle linkstyle; // default style for links
+
+ QCursor handOpenCursor; // cursor while moving canvas view
+ QCursor pickColorCursor; // cursor while picking color
+ bool pickingColor; // true while picking Color CTRL-LeftButton
+
+ LinkableMapObj* selection; // select a LinkableMapObj
+ LinkableMapObj* selectionLast; // last selection
+ MapObj* movingObj; // moving a MapObj
+ QPoint movingObj_start; // rel. pos of mouse to absPos
+ QPoint movingCont_start; // inital pos of moving Content or
+ QPoint movingVec; // how far has Content moved
+ QPoint movingCenter; // used when zooming
+ QPrinter* printer; // Printing
+
+ bool mapDefault; // Flag if map is untouched
+ bool mapChanged; // Flag if undo is possible
+ bool mapUnsaved; // Flag if map should be saved
+ QString backupXML; // backup (XML) for undo
+ LinkableMapObj* undoSelection; // replace this LMO with vympart from backup
+ // if != NULL
+
+ bool printFrame; // Print frame around map
+ bool printFooter; // Print footer below map
+
+ bool zipped; // should map be zipped
+ QString fileName; // short name of file (for tab)
+ QString filePath; // path to file which will be saved
+ QString fileDir; // dir where file is saved
+ QString destPath; // path to .vym file (needed for vymlinks)
+ QString mapName; // fileName without ".vym"
+ QString lastImageDir; // save dir for adding images
+
+ bool isInteractive; // non interactive don't need tmpdirs
+ QString bakMapDir; // tmp directory with data for undo
+ bool blockreposition; // block while load or undo
+
+ BranchObj* itFind; // next object in find process
+ bool EOFind; // true, if search failed
+
+ QPoint exportOffset; // set before export, used in save
+ void resizeEvent( QResizeEvent * );
+};
+#endif
+
diff -r 000000000000 -r 7a96bd401351 mapobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mapobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,143 @@
+#include "mapobj.h"
+
+/////////////////////////////////////////////////////////////////
+// MapObj
+/////////////////////////////////////////////////////////////////
+MapObj::MapObj ()
+{
+ // TODO not used any longer...
+ cout << "Const MapObj (): Please set canvas somehow!!!\n";
+ // canvas=actMapEditor->getCanvas();
+ init ();
+}
+
+MapObj::MapObj (QCanvas* c)
+{
+// cout << "Const MapObj\n";
+ canvas=c;
+ init ();
+}
+
+
+MapObj::MapObj (MapObj* mo)
+{
+// cout << "CopyConst MapObj\n";
+ copy (mo);
+}
+
+MapObj::~MapObj ()
+{
+// cout << "Destr MapObj\n";
+}
+
+void MapObj::init ()
+{
+ absPos=QPoint(0,0);
+ visible=true;
+}
+
+void MapObj::copy(MapObj* other)
+{
+// canvas=other->canvas; // already set in constr. of child, use that one...
+ absPos=other->absPos;
+ bbox.setX (other->bbox.x() );
+ bbox.setY (other->bbox.y() );
+ bbox.setSize (QSize(other->bbox.width(), other->bbox.height() ) );
+}
+
+QCanvas* MapObj::getCanvas()
+{
+ return canvas;
+}
+
+int MapObj::x()
+{
+ return absPos.x();
+}
+
+int MapObj::y()
+{
+ return absPos.y();
+}
+
+int MapObj::width()
+{
+ return bbox.width();
+}
+
+int MapObj::height()
+{
+ return bbox.height();
+}
+
+void MapObj::move (double x, double y)
+{
+ int xi=static_cast (x);
+ int yi=static_cast (y);
+ absPos.setX( xi);
+ absPos.setY( yi);
+ bbox.moveTopLeft(QPoint(xi,yi));
+}
+
+void MapObj::moveBy (double x, double y)
+{
+ move (x+absPos.x(),y+absPos.y() );
+}
+
+bool MapObj::inBBox(QPoint p)
+{
+ if (p.x() >= bbox.left() && p.x() <= bbox.right()
+ && p.y() <= bbox.bottom() && p.y() >= bbox.top() )
+ return true;
+ return false;
+}
+
+QRect MapObj::getBBox()
+{
+ return bbox;
+}
+
+QRect MapObj::addBBox(QRect r1, QRect r2)
+{
+ QRect n;
+ // Set left border
+ if (r1.left() <= r2.left() )
+ n.setLeft(r1.left() );
+ else
+ n.setLeft(r2.left() );
+
+ // Set top border
+ if (r1.top() <= r2.top() )
+ n.setTop(r1.top() );
+ else
+ n.setTop(r2.top() );
+
+ // Set right border
+ if (r1.right() <= r2.right() )
+ n.setRight(r2.right() );
+ else
+ n.setRight(r1.right() );
+
+ // Set bottom
+ if (r1.bottom() <= r2.bottom() )
+ n.setBottom(r2.bottom() );
+ else
+ n.setBottom(r1.bottom() );
+ return n;
+}
+
+QSize MapObj::getSize()
+{
+ return bbox.size();
+}
+
+
+bool MapObj::isVisibleObj()
+{
+ return visible;
+}
+
+void MapObj::setVisibility(bool v)
+{
+ visible=v;
+}
diff -r 000000000000 -r 7a96bd401351 mapobj.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mapobj.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,48 @@
+#ifndef MAPOBJ_H
+#define MAPOBJ_H
+
+#include
+#include
+
+#include "misc.h"
+
+using namespace std;
+
+#define Z_BBOX 0
+#define Z_LINK 20
+#define Z_FRAME 50
+#define Z_SELBOX 60
+#define Z_ICON 80
+#define Z_TEXT 100
+
+class MapObj:public xmlObj {
+public:
+ MapObj ();
+ MapObj (QCanvas*);
+ MapObj (MapObj*);
+ virtual ~MapObj ();
+ virtual void init ();
+ virtual void copy (MapObj*);
+ virtual QCanvas* getCanvas();
+ virtual int x();
+ virtual int y();
+ virtual int width();
+ virtual int height();
+ virtual void move (double x,double y); // move to absolute Position
+ virtual void moveBy (double x,double y); // move to relative Position
+ virtual bool inBBox(QPoint); // Check if Point is in bbox
+ virtual QRect getBBox(); // returns bounding box
+ virtual QRect addBBox(QRect,QRect); // returns bbox which includes both boxes
+ virtual QSize getSize(); // returns size of bounding box
+ virtual bool isVisibleObj();
+ virtual void setVisibility(bool);
+protected:
+ QCanvas* canvas;
+ QRect bbox; // bounding box of MO itself
+ virtual void positionBBox()=0;
+ virtual void calcBBoxSize()=0;
+ QPoint absPos; // Position on canvas
+ bool visible;
+};
+
+#endif
diff -r 000000000000 -r 7a96bd401351 misc.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/misc.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,238 @@
+#include
+#include
+
+#include
+
+#include "misc.h"
+
+
+ostream &operator<< (ostream &stream, QPoint const &p)
+{
+ return (stream << "(" << p.x() << "," << p.y() << ")");
+}
+
+float getAngle(const QPoint &p)
+{
+ // Calculate angle of vector to y-axis
+ if (p.y()==0)
+ {
+ if (p.x()>=0)
+ return M_PI_2;
+ else
+ return 3* M_PI_2;
+ } else
+ {
+ if (p.y()>0)
+ return (float)(M_PI - atan ( (double)(p.x()) / (double)(p.y()) ) );
+ else
+ if (p.x()<0)
+ return (float)( 2*M_PI - atan ( (double)(p.x()) / (double)(p.y()) ) );
+ else
+ return (float)( - atan ( (double)(p.x()) / (double)(p.y()) ) );
+ }
+}
+
+QPoint normalise(const QPoint &p)
+{
+ // Calculate normalised position (fixed length)
+
+ double px=p.x();
+ double py=p.y();
+ double x;
+ double y;
+ double r=150;
+
+ if (px==0)
+ {
+ x=0;
+ if (py>=0)
+ y=r;
+ else
+ y=-r;
+ } else
+ {
+ double sign;
+ double a;
+ if (px>0)
+ sign=1;
+ else
+ sign=-1;
+
+ a=atan (py / px);
+ x=cos (a) * r *sign;
+ y=sin (a) * r *sign;
+ }
+ return QPoint ((int) (x),(int) (y));
+}
+
+QString maskPath(QString p)
+{
+ // Change " " to "\ " to enable blanks in filenames
+ p=p.replace(QChar('&'),"\\&");
+ return p.replace(QChar(' '),"\\ ");
+}
+
+QString convertToRel (const QString &src, const QString &dst)
+{
+ QString s=src;
+ QString d=dst;
+ int i;
+ // Find relative path from src to dst
+
+ // Remove the first "/"
+ if (s.section ("/",0,0).isEmpty())
+ {
+ s=s.right (s.length()-1);
+ d=d.right (d.length()-1);
+ }
+
+ // remove identical left parts
+ while (s.section("/",0,0) == d.section("/",0,0) )
+ {
+ i=s.find ("/");
+ s=s.right (s.length()-i-1);
+ d=d.right (d.length()-i-1);
+ }
+
+ int srcsep=s.contains("/");
+ int dstsep=d.contains("/");
+ if (srcsep >= dstsep )
+ {
+ // find path to go up first and then back to dst
+ i=1;
+ while (i<=srcsep)
+ {
+ d="../"+d;
+ i++;
+ }
+ }
+ return d;
+}
+
+// returns masked "<" ">" "&"
+QString quotemeta(const QString &s)
+{
+ QString r=s;
+ QRegExp rx("&(?!amp;)");
+ r.replace ( rx,"&");
+ rx.setPattern( ">");
+ r.replace ( rx,">");
+ rx.setPattern( "<");
+ r.replace ( rx,"<");
+ rx.setPattern( "\"");
+ r.replace ( rx,""");
+ return r;
+}
+
+int max(int a, int b)
+{
+ if (a>b)
+ return a;
+ return b;
+}
+
+int xmlObj::actindent=0; // make instance of actindent
+
+xmlObj::xmlObj()
+{
+ indentwidth=4;
+}
+
+
+// returns
+QString xmlObj::singleElement(QString s, QString at)
+{
+ return indent() + "<" + s +" " + at +" " + "/>\n";
+}
+
+// returns
+QString xmlObj::beginElement(QString s)
+{
+ return indent() + "<" + s + ">\n";
+}
+
+// returns
+QString xmlObj::beginElement(QString s, QString at)
+{
+ return indent() + "<" + s + " " + at + ">\n";
+}
+
+// returns
+QString xmlObj::endElement(QString s)
+{
+ return indent() + "" + s + ">\n";
+}
+
+// returns at="val"
+QString xmlObj::attribut(QString at, QString val)
+{
+ return " " + at + "=\"" + quotemeta (val) + "\"";
+}
+
+// returns val
+QString xmlObj::valueElement(QString el, QString val)
+{
+ return indent() + "<" + el + ">" + quotemeta(val) + "" +el + ">\n";
+}
+
+// returns val
+QString xmlObj::valueElement(QString el, QString val, QString at)
+{
+ return indent() + "<" + el + " " + at + ">" + quotemeta(val) + "" +el + ">\n";
+}
+
+void xmlObj::incIndent()
+{
+ actindent++;
+}
+
+void xmlObj::decIndent()
+{
+ actindent--;
+ if (actindent<0) actindent=0;
+}
+
+QString xmlObj::indent()
+{
+ QString s;
+ int i;
+ for (i=0; imax_w)
+ {
+ r=max_w / pix.width();
+ pix.resize(lrint(pix.width()*r), lrint(pix.height()*r));
+ // TODO not a resize, but a shrink/enlarge is needed here...
+ }
+ if (pix.height()>max_h)
+ {
+ r=max_h / pix.height();
+ pix.resize(lrint(pix.width()*r), lrint(pix.height()*r));
+ // TODO not a resize, but a shrink/enlarge is needed here...
+ }
+ setPixmap( pix );
+ }
+}
+
diff -r 000000000000 -r 7a96bd401351 misc.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/misc.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,64 @@
+#ifndef MISC_H
+#define MISC_H
+
+#include
+#include
+
+using namespace std;
+
+#define Z_BBOX 0
+#define Z_LINK 20
+#define Z_FRAME 50
+#define Z_SELBOX 60
+#define Z_ICON 80
+#define Z_TEXT 100
+
+enum LoadMode {NewMap,ImportAdd,ImportReplace};
+enum SaveMode {PartOfMap,CompleteMap};
+
+/////////////////////////////////////////////////////////////////////////////
+extern ostream &operator<< (ostream &stream, QPoint const &p);
+float getAngle(const QPoint &);
+QPoint normalise (const QPoint &);
+QString maskPath (QString );
+QString convertToRel (const QString &,const QString &);
+QString quotemeta(const QString&);
+int max (int,int);
+class BranchObj;
+class MapEditor;
+
+/////////////////////////////////////////////////////////////////////////////
+class xmlObj
+{
+public:
+ xmlObj();
+ QString singleElement(QString,QString);
+ QString beginElement(QString,QString);
+ QString beginElement(QString);
+ QString endElement (QString);
+ QString attribut (QString,QString);
+ QString valueElement(QString,QString);
+ QString valueElement(QString,QString,QString);
+ void incIndent();
+ void decIndent();
+ static int actindent;
+
+protected:
+ QString indent();
+ int indentwidth;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+#include
+#include
+#include
+
+class ImagePreview : public QLabel, public QFilePreview
+{
+public:
+ ImagePreview( QWidget * );
+ void previewUrl( const QUrl & );
+};
+
+#endif
diff -r 000000000000 -r 7a96bd401351 noteobj.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/noteobj.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,105 @@
+#include
+#include
+#include
+#include
+
+#include "noteobj.h"
+
+/////////////////////////////////////////////////////////////////
+// NoteObj
+/////////////////////////////////////////////////////////////////
+
+NoteObj::NoteObj()
+{
+ clear();
+}
+
+void NoteObj::copy (NoteObj other)
+{
+ note=other.note;
+ fonthint=other.fonthint;
+ filenamehint="";
+}
+
+void NoteObj::clear()
+{
+ note="";
+ fonthint="undef";
+ filenamehint="";
+}
+
+void NoteObj::setNote (const QString &s)
+{
+ note=s;
+}
+
+QString NoteObj::getNote()
+{
+ return note;
+}
+
+void NoteObj::setFontHint (const QString &s)
+{
+ // only for backward compatibility (pre 1.5 )
+ fonthint=s;
+}
+
+QString NoteObj::getFontHint()
+{
+ // only for backward compatibility (pre 1.5 )
+ return fonthint;
+}
+
+void NoteObj::setFilenameHint (const QString &s)
+{
+ filenamehint=s;
+}
+
+QString NoteObj::getFilenameHint()
+{
+ return filenamehint;
+}
+
+bool NoteObj::isEmpty ()
+{
+ return note.isEmpty();
+}
+
+QString NoteObj::saveToDir ()
+{
+ // QTextEdit may generate fontnames with unquoted &, like
+ // in "Lucida B&H". This is invalid in XML and thus would crash
+ // the XML parser
+ uint pos=0;
+ uint pos2;
+ bool inbracket=false;
+ bool inquot=false;
+ while (pos") inbracket=false;
+ if (note.mid(pos,1)=="\"" && inbracket)
+ {
+ if (!inquot)
+ inquot=true;
+ else
+ inquot=false;
+ }
+ if (note.mid(pos,1)=="&" && inquot)
+ {
+ // Now we are inside < " " >
+ // look for ending "
+ pos2=pos+1;
+ while (note.mid(pos2,1)!=";" && note.mid(pos2,1)!="\"")
+ pos2++;
+ if (note.mid(pos2,1)=="\"")
+ {
+ note.replace(pos,1,"&");
+ pos=pos2;
+ }
+ }
+ pos++;
+ }
+ return beginElement ("htmlnote",attribut("fonthint",fonthint)) + "\n"+ note+ "\n" +endElement ("htmlnote");
+}
+
diff -r 000000000000 -r 7a96bd401351 noteobj.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/noteobj.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,30 @@
+#ifndef NOTEOBJ_H
+#define NOTEOBJ_H
+
+#include
+
+class NoteObj;
+
+#include "misc.h"
+
+class NoteObj:public xmlObj
+{
+public:
+ NoteObj();
+ void copy (NoteObj);
+ void clear();
+ void setNote (const QString&);
+ QString getNote();
+ void setFontHint (const QString&);
+ QString getFontHint ();
+ void setFilenameHint (const QString&);
+ QString getFilenameHint ();
+ bool isEmpty();
+ QString saveToDir();
+
+private:
+ QString note;
+ QString fonthint;
+ QString filenamehint;
+};
+#endif
diff -r 000000000000 -r 7a96bd401351 options.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/options.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,144 @@
+#include "options.h"
+#include
+
+#include
+
+using namespace std;
+
+
+Option::Option()
+{
+ name="";
+ sName="";
+ lName="";
+ type=SwitchOption;
+ sarg="";
+ active=false;
+}
+
+void Option::set(const QString &n, const OptionType &t, const QString &s, const QString &l)
+{
+ sName="-"+s;
+ lName="--"+l;
+ type=t;
+ name=n;
+}
+
+QString Option::getName () { return name; }
+QString Option::getShort () { return sName; }
+QString Option::getLong() { return lName; }
+OptionType Option::getType() { return type; }
+void Option::setArg(const QString& s) { sarg=s; }
+QString Option::getArg() { return sarg; }
+void Option::setActive() { active=true; }
+bool Option::isActive() { return active; }
+
+///////////////////////////////////////////////////////////////
+Options::Options() {}
+
+int Options::parse()
+{
+ QStringList arglist;
+ int i=0;
+ while (iargc())
+ {
+ arglist.append (qApp->argv()[i]);
+ i++;
+ }
+
+ // Get program name
+ progname=arglist.first();
+ arglist.pop_front();
+
+ // Work through rest of options
+ bool isFile;
+ OptionList::iterator itopt;
+ QStringList::iterator itarg;
+ itarg=arglist.begin();
+ while (itarg!=arglist.end())
+ {
+ isFile=true;
+ if ((*itarg).left(1)=="-")
+ {
+ // Compare given option to all defined options
+ itopt=optlist.begin();
+ while (itopt!=optlist.end())
+ {
+ if ((*itarg)==(*itopt).getShort() ||
+ (*itarg)==(*itopt).getLong())
+ {
+ (*itopt).setActive();
+ isFile=false;
+ if ((*itopt).getType()==StringOption)
+ {
+ itarg++;
+ if (itarg==arglist.end())
+ {
+ cout << "Error: argument to option missing\n";
+ return 1;
+ }
+ (*itopt).setArg (*itarg);
+ isFile=false;
+ }
+ break;
+ }
+ itopt++;
+ }
+ if (isFile)
+ {
+ cout << "Error: Unknown argument "<<*itarg<
+#include
+
+enum OptionType {SwitchOption,StringOption};
+
+class Option
+{
+public:
+ Option();
+ void set (const QString &, const OptionType &, const QString &, const QString &);
+ QString getName();
+ QString getShort();
+ QString getLong();
+ OptionType getType();
+ void setArg(const QString &);
+ QString getArg();
+ void setActive();
+ bool isActive();
+private:
+ QString name;
+ OptionType type;
+ QString sName;
+ QString lName;
+ QString sarg;
+ bool active;
+};
+
+
+
+typedef QValueList
"," ");
+ if (parFrom>-1)
+ {
+ e->setCursorPosition (parFrom,indFrom);
+ e->cut();
+ // Tried to simply insert the changed text with
+ // e->insert (t,(uint)(QTextEdit::RemoveSelected));
+ // but then the html would be quoted. So I use the ugly
+ // way: insert a marker, replace it in whole text of QTextEdit
+ QString marker="R3PlAcEMeL4teR!";
+ e->insert (marker);
+ e->setText (e->text().replace(marker,t));
+ } else
+ e->setText(t);
+}
+
+void TextEditor::textJoinLines()
+{
+ int parFrom, parTo, indFrom, indTo;
+ e->getSelection (&parFrom,&indFrom,&parTo,&indTo);
+ QString t;
+ if (parFrom>-1)
+ t=e->selectedText();
+ else
+ t=e->text();
+ // In addition to textConvertPar it is sometimes
+ // useful to join all lines of a paragraph
+ QRegExp re("\n+
(?!
)");
+ re.setMinimal(true);
+ t.replace (re," ");
+
+ // Above we may have introduced new " " at beginning of a
+ // paragraph - remove it.
+ re.setPattern("
");
+ t.replace (re,"
");
+ if (parFrom>-1)
+ {
+ e->setCursorPosition (parFrom,indFrom);
+ e->cut();
+ // Tried to simply insert the changed text with
+ // e->insert (t,(uint)(QTextEdit::RemoveSelected));
+ // but then the html would be quoted. So I use the ugly
+ // way: insert a marker, replace it in whole text of QTextEdit
+ QString marker="R3PlAcEMeL4teR!";
+ e->insert (marker);
+ e->setText (e->text().replace(marker,t));
+ } else
+ e->setText(t);
+}
+
+QString TextEditor::textConvertToASCII(const QString &t)
+{
+ QString r=t;
+
+ // convert all " " to "\n"
+ QRegExp re("");
+ re.setMinimal(true);
+ r.replace (re,"\n");
+
+ // convert all "
" to "\n"
+ re.setPattern ("/p");
+ r.replace (re,"\n");
+
+ // remove all remaining tags
+ re.setPattern ("<.*>");
+ r.replace (re,"");
+
+ // convert "&", "<" and ">"
+ re.setPattern (">");
+ r.replace (re,">");
+ re.setPattern ("<");
+ r.replace (re,"<");
+ re.setPattern ("&");
+ r.replace (re,"&");
+ return r;
+}
+
+void TextEditor::textExportAsASCII()
+{
+ QString text = textConvertToASCII( e->text());
+ QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (ASCII) (*.txt);;All files (*)",
+ this,"export note dialog",tr("Export Note to single file (ASCII)") );
+ int ret=-1;
+
+ if ( !fn.isEmpty() )
+ {
+ QFile file (fn);
+ if (file.exists())
+ {
+ QMessageBox mb( "VYM",
+ tr("The file ") + fn +
+ tr(" exists already. "
+ "Do you want to overwrite it?"),
+ QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::Cancel | QMessageBox::Escape,
+ QMessageBox::NoButton );
+ mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
+ mb.setButtonText( QMessageBox::No, tr("Cancel"));
+ ret=mb.exec();
+ }
+ if (ret==QMessageBox::Cancel)
+ return;
+
+ // save
+ if ( !file.open( IO_WriteOnly ) )
+ statusBar()->message( QString("Could not write to %1").arg(filename),
+ statusbarTime );
+ else
+ {
+ QTextStream t( &file );
+ t << text;
+ file.close();
+
+ statusBar()->message( QString( "Note exported as %1" ).arg( fn ), statusbarTime );
+ }
+ }
+}
+
+
+void TextEditor::textPrint()
+{
+ printer->setFullPage(TRUE);
+ if ( printer->setup( this ) )
+ {
+ QPainter p( printer );
+ // Check that there is a valid device to print to.
+ if ( !p.device() ) return;
+ QPaintDeviceMetrics metrics( p.device() );
+ int dpiy = metrics.logicalDpiY();
+ int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins
+ QRect body( margin, margin, metrics.width() - 2*margin, metrics.height() - 2*margin );
+ QFont font( e->currentFont() );
+ font.setPointSize( 10 ); // we define 10pt to be a nice base size for printing
+
+ QSimpleRichText richText( e->text(), font,
+ e->context(),
+ e->styleSheet(),
+ e->mimeSourceFactory(),
+ body.height() );
+ richText.setWidth( &p, body.width() );
+ QRect view( body );
+ int page = 1;
+ do
+ {
+ richText.draw( &p, body.left(), body.top(), view, colorGroup() );
+ view.moveBy( 0, body.height() );
+ p.translate( 0 , -body.height() );
+ p.setFont( font );
+ p.drawText( view.right() - p.fontMetrics().width( QString::number( page ) ),
+ view.bottom() + p.fontMetrics().ascent() + 5, QString::number( page ) );
+ if ( view.top() >= richText.height() )
+ break;
+ printer->newPage();
+ page++;
+ } while (TRUE);
+ }
+}
+
+void TextEditor::textEditUndo()
+{
+}
+
+void TextEditor::toggleFonthint()
+{
+ setUpdatesEnabled (false);
+ e->selectAll (true);
+ if (!actionFormatUseFixedFont->isOn() )
+ e->setCurrentFont (varFont);
+ else
+ e->setCurrentFont (fixedFont);
+ e->selectAll (false);
+ setUpdatesEnabled (true);
+ repaint();
+}
+
+void TextEditor::setFixedFont()
+{
+ bool ok;
+ QFont font =QFontDialog::getFont(
+ &ok, fixedFont, this );
+ if ( ok )
+ // font is set to the font the user selected
+ fixedFont=font;
+}
+
+void TextEditor::setVarFont()
+{
+ bool ok;
+ QFont font =QFontDialog::getFont(
+ &ok, varFont, this );
+ if ( ok )
+ // font is set to the font the user selected
+ varFont=font;
+}
+
+void TextEditor::textBold()
+{
+ e->setBold( actionTextBold->isOn() );
+}
+
+void TextEditor::textUnderline()
+{
+ e->setUnderline( actionTextUnderline->isOn() );
+}
+
+void TextEditor::textItalic()
+{
+ e->setItalic( actionTextItalic->isOn() );
+}
+
+void TextEditor::textFamily( const QString &f )
+{
+ e->setFamily( f );
+}
+
+void TextEditor::textSize( const QString &p )
+{
+ e->setPointSize( p.toInt() );
+}
+
+
+void TextEditor::textColor()
+{
+ QColor col = QColorDialog::getColor( e->color(), this );
+ if ( !col.isValid() )
+ return;
+ e->setColor( col );
+ QPixmap pix( 16, 16 );
+ pix.fill( black );
+ actionTextColor->setIconSet( pix );
+}
+
+void TextEditor::textAlign( QAction *a )
+{
+ if ( a == actionAlignLeft )
+ e->setAlignment( AlignLeft );
+ else if ( a == actionAlignCenter )
+ e->setAlignment( AlignHCenter );
+ else if ( a == actionAlignRight )
+ e->setAlignment( AlignRight );
+ else if ( a == actionAlignJustify )
+ e->setAlignment( AlignJustify );
+}
+
+void TextEditor::fontChanged( const QFont &f )
+{
+ comboFont->lineEdit()->setText( f.family() );
+ comboSize->lineEdit()->setText( QString::number( f.pointSize() ) );
+ actionTextBold->setOn( f.bold() );
+ actionTextItalic->setOn( f.italic() );
+ actionTextUnderline->setOn( f.underline() );
+}
+
+void TextEditor::colorChanged( const QColor &c )
+{
+ QPixmap pix( 16, 16 );
+ pix.fill( c );
+ actionTextColor->setIconSet( pix );
+}
+
+void TextEditor::alignmentChanged( int a )
+{
+ if ( ( a == AlignAuto ) || ( a & AlignLeft ))
+ actionAlignLeft->setOn( true );
+ else if ( ( a & AlignHCenter ) )
+ actionAlignCenter->setOn( true );
+ else if ( ( a & AlignRight ) )
+ actionAlignRight->setOn( true );
+ else if ( ( a & AlignJustify ) )
+ actionAlignJustify->setOn( true );
+}
+
+
+
+void TextEditor::enableActions()
+{
+ actionFileLoad->setEnabled(true);
+ actionFileSave->setEnabled(true);
+ actionFileSaveAs->setEnabled(true);
+ actionFilePrint->setEnabled(true);
+ actionEditUndo->setEnabled(true);
+ actionEditRedo->setEnabled(true);
+ actionEditCopy->setEnabled(true);
+ actionEditCut->setEnabled(true);
+ actionEditPaste->setEnabled(true);
+ actionEditDeleteAll->setEnabled(true);
+ actionEditConvertPar->setEnabled(true);
+ actionEditJoinLines->setEnabled(true);
+ actionFormatUseFixedFont->setEnabled(true);
+}
+
+void TextEditor::disableActions()
+{
+ actionFileLoad->setEnabled(false);
+ actionFileSave->setEnabled(false);
+ actionFileSaveAs->setEnabled(false);
+ actionFilePrint->setEnabled(false);
+ actionEditUndo->setEnabled(false);
+ actionEditRedo->setEnabled(false);
+ actionEditCopy->setEnabled(false);
+ actionEditCut->setEnabled(false);
+ actionEditPaste->setEnabled(false);
+ actionEditDeleteAll->setEnabled(false);
+ actionEditConvertPar->setEnabled(false);
+ actionEditJoinLines->setEnabled(false);
+ actionFormatUseFixedFont->setEnabled(false);
+}
+
+
diff -r 000000000000 -r 7a96bd401351 texteditor.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/texteditor.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,123 @@
+#ifndef TEXTEDITOR_H
+#define TEXTEDITOR_H
+
+#include
+#include
+#include
+#include
+#include
+
+
+enum EditorState {inactiveEditor,emptyEditor,filledEditor};
+
+class TextEditor : public QMainWindow {
+ Q_OBJECT
+public:
+ TextEditor();
+ ~TextEditor();
+
+ bool isEmpty();
+ void setShowWithMain (bool);
+ bool showWithMain ();
+ void setFontHint(const QString&);
+ QString getFontHint();
+ QString getFontHintDefault();
+ void setFilename (const QString&);
+ QString getFilename ();
+ bool findText(const QString &, const bool &); // find Text
+
+protected:
+ void setupFileActions();
+ void setupEditActions();
+ void setupFormatActions();
+ void setupSettingsActions();
+ void closeEvent( QCloseEvent* );
+
+
+public:
+ QString getText();
+
+public slots:
+ void editorChanged(); // received when text() changed
+ void setText(QString); // set Text (by MapEditor)
+ void setInactive(); // Nothing can be entered
+ void editCopyAll();
+
+signals:
+ void textHasChanged();
+ void fontFamilyHasChanged();
+ void fontSizeHasChanged();
+
+private slots:
+ void textLoad();
+ void textSaveAs();
+ void textSave();
+ void textConvertPar();
+ void textJoinLines();
+ QString textConvertToASCII(const QString &);
+ void textExportAsASCII();
+ void textPrint();
+ void textEditUndo();
+ void toggleFonthint();
+ void setFixedFont();
+ void setVarFont();
+ void textBold();
+ void textUnderline();
+ void textItalic();
+ void textFamily( const QString &f );
+ void textSize( const QString &p );
+ void textColor();
+ void textAlign(QAction*);
+ void fontChanged( const QFont &f );
+ void colorChanged( const QColor &c );
+ void alignmentChanged( int a );
+ void enableActions();
+ void disableActions();
+
+private:
+ QPrinter *printer;
+ QTextEdit *e;
+ QPoint lastPos; // save last position of window
+ QString filename;
+
+ QBrush emptyPaper; // setting the background color
+ QBrush filledPaper; // depending on the state
+ QBrush inactivePaper; // depending on the state
+ EditorState state;
+ bool showwithmain; // same visibility as mainwindow?
+
+ QFont varFont;
+ QFont fixedFont;
+ QComboBox
+ *comboFont,
+ *comboSize;
+
+ QAction *actionFileLoad,
+ *actionFileSave,
+ *actionFileSaveAs,
+ *actionFilePrint,
+ *actionEditUndo,
+ *actionEditRedo,
+ *actionEditCopy,
+ *actionEditCut,
+ *actionEditPaste,
+ *actionEditDeleteAll,
+ *actionEditConvertPar,
+ *actionEditJoinLines,
+ *actionFormatUseFixedFont,
+ *actionSettingsVarFont,
+ *actionSettingsFixedFont,
+ *actionSettingsFonthintDefault,
+ *actionTextBold,
+ *actionTextUnderline,
+ *actionTextItalic,
+ *actionTextColor,
+ *actionAlignLeft,
+ *actionAlignCenter,
+ *actionAlignRight,
+ *actionAlignJustify;
+
+
+};
+
+#endif
diff -r 000000000000 -r 7a96bd401351 version.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/version.h Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,7 @@
+#ifndef VERSION_H
+#define VERSION_H
+
+#define __VYM_VERSION__ "1.6.0"
+#define __BUILD_DATE__ "January 4, 2005"
+
+#endif
diff -r 000000000000 -r 7a96bd401351 vym.pro
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vym.pro Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,81 @@
+TARGET = vym
+TRANSLATIONS += vym_de.ts
+
+TEMPLATE = app
+LANGUAGE = C++
+
+CONFIG += qt warn_on release
+
+DESTROOT = /usr
+
+target.path = $${DESTROOT}/bin
+INSTALLS += target
+
+support.files = styles/ scripts/ icons/
+support.path = $${DESTROOT}/share/vym
+INSTALLS += support
+
+doc.files = doc/*
+doc.path = $${DESTROOT}/share/doc/packages/vym
+INSTALLS += doc
+
+demo.files = demos/
+demo.path = $${DESTROOT}/share/vym
+INSTALLS += demo
+
+
+HEADERS += branchobj.h \
+ exports.h \
+ findwindow.h \
+ flagobj.h \
+ flagrowobj.h \
+ floatimageobj.h \
+ floatobj.h \
+ frameobj.h \
+ headingobj.h \
+ imageobj.h \
+ linkablemapobj.h \
+ mainwindow.h \
+ mapcenterobj.h \
+ mapeditor.h \
+ mapobj.h \
+ misc.h \
+ noteobj.h \
+ ornamentedobj.h \
+ process.h \
+ selection.h \
+ texteditor.h \
+ version.h \
+ xml.h \
+ settings.h \
+ options.h
+SOURCES += branchobj.cpp \
+ exports.cpp \
+ findwindow.cpp \
+ flagobj.cpp \
+ flagrowobj.cpp \
+ floatimageobj.cpp \
+ floatobj.cpp \
+ frameobj.cpp \
+ headingobj.cpp \
+ imageobj.cpp \
+ linkablemapobj.cpp \
+ main.cpp \
+ mainwindow.cpp \
+ mapcenterobj.cpp \
+ mapeditor.cpp \
+ mapobj.cpp \
+ misc.cpp \
+ noteobj.cpp \
+ ornamentedobj.cpp \
+ process.cpp \
+ selection.cpp \
+ texteditor.cpp \
+ xml.cpp \
+ settings.cpp \
+ options.cpp
+FORMS = exporthtmldialog.ui \
+ exportxhtmldialog.ui \
+ showtextdialog.ui \
+ extrainfodialog.ui
+
diff -r 000000000000 -r 7a96bd401351 vym_de.ts
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vym_de.ts Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,1574 @@
+
+
+ ExportHTMLDialog
+
+
+ Exportiere HTML
+
+
+
+ Verzeichnis:
+
+
+
+ Durchsuchen
+
+
+
+ Optionen
+
+
+
+ Bild der Map erzeugen
+
+
+
+ WIKI Stil verwenden
+
+
+
+ Ausgabe der Scripte anzeigen
+
+
+
+ Exportieren
+
+
+
+ Abbrechen
+
+
+
+ VYM - Exportiere HTML in Verzeichnis
+
+
+
+ Kritischer Fehler beim Exportieren
+
+
+
+ Nur Bild erzeugen
+
+
+
+ Verwende Zweigbeschriftung für URL
+
+
+
+ Verwende Globus Symbol für URLs
+
+
+
+ Zeige Ausgabe der externen Skripte
+
+
+
+ Default CSS Datei verwenden
+
+
+
+ ExportXHTMLDialog
+
+
+ Exportiere XHTML
+
+
+
+ Verzeichnis:
+
+
+
+ Durchsuchen
+
+
+
+ Optionen
+
+
+
+ Bild erzeugen
+
+
+
+ Text erzeugen
+
+
+
+ Zeige Ausgabe der externen Skripte
+
+
+
+ Exportieren
+
+
+
+ Abbrechen
+
+
+
+ VYM - Exportiere HTML in Verzeichnis
+
+
+
+ Kritischer Fehler
+
+
+
+ Konnte nicht starten
+
+
+
+ Exportiere XHTML
+
+
+
+ Export Verzeichnis:
+
+
+
+ Farbige Headings im Text
+
+
+
+ Warnung, falls Verzeichnis nicht leer ist
+
+
+
+ Stylesheets
+
+
+
+ CSS:
+
+
+
+ XSL:
+
+
+
+ VYM - Pfad zu CSS Datei
+
+
+
+ VYM - Pfad zu XSL Datei
+
+
+
+ Warnung
+
+
+
+ konnte nicht geöffnet werden!
+
+
+
+ Einstellungen in map speichern
+
+
+
+ Skripte
+
+
+
+ Vor Export:
+
+
+
+ Nach Export:
+
+
+
+ Die in der Map gespeicherten Einstellungen wollen Skripte starten:
+
+
+
+
+
+ Bitte prüfen Sie, ob Sie das in Ihrem
+System wirklich zulassen wollen!
+
+
+
+ VYM - Pfad für Prä-Export Skript
+
+
+
+ VYM -Pfad für Post-Export Skript
+
+
+
+ ExtraInfoDialog
+
+
+ VYM - Info
+
+
+
+ Map:
+
+
+
+ Author:
+
+
+
+ Kommentar:
+
+
+
+ Statistik:
+
+
+
+ Abbrechen
+
+
+
+ Schliessen
+
+
+
+ FindWindow
+
+
+ Neuer Suchbegriff
+
+
+
+ Abbrechen
+
+
+
+ Suchen
+
+
+
+ Main
+
+
+ &Datei
+
+
+
+ Neu
+
+
+
+ &Neu...
+
+
+
+ Öffnen
+
+
+
+ &Öffnen...
+
+
+
+ Speichern
+
+
+
+ Speichern &unter...
+
+
+
+ Speichern &unter...
+
+
+
+ Importiere Verzeichnisstruktur (experimentelle Funktion)
+
+
+
+ Importiere Verzeichnis
+
+
+
+ Exportiere als png-Grafik
+
+
+
+ &Export (png)
+
+
+
+ Drucken
+
+
+
+ &Drucken...
+
+
+
+ Schließen
+
+
+
+ Schlie&ßen
+
+
+
+ Beenden
+
+
+
+ B&eenden
+
+
+
+ &Bearbeiten
+
+
+
+ Rückgängig
+
+
+
+ &Rückgängig
+
+
+
+ Kopieren
+
+
+
+ &Kopieren
+
+
+
+ Ausschneiden
+
+
+
+ &Ausschneiden
+
+
+
+ Einfügen
+
+
+
+ Ein&fügen
+
+
+
+ Zweig nach oben bewegen
+
+
+
+ Zweig nach oben
+
+
+
+ Zweig nach unten bewegen
+
+
+
+ Zweig nach unten
+
+
+
+ Zweig einrollen
+
+
+
+ Alles aufrollen
+
+
+
+ Alle eingerollten Zweige aufrollen
+
+
+
+ Finde
+
+
+
+ URL öffnen
+
+
+
+ URL ändern
+
+
+
+ Beschriftung dieses Zweiges auch als URL verwenden
+
+
+
+ Beschriftung als URL übernehmen
+
+
+
+ Gehe zu einer weiteren Map. (Falls nötig wird die Map vorher geöffnet.)
+
+
+
+ Gehe zu einer weiteren Map.
+
+
+
+ Bearbeite Verbindung zu einer Map
+
+
+
+ Bearbeite Verbindung zu einer Map
+
+
+
+ Bearbeite Zweig-Überschrift
+
+
+
+ Bearbeite Zweig-Überschrift
+
+
+
+ Entfernen
+
+
+
+ Neuer Zweig
+
+
+
+ Neuer Zweig
+
+
+
+ Neuer Zweig - oben
+
+
+
+ Neuer Zweig - oben
+
+
+
+ Neuer Zweig - unten
+
+
+
+ Neuer Zweig - unten
+
+
+
+ Zweig oben
+
+
+
+ Zweig unten
+
+
+
+ Zweig links
+
+
+
+ Zweig rechts
+
+
+
+ Kind-Zweig
+
+
+
+ Oberster Zweig
+
+
+
+ Unterster Zweig
+
+
+
+ Lade Bild
+
+
+
+ &Format
+
+
+
+ Wähle Farbe
+
+
+
+ Wähle &Farbe
+
+
+
+ Farb übernehmen
+Tipp: Zum Kopieren einer Farbe kann man auch CTRL+linke Maustaste nehmen.
+
+
+
+ Farbe &übernehmen
+
+
+
+ Zweig färben
+
+
+
+ Zweig &färben
+
+
+
+ Unterbaum färben
+
+
+
+ &Unterbaum färben
+
+
+
+ Linie
+
+
+
+ Linie
+
+
+
+ Parabel
+
+
+
+ Dicke Linie
+
+
+
+ Dicke Linie
+
+
+
+ Dicke Parabel
+
+
+
+ Dicke Parabel
+
+
+
+ Kein Rahmen
+
+
+
+ Rechteck
+
+
+
+ Verbindungen haben Farbe der Beschriftungen
+
+
+
+ &Verbindungen haben Farbe der Beschriftungen
+
+
+
+ Farbe der Verbindungen
+
+
+
+ &Farbe der Verbindungen
+
+
+
+ Hintergrundfarbe
+
+
+
+ &Hintergrundfarbe
+
+
+
+ &Ansicht
+
+
+
+ Keine Vergrösserung
+
+
+
+ Keine Vergrösserung
+
+
+
+ Vergrössern
+
+
+
+ Verkleinern
+
+
+
+ Zeige Notiz Editor
+
+
+
+ &Nächstes Fenster
+
+
+
+ Nächstes Fenster
+
+
+
+ &Vorheriges Fenster
+
+
+
+ Vorheriges Fenster
+
+
+
+ &Einstellungen
+
+
+
+ pdf-Dateien öffnen mit...
+
+
+
+ URLs öffnen mit...
+
+
+
+ Zweig nach dem Einfügen neu beschriften
+
+
+
+ Zweig nach dem Einfügen auswählen
+
+
+
+ Beschriftung vor dem editieren auswählen
+
+
+
+ Beschriftung vor dem editieren auswählen
+
+
+
+ Einfügen in neuen Zweig
+
+
+
+ Delete Taste zum Löschen von Zweigen verwenden
+
+
+
+ Delete Taste zum Löschen von Zweigen verwenden
+
+
+
+ &Test
+
+
+
+ Test Flag
+
+
+
+ test Flag
+
+
+
+ Zähle Canvas Items
+
+
+
+ Zähle Items
+
+
+
+ Zeige Zwischenablage
+
+
+
+ Zeige Zwischenablage
+
+
+
+ Exportiere in Verzeichnis
+
+
+
+ Exportiere in Verzeichnis
+
+
+
+ &Hilfe
+
+
+
+ VYM Handbuch (pdf)
+
+
+
+ VYM Handbuch (pdf)
+
+
+
+ Information über VYM
+
+
+
+ Über VYM
+
+
+
+ Informationen zum QT Toolkit
+
+
+
+ Über QT
+
+
+
+ Speichere Bild
+
+
+
+ Die Datei
+
+
+
+ gibt es bereits. Wollen Sie sie
+
+
+
+ Überschreiben
+
+
+
+ Abbrechen
+
+
+
+ Diese Datei konnte nicht gespeichert werden:
+
+
+
+ Datei gespeichert:
+
+
+
+ Diese Datei konnte nicht gespeichert werden:
+
+
+
+ Die Map
+
+
+
+ wurde verändert aber noch nicht gespeichert. Wollen Sie
+
+
+
+ Speichern und Map schliessen
+
+
+
+ Änderungen verwerfen
+
+
+
+ Diese Map wurde noch nicht gespeichert. Wollen Sie
+
+
+
+ Speichern
+
+
+
+ Kritischer Fehler
+
+
+
+ Pfad für pdf-Anwendung:
+
+
+
+ Pfad zum Öffnen von URLs:
+
+
+
+ Speichern &unter...
+
+
+
+ Zuletzt geöffnete Dateien
+
+
+
+ Exportieren
+
+
+
+ als Bild
+
+
+
+ als ASCII Text (noch experimentell)
+
+
+
+ als ASCII
+
+
+
+ Bearbeite Map Info
+
+
+
+ Exportiere als XML
+
+
+
+ Exportiere als HTML
+
+
+
+ Das Verzeichnis
+
+
+
+ ist nicht leer.Riskieren sie es, das Verzeichnis zu überschreiben?
+
+
+
+
+ist bereits geöffnet. Die gleiche Map mehrfach in verschiedenen Ansichten zu öffnen
+kann beim Beenden von vym zu Problemen führen. Wollen Sie
+
+
+
+ Trotzdem öffnen
+
+
+
+ Exportiere XML in Verzeichnis
+
+
+
+ Kritischer Fehler
+
+
+
+ Konnte die Dokumentation vym.pdf
+nirgends finden.
+
+
+
+ Konnte kein Programm zum Anzeigen von vym.pdf
+finden. Bitte benutzen Sie Einstellungen->
+
+
+
+ Die Map
+
+
+
+ gibt es nicht
+Wollen Sie eine neue anlegen?
+
+
+
+ Anlegen
+
+
+
+ URL für Bugzilla anlegen
+
+
+
+ vym Verknüpfung ändern
+
+
+
+ vym Verknüfung löschen
+
+
+
+ vym Verknüpfung löschen
+
+
+
+ Kritischer Fehler beim Laden
+
+
+
+ Konnte unzip nicht starten, um Daten zu dekomprimieren.
+
+
+
+ unzip wurde nicht richtig beendet
+
+
+
+ Konnte keine map (*.xml) in .vym Datei finden.
+
+
+
+
+ Kritischer Fehler beim Speichern
+
+
+
+ Konnte zip nicht starten, um Daten zu komprimieren.
+
+
+
+ zip wurde nicht richtig beendet
+
+
+
+ Das Speichern der map als
+
+
+
+
+wird die map unkomprimiert schreiben.
+Dabei werden Verzeichnisse für die Bilder und Flags erzeugt
+und dabei evtl. andere Daten im Verzeichnis überschrieben
+
+
+
+ Weiter
+
+
+
+ Gespeichert:
+
+
+
+ vym-Information:
+
+
+
+ Keine Treffer gefunden für
+
+
+
+ Exportiere XHTML
+
+
+
+
+verwendet nicht das komprimierte vym Dateiformat.
+Wenn die Map unkomprimiert geschrieben werden soll,
+dann werden auch die Flags und Bilder im angegebenen
+Verzeichnis geschrieben, was evtl. bestehende Daten
+überschreiben kann
+
+Wollen Sie die Map beim Schreiben
+
+
+
+ komprimieren (vym default)
+
+
+
+ unkomprimiert lassen
+
+
+
+ Benutze für Export
+
+
+
+ Map an Auswahl anhängen
+
+
+
+ Import (hinzufügen)
+
+
+
+ Auswahl mit Map ersetzen
+
+
+
+ Import (ersetzen)
+
+
+
+ Auswahl speichern
+
+
+
+ Auswahl speichern
+
+
+
+ Lade vym Map
+
+
+
+ Import: Füge Map zu Auswahl hinzu
+
+
+
+ Import: Ersetze Auswahl mit Map
+
+
+
+ Fehler beim Speichern
+
+
+
+
+konnte vor dem Speichern nicht gelöscht werden
+
+
+
+ MapEditor
+
+
+ Notiz
+
+
+
+ WWW Dokument (extern)
+
+
+
+ Verbindung zu einer anderen Map
+
+
+
+ Teilbaum ist eingerollt
+
+
+
+ Teilbaum ist momentan ausgerollt
+
+
+
+ Vorsicht!
+
+
+
+ Wirklich?
+
+
+
+ ok!
+
+
+
+ Nicht ok!
+
+
+
+ Das geht nicht!
+
+
+
+ Gut
+
+
+
+ Schlecht
+
+
+
+ Zeitkritisch
+
+
+
+ Idee!
+
+
+
+ Wichtig
+
+
+
+ Unwichtig
+
+
+
+ Finde ich gut
+
+
+
+ Finde ich schlecht
+
+
+
+ Das liebe ich!
+
+
+
+ Kritischer Fehler beim Laden der Map
+
+
+
+ Kritischer Fehler beim Verarbeiten
+
+
+
+ Warnung: Altes Dateiformat
+
+
+
+ <h3>Altes Dateiformat gefunden</h3>Die gerade geladene Map verwendet ein unkomprimmiertes Format. Wird sie später gespeichert, so wird sie umgewandelt in das Format von Version
+
+
+
+ Kritischer Fehler beim Laden
+
+
+
+ Konnte Map nach dem Entpacken nicht öffnen:
+
+
+
+
+ Kritischer Fehler beim Speichern
+
+
+
+ Konnte nicht speichern:
+
+
+
+ Kritischer Fehler beim Speichern
+
+
+
+ gibt es nicht
+
+
+
+ VYM - Export (ASCII)
+
+
+
+ Die Datei
+
+
+
+ gibt es bereits. Wollen Sie sie
+
+
+
+ Überschreiben
+
+
+
+ Abbrechen
+
+
+
+ Kritischer Fehler beim Exportieren
+
+
+
+ Konnte Verzeichnis nicht anlegen
+
+
+
+ VYM - Export in Verzeichnis
+
+
+
+ VYM - Export in Verzeichnis
+
+
+
+ Das Verzeichnis
+
+
+
+ ist nicht leer.Riskieren sie es, das Verzeichnis zu überschreiben?
+
+
+
+ Kritischer Fehler beim Exportieren
+
+
+
+ Kritischer Fehler
+
+
+
+ Vielleicht wollen sie die Orginaldaten erneut laden
+Sorry für die Unannehmlichkeiten.
+
+
+
+ Neue URL:
+
+
+
+ VYM - Verbindung zu einer anderen Map
+
+
+
+ vym Map
+
+
+
+ VYM - Lade Bild
+
+
+
+ Bilder
+
+
+
+ vym - Lade Bild
+
+
+
+ vym - Speichere Bild als
+
+
+
+ vym - Speichere Bild als
+
+
+
+ Kritischer Fehler beim Importieren
+
+
+
+ Kann das Verzeichnis nicht finden
+
+
+
+ vym - Wähle Verzeichnisstruktur für Import
+
+
+
+ Gefährlich
+
+
+
+ Das könnte helfen
+
+
+
+ Neue Map
+
+
+
+ Kritischer Fehler beim Parsen
+der Sicherungskopie
+
+
+
+ MapEditor::exportXML konnte nicht öffnen:
+
+
+
+ QMessageBox
+
+
+ Kritischer Fehler
+
+
+
+ QObject
+
+
+ Neuer Zweig
+
+
+
+ Neue Map
+
+
+
+ Das ist kein Bild.
+
+
+
+ ShowTextDialog
+
+
+ VYM - Info
+
+
+
+ Schliessen
+
+
+
+ TextEditor
+
+
+ &Datei
+
+
+
+ Importiere
+
+
+
+ &Importiere
+
+
+
+ Exportiere Notiz
+
+
+
+ &Export
+
+
+
+ Exportiere Notiz unter...
+
+
+
+ Exportiere &unter...
+
+
+
+ Drucke Notiz
+
+
+
+ &Drucken
+
+
+
+ &Bearbeiten
+
+
+
+ Rückgängig
+
+
+
+ R&ückgängig
+
+
+
+ Wiederherstellen
+
+
+
+ Wieder&herstellen
+
+
+
+ Alles auswählen und kopieren
+
+
+
+ &Alles auswählen und kopieren
+
+
+
+ Kopieren
+
+
+
+ &Kopieren
+
+
+
+ Ausschneiden
+
+
+
+ &Ausschneiden
+
+
+
+ Einfügen
+
+
+
+ Ein&fügen
+
+
+
+ Alles löschen
+
+
+
+ Alles &löschen
+
+
+
+ &Format
+
+
+
+ Benutze fixe Zeichenbreite
+
+
+
+ &fixe Zeichenbreite
+
+
+
+ &Einstellungen
+
+
+
+ Wähle Zeichensatz mit fixer Breite
+
+
+
+ Wähle Zeichensatz mit f&ixer Breite
+
+
+
+ Wähle Zeichensatz mit variabler Breite
+
+
+
+ Wähle Zeichensatz mit v&ariabler Breite
+
+
+
+ Verwende fixen Zeichensatz per default
+
+
+
+ Verwende fixen Zeichensatz p&er default
+
+
+
+ Exportiere Notiz (HTML)
+
+
+
+ Exportiere Notiz als (HTML)
+
+
+
+ Exportiere Notiz &als... (HTML)
+
+
+
+ Exportiere Notiz als (ASCII)
+
+
+
+ Exportiere a&ls (ASCII)
+
+
+
+ Feste Zeichenbreite für den Text verwenden
+
+
+
+ &Farbe...
+
+
+
+ F&ett
+
+
+
+ K&ursiv
+
+
+
+ &Unterstrichen
+
+
+
+ &Linksbündig
+
+
+
+ &Zentriert
+
+
+
+ &Rechtsbündig
+
+
+
+ &Blocksatz
+
+
+
+ Notiz in eine einzelne Datei exportieren
+
+
+
+ Die Datei
+
+
+
+ gibt es bereits. Wollen Sie sie
+
+
+
+ Überschreiben
+
+
+
+ Abbrechen
+
+
+
+ Konnte Notiz nicht exportieren
+
+
+
+ Notiz als ASCII in eine einzelne Datei ausgeben
+
+
+
+ Absätze in Zeilenbrüche umwandeln
+
+
+
+ &Absätze umwandeln
+
+
+
+ Alle Zeilenumbrüche eines Absatzes zu vereinen
+
+
+
+ &Zeilen vereinen
+
+
+
+ Zeichensatz für gesamten Text umschalten
+
+
+
+ Zeichensatz &umschalten
+
+
+
diff -r 000000000000 -r 7a96bd401351 xml.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xml.cpp Sun Jan 30 12:58:47 2005 +0000
@@ -0,0 +1,519 @@
+#include "xml.h"
+
+#include
+#include
+#include
+#include
+
+#include "misc.h"
+#include "settings.h"
+
+#include "version.h"
+
+static BranchObj *lastBranch;
+static FloatObj *lastFloat;
+
+extern Settings settings;
+
+mapBuilderHandler::mapBuilderHandler() {}
+
+mapBuilderHandler::~mapBuilderHandler() {}
+
+QString mapBuilderHandler::errorProtocol() { return errorProt; }
+
+bool mapBuilderHandler::startDocument()
+{
+ errorProt = "";
+ state = StateInit;
+ laststate = StateInit;
+ branchDepth=0;
+ htmldata="";
+ isVymPart=false;
+ return true;
+}
+
+
+QString mapBuilderHandler::parseHREF(QString href)
+{
+ QString type=href.section(":",0,0);
+ QString path=href.section(":",1,1);
+ if (!tmpDir.endsWith("/"))
+ return tmpDir + "/" + path;
+ else
+ return tmpDir + path;
+}
+
+bool mapBuilderHandler::startElement ( const QString&, const QString&,
+ const QString& eName, const QXmlAttributes& atts )
+{
+ QColor col;
+// cout << "startElement <"< state="<setVersion(atts.value( "version" ));
+ if (!mc->checkVersion())
+ QMessageBox::warning( 0, "Warning: Version Problem" ,
+ "
Map is newer than VYM
"
+ "
The map you are just trying to load was "
+ "saved using vym " +atts.value("version")+". "
+ "The version of this vym is " __VYM_VERSION__
+ ". If you run into problems after pressing "
+ "the ok-button below, updating vym should help.");
+
+ }
+ if (loadMode==NewMap)
+ {
+ if (!atts.value( "author").isEmpty() )
+ {
+ mc->setAuthor(atts.value( "author" ) );
+ }
+ if (!atts.value( "comment").isEmpty() )
+ {
+ mc->setComment (atts.value( "comment" ) );
+ }
+ if (!atts.value( "backgroundColor").isEmpty() )
+ {
+ col.setNamedColor(atts.value("backgroundColor"));
+ mc->getCanvas()->setBackgroundColor(col);
+ }
+ if (!atts.value( "linkColorHint").isEmpty() )
+ {
+ if (atts.value("linkColorHint")=="HeadingColor")
+ me->setLinkColorHint(HeadingColor);
+ else
+ me->setLinkColorHint(DefaultColor);
+ }
+ if (!atts.value( "linkStyle").isEmpty() )
+ {
+ QString s=atts.value("linkStyle");
+ if (s=="StyleLine")
+ me->setLinkStyle(StyleLine);
+ else
+ if (s=="StyleParabel")
+ me->setLinkStyle(StyleParabel);
+ else
+ if (s=="StylePolyLine")
+ me->setLinkStyle(StylePolyLine);
+ else
+ me->setLinkStyle(StylePolyParabel);
+ }
+ if (!atts.value( "linkColor").isEmpty() )
+ {
+ col.setNamedColor(atts.value("linkColor"));
+ me->setLinkColor(col);
+ }
+ }
+ } else if ( eName == "select" && state == StateMap )
+ {
+ state=StateMapSelect;
+ } else if ( eName == "setting" && state == StateMap )
+ {
+ state=StateMapSetting;
+ if (loadMode==NewMap)
+ readSettingAttr (atts);
+ } else if ( eName == "mapcenter" && state == StateMap )
+ {
+ state=StateMapCenter;
+ if (loadMode==NewMap)
+ {
+ // Really use the found mapcenter as MCO in a new map
+ lastBranch=mc; // avoid empty pointer
+ } else
+ {
+ // Treat the found mapcenter as a branch
+ // in an existing map
+ LinkableMapObj* lmo=me->getSelection();
+ if (lmo && (typeid(*lmo) == typeid(BranchObj) )
+ || (typeid(*lmo) == typeid(MapCenterObj) ) )
+ {
+ lastBranch=(BranchObj*)(lmo);
+ if (loadMode==ImportAdd)
+ {
+ lastBranch->addBranch();
+ lastBranch=lastBranch->getLastBranch();
+ } else
+ lastBranch->clear();
+ } else
+ return false;
+ }
+ readBranchAttr (atts);
+ } else if ( (eName == "standardflag" ||eName == "standardFlag") && state == StateMapCenter)
+ {
+ state=StateMapCenterStandardFlag;
+ } else if ( eName == "heading" && state == StateMapCenter)
+ {
+ state=StateMapCenterHeading;
+ if (!atts.value( "textColor").isEmpty() )
+ {
+ col.setNamedColor(atts.value("textColor"));
+ lastBranch->setColor(col ,false );
+ }
+ } else if ( eName == "note" && state == StateMapCenter)
+ { // only for backward compatibility (<1.4.6). Use htmlnote now.
+ state=StateMapCenterNote;
+ if (!readNoteAttr (atts) ) return false;
+ } else if ( eName == "htmlnote" && state == StateMapCenter)
+ {
+ laststate=state;
+ state=StateHtmlNote;
+ } else if ( eName == "floatimage" && state == StateMapCenter )
+ {
+ state=StateMapCenterFloatImage;
+ lastBranch->addFloatImage();
+ lastFloat=lastBranch->getLastFloatImage();
+ if (!readFloatImageAttr(atts)) return false;
+ } else if ( eName == "branch" && state == StateMap)
+ {
+ // This is used in vymparts, which have no mapcenter!
+ isVymPart=true;
+ state=StateBranch;
+ LinkableMapObj* lmo=me->getSelection();
+ if (lmo && (typeid(*lmo) == typeid(BranchObj) )
+ || (typeid(*lmo) == typeid(MapCenterObj) ) )
+ {
+ lastBranch=(BranchObj*)(lmo);
+ if (loadMode==ImportAdd)
+ {
+ lastBranch->addBranch();
+ lastBranch=lastBranch->getLastBranch();
+ } else
+ lastBranch->clear();
+ } else
+ return false;
+ branchDepth=1;
+ readBranchAttr (atts);
+ } else if ( eName == "branch" && state == StateMapCenter)
+ {
+ state=StateBranch;
+ branchDepth=1;
+ lastBranch->addBranch();
+ lastBranch=lastBranch->getLastBranch();
+ readBranchAttr (atts);
+ } else if ( (eName=="standardflag" ||eName == "standardFlag") && state == StateBranch)
+ {
+ state=StateBranchStandardFlag;
+ } else if ( eName == "heading" && state == StateBranch)
+ {
+ state=StateBranchHeading;
+ if (!atts.value( "textColor").isEmpty() )
+ {
+ col.setNamedColor(atts.value("textColor"));
+ lastBranch->setColor(col ,false );
+ }
+ } else if ( eName == "note" && state == StateBranch)
+ {
+ state=StateBranchNote;
+ if (!readNoteAttr (atts) ) return false;
+ } else if ( eName == "htmlnote" && state == StateBranch)
+ {
+ laststate=state;
+ state=StateHtmlNote;
+ no.clear();
+ if (!atts.value( "fonthint").isEmpty() )
+ no.setFontHint(atts.value ("fonthint") );
+ } else if ( eName == "floatimage" && state == StateBranch )
+ {
+ state=StateBranchFloatImage;
+ lastBranch->addFloatImage();
+ lastFloat=lastBranch->getLastFloatImage();
+ if (!readFloatImageAttr(atts)) return false;
+ } else if ( eName == "branch" && state == StateBranch )
+ {
+ lastBranch->addBranch();
+ lastBranch=lastBranch->getLastBranch();
+ branchDepth++;
+ readBranchAttr (atts);
+ } else if ( eName == "html" && state == StateHtmlNote )
+ {
+ state=StateHtml;
+ htmldata="<"+eName;
+ readHtmlAttr(atts);
+ htmldata+=">";
+ } else if ( state == StateHtml )
+ {
+ // accept all while in html mode,
+ htmldata+="<"+eName;
+ readHtmlAttr(atts);
+ htmldata+=">";
+ } else
+ return false; // Error
+ return true;
+}
+
+bool mapBuilderHandler::endElement ( const QString&, const QString&, const QString &eName)
+{
+// cout << "endElement "< state="<";
+ if (eName=="html")
+ {
+ state=StateHtmlNote;
+ htmldata.replace (" "," ");
+ no.setNote (htmldata);
+ lastBranch->setNote (no);
+ return true;
+ } else
+ {
+ return true;
+ }
+ case StateMap: state=StateInit; return true;
+ default :
+ // even for HTML includes, this should never be reached
+ return false;
+ }
+}
+
+bool mapBuilderHandler::characters ( const QString& ch)
+{
+ //cout << "characters \""<getMapCenter();
+}
+
+void mapBuilderHandler::setTmpDir (QString tp)
+{
+ tmpDir=tp;
+}
+
+void mapBuilderHandler::setLoadMode (const LoadMode &lm)
+{
+ loadMode=lm;
+}
+
+bool mapBuilderHandler::readBranchAttr (const QXmlAttributes& a)
+{
+ bool okx,oky;
+ int x,y;
+ if (!a.value( "absPosX").isEmpty() && loadMode==NewMap && branchDepth<2)
+ {
+ if (!a.value( "absPosY").isEmpty() )
+ {
+ x=a.value("absPosX").toInt (&okx, 10);
+ y=a.value("absPosY").toInt (&oky, 10);
+ if (okx && oky)
+ lastBranch->move(x,y);
+ else
+ return false; // Couldn't read absPos
+ }
+ }
+ if (!a.value( "scrolled").isEmpty() )
+ lastBranch->toggleScroll();
+ if (!a.value( "url").isEmpty() )
+ lastBranch->setURL (a.value ("url"));
+ if (!a.value( "vymLink").isEmpty() )
+ lastBranch->setVymLink (a.value ("vymLink"));
+ if (!a.value( "frameType").isEmpty() )
+ lastBranch->setFrameType (a.value("frameType"));
+ return true;
+}
+
+bool mapBuilderHandler::readNoteAttr (const QXmlAttributes& a)
+{ // only for backward compatibility (<1.4.6). Use htmlnote now.
+ no.clear();
+ QString fn;
+ if (!a.value( "href").isEmpty() )
+ {
+ // Load note
+ fn=parseHREF(a.value ("href") );
+ QFile file (fn);
+ QString s; // Reading a note
+
+ if ( !file.open( IO_ReadOnly) )
+ {
+ qWarning ("mapBuilderHandler::readNoteAttr: Couldn't load "+fn);
+ return false;
+ }
+ QTextStream stream( &file );
+ QString lines;
+ while ( !stream.eof() ) {
+ lines += stream.readLine()+"\n";
+ }
+ file.close();
+ // Convert to richtext
+ if ( !QStyleSheet::mightBeRichText( lines ) )
+ {
+ // Here we are workarounding the QT conversion method:
+ // convertFromPlainText does not generate valid xml, needed
+ // for the parser, but just
and without closing tags.
+ // So we have to add those by ourselves
+ //lines=quotemeta (lines);
+ lines = QStyleSheet::convertFromPlainText( lines, QStyleSheetItem::WhiteSpaceNormal );
+ lines.replace (" "," ");
+ }
+
+ lines ="