korganizer Library API Documentation

testnewstuff.cpp

00001 #include <iostream>
00002 
00003 #include <qlayout.h>
00004 #include <qfile.h>
00005 #include <qtextstream.h>
00006 
00007 #include <kaboutdata.h>
00008 #include <kapplication.h>
00009 #include <kdebug.h>
00010 #include <klocale.h>
00011 #include <kcmdlineargs.h>
00012 #include <kdialog.h>
00013 
00014 #include "testnewstuff.h"
00015 #include "testnewstuff.moc"
00016 
00017 using namespace std;
00018 
00019 bool TestNewStuff::install( const QString &fileName )
00020 {
00021   kdDebug() << "TestNewStuff::install(): " << fileName << endl;
00022   QFile f( fileName );
00023   if ( !f.open( IO_ReadOnly ) ) {
00024     kdDebug() << "Error opening file." << endl;
00025     return false;
00026   }
00027   QTextStream ts( &f );
00028   kdDebug() << "--BEGIN-NEW_STUFF--" << endl;
00029   cout << ts.read().utf8();
00030   kdDebug() << "---END-NEW_STUFF---" << endl;
00031   return true;
00032 }
00033 
00034 bool TestNewStuff::createUploadFile( const QString &fileName )
00035 {
00036   QString cmd = "touch " + fileName;
00037   system( cmd.latin1() );
00038   kdDebug() << "TestNewStuff::createUploadFile(): " << fileName << endl;
00039   return fileName;
00040 }
00041 
00042 
00043 MyWidget::MyWidget()
00044 {
00045   mNewStuff = new TestNewStuff;
00046 
00047   QBoxLayout *topLayout = new QVBoxLayout( this );
00048   topLayout->setMargin( KDialog::marginHint() );
00049   topLayout->setSpacing( KDialog::spacingHint() );
00050   
00051   QPushButton *downloadButton = new QPushButton( "Download", this );
00052   topLayout->addWidget( downloadButton );
00053   connect( downloadButton, SIGNAL( clicked() ), SLOT( download() ) );
00054 
00055   QPushButton *uploadButton = new QPushButton( "Upload", this );
00056   topLayout->addWidget( uploadButton );
00057   connect( uploadButton, SIGNAL( clicked() ), SLOT( upload() ) );
00058 
00059   topLayout->addSpacing( 5 );
00060 
00061   QPushButton *closeButton = new QPushButton( "Close", this );
00062   topLayout->addWidget( closeButton );
00063   connect( closeButton, SIGNAL( clicked() ), kapp, SLOT( quit() ) );
00064 }
00065 
00066 MyWidget::~MyWidget()
00067 {
00068   delete mNewStuff;
00069 }
00070 
00071 void MyWidget::download()
00072 {
00073   kdDebug() << "MyWidget::download()" << endl;
00074 
00075   mNewStuff->download();
00076 }
00077 
00078 void MyWidget::upload()
00079 {
00080   kdDebug() << "MyWidget::download()" << endl;
00081 
00082   mNewStuff->upload();
00083 }
00084 
00085 
00086 int main(int argc,char **argv)
00087 {
00088   KAboutData aboutData("knewstufftest","KNewStuff Test","0.1");
00089   KCmdLineArgs::init(argc,argv,&aboutData);
00090 
00091   KApplication app;
00092 
00093   MyWidget wid;
00094   app.setMainWidget( &wid );
00095   wid.show();
00096 
00097   app.exec();
00098 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:41:10 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001