# HG changeset patch # User insilmaril # Date 1152197221 0 # Node ID f94317a94db19cbef237c39f6bb3b6a64521aea6 # Parent 21379539d95294efafd725e10d6a07981a52b39c Text Editor now shows states again diff -r 21379539d952 -r f94317a94db1 demos/todo.vym Binary file demos/todo.vym has changed diff -r 21379539d952 -r f94317a94db1 exportoofiledialog.cpp --- a/exportoofiledialog.cpp Wed Jul 05 10:29:54 2006 +0000 +++ b/exportoofiledialog.cpp Thu Jul 06 14:47:01 2006 +0000 @@ -2,12 +2,12 @@ #include "exportoofiledialog.h" -ExportOOFileDialog::ExportOOFileDialog():Q3FileDialog() +ExportOOFileDialog::ExportOOFileDialog():QFileDialog() { init(); } -ExportOOFileDialog::ExportOOFileDialog (QWidget * parent, const char* name, bool modal):Q3FileDialog(parent, name,modal) +ExportOOFileDialog::ExportOOFileDialog (QWidget * parent, const QString &caption ):QFileDialog(parent, caption) { init(); } @@ -18,7 +18,7 @@ QStringList::Iterator itf=filters.begin(); while (itf != filters.end()) { - if (*itf==lastFilter) return *itpath; + if (*itf==selectedFilter()) return *itpath; itpath++; itf++; } @@ -33,31 +33,36 @@ QString ExportOOFileDialog::selectedFile() { - return Q3FileDialog::selectedFile(); + return QFileDialog::selectedFile(); } +void ExportOOFileDialog::show() +{ + setFilters (filters); + QFileDialog::show(); +} + +void ExportOOFileDialog::init() +{ + setMode( QFileDialog::AnyFile ); + QDir d; + d.setPath ("/usr/share/vym/exports"); + scanExportConfigs(d); + d.setPath (d.homeDirPath()+"/.vym/exports"); + scanExportConfigs(d); + d.setPath (d.currentPath()+"/exports"); + scanExportConfigs(d); + + connect ( + this,SIGNAL (filterSelected(const QString&)), + this, SLOT( newConfigPath(const QString &))); +} + void ExportOOFileDialog::addFilter(const QString &f) { lastFilter=f; filters.append (f); - Q3FileDialog::addFilter (f); -} - -void ExportOOFileDialog::init() -{ - setMode( Q3FileDialog::AnyFile ); - QDir d; - d.setPath ("/usr/share/vym/exports"); - scanExportConfigs(d); - d.setPath (d.homeDirPath()+"/.vym/exports"); - scanExportConfigs(d); - d.setPath ("exports"); - scanExportConfigs(d); - - connect ( - this,SIGNAL (filterSelected(const QString&)), - this, SLOT( newConfigPath(const QString &))); } void ExportOOFileDialog::scanExportConfigs(QDir dir) @@ -68,7 +73,6 @@ if (dir.exists()) { // Traverse files - QDir dir; dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); QFileInfoList list = dir.entryInfoList(); diff -r 21379539d952 -r f94317a94db1 exportoofiledialog.h --- a/exportoofiledialog.h Wed Jul 05 10:29:54 2006 +0000 +++ b/exportoofiledialog.h Thu Jul 06 14:47:01 2006 +0000 @@ -1,28 +1,28 @@ #ifndef EXPORTOOFILEDIALOG #define EXPORTOOFILEDIALOG -#include -#include +#include +#include #include "settings.h" -class ExportOOFileDialog:public Q3FileDialog +class ExportOOFileDialog:public QFileDialog { Q_OBJECT public: ExportOOFileDialog(); - ExportOOFileDialog (QWidget * parent = 0, const char * name = 0, bool - modal = false); + ExportOOFileDialog (QWidget * parent = 0, const QString &caption=QString()); QString selectedConfig(); QString selectedFile(); - void addFilter(const QString &); + void show(); private slots: void newConfigPath (const QString&f); private: void init(); + void addFilter(const QString &); void scanExportConfigs(QDir ); QStringList configPaths; QStringList filters; diff -r 21379539d952 -r f94317a94db1 exports.cpp --- a/exports.cpp Wed Jul 05 10:29:54 2006 +0000 +++ b/exports.cpp Thu Jul 06 14:47:01 2006 +0000 @@ -1,6 +1,6 @@ #include #include -#include +#include //Added by qt3to4: #include @@ -58,10 +58,10 @@ { if (mapCenter && mapCenter->getMapEditor()) { - Q3FileDialog *fd=new Q3FileDialog( mapCenter->getMapEditor(), caption); - fd->addFilter (filter); + QFileDialog *fd=new QFileDialog( mapCenter->getMapEditor(), caption); + fd->setFilter (filter); fd->setCaption(caption); - fd->setMode( Q3FileDialog::AnyFile ); + fd->setMode( QFileDialog::AnyFile ); fd->show(); if ( fd->exec() == QDialog::Accepted ) @@ -186,17 +186,14 @@ p.process(); QString ub=vymBaseDir.path()+"/scripts/update-bookmarks"; - Q3Process *proc = new Q3Process( ); - proc->addArgument(ub); - - if ( !proc->start() ) + QProcess *proc= new QProcess (); + proc->start( ub); + if (!proc->waitForStarted()); { QMessageBox::warning(0, QObject::tr("Warning"), QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub)); } - - } } diff -r 21379539d952 -r f94317a94db1 main.cpp --- a/main.cpp Wed Jul 05 10:29:54 2006 +0000 +++ b/main.cpp Thu Jul 06 14:47:01 2006 +0000 @@ -11,7 +11,6 @@ #include "settings.h" #include "options.h" #include "mainwindow.h" - #include "flagrowobj.h" // Global variables diff -r 21379539d952 -r f94317a94db1 mainwindow.cpp --- a/mainwindow.cpp Wed Jul 05 10:29:54 2006 +0000 +++ b/mainwindow.cpp Thu Jul 06 14:47:01 2006 +0000 @@ -1,15 +1,14 @@ +#include "mainwindow.h" + #include - -#include "mainwindow.h" - -#include -#include -#include +#include +#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include //Added by qt3to4: #include #include @@ -2353,13 +2352,13 @@ void Main::fileExportOOPresentation() { ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office"); - // FIXME add extra info in dialog + // TODO add preview in dialog //ImagePreview *p =new ImagePreview (fd); //fd->setContentsPreviewEnabled( TRUE ); //fd->setContentsPreview( p, p ); //fd->setPreviewMode( QFileDialog::Contents ); fd->setCaption(__VYM " - " +tr("Export to")+" Open Office"); - //fd->setDir (lastImageDir); + fd->setDir (QDir().current()); fd->show(); if ( fd->exec() == QDialog::Accepted ) diff -r 21379539d952 -r f94317a94db1 mapeditor.cpp --- a/mapeditor.cpp Wed Jul 05 10:29:54 2006 +0000 +++ b/mapeditor.cpp Thu Jul 06 14:47:01 2006 +0000 @@ -1,24 +1,23 @@ #include "mapeditor.h" #include -#include +#include #include #include #include #include #include -#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include #include -#include +#include //Added by qt3to4: #include #include @@ -2234,6 +2233,9 @@ BranchObj* MapEditor::findText (QString s, bool cs) { + QTextDocument::FindFlags flags=0; + if (cs) flags=QTextDocument::QTextDocument::FindCaseSensitively; + if (!itFind) { // Nothing found or new find process if (EOFind) @@ -2258,7 +2260,7 @@ adjustCanvasSize(); ensureSelectionVisible(); } - if (textEditor->findText(s,cs)) + if (textEditor->findText(s,flags)) { searching=false; foundNote=true; @@ -3111,10 +3113,10 @@ return; QString ub=vymBaseDir.path()+"/scripts/update-bookmarks"; - Q3Process *proc = new Q3Process( this ); - proc->addArgument(ub); - - if ( !proc->start() ) + + QProcess *proc= new QProcess (this); + proc->start( ub); + if (!proc->waitForStarted()); { QMessageBox::warning(0, tr("Warning"), @@ -3122,7 +3124,7 @@ } -/* +/* Hide hidden stuff temporary, maybe add this as regular function somewhere if (hidemode==HideNone) { setHideTmpMode (HideExport); diff -r 21379539d952 -r f94317a94db1 texteditor.cpp --- a/texteditor.cpp Wed Jul 05 10:29:54 2006 +0000 +++ b/texteditor.cpp Thu Jul 06 14:47:01 2006 +0000 @@ -1,24 +1,17 @@ #include "texteditor.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include -#include #include -#include -#include -#include -#include -#include -#include -#include -//Added by qt3to4: -#include +#include +#include +#include +#include +#include +#include #include #include @@ -29,7 +22,6 @@ #include "noteobj.h" #include "version.h" -extern Q3Canvas* actCanvas; extern int statusbarTime; extern QSettings settings; @@ -56,6 +48,7 @@ e->setTextFormat(Qt::RichText); // default e->setTabStopWidth (20); // unit is pixel e->setColor (Qt::black); + e->setAutoFillBackground (true); connect (e, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); setCentralWidget( e ); statusBar()->message( "Ready", statusbarTime); @@ -68,9 +61,6 @@ setupSettingsActions(); // Various states - emptyPaper = QBrush(Qt::gray); - filledPaper = QBrush(Qt::white); - inactivePaper= QBrush(Qt::black); setInactive(); // Load Settings @@ -137,7 +127,7 @@ bool TextEditor::isEmpty() { - if (e->text().length()) + if (e->toPlainText().length()>0) return false; else return true; @@ -208,10 +198,9 @@ return filenameHint; } -bool TextEditor::findText(const QString &t, const bool &cs) +bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags) { - bool wo=false; // word matches - if (e->find (t, cs, wo, true, 0, 0 )) + if (e->find (t,flags)) return true; else return false; @@ -358,18 +347,20 @@ // comboFont = new QComboBox( true, tb ); comboFont = new QComboBox; tb->addWidget (comboFont); - QFontDatabase db; - comboFont->insertStringList( db.families() ); + QFontDatabase fontDB; + comboFont->insertStringList( fontDB.families() ); connect( comboFont, SIGNAL( activated( const QString & ) ), this, SLOT( textFamily( const QString & ) ) ); comboFont->addItem( QApplication::font().family() ); -// comboSize = new QComboBox( true, tb ); comboSize = new QComboBox; tb->addWidget (comboSize); - Q3ValueList sizes = db.standardSizes(); - Q3ValueList::Iterator it = sizes.begin(); - for ( ; it != sizes.end(); ++it ) - comboSize->insertItem( QString::number( *it ) ); + QList sizes=fontDB.standardSizes(); + QList::iterator i = sizes.begin(); + while (i != sizes.end()) + { + ++i; // increment i before using it + comboSize->insertItem ( QString::number(*i)); + } connect( comboSize, SIGNAL( activated( const QString & ) ), this, SLOT( textSize( const QString & ) ) ); comboSize->addItem ( QString::number( QApplication::font().pointSize() ) ); @@ -461,10 +452,12 @@ 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))); + */ } @@ -497,7 +490,7 @@ { if (state!=inactiveEditor) { - if (e->length()) + if (e->text().length()) { QMessageBox mb( __VYM " - " +tr("Note Editor"), "Loading will overwrite the existing note", @@ -513,9 +506,13 @@ } } // Load note - Q3FileDialog *fd=new Q3FileDialog( this); - fd->addFilter ("ASCII texts (*.txt)"); - fd->addFilter ("VYM notes (*.html)"); + QFileDialog *fd=new QFileDialog( this); + QStringList types; + types<< "VYM notes (*.html)" << + "ASCII texts (*.txt)" << + "All filed (*)"; + fd->setFilters (types); + fd->setDirectory (QDir().current()); fd->show(); QString fn; if ( fd->exec() == QDialog::Accepted ) @@ -544,7 +541,10 @@ QString TextEditor::getText() { - return e->text(); + if (e->toPlainText().isEmpty()) + return ""; + else + return e->text(); } void TextEditor::editorChanged() @@ -555,9 +555,9 @@ state=filledEditor; if (state==emptyEditor) - e->setPaper (emptyPaper); + setState (emptyEditor); else - e->setPaper (filledPaper); + setState (filledEditor); // SLOT is LinkableMapObj, which will update systemFlag emit (textHasChanged() ); } @@ -565,12 +565,8 @@ void TextEditor::setText(QString t) { - if ( !Q3StyleSheet::mightBeRichText( t ) ) - t = Q3StyleSheet::convertFromPlainText( t, Q3StyleSheetItem::WhiteSpaceNormal ); e->setReadOnly(false); e->setText(t); -// editorChanged(); //not called automagically FIXME or is it? - enableActions(); } @@ -578,7 +574,7 @@ { state=inactiveEditor; setText(""); - e->setPaper (inactivePaper); + setState (inactiveEditor); e->setReadOnly (true); disableActions(); @@ -592,7 +588,7 @@ void TextEditor::textSaveAs() { - QString fn = Q3FileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)", + QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)", this,"export note dialog",tr("Export Note to single file") ); if ( !fn.isEmpty() ) @@ -662,9 +658,21 @@ // In X11 a copy&paste generates paragraphs, // which is not always wanted // This function replaces paragraphs by linebreaks. + + e->setBackgroundRole (QPalette::Text); + cout << "dark\n"; + + QString t; + t=e->text(); + QRegExp re(""); + re.setMinimal(true); + t.replace (re,""); + t.replace ("

","
"); + e->setText(t); + + /* FIXME QT3 use seletion () int parFrom, parTo, indFrom, indTo; e->getSelection (&parFrom,&indFrom,&parTo,&indTo); - QString t; if (parFrom>-1) t=e->selectedText(); else @@ -687,10 +695,15 @@ e->setText (e->text().replace(marker,t)); } else e->setText(t); + */ } void TextEditor::textJoinLines() { + e->setBackgroundRole (QPalette::Light); + cout << "light\n"; + +/* FIXME QT3 int parFrom, parTo, indFrom, indTo; e->getSelection (&parFrom,&indFrom,&parTo,&indTo); QString t; @@ -721,6 +734,7 @@ e->setText (e->text().replace(marker,t)); } else e->setText(t); +*/ } void TextEditor::textExportAsASCII() @@ -735,7 +749,7 @@ 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)") ); + fn = QFileDialog::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() ) @@ -776,41 +790,16 @@ void TextEditor::textPrint() { - printer->setFullPage(TRUE); - if ( printer->setup( this ) ) - { - QPainter p( printer ); - // Check that there is a valid device to print to. - if ( !p.device() ) return; - 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 - Q3SimpleRichText richText( e->text(), font, - e->context(), - e->styleSheet(), - e->mimeSourceFactory(), - body.height() ); - richText.setWidth( &p, body.width() ); - QRect view( body ); - int page = 1; - do - { - richText.draw( &p, body.left(), body.top(), view, colorGroup() ); - view.moveBy( 0, body.height() ); - p.translate( 0 , -body.height() ); - p.setFont( font ); - p.drawText( view.right() - p.fontMetrics().width( QString::number( page ) ), - view.bottom() + p.fontMetrics().ascent() + 5, QString::number( page ) ); - if ( view.top() >= richText.height() ) - break; - printer->newPage(); - page++; - } while (TRUE); - } + QTextDocument *document = e->document(); + QPrinter printer; + + QPrintDialog *dialog = new QPrintDialog(&printer, this); + dialog->setWindowTitle(tr("Print Document")); + if (dialog->exec() != QDialog::Accepted) + return; + + document->print(&printer); } void TextEditor::textEditUndo() @@ -820,12 +809,12 @@ void TextEditor::toggleFonthint() { setUpdatesEnabled (false); - e->selectAll (true); + e->selectAll (); if (!actionFormatUseFixedFont->isOn() ) e->setCurrentFont (varFont); else e->setCurrentFont (fixedFont); - e->selectAll (false); + e->selectAll (); setUpdatesEnabled (true); repaint(); } @@ -901,13 +890,15 @@ void TextEditor::textVAlign() { +/* FIXME QT3 if ( sender() == actionAlignSuperScript && actionAlignSuperScript->isOn()) { - e->setVerticalAlignment( Q3TextEdit::AlignSuperScript); + e->setVerticalAlignment( QTextEdit::AlignSuperScript); } else if (sender() == actionAlignSubScript && actionAlignSubScript->isOn()) { - e->setVerticalAlignment( Q3TextEdit::AlignSubScript); + e->setVerticalAlignment( QTextEdit::AlignSubScript); } else { - e->setVerticalAlignment( Q3TextEdit::AlignNormal); + e->setVerticalAlignment( QTextEdit::AlignNormal); } +*/ } @@ -943,16 +934,18 @@ void TextEditor::verticalAlignmentChanged(int a) { - if (a == Q3TextEdit::AlignSuperScript ) { + /* FIXME QT3 + if (a == QTextEdit::AlignSuperScript ) { actionAlignSuperScript->setOn(true); actionAlignSubScript->setOn(false); - } else if (a == Q3TextEdit::AlignSubScript ) { + } else if (a == QTextEdit::AlignSubScript ) { actionAlignSuperScript->setOn(false); actionAlignSubScript->setOn(true); } else { actionAlignSuperScript->setOn(false); actionAlignSubScript->setOn(false); } + */ } @@ -991,4 +984,20 @@ actionFormatUseFixedFont->setEnabled(false); } +void TextEditor::setState (EditorState s) +{ + + QPalette p=palette(); + QColor c; + switch (s) + { + case emptyEditor: c=QColor (150,150,150); break; + case filledEditor: c=QColor (255,255,255); break; + case inactiveEditor: c=QColor (0,0,0); + } + p.setColor(QPalette::Active, static_cast(9), c); + p.setColor(QPalette::Inactive, static_cast(9), c); + e->setPalette(p); +} + diff -r 21379539d952 -r f94317a94db1 texteditor.h --- a/texteditor.h Wed Jul 05 10:29:54 2006 +0000 +++ b/texteditor.h Thu Jul 06 14:47:01 2006 +0000 @@ -1,13 +1,10 @@ -/* emacs: -*- Mode: C; c-style: "bsd"; c-basic-offset: 4; c-recognize-knr-p: nil; -*- */ #ifndef TEXTEDITOR_H #define TEXTEDITOR_H #include -#include -#include -#include -#include -//Added by qt3to4: +#include +#include +#include #include @@ -31,7 +28,7 @@ QString getFilename (); void setFilenameHint (const QString&); QString getFilenameHint (); - bool findText(const QString &, const bool &); // find Text + bool findText(const QString &, const QTextDocument::FindFlags &); // find Text protected: void setupFileActions(); @@ -81,6 +78,7 @@ void verticalAlignmentChanged(int a); void enableActions(); void disableActions(); + void setState (EditorState); private: QPrinter *printer; @@ -129,7 +127,7 @@ *actionAlignSuperScript; }; -/* Wraps currentVerticalAlignmentChanged(VerticalAlignment) +/* FIXME Wraps currentVerticalAlignmentChanged(VerticalAlignment) * to currentVerticalAlignmentChanged(int) * this way the signal can be used without use of the internal * VerticalAlignment enum of QTextEdit @@ -137,26 +135,31 @@ * have been no problems! */ -class MyTextEdit : public Q3TextEdit +class MyTextEdit : public QTextEdit { Q_OBJECT; public: - MyTextEdit(QWidget *parent, const char *name) : Q3TextEdit(parent, name) { - connect(this, - SIGNAL(currentVerticalAlignmentChanged(VerticalAlignment)), - this, - SLOT(verticalAlignmentChanged(VerticalAlignment))); + MyTextEdit(QWidget *parent, const char *name) : QTextEdit(parent, name) + { + /* + connect( + this, SIGNAL(currentVerticalAlignmentChanged(VerticalAlignment)), + this, SLOT(verticalAlignmentChanged(VerticalAlignment))); + */ } - int verticalAlignment() const { return m_verticalAlignment; } +// int verticalAlignment() const { return m_verticalAlignment; } signals: - void currentVerticalAlignmentChanged(int a); +// void currentVerticalAlignmentChanged(int a); public slots: - void verticalAlignmentChanged(VerticalAlignment a) { - m_verticalAlignment = a; - emit currentVerticalAlignmentChanged((int)a); + /* + void verticalAlignmentChanged(VerticalAlignment a) + { + m_verticalAlignment = a; + emit currentVerticalAlignmentChanged((int)a); } +*/ private: - int m_verticalAlignment; +// int m_verticalAlignment; }; #endif diff -r 21379539d952 -r f94317a94db1 version.h --- a/version.h Wed Jul 05 10:29:54 2006 +0000 +++ b/version.h Thu Jul 06 14:47:01 2006 +0000 @@ -3,6 +3,6 @@ #define __VYM "VYM" #define __VYM_VERSION "1.8.50" -#define __BUILD_DATE "June 16, 2006" +#define __BUILD_DATE "July 5, 2006" #endif