Diffstat (limited to 'noncore/apps/opie-write/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-write/mainwindow.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/noncore/apps/opie-write/mainwindow.cpp b/noncore/apps/opie-write/mainwindow.cpp index 90e1a70..aa03060 100644 --- a/noncore/apps/opie-write/mainwindow.cpp +++ b/noncore/apps/opie-write/mainwindow.cpp @@ -1,76 +1,80 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** Licensees holding valid Qtopia Developer license may use this ** file in accordance with the Qtopia Developer License Agreement ** provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR ** PURPOSE. ** ** email sales@trolltech.com for information about Qtopia License ** Agreements. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "mainwindow.h" + +/* OPIE */ +#include <opie2/odebug.h> #include <qpe/fileselector.h> #include <qpe/applnk.h> #include <qpe/resource.h> #include <qpe/fontdatabase.h> +using namespace Opie::Core; -//#include "qspellchecker.h" +/* QT */ #include "qtextedit.h" #include <qaction.h> #include <qtoolbar.h> #include <qtoolbutton.h> #include <qtabwidget.h> #include <qapplication.h> #include <qfontdatabase.h> #include <qcombobox.h> #include <qlineedit.h> #include <qfileinfo.h> #include <qfile.h> #include <qfiledialog.h> #include <qprinter.h> #include <qpaintdevicemetrics.h> #include <qmenubar.h> #include <qpopupmenu.h> #include <qcolordialog.h> #include <qpainter.h> #include <qstyle.h> class ButtonMenu : public QToolButton { Q_OBJECT public: ButtonMenu( QWidget *parent, const char *name=0 ) : QToolButton( parent, name ), current(0) { setPopup( new QPopupMenu( this ) ); setPopupDelay( 1 ); connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) ); } int insertItem(const QIconSet &icon, const QString &text, int id ) { if ( !popup()->count() ) { setIconSet( icon ); current = id; } return popup()->insertItem( icon, text, id ); } void setCurrentItem( int id ) { if ( id != current ) { current = id; setIconSet( *popup()->iconSet( id ) ); } } virtual QSize sizeHint() const { @@ -399,128 +403,128 @@ void MainWindow::fontChanged( const QFont &f ) { comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( f.family() ) ) ); updateFontSizeCombo( f ); comboSize->lineEdit()->setText( QString::number( f.pointSize() ) ); actionTextBold->setOn( f.bold() ); actionTextItalic->setOn( f.italic() ); actionTextUnderline->setOn( f.underline() ); } void MainWindow::colorChanged( const QColor & ) { } void MainWindow::alignmentChanged( int a ) { if ( ( a == Qt3::AlignAuto ) || ( a & AlignLeft )) { alignMenu->setCurrentItem(AlignLeft); } else if ( ( a & AlignCenter ) ) { alignMenu->setCurrentItem(AlignCenter); } else if ( ( a & AlignRight ) ) { alignMenu->setCurrentItem(AlignRight); } else if ( ( a & Qt3::AlignJustify ) ) { alignMenu->setCurrentItem(Qt3::AlignJustify); } } void MainWindow::editorChanged( QWidget * ) { if ( !currentEditor() ) return; fontChanged( currentEditor()->font() ); colorChanged( currentEditor()->color() ); alignmentChanged( currentEditor()->alignment() ); } void MainWindow::fileOpen() { save(); editorStack->raiseWidget( fileSelector ); fileSelector->reread(); hideEditTools(); fileSelector->setNewVisible( TRUE ); clear(); updateCaption(); } void MainWindow::fileRevert() { - qDebug( "QMainWindow::fileRevert needs to be done" ); + odebug << "QMainWindow::fileRevert needs to be done" << oendl; } void MainWindow::fileNew() { editor->setTextFormat( Qt::RichText ); save(); newFile(DocLnk()); } void MainWindow::insertTable() { - qDebug( "MainWindow::insertTable() needs to be done" ); + odebug << "MainWindow::insertTable() needs to be done" << oendl; } void MainWindow::newFile( const DocLnk &dl ) { DocLnk nf = dl; nf.setType( "text/html" ); clear(); editorStack->raiseWidget( editor ); editor->viewport()->setFocus(); doc = new DocLnk( nf ); updateCaption(); } void MainWindow::openFile( const DocLnk &dl ) { FileManager fm; QString txt; if ( !fm.loadFile( dl, txt ) ) - qDebug( "couldn't open file" ); + odebug << "couldn't open file" << oendl; clear(); editorStack->raiseWidget( editor ); editor->viewport()->setFocus(); doc = new DocLnk( dl ); editor->setText( txt ); editor->setModified( FALSE ); updateCaption(); } void MainWindow::showEditTools( void ) { tbMenu->show(); tbEdit->show(); tbFont->show(); tbStyle->show(); } void MainWindow::hideEditTools( void ) { // let's reset the buttons... actionTextBold->setOn( FALSE ); actionTextItalic->setOn( FALSE ); actionTextUnderline->setOn( FALSE ); //comboFont->setCurrentText( QApplication::font().family() ); comboSize->lineEdit()->setText( QString::number(QApplication::font().pointSize() ) ); tbMenu->hide(); tbEdit->hide(); tbFont->hide(); tbStyle->hide(); } void MainWindow::save() { if ( !doc ) return; if ( !editor->isModified() ) return; QString rt = editor->text(); // quick hack to get around formatting... editor->setTextFormat( Qt::PlainText ); QString pt = editor->text(); editor->setTextFormat( Qt::RichText ); if ( doc->name().isEmpty() ) { unsigned ispace = pt.find( ' ' ); |