Added bracket to comfort gcc release-1-12-maintained
authorinsilmaril
Mon, 24 Nov 2008 14:12:01 +0000
branchrelease-1-12-maintained
changeset 531532402be6c2
parent 52 6cd53d63956f
child 54 e47fe0d7b05b
Added bracket to comfort gcc
mapeditor.cpp
texteditor.cpp
     1.1 --- a/mapeditor.cpp	Wed Nov 12 11:15:37 2008 +0000
     1.2 +++ b/mapeditor.cpp	Mon Nov 24 14:12:01 2008 +0000
     1.3 @@ -1814,6 +1814,13 @@
     1.4  		mapChanged=false;
     1.5  		mapUnsaved=false;
     1.6  		autosaveTimer->stop();
     1.7 +		/*
     1.8 +		cout <<"ME::save      filePath="<<filePath.toStdString()<<endl;
     1.9 +		cout <<"ME::save  saveFilePath="<<safeFilePath.toStdString()<<endl;
    1.10 +		cout <<"ME::save      destPath="<<destPath.toStdString()<<endl;
    1.11 +		cout <<"ME::save       mapName="<<mapName.toStdString()<<endl;
    1.12 +		cout <<"ME::save   mapFileName="<<mapFileName.toStdString()<<endl;
    1.13 +		*/
    1.14  	}
    1.15  	else	
    1.16  	{
     2.1 --- a/texteditor.cpp	Wed Nov 12 11:15:37 2008 +0000
     2.2 +++ b/texteditor.cpp	Mon Nov 24 14:12:01 2008 +0000
     2.3 @@ -1,54 +1,19 @@
     2.4  #include "texteditor.h"
     2.5  
     2.6 -#include <qcanvas.h>
     2.7 -#include <qstatusbar.h>
     2.8 -#include <qmessagebox.h>
     2.9 -#include <qaction.h>
    2.10 -#include <qapplication.h>
    2.11 -#include <qpainter.h>
    2.12 -#include <qprinter.h>
    2.13 -#include <qfile.h>
    2.14 -#include <qfiledialog.h>
    2.15 -#include <qtoolbar.h>
    2.16 -#include <qpopupmenu.h>
    2.17 -#include <qmenubar.h>
    2.18 -#include <qtextedit.h>
    2.19 -#include <qaccel.h>
    2.20 -#include <qtextstream.h>
    2.21 -#include <qpaintdevicemetrics.h>
    2.22 -#include <qsettings.h>
    2.23 -#include <qfontdialog.h>
    2.24 -#include <qmessagebox.h>
    2.25 -#include <qcolordialog.h>
    2.26 -#include <qregexp.h>
    2.27 -#include <qlineedit.h>
    2.28 -#include <qsimplerichtext.h>
    2.29 -
    2.30  #include <iostream>
    2.31 -#include <stdlib.h>
    2.32 +#include <cstdlib>
    2.33  #include <typeinfo>
    2.34  
    2.35 -#include "icons/fileopen.xpm"
    2.36 -#include "icons/filesave.xpm"
    2.37 -#include "icons/fileprint.xpm"
    2.38 -#include "icons/editundo.xpm"	
    2.39 -#include "icons/editredo.xpm"	
    2.40 -#include "icons/editcopy.xpm"
    2.41 -#include "icons/editcut.xpm"
    2.42 -#include "icons/editpaste.xpm"
    2.43 -#include "icons/edittrash.xpm"
    2.44 -#include "icons/formatfixedfont.xpm"
    2.45 -#include "icons/formattextbold.xpm"
    2.46 -#include "icons/formattextitalic.xpm"
    2.47 -#include "icons/formattextunder.xpm"
    2.48 -#include "icons/formattextleft.xpm"
    2.49 -#include "icons/formattextcenter.xpm"
    2.50 -#include "icons/formattextright.xpm"
    2.51 -#include "icons/formattextjustify.xpm"
    2.52 +#include "noteobj.h"
    2.53 +#include "settings.h"
    2.54  
    2.55 -extern QCanvas* actCanvas;
    2.56  extern int statusbarTime;
    2.57 -extern QSettings settings;
    2.58 +extern Settings settings;
    2.59 +
    2.60 +extern QAction *actionViewToggleNoteEditor;
    2.61 +
    2.62 +extern QString iconPath;
    2.63 +extern QString vymName;
    2.64  
    2.65  using namespace std;
    2.66  
    2.67 @@ -56,20 +21,28 @@
    2.68  ///////////////////////////////////////////////////////////////////////
    2.69  ///////////////////////////////////////////////////////////////////////
    2.70  
    2.71 +
    2.72  TextEditor::TextEditor()
    2.73  {
    2.74      printer = new QPrinter( QPrinter::HighResolution );
    2.75 +	printer->setPrinterName (settings.value("/mainwindow/printerName",printer->printerName()).toString());
    2.76  
    2.77 -	// Editor
    2.78 -    e = new QTextEdit( this, "editor" );
    2.79 +    e = new QTextEdit( this);
    2.80      e->setFocus();
    2.81 -	e->setTextFormat(RichText);		// default
    2.82 +	e->setTextFormat(Qt::RichText);		// default
    2.83  	e->setTabStopWidth (20);		// unit is pixel
    2.84 -	e->setColor (black);
    2.85 +	e->setColor (Qt::black);
    2.86 +	e->setAutoFillBackground (true);
    2.87  	connect (e, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
    2.88      setCentralWidget( e );
    2.89 -    statusBar()->message( "Ready", statusbarTime);
    2.90 -	setCaption("VYM - Note Editor");
    2.91 +    statusBar()->message( tr("Ready","Statusbar message"), statusbarTime);
    2.92 +	setCaption(vymName +" - " +tr ("Note Editor","Window caption"));
    2.93 +
    2.94 +
    2.95 +	connect(e, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)),
    2.96 +            this, SLOT(formatChanged(const QTextCharFormat &)));
    2.97 +
    2.98 +
    2.99  
   2.100  	// Toolbars
   2.101  	setupFileActions();
   2.102 @@ -78,31 +51,24 @@
   2.103  	setupSettingsActions();
   2.104  	
   2.105  	// Various states
   2.106 -	emptyPaper   = QBrush(gray);
   2.107 -	filledPaper  = QBrush(white);
   2.108 -	inactivePaper= QBrush(black);
   2.109 +	blockChangedSignal=false;
   2.110  	setInactive();
   2.111  
   2.112  	// Load Settings
   2.113 -	resize (settings.readNumEntry( "/vym/noteeditor/geometry/width", 450),
   2.114 -	        settings.readNumEntry( "/vym/noteeditor/geometry/height",600));
   2.115 -	move   (settings.readNumEntry( "/vym/noteeditor/geometry/posX", 150),
   2.116 -	        settings.readNumEntry( "/vym/noteeditor/geometry/posY",  50));
   2.117 +	resize (settings.value ( "/satellite/noteeditor/geometry/size", QSize(450,600)).toSize());
   2.118 +	move   (settings.value ( "/satellite/noteeditor/geometry/pos", QPoint (250,50)).toPoint());
   2.119  	
   2.120 -	if (settings.readEntry( "/vym/noteeditor/showWithMain","yes") =="yes")
   2.121 -		setShowWithMain(true);
   2.122 -	else	
   2.123 -		setShowWithMain(false);
   2.124 +	setShowWithMain (settings.value ( "/satellite/noteeditor/showWithMain",true).toBool());
   2.125  
   2.126 -	varFont.fromString( settings.readEntry 
   2.127 -		("/vym/noteeditor/fonts/varFont",
   2.128 -		"Nimbus Sans l,14,-1,5,48,0,0,0,0,0") 
   2.129 +	varFont.fromString( settings.value
   2.130 +		("/satellite/noteeditor/fonts/varFont",
   2.131 +		"Nimbus Sans l,14,-1,5,48,0,0,0,0,0").toString() 
   2.132  	);
   2.133 -	fixedFont.fromString (settings.readEntry (
   2.134 -		"/vym/noteeditor/fonts/fixedFont",
   2.135 -		"Courier,14,-1,5,48,0,0,0,1,0") 
   2.136 +	fixedFont.fromString (settings.value(
   2.137 +		"/satellite/noteeditor/fonts/fixedFont",
   2.138 +		"Courier,14,-1,5,48,0,0,0,1,0").toString() 
   2.139  	);
   2.140 -	QString s=settings.readEntry ("/vym/noteeditor/fonts/fonthintDefault","variable");
   2.141 +	QString s=settings.value ("/satellite/noteeditor/fonts/fonthintDefault","variable").toString();
   2.142  	if (s == "fixed")
   2.143  	{	
   2.144  		actionSettingsFonthintDefault->setOn (true);
   2.145 @@ -112,6 +78,13 @@
   2.146  		actionSettingsFonthintDefault->setOn (false);
   2.147  		e->setCurrentFont (varFont);
   2.148  	}	
   2.149 +	filenameHint="";
   2.150 +
   2.151 +	// Restore position of toolbars
   2.152 +	restoreState (settings.value("/satellite/noteeditor/state",0).toByteArray());
   2.153 +
   2.154 +	// Save settings in vymrc
   2.155 +	settings.setValue("/mainwindow/printerName",printer->printerName());
   2.156  }
   2.157  
   2.158  
   2.159 @@ -119,31 +92,27 @@
   2.160  {
   2.161      if (printer) delete printer;
   2.162  	// Save Settings
   2.163 -	settings.writeEntry( "/vym/noteeditor/geometry/width", width() );
   2.164 -	settings.writeEntry( "/vym/noteeditor/geometry/height", height() );
   2.165 -	settings.writeEntry( "/vym/noteeditor/geometry/posX", pos().x() );
   2.166 -	settings.writeEntry( "/vym/noteeditor/geometry/posY", pos().y() );
   2.167 +	settings.setValue( "/satellite/noteeditor/geometry/size", size() );
   2.168 +	settings.setValue( "/satellite/noteeditor/geometry/pos", pos() );
   2.169 +	settings.setValue ("/satellite/noteeditor/state",saveState(0));
   2.170  	
   2.171 -	if (showWithMain())
   2.172 -		settings.writeEntry( "/vym/noteeditor/showWithMain","yes");
   2.173 -	else	
   2.174 -		settings.writeEntry( "/vym/noteeditor/showWithMain","no");
   2.175 +	settings.setValue( "/satellite/noteeditor/showWithMain",showwithmain);
   2.176  
   2.177  	QString s;
   2.178  	if (actionSettingsFonthintDefault->isOn() )
   2.179  		s="fixed";
   2.180  	else	
   2.181  		s="variable";
   2.182 -	settings.writeEntry( "/vym/noteeditor/fonts/fonthintDefault",s );
   2.183 -	settings.writeEntry ("/vym/noteeditor/fonts/varFont",
   2.184 -		varFont.toString() );
   2.185 -	settings.writeEntry ("/vym/noteeditor/fonts/fixedFont",
   2.186 -		fixedFont.toString() );
   2.187 +	settings.setValue( "/satellite/noteeditor/fonts/fonthintDefault",s );
   2.188 +	settings.setValue("/satellite/noteeditor/fonts/varFont", varFont.toString() );
   2.189 +	settings.setValue("/satellite/noteeditor/fonts/fixedFont", fixedFont.toString() );
   2.190 +
   2.191 +
   2.192  }
   2.193  
   2.194  bool TextEditor::isEmpty()
   2.195  {
   2.196 -	if (e->text().length())
   2.197 +	if (e->toPlainText().length()>0)
   2.198  		return false;
   2.199  	else
   2.200  		return true;
   2.201 @@ -159,6 +128,7 @@
   2.202  	return showwithmain;
   2.203  }
   2.204  
   2.205 +
   2.206  void TextEditor::setFontHint (const QString &fh)
   2.207  {
   2.208  	if (fh=="fixed")
   2.209 @@ -187,16 +157,18 @@
   2.210  void TextEditor::setFilename(const QString &fn)
   2.211  {
   2.212  	if (state==filledEditor)
   2.213 +	{
   2.214  		if (fn.isEmpty() )
   2.215  		{
   2.216  			filename="";
   2.217 -			statusBar()->message( "No filename available for this note.", statusbarTime );
   2.218 +			statusBar()->message( tr("No filename available for this note.","Statusbar message"), statusbarTime );
   2.219  		}	
   2.220  		else
   2.221  		{
   2.222  			filename=fn;
   2.223 -			statusBar()->message( QString( "Current filename is %1" ).arg( filename ), statusbarTime );
   2.224 +			statusBar()->message( tr(QString( "Current filename is %1" ).arg( filename ),"Statusbar message"), statusbarTime );
   2.225  		}	
   2.226 +	}	
   2.227  }
   2.228  
   2.229  QString TextEditor::getFilename()
   2.230 @@ -204,10 +176,19 @@
   2.231  	return filename;
   2.232  }
   2.233  
   2.234 -bool TextEditor::findText(const QString &t, const bool &cs)
   2.235 +void TextEditor::setFilenameHint(const QString &fnh)
   2.236  {
   2.237 -	bool wo=false;	// word matches
   2.238 -	if (e->find (t, cs, wo, true, 0, 0 ))
   2.239 +	filenameHint=fnh;
   2.240 +}
   2.241 +
   2.242 +QString TextEditor::getFilenameHint()
   2.243 +{
   2.244 +	return filenameHint;
   2.245 +}
   2.246 +
   2.247 +bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags)
   2.248 +{
   2.249 +	if (e->find (t,flags))
   2.250  		return true;
   2.251  	else	
   2.252  		return false;
   2.253 @@ -215,210 +196,257 @@
   2.254  
   2.255  void TextEditor::setupFileActions()
   2.256  {
   2.257 -    QToolBar *tb = new QToolBar( this );
   2.258 -    tb->setLabel( "File Actions" );
   2.259 -    QPopupMenu *menu = new QPopupMenu( this );
   2.260 -    menuBar()->insertItem( tr( "&File" ), menu );
   2.261 +    QToolBar *tb = addToolBar ( tr("Note Actions") );
   2.262 +	tb->setObjectName ("noteEditorFileActions");
   2.263 +    QMenu *fileMenu = menuBar()->addMenu( tr( "&Note","Menubar" ));
   2.264  
   2.265      QAction *a;
   2.266 -    a = new QAction( tr( "Import" ), QPixmap( fileopen_xpm), tr( "&Import..." ), CTRL + Key_O, this, "fileImport" );
   2.267 +    a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Import..." ),this);
   2.268 +	a->setStatusTip (tr( "Import","Status tip for Note menu" ) );
   2.269 +	a->setShortcut( Qt::CTRL + Qt::Key_O );
   2.270      connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) );
   2.271 -	a->setEnabled(false);
   2.272 -    a->addTo( tb );
   2.273 -    a->addTo( menu );
   2.274 +	tb->addAction (a);
   2.275 +	fileMenu->addAction (a);
   2.276  	actionFileLoad=a;
   2.277  
   2.278 -    menu->insertSeparator();
   2.279 -    a = new QAction( tr( "Export Note (HTML)" ), QPixmap( filesave_xpm ), tr( "&Export..." ), CTRL + Key_S, this, "fileSave" );
   2.280 +    fileMenu->addSeparator();
   2.281 +    a = new QAction( QPixmap(iconPath+"filesave.png" ), tr( "&Export..." ),this);
   2.282 +	a->setStatusTip (tr( "Export Note (HTML)","Status tip for Note menu" ) );
   2.283 +	a->setShortcut( Qt::CTRL + Qt::Key_S );
   2.284      connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) );
   2.285 -    a->addTo( tb );
   2.286 -    a->addTo( menu );
   2.287 +	tb->addAction (a);
   2.288 +	fileMenu->addAction (a);
   2.289  	actionFileSave=a;
   2.290  	
   2.291 -    a = new QAction( tr( "Export Note As (HTML) " ), QPixmap(), tr( "Export &As... (HTML)" ), 0, this, "exportHTML" );
   2.292 +    a = new QAction(  QPixmap(), tr( "Export &As... (HTML)" ), this);
   2.293 +	a->setStatusTip (tr( "Export Note As (HTML) ","Status tip for Note Menu"  ));
   2.294      connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) );
   2.295 -    a->addTo( menu );
   2.296 +	fileMenu->addAction (a);
   2.297  	actionFileSaveAs=a;
   2.298  
   2.299 -    a = new QAction( tr( "Export Note As (ASCII) " ), QPixmap(), tr( "Export &As...(ASCII)" ), ALT + Key_X, this, "exportASCII" );
   2.300 +    a = new QAction(QPixmap(), tr( "Export &As...(ASCII)" ), this);
   2.301 +	a->setStatusTip ( tr( "Export Note As (ASCII) ","Status tip for note menu" ) );
   2.302 +	a->setShortcut(Qt::ALT + Qt::Key_X );
   2.303      connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) );
   2.304 -    a->addTo( menu );
   2.305 +	fileMenu->addAction (a);
   2.306  	actionFileSaveAs=a;
   2.307  
   2.308 -    menu->insertSeparator();
   2.309 -    a = new QAction( tr( "Print Note" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
   2.310 +    fileMenu->addSeparator();
   2.311 +    a = new QAction( QPixmap(iconPath+"fileprint.png" ), tr( "&Print..." ),this);
   2.312 +	a->setStatusTip (tr( "Print Note","Status tip for note menu" ) );
   2.313 +	a->setShortcut( Qt::CTRL + Qt::Key_P );
   2.314      connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) );
   2.315 -    a->addTo( tb );
   2.316 -    a->addTo( menu );
   2.317 +	tb->addAction (a);
   2.318 +	fileMenu->addAction (a);
   2.319  	actionFilePrint=a;
   2.320  }
   2.321  
   2.322  void TextEditor::setupEditActions()
   2.323  {
   2.324 -    QToolBar *tb = new QToolBar( this );
   2.325 -    tb->setLabel( "Edit Actions" );
   2.326 -    QPopupMenu *menu = new QPopupMenu( this );
   2.327 -    menuBar()->insertItem( tr( "&Edit" ), menu );
   2.328 +    QToolBar *tb = addToolBar ( tr( "Edit Actions" ));
   2.329 +	tb->setObjectName ("noteEditorEditActions");
   2.330 +    QMenu *editMenu = menuBar()->addMenu ( tr( "&Edit" ));
   2.331  
   2.332      QAction *a;
   2.333 -    a = new QAction( tr( "Undo" ), QPixmap(editundo_xpm), tr( "&Undo" ), CTRL + Key_Z, this, "undoEvent" );
   2.334 +    a = new QAction(QPixmap(iconPath+"undo.png"), tr( "&Undo" ), this );
   2.335 +	a->setStatusTip ( tr( "Undo","Status tip for note menu" ) );
   2.336 +	a->setShortcut(Qt::CTRL + Qt::Key_Z );
   2.337      connect( a, SIGNAL( activated() ), e, SLOT( undo() ) );
   2.338 -    a->addTo( menu );
   2.339 -    a->addTo( tb);
   2.340 +	editMenu->addAction (a);
   2.341 +	tb->addAction (a);
   2.342  	actionEditUndo=a;
   2.343  	
   2.344 -    a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); 
   2.345 +    a = new QAction(QPixmap(iconPath+"redo.png" ), tr( "&Redo" ),this); 
   2.346 +	a->setStatusTip ( tr( "Redo","Status tip for note menu" ) );
   2.347 +	a->setShortcut( Qt::CTRL + Qt::Key_Y );
   2.348      connect( a, SIGNAL( activated() ), e, SLOT( redo() ) );
   2.349 -    a->addTo( tb );
   2.350 -    a->addTo( menu );
   2.351 +	editMenu->addAction (a);
   2.352 +	tb->addAction (a);
   2.353  	actionEditRedo=a;
   2.354  
   2.355 -    menu->insertSeparator();
   2.356 -    a = new QAction( tr( "Select and copy all" ), QPixmap(), tr( "Select and copy &all" ), CTRL + Key_A, this, "editcopyall" ); 
   2.357 +    editMenu->addSeparator();
   2.358 +    a = new QAction(QPixmap(), tr( "Select and copy &all" ),this); 
   2.359 +	a->setStatusTip ( tr( "Select and copy all","Status tip for note menu" ) );
   2.360 +	a->setShortcut( Qt::CTRL + Qt::Key_A );
   2.361      connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) );
   2.362 -    a->addTo( menu );
   2.363 +	editMenu->addAction (a);
   2.364  
   2.365 -    menu->insertSeparator();
   2.366 -    a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
   2.367 +    editMenu->addSeparator();
   2.368 +    a = new QAction(QPixmap(iconPath+"editcopy.png" ), tr( "&Copy" ),this);
   2.369 +	a->setStatusTip ( tr( "Copy","Status tip for note menu" ) );
   2.370 +	a->setShortcut( Qt::CTRL + Qt::Key_C );
   2.371      connect( a, SIGNAL( activated() ), e, SLOT( copy() ) );
   2.372 -    a->addTo( tb );
   2.373 -    a->addTo( menu );
   2.374 +	editMenu->addAction (a);
   2.375 +	tb->addAction (a);
   2.376  	actionEditCopy=a;
   2.377  	
   2.378 -    a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
   2.379 +    a = new QAction(QPixmap(iconPath+"editcut.png" ), tr( "Cu&t" ),this);
   2.380 +	a->setStatusTip ( tr( "Cut","Status tip for note menu" ) );
   2.381 +	a->setShortcut( Qt::CTRL + Qt::Key_X );
   2.382      connect( a, SIGNAL( activated() ), e, SLOT( cut() ) );
   2.383 -    a->addTo( tb );
   2.384 -    a->addTo( menu );
   2.385 +	editMenu->addAction (a);
   2.386 +	tb->addAction (a);
   2.387  	actionEditCut=a;
   2.388  
   2.389 -    a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
   2.390 +    a = new QAction(QPixmap(iconPath+"editpaste.png" ), tr( "&Paste" ),this);
   2.391 +	a->setStatusTip ( tr( "Paste","Status tip for note menu" ) );
   2.392 +	a->setShortcut( Qt::CTRL + Qt::Key_V );
   2.393      connect( a, SIGNAL( activated() ), e, SLOT( paste() ) );
   2.394 -    a->addTo( tb );
   2.395 -    a->addTo( menu );
   2.396 +	editMenu->addAction (a);
   2.397 +	tb->addAction (a);
   2.398  	actionEditPaste=a;
   2.399  	
   2.400 -    a = new QAction( tr( "Delete all" ), QPixmap( edittrash_xpm ), tr( "&Delete All" ), 0, this, "editDeleteAll" );
   2.401 +    a = new QAction( QPixmap( iconPath+"edittrash.png"), tr( "&Delete All" ), this);
   2.402 +	a->setStatusTip (tr( "Delete all","Status tip for note menu" ) );
   2.403      connect( a, SIGNAL( activated() ), e, SLOT( clear() ) );
   2.404 -    a->addTo( tb );
   2.405 -    a->addTo( menu );
   2.406 +	editMenu->addAction (a);
   2.407 +	tb->addAction (a);
   2.408  	actionEditDeleteAll=a;
   2.409  
   2.410 -	a = new QAction( tr( "Convert paragraphs to linebreaks" ), QPixmap(), tr( "&Convert Paragraphs" ), ALT + Key_P, this, "editConvertPar" );
   2.411 -    connect( a, SIGNAL( activated() ), this, SLOT( textConvertPar() ) );
   2.412 -    a->addTo( menu );
   2.413 -	actionEditConvertPar=a;
   2.414 -
   2.415 -	a = new QAction( tr( "Join all lines of a paragraph" ), QPixmap(), tr( "&Join lines" ), ALT + Key_J, this, "editJoinLines" );
   2.416 -    connect( a, SIGNAL( activated() ), this, SLOT( textJoinLines() ) );
   2.417 -    a->addTo( menu );
   2.418 -	actionEditJoinLines=a;
   2.419  }
   2.420  
   2.421  void TextEditor::setupFormatActions()
   2.422  {
   2.423 -    QToolBar *tb = new QToolBar( this );
   2.424 -    tb->setLabel( "Format Actions" );
   2.425 -    QPopupMenu *menu = new QPopupMenu( this );
   2.426 -    menuBar()->insertItem( tr( "&Format" ), menu );
   2.427 +    QToolBar *tb = addToolBar ( tr("Format Actions" ));
   2.428 +	tb->setObjectName ("noteEditorFormatActions");
   2.429 +    QMenu *formatMenu = menuBar()->addMenu ( tr( "F&ormat" ));
   2.430  
   2.431      QAction *a;
   2.432  
   2.433 -    a = new QAction( tr( "Toggle font hint for the whole text" ), QPixmap(formatfixedfont_xpm), tr( "&Font hint" ), ALT + Key_I, this, "fontHint" );
   2.434 +    a = new QAction( QPixmap(iconPath+"formatfixedfont.png"), tr( "&Font hint" ), Qt::ALT + Qt::Key_I, this, "fontHint" );
   2.435 +	a->setStatusTip (tr( "Toggle font hint for the whole text","Status tip for note menu" ) );
   2.436  	a->setToggleAction (true);
   2.437 -	a->setOn (settings.readBoolEntry ("/vym/noteeditor/fonts/useFixedByDefault",false) );
   2.438 +	a->setOn (settings.value("/noteeditor/fonts/useFixedByDefault",false).toBool() );
   2.439      connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) );
   2.440 -    a->addTo( menu );
   2.441 -    a->addTo( tb );
   2.442 +	formatMenu->addAction (a);
   2.443 +	tb->addAction (a);
   2.444  	actionFormatUseFixedFont=a;
   2.445  
   2.446 -	menu->insertSeparator();
   2.447 -
   2.448 -    comboFont = new QComboBox( true, tb );
   2.449 -    QFontDatabase db;
   2.450 -    comboFont->insertStringList( db.families() );
   2.451 +    comboFont = new QComboBox;
   2.452 +	tb->addWidget (comboFont);
   2.453 +    QFontDatabase fontDB;
   2.454 +    comboFont->insertStringList( fontDB.families() );
   2.455      connect( comboFont, SIGNAL( activated( const QString & ) ),
   2.456  	     this, SLOT( textFamily( const QString & ) ) );
   2.457 -    comboFont->lineEdit()->setText( QApplication::font().family() );
   2.458 -
   2.459 -    comboSize = new QComboBox( true, tb );
   2.460 -    QValueList<int> sizes = db.standardSizes();
   2.461 -    QValueList<int>::Iterator it = sizes.begin();
   2.462 -    for ( ; it != sizes.end(); ++it )
   2.463 -	comboSize->insertItem( QString::number( *it ) );
   2.464 +    comboFont->addItem( QApplication::font().family() );
   2.465 +    comboSize = new QComboBox;
   2.466 +	tb->addWidget (comboSize);
   2.467 +	QList<int> sizes=fontDB.standardSizes();
   2.468 +	QList<int>::iterator i = sizes.begin();
   2.469 +	while (i != sizes.end()) 
   2.470 +	{
   2.471 +		++i; // increment i before using it
   2.472 +		comboSize->insertItem ( QString::number(*i));
   2.473 +	}	
   2.474      connect( comboSize, SIGNAL( activated( const QString & ) ),
   2.475  	     this, SLOT( textSize( const QString & ) ) );
   2.476 -    comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) );
   2.477 +    comboSize->addItem ( QString::number( QApplication::font().pointSize() ) );
   2.478  
   2.479 -    menu->insertSeparator();
   2.480 +    formatMenu->addSeparator();
   2.481  
   2.482      QPixmap pix( 16, 16 );
   2.483      pix.fill( e->color());
   2.484 -    actionTextColor = new QAction( pix, tr( "&Color..." ), 0, this, "textColor" );
   2.485 -    connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
   2.486 -    actionTextColor->addTo( tb );
   2.487 -    actionTextColor->addTo( menu );
   2.488 +    a = new QAction( pix, tr( "&Color..." ), this);
   2.489 +	formatMenu->addAction (a);
   2.490 +	tb->addAction (a);
   2.491 +    connect( a, SIGNAL( activated() ), this, SLOT( textColor() ) );
   2.492 +    actionTextColor=a;
   2.493  
   2.494 -    actionTextBold = new QAction( QPixmap (formattextbold_xpm), tr( "&Bold" ), CTRL + Key_B, this, "textBold" );
   2.495 -    connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
   2.496 -    actionTextBold->addTo( tb );
   2.497 -    actionTextBold->addTo( menu );
   2.498 -    actionTextBold->setToggleAction( true );
   2.499 -    actionTextItalic = new QAction( QPixmap(formattextitalic_xpm ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" );
   2.500 -    connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) );
   2.501 -    actionTextItalic->addTo( tb );
   2.502 -    actionTextItalic->addTo( menu );
   2.503 -    actionTextItalic->setToggleAction( true );
   2.504 -    actionTextUnderline = new QAction( QPixmap (formattextunder_xpm ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" );
   2.505 -    connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
   2.506 -    actionTextUnderline->addTo( tb );
   2.507 -    actionTextUnderline->addTo( menu );
   2.508 -    actionTextUnderline->setToggleAction( true );
   2.509 -    menu->insertSeparator();
   2.510 +    a = new QAction( QPixmap (iconPath+"text_bold.png"), tr( "&Bold" ), this);
   2.511 +	a->setShortcut(Qt::CTRL + Qt::Key_B );
   2.512 +    connect( a, SIGNAL( activated() ), this, SLOT( textBold() ) );
   2.513 +	tb->addAction (a);
   2.514 +	formatMenu->addAction (a);
   2.515 +    a->setToggleAction( true );
   2.516 +    actionTextBold=a;
   2.517 +	
   2.518 +    a = new QAction( QPixmap(iconPath+"text_italic.png"), tr( "&Italic" ),  this);
   2.519 +	a->setShortcut(Qt::CTRL + Qt::Key_I);
   2.520 +    connect( a, SIGNAL( activated() ), this, SLOT( textItalic() ) );
   2.521 +	tb->addAction (a);
   2.522 +	formatMenu->addAction (a);
   2.523 +    a->setToggleAction( true );
   2.524 +    actionTextItalic=a;
   2.525 +	
   2.526 +    a = new QAction( QPixmap (iconPath+"text_under.png"), tr( "&Underline" ), this);
   2.527 +	a->setShortcut(Qt::CTRL + Qt::Key_U );
   2.528 +    connect( a, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
   2.529 +	tb->addAction (a);
   2.530 +	formatMenu->addAction (a);
   2.531 +    a->setToggleAction( true );
   2.532 +    actionTextUnderline=a;
   2.533 +    formatMenu->addSeparator();
   2.534  
   2.535 +    QActionGroup *grp2 = new QActionGroup( this );
   2.536 +    grp2->setExclusive(true);
   2.537 +    a = new QAction( QPixmap (iconPath+"text_sub.png"), tr( "Subs&cript" ),grp2 );
   2.538 +	a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_B );
   2.539 +    a->setToggleAction( true );
   2.540 +	tb->addAction (a);
   2.541 +	formatMenu->addAction (a);
   2.542 +    connect(a, SIGNAL(activated()), this, SLOT(textVAlign()));
   2.543 +    actionAlignSubScript=a;
   2.544 +
   2.545 +    a = new QAction( QPixmap (iconPath+"text_super.png"), tr( "Su&perscript" ),grp2  );
   2.546 +	a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P );
   2.547 +    a->setToggleAction( true );
   2.548 +	tb->addAction (a);
   2.549 +	formatMenu->addAction (a);
   2.550 +    connect(a, SIGNAL(activated()), this, SLOT(textVAlign()));
   2.551 +    actionAlignSuperScript=a;
   2.552      QActionGroup *grp = new QActionGroup( this );
   2.553      connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
   2.554  
   2.555 -    actionAlignLeft = new QAction( QPixmap (formattextleft_xpm ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" );
   2.556 -    actionAlignLeft->setToggleAction( true );
   2.557 -    actionAlignCenter = new QAction( QPixmap (formattextcenter_xpm ), tr( "C&enter" ), CTRL + Key_E, grp, "textCenter" );
   2.558 -    actionAlignCenter->setToggleAction( true );
   2.559 -    actionAlignRight = new QAction( QPixmap (formattextright_xpm ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" );
   2.560 -    actionAlignRight->setToggleAction( true );
   2.561 -    actionAlignJustify = new QAction( QPixmap ( formattextjustify_xpm ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" );
   2.562 -    actionAlignJustify->setToggleAction( true );
   2.563 +    formatMenu->addSeparator();
   2.564  
   2.565 -    grp->addTo( tb );
   2.566 -    grp->addTo( menu );
   2.567 -
   2.568 -    connect( e, SIGNAL( currentFontChanged( const QFont & ) ),
   2.569 -	     this, SLOT( fontChanged( const QFont & ) ) );
   2.570 -    connect( e, SIGNAL( currentColorChanged( const QColor & ) ),
   2.571 -	     this, SLOT( colorChanged( const QColor & ) ) );
   2.572 -    connect( e, SIGNAL( currentAlignmentChanged( int ) ),
   2.573 -	     this, SLOT( alignmentChanged( int ) ) );
   2.574 -
   2.575 +    a = new QAction( QPixmap (iconPath+"text_left.png"), tr( "&Left" ),grp );
   2.576 +	a->setShortcut( Qt::CTRL+Qt::Key_L );
   2.577 +    a->setToggleAction( true );
   2.578 +	tb->addAction (a);
   2.579 +	formatMenu->addAction (a);
   2.580 +    actionAlignLeft=a;
   2.581 +    a = new QAction( QPixmap (iconPath+"text_center.png"), tr( "C&enter" ),grp);
   2.582 +    a->setShortcut(  Qt::CTRL + Qt::Key_E);
   2.583 +    a->setToggleAction( true );
   2.584 +	tb->addAction (a);
   2.585 +	formatMenu->addAction (a);
   2.586 +    actionAlignCenter=a;
   2.587 +    a = new QAction( QPixmap (iconPath+"text_right.png" ), tr( "&Right" ), grp);
   2.588 +	a->setShortcut(Qt::CTRL + Qt::Key_R );
   2.589 +    a->setToggleAction( true );
   2.590 +	tb->addAction (a);
   2.591 +	formatMenu->addAction (a);
   2.592 +    actionAlignRight=a;
   2.593 +    a = new QAction( QPixmap ( iconPath+"text_block.png"), tr( "&Justify" ), grp );
   2.594 +	a->setShortcut(Qt::CTRL + Qt::Key_J );
   2.595 +    a->setToggleAction( true );
   2.596 +	tb->addAction (a);
   2.597 +	formatMenu->addAction (a);
   2.598 +    actionAlignJustify=a;
   2.599  }
   2.600  
   2.601  void TextEditor::setupSettingsActions()
   2.602  {
   2.603 -    QPopupMenu *menu = new QPopupMenu( this );
   2.604 -    menuBar()->insertItem( tr( "&Settings" ), menu );
   2.605 +    QMenu *settingsMenu = menuBar()->addMenu ( tr( "&Settings" ));
   2.606  
   2.607      QAction *a;
   2.608 -    a = new QAction( tr( "Set fixed font" ), QPixmap(), tr( "Set &fixed font" ), 0, this, "setFixedFont" );
   2.609 +    a = new QAction(tr( "Set &fixed font" ), this);
   2.610 +	a->setStatusTip ( tr( "Set fixed font","Status tip for note menu" ));
   2.611      connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) );
   2.612 -    a->addTo( menu );
   2.613 +	settingsMenu->addAction (a);
   2.614  	actionSettingsFixedFont=a;
   2.615  
   2.616 -    a = new QAction( tr( "Set variable font" ), QPixmap(), tr( "Set &variable font" ), 0, this, "setvariableFont" );
   2.617 +    a = new QAction(tr( "Set &variable font" ), this);
   2.618 +	a->setStatusTip ( tr( "Set variable font","Status tip for note menu" ) );
   2.619      connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) );
   2.620 -    a->addTo( menu );
   2.621 +	settingsMenu->addAction (a);
   2.622  	actionSettingsVarFont=a;
   2.623  
   2.624 -    a = new QAction( tr( "Used fixed font by default" ), QPixmap(), tr( "&fixed font is default" ), 0, this, "fonthintDefault" );
   2.625 +    a = new QAction(tr( "&fixed font is default" ),  this);
   2.626 +	a->setStatusTip (tr( "Used fixed font by default","Status tip for note menu" ) );
   2.627  	a->setToggleAction (true);
   2.628  	// set state later in constructor...
   2.629 -    a->addTo( menu );
   2.630 +	settingsMenu->addAction (a);
   2.631  	actionSettingsFonthintDefault=a;
   2.632  }
   2.633  
   2.634 @@ -426,9 +454,9 @@
   2.635  {
   2.636  	if (state!=inactiveEditor)
   2.637  	{
   2.638 -		if (e->length()) 
   2.639 +		if (!isEmpty()) 
   2.640  		{
   2.641 -			QMessageBox mb( "VYM - Note Editor",
   2.642 +			QMessageBox mb( vymName + " - " +tr("Note Editor"),
   2.643  				"Loading will overwrite the existing note",
   2.644  				QMessageBox::Warning,
   2.645  				QMessageBox::Yes | QMessageBox::Default,
   2.646 @@ -443,8 +471,12 @@
   2.647  		} 
   2.648  		// Load note
   2.649  		QFileDialog *fd=new QFileDialog( this);
   2.650 -		fd->addFilter ("ASCII texts (*.txt)");
   2.651 -		fd->addFilter ("VYM notes (*.html)");
   2.652 +		QStringList types;
   2.653 +		types<< "VYM notes (*.html)" <<
   2.654 +			"ASCII texts (*.txt)" <<
   2.655 +			"All filed (*)";
   2.656 +		fd->setFilters (types);
   2.657 +		fd->setDirectory (QDir().current());
   2.658  		fd->show();
   2.659  		QString fn;
   2.660  		if ( fd->exec() == QDialog::Accepted )
   2.661 @@ -453,7 +485,7 @@
   2.662  		if ( !fn.isEmpty() )
   2.663  		{
   2.664  			QFile f( fn );
   2.665 -			if ( !f.open( IO_ReadOnly ) )
   2.666 +			if ( !f.open( QIODevice::ReadOnly ) )
   2.667  			return;
   2.668  
   2.669  			QTextStream ts( &f );
   2.670 @@ -465,56 +497,51 @@
   2.671  
   2.672  void TextEditor::closeEvent( QCloseEvent* ce )
   2.673  {
   2.674 -    if ( !e->isModified() ) 
   2.675 -	{
   2.676 -		ce->accept();	// TextEditor can be reopened with show()
   2.677 -		return;
   2.678 -    }
   2.679 +    ce->accept();	// TextEditor can be reopened with show()
   2.680 +	showwithmain=false;
   2.681 +	hide();
   2.682 +	emit (windowClosed() );
   2.683 +    return;
   2.684  }
   2.685  
   2.686  QString TextEditor::getText()
   2.687  {
   2.688 -	return e->text();
   2.689 +	if (e->toPlainText().isEmpty())
   2.690 +		return "";
   2.691 +	else	
   2.692 +		return e->text();
   2.693  }
   2.694  
   2.695  void TextEditor::editorChanged()
   2.696  {
   2.697 -	// received, when QTextEdit::text() has changed
   2.698 -	EditorState	oldstate=state;
   2.699 -
   2.700  	if (isEmpty())
   2.701  		state=emptyEditor;
   2.702  	else
   2.703  		state=filledEditor;
   2.704  
   2.705 -	if (state != oldstate)
   2.706 -	{
   2.707  		if (state==emptyEditor)
   2.708 -			e->setPaper (emptyPaper);
   2.709 +			setState (emptyEditor);
   2.710  		else
   2.711 -			e->setPaper (filledPaper);
   2.712 -	}
   2.713 +			setState (filledEditor);
   2.714  	// SLOT is LinkableMapObj, which will update systemFlag
   2.715 -	emit (textHasChanged() );
   2.716 +	if (!blockChangedSignal) emit (textHasChanged() );
   2.717  }
   2.718  
   2.719  
   2.720  void TextEditor::setText(QString t)
   2.721  {
   2.722 -	if ( !QStyleSheet::mightBeRichText( t ) )
   2.723 -		t = QStyleSheet::convertFromPlainText( t, QStyleSheetItem::WhiteSpaceNormal );
   2.724 +	blockChangedSignal=true;
   2.725  	e->setReadOnly(false);
   2.726  	e->setText(t);
   2.727 -	editorChanged();	//not called automagically
   2.728 -
   2.729  	enableActions();
   2.730 +	blockChangedSignal=false;
   2.731  }
   2.732  
   2.733  void TextEditor::setInactive()
   2.734  {
   2.735 +	state=inactiveEditor;
   2.736  	setText("");
   2.737 -	state=inactiveEditor;
   2.738 -	e->setPaper (inactivePaper);
   2.739 +	setState (inactiveEditor);
   2.740  	e->setReadOnly (true);
   2.741  
   2.742  	disableActions();
   2.743 @@ -536,14 +563,12 @@
   2.744  		QFile file (fn);
   2.745  		if (file.exists())
   2.746  		{
   2.747 -			QMessageBox mb( "VYM",
   2.748 -				tr("The file ") + fn + 
   2.749 -				tr(" exists already. "
   2.750 -				"Do you want to overwrite it?"),
   2.751 +			QMessageBox mb( vymName,
   2.752 +				tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn),
   2.753  			QMessageBox::Warning,
   2.754  			QMessageBox::Yes | QMessageBox::Default,
   2.755  			QMessageBox::Cancel | QMessageBox::Escape,
   2.756 -			QMessageBox::NoButton );
   2.757 +			Qt::NoButton );
   2.758  			mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
   2.759  			mb.setButtonText( QMessageBox::No, tr("Cancel"));
   2.760  			switch( mb.exec() ) {
   2.761 @@ -563,7 +588,7 @@
   2.762  			return;
   2.763  		}			
   2.764      }
   2.765 -	statusBar()->message(tr( "Couldn't export note ") + fn, statusbarTime );
   2.766 +	statusBar()->message(tr( "Couldn't export note ","dialog 'save note as'") + fn, statusbarTime );
   2.767  }
   2.768  
   2.769  
   2.770 @@ -577,7 +602,7 @@
   2.771  
   2.772      QString text = e->text();
   2.773      QFile f( filename );
   2.774 -    if ( !f.open( IO_WriteOnly ) ) 
   2.775 +    if ( !f.open( QIODevice::WriteOnly ) ) 
   2.776  	{
   2.777  		statusBar()->message( QString("Could not write to %1").arg(filename),
   2.778  					  statusbarTime );
   2.779 @@ -593,104 +618,19 @@
   2.780      statusBar()->message( QString( "Note exported as %1" ).arg( filename ), statusbarTime );
   2.781  }
   2.782  
   2.783 -void TextEditor::textConvertPar()
   2.784 -{
   2.785 -	// In X11 a copy&paste generates paragraphs, 
   2.786 -	// which is not always wanted
   2.787 -	// This function replaces paragraphs by linebreaks.
   2.788 -	int parFrom, parTo, indFrom, indTo;
   2.789 -	e->getSelection (&parFrom,&indFrom,&parTo,&indTo);
   2.790 -	QString t;
   2.791 -	if (parFrom>-1)
   2.792 -		t=e->selectedText();
   2.793 -	else
   2.794 -		t=e->text();
   2.795 -
   2.796 -	QRegExp re("<p.*>");
   2.797 -	re.setMinimal(true);
   2.798 -	t.replace (re,"");
   2.799 -	t.replace ("</p>","<br />");
   2.800 -	if (parFrom>-1)
   2.801 -	{
   2.802 -		e->setCursorPosition (parFrom,indFrom);
   2.803 -		e->cut();
   2.804 -		// Tried to simply insert the changed text with
   2.805 -		// e->insert (t,(uint)(QTextEdit::RemoveSelected));
   2.806 -		// but then the html would be quoted. So I use the ugly
   2.807 -		// way: insert a marker, replace it in whole text of QTextEdit
   2.808 -		QString marker="R3PlAcEMeL4teR!";
   2.809 -		e->insert (marker);
   2.810 -		e->setText (e->text().replace(marker,t));
   2.811 -	} else
   2.812 -		e->setText(t);
   2.813 -}
   2.814 -
   2.815 -void TextEditor::textJoinLines()
   2.816 -{
   2.817 -	int parFrom, parTo, indFrom, indTo;
   2.818 -	e->getSelection (&parFrom,&indFrom,&parTo,&indTo);
   2.819 -	QString t;
   2.820 -	if (parFrom>-1)
   2.821 -		t=e->selectedText();
   2.822 -	else
   2.823 -		t=e->text();
   2.824 -	// In addition to textConvertPar it is sometimes
   2.825 -	// useful to join all lines of a paragraph
   2.826 -	QRegExp re("</p>\n+<p>(?!</p>)");
   2.827 -	re.setMinimal(true);
   2.828 -	t.replace (re," ");
   2.829 -
   2.830 -	// Above we may have introduced new " " at beginning of a
   2.831 -	// paragraph - remove it.
   2.832 -	re.setPattern("<p> ");
   2.833 -	t.replace (re,"<p>");
   2.834 -	if (parFrom>-1)
   2.835 -	{
   2.836 -		e->setCursorPosition (parFrom,indFrom);
   2.837 -		e->cut();
   2.838 -		// Tried to simply insert the changed text with
   2.839 -		// e->insert (t,(uint)(QTextEdit::RemoveSelected));
   2.840 -		// but then the html would be quoted. So I use the ugly
   2.841 -		// way: insert a marker, replace it in whole text of QTextEdit
   2.842 -		QString marker="R3PlAcEMeL4teR!";
   2.843 -		e->insert (marker);
   2.844 -		e->setText (e->text().replace(marker,t));
   2.845 -	} else
   2.846 -		e->setText(t);
   2.847 -}
   2.848 -
   2.849 -QString TextEditor::textConvertToASCII(const QString &t)
   2.850 -{
   2.851 -	QString r=t;
   2.852 -
   2.853 -	// convert all "<br*>" to "\n"
   2.854 -	QRegExp re("<br.*>");
   2.855 -	re.setMinimal(true);
   2.856 -	r.replace (re,"\n");
   2.857 -
   2.858 -	// convert all "</p>" to "\n"
   2.859 -	re.setPattern ("/p");
   2.860 -	r.replace (re,"\n");
   2.861 -	
   2.862 -	// remove all remaining tags 
   2.863 -	re.setPattern ("<.*>");
   2.864 -	r.replace (re,"");
   2.865 -
   2.866 -	// convert "&", "<" and ">"
   2.867 -	re.setPattern ("&gt;");
   2.868 -	r.replace (re,">");
   2.869 -	re.setPattern ("&lt;");
   2.870 -	r.replace (re,"<");
   2.871 -	re.setPattern ("&amp;");
   2.872 -	r.replace (re,"&");
   2.873 -	return r;
   2.874 -}
   2.875 -
   2.876  void TextEditor::textExportAsASCII()
   2.877  {
   2.878 -	QString text = textConvertToASCII( e->text());
   2.879 -    QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (ASCII) (*.txt);;All files (*)",
   2.880 -					       this,"export note dialog",tr("Export Note to single file (ASCII)") );
   2.881 +	QString text = NoteObj (e->text()).getNoteASCII();
   2.882 +	QString fn,s;
   2.883 +	if (!filenameHint.isEmpty())
   2.884 +	{
   2.885 +		if (!filenameHint.contains (".txt"))
   2.886 +			s=filenameHint+".txt";
   2.887 +		else	
   2.888 +			s=filenameHint;
   2.889 +	} else	
   2.890 +		s=QString::null;
   2.891 +	fn = QFileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") );
   2.892  	int ret=-1;
   2.893  
   2.894      if ( !fn.isEmpty() ) 
   2.895 @@ -698,14 +638,12 @@
   2.896  		QFile file (fn);
   2.897  		if (file.exists())
   2.898  		{
   2.899 -			QMessageBox mb( "VYM",
   2.900 -				tr("The file ") + fn + 
   2.901 -				tr(" exists already. "
   2.902 -				"Do you want to overwrite it?"),
   2.903 +			QMessageBox mb( vymName,
   2.904 +				tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn),
   2.905  			QMessageBox::Warning,
   2.906  			QMessageBox::Yes | QMessageBox::Default,
   2.907  			QMessageBox::Cancel | QMessageBox::Escape,
   2.908 -			QMessageBox::NoButton );
   2.909 +			Qt::NoButton );
   2.910  			mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
   2.911  			mb.setButtonText( QMessageBox::No, tr("Cancel"));
   2.912  			ret=mb.exec();
   2.913 @@ -714,7 +652,7 @@
   2.914  			return;
   2.915  			
   2.916  		// save 
   2.917 -		if ( !file.open( IO_WriteOnly ) ) 
   2.918 +		if ( !file.open( QIODevice::WriteOnly ) ) 
   2.919  			statusBar()->message( QString("Could not write to %1").arg(filename),
   2.920  						  statusbarTime );
   2.921  		else
   2.922 @@ -731,41 +669,16 @@
   2.923  
   2.924  void TextEditor::textPrint()
   2.925  {
   2.926 -    printer->setFullPage(TRUE);
   2.927 -    if ( printer->setup( this ) ) 
   2.928 -	{
   2.929 -		QPainter p( printer );
   2.930 -		// Check that there is a valid device to print to.
   2.931 -		if ( !p.device() ) return;
   2.932 -		QPaintDeviceMetrics metrics( p.device() );
   2.933 -		int dpiy = metrics.logicalDpiY();
   2.934 -		int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins
   2.935 -		QRect body( margin, margin, metrics.width() - 2*margin, metrics.height() - 2*margin );
   2.936 -		QFont font( e->currentFont() );
   2.937 -		font.setPointSize( 10 ); // we define 10pt to be a nice base size for printing
   2.938  
   2.939 -		QSimpleRichText richText( e->text(), font,
   2.940 -					  e->context(),
   2.941 -					  e->styleSheet(),
   2.942 -					  e->mimeSourceFactory(),
   2.943 -					  body.height() );
   2.944 -		richText.setWidth( &p, body.width() );
   2.945 -		QRect view( body );
   2.946 -		int page = 1;
   2.947 -		do 
   2.948 -		{
   2.949 -			richText.draw( &p, body.left(), body.top(), view, colorGroup() );
   2.950 -			view.moveBy( 0, body.height() );
   2.951 -			p.translate( 0 , -body.height() );
   2.952 -			p.setFont( font );
   2.953 -			p.drawText( view.right() - p.fontMetrics().width( QString::number( page ) ),
   2.954 -				view.bottom() + p.fontMetrics().ascent() + 5, QString::number( page ) );
   2.955 -			if ( view.top()  >= richText.height() )
   2.956 -			break;
   2.957 -			printer->newPage();
   2.958 -			page++;
   2.959 -		} while (TRUE);
   2.960 -    }
   2.961 +    QTextDocument *document = e->document();
   2.962 +    QPrinter printer;
   2.963 +
   2.964 +    QPrintDialog *dialog = new QPrintDialog(&printer, this);
   2.965 +    dialog->setWindowTitle(tr("Print Note"));
   2.966 +    if (dialog->exec() != QDialog::Accepted)
   2.967 +        return;
   2.968 +
   2.969 +    document->print(&printer);
   2.970  }
   2.971  
   2.972  void TextEditor::textEditUndo()
   2.973 @@ -775,12 +688,12 @@
   2.974  void TextEditor::toggleFonthint()
   2.975  {
   2.976  	setUpdatesEnabled (false);
   2.977 -	e->selectAll (true);
   2.978 +	e->selectAll ();
   2.979  	if (!actionFormatUseFixedFont->isOn() ) 
   2.980  		e->setCurrentFont (varFont);
   2.981  	else	
   2.982  		e->setCurrentFont (fixedFont);
   2.983 -	e->selectAll (false);
   2.984 +	e->selectAll ();
   2.985  	setUpdatesEnabled (true);
   2.986  	repaint();
   2.987  }
   2.988 @@ -834,30 +747,46 @@
   2.989  void TextEditor::textColor()
   2.990  {
   2.991      QColor col = QColorDialog::getColor( e->color(), this );
   2.992 -    if ( !col.isValid() )
   2.993 -	return;
   2.994 +    if ( !col.isValid() ) return;
   2.995      e->setColor( col );
   2.996      QPixmap pix( 16, 16 );
   2.997 -    pix.fill( black );
   2.998 +    pix.fill( Qt::black );
   2.999      actionTextColor->setIconSet( pix );
  2.1000  }
  2.1001  
  2.1002  void TextEditor::textAlign( QAction *a )
  2.1003  {
  2.1004      if ( a == actionAlignLeft )
  2.1005 -	e->setAlignment( AlignLeft );
  2.1006 +		e->setAlignment( Qt::AlignLeft );
  2.1007      else if ( a == actionAlignCenter )
  2.1008 -	e->setAlignment( AlignHCenter );
  2.1009 +		e->setAlignment( Qt::AlignHCenter );
  2.1010      else if ( a == actionAlignRight )
  2.1011 -	e->setAlignment( AlignRight );
  2.1012 +		e->setAlignment( Qt::AlignRight );
  2.1013      else if ( a == actionAlignJustify )
  2.1014 -	e->setAlignment( AlignJustify );
  2.1015 +		e->setAlignment( Qt::AlignJustify );
  2.1016  }
  2.1017  
  2.1018 +void TextEditor::textVAlign()
  2.1019 +{
  2.1020 +	QTextCharFormat format;
  2.1021 +
  2.1022 +    if ( sender() == actionAlignSuperScript && actionAlignSuperScript->isOn()) {
  2.1023 +		format.setVerticalAlignment(QTextCharFormat::AlignSuperScript);
  2.1024 +    } else if (sender() == actionAlignSubScript && actionAlignSubScript->isOn()) {
  2.1025 +		format.setVerticalAlignment(QTextCharFormat::AlignSubScript);
  2.1026 +    } else {
  2.1027 +		format.setVerticalAlignment(QTextCharFormat::AlignNormal);
  2.1028 +    }
  2.1029 +	e->mergeCurrentCharFormat(format);
  2.1030 +}
  2.1031 +
  2.1032 +
  2.1033  void TextEditor::fontChanged( const QFont &f )
  2.1034  {
  2.1035 -    comboFont->lineEdit()->setText( f.family() );
  2.1036 -    comboSize->lineEdit()->setText( QString::number( f.pointSize() ) );
  2.1037 +	int i=comboFont->findText(f.family());
  2.1038 +    if (i>=0) comboFont->setCurrentIndex (i);
  2.1039 +	i=comboSize->findText(QString::number(f.pointSize()));
  2.1040 +	if (i>=0) comboSize->setCurrentIndex(i);
  2.1041      actionTextBold->setOn( f.bold() );
  2.1042      actionTextItalic->setOn( f.italic() );
  2.1043      actionTextUnderline->setOn( f.underline() );
  2.1044 @@ -870,16 +799,40 @@
  2.1045      actionTextColor->setIconSet( pix );
  2.1046  }
  2.1047  
  2.1048 +void TextEditor::formatChanged( const QTextCharFormat &f )
  2.1049 +{
  2.1050 +	fontChanged(f.font());
  2.1051 +    colorChanged(f.foreground().color());
  2.1052 +    alignmentChanged(e->alignment());
  2.1053 +	verticalAlignmentChanged (f.verticalAlignment());
  2.1054 +}
  2.1055 +
  2.1056  void TextEditor::alignmentChanged( int a )
  2.1057  {
  2.1058 -    if ( ( a == AlignAuto ) || ( a & AlignLeft ))
  2.1059 -	actionAlignLeft->setOn( true );
  2.1060 -    else if ( ( a & AlignHCenter ) )
  2.1061 -	actionAlignCenter->setOn( true );
  2.1062 -    else if ( ( a & AlignRight ) )
  2.1063 -	actionAlignRight->setOn( true );
  2.1064 -    else if ( ( a & AlignJustify ) )
  2.1065 -	actionAlignJustify->setOn( true );
  2.1066 +    if ( ( a == Qt::AlignLeft ) || ( a & Qt::AlignLeft ))
  2.1067 +		actionAlignLeft->setOn( true );
  2.1068 +    else if ( ( a & Qt::AlignHCenter ) )
  2.1069 +		actionAlignCenter->setOn( true );
  2.1070 +    else if ( ( a & Qt::AlignRight ) )
  2.1071 +		actionAlignRight->setOn( true );
  2.1072 +    else if ( ( a & Qt::AlignJustify ) )
  2.1073 +		actionAlignJustify->setOn( true );
  2.1074 +}
  2.1075 +
  2.1076 +void TextEditor::verticalAlignmentChanged(QTextCharFormat::VerticalAlignment a)
  2.1077 +{
  2.1078 +	actionAlignSubScript->setOn (false);
  2.1079 +	actionAlignSuperScript->setOn (false);
  2.1080 +	switch (a)
  2.1081 +	{
  2.1082 +		case QTextCharFormat::AlignSuperScript: 
  2.1083 +			actionAlignSuperScript->setOn (true);
  2.1084 +			break;
  2.1085 +		case QTextCharFormat::AlignSubScript:
  2.1086 +			actionAlignSubScript->setOn (true);
  2.1087 +			break;
  2.1088 +		default: ;	
  2.1089 +	}
  2.1090  }
  2.1091  
  2.1092  
  2.1093 @@ -896,8 +849,6 @@
  2.1094  	actionEditCut->setEnabled(true);
  2.1095  	actionEditPaste->setEnabled(true);
  2.1096  	actionEditDeleteAll->setEnabled(true);
  2.1097 -	actionEditConvertPar->setEnabled(true);
  2.1098 -	actionEditJoinLines->setEnabled(true);
  2.1099  	actionFormatUseFixedFont->setEnabled(true);
  2.1100  }
  2.1101  
  2.1102 @@ -913,9 +864,23 @@
  2.1103  	actionEditCut->setEnabled(false);
  2.1104  	actionEditPaste->setEnabled(false);
  2.1105  	actionEditDeleteAll->setEnabled(false);
  2.1106 -	actionEditConvertPar->setEnabled(false);
  2.1107 -	actionEditJoinLines->setEnabled(false);
  2.1108  	actionFormatUseFixedFont->setEnabled(false);
  2.1109  }
  2.1110  
  2.1111 +void TextEditor::setState (EditorState s)
  2.1112 +{
  2.1113 +	
  2.1114 +	QPalette p=palette();
  2.1115 +	QColor c;
  2.1116 +	switch (s)
  2.1117 +	{
  2.1118 +		case emptyEditor:    c=QColor (150,150,150); break;
  2.1119 +		case filledEditor:   c=QColor (255,255,255); break;
  2.1120 +		case inactiveEditor: c=QColor (0,0,0);
  2.1121 +	}
  2.1122 +    p.setColor(QPalette::Active, static_cast<QPalette::ColorRole>(9), c);
  2.1123 +    p.setColor(QPalette::Inactive, static_cast<QPalette::ColorRole>(9), c);
  2.1124 +    e->setPalette(p);
  2.1125 +}
  2.1126  
  2.1127 +