# HG changeset patch
# User insilmaril
# Date 1122046686 0
# Node ID 16b250a57c1730019468be3ea50f5b925a04c69c
# Parent 30cd58b70d0235c2b615b03cc6400537064e77a6
reactivated experimental ASCII export, more changes in undo system
diff -r 30cd58b70d02 -r 16b250a57c17 demos/todo.vym
Binary file demos/todo.vym has changed
diff -r 30cd58b70d02 -r 16b250a57c17 exports.cpp
--- a/exports.cpp Tue Jul 19 15:57:49 2005 +0000
+++ b/exports.cpp Fri Jul 22 15:38:06 2005 +0000
@@ -1,6 +1,9 @@
#include "exports.h"
+#include
+
#include "linkablemapobj.h"
+#include "texteditor.h"
Export::Export()
@@ -8,24 +11,6 @@
indentPerDepth=" ";
}
-bool Export::setOutputDir(QString dirname)
-{
- outdir.setPath (dirname);
- if ( outdir.exists() )
- {
- // FIXME
- // ask for confirmation
- // then delete outdir
- return true;
- } else
- {
- // try to create directory
- //return outdir.mkdir (outdir.absPath());
- // FIXME
- return true;
- }
-}
-
void Export::setPath (const QString &p)
{
filepath=p;
@@ -41,7 +26,7 @@
QFile file (filepath);
if ( !file.open( IO_WriteOnly ) )
{
- // FIXME
+ // FIXME experimental, testing
cout << "Export::exportMap couldn't open "<first();
while (bo)
@@ -60,18 +45,24 @@
// Write heading
// write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
- if (bo->getDepth()==1)
- ts << (getSectionString(bo) + bo->getHeading()+ "\n");
+ if (bo->getDepth()==0)
+ {
+ ts << (bo->getHeading()+ "\n");
+ for (i=0;igetHeading().length();i++) ts<<"=";
+ ts << "\n";
+ } else if (bo->getDepth()==1)
+ ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
+ else if (bo->getDepth()==2)
+ ts << (actIndent + " o " + bo->getHeading()+ "\n");
else
ts << (actIndent + " - " + bo->getHeading()+ "\n");
// If necessary, write note
if (!bo->getNote().isEmpty())
{
- ts << ("-------------------Begin of Note-----------------\n");
- ts << (bo->getNote());
- ts << ("\n");
- ts << ("-------------------End of Note-------------------\n");
+ s =textConvertToASCII(bo->getNote());
+ s=s.replace ("\n","\n"+actIndent);
+ ts << (s+"\n\n");
}
bo=bo->next();
@@ -97,36 +88,3 @@
return r + " ";
}
-void Export::exportAsHTML()
-{
- // FIXME just testing...
- // Main loop over all branches
- QString s;
- QString actIndent("");
- int i;
- BranchObj *bo;
- bo=mapCenter->first();
- while (bo)
- {
- // Make indentstring
- for (i=0;igetDepth();i++) actIndent+= indentPerDepth;
-
- // Write heading
- write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
-
- // If necessary, write note
- if (!bo->getNote().isEmpty())
- {
- write (bo->getNote());
- }
-
- bo=bo->next();
- actIndent="";
- }
-}
-
-void Export::write(QString s)
-{
- cout << s;
-}
-
diff -r 30cd58b70d02 -r 16b250a57c17 exports.h
--- a/exports.h Tue Jul 19 15:57:49 2005 +0000
+++ b/exports.h Fri Jul 22 15:38:06 2005 +0000
@@ -14,15 +14,12 @@
{
public:
Export();
- bool setOutputDir (QString);
void setPath(const QString &);
void setMapCenter (MapCenterObj*);
void setIndentPerDepth (QString);
void exportMap();
- void exportAsHTML();
protected:
QString getSectionString (BranchObj*);
- void write (QString);
private:
QDir outdir;
diff -r 30cd58b70d02 -r 16b250a57c17 mainwindow.cpp
--- a/mainwindow.cpp Tue Jul 19 15:57:49 2005 +0000
+++ b/mainwindow.cpp Fri Jul 22 15:38:06 2005 +0000
@@ -967,8 +967,9 @@
a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" ), 0, this, "exportASCII" );
connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
- // TODO deactivated, doesn't work with QRichtext anyway
- // a->addTo( exportMenu );
+ // FIXME Usually deactivated, still experimental
+ if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) ;
+ a->addTo( exportMenu );
a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ), 0, this, "exportXML" );
connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
diff -r 30cd58b70d02 -r 16b250a57c17 mapeditor.cpp
--- a/mapeditor.cpp Tue Jul 19 15:57:49 2005 +0000
+++ b/mapeditor.cpp Fri Jul 22 15:38:06 2005 +0000
@@ -592,6 +592,7 @@
void MapEditor::saveState(const SaveMode &savemode, LinkableMapObj *undoSel, const QString &undoCom)
{
+ setChanged();
if (savemode==UndoCommand)
{
undoCommand=undoCom;
@@ -832,7 +833,6 @@
// (map state is set later at end of load...)
} else
{
- setChanged();
saveState(selection);
}
@@ -1029,7 +1029,7 @@
l->setPen (QPen(QColor(black), 1));
l->setZ (200);
l->show();
- */
+ */
if (printFooter)
{
@@ -1137,6 +1137,9 @@
void MapEditor::exportASCII()
{
// FIXME still experimental
+ Export ex;
+ ex.setMapCenter(mapCenter);
+
QFileDialog *fd=new QFileDialog( this, tr("VYM - Export (ASCII)"));
fd->addFilter ("TXT (*.txt)");
fd->setCaption("VYM - Export (ASCII) (still experimental)");
@@ -1162,21 +1165,14 @@
{
case QMessageBox::Yes:
// save
- if (!ex.setOutputDir ("out"))
- {
- QMessageBox::critical (0,tr("Critical Export Error "),tr("Couldn't create directory ") + "out");
- return;
- }
break;;
case QMessageBox::Cancel:
- // do nothing
+ // return, do nothing
return;
break;
}
}
- Export ex;
ex.setPath (fd->selectedFile() );
- ex.setMapCenter(mapCenter);
ex.exportMap();
}
}
@@ -1288,15 +1284,6 @@
// Finish open lineEdits
if (lineedit) finishedLineEditNoSave();
- // Unselect
- /*FIXME testing
- if (selection)
- {
- selection->unselect();
- selection=NULL;
- }
- */
-
parseAtom (undoCommand);
mapCenter->reposition();
@@ -1414,7 +1401,6 @@
void MapEditor::paste()
{
- setChanged();
saveState(selection);
pasteNoSave();
mapCenter->reposition();
@@ -1423,7 +1409,6 @@
void MapEditor::cut()
{
- setChanged();
saveState(selection->getParObj());
copy();
cutNoSave();
@@ -1448,7 +1433,6 @@
BranchObj* par;
if (typeid(*selection) == typeid(BranchObj) )
{
- setChanged();
saveState("moveBranchDown ()");
bo=(BranchObj*)(selection);
par=(BranchObj*)(bo->getParObj());
@@ -1469,7 +1453,6 @@
BranchObj* par;
if (typeid(*selection) == typeid(BranchObj) )
{
- setChanged();
saveState("moveBranchUp ()");
bo=(BranchObj*)(selection);
par=(BranchObj*)(bo->getParObj());
@@ -1490,7 +1473,6 @@
(typeid(*selection) == typeid(BranchObj) ||
typeid(*selection) == typeid(MapCenterObj) ) )
{
- setChanged();
saveState("setHeading (\""+((BranchObj*)(selection))->getHeading()+"\")");
ensureSelectionVisible();
@@ -1532,7 +1514,6 @@
(typeid(*selection) == typeid(BranchObj) ||
typeid(*selection) == typeid(MapCenterObj) ) )
{
- setChanged();
saveState(selection);
BranchObj* bo1 = (BranchObj*) (selection);
@@ -1598,7 +1579,6 @@
if (selection &&
(typeid(*selection) == typeid(BranchObj) ) )
{
- setChanged();
saveState(selection);
BranchObj* bo1 = (BranchObj*) (selection);
@@ -1647,7 +1627,6 @@
if (selection && typeid(*selection) ==typeid(BranchObj) )
{
- setChanged();
saveState(selection->getParObj());
BranchObj* bo=dynamic_cast (selection);
BranchObj* par=(BranchObj*)(bo->getParObj());
@@ -1662,7 +1641,6 @@
}
if (selection && typeid(*selection) ==typeid(FloatImageObj) )
{
- setChanged();
saveState(selection->getParObj());
FloatImageObj* fio=dynamic_cast (selection);
BranchObj* par=(BranchObj*)(fio->getParObj());
@@ -2104,7 +2082,7 @@
QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this );
if ( !col.isValid() ) return;
setBackgroundColor( col );
- setChanged();
+ saveState();
}
void MapEditor::setBackgroundColor(QColor c)
@@ -2133,7 +2111,6 @@
if (typeid(*selection) == typeid(BranchObj) ||
typeid(*selection) == typeid(MapCenterObj))
{
- setChanged();
saveState(selection);
BranchObj *bo=(BranchObj*)(selection);
bo->setColor(actColor, false); // color links, color childs
@@ -2148,7 +2125,6 @@
if (typeid(*selection) == typeid(BranchObj) ||
typeid(*selection) == typeid(MapCenterObj))
{
- setChanged();
saveState(selection);
BranchObj *bo=(BranchObj*)(selection);
bo->setColor(actColor, true); // color links, color childs
@@ -2161,7 +2137,6 @@
{
if (selection)
{
- setChanged();
saveState(selection);
((BranchObj*)(selection))->toggleStandardFlag (f,actionSettingsUseFlagGroups);
}
@@ -2280,7 +2255,7 @@
// user entered something and pressed OK
((BranchObj*)(selection))->setURL (text);
updateActions();
- setChanged();
+ saveState(); //FIXME undoCommand
}
}
}
@@ -2293,7 +2268,7 @@
BranchObj *b=(BranchObj*)(selection);
b->setURL (b->getHeading());
updateActions();
- setChanged();
+ saveState(); //FIXME undoCommand
}
}
@@ -2305,7 +2280,7 @@
BranchObj *b=(BranchObj*)(selection);
b->setURL ("https://bugzilla.novell.com/show_bug.cgi?id="+b->getHeading());
updateActions();
- setChanged();
+ saveState(); //FIXME undoCommand
}
}
@@ -2328,7 +2303,7 @@
mapCenter->reposition();
adjustCanvasSize();
canvas()->update();
- setChanged();
+ saveState(); //FIXME undoCommand
}
}
@@ -2342,7 +2317,7 @@
mapCenter->reposition();
adjustCanvasSize();
canvas()->update();
- setChanged();
+ saveState(); //FIXME undoCommand
}
}
@@ -2361,7 +2336,6 @@
{
if (selection && (typeid(*selection) == typeid(BranchObj) ))
{
- setChanged();
saveState(selection->getParObj());
QString sel=selection->getSelectString();
BranchObj* bo=(BranchObj*)(selection);
@@ -2377,7 +2351,6 @@
{
if (selection && (typeid(*selection) == typeid(BranchObj) ))
{
- setChanged();
saveState(selection->getParObj());
((BranchObj*)(selection))->removeChilds();
mapCenter->reposition();
@@ -2424,7 +2397,7 @@
{
mapCenter->setAuthor (dia.getAuthor() );
mapCenter->setComment (dia.getComment() );
- setChanged();
+ saveState(); //FIXME undoCommand
}
}
@@ -2577,7 +2550,6 @@
{
linkstyle=ls;
- setChanged();
saveState();
BranchObj *bo;
bo=mapCenter->first();
@@ -2672,7 +2644,8 @@
QColor col = QColorDialog::getColor( defLinkColor, this );
if ( !col.isValid() ) return;
setLinkColor( col );
- setChanged();
+ saveState(); //FIXME undoCommand
+
}
void MapEditor::toggleScroll()
@@ -2682,7 +2655,6 @@
BranchObj *bo=((BranchObj*)(selection));
if (bo->countBranches()==0) return;
if (bo->getDepth()==0) return;
- setChanged();
saveState(selection);
bo->toggleScroll();
adjustCanvasSize();
@@ -2722,7 +2694,6 @@
QString fn;
if ( fd->exec() == QDialog::Accepted )
{
- setChanged();
saveState(selection);
QString fn=fd->selectedFile();
lastImageDir=fn.left(fn.findRev ("/"));
@@ -2929,7 +2900,7 @@
}
if (dia.deleteXLink())
((BranchObj*)(selection))->deleteXLinkAt(i);
- setChanged();
+ saveState(); //FIXME undoCommand
}
}
}
@@ -3163,7 +3134,6 @@
if (typeid(*selection) == typeid(FloatImageObj))
{
- setChanged();
saveState("move "+qpointToString(movingObj_orgPos));
FloatObj *fo=(FloatObj*)(selection);
if (fo->getLinkStyle()==StyleUndef)
@@ -3185,6 +3155,7 @@
{
if (typeid(*fo) == typeid(FloatImageObj))
{
+ saveState();
FloatImageObj *fio=(FloatImageObj*)(fo);
((BranchObj*)(lmo))->addFloatImage (fio);
fio->unselect();
@@ -3215,7 +3186,6 @@
if (lmosel->getDepth()==1)
{
// depth==1, mainbranch
- setChanged();
saveState("move "+qpointToString(movingObj_orgPos));
lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
} else
@@ -3324,8 +3294,7 @@
tmpXLink->setEnd ( ((BranchObj*)(dst)) );
tmpXLink->updateXLink();
tmpXLink->activate();
- setChanged();
-
+ saveState(); //FIXME undoCommand
} else
{
delete(tmpXLink);
@@ -3362,7 +3331,6 @@
if (dst )
{
BranchObj* bs=((BranchObj*)(selection));
- setChanged();
saveState ("linkBranchToPos (\""+
(bs->getParObj())->getSelectString()+
"\","+
@@ -3415,7 +3383,6 @@
if (selection) selection->unselect();
selection=lmo;
selection->select();
- setChanged();
saveState(selection);
editHeading();
}
@@ -3588,7 +3555,7 @@
if (update)
{
- setChanged();
+ saveState(); //FIXME undo Command
mapCenter->reposition();
adjustCanvasSize();
canvas()->update();
@@ -3603,7 +3570,6 @@
(typeid(*selection) == typeid(MapCenterObj)) )
{
BranchObj *bo=((BranchObj*)(selection));
- setChanged();
saveState(selection);
//QString fn=fd->selectedFile();
//lastImageDir=fn.left(fn.findRev ("/"));
diff -r 30cd58b70d02 -r 16b250a57c17 texteditor.cpp
--- a/texteditor.cpp Tue Jul 19 15:57:49 2005 +0000
+++ b/texteditor.cpp Fri Jul 22 15:38:06 2005 +0000
@@ -678,7 +678,7 @@
e->setText(t);
}
-QString TextEditor::textConvertToASCII(const QString &t)
+QString textConvertToASCII(const QString &t)
{
QString r=t;
@@ -687,8 +687,8 @@
re.setMinimal(true);
r.replace (re,"\n");
- // convert all "
" to "\n"
- re.setPattern ("/p");
+ // convert all "" to "\n"
+ re.setPattern ("
");
r.replace (re,"\n");
// remove all remaining tags
@@ -702,6 +702,8 @@
r.replace (re,"<");
re.setPattern ("&");
r.replace (re,"&");
+ re.setPattern (""");
+ r.replace (re,"\"");
return r;
}
diff -r 30cd58b70d02 -r 16b250a57c17 texteditor.h
--- a/texteditor.h Tue Jul 19 15:57:49 2005 +0000
+++ b/texteditor.h Fri Jul 22 15:38:06 2005 +0000
@@ -10,6 +10,8 @@
enum EditorState {inactiveEditor,emptyEditor,filledEditor};
+QString textConvertToASCII(const QString &);
+
class TextEditor : public QMainWindow {
Q_OBJECT
public:
@@ -56,7 +58,6 @@
void textSave();
void textConvertPar();
void textJoinLines();
- QString textConvertToASCII(const QString &);
void textExportAsASCII();
void textPrint();
void textEditUndo();
diff -r 30cd58b70d02 -r 16b250a57c17 version.h
--- a/version.h Tue Jul 19 15:57:49 2005 +0000
+++ b/version.h Fri Jul 22 15:38:06 2005 +0000
@@ -2,6 +2,6 @@
#define VERSION_H
#define __VYM_VERSION__ "1.7.1"
-#define __BUILD_DATE__ "July 19, 2005"
+#define __BUILD_DATE__ "July 22, 2005"
#endif