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

KNewStuff

providerdialog.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 <qlayout.h>
00022 #include <qstring.h>
00023 #include <qlabel.h>
00024 
00025 #include <klistview.h>
00026 #include <klocale.h>
00027 #include <kmessagebox.h>
00028 
00029 #include "engine.h"
00030 #include "provider.h"
00031 
00032 #include "providerdialog.h"
00033 #include "providerdialog.moc"
00034 
00035 using namespace KNS;
00036 
00037 class ProviderItem : public KListViewItem
00038 {
00039   public:
00040     ProviderItem( KListView *parent, Provider *provider ) :
00041       KListViewItem( parent ), mProvider( provider )
00042     {
00043       setText( 0, provider->name() );
00044     }
00045 
00046     Provider *provider() { return mProvider; }
00047 
00048   private:
00049     Provider *mProvider;
00050 };
00051 
00052 ProviderDialog::ProviderDialog( Engine *engine, QWidget *parent ) :
00053   KDialogBase( Plain, i18n("Hot New Stuff Providers"), Ok | Cancel, Cancel,
00054                parent, 0, false, true ),
00055   mEngine( engine )
00056 {
00057   QFrame *topPage = plainPage();
00058 
00059   QBoxLayout *topLayout = new QVBoxLayout( topPage );
00060 
00061   QLabel *description = new QLabel( i18n("Please select one of the providers listed below:"), topPage );
00062   topLayout->addWidget( description );
00063 
00064   mListView = new KListView( topPage );
00065   mListView->addColumn( i18n("Name") );
00066   topLayout->addWidget( mListView );
00067 }
00068 
00069 void ProviderDialog::clear()
00070 {
00071   mListView->clear();
00072 }
00073 
00074 void ProviderDialog::addProvider( Provider *provider )
00075 {
00076   new ProviderItem( mListView, provider );
00077   if ( mListView->childCount() == 1 ) {
00078     mListView->setSelected(mListView->firstChild(), true);
00079   } else if (mListView->childCount() > 1) {
00080     mListView->setSelected(mListView->firstChild(), false);
00081   }
00082 }
00083 
00084 void ProviderDialog::slotOk()
00085 {
00086   ProviderItem *item = static_cast<ProviderItem *>( mListView->selectedItem() );
00087   if ( !item ) {
00088     KMessageBox::error( this, i18n("No provider selected.") );
00089     return;
00090   }
00091 
00092   mEngine->requestMetaInformation( item->provider() );
00093 
00094   accept();
00095 }

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