texteditor.cpp
branchqt4-port
changeset 2 608f976aa7bb
parent 0 7a96bd401351
child 3 6a0342b3c519
     1.1 --- a/texteditor.cpp	Sun Jan 30 12:58:47 2005 +0000
     1.2 +++ b/texteditor.cpp	Tue Jun 06 14:58:11 2006 +0000
     1.3 @@ -1,6 +1,6 @@
     1.4  #include "texteditor.h"
     1.5  
     1.6 -#include <qcanvas.h>
     1.7 +#include <q3canvas.h>
     1.8  #include <qstatusbar.h>
     1.9  #include <qmessagebox.h>
    1.10  #include <qaction.h>
    1.11 @@ -8,68 +8,65 @@
    1.12  #include <qpainter.h>
    1.13  #include <qprinter.h>
    1.14  #include <qfile.h>
    1.15 -#include <qfiledialog.h>
    1.16 -#include <qtoolbar.h>
    1.17 -#include <qpopupmenu.h>
    1.18 +#include <q3filedialog.h>
    1.19 +#include <q3toolbar.h>
    1.20 +#include <q3popupmenu.h>
    1.21  #include <qmenubar.h>
    1.22 -#include <qtextedit.h>
    1.23 -#include <qaccel.h>
    1.24 +#include <q3textedit.h>
    1.25 +#include <q3accel.h>
    1.26  #include <qtextstream.h>
    1.27 -#include <qpaintdevicemetrics.h>
    1.28 +#include <q3paintdevicemetrics.h>
    1.29  #include <qsettings.h>
    1.30  #include <qfontdialog.h>
    1.31  #include <qmessagebox.h>
    1.32  #include <qcolordialog.h>
    1.33  #include <qregexp.h>
    1.34  #include <qlineedit.h>
    1.35 -#include <qsimplerichtext.h>
    1.36 +#include <q3simplerichtext.h>
    1.37 +//Added by qt3to4:
    1.38 +#include <Q3ValueList>
    1.39 +#include <QPixmap>
    1.40 +#include <Q3ActionGroup>
    1.41 +#include <QCloseEvent>
    1.42  
    1.43  #include <iostream>
    1.44 -#include <stdlib.h>
    1.45 +#include <cstdlib>
    1.46  #include <typeinfo>
    1.47  
    1.48 -#include "icons/fileopen.xpm"
    1.49 -#include "icons/filesave.xpm"
    1.50 -#include "icons/fileprint.xpm"
    1.51 -#include "icons/editundo.xpm"	
    1.52 -#include "icons/editredo.xpm"	
    1.53 -#include "icons/editcopy.xpm"
    1.54 -#include "icons/editcut.xpm"
    1.55 -#include "icons/editpaste.xpm"
    1.56 -#include "icons/edittrash.xpm"
    1.57 -#include "icons/formatfixedfont.xpm"
    1.58 -#include "icons/formattextbold.xpm"
    1.59 -#include "icons/formattextitalic.xpm"
    1.60 -#include "icons/formattextunder.xpm"
    1.61 -#include "icons/formattextleft.xpm"
    1.62 -#include "icons/formattextcenter.xpm"
    1.63 -#include "icons/formattextright.xpm"
    1.64 -#include "icons/formattextjustify.xpm"
    1.65 +#include "noteobj.h"
    1.66 +#include "version.h"
    1.67  
    1.68 -extern QCanvas* actCanvas;
    1.69 +extern Q3Canvas* actCanvas;
    1.70  extern int statusbarTime;
    1.71  extern QSettings settings;
    1.72  
    1.73 +extern QAction *actionViewToggleNoteEditor;
    1.74 +
    1.75 +extern QString iconPath;
    1.76 +
    1.77  using namespace std;
    1.78  
    1.79  
    1.80  ///////////////////////////////////////////////////////////////////////
    1.81  ///////////////////////////////////////////////////////////////////////
    1.82  
    1.83 +
    1.84  TextEditor::TextEditor()
    1.85  {
    1.86      printer = new QPrinter( QPrinter::HighResolution );
    1.87 +	printer->setPrinterName (settings.readEntry("/vym/mainwindow/printerName",printer->printerName()));
    1.88  
    1.89 -	// Editor
    1.90 -    e = new QTextEdit( this, "editor" );
    1.91 +	// Editor (use MyTextEdit to wrap verticalAlignmentChanged to 
    1.92 +	//         int argument. see header file)
    1.93 +    e = new MyTextEdit( this, "editor" );
    1.94      e->setFocus();
    1.95 -	e->setTextFormat(RichText);		// default
    1.96 +	e->setTextFormat(Qt::RichText);		// default
    1.97  	e->setTabStopWidth (20);		// unit is pixel
    1.98 -	e->setColor (black);
    1.99 +	e->setColor (Qt::black);
   1.100  	connect (e, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
   1.101      setCentralWidget( e );
   1.102      statusBar()->message( "Ready", statusbarTime);
   1.103 -	setCaption("VYM - Note Editor");
   1.104 +	setCaption(__VYM " - " +tr ("Note Editor"));
   1.105  
   1.106  	// Toolbars
   1.107  	setupFileActions();
   1.108 @@ -78,9 +75,9 @@
   1.109  	setupSettingsActions();
   1.110  	
   1.111  	// Various states
   1.112 -	emptyPaper   = QBrush(gray);
   1.113 -	filledPaper  = QBrush(white);
   1.114 -	inactivePaper= QBrush(black);
   1.115 +	emptyPaper   = QBrush(Qt::gray);
   1.116 +	filledPaper  = QBrush(Qt::white);
   1.117 +	inactivePaper= QBrush(Qt::black);
   1.118  	setInactive();
   1.119  
   1.120  	// Load Settings
   1.121 @@ -112,6 +109,10 @@
   1.122  		actionSettingsFonthintDefault->setOn (false);
   1.123  		e->setCurrentFont (varFont);
   1.124  	}	
   1.125 +	filenameHint="";
   1.126 +
   1.127 +	// Save settings in vymrc
   1.128 +	settings.writeEntry("/vym/mainwindow/printerName",printer->printerName());
   1.129  }
   1.130  
   1.131  
   1.132 @@ -204,6 +205,16 @@
   1.133  	return filename;
   1.134  }
   1.135  
   1.136 +void TextEditor::setFilenameHint(const QString &fnh)
   1.137 +{
   1.138 +	filenameHint=fnh;
   1.139 +}
   1.140 +
   1.141 +QString TextEditor::getFilenameHint()
   1.142 +{
   1.143 +	return filenameHint;
   1.144 +}
   1.145 +
   1.146  bool TextEditor::findText(const QString &t, const bool &cs)
   1.147  {
   1.148  	bool wo=false;	// word matches
   1.149 @@ -215,13 +226,15 @@
   1.150  
   1.151  void TextEditor::setupFileActions()
   1.152  {
   1.153 -    QToolBar *tb = new QToolBar( this );
   1.154 +    Q3ToolBar *tb = new Q3ToolBar( this );
   1.155      tb->setLabel( "File Actions" );
   1.156 -    QPopupMenu *menu = new QPopupMenu( this );
   1.157 +    Q3PopupMenu *menu = new Q3PopupMenu( this );
   1.158      menuBar()->insertItem( tr( "&File" ), menu );
   1.159  
   1.160      QAction *a;
   1.161 -    a = new QAction( tr( "Import" ), QPixmap( fileopen_xpm), tr( "&Import..." ), CTRL + Key_O, this, "fileImport" );
   1.162 +    a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Import..." ),this);
   1.163 +	a->setStatusTip (tr( "Import" ) );
   1.164 +	a->setShortcut( Qt::CTRL + Qt::Key_O );
   1.165      connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) );
   1.166  	a->setEnabled(false);
   1.167      a->addTo( tb );
   1.168 @@ -229,24 +242,31 @@
   1.169  	actionFileLoad=a;
   1.170  
   1.171      menu->insertSeparator();
   1.172 -    a = new QAction( tr( "Export Note (HTML)" ), QPixmap( filesave_xpm ), tr( "&Export..." ), CTRL + Key_S, this, "fileSave" );
   1.173 +    a = new QAction( QPixmap(iconPath+"filesave.png" ), tr( "&Export..." ),this);
   1.174 +	a->setStatusTip (tr( "Export Note (HTML)" ) );
   1.175 +	a->setShortcut( Qt::CTRL + Qt::Key_S );
   1.176      connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) );
   1.177      a->addTo( tb );
   1.178      a->addTo( menu );
   1.179  	actionFileSave=a;
   1.180  	
   1.181 -    a = new QAction( tr( "Export Note As (HTML) " ), QPixmap(), tr( "Export &As... (HTML)" ), 0, this, "exportHTML" );
   1.182 +    a = new QAction(  QPixmap(), tr( "Export &As... (HTML)" ), this);
   1.183 +	a->setStatusTip (tr( "Export Note As (HTML) " ));
   1.184      connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) );
   1.185      a->addTo( menu );
   1.186  	actionFileSaveAs=a;
   1.187  
   1.188 -    a = new QAction( tr( "Export Note As (ASCII) " ), QPixmap(), tr( "Export &As...(ASCII)" ), ALT + Key_X, this, "exportASCII" );
   1.189 +    a = new QAction(QPixmap(), tr( "Export &As...(ASCII)" ), this);
   1.190 +	a->setStatusTip ( tr( "Export Note As (ASCII) " ) );
   1.191 +	a->setShortcut(Qt::ALT + Qt::Key_X );
   1.192      connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) );
   1.193      a->addTo( menu );
   1.194  	actionFileSaveAs=a;
   1.195  
   1.196      menu->insertSeparator();
   1.197 -    a = new QAction( tr( "Print Note" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
   1.198 +    a = new QAction( QPixmap(iconPath+"fileprint.png" ), tr( "&Print..." ),this);
   1.199 +	a->setStatusTip (tr( "Print Note" ) );
   1.200 +	a->setShortcut( Qt::CTRL + Qt::Key_P );
   1.201      connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) );
   1.202      a->addTo( tb );
   1.203      a->addTo( menu );
   1.204 @@ -255,60 +275,77 @@
   1.205  
   1.206  void TextEditor::setupEditActions()
   1.207  {
   1.208 -    QToolBar *tb = new QToolBar( this );
   1.209 +    Q3ToolBar *tb = new Q3ToolBar( this );
   1.210      tb->setLabel( "Edit Actions" );
   1.211 -    QPopupMenu *menu = new QPopupMenu( this );
   1.212 +    Q3PopupMenu *menu = new Q3PopupMenu( this );
   1.213      menuBar()->insertItem( tr( "&Edit" ), menu );
   1.214  
   1.215      QAction *a;
   1.216 -    a = new QAction( tr( "Undo" ), QPixmap(editundo_xpm), tr( "&Undo" ), CTRL + Key_Z, this, "undoEvent" );
   1.217 +    a = new QAction(QPixmap(iconPath+"undo.png"), tr( "&Undo" ), this );
   1.218 +	a->setStatusTip ( tr( "Undo" ) );
   1.219 +	a->setShortcut(Qt::CTRL + Qt::Key_Z );
   1.220      connect( a, SIGNAL( activated() ), e, SLOT( undo() ) );
   1.221      a->addTo( menu );
   1.222      a->addTo( tb);
   1.223  	actionEditUndo=a;
   1.224  	
   1.225 -    a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); 
   1.226 +    a = new QAction(QPixmap(iconPath+"redo.png" ), tr( "&Redo" ),this); 
   1.227 +	a->setStatusTip ( tr( "Redo" ) );
   1.228 +	a->setShortcut( Qt::CTRL + Qt::Key_Y );
   1.229      connect( a, SIGNAL( activated() ), e, SLOT( redo() ) );
   1.230      a->addTo( tb );
   1.231      a->addTo( menu );
   1.232  	actionEditRedo=a;
   1.233  
   1.234      menu->insertSeparator();
   1.235 -    a = new QAction( tr( "Select and copy all" ), QPixmap(), tr( "Select and copy &all" ), CTRL + Key_A, this, "editcopyall" ); 
   1.236 +    a = new QAction(QPixmap(), tr( "Select and copy &all" ),this); 
   1.237 +	a->setStatusTip ( tr( "Select and copy all" ) );
   1.238 +	a->setShortcut( Qt::CTRL + Qt::Key_A );
   1.239      connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) );
   1.240      a->addTo( menu );
   1.241  
   1.242      menu->insertSeparator();
   1.243 -    a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
   1.244 +    a = new QAction(QPixmap(iconPath+"editcopy.png" ), tr( "&Copy" ),this);
   1.245 +	a->setStatusTip ( tr( "Copy" ) );
   1.246 +	a->setShortcut( Qt::CTRL + Qt::Key_C );
   1.247      connect( a, SIGNAL( activated() ), e, SLOT( copy() ) );
   1.248      a->addTo( tb );
   1.249      a->addTo( menu );
   1.250  	actionEditCopy=a;
   1.251  	
   1.252 -    a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
   1.253 +    a = new QAction(QPixmap(iconPath+"editcut.png" ), tr( "Cu&t" ),this);
   1.254 +	a->setStatusTip ( tr( "Cut" ) );
   1.255 +	a->setShortcut( Qt::CTRL + Qt::Key_X );
   1.256      connect( a, SIGNAL( activated() ), e, SLOT( cut() ) );
   1.257      a->addTo( tb );
   1.258      a->addTo( menu );
   1.259  	actionEditCut=a;
   1.260  
   1.261 -    a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
   1.262 +    a = new QAction(QPixmap(iconPath+"editpaste.png" ), tr( "&Paste" ),this);
   1.263 +	a->setStatusTip ( tr( "Paste" ) );
   1.264 +	a->setShortcut( Qt::CTRL + Qt::Key_V );
   1.265      connect( a, SIGNAL( activated() ), e, SLOT( paste() ) );
   1.266      a->addTo( tb );
   1.267      a->addTo( menu );
   1.268  	actionEditPaste=a;
   1.269  	
   1.270 -    a = new QAction( tr( "Delete all" ), QPixmap( edittrash_xpm ), tr( "&Delete All" ), 0, this, "editDeleteAll" );
   1.271 +    a = new QAction( QPixmap( iconPath+"edittrash.png"), tr( "&Delete All" ), this);
   1.272 +	a->setStatusTip (tr( "Delete all" ) );
   1.273      connect( a, SIGNAL( activated() ), e, SLOT( clear() ) );
   1.274      a->addTo( tb );
   1.275      a->addTo( menu );
   1.276  	actionEditDeleteAll=a;
   1.277  
   1.278 -	a = new QAction( tr( "Convert paragraphs to linebreaks" ), QPixmap(), tr( "&Convert Paragraphs" ), ALT + Key_P, this, "editConvertPar" );
   1.279 +	a = new QAction(QPixmap(), tr( "&Convert Paragraphs" ),this);
   1.280 +	a->setStatusTip(tr( "Convert paragraphs to linebreaks" )); 
   1.281 +	a->setShortcut( Qt::ALT + Qt::Key_P );
   1.282      connect( a, SIGNAL( activated() ), this, SLOT( textConvertPar() ) );
   1.283      a->addTo( menu );
   1.284  	actionEditConvertPar=a;
   1.285  
   1.286 -	a = new QAction( tr( "Join all lines of a paragraph" ), QPixmap(), tr( "&Join lines" ), ALT + Key_J, this, "editJoinLines" );
   1.287 +	a = new QAction( QPixmap(), tr( "&Join lines" ), this);
   1.288 +	a->setStatusTip(tr( "Join all lines of a paragraph" ) ); 
   1.289 +	a->setShortcut(Qt::ALT + Qt::Key_J );
   1.290      connect( a, SIGNAL( activated() ), this, SLOT( textJoinLines() ) );
   1.291      a->addTo( menu );
   1.292  	actionEditJoinLines=a;
   1.293 @@ -316,14 +353,15 @@
   1.294  
   1.295  void TextEditor::setupFormatActions()
   1.296  {
   1.297 -    QToolBar *tb = new QToolBar( this );
   1.298 +    Q3ToolBar *tb = new Q3ToolBar( this );
   1.299      tb->setLabel( "Format Actions" );
   1.300 -    QPopupMenu *menu = new QPopupMenu( this );
   1.301 -    menuBar()->insertItem( tr( "&Format" ), menu );
   1.302 +    Q3PopupMenu *menu = new Q3PopupMenu( this );
   1.303 +    menuBar()->insertItem( tr( "F&ormat" ), menu );
   1.304  
   1.305      QAction *a;
   1.306  
   1.307 -    a = new QAction( tr( "Toggle font hint for the whole text" ), QPixmap(formatfixedfont_xpm), tr( "&Font hint" ), ALT + Key_I, this, "fontHint" );
   1.308 +    a = new QAction( QPixmap(iconPath+"formatfixedfont.png"), tr( "&Font hint" ), Qt::ALT + Qt::Key_I, this, "fontHint" );
   1.309 +	a->setStatusTip (tr( "Toggle font hint for the whole text" ) );
   1.310  	a->setToggleAction (true);
   1.311  	a->setOn (settings.readBoolEntry ("/vym/noteeditor/fonts/useFixedByDefault",false) );
   1.312      connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) );
   1.313 @@ -341,8 +379,8 @@
   1.314      comboFont->lineEdit()->setText( QApplication::font().family() );
   1.315  
   1.316      comboSize = new QComboBox( true, tb );
   1.317 -    QValueList<int> sizes = db.standardSizes();
   1.318 -    QValueList<int>::Iterator it = sizes.begin();
   1.319 +    Q3ValueList<int> sizes = db.standardSizes();
   1.320 +    Q3ValueList<int>::Iterator it = sizes.begin();
   1.321      for ( ; it != sizes.end(); ++it )
   1.322  	comboSize->insertItem( QString::number( *it ) );
   1.323      connect( comboSize, SIGNAL( activated( const QString & ) ),
   1.324 @@ -353,69 +391,98 @@
   1.325  
   1.326      QPixmap pix( 16, 16 );
   1.327      pix.fill( e->color());
   1.328 -    actionTextColor = new QAction( pix, tr( "&Color..." ), 0, this, "textColor" );
   1.329 -    connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
   1.330 +    actionTextColor = new QAction( pix, tr( "&Color..." ), this);
   1.331      actionTextColor->addTo( tb );
   1.332      actionTextColor->addTo( menu );
   1.333 +    connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
   1.334  
   1.335 -    actionTextBold = new QAction( QPixmap (formattextbold_xpm), tr( "&Bold" ), CTRL + Key_B, this, "textBold" );
   1.336 +    actionTextBold = new QAction( QPixmap (iconPath+"text_bold.png"), tr( "&Bold" ), this);
   1.337 +	actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B );
   1.338      connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
   1.339      actionTextBold->addTo( tb );
   1.340      actionTextBold->addTo( menu );
   1.341      actionTextBold->setToggleAction( true );
   1.342 -    actionTextItalic = new QAction( QPixmap(formattextitalic_xpm ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" );
   1.343 +    actionTextItalic = new QAction( QPixmap(iconPath+"text_italic.png"), tr( "&Italic" ),  this);
   1.344 +	actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I);
   1.345      connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) );
   1.346      actionTextItalic->addTo( tb );
   1.347      actionTextItalic->addTo( menu );
   1.348      actionTextItalic->setToggleAction( true );
   1.349 -    actionTextUnderline = new QAction( QPixmap (formattextunder_xpm ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" );
   1.350 +    actionTextUnderline = new QAction( QPixmap (iconPath+"text_under.png"), tr( "&Underline" ), this);
   1.351 +	actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U );
   1.352      connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
   1.353      actionTextUnderline->addTo( tb );
   1.354      actionTextUnderline->addTo( menu );
   1.355      actionTextUnderline->setToggleAction( true );
   1.356      menu->insertSeparator();
   1.357  
   1.358 -    QActionGroup *grp = new QActionGroup( this );
   1.359 +    Q3ActionGroup *grp = new Q3ActionGroup( this );
   1.360      connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
   1.361  
   1.362 -    actionAlignLeft = new QAction( QPixmap (formattextleft_xpm ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" );
   1.363 +    actionAlignLeft = new QAction( QPixmap (iconPath+"text_left.png"), tr( "&Left" ),grp );
   1.364 +	actionAlignLeft->setShortcut( Qt::CTRL+Qt::Key_L );
   1.365      actionAlignLeft->setToggleAction( true );
   1.366 -    actionAlignCenter = new QAction( QPixmap (formattextcenter_xpm ), tr( "C&enter" ), CTRL + Key_E, grp, "textCenter" );
   1.367 +    actionAlignCenter = new QAction( QPixmap (iconPath+"text_center.png"), tr( "C&enter" ),grp);
   1.368 +    actionAlignCenter->setShortcut(  Qt::CTRL + Qt::Key_E);
   1.369      actionAlignCenter->setToggleAction( true );
   1.370 -    actionAlignRight = new QAction( QPixmap (formattextright_xpm ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" );
   1.371 +    actionAlignRight = new QAction( QPixmap (iconPath+"text_right.png" ), tr( "&Right" ), grp);
   1.372 +	actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R );
   1.373      actionAlignRight->setToggleAction( true );
   1.374 -    actionAlignJustify = new QAction( QPixmap ( formattextjustify_xpm ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" );
   1.375 +    actionAlignJustify = new QAction( QPixmap ( iconPath+"text_block.png"), tr( "&Justify" ), grp );
   1.376 +	actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J );
   1.377      actionAlignJustify->setToggleAction( true );
   1.378  
   1.379      grp->addTo( tb );
   1.380      grp->addTo( menu );
   1.381  
   1.382 +    Q3ActionGroup *grp2 = new Q3ActionGroup( this );
   1.383 +    grp2->setExclusive(false);
   1.384 +    actionAlignSubScript = new QAction( QPixmap (iconPath+"text_sub.png"), tr( "Subs&cript" ),grp2 );
   1.385 +	actionAlignSubScript->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_B );
   1.386 +    actionAlignSubScript->setToggleAction( true );
   1.387 +    connect(actionAlignSubScript, SIGNAL(activated()), this, SLOT(textVAlign()));
   1.388 +
   1.389 +    actionAlignSuperScript = new QAction( QPixmap (iconPath+"text_super.png"), tr( "Su&perscript" ),grp2  );
   1.390 +	actionAlignSuperScript->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P );
   1.391 +    actionAlignSuperScript->setToggleAction( true );
   1.392 +    connect(actionAlignSuperScript, SIGNAL(activated()), this, SLOT(textVAlign()));
   1.393 +
   1.394 +    menu->insertSeparator();
   1.395 +    
   1.396 +    grp2->addTo(tb);
   1.397 +    grp2->addTo(menu);
   1.398 +
   1.399      connect( e, SIGNAL( currentFontChanged( const QFont & ) ),
   1.400  	     this, SLOT( fontChanged( const QFont & ) ) );
   1.401      connect( e, SIGNAL( currentColorChanged( const QColor & ) ),
   1.402  	     this, SLOT( colorChanged( const QColor & ) ) );
   1.403      connect( e, SIGNAL( currentAlignmentChanged( int ) ),
   1.404  	     this, SLOT( alignmentChanged( int ) ) );
   1.405 +    connect( e, SIGNAL( currentVerticalAlignmentChanged(int)),
   1.406 +	     this, SLOT( verticalAlignmentChanged(int)));
   1.407  
   1.408  }
   1.409  
   1.410  void TextEditor::setupSettingsActions()
   1.411  {
   1.412 -    QPopupMenu *menu = new QPopupMenu( this );
   1.413 +    Q3PopupMenu *menu = new Q3PopupMenu( this );
   1.414      menuBar()->insertItem( tr( "&Settings" ), menu );
   1.415  
   1.416      QAction *a;
   1.417 -    a = new QAction( tr( "Set fixed font" ), QPixmap(), tr( "Set &fixed font" ), 0, this, "setFixedFont" );
   1.418 +    a = new QAction(tr( "Set &fixed font" ), this);
   1.419 +	a->setStatusTip ( tr( "Set fixed font" ));
   1.420      connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) );
   1.421      a->addTo( menu );
   1.422  	actionSettingsFixedFont=a;
   1.423  
   1.424 -    a = new QAction( tr( "Set variable font" ), QPixmap(), tr( "Set &variable font" ), 0, this, "setvariableFont" );
   1.425 +    a = new QAction(tr( "Set &variable font" ), this);
   1.426 +	a->setStatusTip ( tr( "Set variable font" ) );
   1.427      connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) );
   1.428      a->addTo( menu );
   1.429  	actionSettingsVarFont=a;
   1.430  
   1.431 -    a = new QAction( tr( "Used fixed font by default" ), QPixmap(), tr( "&fixed font is default" ), 0, this, "fonthintDefault" );
   1.432 +    a = new QAction(tr( "&fixed font is default" ),  this);
   1.433 +	a->setStatusTip (tr( "Used fixed font by default" ) );
   1.434  	a->setToggleAction (true);
   1.435  	// set state later in constructor...
   1.436      a->addTo( menu );
   1.437 @@ -428,7 +495,7 @@
   1.438  	{
   1.439  		if (e->length()) 
   1.440  		{
   1.441 -			QMessageBox mb( "VYM - Note Editor",
   1.442 +			QMessageBox mb( __VYM " - " +tr("Note Editor"),
   1.443  				"Loading will overwrite the existing note",
   1.444  				QMessageBox::Warning,
   1.445  				QMessageBox::Yes | QMessageBox::Default,
   1.446 @@ -442,7 +509,7 @@
   1.447  			}
   1.448  		} 
   1.449  		// Load note
   1.450 -		QFileDialog *fd=new QFileDialog( this);
   1.451 +		Q3FileDialog *fd=new Q3FileDialog( this);
   1.452  		fd->addFilter ("ASCII texts (*.txt)");
   1.453  		fd->addFilter ("VYM notes (*.html)");
   1.454  		fd->show();
   1.455 @@ -453,7 +520,7 @@
   1.456  		if ( !fn.isEmpty() )
   1.457  		{
   1.458  			QFile f( fn );
   1.459 -			if ( !f.open( IO_ReadOnly ) )
   1.460 +			if ( !f.open( QIODevice::ReadOnly ) )
   1.461  			return;
   1.462  
   1.463  			QTextStream ts( &f );
   1.464 @@ -465,11 +532,10 @@
   1.465  
   1.466  void TextEditor::closeEvent( QCloseEvent* ce )
   1.467  {
   1.468 -    if ( !e->isModified() ) 
   1.469 -	{
   1.470 -		ce->accept();	// TextEditor can be reopened with show()
   1.471 -		return;
   1.472 -    }
   1.473 +    ce->accept();	// TextEditor can be reopened with show()
   1.474 +    actionViewToggleNoteEditor->setOn (false);
   1.475 +    showwithmain=false;
   1.476 +    return;
   1.477  }
   1.478  
   1.479  QString TextEditor::getText()
   1.480 @@ -479,21 +545,15 @@
   1.481  
   1.482  void TextEditor::editorChanged()
   1.483  {
   1.484 -	// received, when QTextEdit::text() has changed
   1.485 -	EditorState	oldstate=state;
   1.486 -
   1.487  	if (isEmpty())
   1.488  		state=emptyEditor;
   1.489  	else
   1.490  		state=filledEditor;
   1.491  
   1.492 -	if (state != oldstate)
   1.493 -	{
   1.494  		if (state==emptyEditor)
   1.495  			e->setPaper (emptyPaper);
   1.496  		else
   1.497  			e->setPaper (filledPaper);
   1.498 -	}
   1.499  	// SLOT is LinkableMapObj, which will update systemFlag
   1.500  	emit (textHasChanged() );
   1.501  }
   1.502 @@ -501,19 +561,19 @@
   1.503  
   1.504  void TextEditor::setText(QString t)
   1.505  {
   1.506 -	if ( !QStyleSheet::mightBeRichText( t ) )
   1.507 -		t = QStyleSheet::convertFromPlainText( t, QStyleSheetItem::WhiteSpaceNormal );
   1.508 +	if ( !Q3StyleSheet::mightBeRichText( t ) )
   1.509 +		t = Q3StyleSheet::convertFromPlainText( t, Q3StyleSheetItem::WhiteSpaceNormal );
   1.510  	e->setReadOnly(false);
   1.511  	e->setText(t);
   1.512 -	editorChanged();	//not called automagically
   1.513 +//	editorChanged();	//not called automagically  FIXME or is it?
   1.514  
   1.515  	enableActions();
   1.516  }
   1.517  
   1.518  void TextEditor::setInactive()
   1.519  {
   1.520 +	state=inactiveEditor;
   1.521  	setText("");
   1.522 -	state=inactiveEditor;
   1.523  	e->setPaper (inactivePaper);
   1.524  	e->setReadOnly (true);
   1.525  
   1.526 @@ -528,7 +588,7 @@
   1.527  
   1.528  void TextEditor::textSaveAs()
   1.529  {
   1.530 -    QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)",
   1.531 +    QString fn = Q3FileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)",
   1.532  					       this,"export note dialog",tr("Export Note to single file") );
   1.533  
   1.534      if ( !fn.isEmpty() ) 
   1.535 @@ -536,14 +596,14 @@
   1.536  		QFile file (fn);
   1.537  		if (file.exists())
   1.538  		{
   1.539 -			QMessageBox mb( "VYM",
   1.540 +			QMessageBox mb( __VYM,
   1.541  				tr("The file ") + fn + 
   1.542  				tr(" exists already. "
   1.543  				"Do you want to overwrite it?"),
   1.544  			QMessageBox::Warning,
   1.545  			QMessageBox::Yes | QMessageBox::Default,
   1.546  			QMessageBox::Cancel | QMessageBox::Escape,
   1.547 -			QMessageBox::NoButton );
   1.548 +			Qt::NoButton );
   1.549  			mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
   1.550  			mb.setButtonText( QMessageBox::No, tr("Cancel"));
   1.551  			switch( mb.exec() ) {
   1.552 @@ -577,7 +637,7 @@
   1.553  
   1.554      QString text = e->text();
   1.555      QFile f( filename );
   1.556 -    if ( !f.open( IO_WriteOnly ) ) 
   1.557 +    if ( !f.open( QIODevice::WriteOnly ) ) 
   1.558  	{
   1.559  		statusBar()->message( QString("Could not write to %1").arg(filename),
   1.560  					  statusbarTime );
   1.561 @@ -659,38 +719,19 @@
   1.562  		e->setText(t);
   1.563  }
   1.564  
   1.565 -QString TextEditor::textConvertToASCII(const QString &t)
   1.566 -{
   1.567 -	QString r=t;
   1.568 -
   1.569 -	// convert all "<br*>" to "\n"
   1.570 -	QRegExp re("<br.*>");
   1.571 -	re.setMinimal(true);
   1.572 -	r.replace (re,"\n");
   1.573 -
   1.574 -	// convert all "</p>" to "\n"
   1.575 -	re.setPattern ("/p");
   1.576 -	r.replace (re,"\n");
   1.577 -	
   1.578 -	// remove all remaining tags 
   1.579 -	re.setPattern ("<.*>");
   1.580 -	r.replace (re,"");
   1.581 -
   1.582 -	// convert "&", "<" and ">"
   1.583 -	re.setPattern ("&gt;");
   1.584 -	r.replace (re,">");
   1.585 -	re.setPattern ("&lt;");
   1.586 -	r.replace (re,"<");
   1.587 -	re.setPattern ("&amp;");
   1.588 -	r.replace (re,"&");
   1.589 -	return r;
   1.590 -}
   1.591 -
   1.592  void TextEditor::textExportAsASCII()
   1.593  {
   1.594 -	QString text = textConvertToASCII( e->text());
   1.595 -    QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (ASCII) (*.txt);;All files (*)",
   1.596 -					       this,"export note dialog",tr("Export Note to single file (ASCII)") );
   1.597 +	QString text = NoteObj (e->text()).getNoteASCII();
   1.598 +	QString fn,s;
   1.599 +	if (!filenameHint.isEmpty())
   1.600 +	{
   1.601 +		if (!filenameHint.contains (".txt"))
   1.602 +			s=filenameHint+".txt";
   1.603 +		else	
   1.604 +			s=filenameHint;
   1.605 +	} else	
   1.606 +		s=QString::null;
   1.607 +	fn = Q3FileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") );
   1.608  	int ret=-1;
   1.609  
   1.610      if ( !fn.isEmpty() ) 
   1.611 @@ -705,7 +746,7 @@
   1.612  			QMessageBox::Warning,
   1.613  			QMessageBox::Yes | QMessageBox::Default,
   1.614  			QMessageBox::Cancel | QMessageBox::Escape,
   1.615 -			QMessageBox::NoButton );
   1.616 +			Qt::NoButton );
   1.617  			mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
   1.618  			mb.setButtonText( QMessageBox::No, tr("Cancel"));
   1.619  			ret=mb.exec();
   1.620 @@ -714,7 +755,7 @@
   1.621  			return;
   1.622  			
   1.623  		// save 
   1.624 -		if ( !file.open( IO_WriteOnly ) ) 
   1.625 +		if ( !file.open( QIODevice::WriteOnly ) ) 
   1.626  			statusBar()->message( QString("Could not write to %1").arg(filename),
   1.627  						  statusbarTime );
   1.628  		else
   1.629 @@ -737,14 +778,14 @@
   1.630  		QPainter p( printer );
   1.631  		// Check that there is a valid device to print to.
   1.632  		if ( !p.device() ) return;
   1.633 -		QPaintDeviceMetrics metrics( p.device() );
   1.634 +		Q3PaintDeviceMetrics metrics( p.device() );
   1.635  		int dpiy = metrics.logicalDpiY();
   1.636  		int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins
   1.637  		QRect body( margin, margin, metrics.width() - 2*margin, metrics.height() - 2*margin );
   1.638  		QFont font( e->currentFont() );
   1.639  		font.setPointSize( 10 ); // we define 10pt to be a nice base size for printing
   1.640  
   1.641 -		QSimpleRichText richText( e->text(), font,
   1.642 +		Q3SimpleRichText richText( e->text(), font,
   1.643  					  e->context(),
   1.644  					  e->styleSheet(),
   1.645  					  e->mimeSourceFactory(),
   1.646 @@ -838,22 +879,34 @@
   1.647  	return;
   1.648      e->setColor( col );
   1.649      QPixmap pix( 16, 16 );
   1.650 -    pix.fill( black );
   1.651 +    pix.fill( Qt::black );
   1.652      actionTextColor->setIconSet( pix );
   1.653  }
   1.654  
   1.655  void TextEditor::textAlign( QAction *a )
   1.656  {
   1.657      if ( a == actionAlignLeft )
   1.658 -	e->setAlignment( AlignLeft );
   1.659 +	e->setAlignment( Qt::AlignLeft );
   1.660      else if ( a == actionAlignCenter )
   1.661 -	e->setAlignment( AlignHCenter );
   1.662 +	e->setAlignment( Qt::AlignHCenter );
   1.663      else if ( a == actionAlignRight )
   1.664 -	e->setAlignment( AlignRight );
   1.665 +	e->setAlignment( Qt::AlignRight );
   1.666      else if ( a == actionAlignJustify )
   1.667 -	e->setAlignment( AlignJustify );
   1.668 +	e->setAlignment( Qt::AlignJustify );
   1.669  }
   1.670  
   1.671 +void TextEditor::textVAlign()
   1.672 +{
   1.673 +    if ( sender() == actionAlignSuperScript && actionAlignSuperScript->isOn()) {
   1.674 +	e->setVerticalAlignment( Q3TextEdit::AlignSuperScript);
   1.675 +    } else if (sender() == actionAlignSubScript && actionAlignSubScript->isOn()) {
   1.676 +	e->setVerticalAlignment( Q3TextEdit::AlignSubScript);
   1.677 +    } else {
   1.678 +	e->setVerticalAlignment( Q3TextEdit::AlignNormal);
   1.679 +    }
   1.680 +}
   1.681 +
   1.682 +
   1.683  void TextEditor::fontChanged( const QFont &f )
   1.684  {
   1.685      comboFont->lineEdit()->setText( f.family() );
   1.686 @@ -872,16 +925,30 @@
   1.687  
   1.688  void TextEditor::alignmentChanged( int a )
   1.689  {
   1.690 -    if ( ( a == AlignAuto ) || ( a & AlignLeft ))
   1.691 +    if ( ( a == Qt::AlignLeft ) || ( a & Qt::AlignLeft ))
   1.692  	actionAlignLeft->setOn( true );
   1.693 -    else if ( ( a & AlignHCenter ) )
   1.694 +    else if ( ( a & Qt::AlignHCenter ) )
   1.695  	actionAlignCenter->setOn( true );
   1.696 -    else if ( ( a & AlignRight ) )
   1.697 +    else if ( ( a & Qt::AlignRight ) )
   1.698  	actionAlignRight->setOn( true );
   1.699 -    else if ( ( a & AlignJustify ) )
   1.700 +    else if ( ( a & Qt::AlignJustify ) )
   1.701  	actionAlignJustify->setOn( true );
   1.702  }
   1.703  
   1.704 +void TextEditor::verticalAlignmentChanged(int a) 
   1.705 +{
   1.706 +    if (a == Q3TextEdit::AlignSuperScript ) {
   1.707 +	actionAlignSuperScript->setOn(true);
   1.708 +	actionAlignSubScript->setOn(false);
   1.709 +    } else if (a == Q3TextEdit::AlignSubScript ) {
   1.710 +	actionAlignSuperScript->setOn(false);
   1.711 +	actionAlignSubScript->setOn(true);
   1.712 +    } else {
   1.713 +	actionAlignSuperScript->setOn(false);
   1.714 +	actionAlignSubScript->setOn(false);
   1.715 +    }
   1.716 +}
   1.717 +
   1.718  
   1.719  
   1.720  void TextEditor::enableActions()