diff -r 9eb7767c2dfa -r 608f976aa7bb texteditor.cpp --- a/texteditor.cpp Sun Jan 30 12:58:47 2005 +0000 +++ b/texteditor.cpp Tue Jun 06 14:58:11 2006 +0000 @@ -1,6 +1,6 @@ #include "texteditor.h" -#include +#include #include #include #include @@ -8,68 +8,65 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include -#include -#include +#include +#include #include -#include +#include #include #include #include #include #include #include -#include +#include +//Added by qt3to4: +#include +#include +#include +#include #include -#include +#include #include -#include "icons/fileopen.xpm" -#include "icons/filesave.xpm" -#include "icons/fileprint.xpm" -#include "icons/editundo.xpm" -#include "icons/editredo.xpm" -#include "icons/editcopy.xpm" -#include "icons/editcut.xpm" -#include "icons/editpaste.xpm" -#include "icons/edittrash.xpm" -#include "icons/formatfixedfont.xpm" -#include "icons/formattextbold.xpm" -#include "icons/formattextitalic.xpm" -#include "icons/formattextunder.xpm" -#include "icons/formattextleft.xpm" -#include "icons/formattextcenter.xpm" -#include "icons/formattextright.xpm" -#include "icons/formattextjustify.xpm" +#include "noteobj.h" +#include "version.h" -extern QCanvas* actCanvas; +extern Q3Canvas* actCanvas; extern int statusbarTime; extern QSettings settings; +extern QAction *actionViewToggleNoteEditor; + +extern QString iconPath; + using namespace std; /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// + TextEditor::TextEditor() { printer = new QPrinter( QPrinter::HighResolution ); + printer->setPrinterName (settings.readEntry("/vym/mainwindow/printerName",printer->printerName())); - // Editor - e = new QTextEdit( this, "editor" ); + // Editor (use MyTextEdit to wrap verticalAlignmentChanged to + // int argument. see header file) + e = new MyTextEdit( this, "editor" ); e->setFocus(); - e->setTextFormat(RichText); // default + e->setTextFormat(Qt::RichText); // default e->setTabStopWidth (20); // unit is pixel - e->setColor (black); + e->setColor (Qt::black); connect (e, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); setCentralWidget( e ); statusBar()->message( "Ready", statusbarTime); - setCaption("VYM - Note Editor"); + setCaption(__VYM " - " +tr ("Note Editor")); // Toolbars setupFileActions(); @@ -78,9 +75,9 @@ setupSettingsActions(); // Various states - emptyPaper = QBrush(gray); - filledPaper = QBrush(white); - inactivePaper= QBrush(black); + emptyPaper = QBrush(Qt::gray); + filledPaper = QBrush(Qt::white); + inactivePaper= QBrush(Qt::black); setInactive(); // Load Settings @@ -112,6 +109,10 @@ actionSettingsFonthintDefault->setOn (false); e->setCurrentFont (varFont); } + filenameHint=""; + + // Save settings in vymrc + settings.writeEntry("/vym/mainwindow/printerName",printer->printerName()); } @@ -204,6 +205,16 @@ return filename; } +void TextEditor::setFilenameHint(const QString &fnh) +{ + filenameHint=fnh; +} + +QString TextEditor::getFilenameHint() +{ + return filenameHint; +} + bool TextEditor::findText(const QString &t, const bool &cs) { bool wo=false; // word matches @@ -215,13 +226,15 @@ void TextEditor::setupFileActions() { - QToolBar *tb = new QToolBar( this ); + Q3ToolBar *tb = new Q3ToolBar( this ); tb->setLabel( "File Actions" ); - QPopupMenu *menu = new QPopupMenu( this ); + Q3PopupMenu *menu = new Q3PopupMenu( this ); menuBar()->insertItem( tr( "&File" ), menu ); QAction *a; - a = new QAction( tr( "Import" ), QPixmap( fileopen_xpm), tr( "&Import..." ), CTRL + Key_O, this, "fileImport" ); + a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Import..." ),this); + a->setStatusTip (tr( "Import" ) ); + a->setShortcut( Qt::CTRL + Qt::Key_O ); connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) ); a->setEnabled(false); a->addTo( tb ); @@ -229,24 +242,31 @@ actionFileLoad=a; menu->insertSeparator(); - a = new QAction( tr( "Export Note (HTML)" ), QPixmap( filesave_xpm ), tr( "&Export..." ), CTRL + Key_S, this, "fileSave" ); + a = new QAction( QPixmap(iconPath+"filesave.png" ), tr( "&Export..." ),this); + a->setStatusTip (tr( "Export Note (HTML)" ) ); + a->setShortcut( Qt::CTRL + Qt::Key_S ); connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) ); a->addTo( tb ); a->addTo( menu ); actionFileSave=a; - a = new QAction( tr( "Export Note As (HTML) " ), QPixmap(), tr( "Export &As... (HTML)" ), 0, this, "exportHTML" ); + a = new QAction( QPixmap(), tr( "Export &As... (HTML)" ), this); + a->setStatusTip (tr( "Export Note As (HTML) " )); connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) ); a->addTo( menu ); actionFileSaveAs=a; - a = new QAction( tr( "Export Note As (ASCII) " ), QPixmap(), tr( "Export &As...(ASCII)" ), ALT + Key_X, this, "exportASCII" ); + a = new QAction(QPixmap(), tr( "Export &As...(ASCII)" ), this); + a->setStatusTip ( tr( "Export Note As (ASCII) " ) ); + a->setShortcut(Qt::ALT + Qt::Key_X ); connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) ); a->addTo( menu ); actionFileSaveAs=a; menu->insertSeparator(); - a = new QAction( tr( "Print Note" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" ); + a = new QAction( QPixmap(iconPath+"fileprint.png" ), tr( "&Print..." ),this); + a->setStatusTip (tr( "Print Note" ) ); + a->setShortcut( Qt::CTRL + Qt::Key_P ); connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) ); a->addTo( tb ); a->addTo( menu ); @@ -255,60 +275,77 @@ void TextEditor::setupEditActions() { - QToolBar *tb = new QToolBar( this ); + Q3ToolBar *tb = new Q3ToolBar( this ); tb->setLabel( "Edit Actions" ); - QPopupMenu *menu = new QPopupMenu( this ); + Q3PopupMenu *menu = new Q3PopupMenu( this ); menuBar()->insertItem( tr( "&Edit" ), menu ); QAction *a; - a = new QAction( tr( "Undo" ), QPixmap(editundo_xpm), tr( "&Undo" ), CTRL + Key_Z, this, "undoEvent" ); + a = new QAction(QPixmap(iconPath+"undo.png"), tr( "&Undo" ), this ); + a->setStatusTip ( tr( "Undo" ) ); + a->setShortcut(Qt::CTRL + Qt::Key_Z ); connect( a, SIGNAL( activated() ), e, SLOT( undo() ) ); a->addTo( menu ); a->addTo( tb); actionEditUndo=a; - a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); + a = new QAction(QPixmap(iconPath+"redo.png" ), tr( "&Redo" ),this); + a->setStatusTip ( tr( "Redo" ) ); + a->setShortcut( Qt::CTRL + Qt::Key_Y ); connect( a, SIGNAL( activated() ), e, SLOT( redo() ) ); a->addTo( tb ); a->addTo( menu ); actionEditRedo=a; menu->insertSeparator(); - a = new QAction( tr( "Select and copy all" ), QPixmap(), tr( "Select and copy &all" ), CTRL + Key_A, this, "editcopyall" ); + a = new QAction(QPixmap(), tr( "Select and copy &all" ),this); + a->setStatusTip ( tr( "Select and copy all" ) ); + a->setShortcut( Qt::CTRL + Qt::Key_A ); connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) ); a->addTo( menu ); menu->insertSeparator(); - a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" ); + a = new QAction(QPixmap(iconPath+"editcopy.png" ), tr( "&Copy" ),this); + a->setStatusTip ( tr( "Copy" ) ); + a->setShortcut( Qt::CTRL + Qt::Key_C ); connect( a, SIGNAL( activated() ), e, SLOT( copy() ) ); a->addTo( tb ); a->addTo( menu ); actionEditCopy=a; - a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" ); + a = new QAction(QPixmap(iconPath+"editcut.png" ), tr( "Cu&t" ),this); + a->setStatusTip ( tr( "Cut" ) ); + a->setShortcut( Qt::CTRL + Qt::Key_X ); connect( a, SIGNAL( activated() ), e, SLOT( cut() ) ); a->addTo( tb ); a->addTo( menu ); actionEditCut=a; - a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" ); + a = new QAction(QPixmap(iconPath+"editpaste.png" ), tr( "&Paste" ),this); + a->setStatusTip ( tr( "Paste" ) ); + a->setShortcut( Qt::CTRL + Qt::Key_V ); connect( a, SIGNAL( activated() ), e, SLOT( paste() ) ); a->addTo( tb ); a->addTo( menu ); actionEditPaste=a; - a = new QAction( tr( "Delete all" ), QPixmap( edittrash_xpm ), tr( "&Delete All" ), 0, this, "editDeleteAll" ); + a = new QAction( QPixmap( iconPath+"edittrash.png"), tr( "&Delete All" ), this); + a->setStatusTip (tr( "Delete all" ) ); connect( a, SIGNAL( activated() ), e, SLOT( clear() ) ); a->addTo( tb ); a->addTo( menu ); actionEditDeleteAll=a; - a = new QAction( tr( "Convert paragraphs to linebreaks" ), QPixmap(), tr( "&Convert Paragraphs" ), ALT + Key_P, this, "editConvertPar" ); + a = new QAction(QPixmap(), tr( "&Convert Paragraphs" ),this); + a->setStatusTip(tr( "Convert paragraphs to linebreaks" )); + a->setShortcut( Qt::ALT + Qt::Key_P ); connect( a, SIGNAL( activated() ), this, SLOT( textConvertPar() ) ); a->addTo( menu ); actionEditConvertPar=a; - a = new QAction( tr( "Join all lines of a paragraph" ), QPixmap(), tr( "&Join lines" ), ALT + Key_J, this, "editJoinLines" ); + a = new QAction( QPixmap(), tr( "&Join lines" ), this); + a->setStatusTip(tr( "Join all lines of a paragraph" ) ); + a->setShortcut(Qt::ALT + Qt::Key_J ); connect( a, SIGNAL( activated() ), this, SLOT( textJoinLines() ) ); a->addTo( menu ); actionEditJoinLines=a; @@ -316,14 +353,15 @@ void TextEditor::setupFormatActions() { - QToolBar *tb = new QToolBar( this ); + Q3ToolBar *tb = new Q3ToolBar( this ); tb->setLabel( "Format Actions" ); - QPopupMenu *menu = new QPopupMenu( this ); - menuBar()->insertItem( tr( "&Format" ), menu ); + Q3PopupMenu *menu = new Q3PopupMenu( this ); + menuBar()->insertItem( tr( "F&ormat" ), menu ); QAction *a; - a = new QAction( tr( "Toggle font hint for the whole text" ), QPixmap(formatfixedfont_xpm), tr( "&Font hint" ), ALT + Key_I, this, "fontHint" ); + a = new QAction( QPixmap(iconPath+"formatfixedfont.png"), tr( "&Font hint" ), Qt::ALT + Qt::Key_I, this, "fontHint" ); + a->setStatusTip (tr( "Toggle font hint for the whole text" ) ); a->setToggleAction (true); a->setOn (settings.readBoolEntry ("/vym/noteeditor/fonts/useFixedByDefault",false) ); connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) ); @@ -341,8 +379,8 @@ comboFont->lineEdit()->setText( QApplication::font().family() ); comboSize = new QComboBox( true, tb ); - QValueList sizes = db.standardSizes(); - QValueList::Iterator it = sizes.begin(); + Q3ValueList sizes = db.standardSizes(); + Q3ValueList::Iterator it = sizes.begin(); for ( ; it != sizes.end(); ++it ) comboSize->insertItem( QString::number( *it ) ); connect( comboSize, SIGNAL( activated( const QString & ) ), @@ -353,69 +391,98 @@ QPixmap pix( 16, 16 ); pix.fill( e->color()); - actionTextColor = new QAction( pix, tr( "&Color..." ), 0, this, "textColor" ); - connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) ); + actionTextColor = new QAction( pix, tr( "&Color..." ), this); actionTextColor->addTo( tb ); actionTextColor->addTo( menu ); + connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) ); - actionTextBold = new QAction( QPixmap (formattextbold_xpm), tr( "&Bold" ), CTRL + Key_B, this, "textBold" ); + actionTextBold = new QAction( QPixmap (iconPath+"text_bold.png"), tr( "&Bold" ), this); + actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B ); connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) ); actionTextBold->addTo( tb ); actionTextBold->addTo( menu ); actionTextBold->setToggleAction( true ); - actionTextItalic = new QAction( QPixmap(formattextitalic_xpm ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" ); + actionTextItalic = new QAction( QPixmap(iconPath+"text_italic.png"), tr( "&Italic" ), this); + actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) ); actionTextItalic->addTo( tb ); actionTextItalic->addTo( menu ); actionTextItalic->setToggleAction( true ); - actionTextUnderline = new QAction( QPixmap (formattextunder_xpm ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" ); + actionTextUnderline = new QAction( QPixmap (iconPath+"text_under.png"), tr( "&Underline" ), this); + actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U ); connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) ); actionTextUnderline->addTo( tb ); actionTextUnderline->addTo( menu ); actionTextUnderline->setToggleAction( true ); menu->insertSeparator(); - QActionGroup *grp = new QActionGroup( this ); + Q3ActionGroup *grp = new Q3ActionGroup( this ); connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) ); - actionAlignLeft = new QAction( QPixmap (formattextleft_xpm ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" ); + actionAlignLeft = new QAction( QPixmap (iconPath+"text_left.png"), tr( "&Left" ),grp ); + actionAlignLeft->setShortcut( Qt::CTRL+Qt::Key_L ); actionAlignLeft->setToggleAction( true ); - actionAlignCenter = new QAction( QPixmap (formattextcenter_xpm ), tr( "C&enter" ), CTRL + Key_E, grp, "textCenter" ); + actionAlignCenter = new QAction( QPixmap (iconPath+"text_center.png"), tr( "C&enter" ),grp); + actionAlignCenter->setShortcut( Qt::CTRL + Qt::Key_E); actionAlignCenter->setToggleAction( true ); - actionAlignRight = new QAction( QPixmap (formattextright_xpm ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" ); + actionAlignRight = new QAction( QPixmap (iconPath+"text_right.png" ), tr( "&Right" ), grp); + actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R ); actionAlignRight->setToggleAction( true ); - actionAlignJustify = new QAction( QPixmap ( formattextjustify_xpm ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" ); + actionAlignJustify = new QAction( QPixmap ( iconPath+"text_block.png"), tr( "&Justify" ), grp ); + actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J ); actionAlignJustify->setToggleAction( true ); grp->addTo( tb ); grp->addTo( menu ); + Q3ActionGroup *grp2 = new Q3ActionGroup( this ); + grp2->setExclusive(false); + actionAlignSubScript = new QAction( QPixmap (iconPath+"text_sub.png"), tr( "Subs&cript" ),grp2 ); + actionAlignSubScript->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_B ); + actionAlignSubScript->setToggleAction( true ); + connect(actionAlignSubScript, SIGNAL(activated()), this, SLOT(textVAlign())); + + actionAlignSuperScript = new QAction( QPixmap (iconPath+"text_super.png"), tr( "Su&perscript" ),grp2 ); + actionAlignSuperScript->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P ); + actionAlignSuperScript->setToggleAction( true ); + connect(actionAlignSuperScript, SIGNAL(activated()), this, SLOT(textVAlign())); + + menu->insertSeparator(); + + grp2->addTo(tb); + grp2->addTo(menu); + connect( e, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( fontChanged( const QFont & ) ) ); connect( e, SIGNAL( currentColorChanged( const QColor & ) ), this, SLOT( colorChanged( const QColor & ) ) ); connect( e, SIGNAL( currentAlignmentChanged( int ) ), this, SLOT( alignmentChanged( int ) ) ); + connect( e, SIGNAL( currentVerticalAlignmentChanged(int)), + this, SLOT( verticalAlignmentChanged(int))); } void TextEditor::setupSettingsActions() { - QPopupMenu *menu = new QPopupMenu( this ); + Q3PopupMenu *menu = new Q3PopupMenu( this ); menuBar()->insertItem( tr( "&Settings" ), menu ); QAction *a; - a = new QAction( tr( "Set fixed font" ), QPixmap(), tr( "Set &fixed font" ), 0, this, "setFixedFont" ); + a = new QAction(tr( "Set &fixed font" ), this); + a->setStatusTip ( tr( "Set fixed font" )); connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) ); a->addTo( menu ); actionSettingsFixedFont=a; - a = new QAction( tr( "Set variable font" ), QPixmap(), tr( "Set &variable font" ), 0, this, "setvariableFont" ); + a = new QAction(tr( "Set &variable font" ), this); + a->setStatusTip ( tr( "Set variable font" ) ); connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) ); a->addTo( menu ); actionSettingsVarFont=a; - a = new QAction( tr( "Used fixed font by default" ), QPixmap(), tr( "&fixed font is default" ), 0, this, "fonthintDefault" ); + a = new QAction(tr( "&fixed font is default" ), this); + a->setStatusTip (tr( "Used fixed font by default" ) ); a->setToggleAction (true); // set state later in constructor... a->addTo( menu ); @@ -428,7 +495,7 @@ { if (e->length()) { - QMessageBox mb( "VYM - Note Editor", + QMessageBox mb( __VYM " - " +tr("Note Editor"), "Loading will overwrite the existing note", QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, @@ -442,7 +509,7 @@ } } // Load note - QFileDialog *fd=new QFileDialog( this); + Q3FileDialog *fd=new Q3FileDialog( this); fd->addFilter ("ASCII texts (*.txt)"); fd->addFilter ("VYM notes (*.html)"); fd->show(); @@ -453,7 +520,7 @@ if ( !fn.isEmpty() ) { QFile f( fn ); - if ( !f.open( IO_ReadOnly ) ) + if ( !f.open( QIODevice::ReadOnly ) ) return; QTextStream ts( &f ); @@ -465,11 +532,10 @@ void TextEditor::closeEvent( QCloseEvent* ce ) { - if ( !e->isModified() ) - { - ce->accept(); // TextEditor can be reopened with show() - return; - } + ce->accept(); // TextEditor can be reopened with show() + actionViewToggleNoteEditor->setOn (false); + showwithmain=false; + return; } QString TextEditor::getText() @@ -479,21 +545,15 @@ void TextEditor::editorChanged() { - // received, when QTextEdit::text() has changed - EditorState oldstate=state; - if (isEmpty()) state=emptyEditor; else state=filledEditor; - if (state != oldstate) - { if (state==emptyEditor) e->setPaper (emptyPaper); else e->setPaper (filledPaper); - } // SLOT is LinkableMapObj, which will update systemFlag emit (textHasChanged() ); } @@ -501,19 +561,19 @@ void TextEditor::setText(QString t) { - if ( !QStyleSheet::mightBeRichText( t ) ) - t = QStyleSheet::convertFromPlainText( t, QStyleSheetItem::WhiteSpaceNormal ); + if ( !Q3StyleSheet::mightBeRichText( t ) ) + t = Q3StyleSheet::convertFromPlainText( t, Q3StyleSheetItem::WhiteSpaceNormal ); e->setReadOnly(false); e->setText(t); - editorChanged(); //not called automagically +// editorChanged(); //not called automagically FIXME or is it? enableActions(); } void TextEditor::setInactive() { + state=inactiveEditor; setText(""); - state=inactiveEditor; e->setPaper (inactivePaper); e->setReadOnly (true); @@ -528,7 +588,7 @@ void TextEditor::textSaveAs() { - QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)", + QString fn = Q3FileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)", this,"export note dialog",tr("Export Note to single file") ); if ( !fn.isEmpty() ) @@ -536,14 +596,14 @@ QFile file (fn); if (file.exists()) { - QMessageBox mb( "VYM", + QMessageBox mb( __VYM, tr("The file ") + fn + tr(" exists already. " "Do you want to overwrite it?"), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::Cancel | QMessageBox::Escape, - QMessageBox::NoButton ); + Qt::NoButton ); mb.setButtonText( QMessageBox::Yes, tr("Overwrite") ); mb.setButtonText( QMessageBox::No, tr("Cancel")); switch( mb.exec() ) { @@ -577,7 +637,7 @@ QString text = e->text(); QFile f( filename ); - if ( !f.open( IO_WriteOnly ) ) + if ( !f.open( QIODevice::WriteOnly ) ) { statusBar()->message( QString("Could not write to %1").arg(filename), statusbarTime ); @@ -659,38 +719,19 @@ e->setText(t); } -QString TextEditor::textConvertToASCII(const QString &t) -{ - QString r=t; - - // convert all "" to "\n" - QRegExp re(""); - re.setMinimal(true); - r.replace (re,"\n"); - - // convert all "

" to "\n" - re.setPattern ("/p"); - r.replace (re,"\n"); - - // remove all remaining tags - re.setPattern ("<.*>"); - r.replace (re,""); - - // convert "&", "<" and ">" - re.setPattern (">"); - r.replace (re,">"); - re.setPattern ("<"); - r.replace (re,"<"); - re.setPattern ("&"); - r.replace (re,"&"); - return r; -} - void TextEditor::textExportAsASCII() { - QString text = textConvertToASCII( e->text()); - QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (ASCII) (*.txt);;All files (*)", - this,"export note dialog",tr("Export Note to single file (ASCII)") ); + QString text = NoteObj (e->text()).getNoteASCII(); + QString fn,s; + if (!filenameHint.isEmpty()) + { + if (!filenameHint.contains (".txt")) + s=filenameHint+".txt"; + else + s=filenameHint; + } else + s=QString::null; + fn = Q3FileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") ); int ret=-1; if ( !fn.isEmpty() ) @@ -705,7 +746,7 @@ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::Cancel | QMessageBox::Escape, - QMessageBox::NoButton ); + Qt::NoButton ); mb.setButtonText( QMessageBox::Yes, tr("Overwrite") ); mb.setButtonText( QMessageBox::No, tr("Cancel")); ret=mb.exec(); @@ -714,7 +755,7 @@ return; // save - if ( !file.open( IO_WriteOnly ) ) + if ( !file.open( QIODevice::WriteOnly ) ) statusBar()->message( QString("Could not write to %1").arg(filename), statusbarTime ); else @@ -737,14 +778,14 @@ QPainter p( printer ); // Check that there is a valid device to print to. if ( !p.device() ) return; - QPaintDeviceMetrics metrics( p.device() ); + Q3PaintDeviceMetrics metrics( p.device() ); int dpiy = metrics.logicalDpiY(); int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins QRect body( margin, margin, metrics.width() - 2*margin, metrics.height() - 2*margin ); QFont font( e->currentFont() ); font.setPointSize( 10 ); // we define 10pt to be a nice base size for printing - QSimpleRichText richText( e->text(), font, + Q3SimpleRichText richText( e->text(), font, e->context(), e->styleSheet(), e->mimeSourceFactory(), @@ -838,22 +879,34 @@ return; e->setColor( col ); QPixmap pix( 16, 16 ); - pix.fill( black ); + pix.fill( Qt::black ); actionTextColor->setIconSet( pix ); } void TextEditor::textAlign( QAction *a ) { if ( a == actionAlignLeft ) - e->setAlignment( AlignLeft ); + e->setAlignment( Qt::AlignLeft ); else if ( a == actionAlignCenter ) - e->setAlignment( AlignHCenter ); + e->setAlignment( Qt::AlignHCenter ); else if ( a == actionAlignRight ) - e->setAlignment( AlignRight ); + e->setAlignment( Qt::AlignRight ); else if ( a == actionAlignJustify ) - e->setAlignment( AlignJustify ); + e->setAlignment( Qt::AlignJustify ); } +void TextEditor::textVAlign() +{ + if ( sender() == actionAlignSuperScript && actionAlignSuperScript->isOn()) { + e->setVerticalAlignment( Q3TextEdit::AlignSuperScript); + } else if (sender() == actionAlignSubScript && actionAlignSubScript->isOn()) { + e->setVerticalAlignment( Q3TextEdit::AlignSubScript); + } else { + e->setVerticalAlignment( Q3TextEdit::AlignNormal); + } +} + + void TextEditor::fontChanged( const QFont &f ) { comboFont->lineEdit()->setText( f.family() ); @@ -872,16 +925,30 @@ void TextEditor::alignmentChanged( int a ) { - if ( ( a == AlignAuto ) || ( a & AlignLeft )) + if ( ( a == Qt::AlignLeft ) || ( a & Qt::AlignLeft )) actionAlignLeft->setOn( true ); - else if ( ( a & AlignHCenter ) ) + else if ( ( a & Qt::AlignHCenter ) ) actionAlignCenter->setOn( true ); - else if ( ( a & AlignRight ) ) + else if ( ( a & Qt::AlignRight ) ) actionAlignRight->setOn( true ); - else if ( ( a & AlignJustify ) ) + else if ( ( a & Qt::AlignJustify ) ) actionAlignJustify->setOn( true ); } +void TextEditor::verticalAlignmentChanged(int a) +{ + if (a == Q3TextEdit::AlignSuperScript ) { + actionAlignSuperScript->setOn(true); + actionAlignSubScript->setOn(false); + } else if (a == Q3TextEdit::AlignSubScript ) { + actionAlignSuperScript->setOn(false); + actionAlignSubScript->setOn(true); + } else { + actionAlignSuperScript->setOn(false); + actionAlignSubScript->setOn(false); + } +} + void TextEditor::enableActions()