00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include <iostream>
00022
00023
#include <qlayout.h>
00024
#include <qfile.h>
00025
#include <qtextstream.h>
00026
00027
#include <kaboutdata.h>
00028
#include <kapplication.h>
00029
#include <kdebug.h>
00030
#include <klocale.h>
00031
#include <kcmdlineargs.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 QString &fileName )
00041 {
00042 kdDebug(5850) <<
"TestNewStuff::install(): " << fileName << endl;
00043
QFile f( fileName );
00044
if ( !f.open( IO_ReadOnly ) ) {
00045 kdDebug(5850) <<
"Error opening file." << endl;
00046
return false;
00047 }
00048
QTextStream ts( &f );
00049 kdDebug(5850) <<
"--BEGIN-NEW_STUFF--" << endl;
00050 cout << ts.read().utf8();
00051 kdDebug(5850) <<
"---END-NEW_STUFF---" << endl;
00052
return true;
00053 }
00054
00055
bool TestNewStuff::createUploadFile(
const QString &fileName )
00056 {
00057 KProcess p;
00058 p <<
"touch" << fileName;
00059 p.start(KProcess::Block);
00060 kdDebug(5850) <<
"TestNewStuff::createUploadFile(): " << fileName << endl;
00061
return true;
00062 }
00063
00064
00065 MyWidget::MyWidget()
00066 {
00067 mNewStuff =
new TestNewStuff;
00068
00069
QBoxLayout *topLayout =
new QVBoxLayout(
this );
00070 topLayout->
setMargin( KDialog::marginHint() );
00071 topLayout->
setSpacing( KDialog::spacingHint() );
00072
00073
QPushButton *downloadButton =
new QPushButton(
"Download",
this );
00074 topLayout->
addWidget( downloadButton );
00075 connect( downloadButton, SIGNAL( clicked() ), SLOT( download() ) );
00076
00077 QPushButton *uploadButton =
new QPushButton(
"Upload",
this );
00078 topLayout->
addWidget( uploadButton );
00079 connect( uploadButton, SIGNAL( clicked() ), SLOT( upload() ) );
00080
00081 topLayout->addSpacing( 5 );
00082
00083 QPushButton *closeButton =
new QPushButton(
"Close",
this );
00084 topLayout->
addWidget( closeButton );
00085 connect( closeButton, SIGNAL( clicked() ), kapp, SLOT( quit() ) );
00086 }
00087
00088 MyWidget::~MyWidget()
00089 {
00090
delete mNewStuff;
00091 }
00092
00093
void MyWidget::download()
00094 {
00095 kdDebug(5850) <<
"MyWidget::download()" << endl;
00096
00097 mNewStuff->download();
00098 }
00099
00100
void MyWidget::upload()
00101 {
00102 kdDebug(5850) <<
"MyWidget::download()" << endl;
00103
00104 mNewStuff->upload();
00105 }
00106
00107
00108
int main(
int argc,
char **argv)
00109 {
00110 KAboutData aboutData(
"knewstufftest",
"KNewStuff Test",
"0.1");
00111 KCmdLineArgs::init(argc,argv,&aboutData);
00112
00113 KApplication app;
00114
00115 MyWidget wid;
00116 app.setMainWidget( &wid );
00117 wid.show();
00118
00119 app.exec();
00120 }