• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KNewStuff

testnewstuff.cpp

Go to the documentation of this file.
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 <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() << "TestNewStuff::install(): " << fileName << endl;
00043   QFile f( fileName );
00044   if ( !f.open( IO_ReadOnly ) ) {
00045     kdDebug() << "Error opening file." << endl;
00046     return false;
00047   }
00048   QTextStream 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 QString &fileName )
00056 {
00057   KProcess p;
00058   p << "touch" << fileName;
00059   p.start(KProcess::Block);
00060   kdDebug() << "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() << "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   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 }

KNewStuff

Skip menu "KNewStuff"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal