• Skip to content
  • Skip to link menu
KDE 4.3 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 KNewStuff2.
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 Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2.1 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     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 #include "providerdialog.h"
00020 
00021 #include <QLabel>
00022 #include <QLayout>
00023 #include <QTreeWidget>
00024 
00025 
00026 #include <klocale.h>
00027 #include <kmessagebox.h>
00028 
00029 //#include "engine.h"
00030 #include "knewstuff2/core/provider.h"
00031 
00032 using namespace KNS;
00033 
00034 class ProviderItem : public QTreeWidgetItem
00035 {
00036 public:
00037     ProviderItem(QTreeWidget *parent, Provider *provider) :
00038             QTreeWidgetItem(parent), mProvider(provider) {
00039         setText(0, provider->name().representation());
00040     }
00041 
00042     Provider *provider() {
00043         return mProvider;
00044     }
00045 
00046 private:
00047     Provider *mProvider;
00048 };
00049 
00050 ProviderDialog::ProviderDialog(/*Engine *engine,*/ QWidget *parent) :
00051         KDialog(parent)
00052 //  mEngine( engine )
00053 {
00054     setCaption(i18n("Hot New Stuff Providers"));
00055     setButtons(Ok | Cancel);
00056     setDefaultButton(Cancel);
00057     setModal(false);
00058     showButtonSeparator(true);
00059 
00060     QFrame *topPage = new QFrame(this);
00061     setMainWidget(topPage);
00062 
00063     QBoxLayout *topLayout = new QVBoxLayout(topPage);
00064 
00065     QLabel *description = new QLabel(i18n("Please select one of the providers listed below:"), topPage);
00066     topLayout->addWidget(description);
00067 
00068     mListWidget = new QTreeWidget(topPage);
00069     mListWidget->setHeaderLabels(QStringList(i18n("Name")));
00070     topLayout->addWidget(mListWidget);
00071     connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
00072 }
00073 
00074 void ProviderDialog::clear()
00075 {
00076     mListWidget->clear();
00077 }
00078 
00079 void ProviderDialog::addProvider(Provider *provider)
00080 {
00081     new ProviderItem(mListWidget, provider);
00082     if (mListWidget->model()->rowCount() == 1) {
00083         QModelIndex index = mListWidget->model()->index(0, 0);
00084         mListWidget->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select);
00085     } else if (mListWidget->model()->rowCount() > 1) {
00086         QModelIndex index = mListWidget->model()->index(0, 0);
00087         mListWidget->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Deselect);
00088     }
00089 }
00090 
00091 void ProviderDialog::slotOk()
00092 {
00093     QList<QTreeWidgetItem*> items = mListWidget->selectedItems();
00094     ProviderItem *item = static_cast<ProviderItem *>(items.first());
00095     if (!item) {
00096         KMessageBox::error(this, i18n("No provider selected."));
00097         return;
00098     }
00099 
00100 //  mEngine->requestMetaInformation( item->provider() );
00101 //  FIXME: return properly
00102     m_provider = item->provider();
00103 
00104     accept();
00105 }
00106 
00107 KNS::Provider *ProviderDialog::provider() const
00108 {
00109     return m_provider;
00110 }
00111 
00112 #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
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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