testnewstuff.cpp
00001 /* 00002 This file is part of KOrganizer. 00003 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include <iostream> 00022 00023 #include <tqlayout.h> 00024 #include <tqfile.h> 00025 #include <tqtextstream.h> 00026 00027 #include <tdeaboutdata.h> 00028 #include <tdeapplication.h> 00029 #include <kdebug.h> 00030 #include <tdelocale.h> 00031 #include <tdecmdlineargs.h> 00032 #include <kprocess.h> 00033 #include <kdialog.h> 00034 00035 #include "testnewstuff.h" 00036 #include "testnewstuff.moc" 00037 00038 using namespace std; 00039 00040 bool TestNewStuff::install( const TQString &fileName ) 00041 { 00042 kdDebug() << "TestNewStuff::install(): " << fileName << endl; 00043 TQFile f( fileName ); 00044 if ( !f.open( IO_ReadOnly ) ) { 00045 kdDebug() << "Error opening file." << endl; 00046 return false; 00047 } 00048 TQTextStream ts( &f ); 00049 kdDebug() << "--BEGIN-NEW_STUFF--" << endl; 00050 cout << ts.read().utf8(); 00051 kdDebug() << "---END-NEW_STUFF---" << endl; 00052 return true; 00053 } 00054 00055 bool TestNewStuff::createUploadFile( const TQString &fileName ) 00056 { 00057 TDEProcess p; 00058 p << "touch" << fileName; 00059 p.start(TDEProcess::Block); 00060 kdDebug() << "TestNewStuff::createUploadFile(): " << fileName << endl; 00061 return true; 00062 } 00063 00064 00065 MyWidget::MyWidget() 00066 { 00067 mNewStuff = new TestNewStuff; 00068 00069 TQBoxLayout *topLayout = new TQVBoxLayout( this ); 00070 topLayout->setMargin( KDialog::marginHint() ); 00071 topLayout->setSpacing( KDialog::spacingHint() ); 00072 00073 TQPushButton *downloadButton = new TQPushButton( "Download", this ); 00074 topLayout->addWidget( downloadButton ); 00075 connect( downloadButton, TQT_SIGNAL( clicked() ), TQT_SLOT( download() ) ); 00076 00077 TQPushButton *uploadButton = new TQPushButton( "Upload", this ); 00078 topLayout->addWidget( uploadButton ); 00079 connect( uploadButton, TQT_SIGNAL( clicked() ), TQT_SLOT( upload() ) ); 00080 00081 topLayout->addSpacing( 5 ); 00082 00083 TQPushButton *closeButton = new TQPushButton( "Close", this ); 00084 topLayout->addWidget( closeButton ); 00085 connect( closeButton, TQT_SIGNAL( clicked() ), kapp, TQT_SLOT( quit() ) ); 00086 } 00087 00088 MyWidget::~MyWidget() 00089 { 00090 delete mNewStuff; 00091 } 00092 00093 void MyWidget::download() 00094 { 00095 kdDebug() << "MyWidget::download()" << endl; 00096 00097 mNewStuff->download(); 00098 } 00099 00100 void MyWidget::upload() 00101 { 00102 kdDebug() << "MyWidget::download()" << endl; 00103 00104 mNewStuff->upload(); 00105 } 00106 00107 00108 int main(int argc,char **argv) 00109 { 00110 TDEAboutData aboutData("knewstufftest","TDENewStuff Test","0.1"); 00111 TDECmdLineArgs::init(argc,argv,&aboutData); 00112 00113 TDEApplication app; 00114 00115 MyWidget wid; 00116 app.setMainWidget( &wid ); 00117 wid.show(); 00118 00119 app.exec(); 00120 }