From ea318d1431c89e647598c510c4245c6571aa5f46 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 26 Jan 2012 23:32:43 -0600 Subject: Update to latest tqt3 automated conversion --- doc/html/qwerty-example.html | 322 +++++++++++++++++++++---------------------- 1 file changed, 161 insertions(+), 161 deletions(-) (limited to 'doc/html/qwerty-example.html') diff --git a/doc/html/qwerty-example.html b/doc/html/qwerty-example.html index 8bd0b6e8f..1bc1688e3 100644 --- a/doc/html/qwerty-example.html +++ b/doc/html/qwerty-example.html @@ -48,19 +48,19 @@ body { background: #ffffff; color: black; } #ifndef TQWERTY_H #define TQWERTY_H -#include <qwidget.h> -#include <qmenubar.h> -#include <qmultilineedit.h> -#include <qprinter.h> +#include <ntqwidget.h> +#include <ntqmenubar.h> +#include <ntqmultilineedit.h> +#include <ntqprinter.h> -class Editor : public TQWidget +class Editor : public TQWidget { Q_OBJECT public: - Editor( TQWidget *parent=0, const char *name="qwerty" ); + Editor( TQWidget *parent=0, const char *name="qwerty" ); ~Editor(); - void load( const TQString& fileName, int code=-1 ); + void load( const TQString& fileName, int code=-1 ); public slots: void newDoc(); @@ -81,15 +81,15 @@ private slots: void textChanged(); private: - bool saveAs( const TQString& fileName, int code=-1 ); + bool saveAs( const TQString& fileName, int code=-1 ); void rebuildCodecList(); - TQMenuBar *m; - TQMultiLineEdit *e; + TQMenuBar *m; + TQMultiLineEdit *e; #ifndef QT_NO_PRINTER - TQPrinter printer; + TQPrinter printer; #endif - TQPopupMenu *save_as; - TQPopupMenu *open_as; + TQPopupMenu *save_as; + TQPopupMenu *open_as; bool changed; }; @@ -109,18 +109,18 @@ private: *****************************************************************************/ #include "qwerty.h" -#include <qapplication.h> -#include <qfile.h> -#include <qfiledialog.h> -#include <qpopupmenu.h> -#include <qtextstream.h> -#include <qpainter.h> -#include <qmessagebox.h> -#include <qpaintdevicemetrics.h> -#include <qptrlist.h> -#include <qfontdialog.h> - -#include <qtextcodec.h> +#include <ntqapplication.h> +#include <ntqfile.h> +#include <ntqfiledialog.h> +#include <ntqpopupmenu.h> +#include <ntqtextstream.h> +#include <ntqpainter.h> +#include <ntqmessagebox.h> +#include <ntqpaintdevicemetrics.h> +#include <ntqptrlist.h> +#include <ntqfontdialog.h> + +#include <ntqtextcodec.h> const bool no_writing = FALSE; @@ -129,49 +129,49 @@ static TQPtrList<TQTextCodec> *codecList = 0; enum { Uni = 0, MBug = 1, Lat1 = 2, Local = 3, Guess = 4, Codec = 5 }; -Editor::Editor( TQWidget * parent , const char * name ) - : TQWidget( parent, name, WDestructiveClose ) +Editor::Editor( TQWidget * parent , const char * name ) + : TQWidget( parent, name, WDestructiveClose ) { - m = new TQMenuBar( this, "menu" ); - - TQPopupMenu * file = new TQPopupMenu(); - Q_CHECK_PTR( file ); - m->insertItem( "&File", file ); - - file->insertItem( "&New", this, SLOT(newDoc()), ALT+Key_N ); - file->insertItem( "&Open...", this, SLOT(load()), ALT+Key_O ); - file->insertItem( "&Save...", this, SLOT(save()), ALT+Key_S ); - file->insertSeparator(); - open_as = new TQPopupMenu(); - file->insertItem( "Open &As", open_as ); - save_as = new TQPopupMenu(); - file->insertItem( "Sa&ve As", save_as ); - file->insertItem( "Add &Encoding", this, SLOT(addEncoding()) ); + m = new TQMenuBar( this, "menu" ); + + TQPopupMenu * file = new TQPopupMenu(); + Q_CHECK_PTR( file ); + m->insertItem( "&File", file ); + + file->insertItem( "&New", this, SLOT(newDoc()), ALT+Key_N ); + file->insertItem( "&Open...", this, SLOT(load()), ALT+Key_O ); + file->insertItem( "&Save...", this, SLOT(save()), ALT+Key_S ); + file->insertSeparator(); + open_as = new TQPopupMenu(); + file->insertItem( "Open &As", open_as ); + save_as = new TQPopupMenu(); + file->insertItem( "Sa&ve As", save_as ); + file->insertItem( "Add &Encoding", this, SLOT(addEncoding()) ); #ifndef QT_NO_PRINTER - file->insertSeparator(); - file->insertItem( "&Print...", this, SLOT(print()), ALT+Key_P ); + file->insertSeparator(); + file->insertItem( "&Print...", this, SLOT(print()), ALT+Key_P ); #endif - file->insertSeparator(); - file->insertItem( "&Close", this, SLOT(close()),ALT+Key_W ); - file->insertItem( "&Quit", qApp, SLOT(closeAllWindows()), ALT+Key_Q ); + file->insertSeparator(); + file->insertItem( "&Close", this, SLOT(close()),ALT+Key_W ); + file->insertItem( "&Quit", qApp, SLOT(closeAllWindows()), ALT+Key_Q ); - connect( save_as, SIGNAL(activated(int)), this, SLOT(saveAsEncoding(int)) ); - connect( open_as, SIGNAL(activated(int)), this, SLOT(openAsEncoding(int)) ); + connect( save_as, SIGNAL(activated(int)), this, SLOT(saveAsEncoding(int)) ); + connect( open_as, SIGNAL(activated(int)), this, SLOT(openAsEncoding(int)) ); rebuildCodecList(); - TQPopupMenu * edit = new TQPopupMenu(); - Q_CHECK_PTR( edit ); - m->insertItem( "&Edit", edit ); + TQPopupMenu * edit = new TQPopupMenu(); + Q_CHECK_PTR( edit ); + m->insertItem( "&Edit", edit ); - edit->insertItem( "To &Uppercase", this, SLOT(toUpper()), ALT+Key_U ); - edit->insertItem( "To &Lowercase", this, SLOT(toLower()), ALT+Key_L ); + edit->insertItem( "To &Uppercase", this, SLOT(toUpper()), ALT+Key_U ); + edit->insertItem( "To &Lowercase", this, SLOT(toLower()), ALT+Key_L ); #ifndef QT_NO_FONTDIALOG - edit->insertSeparator(); - edit->insertItem( "&Select Font" , this, SLOT(font()), ALT+Key_T ); + edit->insertSeparator(); + edit->insertItem( "&Select Font" , this, SLOT(font()), ALT+Key_T ); #endif changed = FALSE; - e = new TQMultiLineEdit( this, "editor" ); - connect( e, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); + e = new TQMultiLineEdit( this, "editor" ); + connect( e, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); // We use Unifont - if you have it installed you'll see all // Unicode character glyphs. @@ -179,23 +179,23 @@ enum { Uni = 0, MBug = 1, Lat1 = 2, Local = 3, Guess = 4, Codec = 5 }; // Unifont only comes in one pixel size, so we cannot let // it change pixel size as the display DPI changes. // - TQFont unifont("unifont",16,50); unifont.setPixelSize(16); - e->setFont( unifont ); + TQFont unifont("unifont",16,50); unifont.setPixelSize(16); + e->setFont( unifont ); - e->setFocus(); + e->setFocus(); } Editor::~Editor() { } -void Editor::font() +void Editor::font() { #ifndef QT_NO_FONTDIALOG bool ok; - TQFont f = TQFontDialog::getFont( &ok, e->font() ); + TQFont f = TQFontDialog::getFont( &ok, e->font() ); if ( ok ) { - e->setFont( f ); + e->setFont( f ); } #endif } @@ -205,38 +205,38 @@ Editor::~Editor() void Editor::rebuildCodecList() { delete codecList; - codecList = new TQPtrList<TQTextCodec>; - TQTextCodec *codec; + codecList = new TQPtrList<TQTextCodec>; + TQTextCodec *codec; int i; - for (i = 0; (codec = TQTextCodec::codecForIndex(i)); i++) - codecList->append( codec ); - int n = codecList->count(); + for (i = 0; (codec = TQTextCodec::codecForIndex(i)); i++) + codecList->append( codec ); + int n = codecList->count(); for (int pm=0; pm<2; pm++) { - TQPopupMenu* menu = pm ? open_as : save_as; - menu->clear(); - TQString local = "Local ("; - local += TQTextCodec::codecForLocale()->name(); + TQPopupMenu* menu = pm ? open_as : save_as; + menu->clear(); + TQString local = "Local ("; + local += TQTextCodec::codecForLocale()->name(); local += ")"; - menu->insertItem( local, Local ); - menu->insertItem( "Unicode", Uni ); - menu->insertItem( "Latin1", Lat1 ); - menu->insertItem( "Microsoft Unicode", MBug ); + menu->insertItem( local, Local ); + menu->insertItem( "Unicode", Uni ); + menu->insertItem( "Latin1", Lat1 ); + menu->insertItem( "Microsoft Unicode", MBug ); if ( pm ) - menu->insertItem( "[guess]", Guess ); + menu->insertItem( "[guess]", Guess ); for ( i = 0; i < n; i++ ) - menu->insertItem( codecList->at(i)->name(), Codec + i ); + menu->insertItem( codecList->at(i)->name(), Codec + i ); } } void Editor::newDoc() { Editor *ed = new Editor; - if ( qApp->desktop()->size().width() < 450 - || qApp->desktop()->size().height() < 450 ) { - ed->showMaximized(); + if ( qApp->desktop()->size().width() < 450 + || qApp->desktop()->size().height() < 450 ) { + ed->showMaximized(); } else { - ed->resize( 400, 400 ); - ed->show(); + ed->resize( 400, 400 ); + ed->show(); } } @@ -244,47 +244,47 @@ void Editor::newDoc() void Editor::load() { #ifndef QT_NO_FILEDIALOG - TQString fn = TQFileDialog::getOpenFileName( TQString::null, TQString::null, this ); - if ( !fn.isEmpty() ) + TQString fn = TQFileDialog::getOpenFileName( TQString::null, TQString::null, this ); + if ( !fn.isEmpty() ) load( fn, -1 ); #endif } -void Editor::load( const TQString& fileName, int code ) +void Editor::load( const TQString& fileName, int code ) { - TQFile f( fileName ); - if ( !f.open( IO_ReadOnly ) ) + TQFile f( fileName ); + if ( !f.open( IO_ReadOnly ) ) return; - e->setAutoUpdate( FALSE ); + e->setAutoUpdate( FALSE ); - TQTextStream t(&f); + TQTextStream t(&f); if ( code >= Codec ) - t.setCodec( codecList->at(code-Codec) ); + t.setCodec( codecList->at(code-Codec) ); else if ( code == Uni ) - t.setEncoding( TQTextStream::Unicode ); + t.setEncoding( TQTextStream::Unicode ); else if ( code == MBug ) - t.setEncoding( TQTextStream::UnicodeReverse ); + t.setEncoding( TQTextStream::UnicodeReverse ); else if ( code == Lat1 ) - t.setEncoding( TQTextStream::Latin1 ); + t.setEncoding( TQTextStream::Latin1 ); else if ( code == Guess ) { - TQFile f(fileName); - f.open(IO_ReadOnly); + TQFile f(fileName); + f.open(IO_ReadOnly); char buffer[256]; int l = 256; - l=f.readBlock(buffer,l); - TQTextCodec* codec = TQTextCodec::codecForContent(buffer, l); + l=f.readBlock(buffer,l); + TQTextCodec* codec = TQTextCodec::codecForContent(buffer, l); if ( codec ) { - TQMessageBox::information(this,"Encoding",TQString("Codec: ")+codec->name()); - t.setCodec( codec ); + TQMessageBox::information(this,"Encoding",TQString("Codec: ")+codec->name()); + t.setCodec( codec ); } } - e->setText( t.read() ); - f.close(); + e->setText( t.read() ); + f.close(); - e->setAutoUpdate( TRUE ); - e->repaint(); - setCaption( fileName ); + e->setAutoUpdate( TRUE ); + e->repaint(); + setCaption( fileName ); changed = FALSE; } @@ -293,8 +293,8 @@ void Editor::openAsEncoding( int code ) { #ifndef QT_NO_FILEDIALOG //storing filename (proper save) is left as an exercise... - TQString fn = TQFileDialog::getOpenFileName( TQString::null, TQString::null, this ); - if ( !fn.isEmpty() ) + TQString fn = TQFileDialog::getOpenFileName( TQString::null, TQString::null, this ); + if ( !fn.isEmpty() ) (void) load( fn, code ); #endif } @@ -303,8 +303,8 @@ bool Editor::save() { #ifndef QT_NO_FILEDIALOG //storing filename (proper save) is left as an exercise... - TQString fn = TQFileDialog::getSaveFileName( TQString::null, TQString::null, this ); - if ( !fn.isEmpty() ) + TQString fn = TQFileDialog::getSaveFileName( TQString::null, TQString::null, this ); + if ( !fn.isEmpty() ) return saveAs( fn ); return FALSE; #endif @@ -314,8 +314,8 @@ void Editor::saveAsEncoding( int code ) { #ifndef QT_NO_FILEDIALOG //storing filename (proper save) is left as an exercise... - TQString fn = TQFileDialog::getSaveFileName( TQString::null, TQString::null, this ); - if ( !fn.isEmpty() ) + TQString fn = TQFileDialog::getSaveFileName( TQString::null, TQString::null, this ); + if ( !fn.isEmpty() ) (void) saveAs( fn, code ); #endif } @@ -323,14 +323,14 @@ void Editor::saveAsEncoding( int code ) void Editor::addEncoding() { #ifndef QT_NO_FILEDIALOG - TQString fn = TQFileDialog::getOpenFileName( TQString::null, "*.map", this ); - if ( !fn.isEmpty() ) { - TQFile f(fn); - if (f.open(IO_ReadOnly)) { - if (TQTextCodec::loadCharmap(&f)) { + TQString fn = TQFileDialog::getOpenFileName( TQString::null, "*.map", this ); + if ( !fn.isEmpty() ) { + TQFile f(fn); + if (f.open(IO_ReadOnly)) { + if (TQTextCodec::loadCharmap(&f)) { rebuildCodecList(); } else { - TQMessageBox::warning(0,"Charmap error", + TQMessageBox::warning(0,"Charmap error", "The file did not contain a valid charmap.\n\n" "A charmap file should look like this:\n" " <code_set_name> thename\n" @@ -349,27 +349,27 @@ void Editor::addEncoding() } -bool Editor::saveAs( const TQString& fileName, int code ) +bool Editor::saveAs( const TQString& fileName, int code ) { - TQFile f( fileName ); - if ( no_writing || !f.open( IO_WriteOnly ) ) { - TQMessageBox::warning(this,"I/O Error", + TQFile f( fileName ); + if ( no_writing || !f.open( IO_WriteOnly ) ) { + TQMessageBox::warning(this,"I/O Error", TQString("The file could not be opened.\n\n") +fileName); return FALSE; } - TQTextStream t(&f); + TQTextStream t(&f); if ( code >= Codec ) - t.setCodec( codecList->at(code-Codec) ); + t.setCodec( codecList->at(code-Codec) ); else if ( code == Uni ) - t.setEncoding( TQTextStream::Unicode ); + t.setEncoding( TQTextStream::Unicode ); else if ( code == MBug ) - t.setEncoding( TQTextStream::UnicodeReverse ); + t.setEncoding( TQTextStream::UnicodeReverse ); else if ( code == Lat1 ) - t.setEncoding( TQTextStream::Latin1 ); - t << e->text(); - f.close(); - setCaption( fileName ); + t.setEncoding( TQTextStream::Latin1 ); + t << e->text(); + f.close(); + setCaption( fileName ); changed = FALSE; return TRUE; } @@ -379,49 +379,49 @@ void Editor::print() #ifndef QT_NO_PRINTER if ( printer.setup(this) ) { // opens printer dialog printer.setFullPage(TRUE); // we'll set our own margins - TQPainter p; - p.begin( &printer ); // paint on printer - p.setFont( e->font() ); - TQFontMetrics fm = p.fontMetrics(); - TQPaintDeviceMetrics metrics( &printer ); // need width/height + TQPainter p; + p.begin( &printer ); // paint on printer + p.setFont( e->font() ); + TQFontMetrics fm = p.fontMetrics(); + TQPaintDeviceMetrics metrics( &printer ); // need width/height // of printer surface - const int MARGIN = metrics.logicalDpiX() / 2; // half-inch margin + const int MARGIN = metrics.logicalDpiX() / 2; // half-inch margin int yPos = MARGIN; // y position for each line - for( int i = 0 ; i < e->numLines() ; i++ ) { + for( int i = 0 ; i < e->numLines() ; i++ ) { if ( printer.aborted() ) break; - if ( yPos + fm.lineSpacing() > metrics.height() - MARGIN ) { + if ( yPos + fm.lineSpacing() > metrics.height() - MARGIN ) { // no more room on this page if ( !printer.newPage() ) // start new page break; // some error yPos = MARGIN; // back to top of page } - p.drawText( MARGIN, yPos, metrics.width() - 2*MARGIN, - fm.lineSpacing(), ExpandTabs, e->textLine( i ) ); - yPos += fm.lineSpacing(); + p.drawText( MARGIN, yPos, metrics.width() - 2*MARGIN, + fm.lineSpacing(), ExpandTabs, e->textLine( i ) ); + yPos += fm.lineSpacing(); } - p.end(); // send job to printer + p.end(); // send job to printer } #endif } -void Editor::resizeEvent( TQResizeEvent * ) +void Editor::resizeEvent( TQResizeEvent * ) { if ( e && m ) - e->setGeometry( 0, m->height(), width(), height() - m->height() ); + e->setGeometry( 0, m->height(), width(), height() - m->height() ); } -void Editor::closeEvent( TQCloseEvent *event ) +void Editor::closeEvent( TQCloseEvent *event ) { event->accept(); if ( changed ) { // the text has been changed - switch ( TQMessageBox::warning( this, "Qwerty", + switch ( TQMessageBox::warning( this, "Qwerty", "Save changes to Document?", - tr("&Yes"), - tr("&No"), - tr("Cancel"), + tr("&Yes"), + tr("&No"), + tr("Cancel"), 0, 2) ) { case 0: // yes if ( save() ) @@ -441,12 +441,12 @@ void Editor::resizeEvent( Editor::toUpper() { - e->setText(e->text().upper()); + e->setText(e->text().upper()); } void Editor::toLower() { - e->setText(e->text().lower()); + e->setText(e->text().lower()); } void Editor::textChanged() @@ -467,33 +467,33 @@ void Editor::textChanged() ** *****************************************************************************/ -#include <qapplication.h> +#include <ntqapplication.h> #include "qwerty.h" int main( int argc, char **argv ) { - TQApplication a( argc, argv ); + TQApplication a( argc, argv ); - bool isSmall = qApp->desktop()->size().width() < 450 - || qApp->desktop()->size().height() < 450; + bool isSmall = qApp->desktop()->size().width() < 450 + || qApp->desktop()->size().height() < 450; int i; for ( i= argc <= 1 ? 0 : 1; i<argc; i++ ) { Editor *e = new Editor; - e->setCaption("TQt Example - TQWERTY"); + e->setCaption("TQt Example - TQWERTY"); if ( i > 0 ) e->load( argv[i] ); if ( isSmall ) { - e->showMaximized(); + e->showMaximized(); } else { - e->resize( 400, 400 ); - e->show(); + e->resize( 400, 400 ); + e->show(); } } - a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ); - return a.exec(); + a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ); + return a.exec(); } -- cgit v1.2.1