# HG changeset patch
# User insilmaril
# Date 1216205174 0
# Node ID 12958f987bcf8ed9595994c5354643224757694e
# Parent 192e1392ba6ada56dd1fac2b0eabb93e9ab42f17
Started to restructure for later use of Model/View
diff -r 192e1392ba6a -r 12958f987bcf aboutdialog.cpp
--- a/aboutdialog.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/aboutdialog.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -54,10 +54,7 @@
"
"
" - Spanish: "
" ACLibre (Academia y Conocimiento Libre)
"
- " - French: Philippe Caillaud and Claude
"
- " - Italian: Seyed Puria Nafisi Azizi
"
- " - Brasilian: Amadeu Júnior
"
- " - Russion: Anton Olenev
"
+ " - French: Philippe Caillaud, Claude ?
"
"
"
""
" Patches"
diff -r 192e1392ba6a -r 12958f987bcf animpoint.cpp
--- a/animpoint.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/animpoint.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -88,7 +88,7 @@
uint AnimPoint::getTicks()
{
- return animTicks;
+ return (uint) animTicks;
}
void AnimPoint::setAnimated(bool b)
@@ -110,15 +110,13 @@
{
vector=QPointF(0,0);
animated=false;
+ setX (destPos.x() );
+ setY (destPos.y() );
return animated;
}
-
setX (startPos.x() + vector.x()*sqrt(n/animTicks) );
setY (startPos.y() + vector.y()*sqrt(n/animTicks) );
- /*
- setX (startPos.x() + vector.x()*(n/animTicks) );
- setY (startPos.y() + vector.y()*(n/animTicks) );
- */
+
return animated;
}
diff -r 192e1392ba6a -r 12958f987bcf branchobj.cpp
--- a/branchobj.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/branchobj.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -21,7 +21,7 @@
BranchObj* BranchObj::itFirst=NULL;
-BranchObj::BranchObj () :OrnamentedObj()
+BranchObj::BranchObj () :OrnamentedObj() // FIXME needed at all?
{
// cout << "Const BranchObj ()\n";
setParObj (this);
@@ -103,7 +103,7 @@
branch.clear();
for (int i=0; ibranch.size(); ++i)
// Make deep copy of b
- // Because addBranch again calls copy for the childs,
+ // Because addBranch again calls copy for the children,
// Those will get a deep copy, too
addBranch(other->branch.at(i) );
@@ -214,7 +214,7 @@
if (off==0)
{
// new parent is just a branch, link to it
- QRectF t=o->getBBoxSizeWithChilds();
+ QRectF t=o->getBBoxSizeWithChildren();
if (o->getLastBranch())
y=t.y() + t.height() ;
else
@@ -343,10 +343,10 @@
standardFlags->setVisibility(v);
LinkableMapObj::setVisibility (v);
- // Only change childs, if I am not scrolled
+ // Only change children, if I am not scrolled
if (!scrolled && (depth < toDepth))
{
- // Now go recursivly through all childs
+ // Now go recursivly through all children
int i;
for (i=0; isetVisibility (v,toDepth);
@@ -370,9 +370,9 @@
// Overloaded from LinkableMapObj
// BranchObj can use color of heading
- if (mapEditor)
+ if (model)
{
- if (mapEditor->getMapLinkColorHint()==HeadingColor)
+ if (model->getMapLinkColorHint()==HeadingColor)
LinkableMapObj::setLinkColor (heading->getColor() );
else
LinkableMapObj::setLinkColor ();
@@ -409,13 +409,13 @@
// no itLast, we are just beginning
if (bo)
{
- // we have childs, return first one
+ // we have children, return first one
itLast=this;
return bo;
}
else
{
- // No childs, so there is no next
+ // No children, so there is no next
itLast=this;
return NULL;
}
@@ -426,12 +426,12 @@
{ // We come from parent
if (bo)
{
- // there are childs, go there
+ // there are children, go there
itLast=this;
return bo;
}
else
- { // no childs, try to go up again
+ { // no children, try to go up again
if (po)
{
// go back to parent and try to find next there
@@ -450,17 +450,17 @@
}
}
- // We don't come from parent, but from brother or childs
+ // We don't come from parent, but from brother or children
- // Try to find last child, where we came from, in my own childs
+ // Try to find last child, where we came from, in my own children
bool searching=true;
int i=0;
while (isetHideTmp (mode);
}
@@ -1114,7 +1114,7 @@
void BranchObj::removeBranchHere(BranchObj* borem)
{
// This removes the branch bo from list, but
- // inserts its childs at the place of bo
+ // inserts its children at the place of bo
BranchObj *bo;
bo=borem->getLastBranch();
int pos=borem->getNum();
@@ -1126,7 +1126,7 @@
removeBranch (borem);
}
-void BranchObj::removeChilds()
+void BranchObj::removeChildren()
{
clear();
}
@@ -1302,7 +1302,7 @@
}
}
-void BranchObj::alignRelativeTo (QPointF ref)
+void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
{
qreal th = bboxTotal.height();
// TODO testing
@@ -1313,9 +1313,11 @@
" ref="<[isHidden())
{
- branch.at(i)->alignRelativeTo (ref2);
- ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChilds().height() );
+ branch.at(i)->alignRelativeTo (ref2,true);
+
+ // append next branch below current one
+ ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChildren().height() );
}
}
}
@@ -1408,7 +1414,7 @@
// only calculate the sizes once. If the deepest LMO
// changes its height,
// all upper LMOs have to change, too.
- calcBBoxSizeWithChilds();
+ calcBBoxSizeWithChildren();
updateLink(); // This update is needed if the scene is resized
// due to excessive moving of a FIO
@@ -1472,12 +1478,12 @@
return r;
}
-QRectF BranchObj::getBBoxSizeWithChilds()
+QRectF BranchObj::getBBoxSizeWithChildren()
{
return bboxTotal;
}
-void BranchObj::calcBBoxSizeWithChilds()
+void BranchObj::calcBBoxSizeWithChildren()
{
// This is initially called only from reposition and
// and only for mapcenter. So it won't be
@@ -1485,11 +1491,11 @@
// action
- // Calculate size of LMO including all childs (to align them later)
+ // Calculate size of LMO including all children (to align them later)
bboxTotal.setX(bbox.x() );
bboxTotal.setY(bbox.y() );
- // if branch is scrolled, ignore childs, but still consider floatimages
+ // if branch is scrolled, ignore children, but still consider floatimages
if (scrolled)
{
bboxTotal.setWidth (bbox.width());
@@ -1523,8 +1529,8 @@
{
if (!branch.at(i)->isHidden())
{
- branch.at(i)->calcBBoxSizeWithChilds();
- br=branch.at(i)->getBBoxSizeWithChilds();
+ branch.at(i)->calcBBoxSizeWithChildren();
+ br=branch.at(i)->getBBoxSizeWithChildren();
r.setWidth( max (br.width(), r.width() ));
r.setHeight(br.height() + r.height() );
if (br.y()updateActions();
+ model->updateActions();
}
void BranchObj::unselect()
{
LinkableMapObj::unselect();
// Delete any messages like vymLink in StatusBar
- mainWindow->statusMessage ("");
+ mainWindow->statusMessage (""); //FIXME this causes segfault, when MainWindow is already gone in global destructor on quitting vym
// Save current note
if (isNoteInEditor) getNoteFromTextEditor();
@@ -1609,7 +1615,11 @@
bool BranchObj::animate()
{
anim.animate ();
- setRelPos (anim);
- return anim.isAnimated();
+ if ( anim.isAnimated() )
+ {
+ setRelPos (anim);
+ return true;
+ }
+ return false;
}
diff -r 192e1392ba6a -r 12958f987bcf branchobj.h
--- a/branchobj.h Wed Jul 16 10:44:44 2008 +0000
+++ b/branchobj.h Wed Jul 16 10:46:14 2008 +0000
@@ -11,7 +11,7 @@
/*! \brief A branch visible in the map */
-/*! If HideExport is used, this branch and its childs will be hidden in export */
+/*! If HideExport is used, this branch and its children will be hidden in export */
enum HideTmpMode {HideNone, HideExport};
@@ -102,7 +102,7 @@
virtual BranchObj* insertBranch(BranchObj*,int);
virtual BranchObj* insertBranchPtr (BranchObj*,int);
virtual void removeBranchHere(BranchObj*);
- virtual void removeChilds();
+ virtual void removeChildren();
virtual void removeBranch(BranchObj*);
virtual void removeBranchPtr (BranchObj*);
virtual void setLastSelectedBranch(BranchObj*);
@@ -116,14 +116,14 @@
virtual BranchObj* moveBranchDown(BranchObj*);
virtual void sortChildren();
virtual BranchObj* linkTo (BranchObj*, int);
- virtual void alignRelativeTo(const QPointF );
+ virtual void alignRelativeTo(const QPointF, bool alignSelf=false );
virtual void reposition();
virtual void unsetAllRepositionRequests();
virtual QPolygonF shape(); //!< Returns arbitrary bounding polygon
- virtual QRectF getTotalBBox(); // return BBox including childs
- virtual QRectF getBBoxSizeWithChilds(); // return size of BBox including childs
- virtual void calcBBoxSizeWithChilds(); // calc size of BBox including childs recursivly
+ virtual QRectF getTotalBBox(); // return BBox including children
+ virtual QRectF getBBoxSizeWithChildren(); // return size of BBox including children
+ virtual void calcBBoxSizeWithChildren(); // calc size of BBox including children recursivly
virtual void select();
virtual void unselect();
@@ -144,7 +144,7 @@
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 scrolled; // true if all children are scrolled and thus invisible
bool tmpUnscrolled; // can only be true (temporary) for a scrolled subtree
bool includeImagesVer; // include floatimages in bbox vertically
bool includeImagesHor; // include floatimages in bbox horizontally
diff -r 192e1392ba6a -r 12958f987bcf branchpropwindow.cpp
--- a/branchpropwindow.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/branchpropwindow.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -16,7 +16,7 @@
setCaption(vymName +" - " +tr ("Property Editor","Window caption"));
branch=NULL;
- mapEditor=NULL;
+ model=NULL;
ui.tabWidget->setEnabled(false);
@@ -125,7 +125,8 @@
// Attributes
attributeModel->removeRows(0, attributeModel->rowCount(), QModelIndex());
- // FIXME some samples for testing
+/*
+ // FIXME some samples for attribute testing
QStringList attrTypes=mapEditor->attributeTable()->getTypes();
for (int i=0; iattributeTable());
ui.attributeTableView->setItemDelegate (&delegate);
-
+*/
// Finally activate signals
connectSignals();
@@ -151,11 +152,11 @@
}
}
-void BranchPropertyWindow::setMapEditor (MapEditor *me)
+void BranchPropertyWindow::setModel (VymModel *m)
{
- mapEditor=me;
- if (mapEditor)
- setBranch (mapEditor->getSelectedBranch() );
+ model=m;
+ if (model)
+ setBranch (model->getSelectedBranch() );
else
ui.tabWidget->setEnabled (false);
@@ -163,17 +164,17 @@
void BranchPropertyWindow::frameTypeChanged (int i)
{
- if (mapEditor)
+ if (model)
{
switch (i)
{
- case 0: mapEditor->setFrameType (FrameObj::NoFrame); break;
+ case 0: model->setFrameType (FrameObj::NoFrame); break;
case 1:
- mapEditor->setFrameType (FrameObj::Rectangle);
+ model->setFrameType (FrameObj::Rectangle);
break;
case 2:
- mapEditor->setFrameType (FrameObj::Ellipse);
- mapEditor->setFramePadding (5);
+ model->setFrameType (FrameObj::Ellipse);
+ model->setFramePadding (5);
break;
}
setBranch (branch);
@@ -182,54 +183,54 @@
void BranchPropertyWindow::framePenColorClicked()
{
- if (mapEditor)
+ if (model)
{
QColor col = QColorDialog::getColor( penColor, this );
if ( col.isValid() )
{
penColor=col;
- mapEditor->setFramePenColor (penColor);
+ model->setFramePenColor (penColor);
}
}
}
void BranchPropertyWindow::frameBrushColorClicked()
{
- if (mapEditor)
+ if (model)
{
QColor col = QColorDialog::getColor( brushColor, this );
if ( col.isValid() )
{
brushColor=col;
- mapEditor->setFrameBrushColor (brushColor);
+ model->setFrameBrushColor (brushColor);
}
}
}
void BranchPropertyWindow::framePaddingChanged(int i)
{
- if (mapEditor) mapEditor->setFramePadding (i);
+ if (model) model->setFramePadding (i);
}
void BranchPropertyWindow::frameBorderWidthChanged(int i)
{
- if (mapEditor) mapEditor->setFrameBorderWidth(i);
+ if (model) model->setFrameBorderWidth(i);
}
void BranchPropertyWindow::linkHideUnselectedChanged (int i)
{
if (!branch) return;
- mapEditor->setHideLinkUnselected(i);
+ model->setHideLinkUnselected(i);
}
void BranchPropertyWindow::incImgVerChanged (int i)
{
- if (mapEditor) mapEditor->setIncludeImagesVer (i);
+ if (model) model->setIncludeImagesVer (i);
}
void BranchPropertyWindow::incImgHorChanged (int i)
{
- if (mapEditor) mapEditor->setIncludeImagesHor (i);
+ if (model) model->setIncludeImagesHor (i);
}
void BranchPropertyWindow::closeEvent( QCloseEvent* ce )
@@ -262,7 +263,7 @@
void BranchPropertyWindow::deleteAttributeClicked()
{
- cout << "BPW::delete\n";
+ //FIXME cout << "BPW::delete\n";
}
void BranchPropertyWindow::connectSignals()
diff -r 192e1392ba6a -r 12958f987bcf branchpropwindow.h
--- a/branchpropwindow.h Wed Jul 16 10:44:44 2008 +0000
+++ b/branchpropwindow.h Wed Jul 16 10:46:14 2008 +0000
@@ -10,8 +10,7 @@
#include "attributedelegate.h"
#include "branchobj.h"
-#include "mapeditor.h"
-
+#include "vymmodel.h"
class QAbstractItemModel;
@@ -22,7 +21,7 @@
BranchPropertyWindow (QWidget *parent=0);
~BranchPropertyWindow ();
void setBranch (BranchObj *);
- void setMapEditor (MapEditor *);
+ void setModel (VymModel *);
private slots:
void frameTypeChanged (int);
@@ -49,7 +48,7 @@
Ui::BranchPropertyWindow ui;
BranchObj *branch;
- MapEditor *mapEditor;
+ VymModel *model;
QColor penColor;
QColor brushColor;
diff -r 192e1392ba6a -r 12958f987bcf demos/math.vym
Binary file demos/math.vym has changed
diff -r 192e1392ba6a -r 12958f987bcf demos/vym-projectplan.vym
Binary file demos/vym-projectplan.vym has changed
diff -r 192e1392ba6a -r 12958f987bcf editxlinkdialog.cpp
--- a/editxlinkdialog.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/editxlinkdialog.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -62,8 +62,8 @@
if (xlo)
{
if (selection &&
- ((typeid(*selection) == typeid(BranchObj)) ||
- (typeid(*selection) == typeid(MapCenterObj))) )
+ (typeid(*selection) == typeid(BranchObj)) ||
+ (typeid(*selection) == typeid(MapCenterObj)) )
{
QColor col=((BranchObj*)(selection))->getColor();
xlo->setColor(col);
diff -r 192e1392ba6a -r 12958f987bcf exports.cpp
--- a/exports.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/exports.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -251,92 +251,77 @@
////////////////////////////////////////////////////////////////////////
void ExportKDEBookmarks::doExport()
{
- MapEditor *me=model->getMapEditor();
- if (me)
+ WarningDialog dia;
+ dia.showCancelButton (true);
+ dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE"));
+ dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
+ dia.setShowAgainName("/exports/KDE/overwriteKDEBookmarks");
+ if (dia.exec()==QDialog::Accepted)
{
- WarningDialog dia;
- dia.showCancelButton (true);
- dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE"));
- dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
- dia.setShowAgainName("/exports/KDE/overwriteKDEBookmarks");
- if (dia.exec()==QDialog::Accepted)
+ model->exportXML(tmpDir.path(),false);
+
+ XSLTProc p;
+ p.setInputFile (tmpDir.path()+"/"+model->getMapName()+".xml");
+ p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
+ p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
+ p.process();
+
+ QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
+ QProcess *proc= new QProcess ;
+ proc->start( ub);
+ if (!proc->waitForStarted())
{
- me->exportXML(tmpDir.path(),false);
-
- XSLTProc p;
- p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
- p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
- p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
- p.process();
-
- QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
- QProcess *proc= new QProcess ;
- proc->start( ub);
- if (!proc->waitForStarted())
- {
- QMessageBox::warning(0,
- QObject::tr("Warning"),
- QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
- }
- }
+ QMessageBox::warning(0,
+ QObject::tr("Warning"),
+ QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
+ }
}
-
}
////////////////////////////////////////////////////////////////////////
void ExportFirefoxBookmarks::doExport()
{
- MapEditor *me=model->getMapEditor();
- if (me)
+ WarningDialog dia;
+ dia.showCancelButton (true);
+ dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("Firefox"));
+ dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("Firefox"));
+ dia.setShowAgainName("/vym/warnings/overwriteImportBookmarks");
+ if (dia.exec()==QDialog::Accepted)
{
- WarningDialog dia;
- dia.showCancelButton (true);
- dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("Firefox"));
- dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("Firefox"));
- dia.setShowAgainName("/vym/warnings/overwriteImportBookmarks");
- if (dia.exec()==QDialog::Accepted)
- {
- me->exportXML(tmpDir.path(),false);
+ model->exportXML(tmpDir.path(),false);
/*
- XSLTProc p;
- p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
- p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
- p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
- p.process();
+ XSLTProc p;
+ p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
+ p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
+ p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
+ p.process();
- QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
- QProcess *proc = new QProcess( );
- proc->addArgument(ub);
+ QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
+ QProcess *proc = new QProcess( );
+ proc->addArgument(ub);
- if ( !proc->start() )
- {
- QMessageBox::warning(0,
- QObject::tr("Warning"),
- QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
- }
+ if ( !proc->start() )
+ {
+ QMessageBox::warning(0,
+ QObject::tr("Warning"),
+ QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
+ }
*/
-
- }
}
}
////////////////////////////////////////////////////////////////////////
void ExportTaskjuggler::doExport()
{
- MapEditor *me=model->getMapEditor();
- if (me)
- {
- me->exportXML(tmpDir.path(),false);
+ model->exportXML(tmpDir.path(),false);
- XSLTProc p;
- p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
- p.setOutputFile (outputFile);
- p.setXSLFile (vymBaseDir.path()+"/styles/vym2taskjuggler.xsl");
- p.process();
- }
-
+ XSLTProc p;
+ p.setInputFile (tmpDir.path()+"/"+model->getMapName()+".xml");
+ p.setOutputFile (outputFile);
+ p.setXSLFile (vymBaseDir.path()+"/styles/vym2taskjuggler.xsl");
+ p.process();
}
////////////////////////////////////////////////////////////////////////
diff -r 192e1392ba6a -r 12958f987bcf file.cpp
--- a/file.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/file.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -354,8 +354,6 @@
// Set up members of the STARTUPINFO structure.
::ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );
siStartInfo.cb = sizeof(STARTUPINFO);
- siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
- siStartInfo.wShowWindow = SW_MINIMIZE;
// Create command line.
QString argv("unzip -o ");
@@ -364,32 +362,26 @@
argv.append(QDir::convertSeparators(zipDir.path()));
// Create the child process.
- if (!::CreateProcess(NULL,
- (LPWSTR) argv.unicode(), // command line
- NULL, // process security attributes
- NULL, // primary thread security attributes
- TRUE, // handles are inherited
- 0, // creation flags
- NULL, // use parent's environment
- NULL, // use parent's current directory
- &siStartInfo, // STARTUPINFO pointer
- &piProcInfo) ) // receives PROCESS_INFORMATION
+ if( !::CreateProcess(NULL,
+ (LPWSTR)argv.unicode(), // command line
+ NULL, // process security attributes
+ NULL, // primary thread security attributes
+ TRUE, // handles are inherited
+ 0, // creation flags
+ NULL, // use parent's environment
+ NULL, // use parent's current directory
+ &siStartInfo, // STARTUPINFO pointer
+ &piProcInfo) ) // receives PROCESS_INFORMATION
{
- QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
- QObject::tr("Couldn't start unzip to decompress data."));
err = aborted;
}
else
{
// Wait for it to finish.
- ::WaitForSingleObject( piProcInfo.hProcess, INFINITE );
-
- // Clean up handles.
- CloseHandle(piProcInfo.hThread);
- CloseHandle(piProcInfo.hProcess);
+ ::WaitForSingleObject( piProcInfo.hProcess, 10000 );
}
#endif
- return err;
+ return err;
}
bool loadStringFromDisk (const QString &fname, QString &s)
@@ -503,3 +495,5 @@
if (imageFilters.at(i)==filter) return imageTypes.at(i);
return QString();
}
+
+
diff -r 192e1392ba6a -r 12958f987bcf floatimageobj.cpp
--- a/floatimageobj.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/floatimageobj.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -214,13 +214,13 @@
return bbox;
}
-QRectF FloatImageObj::getBBoxSizeWithChilds()
+QRectF FloatImageObj::getBBoxSizeWithChildren()
{
//TODO abstract in linkablemapobj.h, not calculated
return bboxTotal;
}
-void FloatImageObj::calcBBoxSizeWithChilds()
+void FloatImageObj::calcBBoxSizeWithChildren()
{
//TODO abstract in linkablemapobj.h
}
diff -r 192e1392ba6a -r 12958f987bcf floatimageobj.h
--- a/floatimageobj.h Wed Jul 16 10:44:44 2008 +0000
+++ b/floatimageobj.h Wed Jul 16 10:46:14 2008 +0000
@@ -30,9 +30,9 @@
virtual void move (QPointF);
virtual void positionBBox();
virtual void calcBBoxSize();
- virtual QRectF getTotalBBox(); // return BBox including childs
- virtual QRectF getBBoxSizeWithChilds(); // return size of BBox including childs
- virtual void calcBBoxSizeWithChilds(); // calc size of BBox including childs recursivly
+ virtual QRectF getTotalBBox(); // return BBox including children
+ virtual QRectF getBBoxSizeWithChildren(); // return size of BBox including children
+ virtual void calcBBoxSizeWithChildren(); // calc size of BBox including children recursivly
virtual QString saveToDir(const QString &,const QString&);
virtual void resetSaveCounter();
diff -r 192e1392ba6a -r 12958f987bcf floatobj.cpp
--- a/floatobj.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/floatobj.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -97,7 +97,7 @@
return bbox;
}
-QRectF FloatObj::getBBoxSizeWithChilds()
+QRectF FloatObj::getBBoxSizeWithChildren()
{
return bboxTotal;
}
diff -r 192e1392ba6a -r 12958f987bcf floatobj.h
--- a/floatobj.h Wed Jul 16 10:44:44 2008 +0000
+++ b/floatobj.h Wed Jul 16 10:46:14 2008 +0000
@@ -26,8 +26,8 @@
virtual void setDockPos();
virtual void reposition();
- virtual QRectF getTotalBBox(); // return BBox including childs
- virtual QRectF getBBoxSizeWithChilds(); // return size of BBox including childs
+ virtual QRectF getTotalBBox(); // return BBox including children
+ virtual QRectF getBBoxSizeWithChildren(); // return size of BBox including children
virtual void resetSaveCounter()=0;
diff -r 192e1392ba6a -r 12958f987bcf lang/vym_de.ts
--- a/lang/vym_de.ts Wed Jul 16 10:44:44 2008 +0000
+++ b/lang/vym_de.ts Wed Jul 16 10:46:14 2008 +0000
@@ -1838,7 +1838,7 @@
- Diese Map gibt es nicht:
+ Diese Map gibt es nich:
%1
Wollen Sie eine neue anlegen?
diff -r 192e1392ba6a -r 12958f987bcf lang/vym_it.ts
--- a/lang/vym_it.ts Wed Jul 16 10:44:44 2008 +0000
+++ b/lang/vym_it.ts Wed Jul 16 10:46:14 2008 +0000
@@ -1,6 +1,5 @@
-
AboutDialog
@@ -59,17 +58,17 @@
- Attributi
+
- Aggiungi chiave
+
- Chiudi
+ Chiudi
@@ -77,7 +76,7 @@
- Form
+
@@ -86,55 +85,55 @@
Window caption
- Editor di proprietà
+
Branchprop window: Attribute name
- Nome
+
Branchprop window: Attribute value
- Valore
+
Branchprop window: Attribute type
- Tipo
+
- Editor di proprietà del Ramo
+
- Frame
+
- Geometria
+
- Senza Frame
+ Senza Frame
- Rettangolo
+ Rettangolo
- Ellisse
+
@@ -144,67 +143,67 @@
- Spessore contorno
+
- Colori
+
- Colore Contorno
+
- Colore di sfondo
+
- Layout
+
- Includi immagini orizzontalmente
+ Includi immagini orizzontalmente
- Includi immagini verticalmente
+ Includi immagini verticalmente
- Puntatore
+
- Nascondi puntatori se non seleionati
+
- Attributi
+
- +
+
- -
+
- Chiudi
+ Chiudi
@@ -529,7 +528,7 @@
- mostra avvertimenti del processore xslt
+
@@ -603,7 +602,7 @@
- Nuova Mappa
+ Nuova Mappa
@@ -1132,7 +1131,7 @@
- Specifica Co&lore dei Collegamenti
+ Specifica Co&lore dei Collegamenti
@@ -2773,149 +2772,149 @@
File menu
- &Nuova mappa
+
File menu
- &Copia in una nuova mappa
+
Status tip File menu
- Copia la selezione nel centro di una nuova mappa
+
Canvas context menu
- Aggiungi centro mappa
+
Edit menu
- Ordina i figli
+
Edit menu
- Mostra i figli
+
- Mostra tutti i rami in sottorami selezionati
+
Edit menu
- Modifical URL locale...
+
- Modifica URL locale
+
Edit menu
- Crea un URL al Novell Bugzilla
+
- Crea un URL al Novell Bugzilla
+
Edit menu
- Crea un URL al Novell FATE
+
- Crea un URL al Novell FATE
+
Dialog to edit properties of selection
- Finestra di proprietà
+
- Imposta le proprietà per la selezione
+
- Collegamenti Curvilinei
+
- Collegamenti Curvilinei Spessi
+
- Scegli Colore di &Selezione
+
- Scegli Colore di Selezione
+
- Scegli immagine di S&fondo
+
- Scegli immagine di Sfondo
+
View action
- Mostra selezione
+
- Mostra selezione
+
View action
- Finestra di Cronologia
+
- Mostra la finestra di Cronologia
+
View action
- Antialiasing
+
- Antialiasing
+
@@ -2927,127 +2926,127 @@
View action
- Mappa successiva
+
View action
- Mappa precedente
+
SystemFlag
- Note
+ Note
SystemFlag
- URL al Documento
+
SystemFlag
- Collega ad un'altra mappa vym
+ Collega ad un'altra mappa vym
SystemFlag
- sottoalbero è espanso
+ sottoalbero è espanso
SystemFlag
- sottoalbero è temporaneamente espanso
+ sottoalbero è temporaneamente espanso
SystemFlag
- Nascondi oggetto nelle mappe esportate
+ Nascondi oggetto nelle mappe esportate
Standardflag
- Lo amo...
+
Freemind-Flag
- Importante
+ Importante
Freemind-Flag
- Priorità
+
Freemind-Flag
- Indietro
+
Freemind-Flag
- Avanti
+
Freemind-Flag
- Guardami
+
Freemind-Flag
- Pericoloso
+ Pericoloso
Freemind-Flag
- Non Trascurare
+
Freemind-Flag
- Flag
+
Freemind-Flag
- Principio
+
Freemind-Flag
- Telefono
+
Freemind-Flag
- Musica
+
Freemind-Flag
- Casella di Posta
+
@@ -3059,208 +3058,206 @@
Freemind-Flag
- Password
+
Freemind-Flag
- Da migliorare
+
Freemind-Flag
- Stop
+
Freemind-Flag
- Magico
+
Freemind-Flag
- Da discutere
+
Freemind-Flag
- Appunto
+
Freemind-Flag
- Eccellente
+
Freemind-Flag
- Linux
+
Freemind-Flag
- Dolce
+
Settings action
- Seleziona percorso per le macro
+
- Seleziona percorso per le macro
+
Settings action
- Imposta numero di livelli Annulla
+
- Imposta numero di livelli Annulla
+
Settings action
- Salva Automatico
+
- Salva Automatico
+
Settings action
- Tempo per salva automativo
+
- Tempo per salva automativo
+
Settings action
- Scrivi un file di backup al Salvataggio
+
- Scrivi un file di backup al Salvataggio
+
Settings action
- Animazione
+
- Animazione
+
Help action
- Apri mappe VYM di esempio
+
- Apri mappe VYM di esempio
+
Context menu name
- Referenze (URL, LinkVYM, ...)
+
- &%1 %2
+
- Carica mappa Freemind
+
- Esporta in CSV
+
- Cartella con macro vym:
+
- QInputDialog::getInteger()
+
- Numero di livelli annulla/rifai:
+
- Le impostazione sono state salvate. La prossima mappa avra "%1" livelli di annulla/rifai
+
- Numero di secondi prima del salvataggio automatico:
+
Window Caption
- Cronologia per %1
+
- Non è possibile trovare la documentazione %1 in:
-%2
+
- Carica mappa di esempio vym
+
- Non è possibile trovare la macro in %1.
-
+
- Imposta la cartella con le macro vym
+
@@ -3612,20 +3609,19 @@
- Errore Critico di Caricamento
+ Errore Critico di Caricamento
- Non è possibile creare una cartella temporanea prima di caricare
-
+ Non è possibile creare una cartella temporanea prima di caricare
- Non è possibile trovare una mappa (*.xml) nell'archivio .vym.
+ Non è possibile trovare una mappa (*.xml) nell'archivio .vym.
@@ -3636,7 +3632,7 @@
and flags and thus may overwrite files in the given directory
Do you want to write the map
- La mappa %1
+ La mappa %1
non usa il formato di compressione vym.
Salvandolo in modo non compresso, salva anche le immagini
e le flag e quindi potrebbe sovvrascrivere dei file in questa cartella
@@ -3645,94 +3641,92 @@
- compresso (predefinito in vym)
+ compresso (predefinito in vym)
- non compresso
+ non compresso
- Errore di Salvataggio
+ Errore di Salvataggio
- %1
-non può essere rimosso prima del salvataggio
+
- %1
-non può essere rinominato prima del salvataggio
+
- Non è possibile creare una cartella temporanea prima di salvare
+ Non è possibile creare una cartella temporanea prima di salvare
- Esporta mappa come immagine
+ Esporta mappa come immagine
- Esporta XML in una cartella
+ Esporta XML in una cartella
- Salvataggio automatico disabilitato durante annullamento.
+
- Carica immagine di sfondo
+
Filedialog
- Testo
+
Filedialog
- Foglio di calcolo
+
Filedialog
- Documento di testo
+
Filedialog
- Immagini
+ Immagini
- Imposta URL come file locale
+
Info about map
- %1 oggetti nella mappa
+
@@ -3746,12 +3740,12 @@
- Ricarica
+
- Ignora
+
@@ -3885,27 +3879,26 @@
- Esporta in ASCII
+ Esporta in ASCII
- (in via di sperimentazione)
+ (in via di sperimentazione)
write directory
- La cartella %1 non è vuota.
+ La cartella %1 non è vuota.
Si rischia di sovvrascrivere i contenuti?
- Non è possibile aprire %1.
-
+
@@ -3931,7 +3924,7 @@
- Salva script
+
@@ -3939,81 +3932,80 @@
exists already.
Do you want to overwrite it?
dialog 'save as'
- Il file %1
+ Il file %1
esiste già.
Vuoi sovvrascriverlo?
- Sovvrascrivi
+ Sovvrascrivi
- Cancella
+ Cancella
- Carica script
+
- Errore
+ Errore
- Non è possibile aprire %1.
-
+
- Editor semplice di script
+
- Salva come
+
- Salva
+ Salva
- Qt::CTRL + Qt::Key_S
+
- Apri
+ Apri
- Qt::CTRL + Qt::Key_O
+
- Avvia
+
- Qt::CTRL + Qt::Key_R
+
- Chiudi
+ Chiudi
@@ -4495,7 +4487,7 @@
- Mostra ancora questo messaggio
+
diff -r 192e1392ba6a -r 12958f987bcf linkablemapobj.cpp
--- a/linkablemapobj.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/linkablemapobj.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -1,8 +1,12 @@
+#include
#include
#include "linkablemapobj.h"
#include "branchobj.h"
-#include "mapeditor.h"
+#include "mapeditor.h" // FIXME needed?
+#include "vymmodel.h"
+
+using namespace std;
/////////////////////////////////////////////////////////////////
// LinkableMapObj
@@ -54,6 +58,8 @@
void LinkableMapObj::init ()
{
+ model=NULL;
+
depth=-1;
mapEditor=NULL;
childObj=NULL;
@@ -99,6 +105,7 @@
void LinkableMapObj::copy (LinkableMapObj* other)
{
MapObj::copy(other);
+ model=other->model;
bboxTotal=other->bboxTotal;
setLinkStyle(other->style);
setLinkColor (other->linkcolor);
@@ -107,6 +114,16 @@
objID=other->objID;
}
+void LinkableMapObj::setModel (VymModel *vm)
+{
+ model=vm;
+}
+
+VymModel* LinkableMapObj::getModel()
+{
+ return model;
+}
+
void LinkableMapObj::setChildObj(LinkableMapObj* o)
{
childObj=o;
@@ -116,13 +133,14 @@
{
parObj=o;
mapEditor=parObj->getMapEditor();
+ model=parObj->getModel(); // FIXME makes painting slow, but that's obvious because there are no links to paint, hmmm....
}
-void LinkableMapObj::setParObjTmp(LinkableMapObj*,QPointF,int)
+void LinkableMapObj::setParObjTmp(LinkableMapObj*,QPointF,int) // FIXME make pure virtual
{
}
-void LinkableMapObj::unsetParObjTmp()
+void LinkableMapObj::unsetParObjTmp() // FIXME make pure virtual
{
}
@@ -180,8 +198,12 @@
LinkableMapObj::Style LinkableMapObj::getDefLinkStyle ()
{
- if (!mapEditor) return UndefinedStyle;
- Style ls=mapEditor->getMapLinkStyle();
+ if (!model)
+ {
+ qWarning ("LMO::getDefLinkStyle model=NULL");
+ return UndefinedStyle;
+ }
+ Style ls=model->getMapLinkStyle();
switch (ls)
{
case Line:
@@ -309,10 +331,10 @@
void LinkableMapObj::setLinkColor()
{
- // Overloaded in BranchObj and childs
+ // Overloaded in BranchObj and children
// here only set default color
- if (mapEditor)
- setLinkColor (mapEditor->getMapDefLinkColor());
+ if (model)
+ setLinkColor (model->getMapDefLinkColor());
}
void LinkableMapObj::setLinkColor(QColor col)
@@ -606,6 +628,7 @@
void LinkableMapObj::setMapEditor (MapEditor *me)
{
mapEditor=me;
+ model=mapEditor->getModel();
}
MapEditor* LinkableMapObj::getMapEditor ()
@@ -646,7 +669,7 @@
// we want to block expensive repositioning, but just do it once at
// the end, thus check first:
- if (mapEditor->isRepositionBlocked()) return;
+ if (mapEditor->getModel()->isRepositionBlocked()) return; // FIXME better go to model directly, maybe via a signal
// Pass on the request to parental objects, if this hasn't been done yet
diff -r 192e1392ba6a -r 12958f987bcf linkablemapobj.h
--- a/linkablemapobj.h Wed Jul 16 10:44:44 2008 +0000
+++ b/linkablemapobj.h Wed Jul 16 10:46:14 2008 +0000
@@ -9,6 +9,7 @@
#define MAX_DEPTH 999
class MapEditor;
+class VymModel;
@@ -55,6 +56,10 @@
virtual void delLink();
virtual void init ();
virtual void copy (LinkableMapObj*);
+
+ virtual void setModel (VymModel *vm);
+ virtual VymModel* getModel ();
+
void setChildObj (LinkableMapObj*);
virtual void setParObj (LinkableMapObj*);
virtual void setParObjTmp (LinkableMapObj*,QPointF,int); // Only for moving Obj around
@@ -94,12 +99,12 @@
LinkableMapObj* getParObj(); // returns pointer to toObj
virtual LinkableMapObj* findObjBySelect(QString s); // find obj by selectstring
virtual void setDockPos()=0; // sets childPos and parPos
- QPointF getChildPos(); // returns pos where childs dock
+ QPointF getChildPos(); // returns pos where children dock
QPointF getParPos(); // returns pos where parents dock
Orientation 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 void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag) FIXME not needed
+ virtual MapEditor* getMapEditor(); // get MapEditor (usually from parent); FIXME not needed
virtual QPointF getRandPos(); // make randomised position
virtual void reposition();
@@ -108,7 +113,7 @@
// of mapeditor e.g. in noteeditor
virtual bool repositionRequested();
- virtual void calcBBoxSizeWithChilds()=0;// calc size of BBox including childs recursivly
+ virtual void calcBBoxSizeWithChildren()=0;// calc size of BBox including children recursivly
virtual void select();
virtual void unselect();
@@ -120,13 +125,15 @@
QPointF childPos;
QPointF parPos;
bool link2ParPos; // While moving around, sometimes link to parent
- MapEditor* mapEditor; // for and toggleScroll(), get default styles
+ MapEditor* mapEditor; // for and toggleScroll(), get default styles FIXME should not be needed with model available
// and mapEditor->updateActions()
// and mapEditor->updateSelection()
+
+ VymModel* model;
Orientation orientation;
qreal linkwidth; // width of a link
int depth; // depth: undef=-1 mapCenter=0 branch=1..n
- QRectF bboxTotal; // bounding box including childs
+ QRectF bboxTotal; // bounding box including children
LinkableMapObj* childObj;
LinkableMapObj* parObj;
diff -r 192e1392ba6a -r 12958f987bcf main.cpp
--- a/main.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/main.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -1,5 +1,8 @@
#include
+#include
+using namespace std;
+
#include "flagrowobj.h"
#include "mainwindow.h"
#include "options.h"
diff -r 192e1392ba6a -r 12958f987bcf mainwindow.cpp
--- a/mainwindow.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/mainwindow.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -79,8 +79,6 @@
{
mainWindow=this;
- setObjectName ("MainWindow");
-
setCaption ("VYM - View Your Mind");
// Load window settings
@@ -496,6 +494,7 @@
editMenu->addAction (a);
actionEditPaste=a;
+/*
// Shortcuts to modify heading:
a = new QAction(tr( "Edit heading","Edit menu" ),this);
a->setStatusTip ( tr( "edit Heading" ));
@@ -513,6 +512,8 @@
actionListBranches.append(a);
editMenu->addAction (a);
actionEditHeading=a;
+
+*/
a = new QAction( tr( "Edit heading","Edit menu" ), this);
a->setStatusTip (tr( "edit Heading" ));
//a->setShortcut ( Qt::Key_F2 ); //Edit heading
@@ -660,10 +661,10 @@
addAction (alt);
actionListBranches.append(actionEditToggleScroll);
- a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
+ a = new QAction( tr( "Unscroll children","Edit menu" ), this);
a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
editMenu->addAction (a);
- connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
+ connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
editMenu->addSeparator();
@@ -803,24 +804,24 @@
actionListBranches.append(a);
actionEditSaveBranch=a;
- // Only remove branch, not its childs
+ // Only remove branch, not its children
a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
- a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
+ a->setStatusTip ( tr( "Remove only branch and keep its children" ));
a->setShortcut (Qt::ALT + Qt::Key_Delete );
- connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
+ connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
a->setEnabled (false);
addAction (a);
actionListBranches.append(a);
- actionEditDeleteKeepChilds=a;
-
- // Only remove childs of a branch
- a = new QAction( tr( "Remove childs","Edit menu" ), this);
- a->setStatusTip (tr( "Remove childs of branch" ));
+ actionEditDeleteKeepChildren=a;
+
+ // Only remove children of a branch
+ a = new QAction( tr( "Remove children","Edit menu" ), this);
+ a->setStatusTip (tr( "Remove children of branch" ));
a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
- connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
+ connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
a->setEnabled (false);
actionListBranches.append(a);
- actionEditDeleteChilds=a;
+ actionEditDeleteChildren=a;
// Shortcuts for navigating with cursor:
a = new QAction(tr( "Select upper branch","Edit menu" ), this);
@@ -1554,8 +1555,8 @@
branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
branchRemoveContextMenu->addAction (actionEditCut);
branchRemoveContextMenu->addAction ( actionEditDelete );
- branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
- branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
+ branchRemoveContextMenu->addAction ( actionEditDeleteKeepChildren );
+ branchRemoveContextMenu->addAction ( actionEditDeleteChildren );
actionEditSaveBranch->addTo( branchContextMenu );
@@ -1690,12 +1691,24 @@
MapEditor* Main::currentMapEditor() const
{
+ // FIXME currentMapEditor should return the latest used editor for a model, or NULL if no editor is open
if ( tabWidget->currentPage() &&
tabWidget->currentPage()->inherits( "MapEditor" ) )
return (MapEditor*)tabWidget->currentPage();
return NULL;
}
+VymModel* Main::currentModel() const
+{
+ // FIXME better get currentModel from a maintained list,
+ // just in case we allow other views in tabs later
+ MapEditor *me=currentMapEditor();
+ if (me)
+ return me->getModel();
+ else
+ return NULL;
+}
+
void Main::editorChanged(QWidget *)
{
@@ -1704,11 +1717,11 @@
MapEditor *me;
for (int i=0;i<=tabWidget->count() -1;i++)
{
+
me=(MapEditor*)tabWidget->page(i);
- me->unselect();
+ me->getModel()->unselect();
}
- me=currentMapEditor();
- if (me) me->reselect();
+ currentModel()->reselect();
// Update actions to in menus and toolbars according to editor
updateActions();
@@ -1716,8 +1729,10 @@
void Main::fileNew()
{
+ VymModel *m=new VymModel;
+ models.append (m);
+ MapEditor* me = new MapEditor (m);
QString fn="unnamed";
- MapEditor* me = new MapEditor ( NULL);
tabWidget->addTab (me,fn);
tabWidget->showPage(me);
me->viewport()->setFocus();
@@ -1725,7 +1740,7 @@
me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
// For the very first map we do not have flagrows yet...
- me->select("mc:");
+ currentModel()->select("mc:");
}
void Main::fileNewCopy()
@@ -1734,8 +1749,10 @@
MapEditor* oldME =currentMapEditor();
if (oldME)
{
- oldME->copy();
- MapEditor* newME = new MapEditor ( NULL);
+ oldME->getModel()->copy();
+ VymModel *m=new VymModel;
+ models.append (m);
+ MapEditor* newME = new MapEditor ( m);
if (newME)
{
tabWidget->addTab (newME,fn);
@@ -1744,8 +1761,8 @@
newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
// For the very first map we do not have flagrows yet...
- newME->select("mc:");
- newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
+ m->select("mc:");
+ m->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
}
}
@@ -1770,7 +1787,7 @@
while (i<=tabWidget->count() -1)
{
me=(MapEditor*)tabWidget->page(i);
- if (me->getFilePath() == fn)
+ if (me->getModel()->getFilePath() == fn)
{
// Already there, ask for confirmation
QMessageBox mb( vymName,
@@ -1809,9 +1826,11 @@
// 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() ) )
+ if ( lmode==NewMap && (!me || !me->getModel()->isDefault() ) )
{
- me= new MapEditor ( NULL);
+ VymModel *m=new VymModel;
+ models.append (m);
+ me= new MapEditor ( m);
tabWidget->addTab (me,fn);
tabIndex=tabWidget->indexOf (me);
tabWidget->setCurrentPage (tabIndex);
@@ -1821,8 +1840,6 @@
// Check, if file exists (important for creating new files
// from command line
- /*
- */
if (!QFile(fn).exists() )
{
QMessageBox mb( vymName,
@@ -1838,9 +1855,9 @@
{
case QMessageBox::Yes:
// Create new map
- currentMapEditor()->setFilePath(fn);
+ currentMapEditor()->getModel()->setFilePath(fn);
tabWidget->setTabLabel (currentMapEditor(),
- currentMapEditor()->getFileName() );
+ currentMapEditor()->getModel()->getFileName() );
statusBar()->message( "Created " + fn , statusbarTime );
return success;
@@ -1852,6 +1869,7 @@
}
}
+
//tabWidget->currentPage() won't be NULL here, because of above...
tabWidget->showPage(me);
me->viewport()->setFocus();
@@ -1859,15 +1877,15 @@
if (err!=aborted)
{
// Save existing filename in case we import
- QString fn_org=me->getFilePath();
+ QString fn_org=me->getModel()->getFilePath();
// Finally load map into mapEditor
- me->setFilePath (fn);
- err=me->load(fn,lmode,ftype);
+ me->getModel()->setFilePath (fn);
+ err=me->getModel()->load(fn,lmode,ftype);
// Restore old (maybe empty) filepath, if this is an import
if (lmode!=NewMap)
- me->setFilePath (fn_org);
+ me->getModel()->setFilePath (fn_org);
}
// Finally check for errors and go home
@@ -1879,13 +1897,13 @@
{
if (lmode==NewMap)
{
- me->setFilePath (fn);
- tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
+ me->getModel()->setFilePath (fn);
+ tabWidget->changeTab(tabWidget->page(tabIndex), me->getModel()->getFileName());
if (!isInTmpDir (fn))
{
// Only append to lastMaps if not loaded from a tmpDir
// e.g. imported bookmarks are in a tmpDir
- addRecentMap(me->getFilePath() );
+ addRecentMap(me->getModel()->getFilePath() );
}
actionFilePrint->setEnabled (true);
}
@@ -1960,40 +1978,40 @@
setupRecentMapsMenu();
}
-void Main::fileSave(MapEditor *me, const SaveMode &savemode)
+void Main::fileSave(VymModel *m, const SaveMode &savemode)
{
- if (!me) return;
-
- if ( me->getFilePath().isEmpty() )
+ if (!m) return;
+
+ if ( m->getFilePath().isEmpty() )
{
// We have no filepath yet,
// call fileSaveAs() now, this will call fileSave()
// again.
// First switch to editor
- tabWidget->setCurrentWidget (me);
+ tabWidget->setCurrentWidget (m->getMapEditor());
fileSaveAs(savemode);
}
- if (me->save (savemode)==success)
+ if (m->save (savemode)==success)
{
statusBar()->message(
- tr("Saved %1").arg(me->getFilePath()),
+ tr("Saved %1").arg(m->getFilePath()),
statusbarTime );
- addRecentMap (me->getFilePath() );
+ addRecentMap (m->getFilePath() );
} else
statusBar()->message(
- tr("Couldn't save ").arg(me->getFilePath()),
+ tr("Couldn't save ").arg(m->getFilePath()),
statusbarTime );
}
void Main::fileSave()
{
- fileSave (currentMapEditor(), CompleteMap);
+ fileSave (currentModel(), CompleteMap);
}
-void Main::fileSave(MapEditor *me)
+void Main::fileSave(VymModel *m)
{
- fileSave (me,CompleteMap);
+ fileSave (m,CompleteMap);
}
void Main::fileSaveAs(const SaveMode& savemode)
@@ -2048,13 +2066,13 @@
// Save now
- currentMapEditor()->setFilePath(fn);
- fileSave(currentMapEditor(), savemode);
+ currentModel()->setFilePath(fn);
+ fileSave(currentModel(), savemode);
// Set name of tab
if (savemode==CompleteMap)
tabWidget->setTabLabel (currentMapEditor(),
- currentMapEditor()->getFileName() );
+ currentModel()->getFileName() );
return;
}
}
@@ -2070,7 +2088,7 @@
ImportKDEBookmarks im;
im.transform();
if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
- currentMapEditor()->setFilePath ("");
+ currentMapEditor()->getModel()->setFilePath ("");
}
void Main::fileImportFirefoxBookmarks()
@@ -2093,7 +2111,7 @@
if (im.transform() &&
success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
currentMapEditor() )
- currentMapEditor()->setFilePath ("");
+ currentMapEditor()->getModel()->setFilePath ("");
++it;
}
}
@@ -2122,7 +2140,7 @@
fn = *it;
if ( fileLoad (fn,NewMap, FreemindMap) )
{
- currentMapEditor()->setFilePath ("");
+ currentMapEditor()->getModel()->setFilePath ("");
}
++it;
}
@@ -2153,80 +2171,78 @@
if (im.transform() &&
success==fileLoad (im.getTransformedFile(),NewMap) &&
currentMapEditor() )
- currentMapEditor()->setFilePath ("");
-
+ currentMapEditor()->getModel()->setFilePath ("");
++it;
}
}
delete (fd);
-
}
void Main::fileImportDir()
{
- if (currentMapEditor())
- currentMapEditor()->importDir();
+ VymModel *m=currentModel();
+ if (m) m->importDir();
}
void Main::fileExportXML()
{
- MapEditor *me=currentMapEditor();
- if (me) me->exportXML();
+ VymModel *m=currentModel();
+ if (m) m->exportXML();
}
void Main::fileExportXHTML()
{
- MapEditor *me=currentMapEditor();
- if (me) me->exportXHTML();
+ VymModel *m=currentModel();
+ if (m) m->exportXHTML();
}
void Main::fileExportImage()
{
- MapEditor *me=currentMapEditor();
- if (me) me->exportImage();
+ VymModel *m=currentModel();
+ if (m) m->exportImage();
}
void Main::fileExportASCII()
{
- MapEditor *me=currentMapEditor();
- if (me) me->exportASCII();
+ VymModel *m=currentModel();
+ if (m) m->exportASCII();
}
void Main::fileExportCSV() //FIXME not scriptable yet
{
- MapEditor *me=currentMapEditor();
- if (me)
+ VymModel *m=currentModel();
+ if (m)
{
ExportCSV ex;
- ex.setModel (me->getModel());
+ ex.setModel (m);
ex.addFilter ("CSV (*.csv)");
ex.setDir(lastImageDir);
ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
if (ex.execDialog() )
{
- me->setExportMode(true);
+ m->setExportMode(true);
ex.doExport();
- me->setExportMode(false);
+ m->setExportMode(false);
}
}
}
void Main::fileExportLaTeX() //FIXME not scriptable yet
{
- MapEditor *me=currentMapEditor();
- if (me)
+ VymModel *m=currentModel();
+ if (m)
{
ExportLaTeX ex;
- ex.setModel (me->getModel());
+ ex.setModel (m);
ex.addFilter ("Tex (*.tex)");
ex.setDir(lastImageDir);
ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
if (ex.execDialog() )
{
- me->setExportMode(true);
+ m->setExportMode(true);
ex.doExport();
- me->setExportMode(false);
+ m->setExportMode(false);
}
}
}
@@ -2234,10 +2250,10 @@
void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
{
ExportKDEBookmarks ex;
- MapEditor *me=currentMapEditor();
- if (me)
+ VymModel *m=currentModel();
+ if (m)
{
- ex.setModel (me->getModel());
+ ex.setModel (m);
ex.doExport();
}
}
@@ -2245,18 +2261,18 @@
void Main::fileExportTaskjuggler() //FIXME not scriptable yet
{
ExportTaskjuggler ex;
- MapEditor *me=currentMapEditor();
- if (me)
+ VymModel *m=currentModel();
+ if (m)
{
- ex.setModel (me->getModel());
+ ex.setModel (m);
ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
ex.setDir(lastImageDir);
ex.addFilter ("Taskjuggler (*.tjp)");
if (ex.execDialog() )
{
- me->setExportMode(true);
+ m->setExportMode(true);
ex.doExport();
- me->setExportMode(false);
+ m->setExportMode(false);
}
}
}
@@ -2282,8 +2298,8 @@
fn +=".odp";
//lastImageDir=fn.left(fn.findRev ("/"));
- if (currentMapEditor())
- currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
+ VymModel *m=currentModel();
+ if (m) m->exportOOPresentation(fn,fd->selectedConfig());
}
} else
{
@@ -2296,12 +2312,13 @@
void Main::fileCloseMap()
{
MapEditor *me = currentMapEditor();
- if (me)
+ VymModel *m=currentModel();
+ if (m)
{
- if (me->hasChanged())
+ if (m->hasChanged())
{
QMessageBox mb( vymName,
- tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
+ tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
QMessageBox::Warning,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No,
@@ -2312,7 +2329,7 @@
{
case QMessageBox::Yes:
// save and close
- fileSave(me, CompleteMap);
+ fileSave(m, CompleteMap);
break;
case QMessageBox::No:
// close without saving
@@ -2322,13 +2339,12 @@
return;
}
}
- //me->closeMap();
- tabWidget->removePage(me);
+ //me->closeMap(); FIXME should not be necessary any longer
+ me->close();
+ tabWidget->removePage(m->getMapEditor());
if (tabWidget->count()==0)
actionFilePrint->setEnabled (false);
-
- //delete me;
- me->clear();
+ delete me;
}
}
@@ -2349,7 +2365,7 @@
me=(MapEditor*)tabWidget->page(i);
// If something changed, ask what to do
- if (me->hasChanged())
+ if (me->getModel()->hasChanged())
{
tabWidget->setCurrentPage(i);
QMessageBox mb( vymName,
@@ -2366,7 +2382,7 @@
switch( mb.exec() ) {
case QMessageBox::Yes:
// save (the changed editors) and exit
- fileSave(currentMapEditor(), CompleteMap);
+ fileSave(currentModel(), CompleteMap);
break;
case QMessageBox::No:
// exit without saving
@@ -2382,38 +2398,38 @@
void Main::editUndo()
{
- if (currentMapEditor())
- currentMapEditor()->undo();
+ VymModel *m=currentModel();
+ if (m) m->undo();
}
void Main::editRedo()
{
- if (currentMapEditor())
- currentMapEditor()->redo();
+ VymModel *m=currentModel();
+ if (m) m->redo();
}
void Main::gotoHistoryStep (int i)
{
- if (currentMapEditor())
- currentMapEditor()->gotoHistoryStep (i);
+ VymModel *m=currentModel();
+ if (m) m->gotoHistoryStep(i);
}
void Main::editCopy()
{
- if (currentMapEditor())
- currentMapEditor()->copy();
+ VymModel *m=currentModel();
+ if (m) m->copy();
}
void Main::editPaste()
{
- if (currentMapEditor())
- currentMapEditor()->paste();
+ VymModel *m=currentModel();
+ if (m) m->paste();
}
void Main::editCut()
{
- if (currentMapEditor())
- currentMapEditor()->cut();
+ VymModel *m=currentModel();
+ if (m) m->cut();
}
void Main::editOpenFindWindow()
@@ -2425,21 +2441,26 @@
void Main::editFind(QString s)
{
- bool cs=false;
- BranchObj *bo=currentMapEditor()->findText(s, cs);
- if (bo)
- {
- statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
- } else
+ VymModel *m=currentModel();
+ if (m)
{
- QMessageBox::information( findWindow, tr( "VYM -Information:" ),
- tr("No matches found for \"%1\"").arg(s));
- }
+ bool cs=false;
+ BranchObj *bo=m->findText(s, cs);
+ if (bo)
+ {
+ statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
+ } else
+ {
+ QMessageBox::information( findWindow, tr( "VYM -Information:" ),
+ tr("No matches found for \"%1\"").arg(s));
+ }
+ }
}
void Main::editFindChanged()
{ // Notify editor, to abort the current find process
- currentMapEditor()->findReset();
+ VymModel *m=currentModel();
+ if (m) m->findReset();
}
void Main::openTabs(QStringList urls)
@@ -2527,9 +2548,10 @@
void Main::editOpenURL()
{
// Open new browser
- if (currentMapEditor())
+ VymModel *m=currentModel();
+ if (m)
{
- QString url=currentMapEditor()->getURL();
+ QString url=m->getURL();
QStringList args;
if (url=="") return;
QString browser=settings.value("/mainwindow/readerURL" ).toString();
@@ -2549,19 +2571,21 @@
}
void Main::editOpenURLTab()
{
- if (currentMapEditor())
+ VymModel *m=currentModel();
+ if (m)
{
QStringList urls;
- urls.append(currentMapEditor()->getURL());
+ urls.append(m->getURL());
openTabs (urls);
}
}
void Main::editOpenMultipleURLTabs()
{
- if (currentMapEditor())
+ VymModel *m=currentModel();
+ if (m)
{
QStringList urls;
- urls=currentMapEditor()->getURLs();
+ urls=m->getURLs();
openTabs (urls);
}
}
@@ -2569,49 +2593,58 @@
void Main::editURL()
{
- if (currentMapEditor())
- currentMapEditor()->editURL();
+ VymModel *m=currentModel();
+ if (m) m->editURL();
}
void Main::editLocalURL()
{
- if (currentMapEditor())
- currentMapEditor()->editLocalURL();
+ VymModel *m=currentModel();
+ if (m) m->editLocalURL();
}
void Main::editHeading2URL()
{
- if (currentMapEditor())
- currentMapEditor()->editHeading2URL();
+ VymModel *m=currentModel();
+ if (m) m->editHeading2URL();
}
void Main::editBugzilla2URL()
{
- if (currentMapEditor())
- currentMapEditor()->editBugzilla2URL();
+ VymModel *m=currentModel();
+ if (m) m->editBugzilla2URL();
}
void Main::editFATE2URL()
{
- if (currentMapEditor())
- currentMapEditor()->editFATE2URL();
+ VymModel *m=currentModel();
+ if (m) m->editFATE2URL();
}
-void Main::editHeadingFinished()
+void Main::editHeadingFinished(VymModel *m)
{
+ if (m)
+ {
+ if (!actionSettingsAutoSelectNewBranch->isOn() &&
+ !prevSelection.isEmpty())
+ m->select(prevSelection);
+ prevSelection="";
+ }
+
+/* FIXME old code, remove now
// only called from editHeading(), so there is a currentME
- MapEditor *me=currentMapEditor();
- if (me)
+ VymModel *m=currentModel();
+ if (m)
{
- me->setStateEditHeading (false);
+ m->setSelectionBlocked (false);
QPoint p; //Not used here, only to find out pos of branch
bool ok;
- QString s=me->getHeading(ok,p);
+ QString s=m->getHeading(ok,p);
#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
#else
if (ok && s!=lineedit->text())
- me->setHeading(lineedit->text());
+ m->setHeading(lineedit->text());
lineedit->releaseKeyboard();
lineedit->hide();
@@ -2619,17 +2652,20 @@
#endif
if (!actionSettingsAutoSelectNewBranch->isOn() &&
!prevSelection.isEmpty())
- me->select(prevSelection);
+ m->select(prevSelection);
prevSelection="";
}
+*/
}
+/*
void Main::editHeading()
{
- if (currentMapEditor())
+ MapEditor *me=currentMapEditor();
+ VymModel *m=currentModel();
+ if (me && m)
{
- MapEditor *me=currentMapEditor();
- QString oldSel=me->getSelectString();
+ QString oldSel=m->getSelectString();
if (lineedit->isVisible())
editHeadingFinished();
@@ -2637,11 +2673,11 @@
{
bool ok;
QPoint p;
- QString s=me->getHeading(ok,p);
+ QString s=m->getHeading(ok,p);
if (ok)
{
- me->setStateEditHeading (true);
+ m->setSelectionBlocked(true);
#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
p=me->mapToGlobal (p);
QDialog *d =new QDialog(NULL);
@@ -2654,7 +2690,7 @@
connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
d->activateWindow();
d->exec();
- me->setHeading (le->text());
+ m->setHeading (le->text());
delete (le);
delete (d);
editHeadingFinished();
@@ -2670,8 +2706,9 @@
#endif
}
}
- } // currentMapEditor()
+ }
}
+*/
void Main::editAttributeFinished()
{
@@ -2707,10 +2744,11 @@
#include "attributedialog.h"
void Main::editAttribute()
{
+/*
MapEditor *me=currentMapEditor();
if (me)
{
- BranchObj *bo=me->getSelectedBranch();
+ BranchObj *bo=me->getModel()->getSelectedBranch();
if (bo)
{
AttributeDialog dia(this);
@@ -2721,6 +2759,7 @@
dia.exec();
}
}
+ */
/*
if (currentMapEditor())
{
@@ -2782,7 +2821,7 @@
for (i=0;i<=tabWidget->count() -1;i++)
{
me=(MapEditor*)tabWidget->page(i);
- if (vl.at(j)==me->getFilePath() )
+ if (vl.at(j)==me->getModel()->getFilePath() )
{
index=i;
break;
@@ -2807,10 +2846,11 @@
void Main::editOpenVymLink()
{
- if (currentMapEditor())
+ VymModel *m=currentModel();
+ if (m)
{
QStringList vl;
- vl.append(currentMapEditor()->getVymLink());
+ vl.append(m->getVymLink());
openVymLinks (vl);
}
}
@@ -2818,168 +2858,204 @@
void Main::editOpenMultipleVymLinks()
{
QString currentVymLink;
- if (currentMapEditor())
+ VymModel *m=currentModel();
+ if (m)
{
- QStringList vl=currentMapEditor()->getVymLinks();
+ QStringList vl=m->getVymLinks();
openVymLinks (vl);
}
}
void Main::editVymLink()
{
- if (currentMapEditor())
- currentMapEditor()->editVymLink();
+ VymModel *m=currentModel();
+ if (m)
+ m->editVymLink();
}
void Main::editDeleteVymLink()
{
- if (currentMapEditor())
- currentMapEditor()->deleteVymLink();
+ VymModel *m=currentModel();
+ if (m) m->deleteVymLink();
}
void Main::editToggleHideExport()
{
- if (currentMapEditor())
- currentMapEditor()->toggleHideExport();
+ VymModel *m=currentModel();
+ if (m) m->toggleHideExport();
}
void Main::editMapInfo()
{
- if (currentMapEditor())
- currentMapEditor()->editMapInfo();
+ VymModel *m=currentModel();
+
+ ExtraInfoDialog dia;
+ dia.setMapName (m->getFileName() );
+ dia.setAuthor (m->getAuthor() );
+ dia.setComment(m->getComment() );
+
+/* FIXME no stats at the moment (view dependent...)
+ // Calc some stats
+ QString stats;
+ stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
+
+ uint b=0;
+ uint f=0;
+ uint n=0;
+ uint xl=0;
+ BranchObj *bo;
+ bo=m->first();
+ while (bo)
+ {
+ if (!bo->getNote().isEmpty() ) n++;
+ f+= bo->countFloatImages();
+ b++;
+ xl+=bo->countXLinks();
+ bo=m->next(bo);
+ }
+ stats+=QString ("%1 branches\n").arg (b-1,6);
+ stats+=QString ("%1 xLinks \n").arg (xl,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)
+ {
+ m->setAuthor (dia.getAuthor() );
+ m->setComment (dia.getComment() );
+ }
}
void Main::editMoveUp()
{
- if (currentMapEditor())
- currentMapEditor()->moveBranchUp();
+ VymModel *m=currentModel();
+ if (m) m->moveBranchUp();
}
void Main::editMoveDown()
{
- if (currentMapEditor())
- currentMapEditor()->moveBranchDown();
+ VymModel *m=currentModel();
+ if (m) m->moveBranchDown();
}
void Main::editSortChildren()
{
- if (currentMapEditor())
- currentMapEditor()->sortChildren();
+ VymModel *m=currentModel();
+ if (m) m->sortChildren();
}
void Main::editToggleScroll()
{
- if (currentMapEditor())
+ VymModel *m=currentModel();
+ if (m) m->toggleScroll();
+}
+
+void Main::editUnscrollChildren()
+{
+ VymModel *m=currentModel();
+ if (m) m->unscrollChildren();
+}
+
+void Main::editAddMapCenter()
+{
+ VymModel *m=currentModel();
+ if (!lineedit->isVisible() && m)
{
- currentMapEditor()->toggleScroll();
+ m->addMapCenter ();
}
}
-void Main::editUnscrollChilds()
-{
- if (currentMapEditor())
- currentMapEditor()->unscrollChilds();
-}
-
-void Main::editAddMapCenter()
-{
- MapEditor *me=currentMapEditor();
- if (!lineedit->isVisible() && me)
- {
- me->addMapCenter ();
- }
-}
-
void Main::editNewBranch()
{
- MapEditor *me=currentMapEditor();
- if (!lineedit->isVisible() && me)
+ VymModel *m=currentModel();
+ if (!lineedit->isVisible() && m)
{
- BranchObj *bo=(BranchObj*)me->getSelection();
- BranchObj *newbo=me->addNewBranch(0);
-
- prevSelection=me->getModel()->getSelectString(bo);
+ BranchObj *bo=(BranchObj*)m->getSelection();
+ BranchObj *newbo=m->addNewBranch(0);
+
+ prevSelection=m->getSelectString(bo);
if (newbo)
- me->select (newbo);
+ m->select (newbo);
else
return;
if (actionSettingsAutoEditNewBranch->isOn())
{
- editHeading();
+ currentMapEditor()->editHeading();
return;
}
if (!prevSelection.isEmpty())
{
- me->select(prevSelection);
+ m->select(prevSelection);
prevSelection="";
}
-
}
}
void Main::editNewBranchBefore()
{
- MapEditor *me=currentMapEditor();
- if (!lineedit->isVisible() && me)
+ VymModel *m=currentModel();
+ if (!lineedit->isVisible() && m)
{
- BranchObj *bo=(BranchObj*)me->getSelection();
- BranchObj *newbo=me->addNewBranchBefore();
+ BranchObj *bo=(BranchObj*)m->getSelection();
+ BranchObj *newbo=m->addNewBranchBefore();
if (newbo)
- me->select (newbo);
+ m->select (newbo);
else
return;
if (actionSettingsAutoEditNewBranch->isOn())
{
if (!actionSettingsAutoSelectNewBranch->isOn())
- prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
- editHeading();
+ prevSelection=m->getSelectString(bo);
+ currentMapEditor()->editHeading();
}
}
}
void Main::editNewBranchAbove()
{
- MapEditor *me=currentMapEditor();
- if (!lineedit->isVisible() && me)
+ VymModel *m=currentModel();
+ if (!lineedit->isVisible() && m)
{
- BranchObj *bo=(BranchObj*)me->getSelection();
- BranchObj *newbo=me->addNewBranch (-1);
+ BranchObj *bo=(BranchObj*)m->getSelection();
+ BranchObj *newbo=m->addNewBranch (-1);
if (newbo)
- me->select (newbo);
+ m->select (newbo);
else
return;
if (actionSettingsAutoEditNewBranch->isOn())
{
if (!actionSettingsAutoSelectNewBranch->isOn())
- prevSelection=me->getModel()->getSelectString (bo); // TODO access directly
- editHeading();
+ prevSelection=m->getSelectString (bo);
+ currentMapEditor()->editHeading();
}
}
}
void Main::editNewBranchBelow()
{
- MapEditor *me=currentMapEditor();
- if (!lineedit->isVisible() && me)
+ VymModel *m=currentModel();
+ if (!lineedit->isVisible() && m)
{
- BranchObj *bo=(BranchObj*)me->getSelection();
- BranchObj *newbo=me->addNewBranch (1);
+ BranchObj *bo=(BranchObj*)m->getSelection();
+ BranchObj *newbo=m->addNewBranch (1);
if (newbo)
- me->select (newbo);
+ m->select (newbo);
else
return;
if (actionSettingsAutoEditNewBranch->isOn())
{
if (!actionSettingsAutoSelectNewBranch->isOn())
- prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
- editHeading();
+ prevSelection=m->getSelectString(bo);
+ currentMapEditor()->editHeading();
}
}
}
@@ -2999,99 +3075,100 @@
fileSaveAs (PartOfMap);
}
-void Main::editDeleteKeepChilds()
+void Main::editDeleteKeepChildren()
{
- if (currentMapEditor())
- currentMapEditor()->deleteKeepChilds();
+ VymModel *m=currentModel();
+ if (m) m->deleteKeepChildren();
}
-void Main::editDeleteChilds()
+void Main::editDeleteChildren()
{
- if (currentMapEditor())
- currentMapEditor()->deleteChilds();
+ VymModel *m=currentModel();
+ if (m) m->deleteChildren();
}
void Main::editDeleteSelection()
{
- if (currentMapEditor() && actionSettingsUseDelKey->isOn())
- currentMapEditor()->deleteSelection();
+ VymModel *m=currentModel();
+ if (m && actionSettingsUseDelKey->isOn())
+ m->deleteSelection();
}
void Main::editUpperBranch()
{
- if (currentMapEditor())
- currentMapEditor()->selectUpperBranch();
+ VymModel *m=currentModel();
+ if (m) m->selectUpperBranch();
}
void Main::editLowerBranch()
{
- if (currentMapEditor())
- currentMapEditor()->selectLowerBranch();
+ VymModel *m=currentModel();
+ if (m) m->selectLowerBranch();
}
void Main::editLeftBranch()
{
- if (currentMapEditor())
- currentMapEditor()->selectLeftBranch();
+ VymModel *m=currentModel();
+ if (m) m->selectLeftBranch();
}
void Main::editRightBranch()
{
- if (currentMapEditor())
- currentMapEditor()->selectRightBranch();
+ VymModel *m=currentModel();
+ if (m) m->selectRightBranch();
}
void Main::editFirstBranch()
{
- if (currentMapEditor())
- currentMapEditor()->selectFirstBranch();
+ VymModel *m=currentModel();
+ if (m) m->selectFirstBranch();
}
void Main::editLastBranch()
{
- if (currentMapEditor())
- currentMapEditor()->selectLastBranch();
+ VymModel *m=currentModel();
+ if (m) m->selectLastBranch();
}
void Main::editLoadImage()
{
- if (currentMapEditor())
- currentMapEditor()->loadFloatImage();
+ VymModel *m=currentModel();
+ if (m) m->loadFloatImage();
}
void Main::editSaveImage()
{
- if (currentMapEditor())
- currentMapEditor()->saveFloatImage();
+ VymModel *m=currentModel();
+ if (m) m->saveFloatImage();
}
void Main::editFollowXLink(QAction *a)
{
- if (currentMapEditor())
- currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
+ VymModel *m=currentModel();
+ if (m)
+ m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
}
void Main::editEditXLink(QAction *a)
{
- if (currentMapEditor())
- currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
+ VymModel *m=currentModel();
+ if (m)
+ m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
}
void Main::formatSelectColor()
{
- if (currentMapEditor())
- {
- QColor col = QColorDialog::getColor((currentColor ), this );
- if ( !col.isValid() ) return;
- colorChanged( col );
- }
+ QColor col = QColorDialog::getColor((currentColor ), this );
+ if ( !col.isValid() ) return;
+ colorChanged( col );
}
void Main::formatPickColor()
{
- if (currentMapEditor())
- colorChanged( currentMapEditor()->getCurrentHeadingColor() );
+ VymModel *m=currentModel();
+ if (m)
+ colorChanged( m->getCurrentHeadingColor() );
}
void Main::colorChanged(QColor c)
@@ -3104,86 +3181,102 @@
void Main::formatColorBranch()
{
- if (currentMapEditor())
- currentMapEditor()->colorBranch(currentColor);
+ VymModel *m=currentModel();
+ if (m) m->colorBranch(currentColor);
}
void Main::formatColorSubtree()
{
- if (currentMapEditor())
- currentMapEditor()->colorSubtree (currentColor);
+ VymModel *m=currentModel();
+ if (m) m->colorSubtree (currentColor);
}
void Main::formatLinkStyleLine()
{
- if (currentMapEditor())
+ VymModel *m=currentModel();
+ if (m)
{
- currentMapEditor()->setMapLinkStyle("StyleLine");
+ m->setMapLinkStyle("StyleLine");
actionFormatLinkStyleLine->setOn(true);
}
}
void Main::formatLinkStyleParabel()
{
- if (currentMapEditor())
+ VymModel *m=currentModel();
+ if (m)
{
- currentMapEditor()->setMapLinkStyle("StyleParabel");
+ m->setMapLinkStyle("StyleParabel");
actionFormatLinkStyleParabel->setOn(true);
}
}
void Main::formatLinkStylePolyLine()
{
- if (currentMapEditor())
+ VymModel *m=currentModel();
+ if (m)
{
- currentMapEditor()->setMapLinkStyle("StylePolyLine");
+ m->setMapLinkStyle("StylePolyLine");
actionFormatLinkStylePolyLine->setOn(true);
}
}
void Main::formatLinkStylePolyParabel()
{
- if (currentMapEditor())
+ VymModel *m=currentModel();
+ if (m)
{
- currentMapEditor()->setMapLinkStyle("StylePolyParabel");
+ m->setMapLinkStyle("StylePolyParabel");
actionFormatLinkStylePolyParabel->setOn(true);
}
}
void Main::formatSelectBackColor()
{
- if (currentMapEditor())
- currentMapEditor()->selectMapBackgroundColor();
+ VymModel *m=currentModel();
+ if (m) m->selectMapBackgroundColor();
}
void Main::formatSelectBackImage()
{
- if (currentMapEditor())
- currentMapEditor()->selectMapBackgroundImage();
+ VymModel *m=currentModel();
+ if (m)
+ m->selectMapBackgroundImage();
}
void Main::formatSelectLinkColor()
{
- if (currentMapEditor())
- currentMapEditor()->selectMapLinkColor();
+ VymModel *m=currentModel();
+ if (m)
+ {
+ QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
+ m->setMapDefLinkColor( col );
+ }
}
void Main::formatSelectSelectionColor()
{
- if (currentMapEditor())
- currentMapEditor()->selectMapSelectionColor();
+ VymModel *m=currentModel();
+ if (m)
+ {
+ QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
+ m->setSelectionColor (col);
+ }
+
}
void Main::formatToggleLinkColorHint()
{
- currentMapEditor()->toggleMapLinkColorHint();
+ VymModel *m=currentModel();
+ if (m) m->toggleMapLinkColorHint();
}
void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
{
- if (currentMapEditor())
- currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
+ VymModel *m=currentModel();
+ if (m)
+ m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
}
void Main::viewZoomReset()
@@ -3218,23 +3311,20 @@
void Main::viewCenter()
{
- MapEditor *me=currentMapEditor();
- if (me)
- {
- me->ensureSelectionVisible();
- }
+ VymModel *m=currentModel();
+ if (m) m->ensureSelectionVisible();
}
void Main::networkStartServer()
{
- MapEditor *me=currentMapEditor();
- if (me) me->newServer();
+ VymModel *m=currentModel();
+ if (m) m->newServer();
}
void Main::networkConnect()
{
- MapEditor *me=currentMapEditor();
- if (me) me->connectToServer();
+ VymModel *m=currentModel();
+ if (m) m->connectToServer();
}
bool Main::settingsPDF()
@@ -3352,19 +3442,7 @@
branchPropertyWindow->hide();
else
branchPropertyWindow->show();
-
- if(currentMapEditor())
- {
- BranchObj *bo=currentMapEditor()->getSelectedBranch();
- if (bo)
- {
- branchPropertyWindow->setMapEditor(currentMapEditor());
- branchPropertyWindow->setBranch(bo);
- return;
- }
-
- }
- branchPropertyWindow->setBranch(NULL);
+ branchPropertyWindow->setModel (currentModel() );
}
void Main::windowToggleAntiAlias()
@@ -3373,7 +3451,6 @@
MapEditor *me;
for (int i=0;icount();i++)
{
-
me=(MapEditor*)tabWidget->page(i);
me->setAntiAlias(b);
}
@@ -3399,33 +3476,35 @@
void Main::updateNoteFlag()
{
- if (currentMapEditor())
- currentMapEditor()->updateNoteFlag();
+ // this slot is connected to TextEditor::textHasChanged()
+
+ VymModel *m=currentModel();
+ if (m) m->updateNoteFlag();
}
void Main::updateSatellites(MapEditor *me)
{
- branchPropertyWindow->setMapEditor (me);
+ branchPropertyWindow->setModel (me->getModel() );
}
void Main::updateActions()
{
- MapEditor *me=currentMapEditor();
- if (!me) return;
-
- historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
+ VymModel *m =currentModel();
+ if (!m) return;
+
+ historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
// updateActions is also called when NoteEditor is closed
actionViewToggleNoteEditor->setOn (textEditor->isVisible());
actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
- if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
+ if (m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
actionFormatLinkColorHint->setOn(true);
else
actionFormatLinkColorHint->setOn(false);
- switch (me->getMapLinkStyle())
+ switch (m->getMapLinkStyle())
{
case LinkableMapObj::Line:
actionFormatLinkStyleLine->setOn(true);
@@ -3445,26 +3524,26 @@
// Update colors
QPixmap pix( 16, 16 );
- pix.fill( me->getMapBackgroundColor() );
+ pix.fill( m->getMapBackgroundColor() );
actionFormatBackColor->setIconSet( pix );
- pix.fill( me->getSelectionColor() );
+ pix.fill( m->getSelectionColor() );
actionFormatSelectionColor->setIconSet( pix );
- pix.fill( me->getMapDefLinkColor() );
+ pix.fill( m->getMapDefLinkColor() );
actionFormatLinkColor->setIconSet( pix );
- actionFileSave->setEnabled( me->hasChanged() );
- if (me->isUndoAvailable())
+ actionFileSave->setEnabled( m->hasChanged() );
+ if (m->isUndoAvailable())
actionEditUndo->setEnabled( true);
else
actionEditUndo->setEnabled( false);
- if (me->isRedoAvailable())
+ if (m->isRedoAvailable())
actionEditRedo->setEnabled( true);
else
actionEditRedo->setEnabled( false);
- LinkableMapObj *selection=me->getSelection();
+ LinkableMapObj *selection=m->getSelection();
if (selection)
{
if ( (typeid(*selection) == typeid(BranchObj)) ||
@@ -3636,8 +3715,8 @@
void Main::runScript (const QString &script)
{
- if (currentMapEditor())
- currentMapEditor()->runScript (script);
+ VymModel *m=currentModel();
+ if (m) m->runScript (script);
}
void Main::runScriptEverywhere (const QString &script)
@@ -3646,7 +3725,7 @@
for (int i=0;i<=tabWidget->count() -1;i++)
{
me=(MapEditor*)tabWidget->page(i);
- if (me) me->runScript (script);
+ if (me) me->getModel()->runScript (script);
}
}
@@ -3828,41 +3907,13 @@
}
QTextStream ts( &f );
- QString m= ts.read();
-
- if (! m.isEmpty())
+ QString macro= ts.read();
+
+ if (! macro.isEmpty())
{
- //cout <<"Main::callMacro m="<runScript (m);
+ VymModel *m=currentModel();
+ if (m) m->runScript(macro);
}
}
}
-
-
-//////////////////////////////////
-/*
-@@ -2544,18 +2576,27 @@
- // Try to open new tab in existing konqueror started previously by vym
- p=new QProcess (this);
- args.clear();
-- args<< QString("konqueror-%1").arg(procBrowser->pid())<<
-- "konqueror-mainwindow#1"<<
-- "newTab" <<
-+#if defined(Q_OS_WIN32)
-+ // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
-+ // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
-+ args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
-+ "konqueror-mainwindow#1"<<
-+ "newTab" <<
- urls.at(i);
-+#else
-+ args<< QString("konqueror-%1").arg(procBrowser->pid())<<
-+ "konqueror-mainwindow#1"<<
-+ "newTab" <<
-+ urls.at(i);
-+#endif
- p->start ("dcop",args);
- if ( !p->waitForStarted() ) success=false;
- }
-*/
diff -r 192e1392ba6a -r 12958f987bcf mainwindow.h
--- a/mainwindow.h Wed Jul 16 10:44:44 2008 +0000
+++ b/mainwindow.h Wed Jul 16 10:46:14 2008 +0000
@@ -4,6 +4,7 @@
#include
#include "branchpropwindow.h"
+#include "extrainfodialog.h"
#include "file.h"
#include "findwindow.h"
#include "historywindow.h"
@@ -56,6 +57,7 @@
void hideEvent (QHideEvent * );
void showEvent (QShowEvent * );
MapEditor* currentMapEditor() const;
+ VymModel* currentModel() const;
private slots:
void editorChanged(QWidget*);
@@ -65,10 +67,10 @@
void fileLoad();
void fileLoadRecent();
void addRecentMap (const QString &);
- void fileSave(MapEditor*, const SaveMode & );
+ void fileSave(VymModel*, const SaveMode & );
void fileSave();
public slots:
- void fileSave(MapEditor *); // autosave from MapEditor
+ void fileSave(VymModel*); // autosave from MapEditor
private slots:
void fileSaveAs(const SaveMode &);
void fileSaveAs();
@@ -116,10 +118,10 @@
void openVymLinks(const QStringList &);
void editVymLink();
void editOpenMultipleVymLinks();
- void editHeadingFinished();
void editAttributeFinished();
public slots:
- void editHeading();
+ void editHeadingFinished(VymModel *m);
+// void editHeading();
void editAttribute();
void editOpenVymLink();
private slots:
@@ -130,7 +132,7 @@
void editMoveDown();
void editSortChildren();
void editToggleScroll();
- void editUnscrollChilds();
+ void editUnscrollChildren();
void editAddMapCenter();
void editNewBranch();
void editNewBranchBefore();
@@ -139,8 +141,8 @@
void editImportAdd();
void editImportReplace();
void editSaveBranch();
- void editDeleteKeepChilds();
- void editDeleteChilds();
+ void editDeleteKeepChildren();
+ void editDeleteChildren();
void editDeleteSelection();
void editUpperBranch();
void editLowerBranch();
@@ -230,6 +232,8 @@
QStringList imageTypes;
+ QList models;
+
QLineEdit *lineedit; // to enter headings of branches
QString prevSelection;
@@ -284,8 +288,8 @@
QAction *actionEditAddBranchBefore;
QAction *actionEditAddBranchAbove;
QAction *actionEditAddBranchBelow;
- QAction *actionEditDeleteKeepChilds;
- QAction *actionEditDeleteChilds;
+ QAction *actionEditDeleteKeepChildren;
+ QAction *actionEditDeleteChildren;
QAction *actionEditImportAdd;
QAction *actionEditImportReplace;
QAction *actionEditSaveBranch;
diff -r 192e1392ba6a -r 12958f987bcf mapcenterobj.cpp
--- a/mapcenterobj.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/mapcenterobj.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -73,7 +73,7 @@
void MapCenterObj::moveAllBy (double dx, double dy)
{
- // Move myself and childs
+ // Move myself and children
BranchObj::moveBy(dx,dy);
}
diff -r 192e1392ba6a -r 12958f987bcf noteobj.cpp
--- a/noteobj.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/noteobj.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -51,6 +51,7 @@
QString NoteObj::getNoteASCII(const QString &indent, const int &width)
{
+ // FIXME make use of width
QString r=note;
// Remove all ...
@@ -167,12 +168,13 @@
{
QString n=note;
- // Remove the doctype, which will confuse parsing
+ // Remove the doctype, which will confuse parsing
// with XmlReader in Qt >= 4.4
QRegExp rx("");
rx.setMinimal(true);
n.replace (rx,"");
-
+
+
// QTextEdit may generate fontnames with unquoted &, like
// in "Lucida B&H". This is invalid in XML and thus would crash
// the XML parser
@@ -183,6 +185,7 @@
bool inbracket=false;
int begin_bracket=0;
bool inquot=false;
+
while (pos1)
{
- rx.setPattern("style=\\s*\"(.*)\"\\s*style=\\s*\"(.*)\"");
+ rx.setPattern ("style=\\s*\"(.*)\"\\s*style=\\s*\"(.*)\"");
s.replace(rx,"style=\"\\1 \\2\"");
n.replace (begin_bracket,sl,s);
pos=pos-(sl-s.length());
@@ -218,8 +221,6 @@
}
pos++;
}
-
-
return beginElement ("htmlnote",attribut("fonthint",fonthint)) + "\n"+ n+ "\n" +endElement ("htmlnote");
}
diff -r 192e1392ba6a -r 12958f987bcf ornamentedobj.cpp
--- a/ornamentedobj.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/ornamentedobj.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -93,10 +93,10 @@
void OrnamentedObj::setLinkColor()
{
- if (mapEditor->getMapLinkColorHint()==HeadingColor)
+ if (model->getMapLinkColorHint()==HeadingColor)
LinkableMapObj::setLinkColor (heading->getColor());
else
- LinkableMapObj::setLinkColor (mapEditor->getMapDefLinkColor());
+ LinkableMapObj::setLinkColor (model->getMapDefLinkColor());
}
void OrnamentedObj::setColor (QColor col)
@@ -321,7 +321,7 @@
QDir d(s);
if (!d.path().startsWith ("/"))
{
- QString p=mapEditor->getDestPath();
+ QString p=model->getDestPath();
int i=p.findRev("/",-1);
d.setPath(p.left(i)+"/"+s);
d.convertToAbs();
@@ -432,7 +432,7 @@
if (!systemFlags->isActive ("note")) return;
systemFlags->deactivate("note");
}
- mapEditor->setChanged();
+ model->setChanged();
calcBBoxSize();
positionBBox();
move (absPos.x(), absPos.y() );
@@ -498,7 +498,7 @@
QString vymLinkAttr;
if (!vymLink.isEmpty())
- vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
+ vymLinkAttr=attribut ("vymLink",convertToRel(model->getDestPath(),vymLink) );
QString hideExpAttr;
if (hideExport)
diff -r 192e1392ba6a -r 12958f987bcf ornamentedobj.h
--- a/ornamentedobj.h Wed Jul 16 10:44:44 2008 +0000
+++ b/ornamentedobj.h Wed Jul 16 10:46:14 2008 +0000
@@ -79,7 +79,7 @@
virtual void updateNoteFlag();
virtual void getNoteFromTextEditor ();
virtual void updateFlagsToolbar();
- virtual void setHideInExport(bool); // set export of object (and childs)
+ virtual void setHideInExport(bool); // set export of object (and children)
virtual bool hideInExport();
virtual bool isHidden ();
virtual QString getOrnXMLAttr(); // get attributes for saveToDir
diff -r 192e1392ba6a -r 12958f987bcf selection.cpp
--- a/selection.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/selection.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -13,6 +13,7 @@
Selection::Selection()
{
color= QColor(255,255,0);
+ blocked=false;
}
Selection::~Selection()
@@ -37,7 +38,7 @@
lastSelectList.clear();
}
-void Selection::update()
+void Selection::update() // FIXME this needs to be adapted to several views
{
QRectF bbox;
int w=0;
@@ -120,6 +121,21 @@
}
}
+bool Selection::isBlocked()
+{
+ return blocked;
+}
+
+void Selection::block()
+{
+ blocked=true;
+}
+
+void Selection::unblock()
+{
+ blocked=false;
+}
+
bool Selection::isEmpty()
{
return selectList.isEmpty();
diff -r 192e1392ba6a -r 12958f987bcf selection.h
--- a/selection.h Wed Jul 16 10:44:44 2008 +0000
+++ b/selection.h Wed Jul 16 10:46:14 2008 +0000
@@ -29,6 +29,9 @@
bool select (const QString &);
bool reselect ();
void unselect ();
+ bool isBlocked ();
+ void block();
+ void unblock();
bool isEmpty();
uint count();
Type type();
@@ -48,6 +51,8 @@
QGraphicsScene *scene;
QColor color;
+ bool blocked; //!< if true, no new selection possible
};
+
#endif
diff -r 192e1392ba6a -r 12958f987bcf version.h
--- a/version.h Wed Jul 16 10:44:44 2008 +0000
+++ b/version.h Wed Jul 16 10:46:14 2008 +0000
@@ -4,10 +4,10 @@
#include
#define __VYM_NAME "VYM"
-#define __VYM_VERSION "1.12.1"
-#define __VYM_CODENAME "Maintenance Update"
-//#define __VYM_CODENAME "Codename: development version"
-#define __VYM_BUILD_DATE "2008-07-14"
+#define __VYM_VERSION "1.13.0"
+//#define __VYM_CODENAME "Codename: RC-1"
+#define __VYM_CODENAME "Codename: development version"
+#define __VYM_BUILD_DATE "2008-07-02"
bool checkVersion(const QString &);
diff -r 192e1392ba6a -r 12958f987bcf vym.pro
--- a/vym.pro Wed Jul 16 10:44:44 2008 +0000
+++ b/vym.pro Wed Jul 16 10:46:14 2008 +0000
@@ -7,11 +7,10 @@
TRANSLATIONS += lang/vym_de.ts
TRANSLATIONS += lang/vym_en.ts
TRANSLATIONS += lang/vym_es.ts
+TRANSLATIONS += lang/vym_it.ts
TRANSLATIONS += lang/vym_fr.ts
-TRANSLATIONS += lang/vym_it.ts
+TRANSLATIONS += lang/vym_zh_CN.ts
TRANSLATIONS += lang/vym_pt_BR.ts
-TRANSLATIONS += lang/vym_ru.ts
-TRANSLATIONS += lang/vym_zh_CN.ts
# Manifest embedding was suggested by Qt docs somewhere...
win32: CONFIG += embed_manifest_exe
diff -r 192e1392ba6a -r 12958f987bcf vymmodel.cpp
--- a/vymmodel.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/vymmodel.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -1,32 +1,122 @@
#include
#include
+#include "vymmodel.h"
+
+#include "editxlinkdialog.h"
+#include "exports.h"
+#include "exportxhtmldialog.h"
+#include "file.h"
#include "geometry.h" // for addBBox
-#include "vymmodel.h"
-
-
+#include "mainwindow.h"
+#include "mapcenterobj.h"
+#include "misc.h"
+#include "parser.h"
+#include "selection.h"
+
+
+#include "warningdialog.h"
+#include "xml-freemind.h"
+#include "xml-vym.h"
+
+
+extern bool debug;
+extern Main *mainWindow;
extern Settings settings;
+extern QString tmpVymDir;
+
+extern TextEditor *textEditor;
+
+
+extern QString clipboardDir;
+extern QString clipboardFile;
+extern bool clipboardEmpty;
+
+extern ImageIO imageIO;
+
+extern QString vymName;
+extern QString vymVersion;
+extern QDir vymBaseDir;
+
+extern QDir lastImageDir;
+extern QDir lastFileDir;
+
+extern FlagRowObj *standardFlagsDefault;
+
+extern Settings settings;
+
+
+
+int VymModel::mapNum=0; // make instance
VymModel::VymModel()
{
// cout << "Const VymModel\n";
+ init();
}
VymModel::~VymModel()
{
// cout << "Destr VymModel\n";
+ autosaveTimer->stop();
+ fileChangedTimer->stop();
+ clear();
}
void VymModel::clear()
{
+ selection.clear();
+
while (!mapCenters.isEmpty())
delete mapCenters.takeFirst();
}
void VymModel::init ()
{
- addMapCenter();
+ // We should have at least one map center to start with
+ // addMapCenter(); FIXME create this in MapEditor as long as model is part of that
+
+ // History
+ mapNum++;
+ mapChanged=false;
+ mapDefault=true;
+ mapUnsaved=false;
+
+ curStep=0;
+ redosAvail=0;
+ undosAvail=0;
+
+ stepsTotal=settings.readNumEntry("/history/stepsTotal",100);
+ undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal));
+ mainWindow->updateHistory (undoSet);
+
+ // Create tmp dirs
+ makeTmpDirectories();
+
+ // Files
+ zipped=true;
+ filePath="";
+ fileName=tr("unnamed");
+ mapName="";
+ blockReposition=false;
+ blockSaveState=false;
+
+ autosaveTimer=new QTimer (this);
+ connect(autosaveTimer, SIGNAL(timeout()), this, SLOT(autosave()));
+
+ fileChangedTimer=new QTimer (this);
+ fileChangedTimer->start(3000);
+ connect(fileChangedTimer, SIGNAL(timeout()), this, SLOT(fileChanged()));
+
+
+ // selections
+ selection.setModel (this);
+ selection.unselect();
+
+ // find routine
+ itFind=NULL;
+ EOFind=false;
// animations
animationUse=settings.readBoolEntry("/animation/use",false);
@@ -36,8 +126,36 @@
animationTimer=new QTimer (this);
connect(animationTimer, SIGNAL(timeout()), this, SLOT(animate()));
+ // View - map
+ defLinkColor=QColor (0,0,255);
+ defXLinkColor=QColor (180,180,180);
+ linkcolorhint=LinkableMapObj::DefaultColor;
+ linkstyle=LinkableMapObj::PolyParabel;
+ defXLinkWidth=1;
+ defXLinkColor=QColor (230,230,230);
+
+ hidemode=HideNone;
+
+
+
+ // Network
+ netstate=Offline;
+
+ // Create MapCenter
+ // addMapCenter(); FIXME create this in MapEditor until BO and MCO are independent of scene
+
}
+void VymModel::makeTmpDirectories()
+{
+ // Create unique temporary directories
+ tmpMapDir = tmpVymDir+QString("/model-%1").arg(mapNum);
+ histPath = tmpMapDir+"/history";
+ QDir d;
+ d.mkdir (tmpMapDir);
+}
+
+
void VymModel::setMapEditor(MapEditor *me)
{
mapEditor=me;
@@ -50,76 +168,1183 @@
return mapEditor;
}
-void VymModel::setVersion (const QString &s)
+bool VymModel::isRepositionBlocked()
{
- version=s;
+ return blockReposition;
}
-void VymModel::setAuthor (const QString &s)
+void VymModel::updateActions() // FIXME maybe don't update if blockReposition is set
{
- author=s;
+ // Tell mainwindow to update states of actions
+ mainWindow->updateActions();
}
-QString VymModel::getAuthor()
+
+
+QString VymModel::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPointF &offset, LinkableMapObj *saveSel)
{
- return author;
+ // tmpdir temporary directory to which data will be written
+ // 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 scene.
+ // Needed for XML export
+
+ // Save Header
+ QString ls;
+ switch (linkstyle)
+ {
+ case LinkableMapObj::Line:
+ ls="StyleLine";
+ break;
+ case LinkableMapObj::Parabel:
+ ls="StyleParabel";
+ break;
+ case LinkableMapObj::PolyLine:
+ ls="StylePolyLine";
+ break;
+ default:
+ ls="StylePolyParabel";
+ break;
+ }
+
+ QString s="\n";
+ QString colhint="";
+ if (linkcolorhint==LinkableMapObj::HeadingColor)
+ colhint=attribut("linkColorHint","HeadingColor");
+
+ QString mapAttr=attribut("version",vymVersion);
+ if (!saveSel)
+ mapAttr+= attribut("author",author) +
+ attribut("comment",comment) +
+ attribut("date",getDate()) +
+ attribut("backgroundColor", mapScene->backgroundBrush().color().name() ) +
+ attribut("selectionColor", selection.getColor().name() ) +
+ attribut("linkStyle", ls ) +
+ attribut("linkColor", defLinkColor.name() ) +
+ attribut("defXLinkColor", defXLinkColor.name() ) +
+ attribut("defXLinkWidth", QString().setNum(defXLinkWidth,10) ) +
+ colhint;
+ s+=beginElement("vymmap",mapAttr);
+ incIndent();
+
+ // Find the used flags while traversing the tree
+ standardFlagsDefault->resetUsedCounter();
+
+ // Reset the counters before saving
+ // TODO constr. of FIO creates lots of objects, better do this in some other way...
+ FloatImageObj (mapScene).resetSaveCounter();
+
+ // Build xml recursivly
+ if (!saveSel || typeid (*saveSel) == typeid (MapCenterObj))
+ // Save complete map, if saveSel not set
+ s+=saveToDir(tmpdir,prefix,writeflags,offset);
+ else
+ {
+ if ( typeid(*saveSel) == typeid(BranchObj) )
+ // Save Subtree
+ s+=((BranchObj*)(saveSel))->saveToDir(tmpdir,prefix,offset);
+ else if ( typeid(*saveSel) == typeid(FloatImageObj) )
+ // Save image
+ s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix);
+ }
+
+ // Save local settings
+ s+=settings.getDataXML (destPath);
+
+ // Save selection
+ if (!selection.isEmpty() && !saveSel )
+ s+=valueElement("select",selection.getSelectString());
+
+ decIndent();
+ s+=endElement("vymmap");
+
+ if (writeflags)
+ standardFlagsDefault->saveToDir (tmpdir+"/flags/","",writeflags);
+ return s;
}
-void VymModel::setComment (const QString &s)
+void VymModel::setFilePath(QString fpath, QString destname)
{
- comment=s;
+ if (fpath.isEmpty() || fpath=="")
+ {
+ filePath="";
+ fileName="";
+ destPath="";
+ } else
+ {
+ filePath=fpath; // becomes absolute path
+ fileName=fpath; // gets stripped of path
+ destPath=destname; // needed for vymlinks and during load to reset fileChangedTime
+
+ // If fpath is not an absolute path, complete it
+ filePath=QDir(fpath).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 VymModel::getComment ()
+void VymModel::setFilePath(QString fpath)
{
- return comment;
+ setFilePath (fpath,fpath);
}
-QString VymModel::getDate ()
+QString VymModel::getFilePath()
{
- return QDate::currentDate().toString ("yyyy-MM-dd");
+ return filePath;
}
-void VymModel::setScene (QGraphicsScene *s)
+QString VymModel::getFileName()
{
- mapScene=s;
- init(); // Here we have a mapScene set,
- // which is (still) needed to create MapCenters
+ return fileName;
}
+QString VymModel::getMapName()
+{
+ return mapName;
+}
+
+QString VymModel::getDestPath()
+{
+ return destPath;
+}
+
+ErrorCode VymModel::load (QString fname, const LoadMode &lmode, const FileType &ftype)
+{
+ ErrorCode err=success;
+
+ parseBaseHandler *handler;
+ fileType=ftype;
+ switch (fileType)
+ {
+ case VymMap: handler=new parseVYMHandler; break;
+ case FreemindMap : handler=new parseFreemindHandler; break;
+ default:
+ QMessageBox::critical( 0, tr( "Critical Parse Error" ),
+ "Unknown FileType in VymModel::load()");
+ return aborted;
+ }
+ if (lmode==NewMap)
+ {
+ selection.clear();
+ // FIXME not needed??? model->setMapEditor(this);
+ // (map state is set later at end of load...)
+ } else
+ {
+ BranchObj *bo=selection.getBranch();
+ if (!bo) return aborted;
+ if (lmode==ImportAdd)
+ saveStateChangingPart(
+ bo,
+ bo,
+ QString("addMapInsert (%1)").arg(fname),
+ QString("Add map %1 to %2").arg(fname).arg(getObjectName(bo)));
+ else
+ saveStateChangingPart(
+ bo,
+ bo,
+ QString("addMapReplace(%1)").arg(fname),
+ QString("Add map %1 to %2").arg(fname).arg(getObjectName(bo)));
+ }
+
+
+ // Create temporary directory for packing
+ bool ok;
+ QString tmpZipDir=makeTmpDir (ok,"vym-pack");
+ if (!ok)
+ {
+ QMessageBox::critical( 0, tr( "Critical Load Error" ),
+ tr("Couldn't create temporary directory before load\n"));
+ return aborted;
+ }
+
+ // Try to unzip file
+ err=unzipDir (tmpZipDir,fname);
+ QString xmlfile;
+ if (err==nozip)
+ {
+ xmlfile=fname;
+ zipped=false;
+ } else
+ {
+ zipped=true;
+
+ // Look for mapname.xml
+ xmlfile= fname.left(fname.findRev(".",-1,true));
+ xmlfile=xmlfile.section( '/', -1 );
+ QFile mfile( tmpZipDir + "/" + xmlfile + ".xml");
+ if (!mfile.exists() )
+ {
+ // mapname.xml does not exist, well,
+ // maybe someone renamed the mapname.vym file...
+ // Try to find any .xml in the toplevel
+ // directory of the .vym file
+ QStringList flist=QDir (tmpZipDir).entryList("*.xml");
+ if (flist.count()==1)
+ {
+ // Only one entry, take this one
+ xmlfile=tmpZipDir + "/"+flist.first();
+ } else
+ {
+ for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
+ *it=tmpZipDir + "/" + *it;
+ // TODO 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
+ xmlfile=mfile.name();
+ }
+
+ QFile file( xmlfile);
+
+ // I am paranoid: file should exist anyway
+ // according to check in mainwindow.
+ if (!file.exists() )
+ {
+ QMessageBox::critical( 0, tr( "Critical Parse Error" ),
+ tr(QString("Couldn't open map %1").arg(file.name())));
+ err=aborted;
+ } else
+ {
+ bool blockSaveStateOrg=blockSaveState;
+ blockReposition=true;
+ blockSaveState=true;
+ QXmlInputSource source( file);
+ QXmlSimpleReader reader;
+ reader.setContentHandler( handler );
+ reader.setErrorHandler( handler );
+ handler->setModel ( this);
+
+
+ // We need to set the tmpDir in order to load files with rel. path
+ QString tmpdir;
+ if (zipped)
+ tmpdir=tmpZipDir;
+ else
+ tmpdir=fname.left(fname.findRev("/",-1));
+ handler->setTmpDir (tmpdir);
+ handler->setInputFile (file.name());
+ handler->setLoadMode (lmode);
+ bool ok = reader.parse( source );
+ blockReposition=false;
+ blockSaveState=blockSaveStateOrg;
+ file.close();
+ if ( ok )
+ {
+ reposition(); // FIXME reposition the view instead...
+ selection.update();
+ if (lmode==NewMap)
+ {
+ mapDefault=false;
+ mapChanged=false;
+ mapUnsaved=false;
+ autosaveTimer->stop();
+ }
+
+ // Reset timestamp to check for later updates of file
+ fileChangedTime=QFileInfo (destPath).lastModified();
+ } 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
+ }
+ }
+
+ // Delete tmpZipDir
+ removeDir (QDir(tmpZipDir));
+
+ updateActions();
+
+ return err;
+}
+
+ErrorCode VymModel::save (const SaveMode &savemode)
+{
+ QString tmpZipDir;
+ QString mapFileName;
+ QString safeFilePath;
+
+ ErrorCode err=success;
+
+ if (zipped)
+ // save as .xml
+ mapFileName=mapName+".xml";
+ else
+ // use name given by user, even if he chooses .doc
+ mapFileName=fileName;
+
+ // Look, if we should zip the data:
+ if (!zipped)
+ {
+ QMessageBox mb( vymName,
+ tr("The map %1\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").arg(filePath),
+ 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)
+ zipped=true;
+ break;
+ case QMessageBox::No:
+ // save uncompressed
+ zipped=false;
+ break;
+ case QMessageBox::Cancel:
+ // do nothing
+ return aborted;
+ break;
+ }
+ }
+
+ // First backup existing file, we
+ // don't want to add to old zip archives
+ QFile f(destPath);
+ if (f.exists())
+ {
+ if ( settings.value ("/mapeditor/writeBackupFile").toBool())
+ {
+ QString backupFileName(destPath + "~");
+ QFile backupFile(backupFileName);
+ if (backupFile.exists() && !backupFile.remove())
+ {
+ QMessageBox::warning(0, tr("Save Error"),
+ tr("%1\ncould not be removed before saving").arg(backupFileName));
+ }
+ else if (!f.rename(backupFileName))
+ {
+ QMessageBox::warning(0, tr("Save Error"),
+ tr("%1\ncould not be renamed before saving").arg(destPath));
+ }
+ }
+ }
+
+ if (zipped)
+ {
+ // Create temporary directory for packing
+ bool ok;
+ tmpZipDir=makeTmpDir (ok,"vym-zip");
+ if (!ok)
+ {
+ QMessageBox::critical( 0, tr( "Critical Load Error" ),
+ tr("Couldn't create temporary directory before save\n"));
+ return aborted;
+ }
+
+ safeFilePath=filePath;
+ setFilePath (tmpZipDir+"/"+ mapName+ ".xml", safeFilePath);
+ } // zipped
+
+ // Create mapName and fileDir
+ makeSubDirs (fileDir);
+
+ QString saveFile;
+ if (savemode==CompleteMap || selection.isEmpty())
+ {
+ // Save complete map
+ saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),NULL);
+ mapChanged=false;
+ mapUnsaved=false;
+ autosaveTimer->stop();
+ }
+ else
+ {
+ // Save part of map
+ if (selection.type()==Selection::FloatImage)
+ saveFloatImage();
+ else
+ saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),selection.getBranch());
+ // TODO take care of multiselections
+ }
+
+ if (!saveStringToDisk(fileDir+mapFileName,saveFile))
+ {
+ err=aborted;
+ qWarning ("ME::saveStringToDisk failed!");
+ }
+
+ if (zipped)
+ {
+ // zip
+ if (err==success) err=zipDir (tmpZipDir,destPath);
+
+ // Delete tmpDir
+ removeDir (QDir(tmpZipDir));
+
+ // Restore original filepath outside of tmp zip dir
+ setFilePath (safeFilePath);
+ }
+
+ updateActions();
+ fileChangedTime=QFileInfo (destPath).lastModified();
+ return err;
+}
+
+void VymModel::addMapReplaceInt(const QString &undoSel, const QString &path)
+{
+ QString pathDir=path.left(path.findRev("/"));
+ QDir d(pathDir);
+ QFile file (path);
+
+ if (d.exists() )
+ {
+ // We need to parse saved XML data
+ parseVYMHandler handler;
+ QXmlInputSource source( file);
+ QXmlSimpleReader reader;
+ reader.setContentHandler( &handler );
+ reader.setErrorHandler( &handler );
+ handler.setModel ( this);
+ handler.setTmpDir ( pathDir ); // needed to load files with rel. path
+ if (undoSel.isEmpty())
+ {
+ unselect();
+ clear();
+ handler.setLoadMode (NewMap);
+ } else
+ {
+ select (undoSel);
+ handler.setLoadMode (ImportReplace);
+ }
+ blockReposition=true;
+ bool ok = reader.parse( source );
+ blockReposition=false;
+ if (! ok )
+ {
+ // This should never ever happen
+ QMessageBox::critical( 0, tr( "Critical Parse Error while reading %1").arg(path),
+ handler.errorProtocol());
+ }
+ } else
+ QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path));
+}
+
+void VymModel::addMapInsertInt (const QString &path, int pos)
+{
+ BranchObj *sel=selection.getBranch();
+ if (sel)
+ {
+ QString pathDir=path.left(path.findRev("/"));
+ QDir d(pathDir);
+ QFile file (path);
+
+ if (d.exists() )
+ {
+ // We need to parse saved XML data
+ parseVYMHandler handler;
+ QXmlInputSource source( file);
+ QXmlSimpleReader reader;
+ reader.setContentHandler( &handler );
+ reader.setErrorHandler( &handler );
+ handler.setModel (this);
+ handler.setTmpDir ( pathDir ); // needed to load files with rel. path
+ handler.setLoadMode (ImportAdd);
+ blockReposition=true;
+ bool ok = reader.parse( source );
+ blockReposition=false;
+ if (! ok )
+ {
+ // This should never ever happen
+ QMessageBox::critical( 0, tr( "Critical Parse Error while reading %1").arg(path),
+ handler.errorProtocol());
+ }
+ if (sel->getDepth()>0)
+ sel->getLastBranch()->linkTo (sel,pos);
+ } else
+ QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path));
+ }
+}
+
+FloatImageObj* VymModel::loadFloatImageInt (QString fn)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ FloatImageObj *fio;
+ bo->addFloatImage();
+ fio=bo->getLastFloatImage();
+ fio->load(fn);
+ reposition();
+ // FIXME needed? scene()->update();
+ return fio;
+ }
+ return NULL;
+}
+
+void VymModel::loadFloatImage ()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+
+ Q3FileDialog *fd=new Q3FileDialog( NULL);
+ fd->setMode (Q3FileDialog::ExistingFiles);
+ 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( Q3FileDialog::Contents );
+ fd->setCaption(vymName+" - " +tr("Load image"));
+ fd->setDir (lastImageDir);
+ fd->show();
+
+ if ( fd->exec() == QDialog::Accepted )
+ {
+ // TODO loadFIO in QT4 use: lastImageDir=fd->directory();
+ lastImageDir=QDir (fd->dirPath());
+ QString s;
+ FloatImageObj *fio;
+ for (int j=0; jselectedFiles().count(); j++)
+ {
+ s=fd->selectedFiles().at(j);
+ fio=loadFloatImageInt (s);
+ if (fio)
+ saveState(
+ (LinkableMapObj*)fio,
+ "delete ()",
+ bo,
+ QString ("loadImage (%1)").arg(s ),
+ QString("Add image %1 to %2").arg(s).arg(getObjectName(bo))
+ );
+ else
+ // TODO loadFIO error handling
+ qWarning ("Failed to load "+s);
+ }
+ }
+ delete (p);
+ delete (fd);
+ }
+}
+
+void VymModel::saveFloatImageInt (FloatImageObj *fio, const QString &type, const QString &fn)
+{
+ fio->save (fn,type);
+}
+
+void VymModel::saveFloatImage ()
+{
+ FloatImageObj *fio=selection.getFloatImage();
+ if (fio)
+ {
+ QFileDialog *fd=new QFileDialog( NULL);
+ fd->setFilters (imageIO.getFilters());
+ fd->setCaption(vymName+" - " +tr("Save image"));
+ fd->setFileMode( QFileDialog::AnyFile );
+ fd->setDirectory (lastImageDir);
+// fd->setSelection (fio->getOriginalFilename());
+ fd->show();
+
+ QString fn;
+ if ( fd->exec() == QDialog::Accepted && fd->selectedFiles().count()==1)
+ {
+ fn=fd->selectedFiles().at(0);
+ if (QFile (fn).exists() )
+ {
+ QMessageBox mb( vymName,
+ tr("The file %1 exists already.\n"
+ "Do you want to overwrite it?").arg(fn),
+ QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::Cancel | QMessageBox::Escape,
+ 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
+ delete (fd);
+ return;
+ break;
+ }
+ }
+ saveFloatImageInt (fio,fd->selectedFilter(),fn );
+ }
+ delete (fd);
+ }
+}
+
+
+void VymModel::importDirInt(BranchObj *dst, QDir d)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ // Traverse directories
+ d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks );
+ QFileInfoList list = d.entryInfoList();
+ QFileInfo fi;
+
+ for (int i = 0; i < list.size(); ++i)
+ {
+ fi=list.at(i);
+ if (fi.fileName() != "." && fi.fileName() != ".." )
+ {
+ dst->addBranch();
+ bo=dst->getLastBranch();
+ bo->setHeading (fi.fileName() );
+ bo->setColor (QColor("blue"));
+ bo->toggleScroll();
+ if ( !d.cd(fi.fileName()) )
+ QMessageBox::critical (0,tr("Critical Import Error"),tr("Cannot find the directory %1").arg(fi.fileName()));
+ else
+ {
+ // Recursively add subdirs
+ importDirInt (bo,d);
+ d.cdUp();
+ }
+ }
+ }
+ // Traverse files
+ d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks );
+ list = d.entryInfoList();
+
+ for (int i = 0; i < list.size(); ++i)
+ {
+ fi=list.at(i);
+ dst->addBranch();
+ bo=dst->getLastBranch();
+ bo->setHeading (fi.fileName() );
+ bo->setColor (QColor("black"));
+ if (fi.fileName().right(4) == ".vym" )
+ bo->setVymLink (fi.filePath());
+ }
+ }
+}
+
+void VymModel::importDirInt (const QString &s)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ saveStateChangingPart (bo,bo,QString ("importDir (\"%1\")").arg(s),QString("Import directory structure from %1").arg(s));
+
+ QDir d(s);
+ importDirInt (bo,d);
+ }
+}
+
+void VymModel::importDir()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ QStringList filters;
+ filters <<"VYM map (*.vym)";
+ QFileDialog *fd=new QFileDialog( NULL,vymName+ " - " +tr("Choose directory structure to import"));
+ fd->setMode (QFileDialog::DirectoryOnly);
+ fd->setFilters (filters);
+ fd->setCaption(vymName+" - " +tr("Choose directory structure to import"));
+ fd->show();
+
+ QString fn;
+ if ( fd->exec() == QDialog::Accepted )
+ {
+ importDirInt (fd->selectedFile() );
+ reposition();
+ //FIXME needed? scene()->update();
+ }
+ }
+}
+
+
+void VymModel::autosave()
+{
+ QDateTime now=QDateTime().currentDateTime();
+
+ // Disable autosave, while we have gone back in history
+ int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
+ if (redosAvail>0) return;
+
+ // Also disable autosave for new map without filename
+ if (filePath.isEmpty()) return;
+
+
+ if (mapUnsaved &&mapChanged && settings.value ("/autosave/use",true).toBool() )
+ {
+ if (QFileInfo(filePath).lastModified()<=fileChangedTime)
+ mainWindow->fileSave (this);
+ else
+ if (debug)
+ cout <<" ME::autosave rejected, file on disk is newer than last save.\n";
+
+ }
+}
+
+void VymModel::fileChanged()
+{
+ // Check if file on disk has changed meanwhile
+ if (!filePath.isEmpty())
+ {
+ QDateTime tmod=QFileInfo (filePath).lastModified();
+ if (tmod>fileChangedTime)
+ {
+ // FIXME switch to current mapeditor and finish lineedits...
+ QMessageBox mb( vymName,
+ tr("The file of the map on disk has changed:\n\n"
+ " %1\n\nDo you want to reload that map with the new file?").arg(filePath),
+ QMessageBox::Question,
+ QMessageBox::Yes ,
+ QMessageBox::Cancel | QMessageBox::Default,
+ QMessageBox::NoButton );
+
+ mb.setButtonText( QMessageBox::Yes, tr("Reload"));
+ mb.setButtonText( QMessageBox::No, tr("Ignore"));
+ switch( mb.exec() )
+ {
+ case QMessageBox::Yes:
+ // Reload map
+ load (filePath,NewMap,fileType);
+ case QMessageBox::Cancel:
+ fileChangedTime=tmod; // allow autosave to overwrite newer file!
+ }
+ }
+ }
+}
+
+bool VymModel::isDefault()
+{
+ return mapDefault;
+}
+
+void VymModel::makeDefault()
+{
+ mapChanged=false;
+ mapDefault=true;
+}
+
+bool VymModel::hasChanged()
+{
+ return mapChanged;
+}
+
+void VymModel::setChanged()
+{
+ if (!mapChanged)
+ autosaveTimer->start(settings.value("/autosave/ms/",300000).toInt());
+ mapChanged=true;
+ mapDefault=false;
+ mapUnsaved=true;
+ findReset();
+}
+
+
+QString VymModel::getObjectName (const LinkableMapObj *lmo)
+{
+ QString s;
+ if (!lmo) return QString("Error: NULL has no name!");
+
+ if ((typeid(*lmo) == typeid(BranchObj) ||
+ typeid(*lmo) == typeid(MapCenterObj)))
+ {
+
+ s=(((BranchObj*)lmo)->getHeading());
+ if (s=="") s="unnamed";
+ return QString("branch (%1)").arg(s);
+ }
+ if ((typeid(*lmo) == typeid(FloatImageObj) ))
+ return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename());
+ return QString("Unknown type has no name!");
+}
+
+void VymModel::redo()
+{
+ // Can we undo at all?
+ if (redosAvail<1) return;
+
+ bool blockSaveStateOrg=blockSaveState;
+ blockSaveState=true;
+
+ redosAvail--;
+
+ if (undosAvailstepsTotal) curStep=1;
+ QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
+ QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
+ QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
+ QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
+ QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
+ QString version=undoSet.readEntry ("/history/version");
+
+ /* TODO Maybe check for version, if we save the history
+ if (!checkVersion(version))
+ QMessageBox::warning(0,tr("Warning"),
+ tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion));
+ */
+
+ // Find out current undo directory
+ QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep));
+
+ if (debug)
+ {
+ cout << "VymModel::redo() begin\n";
+ cout << " undosAvail="<updateHistory (undoSet);
+ updateActions();
+
+ /* TODO remove testing
+ cout << "ME::redo() end\n";
+ cout << " undosAvail="<0)
+ return true;
+ else
+ return false;
+}
+
+void VymModel::undo()
+{
+ // Can we undo at all?
+ if (undosAvail<1) return;
+
+ mainWindow->statusMessage (tr("Autosave disabled during undo."));
+
+ bool blockSaveStateOrg=blockSaveState;
+ blockSaveState=true;
+
+ QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
+ QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
+ QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
+ QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
+ QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
+ QString version=undoSet.readEntry ("/history/version");
+
+ /* TODO Maybe check for version, if we save the history
+ if (!checkVersion(version))
+ QMessageBox::warning(0,tr("Warning"),
+ tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion));
+ */
+
+ // Find out current undo directory
+ QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep));
+
+ // select object before undo
+ if (!undoSelection.isEmpty())
+ select (undoSelection);
+
+ if (debug)
+ {
+ cout << "VymModel::undo() begin\n";
+ cout << " undosAvail="<updateHistory (undoSet);
+ updateActions();
+ selection.update();
+ ensureSelectionVisible();
+}
+
+bool VymModel::isUndoAvailable()
+{
+ if (undoSet.readNumEntry("/history/undosAvail",0)>0)
+ return true;
+ else
+ return false;
+}
+
+void VymModel::gotoHistoryStep (int i)
+{
+ // Restore variables
+ int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
+ int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
+
+ if (i<0) i=undosAvail+redosAvail;
+
+ // Clicking above current step makes us undo things
+ if (iundosAvail)
+ for (int j=undosAvail; jstepsTotal) curStep=1;
+
+ QString backupXML="";
+ QString histDir=getHistoryPath();
+ QString bakMapPath=histDir+"/map.xml";
+
+ // Create histDir if not available
+ QDir d(histDir);
+ if (!d.exists())
+ makeSubDirs (histDir);
+
+ // Save depending on how much needs to be saved
+ if (saveSel)
+ backupXML=saveToDir (histDir,mapName+"-",false, QPointF (),saveSel);
+
+ QString undoCommand="";
+ if (savemode==UndoCommand)
+ {
+ undoCommand=undoCom;
+ }
+ else if (savemode==PartOfMap )
+ {
+ undoCommand=undoCom;
+ undoCommand.replace ("PATH",bakMapPath);
+ }
+
+ if (!backupXML.isEmpty())
+ // Write XML Data to disk
+ saveStringToDisk (bakMapPath,backupXML);
+
+ // We would have to save all actions in a tree, to keep track of
+ // possible redos after a action. Possible, but we are too lazy: forget about redos.
+ redosAvail=0;
+
+ // Write the current state to disk
+ undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
+ undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
+ undoSet.setEntry ("/history/curStep",QString::number(curStep));
+ undoSet.setEntry (QString("/history/step-%1/undoCommand").arg(curStep),undoCommand);
+ undoSet.setEntry (QString("/history/step-%1/undoSelection").arg(curStep),undoSelection);
+ undoSet.setEntry (QString("/history/step-%1/redoCommand").arg(curStep),redoCom);
+ undoSet.setEntry (QString("/history/step-%1/redoSelection").arg(curStep),redoSelection);
+ undoSet.setEntry (QString("/history/step-%1/comment").arg(curStep),comment);
+ undoSet.setEntry (QString("/history/version"),vymVersion);
+ undoSet.writeSettings(histPath);
+
+ if (debug)
+ {
+ // TODO remove after testing
+ //cout << " into="<< histPath.toStdString()<updateHistory (undoSet);
+ setChanged();
+ updateActions();
+}
+
+
+void VymModel::saveStateChangingPart(LinkableMapObj *undoSel, LinkableMapObj* redoSel, const QString &rc, const QString &comment)
+{
+ // save the selected part of the map, Undo will replace part of map
+ QString undoSelection="";
+ if (undoSel)
+ undoSelection=getSelectString(undoSel);
+ else
+ qWarning ("VymModel::saveStateChangingPart no undoSel given!");
+ QString redoSelection="";
+ if (redoSel)
+ redoSelection=getSelectString(undoSel);
+ else
+ qWarning ("VymModel::saveStateChangingPart no redoSel given!");
+
+
+ saveState (PartOfMap,
+ undoSelection, "addMapReplace (\"PATH\")",
+ redoSelection, rc,
+ comment,
+ undoSel);
+}
+
+void VymModel::saveStateRemovingPart(LinkableMapObj *redoSel, const QString &comment)
+{
+ if (!redoSel)
+ {
+ qWarning ("VymModel::saveStateRemovingPart no redoSel given!");
+ return;
+ }
+ QString undoSelection=getSelectString (redoSel->getParObj());
+ QString redoSelection=getSelectString(redoSel);
+ if (typeid(*redoSel) == typeid(BranchObj) )
+ {
+ // save the selected branch of the map, Undo will insert part of map
+ saveState (PartOfMap,
+ undoSelection, QString("addMapInsert (\"PATH\",%1)").arg(((BranchObj*)redoSel)->getNum()),
+ redoSelection, "delete ()",
+ comment,
+ redoSel);
+ }
+}
+
+
+void VymModel::saveState(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment)
+{
+ // "Normal" savestate: save commands, selections and comment
+ // so just save commands for undo and redo
+ // and use current selection
+
+ QString redoSelection="";
+ if (redoSel) redoSelection=getSelectString(redoSel);
+ QString undoSelection="";
+ if (undoSel) undoSelection=getSelectString(undoSel);
+
+ saveState (UndoCommand,
+ undoSelection, uc,
+ redoSelection, rc,
+ comment,
+ NULL);
+}
+
+void VymModel::saveState(const QString &undoSel, const QString &uc, const QString &redoSel, const QString &rc, const QString &comment)
+{
+ // "Normal" savestate: save commands, selections and comment
+ // so just save commands for undo and redo
+ // and use current selection
+ saveState (UndoCommand,
+ undoSel, uc,
+ redoSel, rc,
+ comment,
+ NULL);
+}
+
+void VymModel::saveState(const QString &uc, const QString &rc, const QString &comment)
+{
+ // "Normal" savestate applied to model (no selection needed):
+ // save commands and comment
+ saveState (UndoCommand,
+ NULL, uc,
+ NULL, rc,
+ comment,
+ NULL);
+}
+
+
QGraphicsScene* VymModel::getScene ()
{
return mapScene;
}
-MapCenterObj* VymModel::addMapCenter()
-{
- return addMapCenter (QPointF(0,0));
-}
-
-MapCenterObj* VymModel::addMapCenter(QPointF absPos)
-{
- MapCenterObj *mapCenter = new MapCenterObj(mapScene);
- mapCenter->move (absPos);
- mapCenter->setVisibility (true);
- mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
- mapCenter->setMapEditor(mapEditor); //FIXME needed to get defLinkStyle, mapLinkColorHint ... for later added objects
- mapCenters.append(mapCenter);
- return mapCenter;
-}
-
-MapCenterObj *VymModel::removeMapCenter(MapCenterObj* mco)
-{
- int i=mapCenters.indexOf (mco);
- if (i>=0)
- {
- mapCenters.removeAt (i);
- delete (mco);
- if (i>0) return mapCenters.at(i-1); // Return previous MCO
- }
- return NULL;
-}
-
BranchObj* VymModel::first()
{
if (mapCenters.count()>0)
@@ -196,6 +1421,10 @@
return NULL;
}
+void VymModel::removeSelection()
+{
+}
+
QString VymModel::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
{
QString s;
@@ -205,11 +1434,2264 @@
return s;
}
+//////////////////////////////////////////////
+// Interface
+//////////////////////////////////////////////
+void VymModel::setVersion (const QString &s)
+{
+ version=s;
+}
+
+void VymModel::setAuthor (const QString &s)
+{
+ saveState (
+ QString ("setMapAuthor (\"%1\")").arg(author),
+ QString ("setMapAuthor (\"%1\")").arg(s),
+ QString ("Set author of map to \"%1\"").arg(s)
+ );
+
+ author=s;
+}
+
+QString VymModel::getAuthor()
+{
+ return author;
+}
+
+void VymModel::setComment (const QString &s)
+{
+ saveState (
+ QString ("setMapComment (\"%1\")").arg(comment),
+ QString ("setMapComment (\"%1\")").arg(s),
+ QString ("Set comment of map")
+ );
+
+ comment=s;
+}
+
+QString VymModel::getComment ()
+{
+ return comment;
+}
+
+QString VymModel::getDate ()
+{
+ return QDate::currentDate().toString ("yyyy-MM-dd");
+}
+
+void VymModel::setHeading(const QString &s)
+{
+ BranchObj *sel=selection.getBranch();
+ if (sel)
+ {
+ saveState(
+ sel,
+ "setHeading (\""+sel->getHeading()+"\")",
+ sel,
+ "setHeading (\""+s+"\")",
+ QString("Set heading of %1 to \"%2\"").arg(getObjectName(sel)).arg(s) );
+ sel->setHeading(s );
+ reposition();
+ selection.update();
+ ensureSelectionVisible();
+ }
+}
+
+QString VymModel::getHeading(bool &ok, QPoint &p)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ ok=true;
+ //p=scene->mapFromScene(bo->getAbsPos()); // FIXME this is view-dependant!!!
+ return bo->getHeading();
+ }
+ ok=false;
+ return QString();
+}
+
+
+void VymModel::setHeadingInt(const QString &s)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ bo->setHeading(s);
+ reposition();
+ selection.update();
+ ensureSelectionVisible();
+ }
+}
+
+BranchObj* VymModel::findText (QString s, bool cs)
+{
+ QTextDocument::FindFlags flags=0;
+ if (cs) flags=QTextDocument::FindCaseSensitively;
+
+ if (!itFind)
+ { // Nothing found or new find process
+ if (EOFind)
+ // nothing found, start again
+ EOFind=false;
+ itFind=first();
+ }
+ bool searching=true;
+ bool foundNote=false;
+ while (searching && !EOFind)
+ {
+ if (itFind)
+ {
+ // Searching in Note
+ if (itFind->getNote().contains(s,cs))
+ {
+ if (selection.single()!=itFind)
+ {
+ selection.select(itFind);
+ ensureSelectionVisible();
+ }
+ if (textEditor->findText(s,flags))
+ {
+ searching=false;
+ foundNote=true;
+ }
+ }
+ // Searching in Heading
+ if (searching && itFind->getHeading().contains (s,cs) )
+ {
+ selection.select(itFind);
+ ensureSelectionVisible();
+ searching=false;
+ }
+ }
+ if (!foundNote)
+ {
+ itFind=next(itFind);
+ if (!itFind) EOFind=true;
+ }
+ //cout <<"still searching... "<getHeading())<getURL();
+ bo->setURL (url);
+ saveState (
+ bo,
+ QString ("setURL (\"%1\")").arg(oldurl),
+ bo,
+ QString ("setURL (\"%1\")").arg(url),
+ QString ("set URL of %1 to %2").arg(getObjectName(bo)).arg(url)
+ );
+ updateActions();
+ reposition();
+ selection.update();
+ ensureSelectionVisible();
+ }
+}
+
+QString VymModel::getURL()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ return bo->getURL();
+ else
+ return "";
+}
+
+QStringList VymModel::getURLs()
+{
+ QStringList urls;
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ bo=bo->first();
+ while (bo)
+ {
+ if (!bo->getURL().isEmpty()) urls.append( bo->getURL());
+ bo=bo->next();
+ }
+ }
+ return urls;
+}
+
+void VymModel::linkFloatImageTo(const QString &dstString)
+{
+ FloatImageObj *fio=selection.getFloatImage();
+ if (fio)
+ {
+ BranchObj *dst=(BranchObj*)findObjBySelect(dstString);
+ if (dst && (typeid(*dst)==typeid (BranchObj) ||
+ typeid(*dst)==typeid (MapCenterObj)))
+ {
+ LinkableMapObj *dstPar=dst->getParObj();
+ QString parString=getSelectString(dstPar);
+ QString fioPreSelectString=getSelectString(fio);
+ QString fioPreParentSelectString=getSelectString (fio->getParObj());
+ ((BranchObj*)dst)->addFloatImage (fio);
+ selection.unselect();
+ ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
+ fio=((BranchObj*)dst)->getLastFloatImage();
+ fio->setRelPos();
+ fio->reposition();
+ selection.select(fio);
+ saveState(
+ getSelectString(fio),
+ QString("linkTo (\"%1\")").arg(fioPreParentSelectString),
+ fioPreSelectString,
+ QString ("linkTo (\"%1\")").arg(dstString),
+ QString ("Link floatimage to %1").arg(getObjectName(dst)));
+ }
+ }
+}
+
+
+void VymModel::setFrameType(const FrameObj::FrameType &t)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ QString s=bo->getFrameTypeName();
+ bo->setFrameType (t);
+ saveState (bo, QString("setFrameType (\"%1\")").arg(s),
+ bo, QString ("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),QString ("set type of frame to %1").arg(s));
+ reposition();
+ bo->updateLink();
+ }
+}
+
+void VymModel::setFrameType(const QString &s)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ saveState (bo, QString("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),
+ bo, QString ("setFrameType (\"%1\")").arg(s),QString ("set type of frame to %1").arg(s));
+ bo->setFrameType (s);
+ reposition();
+ bo->updateLink();
+ }
+}
+
+void VymModel::setFramePenColor(const QColor &c)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ saveState (bo, QString("setFramePenColor (\"%1\")").arg(bo->getFramePenColor().name() ),
+ bo, QString ("setFramePenColor (\"%1\")").arg(c.name() ),QString ("set pen color of frame to %1").arg(c.name() ));
+ bo->setFramePenColor (c);
+ }
+}
+
+void VymModel::setFrameBrushColor(const QColor &c)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ),
+ bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() ));
+ bo->setFrameBrushColor (c);
+ }
+}
+
+void VymModel::setFramePadding (const int &i)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ saveState (bo, QString("setFramePadding (\"%1\")").arg(bo->getFramePadding() ),
+ bo, QString ("setFramePadding (\"%1\")").arg(i),QString ("set brush color of frame to %1").arg(i));
+ bo->setFramePadding (i);
+ reposition();
+ bo->updateLink();
+ }
+}
+
+void VymModel::setFrameBorderWidth(const int &i)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ saveState (bo, QString("setFrameBorderWidth (\"%1\")").arg(bo->getFrameBorderWidth() ),
+ bo, QString ("setFrameBorderWidth (\"%1\")").arg(i),QString ("set border width of frame to %1").arg(i));
+ bo->setFrameBorderWidth (i);
+ reposition();
+ bo->updateLink();
+ }
+}
+
+void VymModel::setIncludeImagesVer(bool b)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ QString u= b ? "false" : "true";
+ QString r=!b ? "false" : "true";
+
+ saveState(
+ bo,
+ QString("setIncludeImagesVertically (%1)").arg(u),
+ bo,
+ QString("setIncludeImagesVertically (%1)").arg(r),
+ QString("Include images vertically in %1").arg(getObjectName(bo))
+ );
+ bo->setIncludeImagesVer(b);
+ reposition();
+ }
+}
+
+void VymModel::setIncludeImagesHor(bool b)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ QString u= b ? "false" : "true";
+ QString r=!b ? "false" : "true";
+
+ saveState(
+ bo,
+ QString("setIncludeImagesHorizontally (%1)").arg(u),
+ bo,
+ QString("setIncludeImagesHorizontally (%1)").arg(r),
+ QString("Include images horizontally in %1").arg(getObjectName(bo))
+ );
+ bo->setIncludeImagesHor(b);
+ reposition();
+ }
+}
+
+void VymModel::setHideLinkUnselected (bool b)
+{
+ LinkableMapObj *sel=selection.single();
+ if (sel &&
+ (selection.type() == Selection::Branch ||
+ selection.type() == Selection::MapCenter ||
+ selection.type() == Selection::FloatImage ))
+ {
+ QString u= b ? "false" : "true";
+ QString r=!b ? "false" : "true";
+
+ saveState(
+ sel,
+ QString("setHideLinkUnselected (%1)").arg(u),
+ sel,
+ QString("setHideLinkUnselected (%1)").arg(r),
+ QString("Hide link of %1 if unselected").arg(getObjectName(sel))
+ );
+ sel->setHideLinkUnselected(b);
+ }
+}
+
+void VymModel::setHideExport(bool b)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ bo->setHideInExport (b);
+ QString u= b ? "false" : "true";
+ QString r=!b ? "false" : "true";
+
+ saveState(
+ bo,
+ QString ("setHideExport (%1)").arg(u),
+ bo,
+ QString ("setHideExport (%1)").arg(r),
+ QString ("Set HideExport flag of %1 to %2").arg(getObjectName(bo)).arg (r)
+ );
+ updateActions();
+ reposition();
+ selection.update();
+ // FIXME needed? scene()->update();
+ }
+}
+
+void VymModel::toggleHideExport()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ setHideExport ( !bo->hideInExport() );
+}
+
+
+void VymModel::copy()
+{
+ LinkableMapObj *sel=selection.single();
+ if (sel)
+ {
+ if (redosAvail == 0)
+ {
+ // Copy to history
+ QString s=getSelectString(sel);
+ saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy selection to clipboard",sel );
+ curClipboard=curStep;
+ }
+
+ // Copy also to global clipboard, because we are at last step in history
+ QString bakMapName(QString("history-%1").arg(curStep));
+ QString bakMapDir(tmpMapDir +"/"+bakMapName);
+ copyDir (bakMapDir,clipboardDir );
+
+ clipboardEmpty=false;
+ updateActions();
+ }
+}
+
+
+void VymModel::pasteNoSave(const int &n)
+{
+ bool old=blockSaveState;
+ blockSaveState=true;
+ bool zippedOrg=zipped;
+ if (redosAvail > 0 || n!=0)
+ {
+ // Use the "historical" buffer
+ QString bakMapName(QString("history-%1").arg(n));
+ QString bakMapDir(tmpMapDir +"/"+bakMapName);
+ load (bakMapDir+"/"+clipboardFile,ImportAdd, VymMap);
+ } else
+ // Use the global buffer
+ load (clipboardDir+"/"+clipboardFile,ImportAdd, VymMap);
+ zipped=zippedOrg;
+ blockSaveState=old;
+}
+
+void VymModel::paste()
+{
+ BranchObj *sel=selection.getBranch();
+ if (sel)
+ {
+ saveStateChangingPart(
+ sel,
+ sel,
+ QString ("paste (%1)").arg(curClipboard),
+ QString("Paste to %1").arg( getObjectName(sel))
+ );
+ pasteNoSave(0);
+ reposition();
+ }
+}
+
+void VymModel::cut()
+{
+ LinkableMapObj *sel=selection.single();
+ if ( sel && (selection.type() == Selection::Branch ||
+ selection.type()==Selection::MapCenter ||
+ selection.type()==Selection::FloatImage))
+ {
+ /* No savestate! savestate is called in cutNoSave
+ saveStateChangingPart(
+ sel->getParObj(),
+ sel,
+ "cut ()",
+ QString("Cut %1").arg(getObjectName(sel ))
+ );
+ */
+ copy();
+ deleteSelection();
+ reposition();
+ }
+}
+
+void VymModel::moveBranchUp()
+{
+ BranchObj* bo=selection.getBranch();
+ BranchObj* par;
+ if (bo)
+ {
+ if (!bo->canMoveBranchUp()) return;
+ par=(BranchObj*)(bo->getParObj());
+ BranchObj *obo=par->moveBranchUp (bo); // bo will be the one below selection
+ saveState (getSelectString(bo),"moveBranchDown ()",getSelectString(obo),"moveBranchUp ()",QString("Move up %1").arg(getObjectName(bo)));
+ reposition();
+ //FIXME needed? scene()->update();
+ selection.update();
+ ensureSelectionVisible();
+ }
+}
+
+void VymModel::moveBranchDown()
+{
+ BranchObj* bo=selection.getBranch();
+ BranchObj* par;
+ if (bo)
+ {
+ if (!bo->canMoveBranchDown()) return;
+ par=(BranchObj*)(bo->getParObj());
+ BranchObj *obo=par->moveBranchDown(bo); // bo will be the one above selection
+ saveState(getSelectString(bo),"moveBranchUp ()",getSelectString(obo),"moveBranchDown ()",QString("Move down %1").arg(getObjectName(bo)));
+ reposition();
+ //FIXME needed? scene()->update();
+ selection.update();
+ ensureSelectionVisible();
+ }
+}
+
+void VymModel::sortChildren()
+{
+ BranchObj* bo=selection.getBranch();
+ if (bo)
+ {
+ if(bo->countBranches()>1)
+ {
+ saveStateChangingPart(bo,bo, "sortChildren ()",QString("Sort children of %1").arg(getObjectName(bo)));
+ bo->sortChildren();
+ reposition();
+ ensureSelectionVisible();
+ }
+ }
+}
+
+MapCenterObj* VymModel::addMapCenter ()
+{
+ MapCenterObj *mco=addMapCenter (QPointF(0,0));
+ selection.select (mco);
+ updateActions();
+ ensureSelectionVisible();
+ saveState (
+ mco,
+ "delete()",
+ NULL,
+ // FIXME how to position LineEdit without contextMenuPos ?
+ // QString ("addMapCenter (%1,%2)").arg (contextMenuPos.x()).arg(contextMenuPos.y()),
+ // QString ("Adding MapCenter to (%1,%2").arg (contextMenuPos.x()).arg(contextMenuPos.y())
+ QString ("addMapCenter (%1,%2)").arg (0).arg(0),
+ QString ("Adding MapCenter to (%1,%2").arg (0).arg(0)
+ );
+ return mco;
+}
+
+MapCenterObj* VymModel::addMapCenter(QPointF absPos)
+{
+ MapCenterObj *mapCenter = new MapCenterObj(mapScene);
+ mapCenter->move (absPos);
+ mapCenter->setVisibility (true);
+ mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
+ mapCenter->setMapEditor(mapEditor); //FIXME needed to get defLinkStyle, mapLinkColorHint ... for later added objects
+ mapCenters.append(mapCenter);
+ return mapCenter;
+}
+
+MapCenterObj *VymModel::removeMapCenter(MapCenterObj* mco)
+{
+ int i=mapCenters.indexOf (mco);
+ if (i>=0)
+ {
+ mapCenters.removeAt (i);
+ delete (mco);
+ if (i>0) return mapCenters.at(i-1); // Return previous MCO
+ }
+ return NULL;
+}
+
+
+BranchObj* VymModel::addNewBranchInt(int num)
+{
+ // Depending on pos:
+ // -3 insert in children of parent above selection
+ // -2 add branch to selection
+ // -1 insert in children of parent below selection
+ // 0..n insert in children of parent at pos
+ BranchObj *newbo=NULL;
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ if (num==-2)
+ {
+ // save scroll state. If scrolled, automatically select
+ // new branch in order to tmp unscroll parent...
+ newbo=bo->addBranch();
+
+ }else if (num==-1)
+ {
+ num=bo->getNum()+1;
+ bo=(BranchObj*)bo->getParObj();
+ if (bo) newbo=bo->insertBranch(num);
+ }else if (num==-3)
+ {
+ num=bo->getNum();
+ bo=(BranchObj*)bo->getParObj();
+ if (bo) newbo=bo->insertBranch(num);
+ }
+ if (!newbo) return NULL;
+ }
+ return newbo;
+}
+
+BranchObj* VymModel::addNewBranch(int pos)
+{
+ // Different meaning than num in addNewBranchInt!
+ // -1 add above
+ // 0 add as child
+ // +1 add below
+ BranchObj *bo = selection.getBranch();
+ BranchObj *newbo=NULL;
+
+ if (bo)
+ {
+ // FIXME do we still need this in model? setCursor (Qt::ArrowCursor);
+
+ newbo=addNewBranchInt (pos-2);
+
+ if (newbo)
+ {
+ saveState(
+ newbo,
+ "delete ()",
+ bo,
+ QString ("addBranch (%1)").arg(pos),
+ QString ("Add new branch to %1").arg(getObjectName(bo)));
+
+ reposition();
+ selection.update();
+ latestSelectionString=getSelectString(newbo);
+ // In Network mode, the client needs to know where the new branch is,
+ // so we have to pass on this information via saveState.
+ // TODO: Get rid of this positioning workaround
+ QString ps=qpointfToString (newbo->getAbsPos());
+ sendData ("selectLatestAdded ()");
+ sendData (QString("move %1").arg(ps));
+ sendSelection();
+ }
+ }
+ return newbo;
+}
+
+
+BranchObj* VymModel::addNewBranchBefore()
+{
+ BranchObj *newbo=NULL;
+ BranchObj *bo = selection.getBranch();
+ if (bo && selection.type()==Selection::Branch)
+ // We accept no MapCenterObj here, so we _have_ a parent
+ {
+ QPointF p=bo->getRelPos();
+
+
+ BranchObj *parbo=(BranchObj*)(bo->getParObj());
+
+ // add below selection
+ newbo=parbo->insertBranch(bo->getNum()+1);
+ if (newbo)
+ {
+ newbo->move2RelPos (p);
+
+ // Move selection to new branch
+ bo->linkTo (newbo,-1);
+
+ saveState (newbo, "deleteKeepChildren ()", newbo, "addBranchBefore ()",
+ QString ("Add branch before %1").arg(getObjectName(bo)));
+
+ reposition();
+ selection.update();
+ }
+ }
+ latestSelectionString=selection.getSelectString();
+ return newbo;
+}
+
+void VymModel::deleteSelection()
+{
+ BranchObj *bo = selection.getBranch();
+ if (bo && selection.type()==Selection::MapCenter)
+ {
+ // BranchObj* par=(BranchObj*)(bo->getParObj());
+ selection.unselect();
+ /* FIXME Note: does saveStateRemovingPart work for MCO? (No parent!)
+ saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo)));
+ */
+ bo=removeMapCenter ((MapCenterObj*)bo);
+ if (bo)
+ {
+ selection.select (bo);
+ ensureSelectionVisible();
+ selection.update();
+ }
+ reposition();
+ return;
+ }
+ if (bo && selection.type()==Selection::Branch)
+ {
+ BranchObj* par=(BranchObj*)bo->getParObj();
+ selection.unselect();
+ saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo)));
+ par->removeBranch(bo);
+ selection.select (par);
+ ensureSelectionVisible();
+ reposition();
+ selection.update();
+ return;
+ }
+ FloatImageObj *fio=selection.getFloatImage();
+ if (fio)
+ {
+ BranchObj* par=(BranchObj*)fio->getParObj();
+ saveStateChangingPart(
+ par,
+ fio,
+ "delete ()",
+ QString("Delete %1").arg(getObjectName(fio))
+ );
+ selection.unselect();
+ par->removeFloatImage(fio);
+ selection.select (par);
+ reposition();
+ selection.update();
+ ensureSelectionVisible();
+ return;
+ }
+}
+
+void VymModel::deleteKeepChildren()
+{
+ BranchObj *bo=selection.getBranch();
+ BranchObj *par;
+ if (bo)
+ {
+ par=(BranchObj*)(bo->getParObj());
+ QPointF p=bo->getRelPos();
+ saveStateChangingPart(
+ bo->getParObj(),
+ bo,
+ "deleteKeepChildren ()",
+ QString("Remove %1 and keep its children").arg(getObjectName(bo))
+ );
+
+ QString sel=getSelectString(bo);
+ unselect();
+ par->removeBranchHere(bo);
+ reposition();
+ select (sel);
+ selection.getBranch()->move2RelPos (p);
+ reposition();
+ }
+}
+
+void VymModel::deleteChildren()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ saveStateChangingPart(
+ bo,
+ bo,
+ "deleteChildren ()",
+ QString( "Remove children of branch %1").arg(getObjectName(bo))
+ );
+ bo->removeChildren();
+ reposition();
+ }
+}
+
+
+bool VymModel::scrollBranch(BranchObj *bo)
+{
+ if (bo)
+ {
+ if (bo->isScrolled()) return false;
+ if (bo->countBranches()==0) return false;
+ if (bo->getDepth()==0) return false;
+ QString u,r;
+ r="scroll";
+ u="unscroll";
+ saveState(
+ bo,
+ QString ("%1 ()").arg(u),
+ bo,
+ QString ("%1 ()").arg(r),
+ QString ("%1 %2").arg(r).arg(getObjectName(bo))
+ );
+ bo->toggleScroll();
+ selection.update();
+ // FIXME needed? scene()->update();
+ return true;
+ }
+ return false;
+}
+
+bool VymModel::unscrollBranch(BranchObj *bo)
+{
+ if (bo)
+ {
+ if (!bo->isScrolled()) return false;
+ if (bo->countBranches()==0) return false;
+ if (bo->getDepth()==0) return false;
+ QString u,r;
+ u="scroll";
+ r="unscroll";
+ saveState(
+ bo,
+ QString ("%1 ()").arg(u),
+ bo,
+ QString ("%1 ()").arg(r),
+ QString ("%1 %2").arg(r).arg(getObjectName(bo))
+ );
+ bo->toggleScroll();
+ selection.update();
+ // FIXME needed? scene()->update();
+ return true;
+ }
+ return false;
+}
+
+void VymModel::toggleScroll()
+{
+ BranchObj *bo=selection.getBranch();
+ if (selection.type()==Selection::Branch )
+ {
+ if (bo->isScrolled())
+ unscrollBranch (bo);
+ else
+ scrollBranch (bo);
+ }
+}
+
+void VymModel::unscrollChildren()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ bo->first();
+ while (bo)
+ {
+ if (bo->isScrolled()) unscrollBranch (bo);
+ bo=bo->next();
+ }
+ }
+}
+void VymModel::addFloatImage (const QPixmap &img)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ FloatImageObj *fio=bo->addFloatImage();
+ fio->load(img);
+ fio->setOriginalFilename("No original filename (image added by dropevent)");
+ QString s=getSelectString(bo);
+ saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy dropped image to clipboard",fio );
+ saveState (fio,"delete ()", bo,QString("paste(%1)").arg(curStep),"Pasting dropped image");
+ reposition();
+ // FIXME needed? scene()->update();
+ }
+}
+
+
+void VymModel::colorBranch (QColor c)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ saveState(
+ bo,
+ QString ("colorBranch (\"%1\")").arg(bo->getColor().name()),
+ bo,
+ QString ("colorBranch (\"%1\")").arg(c.name()),
+ QString("Set color of %1 to %2").arg(getObjectName(bo)).arg(c.name())
+ );
+ bo->setColor(c); // color branch
+ }
+}
+
+void VymModel::colorSubtree (QColor c)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ saveStateChangingPart(
+ bo,
+ bo,
+ QString ("colorSubtree (\"%1\")").arg(c.name()),
+ QString ("Set color of %1 and children to %2").arg(getObjectName(bo)).arg(c.name())
+ );
+ bo->setColorSubtree (c); // color links, color children
+ }
+}
+
+QColor VymModel::getCurrentHeadingColor()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo) return bo->getColor();
+
+ QMessageBox::warning(0,"Warning","Can't get color of heading,\nthere's no branch selected");
+ return Qt::black;
+}
+
+
+
+void VymModel::editURL()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ bool ok;
+ QString text = QInputDialog::getText(
+ "VYM", tr("Enter URL:"), QLineEdit::Normal,
+ bo->getURL(), &ok, NULL);
+ if ( ok)
+ // user entered something and pressed OK
+ setURL(text);
+ }
+}
+
+void VymModel::editLocalURL()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ QStringList filters;
+ filters <<"All files (*)";
+ filters << tr("Text","Filedialog") + " (*.txt)";
+ filters << tr("Spreadsheet","Filedialog") + " (*.odp,*.sxc)";
+ filters << tr("Textdocument","Filedialog") +" (*.odw,*.sxw)";
+ filters << tr("Images","Filedialog") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)";
+ QFileDialog *fd=new QFileDialog( NULL,vymName+" - " +tr("Set URL to a local file"));
+ fd->setFilters (filters);
+ fd->setCaption(vymName+" - " +tr("Set URL to a local file"));
+ fd->setDirectory (lastFileDir);
+ if (! bo->getVymLink().isEmpty() )
+ fd->selectFile( bo->getURL() );
+ fd->show();
+
+ if ( fd->exec() == QDialog::Accepted )
+ {
+ lastFileDir=QDir (fd->directory().path());
+ setURL (fd->selectedFile() );
+ }
+ }
+}
+
+
+void VymModel::editHeading2URL()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ setURL (bo->getHeading());
+}
+
+void VymModel::editBugzilla2URL()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
+ setURL (url);
+ }
+}
+
+void VymModel::editFATE2URL()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
+ saveState(
+ bo,
+ "setURL (\""+bo->getURL()+"\")",
+ bo,
+ "setURL (\""+url+"\")",
+ QString("Use heading of %1 as link to FATE").arg(getObjectName(bo))
+ );
+ bo->setURL (url);
+ updateActions();
+ }
+}
+
+void VymModel::editVymLink()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ QStringList filters;
+ filters <<"VYM map (*.vym)";
+ QFileDialog *fd=new QFileDialog( NULL,vymName+" - " +tr("Link to another map"));
+ fd->setFilters (filters);
+ fd->setCaption(vymName+" - " +tr("Link to another map"));
+ fd->setDirectory (lastFileDir);
+ if (! bo->getVymLink().isEmpty() )
+ fd->selectFile( bo->getVymLink() );
+ fd->show();
+
+ QString fn;
+ if ( fd->exec() == QDialog::Accepted )
+ {
+ lastFileDir=QDir (fd->directory().path());
+ saveState(
+ bo,
+ "setVymLink (\""+bo->getVymLink()+"\")",
+ bo,
+ "setVymLink (\""+fd->selectedFile()+"\")",
+ QString("Set vymlink of %1 to %2").arg(getObjectName(bo)).arg(fd->selectedFile())
+ );
+ setVymLink (fd->selectedFile() ); // FIXME ok?
+ }
+ }
+}
+
+void VymModel::setVymLink (const QString &s)
+{
+ // Internal function, no saveState needed
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ bo->setVymLink(s);
+ reposition();
+ updateActions();
+ selection.update();
+ ensureSelectionVisible();
+ }
+}
+
+void VymModel::deleteVymLink()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ saveState(
+ bo,
+ "setVymLink (\""+bo->getVymLink()+"\")",
+ bo,
+ "setVymLink (\"\")",
+ QString("Unset vymlink of %1").arg(getObjectName(bo))
+ );
+ bo->setVymLink ("" );
+ updateActions();
+ reposition();
+ // FIXME needed? scene()->update();
+ }
+}
+
+QString VymModel::getVymLink()
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ return bo->getVymLink();
+ else
+ return "";
+
+}
+
+QStringList VymModel::getVymLinks()
+{
+ QStringList links;
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ bo=bo->first();
+ while (bo)
+ {
+ if (!bo->getVymLink().isEmpty()) links.append( bo->getVymLink());
+ bo=bo->next();
+ }
+ }
+ return links;
+}
+
+
+void VymModel::followXLink(int i)
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ bo=bo->XLinkTargetAt(i);
+ if (bo)
+ {
+ selection.select(bo);
+ ensureSelectionVisible();
+ }
+ }
+}
+
+void VymModel::editXLink(int i) // FIXME missing saveState
+{
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ XLinkObj *xlo=bo->XLinkAt(i);
+ if (xlo)
+ {
+ EditXLinkDialog dia;
+ dia.setXLink (xlo);
+ dia.setSelection(bo);
+ if (dia.exec() == QDialog::Accepted)
+ {
+ if (dia.useSettingsGlobal() )
+ {
+ setMapDefXLinkColor (xlo->getColor() );
+ setMapDefXLinkWidth (xlo->getWidth() );
+ }
+ if (dia.deleteXLink())
+ bo->deleteXLinkAt(i);
+ }
+ }
+ }
+}
+
+
+
+
+
+//////////////////////////////////////////////
+// Scripting
+//////////////////////////////////////////////
+
+void VymModel::parseAtom(const QString &atom)
+{
+ BranchObj *selb=selection.getBranch();
+ QString s,t;
+ double x,y;
+ int n;
+ bool b,ok;
+
+ // Split string s into command and parameters
+ parser.parseAtom (atom);
+ QString com=parser.getCommand();
+
+ // External commands
+ /////////////////////////////////////////////////////////////////////
+ if (com=="addBranch")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else
+ {
+ QList pl;
+ pl << 0 <<1;
+ if (parser.checkParCount(pl))
+ {
+ if (parser.parCount()==0)
+ addNewBranch (0);
+ else
+ {
+ n=parser.parInt (ok,0);
+ if (ok ) addNewBranch (n);
+ }
+ }
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="addBranchBefore")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else
+ {
+ if (parser.parCount()==0)
+ {
+ addNewBranchBefore ();
+ }
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com==QString("addMapCenter"))
+ {
+ if (parser.checkParCount(2))
+ {
+ x=parser.parDouble (ok,0);
+ if (ok)
+ {
+ y=parser.parDouble (ok,1);
+ if (ok) addMapCenter (QPointF(x,y));
+ }
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com==QString("addMapReplace"))
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ //s=parser.parString (ok,0); // selection
+ t=parser.parString (ok,0); // path to map
+ if (QDir::isRelativePath(t)) t=(tmpMapDir + "/"+t);
+ addMapReplaceInt(getSelectString(selb),t);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com==QString("addMapInsert"))
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else
+ {
+ if (parser.checkParCount(2))
+ {
+ t=parser.parString (ok,0); // path to map
+ n=parser.parInt(ok,1); // position
+ if (QDir::isRelativePath(t)) t=(tmpMapDir + "/"+t);
+ addMapInsertInt(t,n);
+ }
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="clearFlags")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ selb->clearStandardFlags();
+ selb->updateFlagsToolbar();
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="colorBranch")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ QColor c=parser.parColor (ok,0);
+ if (ok) colorBranch (c);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="colorSubtree")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ QColor c=parser.parColor (ok,0);
+ if (ok) colorSubtree (c);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="copy")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ //FIXME missing action for copy
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="cut")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if ( selection.type()!=Selection::Branch &&
+ selection.type()!=Selection::MapCenter &&
+ selection.type()!=Selection::FloatImage )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch or floatimage");
+ } else if (parser.checkParCount(0))
+ {
+ cut();
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="delete")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ }
+ /*else if (selection.type() != Selection::Branch && selection.type() != Selection::FloatImage )
+ {
+ parser.setError (Aborted,"Type of selection is wrong.");
+ }
+ */
+ else if (parser.checkParCount(0))
+ {
+ deleteSelection();
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="deleteKeepChildren")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ deleteKeepChildren();
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="deleteChildren")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb)
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ deleteChildren();
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="exportASCII")
+ {
+ QString fname="";
+ ok=true;
+ if (parser.parCount()>=1)
+ // Hey, we even have a filename
+ fname=parser.parString(ok,0);
+ if (!ok)
+ {
+ parser.setError (Aborted,"Could not read filename");
+ } else
+ {
+ exportASCII (fname,false);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="exportImage")
+ {
+ QString fname="";
+ ok=true;
+ if (parser.parCount()>=2)
+ // Hey, we even have a filename
+ fname=parser.parString(ok,0);
+ if (!ok)
+ {
+ parser.setError (Aborted,"Could not read filename");
+ } else
+ {
+ QString format="PNG";
+ if (parser.parCount()>=2)
+ {
+ format=parser.parString(ok,1);
+ }
+ exportImage (fname,false,format);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="exportXHTML")
+ {
+ QString fname="";
+ ok=true;
+ if (parser.parCount()>=2)
+ // Hey, we even have a filename
+ fname=parser.parString(ok,1);
+ if (!ok)
+ {
+ parser.setError (Aborted,"Could not read filename");
+ } else
+ {
+ exportXHTML (fname,false);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="exportXML")
+ {
+ QString fname="";
+ ok=true;
+ if (parser.parCount()>=2)
+ // Hey, we even have a filename
+ fname=parser.parString(ok,1);
+ if (!ok)
+ {
+ parser.setError (Aborted,"Could not read filename");
+ } else
+ {
+ exportXML (fname,false);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="importDir")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ s=parser.parString(ok,0);
+ if (ok) importDirInt(s);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="linkTo")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if ( selb)
+ {
+ if (parser.checkParCount(4))
+ {
+ // 0 selectstring of parent
+ // 1 num in parent (for branches)
+ // 2,3 x,y of mainbranch or mapcenter
+ s=parser.parString(ok,0);
+ LinkableMapObj *dst=findObjBySelect (s);
+ if (dst)
+ {
+ if (typeid(*dst) == typeid(BranchObj) )
+ {
+ // Get number in parent
+ n=parser.parInt (ok,1);
+ if (ok)
+ {
+ selb->linkTo ((BranchObj*)(dst),n);
+ selection.update();
+ }
+ } else if (typeid(*dst) == typeid(MapCenterObj) )
+ {
+ selb->linkTo ((BranchObj*)(dst),-1);
+ // Get coordinates of mainbranch
+ x=parser.parDouble(ok,2);
+ if (ok)
+ {
+ y=parser.parDouble(ok,3);
+ if (ok)
+ {
+ selb->move (x,y);
+ selection.update();
+ }
+ }
+ }
+ }
+ }
+ } else if ( selection.type() == Selection::FloatImage)
+ {
+ if (parser.checkParCount(1))
+ {
+ // 0 selectstring of parent
+ s=parser.parString(ok,0);
+ LinkableMapObj *dst=findObjBySelect (s);
+ if (dst)
+ {
+ if (typeid(*dst) == typeid(BranchObj) ||
+ typeid(*dst) == typeid(MapCenterObj))
+ linkFloatImageTo (getSelectString(dst));
+ } else
+ parser.setError (Aborted,"Destination is not a branch");
+ }
+ } else
+ parser.setError (Aborted,"Type of selection is not a floatimage or branch");
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="loadImage")
+ {
+ if (selection.isEmpty())
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ s=parser.parString(ok,0);
+ if (ok) loadFloatImageInt (s);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="moveBranchUp")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ moveBranchUp();
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="moveBranchDown")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ moveBranchDown();
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="move")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if ( selection.type()!=Selection::Branch &&
+ selection.type()!=Selection::MapCenter &&
+ selection.type()!=Selection::FloatImage )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch or floatimage");
+ } else if (parser.checkParCount(2))
+ {
+ x=parser.parDouble (ok,0);
+ if (ok)
+ {
+ y=parser.parDouble (ok,1);
+ if (ok) move (x,y);
+ }
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="moveRel")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if ( selection.type()!=Selection::Branch &&
+ selection.type()!=Selection::MapCenter &&
+ selection.type()!=Selection::FloatImage )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch or floatimage");
+ } else if (parser.checkParCount(2))
+ {
+ x=parser.parDouble (ok,0);
+ if (ok)
+ {
+ y=parser.parDouble (ok,1);
+ if (ok) moveRel (x,y);
+ }
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="nop")
+ {
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="paste")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ n=parser.parInt (ok,0);
+ if (ok) pasteNoSave(n);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="qa")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(4))
+ {
+ QString c,u;
+ c=parser.parString (ok,0);
+ if (!ok)
+ {
+ parser.setError (Aborted,"No comment given");
+ } else
+ {
+ s=parser.parString (ok,1);
+ if (!ok)
+ {
+ parser.setError (Aborted,"First parameter is not a string");
+ } else
+ {
+ t=parser.parString (ok,2);
+ if (!ok)
+ {
+ parser.setError (Aborted,"Condition is not a string");
+ } else
+ {
+ u=parser.parString (ok,3);
+ if (!ok)
+ {
+ parser.setError (Aborted,"Third parameter is not a string");
+ } else
+ {
+ if (s!="heading")
+ {
+ parser.setError (Aborted,"Unknown type: "+s);
+ } else
+ {
+ if (! (t=="eq") )
+ {
+ parser.setError (Aborted,"Unknown operator: "+t);
+ } else
+ {
+ if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else
+ {
+ if (selb->getHeading() == u)
+ {
+ cout << "PASSED: " << qPrintable (c) << endl;
+ } else
+ {
+ cout << "FAILED: " << qPrintable (c) << endl;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="saveImage")
+ {
+ FloatImageObj *fio=selection.getFloatImage();
+ if (!fio)
+ {
+ parser.setError (Aborted,"Type of selection is not an image");
+ } else if (parser.checkParCount(2))
+ {
+ s=parser.parString(ok,0);
+ if (ok)
+ {
+ t=parser.parString(ok,1);
+ if (ok) saveFloatImageInt (fio,t,s);
+ }
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="scroll")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ if (!scrollBranch (selb))
+ parser.setError (Aborted,"Could not scroll branch");
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="select")
+ {
+ if (parser.checkParCount(1))
+ {
+ s=parser.parString(ok,0);
+ if (ok) select (s);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="selectLastBranch")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ BranchObj *bo=selb->getLastBranch();
+ if (!bo)
+ parser.setError (Aborted,"Could not select last branch");
+ selectInt (bo);
+
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="selectLastImage")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ FloatImageObj *fio=selb->getLastFloatImage();
+ if (!fio)
+ parser.setError (Aborted,"Could not select last image");
+ selectInt (fio);
+
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="selectLatestAdded")
+ {
+ if (latestSelectionString.isEmpty() )
+ {
+ parser.setError (Aborted,"No latest added object");
+ } else
+ {
+ if (!select (latestSelectionString))
+ parser.setError (Aborted,"Could not select latest added object "+latestSelectionString);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setFrameType")
+ {
+ if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
+ {
+ parser.setError (Aborted,"Type of selection does not allow setting frame type");
+ }
+ else if (parser.checkParCount(1))
+ {
+ s=parser.parString(ok,0);
+ if (ok) setFrameType (s);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setFramePenColor")
+ {
+ if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
+ {
+ parser.setError (Aborted,"Type of selection does not allow setting of pen color");
+ }
+ else if (parser.checkParCount(1))
+ {
+ QColor c=parser.parColor(ok,0);
+ if (ok) setFramePenColor (c);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setFrameBrushColor")
+ {
+ if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
+ {
+ parser.setError (Aborted,"Type of selection does not allow setting brush color");
+ }
+ else if (parser.checkParCount(1))
+ {
+ QColor c=parser.parColor(ok,0);
+ if (ok) setFrameBrushColor (c);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setFramePadding")
+ {
+ if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
+ {
+ parser.setError (Aborted,"Type of selection does not allow setting frame padding");
+ }
+ else if (parser.checkParCount(1))
+ {
+ n=parser.parInt(ok,0);
+ if (ok) setFramePadding(n);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setFrameBorderWidth")
+ {
+ if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
+ {
+ parser.setError (Aborted,"Type of selection does not allow setting frame border width");
+ }
+ else if (parser.checkParCount(1))
+ {
+ n=parser.parInt(ok,0);
+ if (ok) setFrameBorderWidth (n);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setMapAuthor")
+ {
+ if (parser.checkParCount(1))
+ {
+ s=parser.parString(ok,0);
+ if (ok) setAuthor (s);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setMapComment")
+ {
+ if (parser.checkParCount(1))
+ {
+ s=parser.parString(ok,0);
+ if (ok) setComment(s);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setMapBackgroundColor")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selection.getBranch() )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ QColor c=parser.parColor (ok,0);
+ if (ok) setMapBackgroundColor (c);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setMapDefLinkColor")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ QColor c=parser.parColor (ok,0);
+ if (ok) setMapDefLinkColor (c);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setMapLinkStyle")
+ {
+ if (parser.checkParCount(1))
+ {
+ s=parser.parString (ok,0);
+ if (ok) setMapLinkStyle(s);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setHeading")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ s=parser.parString (ok,0);
+ if (ok)
+ setHeading (s);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setHideExport")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (selection.type()!=Selection::Branch && selection.type() != Selection::MapCenter &&selection.type()!=Selection::FloatImage)
+ {
+ parser.setError (Aborted,"Type of selection is not a branch or floatimage");
+ } else if (parser.checkParCount(1))
+ {
+ b=parser.parBool(ok,0);
+ if (ok) setHideExport (b);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setIncludeImagesHorizontally")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb)
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ b=parser.parBool(ok,0);
+ if (ok) setIncludeImagesHor(b);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setIncludeImagesVertically")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb)
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ b=parser.parBool(ok,0);
+ if (ok) setIncludeImagesVer(b);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setHideLinkUnselected")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
+ {
+ parser.setError (Aborted,"Type of selection does not allow hiding the link");
+ } else if (parser.checkParCount(1))
+ {
+ b=parser.parBool(ok,0);
+ if (ok) setHideLinkUnselected(b);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setSelectionColor")
+ {
+ if (parser.checkParCount(1))
+ {
+ QColor c=parser.parColor (ok,0);
+ if (ok) setSelectionColorInt (c);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setURL")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ s=parser.parString (ok,0);
+ if (ok) setURL(s);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setVymLink")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ s=parser.parString (ok,0);
+ if (ok) setVymLink(s);
+ }
+ }
+ /////////////////////////////////////////////////////////////////////
+ else if (com=="setFlag")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ s=parser.parString(ok,0);
+ if (ok)
+ {
+ selb->activateStandardFlag(s);
+ selb->updateFlagsToolbar();
+ }
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="setFrameType")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ s=parser.parString(ok,0);
+ if (ok)
+ setFrameType (s);
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="sortChildren")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ sortChildren();
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="toggleFlag")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ s=parser.parString(ok,0);
+ if (ok)
+ {
+ selb->toggleStandardFlag(s);
+ selb->updateFlagsToolbar();
+ }
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="unscroll")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ if (!unscrollBranch (selb))
+ parser.setError (Aborted,"Could not unscroll branch");
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="unscrollChildren")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(0))
+ {
+ unscrollChildren ();
+ }
+ /////////////////////////////////////////////////////////////////////
+ } else if (com=="unsetFlag")
+ {
+ if (selection.isEmpty() )
+ {
+ parser.setError (Aborted,"Nothing selected");
+ } else if (! selb )
+ {
+ parser.setError (Aborted,"Type of selection is not a branch");
+ } else if (parser.checkParCount(1))
+ {
+ s=parser.parString(ok,0);
+ if (ok)
+ {
+ selb->deactivateStandardFlag(s);
+ selb->updateFlagsToolbar();
+ }
+ }
+ } else
+ parser.setError (Aborted,"Unknown command");
+
+ // Any errors?
+ if (parser.errorLevel()==NoError)
+ {
+ // setChanged(); FIXME should not be called e.g. for export?!
+ reposition();
+ }
+ else
+ {
+ // TODO Error handling
+ qWarning("VymModel::parseAtom: Error!");
+ qWarning(parser.errorMessage());
+ }
+}
+
+void VymModel::runScript (QString script)
+{
+ parser.setScript (script);
+ parser.runScript();
+ while (parser.next() )
+ parseAtom(parser.getAtom());
+}
+
+void VymModel::setExportMode (bool b)
+{
+ // should be called before and after exports
+ // depending on the settings
+ if (b && settings.value("/export/useHideExport","true")=="true")
+ setHideTmpMode (HideExport);
+ else
+ setHideTmpMode (HideNone);
+}
+
+void VymModel::exportImage(QString fname, bool askName, QString format)
+{
+ if (fname=="")
+ {
+ fname=getMapName()+".png";
+ format="PNG";
+ }
+
+ if (askName)
+ {
+ QStringList fl;
+ QFileDialog *fd=new QFileDialog (NULL);
+ fd->setCaption (tr("Export map as image"));
+ fd->setDirectory (lastImageDir);
+ fd->setFileMode(QFileDialog::AnyFile);
+ fd->setFilters (imageIO.getFilters() );
+ if (fd->exec())
+ {
+ fl=fd->selectedFiles();
+ fname=fl.first();
+ format=imageIO.getType(fd->selectedFilter());
+ }
+ }
+
+ setExportMode (true);
+ QPixmap pix (getPixmap());
+ pix.save(fname, format);
+ setExportMode (false);
+}
+
+
+void VymModel::exportXML(QString dir, bool askForName)
+{
+ if (askForName)
+ {
+ dir=browseDirectory(NULL,tr("Export XML to directory"));
+ if (dir =="" && !reallyWriteDirectory(dir) )
+ return;
+ }
+
+ // Hide stuff during export, if settings want this
+ setExportMode (true);
+
+ // Create subdirectories
+ makeSubDirs (dir);
+
+ // write to directory
+ QString saveFile=saveToDir (dir,mapName+"-",true,getTotalBBox().topLeft() ,NULL);
+ QFile file;
+
+ file.setName ( dir + "/"+mapName+".xml");
+ if ( !file.open( QIODevice::WriteOnly ) )
+ {
+ // This should neverever happen
+ QMessageBox::critical (0,tr("Critical Export Error"),tr("VymModel::exportXML couldn't open %1").arg(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",false,"PNG");
+
+ setExportMode (false);
+}
+
+void VymModel::exportASCII(QString fname,bool askName)
+{
+ ExportASCII ex;
+ ex.setModel (this);
+ if (fname=="")
+ ex.setFile (mapName+".txt");
+ else
+ ex.setFile (fname);
+
+ if (askName)
+ {
+ //ex.addFilter ("TXT (*.txt)");
+ ex.setDir(lastImageDir);
+ //ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
+ ex.execDialog() ;
+ }
+ if (!ex.canceled())
+ {
+ setExportMode(true);
+ ex.doExport();
+ setExportMode(false);
+ }
+}
+
+void VymModel::exportXHTML (const QString &dir, bool askForName)
+{
+ ExportXHTMLDialog dia(NULL);
+ dia.setFilePath (filePath );
+ dia.setMapName (mapName );
+ dia.readSettings();
+ if (dir!="") dia.setDir (dir);
+
+ bool ok=true;
+
+ if (askForName)
+ {
+ if (dia.exec()!=QDialog::Accepted)
+ ok=false;
+ else
+ {
+ QDir d (dia.getDir());
+ // Check, if warnings should be used before overwriting
+ // the output directory
+ if (d.exists() && d.count()>0)
+ {
+ WarningDialog warn;
+ warn.showCancelButton (true);
+ warn.setText(QString(
+ "The directory %1 is not empty.\n"
+ "Do you risk to overwrite some of its contents?").arg(d.path() ));
+ warn.setCaption("Warning: Directory not empty");
+ warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
+
+ if (warn.exec()!=QDialog::Accepted) ok=false;
+ }
+ }
+ }
+
+ if (ok)
+ {
+ exportXML (dia.getDir(),false );
+ dia.doExport(mapName );
+ //if (dia.hasChanged()) setChanged();
+ }
+}
+
+void VymModel::exportOOPresentation(const QString &fn, const QString &cf)
+{
+ ExportOO ex;
+ ex.setFile (fn);
+ ex.setModel (this);
+ if (ex.setConfigFile(cf))
+ {
+ setExportMode (true);
+ ex.exportPresentation();
+ setExportMode (false);
+ }
+}
+
+
+
//////////////////////////////////////////////
// View related
//////////////////////////////////////////////
+void VymModel::registerEditor(QWidget *)
+{
+}
+
+void VymModel::unregisterEditor(QWidget *)
+{
+}
+
+void VymModel::updateNoteFlag()
+{
+ setChanged();
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ bo->updateNoteFlag();
+ mainWindow->updateActions();
+ }
+}
+
void VymModel::updateRelPositions()
{
for (int i=0; irenderHints());
+
+ // Don't print the visualisation of selection
+ selection.unselect();
+
+ mapScene->render ( &pp,
+ QRectF(0,0,mapRect.width()+2,mapRect.height()+2),
+ QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height() ));
+
+ // Restore selection
+ selection.reselect();
+
+ return pix;
+}
+
+
+void VymModel::setMapLinkStyle (const QString & s)
+{
+ QString snow;
+ if (linkstyle==LinkableMapObj::Line)
+ snow="StyleLine";
+ else if (linkstyle==LinkableMapObj::Parabel)
+ snow="StyleParabel";
+ else if (linkstyle==LinkableMapObj::PolyLine)
+ snow="StylePolyLine";
+ else if (linkstyle==LinkableMapObj::PolyParabel)
+ snow="StyleParabel";
+
+ saveState (
+ QString("setMapLinkStyle (\"%1\")").arg(s),
+ QString("setMapLinkStyle (\"%1\")").arg(snow),
+ QString("Set map link style (\"%1\")").arg(s)
+ );
+
+ if (s=="StyleLine")
+ linkstyle=LinkableMapObj::Line;
+ else if (s=="StyleParabel")
+ linkstyle=LinkableMapObj::Parabel;
+ else if (s=="StylePolyLine")
+ linkstyle=LinkableMapObj::PolyLine;
+ else
+ linkstyle=LinkableMapObj::PolyParabel;
+
+ BranchObj *bo;
+ bo=first();
+ bo=next(bo);
+ while (bo)
+ {
+ bo->setLinkStyle(bo->getDefLinkStyle());
+ bo=next(bo);
+ }
+ reposition();
+}
+
+LinkableMapObj::Style VymModel::getMapLinkStyle ()
+{
+ return linkstyle;
+}
+
+void VymModel::setMapDefLinkColor(QColor col)
+{
+ if ( !col.isValid() ) return;
+ saveState (
+ QString("setMapDefLinkColor (\"%1\")").arg(getMapDefLinkColor().name()),
+ QString("setMapDefLinkColor (\"%1\")").arg(col.name()),
+ QString("Set map link color to %1").arg(col.name())
+ );
+
+ defLinkColor=col;
+ BranchObj *bo;
+ bo=first();
+ while (bo)
+ {
+ bo->setLinkColor();
+ bo=next(bo);
+ }
+ updateActions();
+}
+
+void VymModel::setMapLinkColorHintInt()
+{
+ // called from setMapLinkColorHint(lch) or at end of parse
+ BranchObj *bo;
+ bo=first();
+ while (bo)
+ {
+ bo->setLinkColor();
+ bo=next(bo);
+ }
+}
+
+void VymModel::setMapLinkColorHint(LinkableMapObj::ColorHint lch)
+{
+ linkcolorhint=lch;
+ setMapLinkColorHintInt();
+}
+
+void VymModel::toggleMapLinkColorHint()
+{
+ if (linkcolorhint==LinkableMapObj::HeadingColor)
+ linkcolorhint=LinkableMapObj::DefaultColor;
+ else
+ linkcolorhint=LinkableMapObj::HeadingColor;
+ BranchObj *bo;
+ bo=first();
+ while (bo)
+ {
+ bo->setLinkColor();
+ bo=next(bo);
+ }
+}
+
+void VymModel::selectMapBackgroundImage ()
+{
+ Q3FileDialog *fd=new Q3FileDialog( NULL);
+ fd->setMode (Q3FileDialog::ExistingFile);
+ 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( Q3FileDialog::Contents );
+ fd->setCaption(vymName+" - " +tr("Load background image"));
+ fd->setDir (lastImageDir);
+ fd->show();
+
+ if ( fd->exec() == QDialog::Accepted )
+ {
+ // TODO selectMapBackgroundImg in QT4 use: lastImageDir=fd->directory();
+ lastImageDir=QDir (fd->dirPath());
+ setMapBackgroundImage (fd->selectedFile());
+ }
+}
+
+void VymModel::setMapBackgroundImage (const QString &fn) //FIXME missing savestate
+{
+ QColor oldcol=mapScene->backgroundBrush().color();
+ /*
+ saveState(
+ selection,
+ QString ("setMapBackgroundImage (%1)").arg(oldcol.name()),
+ selection,
+ QString ("setMapBackgroundImage (%1)").arg(col.name()),
+ QString("Set background color of map to %1").arg(col.name()));
+ */
+ QBrush brush;
+ brush.setTextureImage (QPixmap (fn));
+ mapScene->setBackgroundBrush(brush);
+}
+
+void VymModel::selectMapBackgroundColor()
+{
+ QColor col = QColorDialog::getColor( mapScene->backgroundBrush().color(), NULL);
+ if ( !col.isValid() ) return;
+ setMapBackgroundColor( col );
+}
+
+
+void VymModel::setMapBackgroundColor(QColor col)
+{
+ QColor oldcol=mapScene->backgroundBrush().color();
+ saveState(
+ QString ("setMapBackgroundColor (\"%1\")").arg(oldcol.name()),
+ QString ("setMapBackgroundColor (\"%1\")").arg(col.name()),
+ QString("Set background color of map to %1").arg(col.name()));
+ mapScene->setBackgroundBrush(col);
+}
+
+QColor VymModel::getMapBackgroundColor()
+{
+ return mapScene->backgroundBrush().color();
+}
+
+
+LinkableMapObj::ColorHint VymModel::getMapLinkColorHint()
+{
+ return linkcolorhint;
+}
+
+QColor VymModel::getMapDefLinkColor()
+{
+ return defLinkColor;
+}
+
+void VymModel::setMapDefXLinkColor(QColor col)
+{
+ defXLinkColor=col;
+}
+
+QColor VymModel::getMapDefXLinkColor()
+{
+ return defXLinkColor;
+}
+
+void VymModel::setMapDefXLinkWidth (int w)
+{
+ defXLinkWidth=w;
+}
+
+int VymModel::getMapDefXLinkWidth()
+{
+ return defXLinkWidth;
+}
+
+void VymModel::move(const double &x, const double &y)
+{
+ LinkableMapObj *sel=selection.single();
+ if (sel)
+ {
+ QPointF ap(sel->getAbsPos());
+ QPointF to(x, y);
+ if (ap != to)
+ {
+ QString ps=qpointfToString(ap);
+ QString s=selection.getSelectString();
+ saveState(
+ s, "move "+ps,
+ s, "move "+qpointfToString(to),
+ QString("Move %1 to %2").arg(getObjectName(sel)).arg(ps));
+ sel->move(x,y);
+ reposition();
+ selection.update();
+ }
+ }
+}
+
+void VymModel::moveRel (const double &x, const double &y)
+{
+ LinkableMapObj *sel=selection.single();
+ if (sel)
+ {
+ QPointF rp(sel->getRelPos());
+ QPointF to(x, y);
+ if (rp != to)
+ {
+ QString ps=qpointfToString (sel->getRelPos());
+ QString s=getSelectString(sel);
+ saveState(
+ s, "moveRel "+ps,
+ s, "moveRel "+qpointfToString(to),
+ QString("Move %1 to relative position %2").arg(getObjectName(sel)).arg(ps));
+ ((OrnamentedObj*)sel)->move2RelPos (x,y);
+ reposition();
+ sel->updateLink();
+ selection.update();
+ }
+ }
+}
+
+
void VymModel::animate()
{
animationTimer->stop();
@@ -294,7 +4031,11 @@
bo=(BranchObj*)animObjList.at(i);
if (!bo->animate())
{
- if (i>=0) animObjList.removeAt(i);
+ if (i>=0)
+ {
+ animObjList.removeAt(i);
+ i--;
+ }
}
bo->reposition();
i++;
@@ -322,26 +4063,640 @@
}
}
+void VymModel::sendSelection()
+{
+ if (netstate!=Server) return;
+ sendData (QString("select (\"%1\")").arg(selection.getSelectString()) );
+}
+
+void VymModel::newServer()
+{
+ port=54321;
+ sendCounter=0;
+ tcpServer = new QTcpServer(this);
+ if (!tcpServer->listen(QHostAddress::Any,port)) {
+ QMessageBox::critical(NULL, "vym server",
+ QString("Unable to start the server: %1.").arg(tcpServer->errorString()));
+ //FIXME needed? we are no widget any longer... close();
+ return;
+ }
+ connect(tcpServer, SIGNAL(newConnection()), this, SLOT(newClient()));
+ netstate=Server;
+ cout<<"Server is running on port "<serverPort()<abort();
+ clientSocket->connectToHost(server ,port);
+ connect(clientSocket, SIGNAL(readyRead()), this, SLOT(readData()));
+ connect(clientSocket, SIGNAL(error(QAbstractSocket::SocketError)),
+ this, SLOT(displayNetworkError(QAbstractSocket::SocketError)));
+ netstate=Client;
+ cout<<"connected to "<nextPendingConnection();
+ connect(newClient, SIGNAL(disconnected()),
+ newClient, SLOT(deleteLater()));
+
+ cout <<"ME::newClient at "<peerAddress().toString() )<seek(0);
+ quint16 bs=(quint16)(block.size() - 2*sizeof(quint16));
+ out << bs;
+
+ if (debug)
+ cout << "ME::sendData bs="<peerAddress().toString())<write (block);
+ }
+}
+
+void VymModel::readData ()
+{
+ while (clientSocket->bytesAvailable() >=(int)sizeof(quint16) )
+ {
+ if (debug)
+ cout <<"readData bytesAvail="<bytesAvailable();
+ quint16 recCounter;
+ quint16 blockSize;
+
+ QDataStream in(clientSocket);
+ in.setVersion(QDataStream::Qt_4_0);
+
+ in >> blockSize;
+ in >> recCounter;
+
+ QString t;
+ in >>t;
+ if (debug)
+ cout << " t="<errorString()));
+ }
+}
+
+
+
+
+void VymModel::selectMapSelectionColor()
+{
+ QColor col = QColorDialog::getColor( defLinkColor, NULL);
+ setSelectionColor (col);
+}
+
+void VymModel::setSelectionColorInt (QColor col)
+{
+ if ( !col.isValid() ) return;
+ saveState (
+ QString("setSelectionColor (%1)").arg(selection.getColor().name()),
+ QString("setSelectionColor (%1)").arg(col.name()),
+ QString("Set color of selection box to %1").arg(col.name())
+ );
+
+ selection.setColor (col);
+}
+
+void VymModel::updateSelection()
+{
+ selection.update();
+}
+
+void VymModel::setSelectionColor(QColor col)
+{
+ if ( !col.isValid() ) return;
+ saveState (
+ QString("setSelectionColor (%1)").arg(selection.getColor().name()),
+ QString("setSelectionColor (%1)").arg(col.name()),
+ QString("Set color of selection box to %1").arg(col.name())
+ );
+ setSelectionColorInt (col);
+}
+
+QColor VymModel::getSelectionColor()
+{
+ return selection.getColor();
+}
+
+void VymModel::setHideTmpMode (HideTmpMode mode)
+{
+ hidemode=mode;
+ for (int i=0;isetHideTmp (mode);
+ reposition();
+ // FIXME needed? scene()->update();
+}
+
+
+QRectF VymModel::getTotalBBox()
+{
+ QRectF r;
+ for (int i=0;igetTotalBBox(), r);
+ return r;
+}
//////////////////////////////////////////////
// Selection related
//////////////////////////////////////////////
-
-// Only as long as we dont have Model/View yet
+void VymModel::setSelectionBlocked (bool b)
+{
+ if (b)
+ selection.block();
+ else
+ selection.unblock();
+}
+
+bool VymModel::isSelectionBlocked()
+{
+ return selection.isBlocked();
+}
+
+bool VymModel::select (const QString &s)
+{
+ if (selection.select(s))
+ {
+ selection.update();
+ ensureSelectionVisible();
+ sendSelection ();
+ return true;
+ }
+ return false;
+
+}
+
+bool VymModel::select (LinkableMapObj *lmo)
+{
+ if (selection.select(lmo))
+ {
+ selection.update();
+ ensureSelectionVisible();
+ sendSelection ();
+ return true;
+ }
+ return false;
+}
+
+void VymModel::unselect()
+{
+ selection.unselect();
+}
+
+void VymModel::reselect()
+{
+ selection.reselect();
+}
+
+void VymModel::ensureSelectionVisible()
+{
+ LinkableMapObj *lmo=selection.single();
+ if (lmo &&mapEditor) mapEditor->ensureVisible (lmo->getBBox() );
+
+}
+
+void VymModel::selectInt (LinkableMapObj *lmo)
+{
+ if (selection.select(lmo))
+ {
+ selection.update();
+ sendSelection ();
+ }
+}
+
+
+void VymModel::selectNextBranchInt()
+{
+ // Increase number of branch
+ LinkableMapObj *sel=selection.single();
+ if (sel)
+ {
+ 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.single()->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.single()->getOrientation()==LinkableMapObj::RightOfCenter)
+ 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 VymModel::selectPrevBranchInt()
+{
+ // Decrease number of branch
+ BranchObj *bo=selection.getBranch();
+ if (bo)
+ {
+ 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());
+
+ int n=num.toInt()-1;
+
+ // Go to next lmo
+ num=QString ("%1").arg(n);
+ s=s+num;
+
+ // Try to select this one
+ if (n>=0 && 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.single()->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.toInt()-1);
+ s=s.section (",",0,d-2) + ","+ typ+num;
+ } else
+ {
+ // Special case, look at orientation
+ if (selection.single()->getOrientation()==LinkableMapObj::RightOfCenter)
+ num=QString ("%1").arg(num.toInt()-1);
+ else
+ num=QString ("%1").arg(num.toInt()+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( selection.getBranch()->countBranches()-1 );
+ else
+ break;
+ else
+ break;
+ }
+
+ // try to select the freshly built string
+ found=select(s);
+ d--;
+ }
+ return;
+ }
+}
+
+void VymModel::selectUpperBranch()
+{
+ if (selection.isBlocked() ) return;
+
+ BranchObj *bo=selection.getBranch();
+ if (bo && selection.type()==Selection::Branch)
+ {
+ if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
+ selectPrevBranchInt();
+ else
+ if (bo->getDepth()==1)
+ selectNextBranchInt();
+ else
+ selectPrevBranchInt();
+ }
+}
+
+void VymModel::selectLowerBranch()
+{
+ if (selection.isBlocked() ) return;
+
+ BranchObj *bo=selection.getBranch();
+ if (bo && selection.type()==Selection::Branch)
+ {
+ if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
+ selectNextBranchInt();
+ else
+ if (bo->getDepth()==1)
+ selectPrevBranchInt();
+ else
+ selectNextBranchInt();
+ }
+}
+
+
+void VymModel::selectLeftBranch()
+{
+ if (selection.isBlocked() ) return;
+
+ BranchObj* bo;
+ BranchObj* par;
+ LinkableMapObj *sel=selection.single();
+ if (sel)
+ {
+ if (selection.type()== Selection::MapCenter)
+ {
+ par=selection.getBranch();
+ bo=par->getLastSelectedBranch();
+ if (bo)
+ {
+ // Workaround for reselecting on left and right side
+ if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
+ bo=par->getLastBranch();
+ if (bo)
+ {
+ bo=par->getLastBranch();
+ selection.select(bo);
+ selection.update();
+ ensureSelectionVisible();
+ sendSelection();
+ }
+ }
+ } else
+ {
+ par=(BranchObj*)(sel->getParObj());
+ if (sel->getOrientation()==LinkableMapObj::RightOfCenter)
+ {
+ if (selection.type() == Selection::Branch ||
+ selection.type() == Selection::FloatImage)
+ {
+ selection.select(par);
+ selection.update();
+ ensureSelectionVisible();
+ sendSelection();
+ }
+ } else
+ {
+ if (selection.type() == Selection::Branch )
+ {
+ bo=selection.getBranch()->getLastSelectedBranch();
+ if (bo)
+ {
+ selection.select(bo);
+ selection.update();
+ ensureSelectionVisible();
+ sendSelection();
+ }
+ }
+ }
+ }
+ }
+}
+
+void VymModel::selectRightBranch()
+{
+ if (selection.isBlocked() ) return;
+
+ BranchObj* bo;
+ BranchObj* par;
+ LinkableMapObj *sel=selection.single();
+ if (sel)
+ {
+ if (selection.type()==Selection::MapCenter)
+ {
+ par=selection.getBranch();
+ bo=par->getLastSelectedBranch();
+ if (bo)
+ {
+ // Workaround for reselecting on left and right side
+ if (bo->getOrientation()==LinkableMapObj::LeftOfCenter)
+ bo=par->getFirstBranch();
+ if (bo)
+ {
+ selection.select(bo);
+ selection.update();
+ ensureSelectionVisible();
+ sendSelection();
+ }
+ }
+ } else
+ {
+ par=(BranchObj*)(selection.single()->getParObj());
+ if (selection.single()->getOrientation()==LinkableMapObj::LeftOfCenter)
+ {
+ if (selection.type() == Selection::Branch ||
+ selection.type() == Selection::FloatImage)
+ {
+ selection.select(par);
+ selection.update();
+ ensureSelectionVisible();
+ sendSelection();
+ }
+ } else
+ {
+ if (selection.type() == Selection::Branch)
+ {
+ bo=selection.getBranch()->getLastSelectedBranch();
+ if (bo)
+ {
+ selection.select(bo);
+ selection.update();
+ ensureSelectionVisible();
+ sendSelection();
+ }
+ }
+ }
+ }
+ }
+}
+
+void VymModel::selectFirstBranch()
+{
+ BranchObj *bo1=selection.getBranch();
+ BranchObj *bo2;
+ BranchObj* par;
+ if (bo1)
+ {
+ par=(BranchObj*)(bo1->getParObj());
+ if (!par) return;
+ bo2=par->getFirstBranch();
+ if (bo2) {
+ selection.select(bo2);
+ selection.update();
+ ensureSelectionVisible();
+ sendSelection();
+ }
+ }
+}
+
+void VymModel::selectLastBranch()
+{
+ BranchObj *bo1=selection.getBranch();
+ BranchObj *bo2;
+ BranchObj* par;
+ if (bo1)
+ {
+ par=(BranchObj*)(bo1->getParObj());
+ if (!par) return;
+ bo2=par->getLastBranch();
+ if (bo2)
+ {
+ selection.select(bo2);
+ selection.update();
+ ensureSelectionVisible();
+ sendSelection();
+ }
+ }
+}
+
+Selection::Type VymModel::selectionType()
+{
+ return selection.type();
+}
+
LinkableMapObj* VymModel::getSelection()
{
- return mapEditor->getSelection();
+ return selection.single();
}
BranchObj* VymModel::getSelectedBranch()
{
- return mapEditor->getSelectedBranch();
+ return selection.getBranch();
}
-
-bool VymModel::select (const QString &s)
+FloatImageObj* VymModel::getSelectedFloatImage()
{
- return mapEditor->select (s);
+ return selection.getFloatImage();
+}
+
+QString VymModel::getSelectString ()
+{
+ return selection.getSelectString();
}
QString VymModel::getSelectString (LinkableMapObj *lmo)
@@ -368,21 +4723,5 @@
}
}
return s;
-
}
-
-void VymModel::setHideTmp (HideTmpMode mode)
-{
- for (int i=0;isetHideTmp (mode);
-}
-
-QRectF VymModel::getTotalBBox()
-{
- QRectF r;
- for (int i=0;igetTotalBBox(), r);
- return r;
-}
-
diff -r 192e1392ba6a -r 12958f987bcf vymmodel.h
--- a/vymmodel.h Wed Jul 16 10:44:44 2008 +0000
+++ b/vymmodel.h Wed Jul 16 10:46:14 2008 +0000
@@ -2,60 +2,456 @@
#define VYMMODEL_H
#include
+#include
+#include "file.h"
#include "mapcenterobj.h"
#include "mapeditor.h"
+#include "parser.h"
+#include "selection.h"
+#include "xmlobj.h"
/*! \brief This will later be divided into Model/View
*/
-class VymModel : public QObject{
+class VymModel : public QObject, public XMLObj {
Q_OBJECT
+////////////////////////////////////////////
+// General housekeeping
+////////////////////////////////////////////
+private:
+ QGraphicsScene *mapScene;
+ QList mapCenters;
+ QString version; //!< version string saved in vym file
+ QString author;
+ QString comment;
+ QDate date;
+
public:
VymModel();
~VymModel ();
void clear();
void init();
+ void makeTmpDirectories(); //!< create temporary directories e.g. for history
+
void setMapEditor(MapEditor *me); // FIXME should not be necessary in Model/View
- MapEditor* getMapEditor();
+ MapEditor* getMapEditor(); // FIXME not necessary
+
+ bool isRepositionBlocked(); //!< While load or undo there is no need to update graphicsview
+
+ void updateActions(); //!< Update buttons in mainwindow
+
+
+////////////////////////////////////////////
+// Load/save
+////////////////////////////////////////////
+private:
+
+ bool zipped; // should map be zipped
+ static int mapNum; // unique number for model used in save/undo
+ FileType fileType; // type of file, e.g. vym, freemind...
+ 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 tmpMapDir; // tmp directory with undo history
+
+ QTimer *autosaveTimer;
+ QTimer *fileChangedTimer;
+ QDateTime fileChangedTime;
+
+public:
+ /*! This function saves all information of the map to disc.
+ saveToDir also calls the functions for all BranchObj and other objects in the map.
+ The structure of the map itself is returned as QString and passed back to Main,
+ where saveToDir is called initially
+ */
+ QString saveToDir (const QString &tmpdir, const QString &prefix, bool writeflags, const QPointF &offset, LinkableMapObj *saveSel);
+
+ /*! \brief Sets filepath, filename and mapname
+
+ If the filepath is "/home/tux/map.xml", then the filename will be set
+ to map.xml. The destname is needed for vymLinks, pointing to another map.
+ The destname holds the real name of the file, after it has been compressed, e.g. "map.vym"
+ */
+
+
+ /*! \brief Set File path
+
+ The destname is needed to construct the references between maps
+ */
+ void setFilePath (QString filepath,QString destname);
+ void setFilePath (QString); //!< Overloaded for convenience
+ 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"
+
+ /*! \brief Load map
+
+ The data is read from file. Depending on LoadMode the current
+ selection gets replaced by data or the data is appended.
+ */
+ ErrorCode load (QString, const LoadMode &, const FileType& ); // newmap, import/replace selection
+
+public:
+ /*! \brief Save the map to file */
+ ErrorCode save(const SaveMode &);
+
+private:
+ void addMapReplaceInt(const QString & undoSel, const QString & path);
+ void addMapInsertInt (const QString & path, int pos);
+
+ FloatImageObj* loadFloatImageInt (QString);
+ void saveFloatImageInt (FloatImageObj*, const QString &, const QString &);
+public:
+ void loadFloatImage ();
+ void saveFloatImage ();
+
+private:
+ void importDirInt(BranchObj *,QDir);
+ void importDirInt(const QString&);
+public:
+ void importDir();
+
+private slots:
+ void autosave ();
+ void fileChanged();
+
+////////////////////////////////////////////
+// history (undo/redo)
+////////////////////////////////////////////
+private:
+ bool mapDefault; //!< Flag if map is untouched
+ bool mapChanged; //!< Flag if undo is possible
+ bool mapUnsaved; //!< Flag if map should be saved
+
+ QString histPath; //!< Path to history file
+ SimpleSettings undoSet; //!< undo/redo commands, saved in histPath
+ int stepsTotal; //!< total number of steps (undos+redos)
+ int curStep; //!< Current step in history (ring buffer)
+ int curClipboard; //!< number of history step, which is the current clipboard
+ int redosAvail; //!< Available number of redo steps
+ int undosAvail; //!< Available number of undo steps
+ bool blockReposition; //!< block while load or undo
+ bool blockSaveState; //!< block while load or undo
+public:
+ bool isDefault(); //!< true, if map is still the empty default map
+ void makeDefault(); //!< Reset changelog, declare this as default map
+ bool hasChanged() ; //!< true, if something has changed and is not saved yet
+ void setChanged(); //!< called from TextEditor via LinkableMapObj
+
+ /*! \brief Get name of object
+
+ Returns heading of a branch or name of an object for use in comment
+ of undo/redo history
+ */
+ QString getObjectName(const LinkableMapObj*);
+
+ void redo(); //!< Redo last action
+ bool isRedoAvailable(); //!< True, if redo is available
+ void undo(); //!< Undo last action
+ bool isUndoAvailable(); //!< True, if undo is available
+ void gotoHistoryStep (int); //!< Goto a specifig step in history
+
+
+ QString getHistoryPath(); //!< Path to directory containing the history
+
+ /*! \brief Save the current changes in map
+
+ Two commands and selections are saved:
+
+ - undocommand and undoselection to undo the change
+ - redocommand and redoselection to redo the action after an undo
+
+ Additionally a comment is logged.
+
+ */
+ void saveState(
+ const SaveMode& savemode,
+ const QString &undoSelection,
+ const QString &undoCommand,
+ const QString &redoSelection,
+ const QString &redoCommand,
+ const QString &comment,
+ LinkableMapObj *saveSelection);
+ /*! Overloaded for convenience */
+ void saveStateChangingPart(
+ LinkableMapObj *undoSelection,
+ LinkableMapObj* redoSelection,
+ const QString &redoCommand,
+ const QString &comment);
+ /*! Overloaded for convenience */
+ void saveStateRemovingPart(
+ LinkableMapObj *redoSelection,
+ const QString &comment);
+ /*! Overloaded for convenience */
+ void saveState(
+ LinkableMapObj *undoSelection,
+ const QString &undoCommand,
+ LinkableMapObj *redoSelection,
+ const QString &redoCommand,
+ const QString &comment);
+ /*! Overloaded for convenience */
+ void saveState(
+ const QString &undoSelection,
+ const QString &undoCommand,
+ const QString &redoSelection,
+ const QString &redoCommand,
+ const QString &comment) ;
+ void saveState(
+ const QString &undoCommand,
+ const QString &redoCommand,
+ const QString &comment) ;
+
+
+////////////////////////////////////////////
+// unsorted so far
+////////////////////////////////////////////
+public:
+ void setScene(QGraphicsScene *s);
+ QGraphicsScene *getScene();
+
+ BranchObj* first();
+ BranchObj* next(BranchObj *bo);
+
+ LinkableMapObj* findMapObj(QPointF,LinkableMapObj*); // find MapObj
+ LinkableMapObj* findObjBySelect (const QString &s); // find MapObj by select string
+ LinkableMapObj* findID (const QString &s); // find MapObj by previously set ID
+
+ void removeSelection (); // remove selected object
+
+ QString saveToDir (const QString&,const QString&,int, const QPointF&);// Save data recursivly to tempdir
+
+
+////////////////////////////////////////////
+// Interface
+////////////////////////////////////////////
+public:
void setVersion(const QString &);
void setAuthor (const QString &);
QString getAuthor ();
void setComment (const QString &);
QString getComment ();
QString getDate();
- void setScene(QGraphicsScene *s);
- QGraphicsScene *getScene();
+
+public:
+ void setHeading(const QString &); //!< Set heading of branch
+ QString getHeading (bool &ok,QPoint &p); //!< Get heading, ok if selection is branch
+private:
+ void setHeadingInt(const QString &);
+
+private:
+ BranchObj* itFind; // next object in find process
+ bool EOFind; // true, if search failed
+public:
+ BranchObj* findText(QString,bool); // Find object
+ void findReset(); // Reset Search
+
+ void setURL(const QString &url);
+ QString getURL(); // returns URL of selection or ""
+ QStringList getURLs(); // returns URLs of subtree
+
+ void linkFloatImageTo(const QString &);
+
+ void setFrameType(const FrameObj::FrameType &);
+ void setFrameType(const QString &);
+ void setFramePenColor (const QColor &);
+ void setFrameBrushColor (const QColor &);
+ void setFramePadding (const int &);
+ void setFrameBorderWidth (const int &);
+ void setIncludeImagesVer(bool);
+ void setIncludeImagesHor(bool);
+ void setHideLinkUnselected (bool);
+
+ /*! Should object be hidden in exports (clouded)? */
+ void setHideExport(bool);
+
+ /*! Should object be hidden in exports (clouded)? */
+ void toggleHideExport();
+
+ void copy(); //!< Copy to clipboard
+private:
+ void pasteNoSave(const int &n); //!< paste clipboard to branch
+public:
+ void paste(); //!< Paste clipboard to branch and backup
+ void cut(); //!< Cut to clipboard (and copy)
+
+ void moveBranchUp(); //!< Move branch up
+ void moveBranchDown(); //!< Move branch down
+ void sortChildren(); //!< Sort children lexically
+
+ /*! \brief Add new mapcenter
+
+ Disclaimer: Still experimental, not fully supported yet.
+ */
MapCenterObj* addMapCenter();
+private:
MapCenterObj* addMapCenter(QPointF absPos);
+public:
MapCenterObj* removeMapCenter(MapCenterObj *mco);
- BranchObj* first(); // FIXME replaced by ModelIndex later
- BranchObj* next(BranchObj *bo); // FIXME replaced by ModelIndex later
+ /*! \brief Add new branch
- LinkableMapObj* findMapObj(QPointF,LinkableMapObj*); // find MapObj
- LinkableMapObj* findObjBySelect (const QString &s); // find MapObj by select string
- LinkableMapObj* findID (const QString &s); // find MapObj by previously set ID
- QString saveToDir (const QString&,const QString&,int, const QPointF&);// Save data recursivly to tempdir
+ Depending on num the new branch is created
+ -3 above selection as child of selections parent
+ -2 as child of selection
+ -1 below selection as child of selections parent
+ 0..n insert at a specific position in selections parent
+ (needed for free relinking)
+ */
+private:
+ BranchObj* addNewBranchInt(int); // pos allows to add above/below selection
+public:
+ /*! \Add new branch
+
+ Depending on num the new branch is created
+ -1 above selection
+ 0 as child of selection
+ 1 below selection
+ */
+ BranchObj* addNewBranch(int pos);
+ BranchObj* addNewBranchBefore(); //!< Insert branch between selection and its parent
+ void deleteSelection(); //!< Delete selection
+ void deleteKeepChildren(); //!< remove branch, but keep children
+ void deleteChildren(); //!< keep branch, but remove children
-////////////////////////////////////////// View related
- // void updateLink(); FIXME needed?
+private:
+ bool scrollBranch(BranchObj*);
+ bool unscrollBranch(BranchObj*);
+public:
+ void toggleScroll();
+ void unscrollChildren();
+
+ void addFloatImage(const QPixmap &img);
+
+ void colorBranch(QColor);
+ void colorSubtree(QColor);
+ QColor getCurrentHeadingColor();
+
+
+ void editURL(); // edit URL
+ void editLocalURL(); // edit URL to local file
+ void editHeading2URL(); // copy heading to URL
+ void editBugzilla2URL(); // create URL to Bugzilla
+ void editFATE2URL(); // create URL to FATE
+ void editVymLink(); // edit link to another map
+ void setVymLink (const QString &); // Set vymLink for selection
+ void deleteVymLink(); // delete link to another map
+ QString getVymLink(); // return path to map
+ QStringList getVymLinks(); // return paths in subtree
+ void followXLink (int);
+ void editXLink (int);
+
+
+
+
+////////////////////////////////////////////
+// Scripting
+////////////////////////////////////////////
+public:
+
+ /* \brief Process one command and its parameters */
+ void parseAtom (const QString &atom);
+
+ /* \brief Runs the script */
+ void runScript (QString script);
+
+private:
+ Parser parser;
+
+////////////////////////////////////////////
+// Exports
+////////////////////////////////////////////
+private:
+ HideTmpMode hidemode; // true while exporting to hide some stuff
+
+public:
+ /*! Set or unset temporary hiding of objects during export */
+ void setExportMode (bool);
+
+ /*! Save as image */
+ void exportImage (QString fname="",bool askForName=true,QString format="PNG");
+
+
+ /*! Export as XTML to directory */
+ void exportXML(QString dir="", bool askForName=true);
+
+ /*! Export as ASCII text to file */
+ void exportASCII (QString fname="",bool askForName=true);
+
+ /*! Export as XHTML to directory */
+ void exportXHTML(const QString& dir="", bool askForName=true);
+
+ /*! Export as OpenOfficeOrg presentation */
+ void exportOOPresentation(const QString &,const QString &);
+
+
+////////////////////////////////////////////
+// View related
+////////////////////////////////////////////
+public:
+ void registerEditor (QWidget *);
+ void unregisterEditor (QWidget *);
+ void updateNoteFlag(); //!< Signal origination in TextEditor
void updateRelPositions();
QRectF getTotalBBox();
void reposition(); //!< Call reposition for all MCOs
- void setHideTmp (HideTmpMode mode);
+ void setHideTmpMode (HideTmpMode mode);
+
QPolygonF shape(BranchObj *bo); //!< Returns arbitrary shape of subtree
void moveAway (LinkableMapObj *lmo);//!< Autolayout: Move all out of the way
- // Animation **experimental**
-private slots:
- void animate(); //!< Called by timer to animate stuff
+ //void ensureSelectionVisible(); //!< Show selection in all views
+
+private:
+ MapEditor *mapEditor;
+
+ QColor defLinkColor; // default color for links
+ QColor defXLinkColor; // default color for xlinks
+ int defXLinkWidth; // default width for xlinks
+ LinkableMapObj::ColorHint linkcolorhint;// use heading color or own color
+ LinkableMapObj::Style linkstyle; // default style for links
+
+private:
+ QPixmap getPixmap();
+
public:
- void startAnimation(const QPointF &start, const QPointF &dest);
+ void setMapLinkStyle (const QString &); // Set style of link
+ LinkableMapObj::Style getMapLinkStyle (); // requested in LMO
+ void setMapDefLinkColor(QColor); // default color of links
+ void setMapLinkColorHintInt(); // color of links
+ void setMapLinkColorHint(LinkableMapObj::ColorHint);// color of links
+ void toggleMapLinkColorHint(); // after changing linkStyles
+ void selectMapBackgroundImage();
+ void setMapBackgroundImage(const QString &);
+ void selectMapBackgroundColor();
+ void setMapBackgroundColor(QColor);
+ QColor getMapBackgroundColor();
+
+
+ LinkableMapObj::ColorHint getMapLinkColorHint();
+ QColor getMapDefLinkColor();
+ void setMapDefXLinkColor(QColor);
+ QColor getMapDefXLinkColor();
+ void setMapDefXLinkWidth (int);
+ int getMapDefXLinkWidth();
+
+ /*! Move absolutly to (x,y). */
+ void move (const double &x, const double &y);
+
+ /*! Move relativly to (x,y). */
+ void moveRel (const double &x, const double &y);
+
+////////////////////////////////////////////
+// Animation **experimental**
+////////////////////////////////////////////
private:
QTimer *animationTimer;
bool animationUse;
@@ -64,22 +460,102 @@
int timerId; // animation timer
QList animObjList;// list with animated objects
-////////////////////////////////////////// Selection related
+private slots:
+ void animate(); //!< Called by timer to animate stuff
public:
+ void startAnimation(const QPointF &start, const QPointF &dest);
+////////////////////////////////////////////
+// Network related
+////////////////////////////////////////////
+public:
+ /*! \brief Networking states
+
+ In Network modus we want to switch of saveState, autosave, ...
+ */
+ enum NetState {
+ Offline, //!< Offline
+ Client, //!< I am the client and connected to server
+ Server //!< I am the server
+ };
+
+private:
+ // Network connections **Experimental**
+ NetState netstate; // offline, client, server
+ QTcpServer *tcpServer; // Act as server in conference mode (experimental)
+ QList clientList; // List of connected clients
+ quint16 sendCounter; // Increased with every sent command
+
+ QTcpSocket *clientSocket; // socket of this client
+ QString server; // server address of this client
+ int port; // server port of this client
+
+
+
+protected:
+ void sendSelection();
+
+public:
+ void newServer();
+ void connectToServer();
+
+private slots:
+ void newClient();
+ void sendData(const QString &s);
+ void readData();
+ void displayNetworkError (QAbstractSocket::SocketError);
+
+private:
+ void displayClientError(QAbstractSocket::SocketError socketError);
+
+
+////////////////////////////////////////////
+// Selection related
+////////////////////////////////////////////
+private:
+ Selection selection;
+ QString latestSelectionString; // select string of latest added object
+
+public:
+ void setSelectionBlocked(bool);
+ bool isSelectionBlocked();
+
+ bool select(const QString &); // Select by string
+ bool select(LinkableMapObj *lmo); // Select by pointer
+ void unselect();
+ void reselect();
+
+ void ensureSelectionVisible(); //!< Show selection in all views
+
+ void selectInt(LinkableMapObj*);
+
+private:
+ void selectNextBranchInt(); // Increment number of branch
+ void selectPrevBranchInt(); // Decrement number of branch
+public:
+ void selectUpperBranch();
+ void selectLowerBranch();
+ void selectLeftBranch();
+ void selectRightBranch();
+ void selectFirstBranch();
+ void selectLastBranch();
+
+public:
+ Selection::Type selectionType();
LinkableMapObj* getSelection();
BranchObj* getSelectedBranch();
- bool select (const QString &s);
+ FloatImageObj* getSelectedFloatImage();
+ QString getSelectString ();
QString getSelectString (LinkableMapObj *lmo);
+
+ void updateSelection();
+ void selectMapLinkColor();
+ void selectMapSelectionColor();
+private:
+ void setSelectionColorInt(QColor);
+public:
+ void setSelectionColor(QColor);
+ QColor getSelectionColor();
-private:
- QGraphicsScene *mapScene;
- MapEditor *mapEditor;
- QList mapCenters;
- QString version; //!< version string saved in vym file
- QString author;
- QString comment;
- QDate date;
};
-
#endif
diff -r 192e1392ba6a -r 12958f987bcf xml-vym.cpp
--- a/xml-vym.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/xml-vym.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -105,29 +105,29 @@
if (!atts.value( "selectionColor").isEmpty() )
{
col.setNamedColor(atts.value("selectionColor"));
- model->getMapEditor()->setSelectionColor(col);
+ model->setSelectionColor(col);
}
if (!atts.value( "linkColorHint").isEmpty() )
{
if (atts.value("linkColorHint")=="HeadingColor")
- model->getMapEditor()->setMapLinkColorHint(LinkableMapObj::HeadingColor);
+ model->setMapLinkColorHint(LinkableMapObj::HeadingColor);
else
- model->getMapEditor()->setMapLinkColorHint(LinkableMapObj::DefaultColor);
+ model->setMapLinkColorHint(LinkableMapObj::DefaultColor);
}
if (!atts.value( "linkStyle").isEmpty() )
- model->getMapEditor()->setMapLinkStyle(atts.value("linkStyle"));
+ model->setMapLinkStyle(atts.value("linkStyle"));
if (!atts.value( "linkColor").isEmpty() )
{
col.setNamedColor(atts.value("linkColor"));
- model->getMapEditor()->setMapDefLinkColor(col);
+ model->setMapDefLinkColor(col);
}
if (!atts.value( "defXLinkColor").isEmpty() )
{
col.setNamedColor(atts.value("defXLinkColor"));
- model->getMapEditor()->setMapDefXLinkColor(col);
+ model->setMapDefXLinkColor(col);
}
if (!atts.value( "defXLinkWidth").isEmpty() )
- model->getMapEditor()->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ());
+ model->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ());
}
} else if ( eName == "select" && state == StateMap )
{
@@ -150,8 +150,8 @@
// Treat the found mapcenter as a branch
// in an existing map
LinkableMapObj* lmo=model->getSelection();
- if (lmo && ((typeid(*lmo) == typeid(BranchObj) )
- || typeid(*lmo) == typeid(MapCenterObj) ) )
+ if (lmo && (typeid(*lmo) == typeid(BranchObj) )
+ || (typeid(*lmo) == typeid(MapCenterObj) ) )
{
lastBranch=(BranchObj*)lmo;
if (loadMode==ImportAdd)
@@ -205,10 +205,10 @@
// selection==lmo==NULL
// Treat it like ImportAdd then...
loadMode=ImportAdd;
- lmo=model->first(); // FIXME this used to be lmo=mc before
+ lmo=model->first();
}
- if (lmo && ((typeid(*lmo) == typeid(BranchObj) )
- || typeid(*lmo) == typeid(MapCenterObj) ) )
+ if (lmo && (typeid(*lmo) == typeid(BranchObj) )
+ || (typeid(*lmo) == typeid(MapCenterObj) ) )
{
lastBranch=(BranchObj*)(lmo);
if (eName=="branch")
@@ -626,7 +626,7 @@
if (!a.value( "key").isEmpty() )
{
if (!a.value( "value").isEmpty() )
- settings.setLocalEntry (model->getMapEditor()->getDestPath(), a.value ("key"), a.value ("value"));
+ settings.setLocalEntry (model->getDestPath(), a.value ("key"), a.value ("value"));
else
return false;
diff -r 192e1392ba6a -r 12958f987bcf xmlobj.cpp
--- a/xmlobj.cpp Wed Jul 16 10:44:44 2008 +0000
+++ b/xmlobj.cpp Wed Jul 16 10:46:14 2008 +0000
@@ -1,6 +1,7 @@
#include "xmlobj.h"
#include
+#include
// returns masked "<" ">" "&"
diff -r 192e1392ba6a -r 12958f987bcf xmlobj.h
--- a/xmlobj.h Wed Jul 16 10:44:44 2008 +0000
+++ b/xmlobj.h Wed Jul 16 10:46:14 2008 +0000
@@ -1,7 +1,7 @@
#ifndef XMLOBJ_H
#define XMLOBJ_H
-#include
+class QString;
QString quotemeta(const QString&);
]