• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • 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 
00059     QFrame *topPage = new QFrame(this);
00060     setMainWidget(topPage);
00061 
00062     QBoxLayout *topLayout = new QVBoxLayout(topPage);
00063 
00064     QLabel *description = new QLabel(i18n("Please select one of the providers listed below:"), topPage);
00065     topLayout->addWidget(description);
00066 
00067     mListWidget = new QTreeWidget(topPage);
00068     mListWidget->setHeaderLabels(QStringList(i18n("Name")));
00069     topLayout->addWidget(mListWidget);
00070     connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
00071 }
00072 
00073 void ProviderDialog::clear()
00074 {
00075     mListWidget->clear();
00076 }
00077 
00078 void ProviderDialog::addProvider(Provider *provider)
00079 {
00080     new ProviderItem(mListWidget, provider);
00081     if (mListWidget->model()->rowCount() == 1) {
00082         QModelIndex index = mListWidget->model()->index(0, 0);
00083         mListWidget->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select);
00084     } else if (mListWidget->model()->rowCount() > 1) {
00085         QModelIndex index = mListWidget->model()->index(0, 0);
00086         mListWidget->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Deselect);
00087     }
00088 }
00089 
00090 void ProviderDialog::slotOk()
00091 {
00092     QList<QTreeWidgetItem*> items = mListWidget->selectedItems();
00093     ProviderItem *item = static_cast<ProviderItem *>(items.first());
00094     if (!item) {
00095         KMessageBox::error(this, i18n("No provider selected."));
00096         return;
00097     }
00098 
00099 //  mEngine->requestMetaInformation( item->provider() );
00100 //  FIXME: return properly
00101     m_provider = item->provider();
00102 
00103     accept();
00104 }
00105 
00106 KNS::Provider *ProviderDialog::provider() const
00107 {
00108     return m_provider;
00109 }
00110 
00111 #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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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