# HG changeset patch # User insilmaril # Date 1157449634 0 # Node ID e95081c21da24d54147acbabf60132174190b55d # Parent 1cc73bd7ee1fc2d55dfccde6e488220acafc78ac Moved the qt4-port branch to HEAD diff -r 1cc73bd7ee1f -r e95081c21da2 exportoofiledialog.h --- a/exportoofiledialog.h Tue Sep 05 09:47:13 2006 +0000 +++ b/exportoofiledialog.h Tue Sep 05 09:47:14 2006 +0000 @@ -1,8 +1,8 @@ #ifndef EXPORTOOFILEDIALOG #define EXPORTOOFILEDIALOG -#include -#include +#include +#include #include "settings.h" @@ -12,18 +12,18 @@ public: ExportOOFileDialog(); - ExportOOFileDialog (QWidget * parent = 0, const char * name = 0, bool - modal = false); + ExportOOFileDialog (QWidget * parent = 0, const QString &caption=QString()); bool foundConfig(); QString selectedConfig(); QString selectedFile(); - void addFilter(const QString &); + void show(); private slots: void newConfigPath (const QString&f); private: void init(); + void addFilter(const QString &); void scanExportConfigs(QDir ); QStringList configPaths; QStringList filters; diff -r 1cc73bd7ee1f -r e95081c21da2 exports.cpp --- a/exports.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/exports.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -1,6 +1,8 @@ -#include +#include #include -#include +#include +//Added by qt3to4: +#include #include "exports.h" #include "file.h" @@ -18,7 +20,10 @@ { indentPerDepth=" "; // Create tmpdir - tmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX")); + // FIXME not neededtmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX")); + if (!tmpDir.cd ("tmp")) + qWarning ("Could not access temporary directory for export"); + // FIXME there's more needed here... } ExportBase::~ExportBase() @@ -57,7 +62,7 @@ if (mapCenter && mapCenter->getMapEditor()) { QFileDialog *fd=new QFileDialog( mapCenter->getMapEditor(), caption); - fd->addFilter (filter); + fd->setFilter (filter); fd->setCaption(caption); fd->setMode( QFileDialog::AnyFile ); fd->show(); @@ -71,7 +76,7 @@ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::Cancel | QMessageBox::Escape, - QMessageBox::NoButton ); + Qt::NoButton ); mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") ); mb.setButtonText( QMessageBox::No, QObject::tr("Cancel")); ExportBase ex; @@ -116,9 +121,8 @@ void ExportASCII::doExport() { QFile file (outputFile); - if ( !file.open( IO_WriteOnly ) ) + if ( !file.open( QIODevice::WriteOnly ) ) { - // FIXME experimental, testing qWarning ("ExportBase::exportXML couldn't open "+outputFile); return; } @@ -127,8 +131,7 @@ // Main loop over all branches QString s; QString actIndent(""); - int i; - uint j; + int i,j; BranchObj *bo; bo=mapCenter->first(); while (bo) @@ -184,17 +187,14 @@ p.process(); QString ub=vymBaseDir.path()+"/scripts/update-bookmarks"; - QProcess *proc = new QProcess( ); - proc->addArgument(ub); - - if ( !proc->start() ) + 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)); } - - } } @@ -248,8 +248,6 @@ if (me) { me->exportXML(tmpDir.path()); - //FIXME testing - cout << "tmpDir="<getMapName()+".xml"); @@ -269,7 +267,7 @@ // it will not add a preamble, or anything // that makes a full LaTex document. QFile file (outputFile); - if ( !file.open( IO_WriteOnly ) ) { + if ( !file.open( QIODevice::WriteOnly ) ) { QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(outputFile)); mainWindow->statusMessage(QString(QObject::tr("Export failed."))); return; @@ -405,7 +403,7 @@ // Write modified content QFile f (contentFile); - if ( !f.open( IO_WriteOnly ) ) + if ( !f.open( QIODevice::WriteOnly ) ) { QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(contentFile)); mainWindow->statusMessage(QString(QObject::tr("Export failed."))); diff -r 1cc73bd7ee1f -r e95081c21da2 file.cpp --- a/file.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/file.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -1,5 +1,9 @@ #include #include +//Added by qt3to4: +#include +#include +#include #include #include "file.h" @@ -45,8 +49,8 @@ } // Now take care of paths where we have to go back first - int srcsep=s.contains("/"); - int dstsep=d.contains("/"); + int srcsep=s.count("/"); + int dstsep=d.count("/"); if (srcsep <= dstsep ) { // find path to go up first and then back to dst @@ -61,11 +65,12 @@ return d; } -QString makeUniqueDir (QString s) +QString makeUniqueDir (bool &ok,QString s) { // Create unique directory e.g. s="/tmp/vym-XXXXXX" // Convert QString to string first + ok=true; char *p; int bytes=s.length(); p=(char*) malloc (bytes+1); @@ -74,6 +79,7 @@ p[i]=s.at(i).latin1(); p[bytes]=0; QString r=mkdtemp (p); + if (r.isEmpty()) ok=false; free (p); return r; } @@ -89,16 +95,16 @@ // Traverse directories d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks ); - const QFileInfoList *dirlist = d.entryInfoList(); - QFileInfoListIterator itdir( *dirlist ); - QFileInfo *fi; + QFileInfoList list = d.entryInfoList(); + QFileInfo fi; - while ( (fi = itdir.current()) != 0 ) + for (int i = 0; i < list.size(); ++i) { - if (fi->fileName() != "." && fi->fileName() != ".." ) + fi=list.at(i); + if (fi.fileName() != "." && fi.fileName() != ".." ) { - if ( !d.cd(fi->fileName()) ) - qWarning ("removeDir() cannot find the directory "+fi->fileName()); + if ( !d.cd(fi.fileName()) ) + qWarning ("removeDir() cannot find the directory "+fi.fileName()); else { // Recursively remove subdirs @@ -106,18 +112,16 @@ d.cdUp(); } } - ++itdir; - } + } + // Traverse files d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks ); - const QFileInfoList *filelist = d.entryInfoList(); - QFileInfoListIterator itfile( *filelist ); + list = d.entryInfoList(); - while ( (fi = itfile.current()) != 0 ) + for (int i = 0; i < list.size(); ++i) { - QFile (fi->filePath()).remove(); - - ++itfile; + fi=list.at(i); + QFile (fi.filePath()).remove(); } if (!d.rmdir(d.path())) @@ -228,7 +232,7 @@ { s=""; QFile file ( fname); - if ( !file.open( IO_ReadOnly ) ) return false; + if ( !file.open( QIODevice::ReadOnly ) ) return false; QTextStream ts( &file ); ts.setEncoding (QTextStream::UnicodeUTF8); @@ -243,7 +247,7 @@ QFile file( fname); file.setName ( fname); - if ( !file.open( IO_WriteOnly ) ) + if ( !file.open( QIODevice::WriteOnly ) ) { file.close(); return false; @@ -260,10 +264,10 @@ ImagePreview::ImagePreview (QWidget *par=0): QLabel (par) { - fdia=(QFileDialog*)par; + fdia=(Q3FileDialog*)par; } -void ImagePreview::previewUrl( const QUrl &u ) +void ImagePreview::previewUrl( const Q3Url &u ) { QString path = u.path(); QPixmap pix( path ); @@ -301,3 +305,39 @@ } } +ImageIO::ImageIO () +{ + // Create list with supported image types + // foreach (QByteArray format, QImageWriter::supportedImageFormats()) + // imageTypes.append( tr("%1...").arg(QString(format).toUpper())); + imageFilters.append ("Images (*.png *.jpg *.jpeg *.bmp *.bmp *.ppm *.xpm *.xbm)"); + imageTypes.append ("PNG"); + imageFilters.append ("Portable Network Graphics (*.png)"); + imageTypes.append ("PNG"); + imageFilters.append ("Joint Photographic Experts Group (*.jpg)"); + imageTypes.append ("JPG"); + imageFilters.append ("Joint Photographic Experts Group (*.jpeg)"); + imageTypes.append ("JPG"); + imageFilters.append ("Windows Bitmap (*.bmp)"); + imageTypes.append ("BMP"); + imageFilters.append ("Portable Pixmap (*.ppm)"); + imageTypes.append ("PPM"); + imageFilters.append ("X11 Bitmap (*.xpm)"); + imageTypes.append ("XPM"); + imageFilters.append ("X11 Bitmap (*.xbm)"); + imageTypes.append ("XBM"); +} + +QStringList ImageIO::getFilters() +{ + return imageFilters; +} + +QString ImageIO::getType(QString filter) +{ + for (int i=0;i -#include +#include #include -class ImagePreview : public QLabel, public QFilePreview +class ImagePreview : public QLabel, public Q3FilePreview { public: ImagePreview( QWidget * ); - void previewUrl( const QUrl & ); + void previewUrl( const Q3Url & ); protected: - QFileDialog *fdia; + Q3FileDialog *fdia; +}; + + +////////////////////////////////////////////////////////// +// Helper function to select image format while in SaveDialogs + +class ImageIO +{ +public: + ImageIO (); + QStringList getFilters(); + QString getType ( QString ); + +private: + QStringList imageFilters; + QStringList imageTypes; }; #endif diff -r 1cc73bd7ee1f -r e95081c21da2 flagobj.cpp --- a/flagobj.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/flagobj.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -1,4 +1,6 @@ #include "flagobj.h" +//Added by qt3to4: +#include ///////////////////////////////////////////////////////////////// // FlagObj @@ -9,7 +11,7 @@ init (); } -FlagObj::FlagObj(QCanvas* c):MapObj(c) +FlagObj::FlagObj(Q3Canvas* c):MapObj(c) { // cout << "Const FlagObj canvas="<move (absPos.x(), absPos.y() ); - button=NULL; state=false; + action=NULL; } void FlagObj::copy (FlagObj* other) @@ -46,10 +48,8 @@ tooltip=other->tooltip; state=other->state; icon->copy(other->icon); + action=other->action; setVisibility (other->isVisibleObj() ); - // button is not copied, because - // we won't copy to a parentRow and - // all others don't need a button } void FlagObj::move(double x, double y) @@ -117,24 +117,21 @@ return tooltip; } -void FlagObj::setButton(QAction* b) -{ - button=b; -} - -void FlagObj::updateButton() -{ - if (button) - button->setOn(state); - else - qWarning ("FlagObj::updateButton no button defined"); -} - QPixmap FlagObj::getPixmap() { return icon->getPixmap(); } +void FlagObj::setAction (QAction* a) +{ + action=a; +} + +void FlagObj::updateAction () +{ + if (action) action->setChecked(state); +} + bool FlagObj::isActive() { return state; @@ -170,12 +167,6 @@ } } -void FlagObj::setEnabled(bool b) -{ - button->setEnabled (b); -} - - void FlagObj::setUsed (bool b) { used=b; diff -r 1cc73bd7ee1f -r e95081c21da2 flagobj.h --- a/flagobj.h Tue Sep 05 09:47:13 2006 +0000 +++ b/flagobj.h Tue Sep 05 09:47:14 2006 +0000 @@ -2,8 +2,10 @@ #define FLAGOBJ_H -#include +#include #include +//Added by qt3to4: +#include #include "mapobj.h" #include "imageobj.h" @@ -12,7 +14,7 @@ class FlagObj:public MapObj { public: FlagObj (); - FlagObj (QCanvas*); + FlagObj (Q3Canvas*); FlagObj (FlagObj*); ~FlagObj (); virtual void init (); @@ -28,14 +30,13 @@ const QString getGroup(); void setToolTip(const QString&); const QString getToolTip(); - void setButton (QAction*); - void updateButton (); QPixmap getPixmap(); + void setAction(QAction*); + void updateAction (); bool isActive(); void toggle(); void activate(); void deactivate(); - void setEnabled (bool); void setUsed (bool); bool isUsed(); void saveToDir (const QString&, const QString&); @@ -50,7 +51,7 @@ virtual void calcBBoxSize(); private: ImageObj* icon; - QAction* button; + QAction* action; }; #endif diff -r 1cc73bd7ee1f -r e95081c21da2 flagrowobj.cpp --- a/flagrowobj.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/flagrowobj.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -1,5 +1,7 @@ #include "flagrowobj.h" +#include + ///////////////////////////////////////////////////////////////// // FlagRowObj ///////////////////////////////////////////////////////////////// @@ -9,7 +11,7 @@ init (); } -FlagRowObj::FlagRowObj(QCanvas* c):MapObj(c) +FlagRowObj::FlagRowObj(Q3Canvas* c):MapObj(c) { // cout << "Const FlagRowObj\n"; init (); @@ -232,15 +234,16 @@ } } +void FlagRowObj::setToolBar(QToolBar *tb) +{ + toolbar=tb; +} + void FlagRowObj::setEnabled (bool b) { - // If we have no parent, we are the default FlagRowObj - // and have QToolbarButtons - if (!parentRow) + if (toolbar) { - FlagObj *fo; - for (fo=flag.first();fo; fo=flag.next() ) - fo->setEnabled (b); + toolbar->setEnabled (b); } } @@ -286,44 +289,13 @@ name=n; } -void FlagRowObj::makeToolbar (QMainWindow *w, const QString &n) -{ - //Only make toolbar for the parentrow, not each row in branches - if (!parentRow) - { - // create bar and buttons - QToolBar* tb = new QToolBar( w); - tb->setLabel (n); - QAction *a; - FlagObj *fo; - for (fo=flag.first();fo; fo=flag.next() ) - { - a=new QAction ( - fo->getToolTip(), - fo->getPixmap(), - fo->getName(), - 0, - w, - fo->getName() - ); - a->setToggleAction(true); - // FIXME should not be enabled by default, later in updateToolbar - a->setEnabled(true); - a->addTo (tb); - fo->setButton (a); - connect(a, SIGNAL( activated() ), - w, SLOT( standardFlagChanged() ) ); - } - } else - qWarning ("FlagRowObj::makeToolbar must not be called for ordinary rows"); -} - void FlagRowObj::updateToolbar() { FlagObj *fo; if (parentRow) { // We are just a branch, not the toolbar default + // but state has to be copied from ourselves to parentrow! parentRow->deactivateAll(); // In parentRow activate all existing (==active) flags for (fo=flag.first();fo; fo=flag.next() ) @@ -332,8 +304,12 @@ } else { // We are the toolbar default - for (fo=flag.first();fo; fo=flag.next() ) - fo->updateButton(); + if (toolbar) + { + // Update state of actions in toolbar + for (fo=flag.first();fo; fo=flag.next() ) + fo->updateAction(); + } } } diff -r 1cc73bd7ee1f -r e95081c21da2 flagrowobj.h --- a/flagrowobj.h Tue Sep 05 09:47:13 2006 +0000 +++ b/flagrowobj.h Tue Sep 05 09:47:14 2006 +0000 @@ -1,7 +1,9 @@ #ifndef FLAGROWOBJ_H #define FLAGROWOBJ_H -#include +#include +//Added by qt3to4: +#include #include "mapobj.h" #include "flagobj.h" @@ -9,7 +11,7 @@ class FlagRowObj:public QObject,public MapObj { public: FlagRowObj (); - FlagRowObj (QCanvas*); + FlagRowObj (Q3Canvas*); ~FlagRowObj (); virtual void init (); virtual void copy (FlagRowObj*); @@ -27,6 +29,7 @@ void deactivate(const QString&); void deactivateAll(); void deactivateGroup(FlagObj *); + void setToolBar (QToolBar *); void setEnabled (bool); void setShowFlags (bool); void resetUsedCounter(); @@ -37,7 +40,8 @@ private: FlagRowObj* parentRow; // look for flags in this row FlagObj* findFlag (const QString&); - QPtrList flag; + Q3PtrList flag; + QToolBar *toolbar; QString name; bool showFlags; // FloatObjects want to hide their flags }; diff -r 1cc73bd7ee1f -r e95081c21da2 floatimageobj.cpp --- a/floatimageobj.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/floatimageobj.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -1,5 +1,7 @@ #include "floatimageobj.h" #include "branchobj.h" +//Added by qt3to4: +#include ///////////////////////////////////////////////////////////////// @@ -17,7 +19,7 @@ depth=-1; } -FloatImageObj::FloatImageObj (QCanvas* c):FloatObj(c) +FloatImageObj::FloatImageObj (Q3Canvas* c):FloatObj(c) { // cout << "Const FloatImageObj (c) called from MapCenterObj (c)\n"; setParObj (this); @@ -25,7 +27,7 @@ depth=-1; } -FloatImageObj::FloatImageObj (QCanvas* c, OrnamentedObj* p):FloatObj(c,p) +FloatImageObj::FloatImageObj (Q3Canvas* c, OrnamentedObj* p):FloatObj(c,p) { // cout << "Const FloatImageObj (c,p)\n"; init(); @@ -94,7 +96,7 @@ bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8)); positionBBox(); filename=fn; - filetype=QPixmap::imageFormat (fn); +//FIXME QT3 was filetype=QPixmap::imageFormat (fn); setOriginalFilename (fn); return true; } else @@ -102,9 +104,9 @@ } -void FloatImageObj::save (const QString &fn, const char *format) +void FloatImageObj::save (const QString &fn, const QString &format) { - icon->save (fn,format); + icon->save (fn,qPrintable (format)); } void FloatImageObj::setOriginalFilename(const QString & fn) @@ -180,14 +182,10 @@ QString zAttr=attribut ("zPlane",QString().setNum(zPlane)); QString url; - // prevent saving as GIF - if (filetype=="GIF") - filetype="PNG"; - url="images/"+prefix+"image-" + QString().number(saveCounter,10) + "." +filetype; // And really save the image - icon->save (tmpdir + "/" + url, filetype); + icon->save (tmpdir + "/" + url, "PNG"); QString nameAttr=attribut ("orgName",originalFilename); diff -r 1cc73bd7ee1f -r e95081c21da2 floatimageobj.h --- a/floatimageobj.h Tue Sep 05 09:47:13 2006 +0000 +++ b/floatimageobj.h Tue Sep 05 09:47:14 2006 +0000 @@ -2,13 +2,15 @@ #define FLOATIMAGEOBJ_H #include "floatobj.h" +//Added by qt3to4: +#include ///////////////////////////////////////////////////////////////////////////// class FloatImageObj:public FloatObj { public: FloatImageObj (); - FloatImageObj (QCanvas*); - FloatImageObj (QCanvas*, OrnamentedObj* parent); + FloatImageObj (Q3Canvas*); + FloatImageObj (Q3Canvas*, OrnamentedObj* parent); ~FloatImageObj (); virtual void init (); virtual void copy (FloatImageObj*); @@ -17,7 +19,7 @@ virtual void load (const QPixmap &); virtual bool load (const QString &); - virtual void save (const QString &, const char *); + virtual void save (const QString &, const QString&); virtual void setOriginalFilename(const QString &); virtual QString getOriginalFilename(); virtual void setVisibility(bool); // set vis. for w diff -r 1cc73bd7ee1f -r e95081c21da2 floatobj.cpp --- a/floatobj.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/floatobj.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -14,7 +14,7 @@ depth=-1; } -FloatObj::FloatObj (QCanvas* c):OrnamentedObj(c) +FloatObj::FloatObj (Q3Canvas* c):OrnamentedObj(c) { // cout << "Const FloatObj (c) called from MapCenterObj (c)\n"; setParObj (this); @@ -22,7 +22,7 @@ depth=-1; } -FloatObj::FloatObj (QCanvas* c, LinkableMapObj* p):OrnamentedObj (c) +FloatObj::FloatObj (Q3Canvas* c, LinkableMapObj* p):OrnamentedObj (c) { // cout << "Const FloatObj (c,p)\n"; setParObj (p); diff -r 1cc73bd7ee1f -r e95081c21da2 floatobj.h --- a/floatobj.h Tue Sep 05 09:47:13 2006 +0000 +++ b/floatobj.h Tue Sep 05 09:47:14 2006 +0000 @@ -7,8 +7,8 @@ class FloatObj:public OrnamentedObj { public: FloatObj (); - FloatObj (QCanvas*); - FloatObj (QCanvas*, LinkableMapObj* parent); + FloatObj (Q3Canvas*); + FloatObj (Q3Canvas*, LinkableMapObj* parent); ~FloatObj (); virtual void init (); virtual void copy (FloatObj*); diff -r 1cc73bd7ee1f -r e95081c21da2 frameobj.cpp --- a/frameobj.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/frameobj.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -11,7 +11,7 @@ init (); } -FrameObj::FrameObj(QCanvas* c) :MapObj(c) +FrameObj::FrameObj(Q3Canvas* c) :MapObj(c) { // cout << "Const FrameObj\n"; init (); @@ -117,7 +117,7 @@ break; case Rectangle: border=10; - rectFrame = new QCanvasRectangle (canvas); + rectFrame = new Q3CanvasRectangle (canvas); rectFrame->setZ(Z_FRAME); rectFrame->setBrush( QColor("white") ); rectFrame->setPen( QPen(QColor("black") )); diff -r 1cc73bd7ee1f -r e95081c21da2 frameobj.h --- a/frameobj.h Tue Sep 05 09:47:13 2006 +0000 +++ b/frameobj.h Tue Sep 05 09:47:14 2006 +0000 @@ -8,7 +8,7 @@ class FrameObj:public MapObj { public: FrameObj(); - FrameObj(QCanvas*); + FrameObj(Q3Canvas*); ~FrameObj(); void init(); void clear(); @@ -26,7 +26,7 @@ protected: FrameType type; - QCanvasRectangle* rectFrame; + Q3CanvasRectangle* rectFrame; int border; // distance text - frame }; #endif diff -r 1cc73bd7ee1f -r e95081c21da2 headingobj.cpp --- a/headingobj.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/headingobj.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -10,7 +10,7 @@ init (); } -HeadingObj::HeadingObj(QCanvas* c) :MapObj(c) +HeadingObj::HeadingObj(Q3Canvas* c) :MapObj(c) { // cout << "Const HeadingObj\n"; init (); @@ -50,7 +50,7 @@ h=textline.first()->boundingRect().height(); else h=2; - QCanvasText *t; + Q3CanvasText *t; ho=0; for (t=textline.first(); t; t=textline.next() ) { @@ -80,7 +80,7 @@ // then no selection would be visible, thus we prevent it in ::setText() if (!textline.isEmpty() ) { - QCanvasText *t; + Q3CanvasText *t; for (t=textline.first(); t; t=textline.next() ) { h+=t->boundingRect().height(); @@ -91,10 +91,10 @@ bbox.setSize (QSize(w,h)); } -QCanvasText* HeadingObj::newLine(QString s) +Q3CanvasText* HeadingObj::newLine(QString s) { - QCanvasText *t; - t = new QCanvasText(canvas); + Q3CanvasText *t; + t = new Q3CanvasText(canvas); t->setFont (font); t->setColor (color); t->setZ(Z_TEXT); @@ -220,7 +220,7 @@ if (color!=c) { color=c; - QCanvasText *t; + Q3CanvasText *t; for (t=textline.first(); t; t=textline.next() ) t->setColor(c); } @@ -234,7 +234,7 @@ void HeadingObj::setVisibility (bool v) { MapObj::setVisibility(v); - QCanvasText *t; + Q3CanvasText *t; for (t=textline.first(); t; t=textline.next() ) if (v) t->show(); diff -r 1cc73bd7ee1f -r e95081c21da2 headingobj.h --- a/headingobj.h Tue Sep 05 09:47:13 2006 +0000 +++ b/headingobj.h Tue Sep 05 09:47:14 2006 +0000 @@ -2,11 +2,13 @@ #define HEADINGOBJ_H #include "mapobj.h" +//Added by qt3to4: +#include class HeadingObj:public MapObj { public: HeadingObj(); - HeadingObj(QCanvas*); + HeadingObj(Q3Canvas*); virtual ~HeadingObj(); virtual void init(); virtual void copy(HeadingObj*); @@ -15,7 +17,7 @@ virtual void positionBBox(); virtual void calcBBoxSize(); private: - QCanvasText* newLine(QString); // generate new textline + Q3CanvasText* newLine(QString); // generate new textline public: virtual void setText(QString); virtual QString text(); @@ -30,7 +32,7 @@ protected: QString heading; uint textwidth; // width for formatting text - QPtrList textline; // a part of e.g. the parabel + Q3PtrList textline; // a part of e.g. the parabel QColor color; QFont font; }; diff -r 1cc73bd7ee1f -r e95081c21da2 imageobj.cpp --- a/imageobj.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/imageobj.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -1,10 +1,12 @@ #include "imageobj.h" +//Added by qt3to4: +#include ///////////////////////////////////////////////////////////////// // ImageObj ///////////////////////////////////////////////////////////////// -ImageObj::ImageObj( QCanvas *canvas ) - : QCanvasRectangle( canvas ) +ImageObj::ImageObj( Q3Canvas *canvas ) + : Q3CanvasRectangle( canvas ) { // cout << "Const ImageObj (canvas)\n"; setZ(Z_ICON); @@ -54,7 +56,7 @@ type=qimage; #if !defined(Q_WS_QWS) - pixmap.convertFromImage(image, OrderedAlphaDither); + pixmap.convertFromImage(image, Qt::OrderedAlphaDither); #endif return true; } @@ -78,7 +80,7 @@ { type=qimage; image=img; - pixmap.convertFromImage(image, OrderedAlphaDither); + pixmap.convertFromImage(image, Qt::OrderedAlphaDither); } QPixmap ImageObj::getPixmap() @@ -91,7 +93,7 @@ // On Qt/Embedded, we can paint a QImage as fast as a QPixmap, // but on other platforms, we need to use a QPixmap. #if defined(Q_WS_QWS) - p.drawImage( int(x()), int(y()), image, 0, 0, -1, -1, OrderedAlphaDither ); + p.drawImage( int(x()), int(y()), image, 0, 0, -1, -1, Qt::OrderedAlphaDither ); #else p.drawPixmap( int(x()), int(y()), pixmap ); #endif diff -r 1cc73bd7ee1f -r e95081c21da2 imageobj.h --- a/imageobj.h Tue Sep 05 09:47:13 2006 +0000 +++ b/imageobj.h Tue Sep 05 09:47:14 2006 +0000 @@ -2,17 +2,19 @@ #define IMAGEOBJ_H #include -#include +#include #include +//Added by qt3to4: +#include #include "mapobj.h" enum ImageType {qimage,qpixmap,undef}; -class ImageObj: public QCanvasRectangle +class ImageObj: public Q3CanvasRectangle { public: - ImageObj( QCanvas *canvas ); + ImageObj( Q3Canvas *canvas ); ~ImageObj(); virtual void copy (ImageObj*); virtual void setVisibility(bool); diff -r 1cc73bd7ee1f -r e95081c21da2 imports.cpp --- a/imports.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/imports.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -1,4 +1,6 @@ -#include +#include +//Added by qt3to4: +#include #include "file.h" #include "imports.h" @@ -13,7 +15,10 @@ ImportBase::ImportBase() { // Create tmpdir - tmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX")); + // FIXME not neededtmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX")); + if (!tmpDir.cd ("tmp")) + qWarning ("Could not access temporary directory for export"); + // FIXME } @@ -70,7 +75,7 @@ QStringList lines; QFile file( inputFile ); - if ( file.open( IO_ReadOnly ) ) + if ( file.open( QIODevice::ReadOnly ) ) { QTextStream stream( &file ); while ( !stream.atEnd() ) @@ -90,7 +95,6 @@ // try to unzip if (success==unzipDir (tmpDir, inputFile)) { - cout << "Unzipped "<=0) transformedFile=transformedFile.remove (0,i+1); transformedFile.replace(".mmap",".xml"); transformedFile=tmpDir.path()+"/"+transformedFile; - cout << " transformedFile="< ///////////////////////////////////////////////////////////////// @@ -17,7 +19,7 @@ init (); } -LinkableMapObj::LinkableMapObj(QCanvas* c) :MapObj(c) +LinkableMapObj::LinkableMapObj(Q3Canvas* c) :MapObj(c) { // cout << "Const LinkableMapObj\n"; init (); @@ -77,15 +79,15 @@ linkpos=LinkBottom; segment.setAutoDelete (TRUE); arcsegs=13; - QPointArray pa(arcsegs*2+2); + Q3PointArray pa(arcsegs*2+2); - bottomline=new QCanvasLine(canvas); + bottomline=new Q3CanvasLine(canvas); bottomline->setPen( QPen(linkcolor, 1) ); bottomline->setZ(Z_LINK); bottomline->show(); // Prepare showing the selection of a MapObj - selbox = new QCanvasRectangle (canvas); + selbox = new Q3CanvasRectangle (canvas); selbox->setZ(Z_SELBOX); selbox->setBrush( QColor(255,255,0) ); selbox->setPen( QPen(QColor(255,255,0) )); @@ -152,8 +154,7 @@ { if (parObj) { - relPos.setX (absPos.x() - parObj->getChildPos().x() ); - relPos.setY (absPos.y() - parObj->getChildPos().y() ); + relPos=getRelPos(); parObj->calcBBoxSize(); parObj->requestReposition(); @@ -169,6 +170,14 @@ } } +QPoint LinkableMapObj::getRelPos() +{ + if (!parObj) return QPoint(); + relPos.setX (absPos.x() - parObj->getChildPos().x() ); + relPos.setY (absPos.y() - parObj->getChildPos().y() ); + return relPos; +} + int LinkableMapObj::getTopPad() { return topPad; @@ -225,14 +234,14 @@ if (childObj!=NULL && parObj != NULL) { int i; - QCanvasLine* cl; + Q3CanvasLine* cl; switch (style) { case StyleUndef: bottomline->hide(); break; case StyleLine: - l = new QCanvasLine(canvas); + l = new Q3CanvasLine(canvas); l->setPen( QPen(linkcolor, 1) ); l->setZ(Z_LINK); if (visible) @@ -243,7 +252,7 @@ case StyleParabel: for (i=0;isetPen( QPen(linkcolor, 1) ); cl->setPoints( 0,0,i*10,100); cl->setZ(Z_LINK); @@ -256,7 +265,7 @@ pa0.resize (arcsegs+1); break; case StylePolyLine: - p = new QCanvasPolygon(canvas); + p = new Q3CanvasPolygon(canvas); p->setBrush( linkcolor ); p->setZ(Z_LINK); if (visible) @@ -266,7 +275,7 @@ pa0.resize (3); // TODO a bit awkward: draw the lines additionally to polygon, to avoid // missing pixels, when polygon is extremly flat - l = new QCanvasLine(canvas); + l = new Q3CanvasLine(canvas); l->setPen( QPen(linkcolor, 1) ); l->setZ(Z_LINK); if (visible) @@ -275,7 +284,7 @@ l->hide(); break; case StylePolyParabel: - p = new QCanvasPolygon(canvas); + p = new Q3CanvasPolygon(canvas); p->setBrush( linkcolor ); p->setZ(Z_LINK); if (visible) @@ -291,7 +300,7 @@ // if polygon is extremly flat for (i=0;isetPen( QPen(linkcolor, 1) ); cl->setPoints( 0,0,i*10,100); cl->setZ(Z_LINK); @@ -348,7 +357,7 @@ { linkcolor=col; bottomline->setPen( QPen(linkcolor, 1) ); - QCanvasLine *cl; + Q3CanvasLine *cl; switch (style) { case StyleLine: @@ -400,7 +409,7 @@ void LinkableMapObj::setVisibility (bool v) { - QCanvasLine* cl; + Q3CanvasLine* cl; MapObj::setVisibility (v); bool visnow=visible; @@ -550,7 +559,7 @@ // "turning point" for drawing polygonal links QPoint tp (-qRound(sin (a)*thickness_start), qRound(cos (a)*thickness_start)); - QCanvasLine *cl; + Q3CanvasLine *cl; int i; @@ -663,21 +672,6 @@ return parPos; } -QPoint LinkableMapObj::getRelPos() -{ - return relPos; -/* FIXME not needed? relPos was moved in 1.7.10 from - floatobj to linkablemapobj. Before we had: - - if (!parObj) return QPoint (0,0); - return QPoint( - absPos.x() - parObj->x(), - absPos.y() - parObj->y() - ); -*/ -} - - void LinkableMapObj::setUseOrientation (const bool &b) { if (useOrientation!=b) @@ -802,7 +796,7 @@ setVisibility (visible); } -void LinkableMapObj::parabel (QPointArray &ya, double p1x, double p1y, double p2x, double p2y) +void LinkableMapObj::parabel (Q3PointArray &ya, double p1x, double p1y, double p2x, double p2y) { double vx=p2x - p1x; // V=P2-P1 diff -r 1cc73bd7ee1f -r e95081c21da2 linkablemapobj.h --- a/linkablemapobj.h Tue Sep 05 09:47:13 2006 +0000 +++ b/linkablemapobj.h Tue Sep 05 09:47:14 2006 +0000 @@ -5,6 +5,9 @@ #include "noteobj.h" #include "headingobj.h" #include "flagrowobj.h" +//Added by qt3to4: +#include +#include #define MAX_DEPTH 999 @@ -23,7 +26,7 @@ Q_OBJECT public: LinkableMapObj (); - LinkableMapObj (QCanvas*); + LinkableMapObj (Q3Canvas*); LinkableMapObj (LinkableMapObj*); ~LinkableMapObj (); virtual void delLink(); @@ -38,6 +41,7 @@ virtual void setUseRelPos (const bool&); virtual void setRelPos(); // set relPos to current parentPos virtual void setRelPos(const QPoint&); + virtual QPoint getRelPos(); virtual void setUseOrientation (const bool &); @@ -68,7 +72,6 @@ virtual void setDockPos(); // sets childPos and parPos QPoint getChildPos(); // returns pos where childs dock QPoint getParPos(); // returns pos where parents dock - QPoint getRelPos(); // get position relative to parent (or (0,0)) LinkOrient getOrientation(); // get orientation virtual int getDepth(); // return depth virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag) @@ -93,7 +96,7 @@ virtual QString saveToDir (const QString&,const QString&, const QPoint&)=0;// Save data to tempdir protected: - void parabel(QPointArray &,double,double,double,double); // Create Parabel connecting two points + void parabel(Q3PointArray &,double,double,double,double); // Create Parabel connecting two points QString getLinkAttr(); QPoint childPos; @@ -114,19 +117,19 @@ LinkStyle style; // Current style LinkPos linkpos; // Link at bottom of object or middle of height QColor linkcolor; // Link color - QCanvasLine* l; // line style - QCanvasPolygon* p; // poly styles + Q3CanvasLine* l; // line style + Q3CanvasPolygon* p; // poly styles int arcsegs; // arc: number of segments - QPtrList segment; // a part of e.g. the parabel - QPointArray pa0; // For drawing of PolyParabel and PolyLine - QPointArray pa1; // For drawing of PolyParabel - QPointArray pa2; // For drawing of PolyParabel - QCanvasLine* bottomline; // on bottom of BBox + Q3PtrList segment; // a part of e.g. the parabel + Q3PointArray pa0; // For drawing of PolyParabel and PolyLine + Q3PointArray pa1; // For drawing of PolyParabel + Q3PointArray pa2; // For drawing of PolyParabel + Q3CanvasLine* bottomline; // on bottom of BBox bool repositionRequest; // bool selected; // Used for marking the selection bool hideLinkUnselected; // to hide links if unselected - QCanvasRectangle* selbox; + Q3CanvasRectangle* selbox; FrameObj *frame; // frame around object int topPad, botPad, leftPad, rightPad; // padding within bbox diff -r 1cc73bd7ee1f -r e95081c21da2 main.cpp --- a/main.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/main.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -1,16 +1,16 @@ -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "settings.h" #include "options.h" #include "mainwindow.h" - #include "flagrowobj.h" // Global variables @@ -21,6 +21,8 @@ QString tmpVymDir; // All temp files go there, created in mainwindow QString clipboardDir; // Clipboard used in all mapEditors QDir vymBaseDir; // Containing all styles, scripts, images, ... +QDir lastImageDir; +QDir lastFileDir; QString iconPath; // Pointing to icons used for toolbars QString flagsPath; // Pointing to flags bool clipboardEmpty; @@ -29,7 +31,7 @@ // Lists of actions // (QActionGroup could not be "enabled") -QPtrList actionListBranches; +Q3PtrList actionListBranches; // Actions which change sometimes QAction *actionFileSave; @@ -44,11 +46,13 @@ QAction *actionEditToggleScroll; QAction *actionEditOpenURL; QAction *actionEditOpenURLTab; +QAction *actionEditOpenMultipleURLTabs; QAction *actionEditURL; QAction *actionEditHeading2URL; QAction *actionEditBugzilla2URL; QAction *actionEditFATE2URL; QAction *actionEditOpenVymLink; +QAction *actionEditOpenMultipleVymLinks; QAction *actionEditVymLink; QAction *actionEditToggleHideExport; QAction *actionEditDeleteVymLink; @@ -99,33 +103,36 @@ QAction *actionSettingsAutoselectHeading; QAction *actionSettingsAutoselectText; -QAction *actionSettingsPasteNewHeading; QAction *actionSettingsAutoedit; QAction *actionSettingsUseDelKey; QAction *actionSettingsUseFlagGroups; QAction *actionSettingsUseHideExport; -QPopupMenu *branchContextMenu; -QPopupMenu *branchAddContextMenu; -QPopupMenu *branchRemoveContextMenu; -QPopupMenu *branchLinksContextMenu; -QPopupMenu *branchLinksContextMenuDup; -QPopupMenu *floatimageContextMenu; -QPopupMenu *saveImageFormatMenu; -QPopupMenu *canvasContextMenu; -QPopupMenu *lastMapsMenu; -QPopupMenu *importMenu; -QPopupMenu *exportMenu; -QPopupMenu *exportImageFormatMenu; +QMenu* branchContextMenu; +QMenu* branchAddContextMenu; +QMenu* branchRemoveContextMenu; +QMenu* branchLinksContextMenu; +QMenu* branchXLinksContextMenuEdit; +QMenu* branchXLinksContextMenuFollow; +QMenu* floatimageContextMenu; +QMenu* canvasContextMenu; +QMenu* fileLastMapsMenu; +QMenu* fileImportMenu; +QMenu* fileExportMenu; -Settings settings; + +Settings settings ("InSilmaril","vym"); // Organization, Application name + Options options; +ImageIO imageIO; int statusbarTime=3500; int main(int argc, char** argv) { +//FIXME Q_INIT_RESOURCE (application); + QApplication app(argc,argv); @@ -144,14 +151,14 @@ "http://www.InSilmaril.de/vym\n"); if (options.parse()) { - cout << endl << options.getHelpText()<setPixmap("vym-128x128", QPixmap(iconPath+"vym-128x128.png")); - qInitNetworkProtocols(); + q3InitNetworkProtocols(); // Initialize translations diff -r 1cc73bd7ee1f -r e95081c21da2 mainwindow.cpp --- a/mainwindow.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/mainwindow.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -1,20 +1,25 @@ #include "mainwindow.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//Added by qt3to4: +#include +#include +#include +#include +#include +#include +#include +#include //#include // for random seed - #include #include #include @@ -44,7 +49,7 @@ extern FlagRowObj* standardFlagsDefault; extern FlagRowObj* systemFlagsDefault; -extern QPtrList actionListBranches; +extern Q3PtrList actionListBranches; extern QAction* actionFileSave; extern QAction* actionFilePrint; @@ -58,11 +63,13 @@ extern QAction *actionEditToggleScroll; extern QAction* actionEditOpenURL; extern QAction* actionEditOpenURLTab; +extern QAction* actionEditOpenMultipleURLTabs; extern QAction* actionEditURL; extern QAction* actionEditHeading2URL; extern QAction* actionEditBugzilla2URL; extern QAction* actionEditFATE2URL; extern QAction *actionEditOpenVymLink; +extern QAction *actionEditOpenMultipleVymLinks; extern QAction *actionEditVymLink; extern QAction *actionEditDeleteVymLink; extern QAction *actionEditToggleHideExport; @@ -115,36 +122,34 @@ extern QAction* actionSettingsAutoselectHeading; extern QAction* actionSettingsAutoselectHeading; extern QAction* actionSettingsAutoselectText; -extern QAction* actionSettingsPasteNewHeading; extern QAction* actionSettingsUseDelKey; extern QAction* actionSettingsUseFlagGroups; extern QAction* actionSettingsUseHideExport; -extern QPopupMenu* branchContextMenu; -extern QPopupMenu* branchAddContextMenu; -extern QPopupMenu* branchRemoveContextMenu; -extern QPopupMenu* branchLinksContextMenu; -extern QPopupMenu* branchLinksContextMenuDup; -extern QPopupMenu* floatimageContextMenu; -extern QPopupMenu* saveImageFormatMenu; -extern QPopupMenu* canvasContextMenu; -extern QPopupMenu* lastMapsMenu; -extern QPopupMenu* importMenu; -extern QPopupMenu* exportMenu; -extern QPopupMenu* exportImageFormatMenu; +extern QMenu* branchContextMenu; +extern QMenu* branchAddContextMenu; +extern QMenu* branchRemoveContextMenu; +extern QMenu* branchLinksContextMenu; +extern QMenu* branchXLinksContextMenuEdit; +extern QMenu* branchXLinksContextMenuFollow; +extern QMenu* floatimageContextMenu; +extern QMenu* canvasContextMenu; +extern QMenu* fileLastMapsMenu; +extern QMenu* fileImportMenu; +extern QMenu* fileExportMenu; extern Settings settings; extern Options options; +extern ImageIO imageIO; + extern QDir vymBaseDir; +extern QDir lastImageDir; +extern QDir lastFileDir; extern QString iconPath; extern QString flagsPath; -#if defined(Q_OS_LINUX) -extern void qt_wait_for_window_manager( QWidget* w ); -#endif - -Main::Main(QWidget* parent, const char* name, WFlags f) : +Main::Main(QWidget* parent, const char* name, Qt::WFlags f) : QMainWindow(parent,name,f) { mainWindow=this; @@ -152,14 +157,18 @@ setCaption ("VYM - View Your Mind"); // Load window settings - resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800), - settings.readNumEntry( "/vym/mainwindow/geometry/height",600)); - move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100), - settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100)); + resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize()); + move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint()); // Create unique temporary directory - tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX"); + bool ok; + tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX"); + if (!ok) + { + qWarning ("Mainwindow: Could not create temporary directory, failed to start vym"); + exit (1); + } // Create direcctory for clipboard clipboardDir=tmpVymDir+"/clipboard"; @@ -180,30 +189,30 @@ QString p,s; // application to open URLs - p="/vym/mainwindow/readerURL"; + p="/mainwindow/readerURL"; #if defined(Q_OS_LINUX) - s=settings.readEntry (p,"konqueror"); + s=settings.value (p,"konqueror").toString(); #else #if defined(Q_OS_MACX) - s=settings.readEntry (p,"/usr/bin/open"); + s=settings.value (p,"/usr/bin/open").toString(); #else - s=settings.readEntry (p,"mozilla"); + s=settings.value (p,"mozilla"); #endif #endif - settings.writeEntry( p,s); + settings.setValue( p,s); // application to open PDFs - p="/vym/mainwindow/readerPDF"; + p="/mainwindow/readerPDF"; #if defined(Q_OS_LINUX) - s=settings.readEntry (p,"acroread"); + s=settings.value (p,"acroread").toString(); #else #if defined(Q_OS_MACX) - s=settings.readEntry (p,"/usr/bin/open"); + s=settings.value (p,"/usr/bin/open").toString(); #else - s=settings.readEntry (p,"acroread"); + s=settings.value (p,"acroread").toString(); #endif #endif - settings.writeEntry( p,s); + settings.setValue( p,s); maxLastMaps=9; @@ -213,6 +222,9 @@ connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), this, SLOT( editorChanged( QWidget * ) ) ); + lineedit=new QLineEdit (this); + lineedit->hide(); + setCentralWidget(tabWidget); setupFileActions(); @@ -223,14 +235,12 @@ setupFlagActions(); setupSettingsActions(); setupContextMenus(); - if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions(); + if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions(); setupHelpActions(); - // After menu is created, we can enable some actions - actionFilePrint->setEnabled (true); - statusBar(); + restoreState (settings.value("/mainwindow/state",0).toByteArray()); // Initialize Find window findWindow=new FindWindow(NULL,"findwindow"); @@ -248,31 +258,29 @@ Main::~Main() { // Save Settings - settings.writeEntry( "/vym/mainwindow/geometry/width", width() ); - settings.writeEntry( "/vym/mainwindow/geometry/height", height() ); - settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() ); - settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() ); - - settings.writeEntry( "/vym/version/version", __VYM_VERSION ); - settings.writeEntry( "/vym/version/builddate", __BUILD_DATE ); - - settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() ); - settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() ); - settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() ); - settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() ); - settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() ); - settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); - settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() ); + settings.setValue ( "/mainwindow/geometry/size", size() ); + settings.setValue ( "/mainwindow/geometry/pos", pos() ); + + settings.setValue ("/mainwindow/state",saveState(0)); + + settings.setValue( "/version/version", __VYM_VERSION ); + settings.setValue( "/version/builddate", __BUILD_DATE ); + + settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoselectHeading->isOn() ); + settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoselectText->isOn() ); + settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoedit->isOn() ); + settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() ); + settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); + settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() ); QString s; int maps=lastMaps.count(); - settings.writeEntry( "/vym/lastMaps/number",maps ); + settings.setValue( "/lastMaps/number",maps ); for (int i=1;i<=maps;i++) { - QStringList::Iterator it = lastMaps.at(i-1); - s=QString("/vym/lastMaps/map-%1").arg(i); + s=QString("/lastMaps/map-%1").arg(i); if (!s.isEmpty() && i<=maxLastMaps) - settings.writeEntry (s, *it); + settings.setValue (s, lastMaps.at(i-1)); } @@ -315,215 +323,327 @@ // File Actions void Main::setupFileActions() { - QToolBar *tb = new QToolBar( this ); - tb->setLabel( "File Actions" ); - QPopupMenu *menu = new QPopupMenu( this ); - menuBar()->insertItem( tr( "&File" ), menu ); - - // Keycodes: /usr/lib64/qt3/include/qnamespace.h + QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") ); + QToolBar *tb = addToolBar( tr ("&Map") ); + tb->setObjectName ("mapTB"); QAction *a; - a = new QAction( tr( "New map","File menu" ), QPixmap( iconPath+"filenew.png"), tr( "&New..." ), CTRL + Key_N, this, "fileNew" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); + a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this); + a->setStatusTip ( tr( "New map","File menu" ) ); + a->setShortcut ( Qt::CTRL + Qt::Key_N ); a->addTo( tb ); - a->addTo( menu ); + fileMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) ); - a = new QAction( tr( "Open","File menu" ), QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) ); + a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this); + a->setStatusTip (tr( "Open","File menu" ) ); + a->setShortcut ( Qt::CTRL + Qt::Key_O ); a->addTo( tb ); - a->addTo( menu ); + fileMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) ); - lastMapsMenu = new QPopupMenu (this); - - menu->insertItem (tr("Open Recent"),lastMapsMenu ); - menu->insertSeparator(); + fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent")); + fileMenu->addSeparator(); - a = new QAction( tr( "Save" ), QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) ); + a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this); + a->setStatusTip ( tr( "Save" )); + a->setShortcut (Qt::CTRL + Qt::Key_S ); a->addTo( tb ); - a->addTo( menu ); + fileMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) ); actionFileSave=a; - a = new QAction( tr( "Save &As" ), QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), 0, this, "fileSaveAs" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) ); - a->addTo( menu ); - - menu->insertSeparator(); - - importMenu = new QPopupMenu (this); - menu->insertItem (tr("Import"),importMenu ); - - a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) ); - a->addTo (importMenu); - - if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) + a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this); + a->setStatusTip (tr( "Save &As" ) ); + fileMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) ); + + fileMenu->addSeparator(); + + fileImportMenu = fileMenu->addMenu (tr("Import")); + + a = new QAction(tr("KDE Bookmarks"), this); + a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" )); + a->addTo (fileImportMenu); + connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) ); + + if (settings.value( "/mainwindow/showTestMenu",false).toBool()) { - a = new QAction( tr( "Import")+" "+tr("Firefox Bookmarks" ), QPixmap(), tr("Firefox Bookmarks"), 0, this, "importFirefoxBookmarks" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) ); - a->addTo (importMenu); + a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this); + a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) ); + a->addTo (fileImportMenu); + connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) ); } - a = new QAction( tr( "Import")+" Mind Manager" , QPixmap(), "Mind Manager...", 0, this, "importMM" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) ); - a->addTo (importMenu); - - a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) ); - a->addTo( importMenu); - - exportMenu = new QPopupMenu (this); - menu->insertItem (tr("Export"),exportMenu ); - - menu->insertSeparator(); - - - a = new QAction( tr( "Print" ), QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" ); - connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) ); + a = new QAction("Mind Manager...",this); + a->setStatusTip ( tr( "Import")+" Mind Manager" ); + fileImportMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) ); + + a = new QAction( tr( "Import Dir"+QString("...") ), this); + a->setStatusTip (tr( "Import directory structure (experimental)" ) ); + fileImportMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) ); + + fileExportMenu = fileMenu->addMenu (tr("Export")); + + a = new QAction( tr("Image")+QString("..."), this); + a->setStatusTip( tr( "Export map as image" )); + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) ); + fileExportMenu->addAction (a); + + a = new QAction( "Open Office"+QString("..."), this); + a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " )); + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) ); + fileExportMenu->addAction (a); + + a = new QAction( "Webpage (XHTML)...",this ); + a->setShortcut (Qt::ALT + Qt::Key_X); + a->setStatusTip ( tr( "Export as")+" webpage (XHTML)"); + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) ); + fileExportMenu->addAction (a); + + a = new QAction( "Text (ASCII)...", this); + a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" )); + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) ); + fileExportMenu->addAction (a); + + a = new QAction( tr("KDE Bookmarks"), this); + a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" )); + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) ); + fileExportMenu->addAction (a); + + a = new QAction( "Taskjuggler...", this ); + a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" )); + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) ); + fileExportMenu->addAction (a); + + a = new QAction( "LaTeX...", this); + a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" )); + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) ); + fileExportMenu->addAction (a); + + a = new QAction( "XML..." , this ); + a->setStatusTip (tr( "Export as")+" XML"); + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) ); + fileExportMenu->addAction (a); + + fileMenu->addSeparator(); + + a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this); + a->setStatusTip ( tr( "Print" ) ); + a->setShortcut (Qt::CTRL + Qt::Key_P ); a->addTo( tb ); - a->addTo( menu ); + fileMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) ); actionFilePrint=a; - a = new QAction( tr( "Close Map" ), QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) ); - a->addTo( menu ); - - a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) ); - a->addTo( menu ); + a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this); + a->setStatusTip (tr( "Close Map" ) ); + a->setShortcut (Qt::ALT + Qt::Key_C ); + fileMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) ); + + a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this); + a->setStatusTip ( tr( "Exit")+" "+__VYM ); + a->setShortcut (Qt::CTRL + Qt::Key_Q ); + fileMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) ); } //Edit Actions void Main::setupEditActions() { - QToolBar *tb = new QToolBar( this ); + QToolBar *tb = addToolBar( tr ("&Actions") ); tb->setLabel( "Edit Actions" ); - QPopupMenu *menu = new QPopupMenu( this ); - menuBar()->insertItem( tr( "&Edit" ), menu ); + tb->setObjectName ("actionsTB"); + QMenu *editMenu = menuBar()->addMenu( tr("&Edit") ); QAction *a; QAction *alt; - a = new QAction( tr( "Undo" ), QPixmap( iconPath+"undo.png"), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" ); - connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) ); + a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this); + connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) ); + a->setStatusTip (tr( "Undo" ) ); + a->setShortcut ( Qt::CTRL + Qt::Key_Z ); a->setEnabled (false); - a->addTo( tb ); - a->addTo( menu ); + tb->addAction (a); + editMenu->addAction (a); actionEditUndo=a; - if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) - { - a = new QAction( tr( "Redo" ), QPixmap( iconPath+"redo.png"), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); - connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) ); - a->addTo( tb ); - a->addTo( menu ); - } + a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this); + a->setStatusTip (tr( "Redo" )); + a->setShortcut (Qt::CTRL + Qt::Key_Y ); + tb->addAction (a); + editMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) ); + actionEditRedo=a; - menu->insertSeparator(); - a = new QAction( tr( "Copy" ), QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" ); - connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); + editMenu->addSeparator(); + a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this); + a->setStatusTip ( tr( "Copy" ) ); + a->setShortcut (Qt::CTRL + Qt::Key_C ); a->setEnabled (false); - a->addTo( tb ); - a->addTo( menu ); + tb->addAction (a); + editMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) ); actionEditCopy=a; - a = new QAction( tr( "Cut" ), QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" ); - connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); + + a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this); + a->setStatusTip ( tr( "Cut" ) ); + a->setShortcut (Qt::CTRL + Qt::Key_X ); a->setEnabled (false); - a->addTo( tb ); - a->addTo( menu ); + tb->addAction (a); + editMenu->addAction (a); actionEditCut=a; - a = new QAction( tr( "Paste" ), QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" ); - connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) ); + + a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this); + connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) ); + a->setStatusTip ( tr( "Paste" ) ); + a->setShortcut ( Qt::CTRL + Qt::Key_V ); a->setEnabled (false); - a->addTo( tb ); - a->addTo( menu ); + tb->addAction (a); + editMenu->addAction (a); actionEditPaste=a; // Shortcuts to modify heading: - a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" ); - connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); + a = new QAction(tr( "Edit heading" ),this); + a->setStatusTip ( tr( "edit Heading" )); + a->setShortcut ( Qt::Key_Enter); +// a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); actionListBranches.append(a); - a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" ); - connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); + a = new QAction( tr( "Edit heading" ), this); + a->setStatusTip (tr( "edit Heading" )); + a->setShortcut (Qt::Key_Return ); + //a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); actionListBranches.append(a); + editMenu->addAction (a); actionEditHeading=a; - a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" ); - connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); - a->setEnabled (false); - actionEditHeading=a; + a = new QAction( tr( "Edit heading" ), this); + a->setStatusTip (tr( "edit Heading" )); + a->setShortcut ( Qt::Key_F2 ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); actionListBranches.append(a); // Shortcut to delete selection - a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) ); - a->setEnabled (false); + a = new QAction( tr( "Delete Selection" ),this); + a->setStatusTip (tr( "Delete Selection" )); + a->setShortcut ( Qt::Key_Delete); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) ); actionEditDelete=a; // Shortcut to add branch - alt = new QAction( tr( "Add a branch as child of selection" ),QPixmap(iconPath+"newbranch.png"),tr( "Add branch as child" ), Key_A, this, "newBranch" ); - connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) ); - a = new QAction( tr( "Add a branch as child of selection" ),QPixmap(iconPath+"newbranch.png"),tr( "Add branch as child" ), Key_Insert, this, "newBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) ); - a->setEnabled (false); + alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this); + alt->setStatusTip ( tr( "Add a branch as child of selection" )); + alt->setShortcut (Qt::Key_A); + alt->setShortcutContext (Qt::WindowShortcut); + addAction (alt); + connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); + a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this); + a->setStatusTip ( tr( "Add a branch as child of selection" )); + a->setShortcut (Qt::Key_Insert); + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); actionListBranches.append(a); #if defined (Q_OS_MACX) - // In OSX show different shortcut in menues, the keys work independtly always + // In OSX show different shortcut in menues, the keys work indepently always actionEditAddBranch=alt; #else actionEditAddBranch=a; #endif - actionEditAddBranch->addTo( menu ); - actionEditAddBranch->addTo( tb ); + editMenu->addAction (actionEditAddBranch); + tb->addAction (actionEditAddBranch); + // Add branch by inserting it at selection - a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" ); - connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) ); + a = new QAction(tr( "Add branch (insert)" ), this); + a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); + a->setShortcut (Qt::ALT + Qt::Key_Insert ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) ); a->setEnabled (false); actionListBranches.append(a); actionEditAddBranchHere=a; - a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" ); - connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) ); + a = new QAction(tr( "Add branch (insert)" ),this); + a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); + a->setShortcut ( Qt::ALT + Qt::Key_A ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) ); actionListBranches.append(a); // Add branch above - a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) ); + a = new QAction(tr( "Add branch above" ), this); + a->setStatusTip ( tr( "Add a branch above selection" )); + a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); a->setEnabled (false); actionListBranches.append(a); actionEditAddBranchAbove=a; - a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) ); + a = new QAction(tr( "Add branch above" ), this); + a->setStatusTip ( tr( "Add a branch above selection" )); + a->setShortcut (Qt::SHIFT+Qt::Key_A ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); actionListBranches.append(a); // Add branch below - a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) ); + a = new QAction(tr( "Add branch below" ), this); + a->setStatusTip ( tr( "Add a branch below selection" )); + a->setShortcut (Qt::CTRL +Qt::Key_Insert ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); a->setEnabled (false); actionListBranches.append(a); actionEditAddBranchBelow=a; - a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) ); + a = new QAction(tr( "Add branch below" ), this); + a->setStatusTip ( tr( "Add a branch below selection" )); + a->setShortcut (Qt::CTRL +Qt::Key_A ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); actionListBranches.append(a); - a = new QAction( tr( "Move branch up" ), QPixmap(iconPath+"up.png" ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" ); - connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) ); + a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this); + a->setStatusTip ( tr( "Move branch up" ) ); + a->setShortcut (Qt::Key_PageUp ); a->setEnabled (false); - a->addTo( tb ); - a->addTo( menu ); + tb->addAction (a); + editMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) ); actionEditMoveUp=a; - a = new QAction( tr( "Move branch down" ), QPixmap( iconPath+"down.png"), tr( "Move down" ), Key_PageDown, this, "editMoveDown" ); - connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) ); + a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this); + connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) ); + a->setStatusTip (tr( "Move branch down" ) ); + a->setShortcut ( Qt::Key_PageDown ); a->setEnabled (false); - a->addTo( tb ); - a->addTo( menu ); + tb->addAction (a); + editMenu->addAction (a); actionEditMoveDown=a; - a = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" ); - connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) ); - alt = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_S, this, "scroll" ); - connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) ); + a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this); + a->setShortcut ( Qt::Key_ScrollLock ); + a->setStatusTip (tr( "Scroll branch" ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); + alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this); + alt->setShortcut ( Qt::Key_S ); + alt->setStatusTip (tr( "Scroll branch" )); + connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); #if defined(Q_OS_MACX) actionEditToggleScroll=alt; #else @@ -531,147 +651,215 @@ #endif actionEditToggleScroll->setEnabled (false); actionEditToggleScroll->setToggleAction(true); - actionEditToggleScroll->addTo( tb ); - actionEditToggleScroll->addTo( menu ); + tb->addAction (actionEditToggleScroll); + editMenu->addAction ( actionEditToggleScroll); + editMenu->addAction (actionEditToggleScroll); actionListBranches.append(actionEditToggleScroll); - a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" ); - connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) ); - a->addTo( menu ); + a = new QAction( tr( "Unscroll all scrolled branches" ), this); + a->setStatusTip (tr( "Unscroll all" )); + editMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) ); - menu->insertSeparator(); - - a = new QAction( tr( "Find" ), QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" ); - connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) ); - a->addTo( menu ); + editMenu->addSeparator(); + + a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this); + a->setStatusTip (tr( "Find" ) ); + a->setShortcut (Qt::CTRL + Qt::Key_F ); + editMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) ); - menu->insertSeparator(); - - a = new QAction( tr( "Open URL" ), QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), CTRL + Key_U, this, "url" ); - connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) ); - a->addTo( tb ); - a->setEnabled (false); + editMenu->addSeparator(); + + a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this); + a->setShortcut (Qt::CTRL + Qt::Key_U ); + a->setShortcut (tr( "Open URL" )); + tb->addAction (a); + addAction(a); + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) ); actionEditOpenURL=a; - a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), CTRL + Key_U, this, "urltab" ); - connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) ); - a->setEnabled (false); + a = new QAction( tr( "Open URL in new tab" ), this); + a->setStatusTip (tr( "Open URL in new tab" )); + a->setShortcut (Qt::CTRL+Qt::Key_U ); + addAction(a); + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) ); actionEditOpenURLTab=a; - a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" ); - connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) ); + a = new QAction( tr( "Open all URLs in subtree" ), this); + a->setStatusTip (tr( "Open all URLs in subtree" )); + addAction(a); + actionListBranches.append(a); + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) ); + actionEditOpenMultipleURLTabs=a; + + a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this); + a->setStatusTip ( tr( "Edit URL" ) ); + a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U ); + //a->setShortcut ( Qt::Key_U ); + a->setShortcutContext (Qt::WindowShortcut); + actionListBranches.append(a); + addAction(a); + connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) ); + actionEditURL=a; + + a = new QAction( tr( "Use heading for URL" ), this); + a->setStatusTip ( tr( "Use heading of selected branch as URL" )); a->setEnabled (false); actionListBranches.append(a); - actionEditURL=a; - - a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" ); - connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) ); + actionEditHeading2URL=a; + + a = new QAction(tr( "Create URL to Bugzilla" ), this); + a->setStatusTip ( tr( "Create URL to Bugzilla" )); a->setEnabled (false); actionListBranches.append(a); - actionEditHeading2URL=a; + connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) ); + actionEditBugzilla2URL=a; - a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" ); - connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) ); + a = new QAction(tr( "Create URL to FATE" ), this); + a->setStatusTip ( tr( "Create URL to FATE" )); a->setEnabled (false); actionListBranches.append(a); - actionEditBugzilla2URL=a; - - a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" ); - connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) ); + actionEditFATE2URL=a; + + a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open xlinked map" ), this); + a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" )); + tb->addAction (a); + a->setEnabled (false); + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) ); + actionEditOpenVymLink=a; + + a = new QAction(QPixmap(), tr( "Open all vym links in subtree" ), this); + a->setStatusTip ( tr( "Open all vym links in subtree" )); a->setEnabled (false); actionListBranches.append(a); - actionEditFATE2URL=a; + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) ); + actionEditOpenMultipleVymLinks=a; - a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), 0, this, "jumpMap" ); - connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) ); - a->addTo( tb ); + + a = new QAction(tr( "Edit vym link"+QString("...") ), this); a->setEnabled (false); - actionEditOpenVymLink=a; - - a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" ); - connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) ); - a->setEnabled (false); + a->setStatusTip ( tr( "Edit link to another vym map" )); + connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) ); actionListBranches.append(a); actionEditVymLink=a; - a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" ); - connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) ); + a = new QAction(tr( "Delete vym link" ),this); + a->setStatusTip ( tr( "Delete link to another vym map" )); a->setEnabled (false); + connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) ); actionEditDeleteVymLink=a; - a = new QAction( tr( "Hide object in exports" ), QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), Key_H, this, "hideExport" ); - connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) ); + a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this); + a->setStatusTip ( tr( "Hide object in exports" ) ); + a->setShortcut (Qt::Key_H ); a->setToggleAction(true); - a->addTo( tb ); + tb->addAction (a); a->setEnabled (false); + connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) ); actionEditToggleHideExport=a; - a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" ); - connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) ); + a = new QAction(tr( "Edit Map Info"+QString("...") ),this); + a->setStatusTip ( tr( "Edit Map Info" )); a->setEnabled (true); + connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) ); actionEditMapInfo=a; - menu->insertSeparator(); + editMenu->addSeparator(); // Import at selection (adding to selection) - a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" ); - connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) ); + a = new QAction( tr( "Add map (insert)" ),this); + a->setStatusTip (tr( "Add map at selection" )); + connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) ); a->setEnabled (false); actionListBranches.append(a); actionEditImportAdd=a; // Import at selection (replacing selection) - a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" ); - connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) ); + a = new QAction( tr( "Add map (replace)" ), this); + a->setStatusTip (tr( "Replace selection with map" )); + connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) ); a->setEnabled (false); actionListBranches.append(a); actionEditImportReplace=a; // Save selection - a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" ); - connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) ); + a = new QAction( tr( "Save selection" ), this); + a->setStatusTip (tr( "Save selection" )); + connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) ); a->setEnabled (false); actionListBranches.append(a); actionEditSaveBranch=a; // Only remove branch, not its childs - a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" ); - connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) ); + a = new QAction(tr( "Remove only branch " ), this); + a->setStatusTip ( tr( "Remove only branch and keep its childs" )); + a->setShortcut (Qt::ALT + Qt::Key_Delete ); + connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) ); a->setEnabled (false); actionListBranches.append(a); actionEditRemoveBranchKeepChilds=a; // Only remove childs of a branch - a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" ); - connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) ); + a = new QAction( tr( "Remove childs" ), this); + a->setStatusTip (tr( "Remove childs of branch" )); + a->setShortcut (Qt::SHIFT + Qt::Key_Delete ); + connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) ); a->setEnabled (false); actionListBranches.append(a); actionEditRemoveChilds=a; // Shortcuts for navigating with cursor: - a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) ); - a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) ); - a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) ); - a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) ); - a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" ); + a = new QAction(tr( "Select upper branch" ), this); + a->setStatusTip ( tr( "Select upper branch" )); + a->setShortcut (Qt::Key_Up ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) ); + a = new QAction( tr( "Select lower branch" ),this); + a->setStatusTip (tr( "Select lower branch" )); + a->setShortcut ( Qt::Key_Down ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) ); + a = new QAction(tr( "Select left branch" ), this); + a->setStatusTip ( tr( "Select left branch" )); + a->setShortcut (Qt::Key_Left ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) ); + a = new QAction( tr( "Select child branch" ), this); + a->setStatusTip (tr( "Select right branch" )); + a->setShortcut (Qt::Key_Right); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) ); + a = new QAction( tr( "Select first branch" ), this); + a->setStatusTip (tr( "Select first branch" )); + a->setShortcut (Qt::Key_Home ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); a->setEnabled (false); - a->addTo ( menu ); + editMenu->addAction (a); actionListBranches.append(a); actionEditSelectFirst=a; - connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) ); - a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) ); + a = new QAction( tr( "Select last branch" ),this); + a->setStatusTip (tr( "Select last branch" )); + a->setShortcut ( Qt::Key_End ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) ); a->setEnabled (false); - a->addTo ( menu ); + editMenu->addAction (a); actionListBranches.append(a); actionEditSelectLast=a; - a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" ); - connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) ); + a = new QAction( tr( "Add Image" )+QString("..."), this); + a->setStatusTip (tr( "Add Image" )); + connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) ); actionEditLoadImage=a; } @@ -679,147 +867,194 @@ // Format Actions void Main::setupFormatActions() { - QPopupMenu *menu = new QPopupMenu( this ); - menuBar()->insertItem( tr( "F&ormat" ), menu ); - - QToolBar *tb = new QToolBar( this ); + QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat")); + + QToolBar *tb = addToolBar( tr("Format Actions","Toolbars")); + tb->setObjectName ("formatTB"); QAction *a; QPixmap pix( 16,16); - pix.fill (black); - actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" ); - connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) ); - actionFormatColor->addTo( tb ); - actionFormatColor->addTo( menu ); - a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" ); - connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) ); + pix.fill (Qt::black); + a= new QAction(pix, tr( "Set &Color" )+QString("..."), this); + a->setStatusTip ( tr( "Set Color" )); + connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) ); + a->addTo( tb ); + formatMenu->addAction (a); + actionFormatColor=a; + a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this); + a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) ); + a->setShortcut (Qt::CTRL + Qt::Key_K ); + connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) ); a->setEnabled (false); a->addTo( tb ); - a->addTo( menu ); + formatMenu->addAction (a); actionListBranches.append(a); actionFormatPickColor=a; - a= new QAction( tr( "Color branch" ), QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" ); - connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) ); + + a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this); + a->setStatusTip ( tr( "Color branch" ) ); + a->setShortcut (Qt::CTRL + Qt::Key_I); + connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) ); a->setEnabled (false); a->addTo( tb ); - a->addTo( menu ); + formatMenu->addAction (a); actionListBranches.append(a); actionFormatColorBranch=a; - a= new QAction( tr( "Color Subtree" ), QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" ); - connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) ); + + a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this); + a->setStatusTip ( tr( "Color Subtree" )); + a->setShortcut (Qt::CTRL + Qt::Key_T); + connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) ); a->setEnabled (false); - a->addTo( menu ); + formatMenu->addAction (a); a->addTo( tb ); actionListBranches.append(a); actionFormatColorSubtree=a; - menu->insertSeparator(); - actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles"); + formatMenu->addSeparator(); + actionGroupFormatLinkStyles=new QActionGroup ( this); actionGroupFormatLinkStyles->setExclusive (true); - a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" ); + a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles); + a->setStatusTip (tr( "Line" )); a->setToggleAction(true); - connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) ); + formatMenu->addAction (a); actionFormatLinkStyleLine=a; - a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" ); + a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles); + a->setStatusTip (tr( "Line" )); a->setToggleAction(true); - connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) ); + formatMenu->addAction (a); actionFormatLinkStyleParabel=a; - a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" ); + a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles ); + a->setStatusTip (tr( "PolyLine" )); a->setToggleAction(true); - connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) ); + formatMenu->addAction (a); actionFormatLinkStylePolyLine=a; - a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" ); + a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles); + a->setStatusTip (tr( "PolyParabel" ) ); a->setToggleAction(true); - connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) ); + a->setChecked (true); + connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) ); + formatMenu->addAction (a); actionFormatLinkStylePolyParabel=a; - actionGroupFormatLinkStyles->addTo (menu); - actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes"); + actionGroupFormatFrameTypes=new QActionGroup ( this); actionGroupFormatFrameTypes->setExclusive (true); - a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" ); + a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes ); + a->setStatusTip (tr("No Frame")); a->setToggleAction(true); - connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) ); actionFormatFrameNone=a; - a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" ); + a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes); + a->setStatusTip (tr( "Rectangle" )); a->setToggleAction(true); - connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) ); actionFormatFrameRectangle=a; - a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" ); + a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer); + a->setStatusTip ( tr ("Include top and bottom position of images into branch")); a->setToggleAction(true); - connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) ); actionFormatIncludeImagesVer=a; - a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" ); + a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor ); + a->setStatusTip ( tr ("Include left and right position of images into branch")); a->setToggleAction(true); - connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) ); actionFormatIncludeImagesHor=a; - a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" ); + a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected); + a->setStatusTip (tr( "Hide link" )); a->setToggleAction(true); - connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) ); actionFormatHideLinkUnselected=a; - menu->insertSeparator(); - a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" ); + formatMenu->addSeparator(); + a= new QAction( tr( "&Use color of heading for link" ), this); + a->setStatusTip (tr( "Use same color for links and headings" )); a->setToggleAction(true); - connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) ); - a->addTo( menu ); + connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) ); + formatMenu->addAction (a); actionFormatLinkColorHint=a; - pix.fill (white); - actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" ); - connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) ); - actionFormatLinkColor->addTo( menu ); - actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" ); - connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) ); - actionFormatBackColor->addTo( menu ); + + pix.fill (Qt::white); + a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this ); + a->setStatusTip (tr( "Set Link Color" )); + formatMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) ); + actionFormatLinkColor=a; + + a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this ); + a->setStatusTip (tr( "Set Background Color" )); + formatMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) ); + actionFormatBackColor=a; } // View Actions void Main::setupViewActions() { - QToolBar *tb = new QToolBar( this ); + QToolBar *tb = addToolBar( tr("View Actions","Toolbars") ); tb->setLabel( "View Actions" ); - QPopupMenu *menu = new QPopupMenu( this ); - menuBar()->insertItem( tr( "&View" ), menu ); + tb->setObjectName ("viewTB"); + QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" )); QAction *a; - a = new QAction( tr( "Zoom reset" ), QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" ); - connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) ); + a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this); + a->setStatusTip ( tr( "Zoom reset" ) ); + a->setShortcut (Qt::CTRL + Qt::Key_0 ); a->addTo( tb ); - a->addTo( menu ); - a = new QAction( tr( "Zoom in" ), QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" ); - connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) ); + viewMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) ); + + a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this); + a->setStatusTip (tr( "Zoom in" )); + a->setShortcut (Qt::CTRL + Qt::Key_Plus); a->addTo( tb ); - a->addTo( menu ); - a = new QAction( tr( "Zoom out" ), QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" ); - connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) ); + viewMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) ); + + a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this); + a->setStatusTip (tr( "Zoom out" )); + a->setShortcut (Qt::CTRL + Qt::Key_Minus ); a->addTo( tb ); - a->addTo( menu ); - - - a = new QAction( tr( "Show Note Editor" ), QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ), CTRL + Key_E , this, "noteEditor" ); - connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) ); + viewMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) ); + + + a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this); + a->setStatusTip ( tr( "Show Note Editor" )); + a->setShortcut ( Qt::CTRL + Qt::Key_E ); a->setToggleAction(true); if (textEditor->showWithMain()) a->setOn(true); else a->setOn(false); a->addTo( tb ); - a->addTo( menu ); + viewMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) ); actionViewToggleNoteEditor=a; - a = new QAction( tr( "Show history window" ), QPixmap(), tr( "Show history window" ), CTRL + Key_H , this, "historyWindow" ); - connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) ); + a = new QAction( tr( "Show history window" ),this ); + a->setStatusTip ( tr( "Show history window" )); + a->setShortcut ( Qt::CTRL + Qt::Key_H ); a->setToggleAction(false); - a->addTo( menu ); + viewMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) ); actionViewToggleHistoryWindow=a; - a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" ); - connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) ); - a->addTo( menu ); - a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" ); - connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) ); - a->addTo( menu ); + a = new QAction(tr( "Next Window" ), this); + a->setStatusTip ( tr( "&Next Window" ) ); + a->setShortcut (Qt::ALT + Qt::Key_N ); + viewMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) ); + + a = new QAction (tr( "Previous Window" ), this ); + a->setStatusTip (tr( "&Previous Window" )); + a->setShortcut (Qt::ALT + Qt::Key_P ); + viewMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) ); } // Mode Actions @@ -828,23 +1063,29 @@ //QPopupMenu *menu = new QPopupMenu( this ); //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu ); - QToolBar *tb = new QToolBar( this ); - tb->setLabel( tr ("Modes when using modifiers") ); + QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") ); + tb->setObjectName ("modesTB"); QAction *a; - actionGroupModModes=new QActionGroup ( this, "formatLinkStyles"); + actionGroupModModes=new QActionGroup ( this); actionGroupModModes->setExclusive (true); - a= new QAction( tr( "Use modifier to color branches" ), QPixmap(iconPath+"modecolor.png"), 0, Key_J, actionGroupModModes, "modModeColor" ); + a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes); + a->setShortcut (Qt::Key_J); + a->setStatusTip ( tr( "Use modifier to color branches" )); a->setToggleAction(true); a->addTo (tb); a->setOn(true); actionModModeColor=a; - a= new QAction( tr( "Use modifier to copy" ), QPixmap(iconPath+"modecopy.png"), 0, Key_K, actionGroupModModes, "modModeCopy" ); + a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes ); + a->setShortcut( Qt::Key_K); + a->setStatusTip( tr( "Use modifier to copy" )); a->setToggleAction(true); a->addTo (tb); actionModModeCopy=a; - a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(iconPath+"modelink.png"), 0, Key_L, actionGroupModModes, "modModeLink" ); + a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes ); + a->setShortcut (Qt::Key_L); + a->setStatusTip( tr( "Use modifier to draw xLinks" )); a->setToggleAction(true); a->addTo (tb); actionModModeLink=a; @@ -890,239 +1131,379 @@ systemFlagsDefault->addFlag (fo); // Create Standard Flags + QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar")); + tb->setObjectName ("standardFlagTB"); + standardFlagsDefault = new FlagRowObj (); standardFlagsDefault->setVisibility (false); standardFlagsDefault->setName ("standardFlagsDef"); + standardFlagsDefault->setToolBar (tb); fo->load(QPixmap(flagsPath+"flag-exclamationmark.png")); fo->setName ("exclamationmark"); fo->setGroup("standard-mark"); - fo->setToolTip(tr("Take care!","Standardflag")); + QAction *a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Take care!","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); // makes deep copy fo->load(QPixmap(flagsPath+"flag-questionmark.png")); fo->setName("questionmark"); fo->setGroup("standard-mark"); - fo->setToolTip(tr("Really?","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Really?","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-hook-green.png")); fo->setName("hook-green"); fo->setGroup("standard-hook"); - fo->setToolTip(tr("ok!","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("ok!","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-cross-red.png")); fo->setName("cross-red"); fo->setGroup("standard-hook"); - fo->setToolTip(tr("Not ok!","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Not ok!","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-stopsign.png")); fo->setName("stopsign"); - fo->setToolTip(tr("This won't work!","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("This won't work!","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-smiley-good.png")); fo->setName("smiley-good"); fo->setGroup("standard-smiley"); - fo->setToolTip(tr("Good","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Good","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-smiley-sad.png")); fo->setName("smiley-sad"); fo->setGroup("standard-smiley"); - fo->setToolTip(tr("Bad","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Bad","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-smiley-omg.png")); // Original omg.png (in KDE emoticons) fo->setName("smiley-omg"); fo->setGroup("standard-smiley"); - fo->setToolTip(tr("Oh no!","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Oh no!","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-kalarm.png")); fo->setName("clock"); - fo->setToolTip(tr("Time critical","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Time critical","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-phone.png")); fo->setName("phone"); - fo->setToolTip(tr("Call...","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Call...","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-lamp.png")); fo->setName("lamp"); - fo->setToolTip(tr("Idea!","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Idea!","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-arrow-up.png")); fo->setName("arrow-up"); fo->setGroup("standard-arrow"); - fo->setToolTip(tr("Important","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Important","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-arrow-down.png")); fo->setName("arrow-down"); fo->setGroup("standard-arrow"); - fo->setToolTip(tr("Unimportant","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Unimportant","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-arrow-2up.png")); fo->setName("2arrow-up"); fo->setGroup("standard-arrow"); - fo->setToolTip(tr("Very important!","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Very important!","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-arrow-2down.png")); fo->setName("2arrow-down"); fo->setGroup("standard-arrow"); - fo->setToolTip(tr("Very unimportant!","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Very unimportant!","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-thumb-up.png")); fo->setName("thumb-up"); fo->setGroup("standard-thumb"); - fo->setToolTip(tr("I like this","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("I like this","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-thumb-down.png")); fo->setName("thumb-down"); fo->setGroup("standard-thumb"); - fo->setToolTip(tr("I like this","Standardflag")); - fo->setToolTip(tr("I do not like this","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("I do not like this","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-rose.png")); fo->setName("rose"); - fo->setToolTip(tr("Rose","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Rose","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-heart.png")); fo->setName("heart"); - fo->setToolTip(tr("I just love... ","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("I just love... ","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-present.png")); fo->setName("present"); - fo->setToolTip(tr("Surprise!","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Surprise!","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-flash.png")); fo->setName("flash"); - fo->setToolTip(tr("Dangerous","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Dangerous","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-info.png")); // Original: xsldbg_output.png fo->setName("info"); - fo->setToolTip(tr("Info","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("Info","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); fo->load(QPixmap(flagsPath+"flag-lifebelt.png")); // Original khelpcenter.png fo->setName("lifebelt"); - fo->setToolTip(tr("This will help","Standardflag")); + a=new QAction (fo->getPixmap(),fo->getName(),this); + tb->addAction (a); + fo->setAction (a); + a->setCheckable(true); + a->setObjectName(fo->getName()); + a->setToolTip(tr("This will help","Standardflag")); + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); delete (fo); - - standardFlagsDefault->makeToolbar(this, "Standard Flags"); } // Settings Actions void Main::setupSettingsActions() { - QPopupMenu *menu = new QPopupMenu( this ); - menuBar()->insertItem( tr( "&Settings" ), menu ); + QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" )); QAction *a; - - a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" ); - connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) ); - a->addTo( menu ); - - a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" ); - connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) ); - a->addTo( menu ); - - menu->insertSeparator(); - a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" ); + a = new QAction( tr( "Set application to open pdf files"), this); + a->setStatusTip ( tr( "Set application to open pdf files")); + connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) ); + settingsMenu->addAction (a); + + a = new QAction( tr( "Set application to open external links"), this); + a->setStatusTip( tr( "Set application to open external links")); + connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) ); + settingsMenu->addAction (a); + + settingsMenu->addSeparator(); + a = new QAction( tr( "Edit branch after adding it" ), this ); + a->setStatusTip( tr( "Edit branch after adding it" )); a->setToggleAction(true); - a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) ); - a->addTo( menu ); + a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool()); + settingsMenu->addAction (a); actionSettingsAutoedit=a; - a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" ); + a= new QAction( tr( "Select branch after adding it" ), this ); + a->setStatusTip( tr( "Select branch after adding it" )); a->setToggleAction(true); - a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) ); - a->addTo( menu ); + a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() ); + settingsMenu->addAction (a); actionSettingsAutoselectHeading=a; - a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" ); + a= new QAction(tr( "Select existing heading" ), this); + a->setStatusTip( tr( "Select heading before editing" )); a->setToggleAction(true); - a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) ); - a->addTo( menu ); + a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() ); + settingsMenu->addAction (a); actionSettingsAutoselectText=a; - a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" ); + a= new QAction( tr( "Delete key" ), this); + a->setStatusTip( tr( "Delete key for deleting branches" )); a->setToggleAction(true); - a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) ); - a->addTo( menu ); - actionSettingsPasteNewHeading=a; - - a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" ); + a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() ); + settingsMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) ); + actionSettingsUseDelKey=a; + + a= new QAction( tr( "Exclusive flags" ), this); + a->setStatusTip( tr( "Use exclusive flags in flag toolbars" )); a->setToggleAction(true); - a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) ); - a->addTo( menu ); - connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) ); - actionSettingsUseDelKey=a; - - a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" ); - a->setToggleAction(true); - a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) ); - a->addTo( menu ); + a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() ); + settingsMenu->addAction (a); actionSettingsUseFlagGroups=a; - a= new QAction( tr( "Use hide flag during exports " ), QPixmap(), tr( "Use hide flags" ), 0, this, "hideexport" ); + a= new QAction( tr( "Use hide flags" ), this); + a->setStatusTip( tr( "Use hide flag during exports " )); a->setToggleAction(true); - a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) ); - a->addTo( menu ); + a->setOn ( settings.value ("/export/useHideExport",true).toBool() ); + settingsMenu->addAction (a); actionSettingsUseHideExport=a; } // Test Actions void Main::setupTestActions() { - QPopupMenu *menu = new QPopupMenu( this ); - menuBar()->insertItem( tr( "&Test" ), menu ); + QMenu *testMenu = menuBar()->addMenu( tr( "&Test" )); QAction *a; - a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" ); - connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) ); - a->addTo( menu ); + a = new QAction( tr( "test flag" ), this); + a->setStatusTip( tr( "Call test function" )); + connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) ); + testMenu->addAction (a); } // Help Actions void Main::setupHelpActions() { - QPopupMenu *menu = new QPopupMenu( this ); - menuBar()->insertItem( tr( "&Help" ), menu ); + QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" )); QAction *a; - a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" ); - connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) ); - a->addTo( menu ); - - a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" ); - connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) ); - a->addTo( menu ); - - a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" ); - connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) ); - a->addTo( menu ); + a = new QAction( tr( "Open VYM Documentation (pdf) " ), this ); + a->setStatusTip( tr( "Open VYM Documentation (pdf)" )); + connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) ); + helpMenu->addAction (a); + + a = new QAction( tr( "About VYM" ), this); + a->setStatusTip( tr( "About VYM")+" "__VYM); + connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) ); + helpMenu->addAction (a); + + a = new QAction( tr( "About QT" ), this); + a->setStatusTip( tr( "Information about QT toolkit" )); + connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) ); + helpMenu->addAction (a); } // Context Menus @@ -1131,130 +1512,87 @@ QAction*a; // Context Menu for branch or mapcenter - branchContextMenu =new QPopupMenu (this); + branchContextMenu =new QMenu (this); // Submenu "Add" - branchAddContextMenu =new QPopupMenu (this); - actionEditPaste->addTo ( branchAddContextMenu ); - actionEditAddBranch->addTo ( branchAddContextMenu ); - actionEditAddBranchHere->addTo ( branchAddContextMenu ); - actionEditAddBranchAbove->addTo ( branchAddContextMenu ); - actionEditAddBranchBelow->addTo ( branchAddContextMenu ); - branchAddContextMenu->insertSeparator(); - actionEditLoadImage->addTo( branchAddContextMenu ); - branchAddContextMenu->insertSeparator(); - actionEditImportAdd->addTo ( branchAddContextMenu ); - actionEditImportReplace->addTo ( branchAddContextMenu ); + branchAddContextMenu =branchContextMenu->addMenu (tr("Add")); + branchAddContextMenu->addAction (actionEditPaste ); + branchAddContextMenu->addAction ( actionEditAddBranch ); + branchAddContextMenu->addAction ( actionEditAddBranchHere ); + branchAddContextMenu->addAction ( actionEditAddBranchAbove); + branchAddContextMenu->addAction ( actionEditAddBranchBelow ); + branchAddContextMenu->addSeparator(); + branchAddContextMenu->addAction ( actionEditLoadImage); + branchAddContextMenu->addSeparator(); + branchAddContextMenu->addAction ( actionEditImportAdd ); + branchAddContextMenu->addAction ( actionEditImportReplace ); // Submenu "Remove" - branchRemoveContextMenu =new QPopupMenu (this); - actionEditCut->addTo ( branchRemoveContextMenu ); - actionEditDelete->addTo ( branchRemoveContextMenu ); - actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu ); - actionEditRemoveChilds->addTo( branchRemoveContextMenu ); + branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove")); + branchRemoveContextMenu->addAction (actionEditCut); + branchRemoveContextMenu->addAction ( actionEditDelete ); + branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds ); + branchRemoveContextMenu->addAction ( actionEditRemoveChilds ); - branchContextMenu->insertItem (tr("Add"),branchAddContextMenu); - branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu); actionEditSaveBranch->addTo( branchContextMenu ); - branchContextMenu->insertSeparator(); - actionEditOpenURL->addTo ( branchContextMenu ); - actionEditOpenURLTab->addTo ( branchContextMenu ); - actionEditURL->addTo ( branchContextMenu ); - actionEditHeading2URL->addTo ( branchContextMenu ); - actionEditBugzilla2URL->addTo( branchContextMenu ); - if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) - { - actionEditFATE2URL->addTo( branchContextMenu ); - } - branchContextMenu->insertSeparator(); - actionEditOpenVymLink->addTo ( branchContextMenu ); - actionEditVymLink->addTo ( branchContextMenu ); - actionEditDeleteVymLink->addTo ( branchContextMenu ); - - branchContextMenu->insertSeparator(); - actionGroupFormatFrameTypes->addTo( branchContextMenu ); - - branchContextMenu->insertSeparator(); - actionFormatIncludeImagesVer->addTo( branchContextMenu ); - actionFormatIncludeImagesHor->addTo( branchContextMenu ); - actionFormatHideLinkUnselected->addTo( branchContextMenu ); - - // Context Menu for links in a branch menu + branchContextMenu->addSeparator(); + branchContextMenu->addAction ( actionFormatFrameNone ); + branchContextMenu->addAction ( actionFormatFrameRectangle); + + branchContextMenu->addSeparator(); + branchContextMenu->addAction ( actionFormatIncludeImagesVer ); + branchContextMenu->addAction ( actionFormatIncludeImagesHor ); + branchContextMenu->addAction ( actionFormatHideLinkUnselected ); + + // Submenu for Links (URLs, vymLinks) + branchLinksContextMenu =new QMenu (this); + + branchContextMenu->addSeparator(); + branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks")); + branchLinksContextMenu->addAction ( actionEditOpenURL ); + branchLinksContextMenu->addAction ( actionEditOpenURLTab ); + branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs ); + branchLinksContextMenu->addAction ( actionEditURL ); + branchLinksContextMenu->addAction ( actionEditHeading2URL ); + branchLinksContextMenu->addAction ( actionEditBugzilla2URL ); + if (settings.value( "/mainwindow/showTestMenu",true).toBool() ) + { + branchLinksContextMenu->addAction ( actionEditFATE2URL ); + } + branchLinksContextMenu->addSeparator(); + branchLinksContextMenu->addAction ( actionEditOpenVymLink ); + branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks ); + branchLinksContextMenu->addAction ( actionEditVymLink ); + branchLinksContextMenu->addAction ( actionEditDeleteVymLink ); + + + // Context Menu for XLinks in a branch menu // This will be populated "on demand" in MapEditor::updateActions - branchContextMenu->insertSeparator(); - branchLinksContextMenu =new QPopupMenu (this); - branchLinksContextMenuDup =new QPopupMenu (this); - branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup); - connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) ); - - branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu); - connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) ); + branchContextMenu->addSeparator(); + branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink")); + branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink")); + connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) ); + connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) ); + // Context menu for floatimage - floatimageContextMenu =new QPopupMenu (this); - saveImageFormatMenu=new QPopupMenu (this); - exportImageFormatMenu=new QPopupMenu (this); - - QStrList fmt = QImage::outputFormats(); - for (const char* f = fmt.first(); f; f = fmt.next()) - { - saveImageFormatMenu->insertItem( f ); - exportImageFormatMenu->insertItem( f ); - } - connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) ); - connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) ); - floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu ); - - floatimageContextMenu->insertSeparator(); + floatimageContextMenu =new QMenu (this); + a= new QAction (tr ("Save image"),this); + connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage())); + floatimageContextMenu->addAction (a); + + floatimageContextMenu->addSeparator(); actionEditCopy->addTo( floatimageContextMenu ); actionEditCut->addTo( floatimageContextMenu ); -/* FIXME not needed any longer - floatimageContextMenu->insertSeparator(); - a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" ); - a->setToggleAction(true); - connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) ); - a->addTo( floatimageContextMenu); - actionEditToggleFloatExport=a; - */ - - floatimageContextMenu->insertSeparator(); - actionFormatHideLinkUnselected->addTo( floatimageContextMenu ); - - exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu); - - a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) ); - a->addTo (exportMenu); - - a = new QAction( tr( "Export as")+" webpage (XHTML)" , QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) ); - a->addTo( exportMenu ); - - a = new QAction( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) ); - a->addTo( exportMenu ); - - a = new QAction( tr( "Export as")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) ); - a->addTo (exportMenu); - - a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) ); - a->addTo( exportMenu ); - - a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) ); - a->addTo( exportMenu ); - - a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...", 0, this, "exportXML" ); - connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) ); - a->addTo( exportMenu ); + floatimageContextMenu->addSeparator(); + floatimageContextMenu->addAction ( actionFormatHideLinkUnselected ); + // Context menu for canvas - canvasContextMenu =new QPopupMenu (this); + canvasContextMenu =new QMenu (this); actionEditMapInfo->addTo( canvasContextMenu ); canvasContextMenu->insertSeparator(); actionGroupFormatLinkStyles->addTo( canvasContextMenu ); @@ -1266,15 +1604,15 @@ // Menu for last opened files // Read settings initially QString s; - int j=settings.readNumEntry( "/vym/lastMaps/number",0); + int j=settings.readNumEntry( "/lastMaps/number",0); for (int i=1;i<=j;i++) { - s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),""); + s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString(); if (!s.isEmpty() && j<=maxLastMaps) lastMaps.append(s); } setupLastMapsMenu(); - connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) ); + connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) ); } void Main::setupLastMapsMenu() @@ -1300,10 +1638,9 @@ while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back(); // build Menu from lastMaps string list - lastMapsMenu->clear(); + fileLastMapsMenu->clear(); for (it = lastMaps.begin(); it != lastMaps.end(); ++it ) - lastMapsMenu->insertItem (*it ); - + fileLastMapsMenu->addAction (*it ); } void Main::hideEvent (QHideEvent * ) @@ -1347,8 +1684,8 @@ QString Main::browseDirectory (const QString &caption) { - QFileDialog fd(this,caption); - fd.setMode (QFileDialog::DirectoryOnly); + Q3FileDialog fd(this,caption); + fd.setMode (Q3FileDialog::DirectoryOnly); fd.setCaption(__VYM " - "+caption); fd.show(); @@ -1370,7 +1707,7 @@ void Main::newView() { // Open a new view... have it delete when closed. - Main *m = new Main(0, 0, WDestructiveClose); + Main *m = new Main(0, 0, Qt::WDestructiveClose); qApp->setMainWidget(m); m->show(); qApp->setMainWidget(0); @@ -1397,12 +1734,12 @@ void Main::fileNew() { QString fn="unnamed"; - MapEditor* medit = new MapEditor (tabWidget, true); + MapEditor* medit = new MapEditor ( NULL,true); tabWidget->addTab (medit,fn); tabWidget->showPage(medit); medit->viewport()->setFocus(); - // For the very first map we do not have flagrows yet... - medit->select("mc:"); + // For the very first map we do not have flagrows yet... + medit->select("mc:"); } ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode) @@ -1435,7 +1772,7 @@ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::Cancel | QMessageBox::Escape, - QMessageBox::QMessageBox::NoButton); + QMessageBox::NoButton); mb.setButtonText( QMessageBox::Yes, tr("Open anyway") ); mb.setButtonText( QMessageBox::Cancel, tr("Cancel")); switch( mb.exec() ) @@ -1465,7 +1802,7 @@ // create a new mapeditor in a new tab if ( lmode==NewMap && (!me || !me->isDefault() ) ) { - me = new MapEditor (tabWidget,true); + me= new MapEditor ( NULL,true); tabWidget->addTab (me,fn); tabIndex=tabWidget->indexOf (me); tabWidget->setCurrentPage (tabIndex); @@ -1480,7 +1817,7 @@ QMessageBox::Question, QMessageBox::Yes , QMessageBox::Cancel | QMessageBox::Default, - QMessageBox::QMessageBox::NoButton ); + QMessageBox::NoButton ); mb.setButtonText( QMessageBox::Yes, tr("Create")); mb.setButtonText( QMessageBox::No, tr("Cancel")); @@ -1603,10 +1940,9 @@ void Main::fileLoad(const LoadMode &lmode) { - QFileDialog *fd=new QFileDialog( this); - if (!lastFileDir.isEmpty()) - fd->setDir (lastFileDir); - fd->setMode (QFileDialog::ExistingFiles); + Q3FileDialog *fd=new Q3FileDialog( this); + fd->setDir (lastFileDir); + fd->setMode (Q3FileDialog::ExistingFiles); fd->addFilter ("XML (*.xml)"); fd->addFilter ("VYM map (*.vym *.vyp)"); switch (lmode) @@ -1644,9 +1980,9 @@ fileLoad (NewMap); } -void Main::fileLoadLast(int i) +void Main::fileLoadLast(QAction *a) { - fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap); + fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap); } void Main::fileSave(const SaveMode &savemode) @@ -1770,9 +2106,9 @@ if (currentMapEditor()) { if (savemode==CompleteMap) - fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this ); + fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this ); else - fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this ); + fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this ); if ( !fn.isEmpty() ) { // Check for existing file @@ -1783,7 +2119,7 @@ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::Cancel | QMessageBox::Escape, - QMessageBox::QMessageBox::NoButton); + QMessageBox::NoButton); mb.setButtonText( QMessageBox::Yes, tr("Overwrite") ); mb.setButtonText( QMessageBox::Cancel, tr("Cancel")); switch( mb.exec() ) @@ -1842,9 +2178,9 @@ void Main::fileImportFirefoxBookmarks() { - QFileDialog *fd=new QFileDialog( this); + Q3FileDialog *fd=new Q3FileDialog( this); fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox"); - fd->setMode (QFileDialog::ExistingFiles); + fd->setMode (Q3FileDialog::ExistingFiles); fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)"); fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks")); fd->show(); @@ -1871,10 +2207,9 @@ { ImportMM im; - QFileDialog *fd=new QFileDialog( this); - if (!lastFileDir.isEmpty()) - fd->setDir (lastFileDir); - fd->setMode (QFileDialog::ExistingFiles); + Q3FileDialog *fd=new Q3FileDialog( this); + fd->setDir (lastFileDir); + fd->setMode (Q3FileDialog::ExistingFiles); fd->addFilter ("Mind Manager (*.mmap)"); fd->setCaption(tr("Import")+" "+"Mind Manager"); fd->show(); @@ -1949,18 +2284,23 @@ } } -void Main::fileExportImage(int item) +void Main::fileExportImage() { MapEditor *me=currentMapEditor(); if (me) { - QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)", - this ); - if ( !fn.isEmpty() ) - me->exportImage(fn,item); - else - statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime ); - + QStringList fl; + QFileDialog *fd=new QFileDialog (this); + fd->setCaption (tr("Export map as image")); + fd->setFileMode(QFileDialog::AnyFile); + fd->setFilters (imageIO.getFilters() ); + fd->setDirectory (lastImageDir); + if (fd->exec()) + { + fl=fd->selectedFiles(); + qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter()); + me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) ); + } } } @@ -2032,13 +2372,13 @@ void Main::fileExportOOPresentation() { ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office"); - // FIXME add extra info in dialog + // TODO add preview in dialog //ImagePreview *p =new ImagePreview (fd); //fd->setContentsPreviewEnabled( TRUE ); //fd->setContentsPreview( p, p ); //fd->setPreviewMode( QFileDialog::Contents ); fd->setCaption(__VYM " - " +tr("Export to")+" Open Office"); - //fd->setDir (lastImageDir); + fd->setDir (QDir().current()); if (fd->foundConfig()) { fd->show(); @@ -2046,6 +2386,9 @@ if ( fd->exec() == QDialog::Accepted ) { QString fn=fd->selectedFile(); + if (!fn.contains (".odp")) + fn +=".odp"; + //lastImageDir=fn.left(fn.findRev ("/")); if (currentMapEditor()) currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig()); @@ -2053,8 +2396,8 @@ } else { QMessageBox::warning(0, - tr("Warning"), - tr("Couldn't find configuration for export to Open Office\n")); + tr("Warning"), + tr("Couldn't find configuration for export to Open Office\n")); } } @@ -2121,13 +2464,8 @@ QMessageBox::Cancel | QMessageBox::Escape ); mb.setButtonText( QMessageBox::Yes, tr("Save map") ); mb.setButtonText( QMessageBox::No, tr("Discard changes") ); + mb.setModal (true); mb.show(); - // Call undocumented function: setActiveWindow is only - // possible, if widget is visible. This depends on - // windowmanager... -#if defined(Q_OS_LINUX) - qt_wait_for_window_manager( this); -#endif mb.setActiveWindow(); switch( mb.exec() ) { case QMessageBox::Yes: @@ -2180,13 +2518,6 @@ { findWindow->popup(); findWindow->raise(); - - // Call undocumented function: setActiveWindow is only - // possible, if widget is visible. This depends on - // windowmanager... -#if defined(Q_OS_LINUX) - qt_wait_for_window_manager( this); -#endif findWindow->setActiveWindow(); } @@ -2209,20 +2540,86 @@ currentMapEditor()->findReset(); } +void Main::openTabs(QStringList urls) +{ + if (!urls.isEmpty()) + { + bool success=true; + QStringList args; + QString browser=settings.value("/mainwindow/readerURL" ).toString(); + QProcess *p; + if (!procBrowser || procBrowser->state()!=QProcess::Running) + { + QString u=urls.takeFirst(); + procBrowser = new QProcess( this ); + args<start(browser,args); + if ( !procBrowser->waitForStarted()) + { + // try to set path to browser + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't find a viewer to open %1.\n").arg(u)+ + tr("Please use Settings->")+tr("Set application to open an URL")); + return; + } + sleep (3); + } + if (browser.contains("konqueror")) + { + for (int i=0; ipid())<< + "konqueror-mainwindow#1"<< + "newTab" << + urls.at(i); + p->start ("dcop",args); + if ( !p->waitForStarted() ) success=false; + } + if (!success) + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); + return; + } else if (browser.contains ("firefox") || browser.contains ("mozilla") ) + { + for (int i=0; istart (browser,args); + if ( !p->waitForStarted() ) success=false; + } + if (!success) + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't start %1 to open a new tab").arg(browser)); + return; + } + QMessageBox::warning(0, + tr("Warning"), + tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing.")); + } +} + void Main::editOpenURL() { // Open new browser if (currentMapEditor()) { QString url=currentMapEditor()->getURL(); + QStringList args; if (url=="") return; - QString browser=settings.readEntry("/vym/mainwindow/readerURL" ); + QString browser=settings.value("/mainwindow/readerURL" ).toString(); procBrowser = new QProcess( this ); - - procBrowser->addArgument( browser); - procBrowser->addArgument( url); - - if ( !procBrowser->start() ) + args<start(browser,args); + if ( !procBrowser->waitForStarted()) { // try to set path to browser QMessageBox::warning(0, @@ -2237,45 +2634,21 @@ { if (currentMapEditor()) { - QString url=currentMapEditor()->getURL(); - if (url=="") return; - QString browser=settings.readEntry("/vym/mainwindow/readerURL" ); - if (procBrowser && procBrowser->isRunning()) - { - if (browser.contains("konqueror")) - { - // Try to open new tab in existing konqueror started previously by vym - QProcess *p=new QProcess (this); - p->addArgument ("dcop"); - p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier())); - p->addArgument ("konqueror-mainwindow#1"); - p->addArgument ("newTab"); - p->addArgument (url); - if ( !p->start() ) - // try to set browser - QMessageBox::warning(0, - tr("Warning"), - tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); - return; - } else if (browser.contains ("firefox") || browser.contains ("mozilla") ) - { - // Try to open new tab in firefox - QProcess *p=new QProcess (this); - p->addArgument (browser); - p->addArgument ("-remote"); - p->addArgument (QString("openurl(%1,new-tab)").arg(url)); - if ( !p->start() ) - // try to set browser - QMessageBox::warning(0, - tr("Warning"), - tr("Couldn't start %1 to open a new tab").arg(browser)); - return; - } - } - // Open new browser - editOpenURL(); + QStringList urls; + urls.append(currentMapEditor()->getURL()); + openTabs (urls); } } +void Main::editOpenMultipleURLTabs() +{ + if (currentMapEditor()) + { + QStringList urls; + urls=currentMapEditor()->getURLs(); + openTabs (urls); + } +} + void Main::editURL() { @@ -2301,13 +2674,66 @@ currentMapEditor()->editFATE2URL(); } -void Main::editOpenVymLink() +void Main::editHeading() { - // Get current path to map - QString currentVymLink; - if (currentMapEditor()) + if (lineedit->isVisible()) { - currentVymLink=currentMapEditor()->getVymLink(); + if (currentMapEditor()) + { + MapEditor *me=currentMapEditor(); + QString oldSel=me->getSelectString(); + if (me->select (editSel)) + me->setHeading(lineedit->text()); + me->select (oldSel); + } + lineedit->releaseKeyboard(); + lineedit->hide(); + setFocus(); + } else + { + if (currentMapEditor()) + { + bool ok; + QPoint p; + QString s=currentMapEditor()->getHeading(ok,p); + + if (ok) + { +#if defined(Q_OS_MACX) + p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p)); + QDialog *d =new QDialog(NULL); + QLineEdit *le=new QLineEdit (d); + d->setWindowFlags (Qt::FramelessWindowHint); + d->setGeometry(p.x(),p.y(),200,25); + le->resize (d->size()); + le->setText (s); + le->selectAll(); + connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); + d->activateWindow(); + d->exec(); + currentMapEditor()->setHeading (le->text()); +#else + p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p)); + lineedit->setGeometry(p.x(),p.y(),200,25); + lineedit->setText(s); + lineedit->setCursorPosition(1); + lineedit->selectAll(); + lineedit->show(); + lineedit->grabKeyboard(); + lineedit->setFocus(); + + editSel=currentMapEditor()->getSelectString(); +#endif + + } + } + } +} + +void Main::openVymLinks(const QStringList &vl) +{ + for (int j=0; jcount() -1;i++) { me=(MapEditor*)tabWidget->page(i); - if (currentVymLink==me->getFilePath() ) + if (vl.at(j)==me->getFilePath() ) { index=i; break; @@ -2324,12 +2750,12 @@ if (index<0) // Load map { - if (!QFile(currentVymLink).exists() ) + if (!QFile(vl.at(j)).exists() ) QMessageBox::critical( 0, tr( "Critical Error" ), - tr("Couldn't open map %1").arg(currentVymLink)); + tr("Couldn't open map %1").arg(vl.at(j))); else { - fileLoad (currentVymLink, NewMap); + fileLoad (vl.at(j), NewMap); tabWidget->setCurrentPage (tabWidget->count()-1); } } else @@ -2338,6 +2764,26 @@ } } +void Main::editOpenVymLink() +{ + if (currentMapEditor()) + { + QStringList vl; + vl.append(currentMapEditor()->getVymLink()); + openVymLinks (vl); + } +} + +void Main::editOpenMultipleVymLinks() +{ + QString currentVymLink; + if (currentMapEditor()) + { + QStringList vl=currentMapEditor()->getVymLinks(); + openVymLinks (vl); + } +} + void Main::editVymLink() { if (currentMapEditor()) @@ -2390,15 +2836,10 @@ } } -void Main::editHeading() -{ - if (currentMapEditor()) - currentMapEditor()->editHeading(); -} - void Main::editNewBranch() { - if (currentMapEditor()) + + if (!lineedit->isVisible() && currentMapEditor()) currentMapEditor()->addNewBranch(0); } @@ -2495,22 +2936,23 @@ currentMapEditor()->loadFloatImage(); } -void Main::editSaveImage(int item) +void Main::editSaveImage() { if (currentMapEditor()) - currentMapEditor()->saveFloatImage(item); + currentMapEditor()->saveFloatImage(); } -void Main::editFollowXLink(int item) +void Main::editFollowXLink(QAction *a) +{ + + if (currentMapEditor()) + currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a)); +} + +void Main::editEditXLink(QAction *a) { if (currentMapEditor()) - currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item)); -} - -void Main::editEditXLink(int item) -{ - if (currentMapEditor()) - currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item)); + currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a)); } void Main::formatSelectColor() @@ -2624,7 +3066,7 @@ { if (currentMapEditor()) { - QWMatrix m; + QMatrix m; m.reset(); currentMapEditor()->setWorldMatrix( m ); currentMapEditor()->setViewCenter(); @@ -2636,7 +3078,7 @@ { if (currentMapEditor()) { - QWMatrix m = currentMapEditor()->worldMatrix(); + QMatrix m = currentMapEditor()->worldMatrix(); m.scale( 1.25, 1.25 ); currentMapEditor()->setWorldMatrix( m ); currentMapEditor()->setViewCenter(); @@ -2648,7 +3090,7 @@ { if (currentMapEditor()) { - QWMatrix m = currentMapEditor()->worldMatrix(); + QMatrix m = currentMapEditor()->worldMatrix(); m.scale( 0.8, 0.8 ); currentMapEditor()->setWorldMatrix( m ); currentMapEditor()->setViewCenter(); @@ -2670,9 +3112,9 @@ bool ok; QString text = QInputDialog::getText( "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal, - settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this ); + settings.value("/mainwindow/readerPDF").toString(), &ok, this ); if (ok) - settings.writeEntry ("/vym/mainwindow/readerPDF",text); + settings.setValue ("/mainwindow/readerPDF",text); return ok; } @@ -2683,10 +3125,10 @@ bool ok; QString text = QInputDialog::getText( "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal, - settings.readEntry("/vym/mainwindow/readerURL") + settings.value("/mainwindow/readerURL").toString() , &ok, this ); if (ok) - settings.writeEntry ("/vym/mainwindow/readerURL",text); + settings.setValue ("/mainwindow/readerURL",text); return ok; } @@ -2694,7 +3136,7 @@ { if (actionSettingsUseDelKey->isOn()) { - actionEditDelete->setAccel (QKeySequence (Key_Delete)); + actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete)); } else { actionEditDelete->setAccel (QKeySequence ("")); @@ -2793,7 +3235,7 @@ Process *pdfProc = new Process(); pdfProc->clearArguments(); - pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF")); + pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString()); pdfProc->addArgument( docpath); if ( !pdfProc->start() ) diff -r 1cc73bd7ee1f -r e95081c21da2 mainwindow.h --- a/mainwindow.h Tue Sep 05 09:47:13 2006 +0000 +++ b/mainwindow.h Tue Sep 05 09:47:14 2006 +0000 @@ -1,16 +1,16 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +//Added by qt3to4: +#include +#include +#include #include "file.h" #include "findwindow.h" @@ -23,7 +23,7 @@ Q_OBJECT public: - Main(QWidget* parent=0, const char* name=0, WFlags f=0); + Main(QWidget* parent=0, const char* name=0, Qt::WFlags f=0); ~Main(); void loadCmdLine(); void statusMessage (const QString &); @@ -60,7 +60,7 @@ ErrorCode fileLoad(QString ,const LoadMode &); void fileLoad(const LoadMode &); void fileLoad(); - void fileLoadLast(int); + void fileLoadLast(QAction *); void fileSave(const SaveMode & ); void fileSave(); void fileSaveAs(const SaveMode &); @@ -71,7 +71,7 @@ void fileImportDir(); void fileExportXML(); void fileExportXHTML(); - void fileExportImage(int); + void fileExportImage(); void fileExportASCII(); void fileExportLaTeX(); void fileExportKDEBookmarks(); @@ -89,16 +89,22 @@ void editOpenFindWindow(); void editFind(QString); void editFindChanged(); +private: + void openTabs(QStringList); public slots: void editOpenURL(); void editOpenURLTab(); private slots: + void editOpenMultipleURLTabs(); void editURL(); void editHeading2URL(); void editBugzilla2URL(); void editFATE2URL(); + void openVymLinks(const QStringList &); void editVymLink(); + void editOpenMultipleVymLinks(); public slots: + void editHeading(); void editOpenVymLink(); private slots: void editDeleteVymLink(); @@ -108,7 +114,6 @@ void editMoveDown(); void editToggleScroll(); void editUnScrollAll(); - void editHeading(); void editNewBranch(); void editNewBranchHere(); void editNewBranchAbove(); @@ -126,9 +131,9 @@ void editFirstBranch(); void editLastBranch(); void editLoadImage(); - void editSaveImage(int); - void editFollowXLink (int); - void editEditXLink (int); + void editSaveImage(); + void editFollowXLink (QAction *); + void editEditXLink (QAction *); void formatSelectColor(); void formatPickColor(); @@ -179,13 +184,17 @@ void helpAboutQT(); private: -// not needed? QCanvas* canvas; QTabWidget *tabWidget; FindWindow *findWindow; QStringList lastMaps; int maxLastMaps; - QString lastFileDir; QProcess *procBrowser; + + QStringList imageTypes; + + QLineEdit *lineedit; // to enter headings of branches + QString editSel; + }; diff -r 1cc73bd7ee1f -r e95081c21da2 mapeditor.cpp --- a/mapeditor.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/mapeditor.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -1,24 +1,34 @@ #include "mapeditor.h" #include -#include +#include #include #include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include +//Added by qt3to4: +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -34,7 +44,6 @@ #include "linkablemapobj.h" #include "mainwindow.h" #include "misc.h" -#include "settings.h" #include "texteditor.h" #include "warningdialog.h" #include "xml.h" @@ -49,10 +58,11 @@ extern FlagRowObj *systemFlagsDefault; extern FlagRowObj *standardFlagsDefault; -extern QPtrList actionListBranches; +extern Q3PtrList actionListBranches; extern QAction *actionFileSave; extern QAction *actionEditUndo; +extern QAction *actionEditRedo; extern QAction *actionEditCopy; extern QAction *actionEditCut; extern QAction *actionEditPaste; @@ -113,44 +123,51 @@ extern QAction *actionSettingsAutoedit; extern QAction *actionSettingsAutoselectHeading; extern QAction *actionSettingsAutoselectText; -extern QAction *actionSettingsPasteNewHeading; extern QAction *actionSettingsUseFlagGroups; -extern QPopupMenu *branchContextMenu; -extern QPopupMenu *branchLinksContextMenu; -extern QPopupMenu *branchLinksContextMenuDup; -extern QPopupMenu *floatimageContextMenu; -extern QPopupMenu *saveImageFormatMenu; -extern QPopupMenu *exportImageFormatMenu; -extern QPopupMenu *canvasContextMenu; +extern QMenu* branchContextMenu; +extern QMenu* branchAddContextMenu; +extern QMenu* branchRemoveContextMenu; +extern QMenu* branchLinksContextMenu; +extern QMenu* branchXLinksContextMenuEdit; +extern QMenu* branchXLinksContextMenuFollow; +extern QMenu* floatimageContextMenu; +extern QMenu* saveImageFormatMenu; +extern QMenu* canvasContextMenu; +extern QMenu* lastMapsMenu; +extern QMenu* importMenu; +extern QMenu* exportMenu; + extern Settings settings; +extern ImageIO imageIO; extern QString iconPath; extern QDir vymBaseDir; +extern QDir lastImageDir; int MapEditor::mapNum=0; // make instance /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// MapEditor::MapEditor( - QWidget* parent, bool interactive, const char* name, WFlags f) : - QCanvasView(parent,name,f), urlOperator(0), imageBuffer(0) + QWidget* parent, bool interactive, const char* name, Qt::WFlags f) : + Q3CanvasView(parent,name,f), urlOperator(0), imageBuffer(0) { //cout << "Constructor ME "<setAcceptDrops(true); - mapCanvas = new QCanvas(1000,800); + mapCanvas = new Q3Canvas(width(),height()); mapCanvas->setAdvancePeriod(30); - mapCanvas->setBackgroundColor (white); + mapCanvas->setBackgroundColor (Qt::white); setCanvas (mapCanvas); // Always show scroll bars (automatic would flicker sometimes) - setVScrollBarMode ( QScrollView::AlwaysOn ); - setHScrollBarMode ( QScrollView::AlwaysOn ); + setVScrollBarMode ( Q3ScrollView::AlwaysOn ); + setHScrollBarMode ( Q3ScrollView::AlwaysOn ); mapCenter = new MapCenterObj(mapCanvas); mapCenter->setVisibility (true); @@ -160,24 +177,18 @@ printer=NULL; - lineedit = new QLineEdit(this, "lineedit" ); - connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEdit() ) ); - lineedit->hide(); - - actColor=black; setColor (actColor); + actColor=Qt::black; setColor (actColor); defLinkColor=QColor (0,0,255); defXLinkColor=QColor (180,180,180); linkcolorhint=DefaultColor; linkstyle=StylePolyParabel; - // Create bitmap cursors, patform dependant + // Create bitmap cursors, platform dependant #if defined(Q_OS_MACX) - handOpenCursor=QCursor ( QPixmap(iconPath+"cursorhandopen16.png") ); - // set hot spot to tip of picker + handOpenCursor=QCursor ( QPixmap(iconPath+"cursorhandopen16.png"),1,1 ); pickColorCursor=QCursor ( QPixmap (iconPath+"cursorcolorpicker16.png"), 1,15 ); #else - handOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen16.png")); - // set hot spot to tip of picker + handOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1); pickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 ); #endif @@ -190,6 +201,8 @@ selectionLast=NULL; movingObj=NULL; + xelection.setMapCenter (mapCenter); + defXLinkWidth=1; defXLinkColor=QColor (230,230,230); @@ -202,9 +215,7 @@ fileName=tr("unnamed"); mapName=""; - undosTotal=settings.readNumEntry("/vym/mapeditor/undoLevels",50); - undosAvail=0; - undoNum=0; + undosTotal=settings.readNumEntry("/mapeditor/undoLevels",50); // Initialize find routine itFind=NULL; @@ -231,6 +242,8 @@ historyWindow->setCaption (fileName); mapCenter->reposition(); // for positioning heading + + } MapEditor::~MapEditor() @@ -244,7 +257,7 @@ //cout <<"Destructor MapEditor\n"; // Save Settings - //settings.writeEntry( "/vym/mapeditor/editmode/autoselect", ); + //settings.writeEntry( "/mapeditor/editmode/autoselect", ); } @@ -263,7 +276,7 @@ return mapCenter; } -QCanvas* MapEditor::getCanvas() +Q3Canvas* MapEditor::getCanvas() { return mapCanvas; } @@ -355,12 +368,13 @@ void MapEditor::makeTmpDirs() { // Create unique temporary directories - tmpMapDir=tmpVymDir+QString("/mapeditor-%1").arg(mapNum); + tmpMapDir=QDir::convertSeparators (tmpVymDir+QString("/mapeditor-%1").arg(mapNum)); + histPath=QDir::convertSeparators (tmpMapDir+"/history"); QDir d; d.mkdir (tmpMapDir,true); } -QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSelection) +QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSel) { // tmpdir temporary directory to which data will be written // prefix mapname, which will be appended to images etc. @@ -392,7 +406,7 @@ colhint=attribut("linkColorHint","HeadingColor"); QString mapAttr=attribut("version",__VYM_VERSION); - if (!saveSelection) + if (!saveSel) mapAttr+= attribut("author",mapCenter->getAuthor()) + attribut("comment",mapCenter->getComment()) + attribut("date",mapCenter->getDate()) + @@ -412,25 +426,28 @@ FloatImageObj (mapCanvas).resetSaveCounter(); // Build xml recursivly - if (!saveSelection) + if (!saveSel) + // Save complete map, if saveSel not set s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset); else { - if ( typeid(*saveSelection) == typeid(BranchObj) ) - s+=((BranchObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset); - else if ( typeid(*saveSelection) == typeid(FloatImageObj) ) - s+=((FloatImageObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset); + 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,offset); else if (selection && typeid(*selection)==typeid(BranchObj)) - // This is used if selected branch is saved from mainwindow - s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset); + // Save selected branch is saved from mainwindow //FIXME maybe use "subtree" above? + s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset); } // Save local settings s+=settings.getXMLData (destPath); // Save selection - if (selection && !saveSelection ) + if (selection && !saveSel ) s+=valueElement("select",selection->getSelectString()); decIndent(); @@ -441,60 +458,112 @@ return s; } -void MapEditor::saveState(const QString &comment) +void MapEditor::saveStateComplete(const QString &comment) { - // Save complete map - saveState (CompleteMap,"",NULL,"",NULL, comment); + // Save complete map, Undo will replace whole map + saveState (CompleteMap, + "", "", + "", "", + comment, + mapCenter); } -void MapEditor::saveState(LinkableMapObj *undoSel, const QString &comment) +void MapEditor::saveStatePart(LinkableMapObj *undoSel, const QString &comment) { - // save the given part of the map - saveState (PartOfMap,"",undoSel,"",NULL, comment); + // save the selected part of the map, Undo will replace part of map + QString undoSelection=""; + if (undoSel) undoSelection=undoSel->getSelectString(); + + saveState (PartOfMap, + undoSelection, "", + "", "", + comment, + undoSel); } -void MapEditor::saveState(const QString &uc, const QString &rc, const QString &comment) +void MapEditor::saveStateConstSelection(const QString &uc, const QString &rc, const QString &comment) { // selection does not change during action, // so just save commands for undo and redo - LinkableMapObj *unsel; - if (selection) - unsel=selection; - else - unsel=NULL; - saveState (UndoCommand,uc,unsel,rc,unsel, comment); + // and use current selection + + QString sel; + if (selection) sel=selection->getSelectString(); + + saveState (UndoCommand, + sel, uc, + sel, rc, + comment, + NULL); } -void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel, const QString &comment) +void MapEditor::saveStateComData(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment, LinkableMapObj *saveSel) { - saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL, comment); + QString redoSelection=""; + if (redoSel) redoSelection=redoSel->getSelectString(); + QString undoSelection=""; + if (undoSel) undoSelection=undoSel->getSelectString(); + + saveState (UndoCommand, + undoSelection, uc, + redoSelection, "FIXME-redoCom", //FIXME + comment, + saveSel); } -void MapEditor::saveState(const SaveMode &savemode, const QString &undoCom, LinkableMapObj *undoSel, const QString &redoCom, LinkableMapObj *redoSel, const QString &comment) +void MapEditor::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=redoSel->getSelectString(); + QString undoSelection=""; + if (undoSel) undoSelection=undoSel->getSelectString(); + + saveState (UndoCommand, + undoSelection, uc, + redoSelection, rc, + comment, + NULL); +} + +void MapEditor::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 MapEditor::saveState(const SaveMode &savemode, const QString &undoSelection, const QString &undoCom, const QString &redoSelection, const QString &redoCom, const QString &comment, LinkableMapObj *saveSel) { // Main saveState if (blockSaveState) return; /* TODO remove after testing - cout << "ME::saveState() begin\n"<append (comment); setChanged(); + int undosAvail=undoSet.readNumEntry ("/history/undosAvail",0); + int curStep=undoSet.readNumEntry ("/history/curStep",0); // Find out current undo directory if (undosAvailundosTotal) undoNum=1; + curStep++; + if (curStep>undosTotal) curStep=1; QString backupXML; - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum)); + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep)); QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml"); // Create bakMapDir if not available @@ -502,59 +571,50 @@ if (!d.exists()) makeSubDirs (bakMapDir); - // Save current selection - QString redoSelection=""; - if (redoSel) - redoSelection=redoSel->getSelectString(); - - // Save the object, which should be undone - QString undoSelection=""; - if (undoSel) - undoSelection=undoSel->getSelectString(); + // Save depending on how much needs to be saved + if (!saveSel) + backupXML=""; + else + backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),saveSel); - // Save depending on how much needs to be saved QString undoCommand=""; if (savemode==UndoCommand) { undoCommand=undoCom; - backupXML=""; } - else if (savemode==PartOfMap && undoSel) + else if (savemode==PartOfMap ) { undoCommand="undoPart (\""+ undoSelection+"\",\""+bakMapPath+"\")"; - backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),undoSel); } else { undoCommand="undoMap (\""+bakMapPath+"\")"; - backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),NULL); - undoSelection=""; } if (!backupXML.isEmpty()) // Write XML Data to disk saveStringToDisk (QString(bakMapPath),backupXML); - SimpleSettings set; - set.setEntry (QString("undoCommand"),undoCommand); - set.setEntry (QString("undoSelection"),undoSelection); - set.setEntry (QString("redoCommand"),redoCom); - set.setEntry (QString("redoSelection"),redoSelection); - set.setEntry (QString("comment"),comment); - set.writeSettings(QString(bakMapDir+"/commands")); + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail)); + 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.writeSettings(histPath); /* TODO remove after testing - cout << " into="<< bakMapDir<findObjBySelect (s); if (dst) @@ -620,23 +711,56 @@ if (api.checkParamCount(1)) { s=api.parString (ok,0); - if (ok) setHeading (s); + if (ok) + setHeading (s); } } else if (com=="setURL") { if (api.checkParamCount(1)) { s=api.parString (ok,0); - if (ok) setURL(s); + if (ok) setURLInt(s); } } else if (com=="setVymLink") { if (api.checkParamCount(1)) { s=api.parString (ok,0); - if (ok) setVymLink(s); + if (ok) setVymLinkInt(s); } } + else if (com=="setFlag") + { + if (selection && typeid(*selection) == typeid(BranchObj) ) + { + if (api.checkParamCount(1) ) + { + s=api.parString(ok,0); + if (ok) + { + BranchObj* bo=(BranchObj*)selection; + bo->activateStandardFlag(s); + bo->updateFlagsToolbar(); + } + } + } + } + else if (com=="unsetFlag") + { + if (selection && typeid(*selection) == typeid(BranchObj) ) + { + if (api.checkParamCount(1) ) + { + s=api.parString(ok,0); + if (ok) + { + BranchObj* bo=(BranchObj*)selection; + bo->deactivateStandardFlag(s); + bo->updateFlagsToolbar(); + } + } + } + } // Internal commands, used for undo etc. else if (com==QString("undoMap")) { @@ -646,55 +770,32 @@ { if (api.checkParamCount(2)) { - s=api.parString (ok,0); - t=api.parString (ok,1); + s=api.parString (ok,0); // undo selection + t=api.parString (ok,1); // backup dir undoXML(s,t); } } else if (com=="select") + { if (api.checkParamCount(1)) { s=api.parString(ok,0); if (ok) select (s); } + } else { api.setError ("Unknown command in: "+atom); - cout << "ME::parse api should have error now...\n"; } // Any errors? if (api.error()) { - cout << "MapEditor::parseAtom: Error!\n"; - cout << " "<setFocus() - - if (editingBO!=NULL) - { - saveState("setHeading (\""+editingBO->getHeading()+"\")",editingBO, QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(lineedit->text()) ); - editingBO->setHeading(lineedit->text() ); - editingBO=NULL; - lineedit->releaseKeyboard(); - lineedit->hide(); - parentWidget()->setFocus(); - mapCenter->reposition(); - adjustCanvasSize(); - ensureSelectionVisible(); - } -} - void MapEditor::toggleHistoryWindow() { if (historyWindow->isVisible()) @@ -731,9 +832,6 @@ void MapEditor::closeMap() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - // Unselect before disabling the toolbar actions if (selection) selection->unselect(); selection=NULL; @@ -799,9 +897,6 @@ ErrorCode MapEditor::load (QString fname, LoadMode lmode) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - ErrorCode err=success; if (lmode==NewMap) @@ -813,7 +908,7 @@ // (map state is set later at end of load...) } else { - saveState(selection,"Load map"); + saveStatePart(selection,"Load map"); } @@ -868,9 +963,6 @@ int MapEditor::save (const SaveMode &savemode) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - int returnCode=0; // The SaveMode UndoCommand is not supported here @@ -918,14 +1010,11 @@ void MapEditor::print() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if ( !printer ) { printer = new QPrinter; printer->setColorMode (QPrinter::Color); - printer->setPrinterName (settings.readEntry("/vym/mainwindow/printerName",printer->printerName())); + printer->setPrinterName (settings.value("/mainwindow/printerName",printer->printerName()).toString()); } QRect totalBBox=mapCenter->getTotalBBox(); @@ -962,15 +1051,15 @@ // e.g. (0,50,700,700) is upper part on A4 // see also /usr/lib/qt3/doc/html/coordsys.html - QPaintDeviceMetrics metrics (printer); + Q3PaintDeviceMetrics metrics (printer); double paperAspect = (double)metrics.width() / (double)metrics.height(); double mapAspect = (double)totalBBox.width() / (double)totalBBox.height(); QRect mapRect=totalBBox; - QCanvasRectangle *frame=NULL; - QCanvasText *footerFN=NULL; - QCanvasText *footerDate=NULL; + Q3CanvasRectangle *frame=NULL; + Q3CanvasText *footerFN=NULL; + Q3CanvasText *footerDate=NULL; if (printFrame || printFooter) { @@ -979,9 +1068,9 @@ // Print frame around map mapRect.setRect (totalBBox.x()-10, totalBBox.y()-10, totalBBox.width()+20, totalBBox.height()+20); - frame=new QCanvasRectangle (mapRect,mapCanvas); - frame->setBrush (QColor(white)); - frame->setPen (QColor(black)); + frame=new Q3CanvasRectangle (mapRect,mapCanvas); + frame->setBrush (QColor(Qt::white)); + frame->setPen (QColor(Qt::black)); frame->setZ(0); frame->show(); } @@ -998,13 +1087,13 @@ // Print footer below map QFont font; font.setPointSize(10); - footerFN=new QCanvasText (mapCanvas); + footerFN=new Q3CanvasText (mapCanvas); footerFN->setText ("VYM - " + fileName); footerFN->setFont(font); footerFN->move (mapRect.x(), mapRect.y() + mapRect.height() ); footerFN->setZ(Z_TEXT); footerFN->show(); - footerDate=new QCanvasText (mapCanvas); + footerDate=new Q3CanvasText (mapCanvas); footerDate->setText (QDate::currentDate().toString(Qt::TextDate)); footerDate->setFont(font); footerDate->move (mapRect.x()+mapRect.width()-footerDate->boundingRect().width(), mapRect.y() + mapRect.height() ); @@ -1045,7 +1134,7 @@ } // Save settings in vymrc - settings.writeEntry("/vym/mainwindow/printerName",printer->printerName()); + settings.writeEntry("/mainwindow/printerName",printer->printerName()); } } @@ -1094,9 +1183,6 @@ void MapEditor::exportImage(QString fn) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - setExportMode (true); QPixmap pix (getPixmap()); pix.save(fn, "PNG"); @@ -1107,20 +1193,17 @@ { // should be called before and after exports // depending on the settings - if (b && settings.readEntry("/vym/export/useHideExport","yes")) + if (b && settings.value("/export/useHideExport","yes")=="yes") setHideTmpMode (HideExport); else setHideTmpMode (HideNone); } -void MapEditor::exportImage(QString fn, int item) +void MapEditor::exportImage(QString fn, QString format) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - setExportMode (true); QPixmap pix (getPixmap()); - pix.save(fn, exportImageFormatMenu->text(item) ); + pix.save(fn, format); setExportMode (false); } @@ -1152,7 +1235,7 @@ QFile file; file.setName ( dir + "/"+mapName+".xml"); - if ( !file.open( IO_WriteOnly ) ) + if ( !file.open( QIODevice::WriteOnly ) ) { // This should neverever happen QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open %1").arg(file.name())); @@ -1184,9 +1267,6 @@ void MapEditor::copy() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection) { // write to directory @@ -1195,7 +1275,7 @@ QFile file; file.setName ( clipboardDir + "/"+clipfile+".xml"); - if ( !file.open( IO_WriteOnly ) ) + if ( !file.open( QIODevice::WriteOnly ) ) { // This should neverever happen QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open %1").arg(file.name())); @@ -1215,124 +1295,126 @@ void MapEditor::redo() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - blockSaveState=true; + // Restore variables + int curStep=undoSet.readNumEntry (QString("/history/curStep")); + int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail")); + int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail")); + if (redosAvail>0) redosAvail--; + if (undosAvailundosTotal) 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)); + // Find out current undo directory - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum)); - - // Restore variables - QString undoCommand; - QString undoSelection; - QString redoCommand; - QString redoSelection; - SimpleSettings set; - set.readSettings(QString(bakMapDir+"/commands")); - undoCommand=set.readEntry ("undoCommand"); - undoSelection=set.readEntry ("undoSelection"); - redoCommand=set.readEntry ("redoCommand"); - redoSelection=set.readEntry ("redoSelection"); + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep)); + +/* TODO remove testing +*/ + cout << "ME::redo() begin\n"; + cout << " undosAvail="<reposition(); + + blockSaveState=false; + + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail)); + undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail)); + undoSet.setEntry ("/history/curStep",QString::number(curStep)); + undoSet.writeSettings(histPath); + + updateActions(); + + /* TODO remove testing */ - parseAtom (undoCommand); - mapCenter->reposition(); - - //if (!redoSelection.isEmpty()) - // select (redoSelection); - - undosAvail--; - if (undosAvail<1) - // Undo not longer available now - actionEditUndo->setEnabled (false); - else - undoNum--; if (undoNum<1) undoNum=undosTotal; - - blockSaveState=false; -/* TODO remove testing cout << "ME::redo() end\n"; cout << " undosAvail="<reposition(); - //if (!redoSelection.isEmpty()) - // select (redoSelection); - undosAvail--; - if (undosAvail<1) - // Undo not longer available now - actionEditUndo->setEnabled (false); - else - undoNum--; if (undoNum<1) undoNum=undosTotal; + curStep--; + if (curStep<1) curStep=undosTotal; + + redosAvail++; blockSaveState=false; /* TODO remove testing +*/ cout << "ME::undo() end\n"; cout << " undosAvail="<reposition(); adjustCanvasSize(); @@ -1409,7 +1488,7 @@ void MapEditor::cut() { - saveState(selection->getParObj(),QString("Cut %1").arg(getName(selection))); + saveStatePart(selection->getParObj(),QString("Cut %1").arg(getName(selection))); copy(); cutNoSave(); mapCenter->reposition(); @@ -1418,17 +1497,39 @@ void MapEditor::move(const int &x, const int &y) { - // TODO no saveState, because this is only internal at undo so far - if (selection) selection->move(x,y); - if (typeid(*selection) == typeid(FloatImageObj)) - ((FloatImageObj*)selection)->setRelPos(); + if (selection) + { + QString ps=qpointToString (selection->getAbsPos()); + QString s=selection->getSelectString(); + saveState( + s, "move "+ps, + s, "move "+qpointToString (QPoint (x,y)), + QString("Move %1 to %2").arg(getName(selection)).arg(ps)); + selection->move(x,y); + mapCenter->reposition(); + adjustCanvasSize(); + } + +} + +void MapEditor::moveRel (const int &x, const int &y) +{ + if (selection) + { + QString ps=qpointToString (selection->getRelPos()); + QString s=selection->getSelectString(); + saveState( + s, "moveRel "+ps, + s, "moveRel "+qpointToString (QPoint (x,y)), + QString("Move %1 to relativ position %2").arg(getName(selection)).arg(ps)); + selection->setRelPos (QPoint(x,y)); + mapCenter->reposition(); + adjustCanvasSize(); + } } void MapEditor::moveBranchUp() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; if (typeid(*selection) == typeid(BranchObj) ) @@ -1437,9 +1538,9 @@ if (!bo->canMoveBranchUp()) return; par=(BranchObj*)(bo->getParObj()); selection->unselect(); - selection=par->moveBranchUp (bo); + bo=par->moveBranchUp (bo); // bo will be the one below selection selection->select(); - saveState("moveBranchDown ()",bo,QString("Move up %1").arg(getName(bo))); + saveState (selection,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo))); mapCenter->reposition(); ensureSelectionVisible(); } @@ -1447,9 +1548,6 @@ void MapEditor::moveBranchDown() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; if (typeid(*selection) == typeid(BranchObj) ) @@ -1458,54 +1556,51 @@ if (!bo->canMoveBranchDown()) return; par=(BranchObj*)(bo->getParObj()); selection->unselect(); - selection=par->moveBranchDown(bo); + bo=par->moveBranchDown(bo); // bo will be the one above selection selection->select(); - saveState("moveBranchUp ()",bo,QString("Move down %1").arg(getName(bo))); + saveState(selection,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo))); mapCenter->reposition(); ensureSelectionVisible(); } } -void MapEditor::editHeading() +QString MapEditor::getHeading(bool &ok, QPoint &p) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - + if (selection && + (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj) ) ) + { + ok=true; + ensureSelectionVisible(); + p = ((BranchObj*)selection)->getAbsPos(); + p.setX (p.x() - contentsX()); + p.setY (p.y() - contentsY() + ((BranchObj*)selection)->height()/2); + return ((BranchObj*)selection)->getHeading(); + } + ok=false; + return QString(); +} + +void MapEditor::setHeading(const QString &s) +{ if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj) ) ) { editingBO=(BranchObj*)selection; - - ensureSelectionVisible(); - QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y())); - lineedit->setGeometry(p.x()-contentsX(),p.y()-contentsY(),200,25); - QString s=editingBO->getHeading(); - lineedit->setText(s); - lineedit->setCursorPosition(1); - if (actionSettingsAutoselectText->isOn() && !s.isEmpty() && actionSettingsPasteNewHeading->isOn() ) - lineedit->selectAll(); - lineedit->show(); - lineedit->grabKeyboard(); - lineedit->setFocus(); - } -} - -void MapEditor::setHeading(const QString &s) -{ - // Internal function, no saveState needed - if (selection && - (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj) ) ) - { - ((BranchObj*)selection)->setHeading(s); + saveStateConstSelection( + "setHeading (\""+editingBO->getHeading()+"\")", + "setHeading (\""+s+"\")", + QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(s) ); + editingBO->setHeading(s ); + editingBO=NULL; mapCenter->reposition(); adjustCanvasSize(); ensureSelectionVisible(); } } -void MapEditor::setURL (const QString &s) +void MapEditor::setURLInt (const QString &s) { // Internal function, no saveState needed if (selection && @@ -1519,7 +1614,20 @@ } } -void MapEditor::setVymLink (const QString &s) +void MapEditor::setHeadingInt(const QString &s) +{ + if (selection && + (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj) ) ) + { + ((BranchObj*)selection)->setHeading(s); + mapCenter->reposition(); + adjustCanvasSize(); + ensureSelectionVisible(); + } +} + +void MapEditor::setVymLinkInt (const QString &s) { // Internal function, no saveState needed if (selection && @@ -1533,44 +1641,107 @@ } } -void MapEditor::addNewBranch(int pos) +BranchObj* MapEditor::addNewBranchInt(int num) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - + // Depending on pos: + // -3 insert in childs of parent above selection + // -2 add branch to selection + // -1 insert in childs of parent below selection + // 0..n insert in childs of parent at pos + BranchObj *newbo=NULL; if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj) ) ) { - BranchObj* bo1 = (BranchObj*) selection; - saveState(selection, QString("Add new branch to %1").arg(getName(bo1))); //TODO undoCommand - - bool wasScrolled=false; - BranchObj *newbo=NULL; - if (pos==0) + BranchObj* bo = (BranchObj*) selection; + if (num==-2) { // save scroll state. If scrolled, automatically select // new branch in order to tmp unscroll parent... - wasScrolled=bo1->isScrolled(); - newbo=bo1->addBranch(); - } else + return bo->addBranch(); + + }else if (num==-1) { - BranchObj *parbo=(BranchObj*)(selection->getParObj()); - if (parbo) + num=bo->getNum()+1; + bo=(BranchObj*)bo->getParObj(); + }else if (num==-3) + { + num=bo->getNum(); + bo=(BranchObj*)bo->getParObj(); + } + if (!bo) return bo; + newbo=bo->insertBranch(num); + } + return newbo; +} + +void MapEditor::addNewBranch(int pos) +{ + // Different meaning than num in addNewBranchInt! + // -1 add above + // 0 add as child + // +1 add below + if (selection && + (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj) ) ) + { + BranchObj *bo = (BranchObj*) selection; + BranchObj *newbo; + newbo=addNewBranchInt (pos-2); + + if (newbo) + { + saveStateConstSelection ( + QString ("delete (\"%1\")").arg(newbo->getSelectString()), + QString ("addBranch (%1)").arg(pos-2), + QString ("Add new branch to %1").arg(getName(bo))); //TODO undoCommand + + LinkableMapObj *oldselection=selection; + + mapCenter->reposition(); + adjustCanvasSize(); + + + if (actionSettingsAutoedit->isOn() || + actionSettingsAutoselectHeading->isOn() ) { - if (pos<0) - // add above selection - newbo=parbo->insertBranch(bo1->getNum()); - else - // add below selection - newbo=parbo->insertBranch(bo1->getNum()+1); - } else - // This should not happen... - return; - - } + selection->unselect(); + selection=newbo; + selection->select(); + if (actionSettingsAutoedit->isOn() ) + mainWindow->editHeading(); + if (!actionSettingsAutoselectHeading->isOn() + )//&& !wasScrolled) //FIXME wasScrolled was moved to addNewBranchInt + { + selection->unselect(); + selection=oldselection; + selection->select(); + } + } + } + } +} + + +void MapEditor::addNewBranchHere() +{ + if (selection && + (typeid(*selection) == typeid(BranchObj) ) ) + { + BranchObj* bo1 = (BranchObj*) selection; + saveStatePart(selection, QString("Add new branch here").arg(getName(bo1))); + + bool wasScrolled=false; + BranchObj *newbo=NULL; + BranchObj *parbo=(BranchObj*)(selection->getParObj()); + if (parbo) + { + // add below selection + newbo=parbo->insertBranch(bo1->getNum()+1); + } LinkableMapObj *oldselection=selection; + ((BranchObj*)selection)->moveBranchTo (newbo,-1); mapCenter->reposition(); adjustCanvasSize(); @@ -1580,13 +1751,8 @@ selection->unselect(); selection=newbo; selection->select(); - if (actionSettingsPasteNewHeading->isOn() ) - { - BranchObj *bo2= (BranchObj*)selection; - bo2->setHeading(""); - } if (actionSettingsAutoedit->isOn() ) - editHeading(); + mainWindow->editHeading(); if (!actionSettingsAutoselectHeading->isOn() && !wasScrolled) { @@ -1598,74 +1764,22 @@ } } - -void MapEditor::addNewBranchHere() -{ - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - - if (selection && - (typeid(*selection) == typeid(BranchObj) ) ) - { - BranchObj* bo1 = (BranchObj*) selection; - saveState(selection, QString("Add new branch here").arg(getName(bo1))); - - bool wasScrolled=false; - BranchObj *newbo=NULL; - BranchObj *parbo=(BranchObj*)(selection->getParObj()); - if (parbo) - { - // add below selection - newbo=parbo->insertBranch(bo1->getNum()+1); - } - - LinkableMapObj *oldselection=selection; - ((BranchObj*)selection)->moveBranchTo (newbo,-1); - - mapCenter->reposition(); - adjustCanvasSize(); - if (actionSettingsAutoedit->isOn() || - actionSettingsAutoselectHeading->isOn() ) - { - selection->unselect(); - selection=newbo; - selection->select(); - if (actionSettingsPasteNewHeading->isOn() ) - { - BranchObj *bo2= (BranchObj*)selection; - bo2->setHeading(""); - } - if (actionSettingsAutoedit->isOn() ) - editHeading(); - if (!actionSettingsAutoselectHeading->isOn() - && !wasScrolled) - { - selection->unselect(); - selection=oldselection; - selection->select(); - } - } - } -} - void MapEditor::deleteSelection() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection && typeid(*selection) ==typeid(BranchObj) ) { - BranchObj* bo=dynamic_cast (selection); + BranchObj* bo=(BranchObj*)selection; BranchObj* par=(BranchObj*)(bo->getParObj()); bo->unselect(); if (selection->getDepth()>1) // Normal branch, save parent with childs - saveState(par,QString("Delete %1").arg(getName(bo))); + saveStatePart(par,QString("Delete %1").arg(getName(bo))); + // naveState (UndoCom, par, QString("insertBranchAt (%1)", bo, "", QString ("Delete %1").arg(getName(bo)))); else // Mainbranch, save whole map // TODO Better would be to insert mainbranch again at pos // But undoCommand is missing right now - saveState(QString("Delete %1").arg(getName(bo))); + saveStateComplete(QString("Delete %1").arg(getName(bo))); selection=NULL; par->removeBranch(bo); selection=par; @@ -1676,9 +1790,9 @@ } if (selection && typeid(*selection) ==typeid(FloatImageObj) ) { - FloatImageObj* fio=dynamic_cast (selection); + FloatImageObj* fio=(FloatImageObj*)selection; BranchObj* par=(BranchObj*)(fio->getParObj()); - saveState(par, QString("Delete %1").arg(getName(fio))); + saveStatePart(par, QString("Delete %1").arg(getName(fio))); fio->unselect(); selection=NULL; par->removeFloatImage(fio); @@ -1732,7 +1846,13 @@ return false; } -void MapEditor::select (LinkableMapObj *lmo) +QString MapEditor::getSelectString() +{ + if (selection) return selection->getSelectString(); + return QString(); +} + +void MapEditor::selectInt (LinkableMapObj *lmo) { if (lmo && selection != lmo) { @@ -1743,10 +1863,9 @@ adjustCanvasSize(); } - } -void MapEditor::selectNextBranch() +void MapEditor::selectNextBranchInt() { // Increase number of branch if (selection) @@ -1826,7 +1945,7 @@ } } -void MapEditor::selectPrevBranch() +void MapEditor::selectPrevBranchInt() { // Decrease number of branch if (selection) @@ -1907,40 +2026,34 @@ void MapEditor::selectUpperBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection) { if (typeid(*selection) == typeid(BranchObj)) { if (selection->getOrientation()==OrientRightOfCenter) - selectPrevBranch(); + selectPrevBranchInt(); else if (selection->getDepth()==1) - selectNextBranch(); + selectNextBranchInt(); else - selectPrevBranch(); + selectPrevBranchInt(); } } } void MapEditor::selectLowerBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection) { if (typeid(*selection) == typeid(BranchObj)) { if (selection->getOrientation()==OrientRightOfCenter) - selectNextBranch(); + selectNextBranchInt(); else if (selection->getDepth()==1) - selectPrevBranch(); + selectPrevBranchInt(); else - selectNextBranch(); + selectNextBranchInt(); } } } @@ -1948,9 +2061,6 @@ void MapEditor::selectLeftBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; if (selection) @@ -2010,9 +2120,6 @@ void MapEditor::selectRightBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; @@ -2024,7 +2131,7 @@ bo=par->getLastSelectedBranch(); if (bo) { - // Workaround for relecting on left and right side + // Workaround for reselecting on left and right side if (bo->getOrientation()==OrientLeftOfCenter) bo=par->getFirstBranch(); if (bo) @@ -2070,9 +2177,6 @@ void MapEditor::selectFirstBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj *bo1; BranchObj *bo2; BranchObj* par; @@ -2095,9 +2199,6 @@ void MapEditor::selectLastBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj *bo1; BranchObj *bo2; BranchObj* par; @@ -2125,13 +2226,11 @@ void MapEditor::selectBackgroundColor() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this ); if ( !col.isValid() ) return; setBackgroundColor( col ); - saveState(QString("Set background color of map to %1").arg(col.name())); + //TODO undocomm + saveStateComplete(QString("Set background color of map to %1").arg(col.name())); } void MapEditor::setBackgroundColor(QColor c) @@ -2161,7 +2260,7 @@ typeid(*selection) == typeid(MapCenterObj)) { BranchObj *bo=(BranchObj*)selection; - saveState(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand + saveStatePart(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand bo->setColor(actColor); // color branch } } @@ -2175,7 +2274,7 @@ typeid(*selection) == typeid(MapCenterObj)) { BranchObj *bo=(BranchObj*)selection; - saveState(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand + saveStatePart(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand bo->setColorChilds(actColor); // color links, color childs } } @@ -2186,15 +2285,27 @@ { if (selection) { - BranchObj *bo=(BranchObj*)selection; - QString s; - if (bo->isSetStandardFlag(f)) - s="Unset"; - else - s="Set"; - saveState(selection, QString("%1 standard flag \"%2\" of %3").arg(s).arg(f).arg(getName(bo)));// TODO undoCommand - bo->toggleStandardFlag (f,actionSettingsUseFlagGroups->isOn()); - adjustCanvasSize(); + if (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj)) + { + BranchObj *bo=(BranchObj*)selection; + QString u,r; + if (bo->isSetStandardFlag(f)) + { + r="unsetFlag"; + u="setFlag"; + } + else + { + u="unsetFlag"; + r="setFlag"; + } + saveStateConstSelection(QString("%1 (\"%2\")").arg(u).arg(f), + QString("%1 (\"%2\")").arg(r).arg(f), + QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo))); + bo->toggleStandardFlag (f,actionSettingsUseFlagGroups->isOn()); + adjustCanvasSize(); + } } } @@ -2208,6 +2319,9 @@ BranchObj* MapEditor::findText (QString s, bool cs) { + QTextDocument::FindFlags flags=0; + if (cs) flags=QTextDocument::FindCaseSensitively; + if (!itFind) { // Nothing found or new find process if (EOFind) @@ -2232,7 +2346,7 @@ adjustCanvasSize(); ensureSelectionVisible(); } - if (textEditor->findText(s,cs)) + if (textEditor->findText(s,flags)) { searching=false; foundNote=true; @@ -2282,7 +2396,7 @@ if ( ok) { // user entered something and pressed OK - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text)); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text)); bo->setURL (text); updateActions(); } @@ -2298,13 +2412,31 @@ return ""; } +QStringList MapEditor::getURLs() +{ + QStringList urls; + if (selection && (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj)) ) + { + BranchObj *bo=(BranchObj*)selection; + bo=bo->first(); + while (bo) + { + if (!bo->getURL().isEmpty()) urls.append( bo->getURL()); + bo=bo->next(); + } + } + return urls; +} + + void MapEditor::editHeading2URL() { if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=(BranchObj*)selection; - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo))); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo))); bo->setURL (bo->getHeading()); updateActions(); } @@ -2317,7 +2449,7 @@ { BranchObj *bo=(BranchObj*)selection; QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading(); - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo))); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo))); bo->setURL (url); updateActions(); } @@ -2330,7 +2462,7 @@ { BranchObj *bo=(BranchObj*)selection; QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading(); - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo))); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo))); bo->setURL (url); updateActions(); } @@ -2342,7 +2474,7 @@ typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=(BranchObj*)selection; - QFileDialog *fd=new QFileDialog( this,__VYM " - " +tr("Link to another map")); + Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Link to another map")); fd->addFilter (QString (tr("vym map") + " (*.vym)")); fd->setCaption(__VYM " - " +tr("Link to another map")); if (! bo->getVymLink().isEmpty() ) @@ -2352,7 +2484,7 @@ QString fn; if ( fd->exec() == QDialog::Accepted ) { - saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile())); + saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile())); bo->setVymLink (fd->selectedFile() ); updateActions(); mapCenter->reposition(); @@ -2368,7 +2500,7 @@ typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=(BranchObj*)selection; - saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo))); + saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo))); bo->setVymLink ("" ); updateActions(); mapCenter->reposition(); @@ -2396,7 +2528,7 @@ oo->setHideInExport(true); s="Set"; } - saveState(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand + saveStateComplete(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand actionEditToggleHideExport->setOn (oo->hideInExport()); updateActions(); mapCenter->reposition(); @@ -2416,6 +2548,24 @@ } +QStringList MapEditor::getVymLinks() +{ + QStringList links; + if (selection && (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj)) ) + { + BranchObj *bo=(BranchObj*)selection; + bo=bo->first(); + while (bo) + { + if (!bo->getVymLink().isEmpty()) links.append( bo->getVymLink()); + bo=bo->next(); + } + } + return links; +} + + void MapEditor::removeBranchKeepChilds() { if (selection && (typeid(*selection) == typeid(BranchObj) )) @@ -2424,9 +2574,9 @@ BranchObj* par=(BranchObj*)(bo->getParObj()); QString s=QString("Remove %1 and keep its childs").arg(getName(bo)); if (bo->getDepth()==1) - saveState(s); + saveStateComplete(s); else - saveState(selection->getParObj(),s); // TODO undoCommand + saveStatePart(selection->getParObj(),s); // TODO undoCommand QString sel=selection->getSelectString(); unselect(); par->removeBranchHere(bo); @@ -2439,7 +2589,7 @@ { if (selection && (typeid(*selection) == typeid(BranchObj) )) { - saveState(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection))); + saveStatePart(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection))); ((BranchObj*)selection)->removeChilds(); mapCenter->reposition(); } @@ -2455,8 +2605,8 @@ // Calc some stats QString stats; int i=0; - QCanvasItemList l=canvas()->allItems(); - for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) + Q3CanvasItemList l=canvas()->allItems(); + for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) i++; stats+=QString ("%1 items on canvas\n").arg (i,6); @@ -2483,7 +2633,7 @@ // Finally show dialog if (dia.exec() == QDialog::Accepted) { - saveState("Edit info about map"); //TODO undoCommand + saveStateComplete("Edit info about map"); //TODO undoCommand mapCenter->setAuthor (dia.getAuthor() ); mapCenter->setComment (dia.getComment() ); } @@ -2521,8 +2671,16 @@ pix.fill( defLinkColor ); actionFormatLinkColor->setIconSet( pix ); - actionEditUndo->setEnabled( mapChanged ); actionFileSave->setEnabled( mapUnsaved ); + if (undoSet.readNumEntry("/history/undosAvail",0)>0) + actionEditUndo->setEnabled( true); + else + actionEditUndo->setEnabled( false); + + if (undoSet.readNumEntry("/history/redosAvail",0)>0) + actionEditRedo->setEnabled( true); + else + actionEditRedo->setEnabled( false); if (selection) { @@ -2533,17 +2691,14 @@ // Take care of links if (bo->countXLinks()==0) { - branchLinksContextMenu->clear(); - branchLinksContextMenu->insertItem ("No xLink available"); - branchLinksContextMenuDup->clear(); - branchLinksContextMenuDup->insertItem ("No xLink available"); - + branchXLinksContextMenuEdit->clear(); + branchXLinksContextMenuFollow->clear(); } else { BranchObj *bot; QString s; - branchLinksContextMenu->clear(); - branchLinksContextMenuDup->clear(); + branchXLinksContextMenuEdit->clear(); + branchXLinksContextMenuFollow->clear(); for (int i=0; i<=bo->countXLinks();i++) { bot=bo->XLinkTargetAt(i); @@ -2552,8 +2707,8 @@ s=bot->getHeading(); if (s.length()>25) s=s.left(25)+"..."; - branchLinksContextMenu->insertItem (s); - branchLinksContextMenuDup->insertItem (s); + branchXLinksContextMenuFollow->addAction (s); + branchXLinksContextMenuEdit->addAction (s); } } } @@ -2629,7 +2784,7 @@ if ( (typeid(*selection) == typeid(FloatImageObj)) ) { FloatObj *fo=(FloatImageObj*)selection; - standardFlagsDefault->setEnabled (false); +//FIXME do this in mainwindow standardFlagsDefault->setEnabled (false); actionEditOpenURL->setEnabled (false); actionEditOpenVymLink->setEnabled (false); @@ -2652,7 +2807,7 @@ } else { - standardFlagsDefault->setEnabled (false); +//FIXME do this in mainwindow standardFlagsDefault->setEnabled (false); actionEditCopy->setEnabled (false); actionEditCut->setEnabled (false); @@ -2684,7 +2839,7 @@ { linkstyle=ls; - saveState("Set link style"); // TODO undoCommand + saveStateComplete("Set link style"); // TODO undoCommand BranchObj *bo; bo=mapCenter->first(); bo=bo->next(); @@ -2772,13 +2927,10 @@ void MapEditor::selectLinkColor() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - QColor col = QColorDialog::getColor( defLinkColor, this ); if ( !col.isValid() ) return; setLinkColor( col ); - saveState(QString("Set link color to %1").arg(col.name())); //TODO undoCommand + saveStateComplete(QString("Set link color to %1").arg(col.name())); //TODO undoCommand } @@ -2794,7 +2946,7 @@ s="Unscroll"; else s="Scroll"; - saveState(selection, QString ("%1 %2").arg(s).arg(getName(bo))); + saveStatePart(selection, QString ("%1 %2").arg(s).arg(getName(bo))); bo->toggleScroll(); adjustCanvasSize(); canvas()->update(); @@ -2820,13 +2972,13 @@ { BranchObj *bo=((BranchObj*)selection); - QFileDialog *fd=new QFileDialog( this); - fd->setMode (QFileDialog::ExistingFiles); + Q3FileDialog *fd=new Q3FileDialog( this); + 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( QFileDialog::Contents ); + fd->setPreviewMode( Q3FileDialog::Contents ); fd->setCaption(__VYM " - " +tr("Load image")); fd->setDir (lastImageDir); fd->show(); @@ -2834,8 +2986,9 @@ QString fn; if ( fd->exec() == QDialog::Accepted ) { - saveState(selection, QString("Add floatimage to %1").arg(getName(selection))); - lastImageDir=fn.left(fn.findRev ("/")); + saveStatePart(selection, QString("Add floatimage to %1").arg(getName(selection))); + // FIXME in QT4 use: lastImageDir=fd->directory(); + lastImageDir=QDir (fd->dirPath()); QStringList flist = fd->selectedFiles(); QStringList::Iterator it = flist.begin(); while( it != flist.end() ) @@ -2857,26 +3010,18 @@ } } -void MapEditor::saveFloatImage (int item) +void MapEditor::saveFloatImage () { if (selection && (typeid(*selection) == typeid(FloatImageObj)) ) { FloatImageObj *fio=((FloatImageObj*)selection); - const char* fmt = saveImageFormatMenu->text(item); - - QFileDialog *fd=new QFileDialog( this, tr("vym - save image as") + fmt); - fd->addFilter ("PNG (*.png)"); - fd->addFilter ("BMP (*.bmp)"); - fd->addFilter ("XBM (*.xbm)"); - fd->addFilter ("JPG (*.jpg)"); - fd->addFilter ("XPM (*.xpm)"); - fd->addFilter ("GIF (*.gif)"); - fd->addFilter ("PNM (*.pnm)"); - fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)")); - fd->setCaption(__VYM " - " +tr("Save image as %1").arg(fmt)); - fd->setMode( QFileDialog::AnyFile ); - fd->setSelection (fio->getOriginalFilename()); + QFileDialog *fd=new QFileDialog( this); + fd->setFilters (imageIO.getFilters()); + fd->setCaption(__VYM " - " +tr("Save image")); + fd->setFileMode( QFileDialog::AnyFile ); + fd->setDirectory (lastImageDir); +// fd->setSelection (fio->getOriginalFilename()); fd->show(); QString fn; @@ -2905,7 +3050,7 @@ break; } } - fio->save (fd->selectedFile(),fmt); + fio->save (fd->selectedFile(),imageIO.getType (fd->selectedFilter() ) ); } } } @@ -2949,7 +3094,7 @@ selection->setHideLinkUnselected(b); } -void MapEditor::importDir(BranchObj *dst, QDir d) +void MapEditor::importDirInt(BranchObj *dst, QDir d) { if (selection && (typeid(*selection) == typeid(BranchObj)) || @@ -2959,45 +3104,42 @@ // Traverse directories d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks ); - const QFileInfoList *dirlist = d.entryInfoList(); - QFileInfoListIterator itdir( *dirlist ); - QFileInfo *fi; - - while ( (fi = itdir.current()) != 0 ) + QFileInfoList list = d.entryInfoList(); + QFileInfo fi; + + for (int i = 0; i < list.size(); ++i) { - if (fi->fileName() != "." && fi->fileName() != ".." ) + fi=list.at(i); + if (fi.fileName() != "." && fi.fileName() != ".." ) { dst->addBranch(); bo=dst->getLastBranch(); - bo->setHeading (fi->fileName() ); + 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())); + 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 - importDir (bo,d); + importDirInt (bo,d); d.cdUp(); } } - ++itdir; } // Traverse files d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks ); - const QFileInfoList *filelist = d.entryInfoList(); - QFileInfoListIterator itfile( *filelist ); - - while ( (fi = itfile.current()) != 0 ) + 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->setHeading (fi.fileName() ); bo->setColor (QColor("black")); - if (fi->fileName().right(4) == ".vym" ) - bo->setVymLink (fi->filePath()); - - ++itfile; + if (fi.fileName().right(4) == ".vym" ) + bo->setVymLink (fi.filePath()); } } } @@ -3008,8 +3150,8 @@ (typeid(*selection) == typeid(BranchObj)) || (typeid(*selection) == typeid(MapCenterObj)) ) { - QFileDialog *fd=new QFileDialog( this,__VYM " - " +tr("Choose directory structure to import")); - fd->setMode (QFileDialog::DirectoryOnly); + Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Choose directory structure to import")); + fd->setMode (Q3FileDialog::DirectoryOnly); fd->addFilter (QString (tr("vym map") + " (*.vym)")); fd->setCaption(__VYM " - " +tr("Choose directory structure to import")); fd->show(); @@ -3018,7 +3160,7 @@ if ( fd->exec() == QDialog::Accepted ) { BranchObj *bo=((BranchObj*)selection); - importDir (bo,QDir(fd->selectedFile()) ); + importDirInt (bo,QDir(fd->selectedFile()) ); mapCenter->reposition(); adjustCanvasSize(); canvas()->update(); @@ -3045,6 +3187,7 @@ void MapEditor::editXLink(int i) { + qDebug ("ko."); //FIXME Huh? if (selection && (typeid(*selection) == typeid(BranchObj)) || (typeid(*selection) == typeid(MapCenterObj)) ) @@ -3064,7 +3207,7 @@ } if (dia.deleteXLink()) ((BranchObj*)selection)->deleteXLinkAt(i); - saveState("Edit xLink"); //TODO undoCommand + saveStateComplete("Edit xLink"); //TODO undoCommand } } } @@ -3074,33 +3217,44 @@ { cout << "MapEditor::testFunction() called\n"; - mapCenter->positionBBox(); +/* + bool ok; + QString text = QInputDialog::getText( + this, + tr("QInputDialog::getText()"), + tr("User name:"), QLineEdit::Normal, + QDir::home().dirName(), &ok, Qt::FramelessWindowHint); +*/ + + QDialog *d =new QDialog(NULL); + QLineEdit *le=new QLineEdit (d); +// d->setModal (true); + d->setWindowFlags (Qt::FramelessWindowHint); + le->setFocus(); + le->setText ("Foo"); + le->selectAll(); + connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); + d->exec(); + qWarning( le->text()); return; - + + + +/* WarningDialog dia; dia.setCancelButton (true); dia.setText("This is a longer \nWarning"); dia.setCaption("Warning: Flux problem"); - dia.setShowAgainName("/vym/warnings/mapeditor"); + dia.setShowAgainName("/warnings/mapeditor"); + dia.setWindowFlags (Qt::FramelessWindowHint); if (dia.exec()==QDialog::Accepted) cout << "accepted!\n"; else cout << "canceled!\n"; return; - - QString ub=vymBaseDir.path()+"/scripts/update-bookmarks"; - QProcess *proc = new QProcess( this ); - proc->addArgument(ub); - - if ( !proc->start() ) - { - QMessageBox::warning(0, - tr("Warning"), - tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub)); - } - - -/* +*/ + +/* Hide hidden stuff temporary, maybe add this as regular function somewhere if (hidemode==HideNone) { setHideTmpMode (HideExport); @@ -3199,15 +3353,12 @@ void MapEditor::contentsMousePressEvent(QMouseEvent* e) { // Ignore right clicks, these will go to context menus - if (e->button() == QMouseEvent::RightButton ) + if (e->button() == Qt::RightButton ) { e->ignore(); return; } - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - QPoint p = inverseWorldMatrix().map(e->pos()); LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL); @@ -3222,10 +3373,10 @@ if (!foname.isEmpty()) { // systemFlag clicked - select (lmo); + selectInt (lmo); if (foname=="url") { - if (e->state() & QMouseEvent::ControlButton) + if (e->state() & Qt::ControlModifier) mainWindow->editOpenURLTab(); else mainWindow->editOpenURL(); @@ -3245,7 +3396,7 @@ // No system flag clicked, take care of modmodes // Special case: CTRL is pressed - if (e->state() & QMouseEvent::ControlButton) + if (e->state() & Qt::ControlModifier) { if (actionModModeColor->isOn()) { @@ -3280,19 +3431,20 @@ } if (lmo) { - select (lmo); + selectInt (lmo); // Left Button Move Branches - if (e->button() == QMouseEvent::LeftButton ) + if (e->button() == Qt::LeftButton ) { movingObj_start.setX( p.x() - selection->x() ); movingObj_start.setY( p.y() - selection->y() ); movingObj_orgPos.setX (lmo->x() ); movingObj_orgPos.setY (lmo->y() ); + movingObj_orgRelPos=lmo->getRelPos(); // If modMode==copy, then we want to "move" the _new_ object around // then we need the offset from p to the _old_ selection, because of tmp if (actionModModeCopy->isOn() && - e->state() & QMouseEvent::ControlButton) + e->state() & Qt::ControlModifier) { if (typeid(*selection)==typeid(BranchObj) ) { @@ -3309,13 +3461,13 @@ // Middle Button Toggle Scroll // (On Mac OS X this won't work, but we still have // a button in the toolbar) - if (e->button() == QMouseEvent::MidButton ) + if (e->button() == Qt::MidButton ) toggleScroll(); updateActions(); } else { // No MapObj found, we are on the Canvas itself // Left Button move Pos of CanvasView - if (e->button() == QMouseEvent::LeftButton ) + if (e->button() == Qt::LeftButton ) { movingObj=NULL; // move Content not Obj movingObj_start=e->globalPos(); @@ -3353,16 +3505,13 @@ if (typeid(*selection) == typeid(FloatImageObj)) { FloatObj *fo=(FloatObj*)selection; - saveState( - "move "+qpointToString(movingObj_orgPos),fo->getSelectString() , - QString("Move %1").arg(getName(selection))); fo->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); fo->setRelPos(); fo->reposition(); // Relink float to new mapcenter or branch, if shift is pressed // Only relink, if selection really has a new parent - if ( (e->state() & QMouseEvent::ShiftButton) && lmo && + if ( (e->state() & Qt::ShiftModifier) && lmo && ( (typeid(*lmo)==typeid(BranchObj)) || (typeid(*lmo)==typeid(MapCenterObj)) ) && ( lmo != fo->getParObj()) @@ -3370,7 +3519,8 @@ { if (typeid(*fo) == typeid(FloatImageObj)) { - saveState(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) ); + //TODO undocom + saveStateComplete(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) ); FloatImageObj *fio=(FloatImageObj*)(fo); ((BranchObj*)(lmo))->addFloatImage (fio); fio->unselect(); @@ -3387,7 +3537,7 @@ { if (lmosel->getDepth()==0) { - if (e->state() == (LeftButton | !ShiftButton)) + if (e->state() == Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) // If mapCenter is moved, move all the rest by default, too. mapCenter->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); else @@ -3417,12 +3567,12 @@ (typeid(*lmo) == typeid(MapCenterObj) ) ) ) { - if (e->state() & QMouseEvent::ControlButton) + if (e->state() & Qt::ControlModifier) { // Special case: CTRL to link below lmo lmosel->setParObjTmp (lmo,p,+1); } - else if (e->state() & QMouseEvent::ShiftButton) + else if (e->state() & Qt::ShiftModifier) lmosel->setParObjTmp (lmo,p,-1); else lmosel->setParObjTmp (lmo,p,0); @@ -3466,12 +3616,12 @@ if (pickingColor) { pickingColor=false; - setCursor (ArrowCursor); + setCursor (Qt::ArrowCursor); // Check if we are over another branch dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), NULL); if (dst && selection) { - if (e->state() & QMouseEvent::ShiftButton) + if (e->state() & Qt::ShiftModifier) { ((BranchObj*)selection)->setColor (((BranchObj*)(dst))->getColor()); ((BranchObj*)selection)->setLinkColor (); @@ -3496,7 +3646,7 @@ tmpXLink->setEnd ( ((BranchObj*)(dst)) ); tmpXLink->updateXLink(); tmpXLink->activate(); - saveState(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //TODO undoCommand + saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //TODO undoCommand } else { delete(tmpXLink); @@ -3511,6 +3661,14 @@ // Moved FloatObj? Maybe we need to reposition if(typeid(*selection)==typeid (FloatImageObj)) { + FloatImageObj *fo=(FloatImageObj*)selection; + QString pold=qpointToString(movingObj_orgRelPos); + QString pnow=qpointToString(fo->getRelPos()); + saveStateConstSelection( + "moveRel "+pold, + "moveRel "+pnow, + QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow)); + selection->getParObj()->requestReposition(); mapCenter->reposition(); } @@ -3532,41 +3690,64 @@ // Reset the temporary drawn link to the original one ((LinkableMapObj*)selection)->unsetParObjTmp(); + // For Redo we may need to save original selection + QString preSelStr=selection->getSelectString(); copyingObj=false; if (dst ) { - BranchObj* bs=((BranchObj*)selection); + BranchObj* bsel=(BranchObj*)selection; + BranchObj* bdst=(BranchObj*)dst; + + QString preParStr=(bsel->getParObj())->getSelectString(); + QString preNum=QString::number (bsel->getNum(),10); + QString preDstParStr; + + if (e->state() & Qt::ShiftModifier && dst->getParObj()) + { // Link above dst + preDstParStr=dst->getParObj()->getSelectString(); + bsel->moveBranchTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()); + } else + if (e->state() & Qt::ControlModifier && dst->getParObj()) + { + // Link below dst + preDstParStr=dst->getParObj()->getSelectString(); + bsel->moveBranchTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()+1); + } else + { // Append to dst + preDstParStr=dst->getSelectString(); + bsel->moveBranchTo (bdst,-1); + if (dst->getDepth()==0) bsel->move (savePos); + } + QString postSelStr=selection->getSelectString(); + QString postNum=QString::number (bsel->getNum(),10); + QString undoCom="linkBranchToPos (\""+ - (bs->getParObj())->getSelectString()+ - "\","+ - QString("%1").arg(bs->getNum())+ - ","+ - QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ - ")"; - // TODO we also could check, if dest and src are on same branch, - // then it would be sufficient to saveState of this branch - - // Modifiers allow to insert above/below dst - if (e->state() & QMouseEvent::ShiftButton) - { - bs->moveBranchTo ( (BranchObj*)(dst->getParObj()), ((BranchObj*)(dst))->getNum()); - } else - if (e->state() & QMouseEvent::ControlButton) - { - bs->moveBranchTo ( (BranchObj*)(dst->getParObj()), ((BranchObj*)(dst))->getNum()+1); - } else - { - bs->moveBranchTo ((BranchObj*)(dst),-1); - if (dst->getDepth()==0) - bs->move (savePos); - } - saveState (undoCom,bs->getSelectString(),QString("Relink %1 to %2").arg(getName(bs)).arg(getName(dst)) ); + preParStr+ "\"," + preNum +"," + + QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ ")"; + + QString redoCom="linkBranchToPos (\""+ + preDstParStr + "\"," + postNum + "," + + QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+ ")"; + + saveState ( + postSelStr,undoCom, + preSelStr, redoCom, + QString("Relink %1 to %2").arg(getName(bsel)).arg(getName(dst)) ); } else if (selection->getDepth()==1) - // If we have moved mainbranch only save endposition - saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString(), QString("Move %1 to %2").arg(getName(selection)).arg(qpointToString(movingObj_orgPos))); + { + // The select string might be different _after_ moving around. + // Therefor reposition and then use string of old selection, too + mapCenter->reposition(); + + QString ps=qpointToString ( ((BranchObj*)selection)->getRelPos() ); + saveState( + selection->getSelectString(), "moveRel "+qpointToString(movingObj_orgRelPos), + preSelStr, "moveRel "+ps, + QString("Move %1 to relative position %2").arg(getName(selection)).arg(ps)); + } // Draw the original link, before selection was moved around mapCenter->reposition(); } @@ -3574,18 +3755,18 @@ adjustCanvasSize(); canvas()->update(); movingObj=NULL; + + // Just make sure, that actions are still ok,e.g. the move branch up/down buttons... + updateActions(); } else // maybe we moved View: set old cursor - setCursor (ArrowCursor); + setCursor (Qt::ArrowCursor); } void MapEditor::contentsMouseDoubleClickEvent(QMouseEvent* e) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - - if (e->button() == QMouseEvent::LeftButton ) + if (e->button() == Qt::LeftButton ) { QPoint p = inverseWorldMatrix().map(e->pos()); LinkableMapObj *lmo=mapCenter->findMapObj(p, NULL); @@ -3594,14 +3775,14 @@ if (selection) selection->unselect(); selection=lmo; selection->select(); - editHeading(); + mainWindow->editHeading(); } } } void MapEditor::resizeEvent (QResizeEvent* e) { - QCanvasView::resizeEvent( e ); + Q3CanvasView::resizeEvent( e ); adjustCanvasSize(); } @@ -3616,7 +3797,7 @@ (typeid(*selection) == typeid(MapCenterObj))) { // If QImageDrag can decode mime type - if (QImageDrag::canDecode(event)) { + if (Q3ImageDrag::canDecode(event)) { event->accept(); return; } @@ -3629,7 +3810,7 @@ } // If QUriDrag can decode mime type - if (QUriDrag::canDecode(event)) { + if (Q3UriDrag::canDecode(event)) { event->accept(); return; } @@ -3641,7 +3822,7 @@ } // If QTextDrag can decode mime type - if (QTextDrag::canDecode(event)) { + if (Q3TextDrag::canDecode(event)) { event->accept(); return; } @@ -3667,12 +3848,12 @@ (typeid(*selection) == typeid(MapCenterObj))) { bool update=false; - QStrList uris; + Q3StrList uris; QString heading; if (event->provides("image/png")) { QPixmap pix; - if (QImageDrag::decode(event, pix)) + if (Q3ImageDrag::decode(event, pix)) { addFloatImage(pix); event->accept(); @@ -3691,7 +3872,7 @@ update=true; } else if (event->provides ("text/uri-list")) { // Uris provided e.g. by konqueror - QUriDrag::decode (event,uris); + Q3UriDrag::decode (event,uris); } else if (event->provides ("_NETSCAPE_URL")) { // Uris provided by Mozilla QStringList l = QStringList::split("\n", event->encodedData("_NETSCAPE_URL")); @@ -3737,8 +3918,9 @@ bo=((BranchObj*)selection)->addBranch(); if (bo) { - s=QUriDrag::uriToLocalFile(u); - if (s) { + s=Q3UriDrag::uriToLocalFile(u); + if (!s.isEmpty()) + { QString file = QDir::convertSeparators(s); heading = QFileInfo(file).baseName(); files.append(file); @@ -3746,12 +3928,13 @@ bo->setVymLink(file); else bo->setURL(u); - } else { + } else + { urls.append (u); bo->setURL(u); } - if (heading) + if (!heading.isEmpty()) bo->setHeading(heading); else bo->setHeading(u); @@ -3763,7 +3946,7 @@ if (update) { //FIXME saveState has to be called earlier for each of the drops... - saveState("Drop Event"); //TODO undo Command + saveStateComplete("Drop Event"); //TODO undo Command mapCenter->reposition(); adjustCanvasSize(); canvas()->update(); @@ -3778,7 +3961,7 @@ (typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=((BranchObj*)selection); - saveState(selection,QString("Add floatimage to %1").arg(getName(bo))); + saveStatePart(selection,QString("Add floatimage to %1").arg(getName(bo))); //QString fn=fd->selectedFile(); //lastImageDir=fn.left(fn.findRev ("/")); bo->addFloatImage(); @@ -3792,19 +3975,19 @@ } -void MapEditor::imageDataFetched(const QByteArray &a, QNetworkOperation */*nop*/) +void MapEditor::imageDataFetched(const QByteArray &a, Q3NetworkOperation */*nop*/) { if (!imageBuffer) imageBuffer = new QBuffer(); if (!imageBuffer->isOpen()) { - imageBuffer->open(IO_WriteOnly | IO_Append); + imageBuffer->open(QIODevice::WriteOnly | QIODevice::Append); } imageBuffer->at(imageBuffer->at()+imageBuffer->writeBlock(a)); } -void MapEditor::imageDataFinished(QNetworkOperation *nop) +void MapEditor::imageDataFinished(Q3NetworkOperation *nop) { - if (nop->state()==QNetworkProtocol::StDone) { + if (nop->state()==Q3NetworkProtocol::StDone) { QPixmap img(imageBuffer->buffer()); addFloatImage(img); } @@ -3827,11 +4010,11 @@ delete urlOperator; } - urlOperator = new QUrlOperator(url); - connect(urlOperator, SIGNAL(finished(QNetworkOperation *)), - this, SLOT(imageDataFinished(QNetworkOperation*))); - - connect(urlOperator, SIGNAL(data(const QByteArray &, QNetworkOperation *)), - this, SLOT(imageDataFetched(const QByteArray &, QNetworkOperation *))); + urlOperator = new Q3UrlOperator(url); + connect(urlOperator, SIGNAL(finished(Q3NetworkOperation *)), + this, SLOT(imageDataFinished(Q3NetworkOperation*))); + + connect(urlOperator, SIGNAL(data(const QByteArray &, Q3NetworkOperation *)), + this, SLOT(imageDataFetched(const QByteArray &, Q3NetworkOperation *))); urlOperator->get(); } diff -r 1cc73bd7ee1f -r e95081c21da2 mapeditor.h --- a/mapeditor.h Tue Sep 05 09:47:13 2006 +0000 +++ b/mapeditor.h Tue Sep 05 09:47:14 2006 +0000 @@ -1,32 +1,40 @@ #ifndef MAPEDITOR_H #define MAPEDITOR_H -#include -#include -#include -#include -#include -#include -#include +#include +//#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "mapcenterobj.h" #include "file.h" #include "misc.h" +#include "selection.h" +#include "settings.h" #include "showtextdialog.h" -class QNetworkOperation; -class QUrlOperator; +class Q3NetworkOperation; +class Q3UrlOperator; -class MapEditor : public QCanvasView , public xmlObj { +class MapEditor : public Q3CanvasView , public xmlObj { Q_OBJECT public: - MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, WFlags f=0); + MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, Qt::WFlags f=0); ~MapEditor(); QColor color(); QColor backgroundColor(); MapCenterObj* getMapCenter(); - QCanvas* getCanvas(); + Q3Canvas* getCanvas(); void adjustCanvasSize();// adjust canvas size to map and scrollview bool isRepositionBlocked(); // block while load or undo @@ -34,20 +42,21 @@ QString getName(LinkableMapObj*); // Get e.g. heading or filename void makeTmpDirs(); // create temporary directories QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*); - void saveState(const QString &); // save actual state to backup - void saveState(LinkableMapObj *, const QString &); - void saveState(const QString &, const QString &, const QString &); - void saveState(const QString &, LinkableMapObj *, const QString &); - void saveState(const SaveMode&, const QString &, LinkableMapObj *, const QString &, LinkableMapObj *, const QString &); + void saveStateComplete (const QString &); + void saveStatePart (LinkableMapObj *, const QString &); + void saveStateConstSelection (const QString &, const QString &, const QString &); + void saveStateComData (LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &, LinkableMapObj *); + void saveState(LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &); + void saveState(const QString &, const QString &, const QString &, const QString &, const QString &); + void saveState(const SaveMode&, const QString &, const QString &, const QString &, const QString &, const QString &, LinkableMapObj *); void parseAtom(const QString &); void addFloatImage(const QPixmap &img); private slots: - void finishedLineEdit(); void fetchImage(const QString &img); - void imageDataFetched(const QByteArray &, QNetworkOperation *); - void imageDataFinished(QNetworkOperation *); + void imageDataFetched(const QByteArray &, Q3NetworkOperation *); + void imageDataFinished(Q3NetworkOperation *); public: void toggleHistoryWindow(); @@ -74,8 +83,8 @@ HideTmpMode getHideTmpMode(); // temporary hide stuff public: void setExportMode (bool); // temporary hide stuff during export - void exportImage (QString fn); // export as PNG - void exportImage (QString fn, int); // export in given format + void exportImage (QString fn); // export as PNG + void exportImage (QString fn, QString); // export in given format void exportOOPresentation(const QString &,const QString &); void exportXML(const QString&); // export to directory void clear(); // clear map @@ -89,14 +98,17 @@ public: void paste(); // paste clipboard to branch and backup void cut(); // cut to clipboard and backup - void move(const int &,const int&); + void move (const int &,const int&); + void moveRel (const int &,const int&); void moveBranchUp(); void moveBranchDown(); - void editHeading(); // Start editing heading + QString getHeading (bool &,QPoint &); // Get heading, ok if selection is branch + void setHeading(const QString &); private: - void setHeading(const QString &); // Just set the heading for selection - void setURL(const QString &); // Just set the URL for selection - void setVymLink(const QString &); // Set vymLink for selection + void setHeadingInt(const QString &); + void setURLInt(const QString &); // Just set the URL for selection + void setVymLinkInt(const QString &); // Set vymLink for selection + BranchObj* addNewBranchInt(int); // pos allows to add above/below selection public: void addNewBranch(int); // pos allows to add above/below selection void addNewBranchHere(); // insert and make selection its @@ -104,11 +116,12 @@ LinkableMapObj* getSelection(); // returns selection void unselect(); // before changing current noteedit void reselect(); // after changing current noteedit - bool select(const QString &); // Select + bool select(const QString &); // Select by string + QString getSelectString(); private: - void select(LinkableMapObj*); - void selectNextBranch(); // Increment number of branch - void selectPrevBranch(); // Decrement number of branch + void selectInt(LinkableMapObj*); + void selectNextBranchInt(); // Increment number of branch + void selectPrevBranchInt(); // Decrement number of branch public: void selectUpperBranch(); void selectLowerBranch(); @@ -128,12 +141,14 @@ void findReset(); // Reset Find void editURL(); // edit the URL QString getURL(); // returns URL of selection or "" + QStringList getURLs(); // returns URLs of subtree 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 deleteVymLink(); // delete link to another map QString getVymLink(); // return path to map + QStringList getVymLinks(); // return paths in subtree void toggleHideExport(); // toggle the export flag void removeBranchKeepChilds(); // remove but keep childs void removeChilds(); // remove childs @@ -156,19 +171,20 @@ void toggleScroll(); void unScrollAll(); void loadFloatImage (); - void saveFloatImage (int); + void saveFloatImage (); void setFrame(const FrameType &); void setIncludeImagesVer(bool); void setIncludeImagesHor(bool); void setHideLinkUnselected (bool); bool getHideLinkUnselected (); private: - void importDir(BranchObj *,QDir); + void importDirInt(BranchObj *,QDir); public: void importDir(); void followXLink (int); void editXLink (int); - void testFunction(); // FIXME just testing + void testFunction(); // just testing new stuff + // set /mainwindo/showTestMenu=true... protected: void ensureSelectionVisible(); @@ -182,12 +198,11 @@ virtual void contentsDragEnterEvent(QDragEnterEvent *event); virtual void contentsDropEvent(QDropEvent *event); private: - QCanvas* mapCanvas; + Q3Canvas* mapCanvas; MapCenterObj* mapCenter; bool adjustCanvasRequested; // collect requests until end of user event BranchObj *editingBO; // entering Text into BO - QLineEdit* lineedit; QColor actColor; // actual color QColor defLinkColor; // default color for links @@ -202,12 +217,14 @@ bool drawingLink; // true while creating a link bool copyingObj; // true while creating a link XLinkObj* tmpXLink; - + + Selection xelection; LinkableMapObj* selection; // select a LinkableMapObj LinkableMapObj* selectionLast; // last selection MapObj* movingObj; // moving a MapObj MapObj* linkingObj_src; // part of a link QPoint movingObj_orgPos; // org. pos of mouse before move + QPoint movingObj_orgRelPos; // org. relative pos of mouse before move QPoint movingObj_start; // rel. pos of mouse to absPos QPoint movingCont_start; // inital pos of moving Content or QPoint movingVec; // how far has Content moved @@ -228,13 +245,12 @@ QString fileDir; // dir where file is saved QString destPath; // path to .vym file (needed for vymlinks) QString mapName; // fileName without ".vym" - QString lastImageDir; // save dir for adding images bool isInteractive; // non interactive don't need tmpdirs QString tmpMapDir; // tmp directory with data for undo/redo + QString histPath; // Path to history file int undosTotal; // total number of undos - int undoNum; // current number of bakMapDir to be used - int undosAvail; // how many actions can currently be undone + SimpleSettings undoSet; // undo/redo commands bool blockReposition; // block while load or undo bool blockSaveState; // block while load or undo @@ -246,7 +262,7 @@ void resizeEvent( QResizeEvent * ); - QUrlOperator *urlOperator; + Q3UrlOperator *urlOperator; QDataStream *imageData; QBuffer *imageBuffer; diff -r 1cc73bd7ee1f -r e95081c21da2 mapobj.cpp --- a/mapobj.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/mapobj.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -11,7 +11,7 @@ init (); } -MapObj::MapObj (QCanvas* c) +MapObj::MapObj (Q3Canvas* c) { // cout << "Const MapObj\n"; canvas=c; @@ -45,7 +45,7 @@ bbox.setSize (QSize(other->bbox.width(), other->bbox.height() ) ); } -QCanvas* MapObj::getCanvas() +Q3Canvas* MapObj::getCanvas() { return canvas; } diff -r 1cc73bd7ee1f -r e95081c21da2 mapobj.h --- a/mapobj.h Tue Sep 05 09:47:13 2006 +0000 +++ b/mapobj.h Tue Sep 05 09:47:14 2006 +0000 @@ -1,7 +1,7 @@ #ifndef MAPOBJ_H #define MAPOBJ_H -#include +#include #include #include "misc.h" @@ -20,12 +20,12 @@ class MapObj:public xmlObj { public: MapObj (); - MapObj (QCanvas*); + MapObj (Q3Canvas*); MapObj (MapObj*); virtual ~MapObj (); virtual void init (); virtual void copy (MapObj*); - virtual QCanvas* getCanvas(); + virtual Q3Canvas* getCanvas(); virtual int x(); virtual int y(); virtual int width(); @@ -43,7 +43,7 @@ virtual void positionBBox()=0; virtual void calcBBoxSize()=0; protected: - QCanvas* canvas; + Q3Canvas* canvas; QRect bbox; // bounding box of MO itself QRect clickBox; // area where mouseclicks are found QPoint absPos; // Position on canvas diff -r 1cc73bd7ee1f -r e95081c21da2 misc.cpp --- a/misc.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/misc.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -13,7 +13,8 @@ ostream &operator<< (ostream &stream, QPoint const &p) { - return (stream << qpointToString(p) ); + stream << "("< #include +//Added by qt3to4: +#include enum OptionType {SwitchOption,StringOption}; @@ -30,7 +32,7 @@ -typedef QValueList