# HG changeset patch # User insilmaril # Date 1157546826 0 # Node ID 5391ab620c9552046e3159488665fd9a5747bcd4 # Parent 626fd85b1f6980541895d997685f20d6e17bd73a 1.8.55 New history window and showtextwindow diff -r 626fd85b1f69 -r 5391ab620c95 api.cpp --- a/api.cpp Tue Sep 05 15:05:18 2006 +0000 +++ b/api.cpp Wed Sep 06 12:47:06 2006 +0000 @@ -92,7 +92,7 @@ errorString=e; } -bool API::checkParamCount (const uint &expected) +bool API::checkParamCount (const int &expected) { if (paramList.count()!=expected) { @@ -103,7 +103,7 @@ return noErr; } -bool API::checkParamIsInt(const uint &index) +bool API::checkParamIsInt(const int &index) { bool ok; if (index > paramList.count()) @@ -131,7 +131,7 @@ return 0; } -QString API::parString (bool &ok,const uint &index) +QString API::parString (bool &ok,const int &index) { // return the string at index, this could be also stored in // a variable later diff -r 626fd85b1f69 -r 5391ab620c95 api.h --- a/api.h Tue Sep 05 15:05:18 2006 +0000 +++ b/api.h Wed Sep 06 12:47:06 2006 +0000 @@ -14,10 +14,10 @@ QString errorDesc(); bool error(); void setError (const QString &); - bool checkParamCount (const uint &); - bool checkParamIsInt (const uint &); + bool checkParamCount (const int &); + bool checkParamIsInt (const int &); int parInt (bool &,const uint&); - QString parString(bool &,const uint &); + QString parString(bool &,const int &); private: QString com; QStringList paramList; diff -r 626fd85b1f69 -r 5391ab620c95 branchobj.cpp --- a/branchobj.cpp Tue Sep 05 15:05:18 2006 +0000 +++ b/branchobj.cpp Wed Sep 06 12:47:06 2006 +0000 @@ -804,7 +804,7 @@ // Save FloatImages FloatImageObj *fio; for (fio=floatimage.first(); fio; fio=floatimage.next() ) - s+=fio->saveToDir (tmpdir,prefix,offset); + s+=fio->saveToDir (tmpdir,prefix); // save note if (!note.isEmpty() ) diff -r 626fd85b1f69 -r 5391ab620c95 demos/todo.vym Binary file demos/todo.vym has changed diff -r 626fd85b1f69 -r 5391ab620c95 exports.cpp --- a/exports.cpp Tue Sep 05 15:05:18 2006 +0000 +++ b/exports.cpp Wed Sep 06 12:47:06 2006 +0000 @@ -1,7 +1,6 @@ #include -#include +#include #include -//Added by qt3to4: #include #include "exports.h" @@ -19,16 +18,16 @@ ExportBase::ExportBase() { indentPerDepth=" "; - // Create tmpdir - // 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... + bool ok; + tmpDir.setPath (makeUniqueDir(ok,"/tmp/vym-XXXXXX")); + if (!tmpDir.exists() || !ok) + QMessageBox::critical( 0, QObject::tr( "Error" ), + QObject::tr("Couldn't access temporary directory\n")); } ExportBase::~ExportBase() { - // Remove tmpdir + // Cleanup tmpdir removeDir (tmpDir); } @@ -187,9 +186,9 @@ p.process(); QString ub=vymBaseDir.path()+"/scripts/update-bookmarks"; - QProcess *proc= new QProcess (); + QProcess *proc= new QProcess ; proc->start( ub); - if (!proc->waitForStarted()); + if (!proc->waitForStarted()) { QMessageBox::warning(0, QObject::tr("Warning"), diff -r 626fd85b1f69 -r 5391ab620c95 floatimageobj.cpp --- a/floatimageobj.cpp Tue Sep 05 15:05:18 2006 +0000 +++ b/floatimageobj.cpp Wed Sep 06 12:47:06 2006 +0000 @@ -154,7 +154,7 @@ // TODO } -QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint &p) +QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix) { if (hidden) return ""; diff -r 626fd85b1f69 -r 5391ab620c95 floatimageobj.h --- a/floatimageobj.h Tue Sep 05 15:05:18 2006 +0000 +++ b/floatimageobj.h Wed Sep 06 12:47:06 2006 +0000 @@ -30,7 +30,7 @@ virtual QRect getTotalBBox(); // return BBox including childs virtual QRect getBBoxSizeWithChilds(); // return size of BBox including childs virtual void calcBBoxSizeWithChilds(); // calc size of BBox including childs recursivly - virtual QString saveToDir(const QString &,const QString&, const QPoint &); + virtual QString saveToDir(const QString &,const QString&); virtual void resetSaveCounter(); virtual QString getSelectString(); diff -r 626fd85b1f69 -r 5391ab620c95 headingobj.h --- a/headingobj.h Tue Sep 05 15:05:18 2006 +0000 +++ b/headingobj.h Wed Sep 06 12:47:06 2006 +0000 @@ -31,7 +31,7 @@ protected: QString heading; - uint textwidth; // width for formatting text + int textwidth; // width for formatting text Q3PtrList textline; // a part of e.g. the parabel QColor color; QFont font; diff -r 626fd85b1f69 -r 5391ab620c95 historywindow.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/historywindow.cpp Wed Sep 06 12:47:06 2006 +0000 @@ -0,0 +1,46 @@ +#include "historywindow.h" + +HistoryWindow::HistoryWindow (QWidget *parent):QDialog (parent) +{ + ui.setupUi (this); + ui.historyTable->setRowCount (20); + ui.historyTable->setColumnCount (3); + + + QTableWidgetItem *item; + + item= new QTableWidgetItem(tr("Action")); + ui.historyTable->setHorizontalHeaderItem(0, item); + + item= new QTableWidgetItem(tr("Comment")); + ui.historyTable->setHorizontalHeaderItem(1, item); + + item= new QTableWidgetItem(tr("Undo action")); + ui.historyTable->setHorizontalHeaderItem(2, item); + + ui.historyTable->setSelectionBehavior (QAbstractItemView::SelectRows); +} + + +void HistoryWindow::update(SimpleSettings &set) +{ + //int rows=set.readNumEntry("/history/undosTotal"); + //ui.historyTable->setRowCount (rows); + + int i; + for (i=0;i<= set.readNumEntry("/history/undosAvail",0); i++) + { + QTableWidgetItem *item; + + item= new QTableWidgetItem(set.readEntry(QString("/history/step-%1/redoCommand").arg(i))); + ui.historyTable->setItem(i, 0, item); + + item= new QTableWidgetItem(set.readEntry(QString("/history/step-%1/comment").arg(i))); + ui.historyTable->setItem(i, 1, item); + + item=new QTableWidgetItem(set.readEntry(QString("/history/step-%1/undoCommand").arg(i))); + ui.historyTable->setItem(i, 2, item); + } + + ui.historyTable->resizeColumnsToContents(); +} diff -r 626fd85b1f69 -r 5391ab620c95 historywindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/historywindow.h Wed Sep 06 12:47:06 2006 +0000 @@ -0,0 +1,22 @@ +#ifndef HISTORYWINDOW_H +#define HISTORYWINDOW_H + +#include "settings.h" +#include "ui_historywindow.h" + +///////////////////////////////////////////////////////////////////////////// +class HistoryWindow:public QDialog +{ + Q_OBJECT + +public: + HistoryWindow(QWidget* parent = 0); + void update (SimpleSettings &); + + +private: + Ui::HistoryWindow ui; +}; + + +#endif diff -r 626fd85b1f69 -r 5391ab620c95 historywindow.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/historywindow.ui Wed Sep 06 12:47:06 2006 +0000 @@ -0,0 +1,136 @@ + + + + + HistoryWindow + + + + 0 + 0 + 1160 + 340 + + + + Dialog + + + + 9 + + + 6 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Redo + + + + + + + Qt::Vertical + + + + 20 + 61 + + + + + + + + + New Row + + + + + Time + + + + + Comment + + + + + + + + Undo + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + Close + + + + + + + + + + + + closeButton + clicked() + HistoryWindow + close() + + + 369 + 253 + + + 179 + 282 + + + + + diff -r 626fd85b1f69 -r 5391ab620c95 imports.cpp --- a/imports.cpp Tue Sep 05 15:05:18 2006 +0000 +++ b/imports.cpp Wed Sep 06 12:47:06 2006 +0000 @@ -14,11 +14,11 @@ ImportBase::ImportBase() { - // Create tmpdir - // FIXME not neededtmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX")); - if (!tmpDir.cd ("tmp")) - qWarning ("Could not access temporary directory for export"); - // FIXME + bool ok; + tmpDir.setPath (makeUniqueDir(ok,"/tmp/vym-XXXXXX")); + if (!tmpDir.exists() || !ok) + QMessageBox::critical( 0, QObject::tr( "Error" ), + QObject::tr("Couldn't access temporary directory\n")); } diff -r 626fd85b1f69 -r 5391ab620c95 linkablemapobj.h --- a/linkablemapobj.h Tue Sep 05 15:05:18 2006 +0000 +++ b/linkablemapobj.h Wed Sep 06 12:47:06 2006 +0000 @@ -85,15 +85,15 @@ // of mapeditor e.g. in noteeditor virtual bool repositionRequested(); - virtual QRect getTotalBBox()=0; // return BBox including childs - virtual QRect getBBoxSizeWithChilds()=0;// return size of BBox including childs + //virtual QRect getTotalBBox(); // return BBox including childs + //virtual QRect getBBoxSizeWithChilds();// return size of BBox including childs virtual void calcBBoxSizeWithChilds()=0;// calc size of BBox including childs recursivly virtual void setSelBox(); virtual void select(); virtual void unselect(); virtual QString getSelectString()=0; - virtual QString saveToDir (const QString&,const QString&, const QPoint&)=0;// Save data to tempdir + //virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data to XML protected: void parabel(Q3PointArray &,double,double,double,double); // Create Parabel connecting two points diff -r 626fd85b1f69 -r 5391ab620c95 mainwindow.cpp --- a/mainwindow.cpp Tue Sep 05 15:05:18 2006 +0000 +++ b/mainwindow.cpp Wed Sep 06 12:47:06 2006 +0000 @@ -30,13 +30,13 @@ #include "exportxhtmldialog.h" #include "file.h" #include "flagrowobj.h" +#include "historywindow.h" #include "imports.h" #include "mapeditor.h" #include "misc.h" #include "options.h" #include "process.h" #include "settings.h" -#include "showtextdialog.h" #include "texteditor.h" #include "version.h" @@ -1850,8 +1850,14 @@ me->viewport()->setFocus(); // Create temporary directory for packing - char tmpdir1[]="/tmp/vym-XXXXXX"; - QString tmpMapDir=mkdtemp(tmpdir1); + bool ok; + QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX"); + if (!ok) + { + QMessageBox::critical( 0, tr( "Critical Load Error" ), + tr("Couldn't create temporary directory before load\n")); + return aborted; + } // Try to unzip file err=unzipDir (tmpMapDir,fn); @@ -1945,21 +1951,22 @@ void Main::fileLoad(const LoadMode &lmode) { - Q3FileDialog *fd=new Q3FileDialog( this); + QStringList filters; + filters <<"XML (*.xml)"<<"VYM map (*.vym *.vyp)"; + QFileDialog *fd=new QFileDialog( this); fd->setDir (lastFileDir); - fd->setMode (Q3FileDialog::ExistingFiles); - fd->addFilter ("XML (*.xml)"); - fd->addFilter ("VYM map (*.vym *.vyp)"); + fd->setFileMode (QFileDialog::ExistingFiles); + fd->setFilters (filters); switch (lmode) { case NewMap: - fd->setCaption(tr("Load vym map")); + fd->setCaption(__VYM " - " +tr("Load vym map")); break; case ImportAdd: - fd->setCaption(tr("Import: Add vym map to selection")); + fd->setCaption(__VYM " - " +tr("Import: Add vym map to selection")); break; case ImportReplace: - fd->setCaption(tr("Import: Replace selection with vym map")); + fd->setCaption(__VYM " - " +tr("Import: Replace selection with vym map")); break; } fd->show(); @@ -1967,7 +1974,7 @@ QString fn; if ( fd->exec() == QDialog::Accepted ) { - lastFileDir=fd->dirPath(); + lastFileDir=fd->directory().path(); QStringList flist = fd->selectedFiles(); QStringList::Iterator it = flist.begin(); while( it != flist.end() ) @@ -2052,9 +2059,16 @@ if (saveZipped) { - char tmpdir1[]="/tmp/vym-XXXXXX"; - tmpMapDir=mkdtemp(tmpdir1); - + // Create temporary directory for packing + bool ok; + QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX"); + if (!ok) + { + QMessageBox::critical( 0, tr( "Critical Load Error" ), + tr("Couldn't create temporary directory before save\n")); + return; + } + safeFilePath=me->getFilePath(); me->setFilePath (tmpMapDir+"/"+ me->getMapName()+ ".xml", @@ -3201,7 +3215,9 @@ void Main::testFunction() { - currentMapEditor()->testFunction(); + HistoryWindow hw; + hw.exec(); + //currentMapEditor()->testFunction(); } void Main::helpDoc() diff -r 626fd85b1f69 -r 5391ab620c95 mapcenterobj.cpp --- a/mapcenterobj.cpp Tue Sep 05 15:05:18 2006 +0000 +++ b/mapcenterobj.cpp Wed Sep 06 12:47:06 2006 +0000 @@ -152,7 +152,7 @@ // Save FloatImages FloatImageObj *fio; for (fio=floatimage.first(); fio; fio=floatimage.next() ) - s+=fio->saveToDir (tmpdir,prefix,offset); + s+=fio->saveToDir (tmpdir,prefix); // Save XLinks XLinkObj *xlo; diff -r 626fd85b1f69 -r 5391ab620c95 mapeditor.cpp --- a/mapeditor.cpp Tue Sep 05 15:05:18 2006 +0000 +++ b/mapeditor.cpp Wed Sep 06 12:47:06 2006 +0000 @@ -223,21 +223,15 @@ hidemode=HideNone; - isInteractive=interactive; - if (isInteractive) - // Create temporary files - makeTmpDirs(); + isInteractive=interactive; // FIXME still needed? + + // Create temporary files + makeTmpDirs(); // Initially set movingCentre updateViewCenter(); - // For testing purposes create history window - historyWindow = new ShowTextDialog (this); - historyWindow->setCaption (fileName); - mapCenter->reposition(); // for positioning heading - - } MapEditor::~MapEditor() @@ -352,10 +346,12 @@ s=(((BranchObj*)lmo)->getHeading()); if (s=="") s="unnamed"; - return QString("branch (%1)").arg(s); + return QString("branch (%1)").arg(s); + //return QString("branch (%1)").arg(s); } if ((typeid(*lmo) == typeid(FloatImageObj) )) - return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename()); + return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename()); + //return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename()); return QString("Unknown type has no name!"); } @@ -365,7 +361,7 @@ tmpMapDir=QDir::convertSeparators (tmpVymDir+QString("/mapeditor-%1").arg(mapNum)); histPath=QDir::convertSeparators (tmpMapDir+"/history"); QDir d; - d.mkdir (tmpMapDir,true); + d.mkdir (tmpMapDir); } QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSel) @@ -430,7 +426,7 @@ s+=((BranchObj*)(saveSel))->saveToDir(tmpdir,prefix,offset); else if ( typeid(*saveSel) == typeid(FloatImageObj) ) // Save image - s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix,offset); + s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix); else if (selection && typeid(*selection)==typeid(BranchObj)) // Save selected branch is saved from mainwindow //FIXME maybe use "subtree" above? @@ -545,7 +541,6 @@ /* TODO remove after testing */ cout << "ME::saveState() begin"<append (comment); setChanged(); @@ -609,6 +604,8 @@ cout << " redoCom="<isVisible()) - historyWindow->hide(); + if (historyWindow.isVisible()) + historyWindow.hide(); else - historyWindow->show(); + historyWindow.show(); } @@ -865,7 +862,7 @@ mapName=fileName.left(fileName.findRev(".",-1,true) ); // Adjust history window - historyWindow->setCaption (fileName); + historyWindow.setCaption (__VYM " - " +tr("History for ")+fileName); } } @@ -3040,12 +3037,14 @@ break;; case QMessageBox::Cancel: // do nothing + delete (fd); return; break; } } fio->save (fd->selectedFile(),imageIO.getType (fd->selectedFilter() ) ); } + delete (fd); } } diff -r 626fd85b1f69 -r 5391ab620c95 mapeditor.h --- a/mapeditor.h Tue Sep 05 15:05:18 2006 +0000 +++ b/mapeditor.h Wed Sep 06 12:47:06 2006 +0000 @@ -17,10 +17,10 @@ #include "mapcenterobj.h" #include "file.h" +#include "historywindow.h" #include "misc.h" #include "selection.h" #include "settings.h" -#include "showtextdialog.h" class Q3NetworkOperation; class Q3UrlOperator; @@ -247,7 +247,7 @@ QString mapName; // fileName without ".vym" bool isInteractive; // non interactive don't need tmpdirs - QString tmpMapDir; // tmp directory with data for undo/redo + QString tmpMapDir; // tmp directory with undo history QString histPath; // Path to history file int undosTotal; // total number of undos SimpleSettings undoSet; // undo/redo commands @@ -266,7 +266,7 @@ QDataStream *imageData; QBuffer *imageBuffer; - ShowTextDialog *historyWindow; + HistoryWindow historyWindow; }; #endif diff -r 626fd85b1f69 -r 5391ab620c95 ornamentedobj.cpp --- a/ornamentedobj.cpp Tue Sep 05 15:05:18 2006 +0000 +++ b/ornamentedobj.cpp Wed Sep 06 12:47:06 2006 +0000 @@ -159,7 +159,7 @@ void OrnamentedObj::move2RelPos(double x, double y) { - setRelPos (QPoint(x,y)); + setRelPos (QPoint((int)x,(int)y)); } void OrnamentedObj::move2RelPos(QPoint p) diff -r 626fd85b1f69 -r 5391ab620c95 showtextdialog.ui.h --- a/showtextdialog.ui.h Tue Sep 05 15:05:18 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -void ShowTextDialog::init() -{ - textEdit1->setReadOnly (true); -} - -void ShowTextDialog::setCaption (const QString &t) -{ - QDialog::setCaption ("VYM - " + tr ("History of %1").arg(t)); -} - -void ShowTextDialog::setText(const QString &t) -{ - textEdit1->setText (t); -} - -void ShowTextDialog::append( const QString &t ) -{ - textEdit1->append (t); -}