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/dirview-example.html | 260 +++++++++++++++++++++--------------------- 1 file changed, 130 insertions(+), 130 deletions(-) (limited to 'doc/html/dirview-example.html') diff --git a/doc/html/dirview-example.html b/doc/html/dirview-example.html index bfed86e6b..c0a9e7f6d 100644 --- a/doc/html/dirview-example.html +++ b/doc/html/dirview-example.html @@ -52,11 +52,11 @@ Drag&Drop in a listview. #ifndef DIRVIEW_H #define DIRVIEW_H -#include <qlistview.h> -#include <qstring.h> -#include <qfile.h> -#include <qfileinfo.h> -#include <qtimer.h> +#include <ntqlistview.h> +#include <ntqstring.h> +#include <ntqfile.h> +#include <ntqfileinfo.h> +#include <ntqtimer.h> class TQWidget; class TQDragEnterEvent; @@ -67,63 +67,63 @@ class TQDropEvent; class FileItem : public TQListViewItem { public: - FileItem( TQListViewItem *parent, const TQString &s1, const TQString &s2 ) + FileItem( TQListViewItem *parent, const TQString &s1, const TQString &s2 ) : TQListViewItem( parent, s1, s2 ), pix( 0 ) {} - const TQPixmap *pixmap( int i ) const; + const TQPixmap *pixmap( int i ) const; #if !defined(Q_NO_USING_KEYWORD) using TQListViewItem::setPixmap; #endif - void setPixmap( TQPixmap *p ); + void setPixmap( TQPixmap *p ); private: - TQPixmap *pix; + TQPixmap *pix; }; class Directory : public TQListViewItem { public: - Directory( TQListView * parent, const TQString& filename ); - Directory( Directory * parent, const TQString& filename, const TQString &col2 ) + Directory( TQListView * parent, const TQString& filename ); + Directory( Directory * parent, const TQString& filename, const TQString &col2 ) : TQListViewItem( parent, filename, col2 ), pix( 0 ) {} - Directory( Directory * parent, const TQString& filename ); + Directory( Directory * parent, const TQString& filename ); - TQString text( int column ) const; + TQString text( int column ) const; - TQString fullName(); + TQString fullName(); void setOpen( bool ); void setup(); - const TQPixmap *pixmap( int i ) const; + const TQPixmap *pixmap( int i ) const; #if !defined(Q_NO_USING_KEYWORD) using TQListViewItem::setPixmap; #endif - void setPixmap( TQPixmap *p ); + void setPixmap( TQPixmap *p ); private: - TQFile f; + TQFile f; Directory * p; bool readable; bool showDirsOnly; - TQPixmap *pix; + TQPixmap *pix; }; -class DirectoryView : public TQListView +class DirectoryView : public TQListView { Q_OBJECT public: - DirectoryView( TQWidget *parent = 0, const char *name = 0, bool sdo = FALSE ); + DirectoryView( TQWidget *parent = 0, const char *name = 0, bool sdo = FALSE ); bool showDirsOnly() { return dirsOnly; } public slots: - void setDir( const TQString & ); + void setDir( const TQString & ); signals: - void folderSelected( const TQString & ); + void folderSelected( const TQString & ); protected slots: void slotFolderSelected( TQListViewItem * ); @@ -139,12 +139,12 @@ protected: void contentsMouseReleaseEvent( TQMouseEvent *e ); private: - TQString fullPath(TQListViewItem* item); + TQString fullPath(TQListViewItem* item); bool dirsOnly; TQListViewItem *oldCurrent; TQListViewItem *dropItem; - TQTimer* autoopen_timer; - TQPoint presspos; + TQTimer* autoopen_timer; + TQPoint presspos; bool mousePressed; }; @@ -169,19 +169,19 @@ can be used in any other trees. #include "dirview.h" -#include <qdir.h> -#include <qfile.h> -#include <qfileinfo.h> -#include <qpixmap.h> -#include <qevent.h> -#include <qpoint.h> -#include <qmessagebox.h> -#include <qdragobject.h> -#include <qmime.h> -#include <qstrlist.h> -#include <qstringlist.h> -#include <qapplication.h> -#include <qheader.h> +#include <ntqdir.h> +#include <ntqfile.h> +#include <ntqfileinfo.h> +#include <ntqpixmap.h> +#include <ntqevent.h> +#include <ntqpoint.h> +#include <ntqmessagebox.h> +#include <ntqdragobject.h> +#include <ntqmime.h> +#include <ntqstrlist.h> +#include <ntqstringlist.h> +#include <ntqapplication.h> +#include <ntqheader.h> static const char* folder_closed_xpm[]={ "16 16 9 1", @@ -307,7 +307,7 @@ TQPixmap *fileNormal = 0; * *****************************************************************************/ -Directory::Directory( Directory * parent, const TQString& filename ) +Directory::Directory( Directory * parent, const TQString& filename ) : TQListViewItem( parent ), f(filename), showDirsOnly( parent->showDirsOnly ), pix( 0 ) @@ -322,7 +322,7 @@ TQPixmap *fileNormal = 0; } -Directory::Directory( TQListView * parent, const TQString& filename ) +Directory::Directory( TQListView * parent, const TQString& filename ) : TQListViewItem( parent ), f(filename), showDirsOnly( ( (DirectoryView*)parent )->showDirsOnly() ), pix( 0 ) @@ -332,7 +332,7 @@ Directory::Directory( TQListView * parent, const void Directory::setPixmap( TQPixmap *px ) +void Directory::setPixmap( TQPixmap *px ) { pix = px; setup(); @@ -357,34 +357,34 @@ Directory::Directory( TQListView * parent, const setPixmap( folderClosed ); if ( o && !childCount() ) { - TQString s( fullName() ); - TQDir thisDir( s ); - if ( !thisDir.isReadable() ) { + TQString s( fullName() ); + TQDir thisDir( s ); + if ( !thisDir.isReadable() ) { readable = FALSE; setExpandable( FALSE ); return; } listView()->setUpdatesEnabled( FALSE ); - const TQFileInfoList * files = thisDir.entryInfoList(); + const TQFileInfoList * files = thisDir.entryInfoList(); if ( files ) { TQFileInfoListIterator it( *files ); - TQFileInfo * fi; + TQFileInfo * fi; while( (fi=it.current()) != 0 ) { ++it; - if ( fi->fileName() == "." || fi->fileName() == ".." ) + if ( fi->fileName() == "." || fi->fileName() == ".." ) ; // nothing - else if ( fi->isSymLink() && !showDirsOnly ) { - FileItem *item = new FileItem( this, fi->fileName(), + else if ( fi->isSymLink() && !showDirsOnly ) { + FileItem *item = new FileItem( this, fi->fileName(), "Symbolic Link" ); item->setPixmap( fileNormal ); } - else if ( fi->isDir() ) - (void)new Directory( this, fi->fileName() ); + else if ( fi->isDir() ) + (void)new Directory( this, fi->fileName() ); else if ( !showDirsOnly ) { FileItem *item - = new FileItem( this, fi->fileName(), - fi->isFile()?"File":"Special" ); + = new FileItem( this, fi->fileName(), + fi->isFile()?"File":"Special" ); item->setPixmap( fileNormal ); } } @@ -404,11 +404,11 @@ Directory::Directory( TQListView * parent, const Directory::fullName() { - TQString s; + TQString s; if ( p ) { s = p->fullName(); - s.append( f.name() ); - s.append( "/" ); + s.append( f.name() ); + s.append( "/" ); } else { s = f.name(); } @@ -432,27 +432,27 @@ TQString Directory::fullName() * *****************************************************************************/ -DirectoryView::DirectoryView( TQWidget *parent, const char *name, bool sdo ) - : TQListView( parent, name ), dirsOnly( sdo ), oldCurrent( 0 ), +DirectoryView::DirectoryView( TQWidget *parent, const char *name, bool sdo ) + : TQListView( parent, name ), dirsOnly( sdo ), oldCurrent( 0 ), dropItem( 0 ), mousePressed( FALSE ) { - autoopen_timer = new TQTimer( this ); + autoopen_timer = new TQTimer( this ); if ( !folderLocked ) { - folderLocked = new TQPixmap( folder_locked ); - folderClosed = new TQPixmap( folder_closed_xpm ); - folderOpen = new TQPixmap( folder_open_xpm ); - fileNormal = new TQPixmap( pix_file ); + folderLocked = new TQPixmap( folder_locked ); + folderClosed = new TQPixmap( folder_closed_xpm ); + folderOpen = new TQPixmap( folder_open_xpm ); + fileNormal = new TQPixmap( pix_file ); } - connect( this, SIGNAL( doubleClicked( TQListViewItem * ) ), + connect( this, SIGNAL( doubleClicked( TQListViewItem * ) ), this, SLOT( slotFolderSelected( TQListViewItem * ) ) ); - connect( this, SIGNAL( returnPressed( TQListViewItem * ) ), + connect( this, SIGNAL( returnPressed( TQListViewItem * ) ), this, SLOT( slotFolderSelected( TQListViewItem * ) ) ); - setAcceptDrops( TRUE ); - viewport()->setAcceptDrops( TRUE ); + setAcceptDrops( TRUE ); + viewport()->setAcceptDrops( TRUE ); - connect( autoopen_timer, SIGNAL( timeout() ), + connect( autoopen_timer, SIGNAL( timeout() ), this, SLOT( openFolder() ) ); } @@ -467,7 +467,7 @@ void DirectoryView::slotFolderSelected( DirectoryView::openFolder() { - autoopen_timer->stop(); + autoopen_timer->stop(); if ( dropItem && !dropItem->isOpen() ) { dropItem->setOpen( TRUE ); dropItem->repaint(); @@ -477,39 +477,39 @@ void DirectoryView::openFolder() static const int autoopenTime = 750; -void DirectoryView::contentsDragEnterEvent( TQDragEnterEvent *e ) +void DirectoryView::contentsDragEnterEvent( TQDragEnterEvent *e ) { if ( !TQUriDrag::canDecode(e) ) { e->ignore(); return; } - oldCurrent = currentItem(); + oldCurrent = currentItem(); - TQListViewItem *i = itemAt( contentsToViewport(e->pos()) ); + TQListViewItem *i = itemAt( contentsToViewport(e->pos()) ); if ( i ) { dropItem = i; - autoopen_timer->start( autoopenTime ); + autoopen_timer->start( autoopenTime ); } } -void DirectoryView::contentsDragMoveEvent( TQDragMoveEvent *e ) +void DirectoryView::contentsDragMoveEvent( TQDragMoveEvent *e ) { if ( !TQUriDrag::canDecode(e) ) { e->ignore(); return; } - TQPoint vp = contentsToViewport( ( (TQDragMoveEvent*)e )->pos() ); - TQListViewItem *i = itemAt( vp ); + TQPoint vp = contentsToViewport( ( (TQDragMoveEvent*)e )->pos() ); + TQListViewItem *i = itemAt( vp ); if ( i ) { - setSelected( i, TRUE ); + setSelected( i, TRUE ); e->accept(); if ( i != dropItem ) { - autoopen_timer->stop(); + autoopen_timer->stop(); dropItem = i; - autoopen_timer->start( autoopenTime ); + autoopen_timer->start( autoopenTime ); } switch ( e->action() ) { case TQDropEvent::Copy: @@ -525,37 +525,37 @@ static const int autoopenTime = 750; } } else { e->ignore(); - autoopen_timer->stop(); + autoopen_timer->stop(); dropItem = 0; } } -void DirectoryView::contentsDragLeaveEvent( TQDragLeaveEvent * ) +void DirectoryView::contentsDragLeaveEvent( TQDragLeaveEvent * ) { - autoopen_timer->stop(); + autoopen_timer->stop(); dropItem = 0; - setCurrentItem( oldCurrent ); - setSelected( oldCurrent, TRUE ); + setCurrentItem( oldCurrent ); + setSelected( oldCurrent, TRUE ); } -void DirectoryView::contentsDropEvent( TQDropEvent *e ) +void DirectoryView::contentsDropEvent( TQDropEvent *e ) { - autoopen_timer->stop(); + autoopen_timer->stop(); if ( !TQUriDrag::canDecode(e) ) { e->ignore(); return; } - TQListViewItem *item = itemAt( contentsToViewport(e->pos()) ); + TQListViewItem *item = itemAt( contentsToViewport(e->pos()) ); if ( item ) { - TQStrList lst; + TQStrList lst; TQUriDrag::decode( e, lst ); - TQString str; + TQString str; switch ( e->action() ) { case TQDropEvent::Copy: @@ -577,14 +577,14 @@ static const int autoopenTime = 750; e->accept(); - for ( uint i = 0; i < lst.count(); ++i ) { - TQString filename = TQDir::convertSeparators(TQUriDrag::uriToLocalFile(lst.at(i))); + for ( uint i = 0; i < lst.count(); ++i ) { + TQString filename = TQDir::convertSeparators(TQUriDrag::uriToLocalFile(lst.at(i))); str += filename + "\n"; } str += TQString( "\nTo\n\n %1" ) - .arg( TQDir::convertSeparators(fullPath(item)) ); + .arg( TQDir::convertSeparators(fullPath(item)) ); - TQMessageBox::information( this, "Drop target", str, "Not implemented" ); + TQMessageBox::information( this, "Drop target", str, "Not implemented" ); } else e->ignore(); @@ -593,7 +593,7 @@ static const int autoopenTime = 750; TQString DirectoryView::fullPath(TQListViewItem* item) { - TQString fullpath = item->text(0); + TQString fullpath = item->text(0); while ( (item=item->parent()) ) { if ( item->parent() ) fullpath = item->text(0) + "/" + fullpath; @@ -601,55 +601,55 @@ TQString DirectoryView::fullPath(TQListViewItem* item) fullpath = item->text(0) + fullpath; } #ifdef Q_WS_WIN - if (fullpath.length() > 2 && fullpath[1] != ':') { - TQDir dir(fullpath); - fullpath = dir.currentDirPath().left(2) + fullpath; + if (fullpath.length() > 2 && fullpath[1] != ':') { + TQDir dir(fullpath); + fullpath = dir.currentDirPath().left(2) + fullpath; } #endif return fullpath; } -void DirectoryView::contentsMousePressEvent( TQMouseEvent* e ) +void DirectoryView::contentsMousePressEvent( TQMouseEvent* e ) { - TQListView::contentsMousePressEvent(e); - TQPoint p( contentsToViewport( e->pos() ) ); + TQListView::contentsMousePressEvent(e); + TQPoint p( contentsToViewport( e->pos() ) ); TQListViewItem *i = itemAt( p ); if ( i ) { // if the user clicked into the root decoration of the item, don't try to start a drag! - if ( p.x() > header()->cellPos( header()->mapToActual( 0 ) ) + + if ( p.x() > header()->cellPos( header()->mapToActual( 0 ) ) + treeStepSize() * ( i->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() || - p.x() < header()->cellPos( header()->mapToActual( 0 ) ) ) { + p.x() < header()->cellPos( header()->mapToActual( 0 ) ) ) { presspos = e->pos(); mousePressed = TRUE; } } } -void DirectoryView::contentsMouseMoveEvent( TQMouseEvent* e ) +void DirectoryView::contentsMouseMoveEvent( TQMouseEvent* e ) { - if ( mousePressed && ( presspos - e->pos() ).manhattanLength() > TQApplication::startDragDistance() ) { + if ( mousePressed && ( presspos - e->pos() ).manhattanLength() > TQApplication::startDragDistance() ) { mousePressed = FALSE; TQListViewItem *item = itemAt( contentsToViewport(presspos) ); if ( item ) { - TQString source = fullPath(item); - if ( TQFile::exists(source) ) { + TQString source = fullPath(item); + if ( TQFile::exists(source) ) { TQUriDrag* ud = new TQUriDrag(viewport()); ud->setFileNames( source ); - if ( ud->drag() ) - TQMessageBox::information( this, "Drag source", + if ( ud->drag() ) + TQMessageBox::information( this, "Drag source", TQString("Delete ") + TQDir::convertSeparators(source), "Not implemented" ); } } } } -void DirectoryView::contentsMouseReleaseEvent( TQMouseEvent * ) +void DirectoryView::contentsMouseReleaseEvent( TQMouseEvent * ) { mousePressed = FALSE; } -void DirectoryView::setDir( const TQString &s ) +void DirectoryView::setDir( const TQString &s ) { TQListViewItemIterator it( this ); ++it; @@ -657,10 +657,10 @@ void DirectoryView::setDir( const TQSt it.current()->setOpen( FALSE ); } - TQStringList lst( TQStringList::split( "/", s ) ); + TQStringList lst( TQStringList::split( "/", s ) ); TQListViewItem *item = firstChild(); - TQStringList::Iterator it2 = lst.begin(); - for ( ; it2 != lst.end(); ++it2 ) { + TQStringList::Iterator it2 = lst.begin(); + for ( ; it2 != lst.end(); ++it2 ) { while ( item ) { if ( item->text( 0 ) == *it2 ) { item->setOpen( TRUE ); @@ -674,7 +674,7 @@ void DirectoryView::setDir( const TQSt setCurrentItem( item ); } -void FileItem::setPixmap( TQPixmap *p ) +void FileItem::setPixmap( TQPixmap *p ) { pix = p; setup(); @@ -704,38 +704,38 @@ const TQPixmap *FileItem::pixmap( int i ** *****************************************************************************/ -#include <qapplication.h> -#include <qfileinfo.h> -#include <qdir.h> +#include <ntqapplication.h> +#include <ntqfileinfo.h> +#include <ntqdir.h> #include "dirview.h" int main( int argc, char ** argv ) { - TQApplication a( argc, argv ); + TQApplication a( argc, argv ); DirectoryView mw; - mw.addColumn( "Name" ); - mw.addColumn( "Type" ); - mw.setTreeStepSize( 20 ); + mw.addColumn( "Name" ); + mw.addColumn( "Type" ); + mw.setTreeStepSize( 20 ); - const TQFileInfoList* roots = TQDir::drives(); + const TQFileInfoList* roots = TQDir::drives(); TQPtrListIterator<TQFileInfo> i(*roots); - TQFileInfo* fi; + TQFileInfo* fi; while ( (fi = *i) ) { ++i; - Directory * root = new Directory( &mw, fi->filePath() ); + Directory * root = new Directory( &mw, fi->filePath() ); if ( roots->count() <= 1 ) root->setOpen( TRUE ); // be interesting } - mw.resize( 400, 400 ); - mw.setCaption( "TQt Example - Directory Browser" ); - mw.setAllColumnsShowFocus( TRUE ); - a.setMainWidget( &mw ); - mw.show(); + mw.resize( 400, 400 ); + mw.setCaption( "TQt Example - Directory Browser" ); + mw.setAllColumnsShowFocus( TRUE ); + a.setMainWidget( &mw ); + mw.show(); - return a.exec(); + return a.exec(); } -- cgit v1.2.3