TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kdirlistertest.cpp 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* This file is part of the KDE desktop environment
  2. Copyright (C) 2001, 2002 Michael Brade <brade@kde.org>
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this library; see the file COPYING.LIB. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. Boston, MA 02110-1301, USA.
  15. */
  16. #include <tqlayout.h>
  17. #include <tqpushbutton.h>
  18. #include <tdeapplication.h>
  19. #include <kdirlister.h>
  20. #include <kdebug.h>
  21. #include "kdirlistertest.h"
  22. #include <cstdlib>
  23. KDirListerTest::KDirListerTest( TQWidget *parent, const char *name )
  24. : TQWidget( parent, name )
  25. {
  26. lister = new KDirLister( false /* true */ );
  27. debug = new PrintSignals;
  28. TQVBoxLayout* layout = new TQVBoxLayout( this );
  29. TQPushButton* startH = new TQPushButton( "Start listing $HOME", this );
  30. TQPushButton* startR= new TQPushButton( "Start listing /", this );
  31. TQPushButton* test = new TQPushButton( "Many", this );
  32. TQPushButton* startT = new TQPushButton( "tarfile", this );
  33. layout->addWidget( startH );
  34. layout->addWidget( startR );
  35. layout->addWidget( startT );
  36. layout->addWidget( test );
  37. resize( layout->sizeHint() );
  38. connect( startR, TQT_SIGNAL( clicked() ), TQT_SLOT( startRoot() ) );
  39. connect( startH, TQT_SIGNAL( clicked() ), TQT_SLOT( startHome() ) );
  40. connect( startT, TQT_SIGNAL( clicked() ), TQT_SLOT( startTar() ) );
  41. connect( test, TQT_SIGNAL( clicked() ), TQT_SLOT( test() ) );
  42. connect( lister, TQT_SIGNAL( started( const KURL & ) ),
  43. debug, TQT_SLOT( started( const KURL & ) ) );
  44. connect( lister, TQT_SIGNAL( completed() ),
  45. debug, TQT_SLOT( completed() ) );
  46. connect( lister, TQT_SIGNAL( completed( const KURL & ) ),
  47. debug, TQT_SLOT( completed( const KURL & ) ) );
  48. connect( lister, TQT_SIGNAL( canceled() ),
  49. debug, TQT_SLOT( canceled() ) );
  50. connect( lister, TQT_SIGNAL( canceled( const KURL & ) ),
  51. debug, TQT_SLOT( canceled( const KURL & ) ) );
  52. connect( lister, TQT_SIGNAL( redirection( const KURL & ) ),
  53. debug, TQT_SLOT( redirection( const KURL & ) ) );
  54. connect( lister, TQT_SIGNAL( redirection( const KURL &, const KURL & ) ),
  55. debug, TQT_SLOT( redirection( const KURL &, const KURL & ) ) );
  56. connect( lister, TQT_SIGNAL( clear() ),
  57. debug, TQT_SLOT( clear() ) );
  58. connect( lister, TQT_SIGNAL( newItems( const KFileItemList & ) ),
  59. debug, TQT_SLOT( newItems( const KFileItemList & ) ) );
  60. connect( lister, TQT_SIGNAL( itemsFilteredByMime( const KFileItemList & ) ),
  61. debug, TQT_SLOT( itemsFilteredByMime( const KFileItemList & ) ) );
  62. connect( lister, TQT_SIGNAL( deleteItem( KFileItem * ) ),
  63. debug, TQT_SLOT( deleteItem( KFileItem * ) ) );
  64. connect( lister, TQT_SIGNAL( refreshItems( const KFileItemList & ) ),
  65. debug, TQT_SLOT( refreshItems( const KFileItemList & ) ) );
  66. connect( lister, TQT_SIGNAL( infoMessage( const TQString& ) ),
  67. debug, TQT_SLOT( infoMessage( const TQString& ) ) );
  68. connect( lister, TQT_SIGNAL( percent( int ) ),
  69. debug, TQT_SLOT( percent( int ) ) );
  70. connect( lister, TQT_SIGNAL( totalSize( TDEIO::filesize_t ) ),
  71. debug, TQT_SLOT( totalSize( TDEIO::filesize_t ) ) );
  72. connect( lister, TQT_SIGNAL( processedSize( TDEIO::filesize_t ) ),
  73. debug, TQT_SLOT( processedSize( TDEIO::filesize_t ) ) );
  74. connect( lister, TQT_SIGNAL( speed( int ) ),
  75. debug, TQT_SLOT( speed( int ) ) );
  76. connect( lister, TQT_SIGNAL( completed() ),
  77. this, TQT_SLOT( completed() ) );
  78. }
  79. KDirListerTest::~KDirListerTest()
  80. {
  81. delete lister;
  82. }
  83. void KDirListerTest::startHome()
  84. {
  85. KURL home( getenv( "HOME" ) );
  86. lister->openURL( home, false, false );
  87. // lister->stop();
  88. }
  89. void KDirListerTest::startRoot()
  90. {
  91. KURL root( "file:/" );
  92. lister->openURL( root, true, true );
  93. // lister->stop( root );
  94. }
  95. void KDirListerTest::startTar()
  96. {
  97. KURL root( "file:/home/jowenn/aclocal_1.tgz" );
  98. lister->openURL( root, true, true );
  99. // lister->stop( root );
  100. }
  101. void KDirListerTest::test()
  102. {
  103. KURL home( getenv( "HOME" ) );
  104. KURL root( "file:/" );
  105. /* lister->openURL( home, true, false );
  106. lister->openURL( root, true, true );
  107. lister->openURL( KURL("file:/etc"), true, true );
  108. lister->openURL( root, true, true );
  109. lister->openURL( KURL("file:/dev"), true, true );
  110. lister->openURL( KURL("file:/tmp"), true, true );
  111. lister->openURL( KURL("file:/usr/include"), true, true );
  112. lister->updateDirectory( KURL("file:/usr/include") );
  113. lister->updateDirectory( KURL("file:/usr/include") );
  114. lister->openURL( KURL("file:/usr/"), true, true );
  115. */
  116. lister->openURL( KURL("file:/dev"), true, true );
  117. }
  118. void KDirListerTest::completed()
  119. {
  120. if ( lister->url().path() == "/")
  121. {
  122. KFileItem* item = lister->findByURL( "/tmp" );
  123. if ( item )
  124. kdDebug() << "Found /tmp: " << item << endl;
  125. else
  126. kdWarning() << "/tmp not found! Bug in findByURL?" << endl;
  127. }
  128. }
  129. int main ( int argc, char *argv[] )
  130. {
  131. TDEApplication app( argc, argv, "kdirlistertest", true /*styles*/ );
  132. KDirListerTest *test = new KDirListerTest( 0 );
  133. test->show();
  134. app.setMainWidget( test );
  135. return app.exec();
  136. }
  137. #include "kdirlistertest.moc"