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/qdir-example.html | 262 ++++++++++++++++++++++----------------------- 1 file changed, 131 insertions(+), 131 deletions(-) (limited to 'doc/html/qdir-example.html') diff --git a/doc/html/qdir-example.html b/doc/html/qdir-example.html index df2b245f0..45d7982e3 100644 --- a/doc/html/qdir-example.html +++ b/doc/html/qdir-example.html @@ -46,26 +46,26 @@ body { background: #ffffff; color: black; } *****************************************************************************/ #include "../dirview/dirview.h" -#include "qdir.h" - -#include <qapplication.h> -#include <qtextview.h> -#include <qfileinfo.h> -#include <qfile.h> -#include <qtextstream.h> -#include <qhbox.h> -#include <qspinbox.h> -#include <qlabel.h> -#include <qmultilineedit.h> -#include <qheader.h> -#include <qevent.h> -#include <qpainter.h> -#include <qpopupmenu.h> -#include <qpushbutton.h> -#include <qtoolbutton.h> -#include <qfile.h> -#include <qtextstream.h> -#include <qtooltip.h> +#include "ntqdir.h" + +#include <ntqapplication.h> +#include <ntqtextview.h> +#include <ntqfileinfo.h> +#include <ntqfile.h> +#include <ntqtextstream.h> +#include <ntqhbox.h> +#include <ntqspinbox.h> +#include <ntqlabel.h> +#include <ntqmultilineedit.h> +#include <ntqheader.h> +#include <ntqevent.h> +#include <ntqpainter.h> +#include <ntqpopupmenu.h> +#include <ntqpushbutton.h> +#include <ntqtoolbutton.h> +#include <ntqfile.h> +#include <ntqtextstream.h> +#include <ntqtooltip.h> #include <stdlib.h> @@ -122,201 +122,201 @@ static const char *home[]={ // **************************************************************************************************** -PixmapView::PixmapView( TQWidget *parent ) - : TQScrollView( parent ) +PixmapView::PixmapView( TQWidget *parent ) + : TQScrollView( parent ) { - viewport()->setBackgroundMode( PaletteBase ); + viewport()->setBackgroundMode( PaletteBase ); } -void PixmapView::setPixmap( const TQPixmap &pix ) +void PixmapView::setPixmap( const TQPixmap &pix ) { pixmap = pix; - resizeContents( pixmap.size().width(), pixmap.size().height() ); - viewport()->repaint( FALSE ); + resizeContents( pixmap.size().width(), pixmap.size().height() ); + viewport()->repaint( FALSE ); } -void PixmapView::drawContents( TQPainter *p, int cx, int cy, int cw, int ch ) +void PixmapView::drawContents( TQPainter *p, int cx, int cy, int cw, int ch ) { - p->fillRect( cx, cy, cw, ch, colorGroup().brush( TQColorGroup::Base ) ); - p->drawPixmap( 0, 0, pixmap ); + p->fillRect( cx, cy, cw, ch, colorGroup().brush( TQColorGroup::Base ) ); + p->drawPixmap( 0, 0, pixmap ); } // **************************************************************************************************** -Preview::Preview( TQWidget *parent ) - : TQWidgetStack( parent ) +Preview::Preview( TQWidget *parent ) + : TQWidgetStack( parent ) { - normalText = new TQMultiLineEdit( this ); - normalText->setReadOnly( TRUE ); - html = new TQTextView( this ); + normalText = new TQMultiLineEdit( this ); + normalText->setReadOnly( TRUE ); + html = new TQTextView( this ); pixmap = new PixmapView( this ); - raiseWidget( normalText ); + raiseWidget( normalText ); } -void Preview::showPreview( const TQUrl &u, int size ) +void Preview::showPreview( const TQUrl &u, int size ) { - if ( u.isLocalFile() ) { - TQString path = u.path(); - TQFileInfo fi( path ); - if ( fi.isFile() && (int)fi.size() > size * 1000 ) { - normalText->setText( tr( "The File\n%1\nis too large, so I don't show it!" ).arg( path ) ); - raiseWidget( normalText ); + if ( u.isLocalFile() ) { + TQString path = u.path(); + TQFileInfo fi( path ); + if ( fi.isFile() && (int)fi.size() > size * 1000 ) { + normalText->setText( tr( "The File\n%1\nis too large, so I don't show it!" ).arg( path ) ); + raiseWidget( normalText ); return; } - TQPixmap pix( path ); - if ( pix.isNull() ) { - if ( fi.isFile() ) { - TQFile f( path ); - if ( f.open( IO_ReadOnly ) ) { - TQTextStream ts( &f ); - TQString text = ts.read(); - f.close(); - if ( fi.extension().lower().contains( "htm" ) ) { - TQString url = html->mimeSourceFactory()->makeAbsolute( path, html->context() ); - html->setText( text, url ); + TQPixmap pix( path ); + if ( pix.isNull() ) { + if ( fi.isFile() ) { + TQFile f( path ); + if ( f.open( IO_ReadOnly ) ) { + TQTextStream ts( &f ); + TQString text = ts.read(); + f.close(); + if ( fi.extension().lower().contains( "htm" ) ) { + TQString url = html->mimeSourceFactory()->makeAbsolute( path, html->context() ); + html->setText( text, url ); raiseWidget( html ); return; } else { - normalText->setText( text ); + normalText->setText( text ); raiseWidget( normalText ); return; } } } - normalText->setText( TQString::null ); + normalText->setText( TQString::null ); raiseWidget( normalText ); } else { pixmap->setPixmap( pix ); raiseWidget( pixmap ); } } else { - normalText->setText( "I only show local files!" ); + normalText->setText( "I only show local files!" ); raiseWidget( normalText ); } } // **************************************************************************************************** -PreviewWidget::PreviewWidget( TQWidget *parent ) - : TQVBox( parent ), TQFilePreview() +PreviewWidget::PreviewWidget( TQWidget *parent ) + : TQVBox( parent ), TQFilePreview() { setSpacing( 5 ); setMargin( 5 ); - TQHBox *row = new TQHBox( this ); - row->setSpacing( 5 ); - (void)new TQLabel( tr( "Only show files smaller than: " ), row ); - sizeSpinBox = new TQSpinBox( 1, 10000, 1, row ); - sizeSpinBox->setSuffix( " KB" ); - sizeSpinBox->setValue( 64 ); - row->setFixedHeight( 10 + sizeSpinBox->sizeHint().height() ); + TQHBox *row = new TQHBox( this ); + row->setSpacing( 5 ); + (void)new TQLabel( tr( "Only show files smaller than: " ), row ); + sizeSpinBox = new TQSpinBox( 1, 10000, 1, row ); + sizeSpinBox->setSuffix( " KB" ); + sizeSpinBox->setValue( 64 ); + row->setFixedHeight( 10 + sizeSpinBox->sizeHint().height() ); preview = new Preview( this ); } -void PreviewWidget::previewUrl( const TQUrl &u ) +void PreviewWidget::previewUrl( const TQUrl &u ) { - preview->showPreview( u, sizeSpinBox->value() ); + preview->showPreview( u, sizeSpinBox->value() ); } // **************************************************************************************************** CustomFileDialog::CustomFileDialog() - : TQFileDialog( 0, 0, TRUE ) + : TQFileDialog( 0, 0, TRUE ) { - setDir( "/" ); + setDir( "/" ); dirView = new DirectoryView( this, 0, TRUE ); - dirView->addColumn( "" ); - dirView->header()->hide(); + dirView->addColumn( "" ); + dirView->header()->hide(); ::Directory *root = new ::Directory( dirView, "/" ); root->setOpen( TRUE ); - dirView->setFixedWidth( 150 ); + dirView->setFixedWidth( 150 ); - addLeftWidget( dirView ); + addLeftWidget( dirView ); - TQPushButton *p = new TQPushButton( this ); - p->setPixmap( TQPixmap( bookmarks ) ); - TQToolTip::add( p, tr( "Bookmarks" ) ); + TQPushButton *p = new TQPushButton( this ); + p->setPixmap( TQPixmap( bookmarks ) ); + TQToolTip::add( p, tr( "Bookmarks" ) ); - bookmarkMenu = new TQPopupMenu( this ); - connect( bookmarkMenu, SIGNAL( activated( int ) ), + bookmarkMenu = new TQPopupMenu( this ); + connect( bookmarkMenu, SIGNAL( activated( int ) ), this, SLOT( bookmarkChosen( int ) ) ); - addId = bookmarkMenu->insertItem( tr( "Add bookmark" ) ); - bookmarkMenu->insertSeparator(); + addId = bookmarkMenu->insertItem( tr( "Add bookmark" ) ); + bookmarkMenu->insertSeparator(); - TQFile f( ".bookmarks" ); - if ( f.open( IO_ReadOnly ) ) { - TQDataStream ds( &f ); + TQFile f( ".bookmarks" ); + if ( f.open( IO_ReadOnly ) ) { + TQDataStream ds( &f ); ds >> bookmarkList; - f.close(); + f.close(); TQStringList::Iterator it = bookmarkList.begin(); for ( ; it != bookmarkList.end(); ++it ) { - bookmarkMenu->insertItem( *it ); + bookmarkMenu->insertItem( *it ); } } - p->setPopup( bookmarkMenu ); + p->setPopup( bookmarkMenu ); - addToolButton( p, TRUE ); + addToolButton( p, TRUE ); - connect( dirView, SIGNAL( folderSelected( const TQString & ) ), - this, SLOT( setDir2( const TQString & ) ) ); - connect( this, SIGNAL( dirEntered( const TQString & ) ), - dirView, SLOT( setDir( const TQString & ) ) ); + connect( dirView, SIGNAL( folderSelected( const TQString & ) ), + this, SLOT( setDir2( const TQString & ) ) ); + connect( this, SIGNAL( dirEntered( const TQString & ) ), + dirView, SLOT( setDir( const TQString & ) ) ); - TQToolButton *b = new TQToolButton( this ); - TQToolTip::add( b, tr( "Go Home!" ) ); - b->setPixmap( TQPixmap( home ) ); - connect( b, SIGNAL( clicked() ), + TQToolButton *b = new TQToolButton( this ); + TQToolTip::add( b, tr( "Go Home!" ) ); + b->setPixmap( TQPixmap( home ) ); + connect( b, SIGNAL( clicked() ), this, SLOT( goHome() ) ); - addToolButton( b ); + addToolButton( b ); - resize( width() + width() / 3, height() ); + resize( width() + width() / 3, height() ); } CustomFileDialog::~CustomFileDialog() { if ( !bookmarkList.isEmpty() ) { - TQFile f( ".bookmarks" ); - if ( f.open( IO_WriteOnly ) ) { - TQDataStream ds( &f ); + TQFile f( ".bookmarks" ); + if ( f.open( IO_WriteOnly ) ) { + TQDataStream ds( &f ); ds << bookmarkList; - f.close(); + f.close(); } } } -void CustomFileDialog::setDir2( const TQString &s ) +void CustomFileDialog::setDir2( const TQString &s ) { - blockSignals( TRUE ); - setDir( s ); - blockSignals( FALSE ); + blockSignals( TRUE ); + setDir( s ); + blockSignals( FALSE ); } -void CustomFileDialog::showEvent( TQShowEvent *e ) +void CustomFileDialog::showEvent( TQShowEvent *e ) { - TQFileDialog::showEvent( e ); - dirView->setDir( dirPath() ); + TQFileDialog::showEvent( e ); + dirView->setDir( dirPath() ); } void CustomFileDialog::bookmarkChosen( int i ) { if ( i == addId ) { bookmarkList << dirPath(); - bookmarkMenu->insertItem( dirPath() ); + bookmarkMenu->insertItem( dirPath() ); } else { - setDir( bookmarkMenu->text( i ) ); + setDir( bookmarkMenu->text( i ) ); } } void CustomFileDialog::goHome() { if ( getenv( "HOME" ) ) - setDir( getenv( "HOME" ) ); + setDir( getenv( "HOME" ) ); else - setDir( "/" ); + setDir( "/" ); } // **************************************************************************************************** @@ -324,14 +324,14 @@ void CustomFileDialog::goHome() int main( int argc, char ** argv ) { TQFileDialog::Mode mode = TQFileDialog::ExistingFile; - TQString start; - TQString filter; - TQString caption; + TQString start; + TQString filter; + TQString caption; bool preview = FALSE; bool custom = FALSE; - TQApplication a( argc, argv ); + TQApplication a( argc, argv ); for (int i=1; i<argc; i++) { - TQString arg = argv[i]; + TQString arg = argv[i]; if ( arg == "-any" ) mode = TQFileDialog::AnyFile; else if ( arg == "-dir" ) @@ -345,7 +345,7 @@ int main( int argc, char ** argv ) else if ( arg == "-custom" ) custom = TRUE; else if ( arg[0] == '-' ) { - qDebug("Usage: qdir [-any | -dir | -custom] [-preview] [-default f] {-filter f} [caption ...]\n" + qDebug("Usage: qdir [-any | -dir | -custom] [-preview] [-default f] {-filter f} [caption ...]\n" " -any Get any filename, need not exist.\n" " -dir Return a directory rather than a file.\n" " -custom Opens a customized TQFileDialog with \n" @@ -357,33 +357,33 @@ int main( int argc, char ** argv ) ); return 1; } else { - if ( !caption.isNull() ) + if ( !caption.isNull() ) caption += ' '; caption += arg; } } if ( !start ) - start = TQDir::currentDirPath(); + start = TQDir::currentDirPath(); if ( !caption ) caption = mode == TQFileDialog::Directory ? "Choose directory..." : "Choose file..."; if ( !custom ) { - TQFileDialog fd( TQString::null, filter, 0, 0, TRUE ); - fd.setMode( mode ); + TQFileDialog fd( TQString::null, filter, 0, 0, TRUE ); + fd.setMode( mode ); if ( preview ) { - fd.setContentsPreviewEnabled( TRUE ); + fd.setContentsPreviewEnabled( TRUE ); PreviewWidget *pw = new PreviewWidget( &fd ); - fd.setContentsPreview( pw, pw ); - fd.setViewMode( TQFileDialog::List ); - fd.setPreviewMode( TQFileDialog::Contents ); + fd.setContentsPreview( pw, pw ); + fd.setViewMode( TQFileDialog::List ); + fd.setPreviewMode( TQFileDialog::Contents ); } - fd.setCaption( caption ); - fd.setSelection( start ); - if ( fd.exec() == TQDialog::Accepted ) { - TQString result = fd.selectedFile(); + fd.setCaption( caption ); + fd.setSelection( start ); + if ( fd.exec() == TQDialog::Accepted ) { + TQString result = fd.selectedFile(); printf("%s\n", (const char*)result); return 0; } else { @@ -391,7 +391,7 @@ int main( int argc, char ** argv ) } } else { CustomFileDialog fd; - fd.exec(); + fd.exec(); return 1; } } -- cgit v1.2.1