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.

testnewstuff.cpp 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. This file is part of KOrganizer.
  3. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #include <iostream>
  18. #include <tqlayout.h>
  19. #include <tqfile.h>
  20. #include <tqtextstream.h>
  21. #include <tdeaboutdata.h>
  22. #include <tdeapplication.h>
  23. #include <kdebug.h>
  24. #include <tdelocale.h>
  25. #include <tdecmdlineargs.h>
  26. #include <kprocess.h>
  27. #include <kdialog.h>
  28. #include "testnewstuff.h"
  29. #include "testnewstuff.moc"
  30. using namespace std;
  31. bool TestNewStuff::install( const TQString &fileName )
  32. {
  33. kdDebug() << "TestNewStuff::install(): " << fileName << endl;
  34. TQFile f( fileName );
  35. if ( !f.open( IO_ReadOnly ) ) {
  36. kdDebug() << "Error opening file." << endl;
  37. return false;
  38. }
  39. TQTextStream ts( &f );
  40. kdDebug() << "--BEGIN-NEW_STUFF--" << endl;
  41. cout << ts.read().utf8();
  42. kdDebug() << "---END-NEW_STUFF---" << endl;
  43. return true;
  44. }
  45. bool TestNewStuff::createUploadFile( const TQString &fileName )
  46. {
  47. TDEProcess p;
  48. p << "touch" << fileName;
  49. p.start(TDEProcess::Block);
  50. kdDebug() << "TestNewStuff::createUploadFile(): " << fileName << endl;
  51. return true;
  52. }
  53. MyWidget::MyWidget()
  54. {
  55. mNewStuff = new TestNewStuff;
  56. TQBoxLayout *topLayout = new TQVBoxLayout( this );
  57. topLayout->setMargin( KDialog::marginHint() );
  58. topLayout->setSpacing( KDialog::spacingHint() );
  59. TQPushButton *downloadButton = new TQPushButton( "Download", this );
  60. topLayout->addWidget( downloadButton );
  61. connect( downloadButton, TQT_SIGNAL( clicked() ), TQT_SLOT( download() ) );
  62. TQPushButton *uploadButton = new TQPushButton( "Upload", this );
  63. topLayout->addWidget( uploadButton );
  64. connect( uploadButton, TQT_SIGNAL( clicked() ), TQT_SLOT( upload() ) );
  65. topLayout->addSpacing( 5 );
  66. TQPushButton *closeButton = new TQPushButton( "Close", this );
  67. topLayout->addWidget( closeButton );
  68. connect( closeButton, TQT_SIGNAL( clicked() ), kapp, TQT_SLOT( quit() ) );
  69. }
  70. MyWidget::~MyWidget()
  71. {
  72. delete mNewStuff;
  73. }
  74. void MyWidget::download()
  75. {
  76. kdDebug() << "MyWidget::download()" << endl;
  77. mNewStuff->download();
  78. }
  79. void MyWidget::upload()
  80. {
  81. kdDebug() << "MyWidget::download()" << endl;
  82. mNewStuff->upload();
  83. }
  84. int main(int argc,char **argv)
  85. {
  86. TDEAboutData aboutData("knewstufftest","KNewStuff Test","0.1");
  87. TDECmdLineArgs::init(argc,argv,&aboutData);
  88. TDEApplication app;
  89. MyWidget wid;
  90. app.setMainWidget( &wid );
  91. wid.show();
  92. app.exec();
  93. }