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

KNewStuff

providerdialog.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of KNewStuff.
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 "providerdialog.h"
00022 
00023 #include <QLabel>
00024 #include <QLayout>
00025 #include <QTreeWidget>
00026 
00027 
00028 #include <klocale.h>
00029 #include <kmessagebox.h>
00030 
00031 //#include "engine.h"
00032 #include "knewstuff2/core/provider.h"
00033 
00034 using namespace KNS;
00035 
00036 class ProviderItem : public QTreeWidgetItem
00037 {
00038 public:
00039     ProviderItem(QTreeWidget *parent, Provider *provider) :
00040             QTreeWidgetItem(parent), mProvider(provider) {
00041         setText(0, provider->name().representation());
00042     }
00043 
00044     Provider *provider() {
00045         return mProvider;
00046     }
00047 
00048 private:
00049     Provider *mProvider;
00050 };
00051 
00052 ProviderDialog::ProviderDialog(/*Engine *engine,*/ QWidget *parent) :
00053         KDialog(parent)
00054 //  mEngine( engine )
00055 {
00056     setCaption(i18n("Hot New Stuff Providers"));
00057     setButtons(Ok | Cancel);
00058     setDefaultButton(Cancel);
00059     setModal(false);
00060     showButtonSeparator(true);
00061 
00062     QFrame *topPage = new QFrame(this);
00063     setMainWidget(topPage);
00064 
00065     QBoxLayout *topLayout = new QVBoxLayout(topPage);
00066 
00067     QLabel *description = new QLabel(i18n("Please select one of the providers listed below:"), topPage);
00068     topLayout->addWidget(description);
00069 
00070     mListWidget = new QTreeWidget(topPage);
00071     mListWidget->setHeaderLabels(QStringList(i18n("Name")));
00072     topLayout->addWidget(mListWidget);
00073     connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
00074 }
00075 
00076 void ProviderDialog::clear()
00077 {
00078     mListWidget->clear();
00079 }
00080 
00081 void ProviderDialog::addProvider(Provider *provider)
00082 {
00083     new ProviderItem(mListWidget, provider);
00084     if (mListWidget->model()->rowCount() == 1) {
00085         QModelIndex index = mListWidget->model()->index(0, 0);
00086         mListWidget->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select);
00087     } else if (mListWidget->model()->rowCount() > 1) {
00088         QModelIndex index = mListWidget->model()->index(0, 0);
00089         mListWidget->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Deselect);
00090     }
00091 }
00092 
00093 void ProviderDialog::slotOk()
00094 {
00095     QList<QTreeWidgetItem*> items = mListWidget->selectedItems();
00096     ProviderItem *item = static_cast<ProviderItem *>(items.first());
00097     if (!item) {
00098         KMessageBox::error(this, i18n("No provider selected."));
00099         return;
00100     }
00101 
00102 //  mEngine->requestMetaInformation( item->provider() );
00103 //  FIXME: return properly
00104     m_provider = item->provider();
00105 
00106     accept();
00107 }
00108 
00109 KNS::Provider *ProviderDialog::provider() const
00110 {
00111     return m_provider;
00112 }
00113 
00114 #include "providerdialog.moc"

KNewStuff

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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