home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / knewstuff / downloaddialog.h next >
Encoding:
C/C++ Source or Header  |  2006-10-01  |  6.9 KB  |  258 lines

  1. /*
  2.     This file is part of KNewStuff.
  3.     Copyright (c) 2003 Josef Spillner <spillner@kde.org>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef KNEWSTUFF_DOWNLOADDIALOG_H
  21. #define KNEWSTUFF_DOWNLOADDIALOG_H
  22.  
  23. #include <kdialogbase.h>
  24. #include <knewstuff/provider.h>
  25.  
  26. namespace KIO
  27. {
  28.   class Job;
  29. }
  30.  
  31. class KListView;
  32. class QTextBrowser;
  33. class QFrame;
  34. class KNewStuffGeneric;
  35.  
  36. namespace KNS
  37. {
  38.  
  39. class ProviderLoader;
  40. class Entry;
  41. class Provider;
  42. class Engine;
  43.  
  44. /**
  45.  * @short Common download dialog for data browsing and installation.
  46.  *
  47.  * It provides an easy-to-use convenience method named open() which does all
  48.  * the work, unless a more complex operation is needed.
  49.  * \code
  50.  * KNewStuff::DownloadDialog::open("kdesktop/wallpapers");
  51.  * \endcode
  52.  *
  53.  * @author Josef Spillner (spillner@kde.org)
  54.  * \par Maintainer:
  55.  * Josef Spillner (spillner@kde.org)
  56.  */
  57. class KDE_EXPORT DownloadDialog : public KDialogBase
  58. {
  59.     Q_OBJECT
  60.     struct Private;
  61.   public:
  62.     /**
  63.       Constructor.
  64.  
  65.       @param engine a pre-built engine object, or NULL if the download
  66.                     dialog should create an engine on its own
  67.       @param parent the parent window
  68.       @param caption the dialog caption
  69.     */
  70.     DownloadDialog(Engine *engine, QWidget *parent, const QString& caption);
  71.  
  72.     /**
  73.       Alternative constructor.
  74.       Always uses an internal engine.
  75.  
  76.       @param parent the parent window
  77.       @param caption the dialog caption
  78.     */
  79.     DownloadDialog(QWidget *parent, const QString& caption);
  80.  
  81.     /**
  82.       Destructor.
  83.     */
  84.     ~DownloadDialog();
  85.  
  86.     /**
  87.       Restricts the display of available data to a certain data type.
  88.  
  89.       @param type a Hotstuff data type such as "korganizer/calendar"
  90.     */
  91.     void setType(QString type);
  92.     // ### KDE 4.0: use const QString&
  93.  
  94.     /**
  95.       Fetches descriptions of all available data, optionally considering
  96.       a previously set type.
  97.     */
  98.     void load();
  99.  
  100.     /**
  101.       Explicitly uses this provider list instead of the one read from
  102.       the application configuration.
  103.  
  104.       @param providerList the URL of the provider list
  105.  
  106.       @since 3.4
  107.     */
  108.     void setProviderList(const QString& providerList);
  109.  
  110.     /**
  111.       Fetches descriptions of all available data, optionally considering
  112.       a previously set type.
  113.  
  114.       @param providerList the URl to the list of providers; if empty
  115.              we first try the ProvidersUrl from KGlobal::config, then we
  116.              fall back to a hardcoded value.
  117.     */
  118.     void load(QString providerList); // KDE4: merge with load() above
  119.  
  120.     /**
  121.       Adds another provider to the download dialog.
  122.       This is normally done internally.
  123.  
  124.       @param p the Hotstuff provider to be added
  125.     */
  126.     void addProvider(Provider *p);
  127.  
  128.     /**
  129.       Adds an additional entry to the current provider.
  130.       This is normally done internally.
  131.  
  132.       @param entry a Hotstuff data entry to be added
  133.     */
  134.     void addEntry(Entry *entry);
  135.  
  136.     /**
  137.       Adds an additional entry to the current provider.
  138.       This is normally done internal.
  139.       This version takes into accounts the download variant.
  140.  
  141.       @param entry a Hotstuff data entry to be added
  142.       @param variants all variants this entry is intended for
  143.     */
  144.     void addEntry(Entry *entry, const QStringList& variants);
  145.  
  146.     /**
  147.       Clears the entry list of the current provider.
  148.       This is normally done internally.
  149.     */
  150.     void clear();
  151.  
  152.     /**
  153.       Constructor.
  154.  
  155.       @param engine a pre-built engine object, or NULL if the download
  156.                     dialog should create an engine on its own
  157.       @param parent the parent window
  158.     */
  159.     DownloadDialog(Engine *engine, QWidget *parent = 0);
  160.     // ### KDE 4.0: remove and make caption/parent argument optional
  161.  
  162.     /**
  163.       Alternative constructor.
  164.       Always uses an internal engine.
  165.  
  166.       @param parent the parent window
  167.     */
  168.     DownloadDialog(QWidget *parent = 0);
  169.     // ### KDE 4.0: remove and make caption/parent argument optional
  170.  
  171.     /**
  172.       Opens the download dialog.
  173.       This is a convenience method which automatically sets up the dialog.
  174.       @see setType()
  175.       @see load()
  176.  
  177.       @param type a data type such as "korganizer/calendar"
  178.       @param caption the dialog caption
  179.     */
  180.     static void open(const QString& type, const QString& caption);
  181.  
  182.     /**
  183.       Opens the download dialog.
  184.       This is a convenience method which automatically sets up the dialog.
  185.       @see setType()
  186.       @see load()
  187.  
  188.       @param type a data type such as "korganizer/calendar"
  189.       @deprecated use open( const QString& type, const QString& caption );
  190.     */
  191.     static void open(QString type) KDE_DEPRECATED; // ### KDE 4.0: remove and make caption/parent argument optional
  192.  
  193.     /**
  194.       Returns the list of installed data entries.
  195.  
  196.       @return list of data entries which have been installed
  197.     */
  198.     QPtrList<Entry> installedEntries();
  199.     // ### KDE 4.0: the open() method should return this
  200.  
  201.   public slots:
  202.     /**
  203.       Availability of the provider list.
  204.  
  205.       @param list list of Hotstuff providers
  206.     */
  207.     void slotProviders(Provider::List *list);
  208.  
  209.   protected slots:
  210.     void slotApply();
  211.     void slotOk();
  212.  
  213.   private slots:
  214.     void slotResult(KIO::Job *job);
  215.     void slotData(KIO::Job *job, const QByteArray &a);
  216.     void slotInstall();
  217.     void slotDetails();
  218.     void slotInstalled(KIO::Job *job);
  219.     void slotTab();
  220.     void slotSelected();
  221.     void slotPage(QWidget *w);
  222.     void slotFinish();
  223.     void slotEmail(const QString& link);
  224.  
  225.   private:
  226.     void init(Engine *e);
  227.     Entry *getEntry();
  228.     void loadProvider(Provider *p);
  229.     void install(Entry *e);
  230.     int installStatus(Entry *e);
  231.     QListViewItem *currentEntryItem();
  232.  
  233.     ProviderLoader *m_loader;
  234.     QString m_entryname;
  235.     KListView *lv_r, *lv_d, *lv_l;
  236.     QTextBrowser *m_rt;
  237.     QFrame *m_frame;
  238.     QListViewItem *m_entryitem;
  239.     QPtrList<Entry> m_entries;
  240.     Entry *m_entry;
  241.     KNewStuffGeneric *m_s;
  242.     int m_curtab;
  243.     QMap<QWidget*, QValueList<KListView*>* > m_map;
  244.     QMap<QWidget*, Provider*> m_providers;
  245.     QMap<QWidget*, QTextBrowser*> m_rts;
  246.     QMap<QWidget*, QValueList<QPushButton*>* > m_buttons;
  247.     QMap<KIO::Job*, Provider*> m_jobs;
  248.     QMap<KIO::Job*, QString> m_data;
  249.     QString m_filter;
  250.     Engine *m_engine;
  251.     Private *d;
  252. };
  253.  
  254. }
  255.  
  256. #endif
  257.  
  258.