# knewstuff Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# providerdialog.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., 59 Temple Place - Suite 330,
    00018     Boston, MA 02111-1307, 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 }

This file is part of the documentation for knewstuff Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:28:34 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003