kdeui Library API Documentation

kedittoolbar.h

00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2000 Kurt Granroth <granroth@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
00017 */
00018 #ifndef _KEDITTOOLBAR_H
00019 #define _KEDITTOOLBAR_H
00020 
00021 #include <qwidget.h>
00022 #include <kxmlguiclient.h>
00023 #include <kdialogbase.h>
00024 
00025 class KActionCollection;
00026 class QComboBox;
00027 class QToolButton;
00028 class KListView;
00029 class QListViewItem;
00030 
00031 class KEditToolbarWidget;
00032 class KEditToolbarPrivate;
00033 class KEditToolbarWidgetPrivate;
00034 
00105 class KEditToolbar : public KDialogBase
00106 {
00107     Q_OBJECT
00108 public:
00139   KEditToolbar(KActionCollection *collection,
00140                const QString& xmlfile = QString::null, bool global = true,
00141                QWidget* parent = 0, const char* name = 0);
00142 
00143   //KDE 4.0: merge the two constructors
00144   /* Constructor for apps that do not use components, which has an extra argument
00145    * specifying the toolbar to be shown.
00146    * @param defaultToolbar The toolbar with this name will appear for editing.
00147    * @param collection The collection of actions to work on.
00148    * @param xmlfile The application's local resource file.
00149    * @param global If @p true, then the global resource file will also
00150    *               be parsed.
00151    * @param parent The parent of the dialog.
00152    * @param name An internal name.
00153    * @since 3.2
00154    */
00155   KEditToolbar(const QString& defaultToolbar, KActionCollection *collection,
00156                const QString& xmlfile = QString::null, bool global = true,
00157                QWidget* parent = 0, const char* name = 0);
00181   KEditToolbar(KXMLGUIFactory* factory, QWidget* parent = 0, const char* name = 0);
00182 
00183   //KDE 4.0: merge the two constructors
00184   /* Constructor for KParts based apps, which has an extra argument
00185    * specifying the toolbar to be shown.
00186    *
00187    * @param defaultToolbar The toolbar with this name will appear for editing.
00188    * @param factory Your application's factory object
00189    * @param parent The usual parent for the dialog.
00190    * @param name An internal name.
00191    * @since 3.2
00192    */
00193   KEditToolbar(const QString& defaultToolbar, KXMLGUIFactory* factory,
00194                QWidget* parent = 0, const char* name = 0);
00195 
00197   ~KEditToolbar();
00198 
00199 protected slots:
00203   virtual void slotOk();
00207   virtual void slotApply();
00208 
00212   void acceptOK(bool b);
00213 
00214 signals:
00220   void newToolbarConfig();
00221 
00222 private:
00223   void init();
00224   KEditToolbarWidget *m_widget;
00225 protected:
00226   virtual void virtual_hook( int id, void* data );
00227 private:
00228   KEditToolbarPrivate *d;
00229 };
00230 
00251 class KEditToolbarWidget : public QWidget, virtual public KXMLGUIClient
00252 {
00253   Q_OBJECT
00254 public:
00284   KEditToolbarWidget(KActionCollection *collection,
00285                      const QString& xmlfile = QString::null,
00286                      bool global = true, QWidget *parent = 0L);
00287 
00288    //KDE 4.0: merge the two constructors
00289    /* Same as above, with an extra agrument specifying the toolbar to be shown.
00290    *
00291    * @param defaultToolbar The toolbar with this name will appear for editing.
00292    * @param collection The collection of actions to work on
00293    * @param xmlfile The application's local resource file
00294    * @param global If true, then the global resource file will also
00295    *               be parsed
00296    * @param parent This widget's parent
00297    * @since 3.2
00298    */
00299   KEditToolbarWidget(const QString& defaultToolbar,
00300                      KActionCollection *collection,
00301                      const QString& file = QString::null,
00302                      bool global = true,
00303                      QWidget *parent = 0L);
00304 
00325   KEditToolbarWidget(KXMLGUIFactory* factory, QWidget *parent = 0L);
00326 
00327    //KDE 4.0: merge the two constructors
00328    /* Same as above, with an extra agrument specifying the toolbar to be shown.
00329    *
00330    *
00331    * @param defaultToolbar The toolbar with this name will appear for editing.
00332    * @param factory Your application's factory object
00333    * @param parent This widget's parent
00334    * @since 3.2
00335    */
00336   KEditToolbarWidget(const QString& defaultToolbar,
00337                      KXMLGUIFactory* factory,
00338                      QWidget *parent = 0L);
00339 
00345   virtual ~KEditToolbarWidget();
00346 
00350   virtual KActionCollection *actionCollection() const;
00351 
00360   bool save();
00361 
00362 signals:
00366   void enableOk(bool);
00367 
00368 protected slots:
00369   void slotToolbarSelected(const QString& text);
00370 
00371   void slotInactiveSelected(QListViewItem *item);
00372   void slotActiveSelected(QListViewItem *item);
00373 
00374   void slotInsertButton();
00375   void slotRemoveButton();
00376   void slotUpButton();
00377   void slotDownButton();
00378 
00379 protected:
00380   void setupLayout();
00381 
00382   void initNonKPart(KActionCollection *collection, const QString& file, bool global);
00383   void initKPart(KXMLGUIFactory* factory);
00384   void loadToolbarCombo(const QString& defaultToolbar = QString::null);
00385   void loadActionList(QDomElement& elem);
00386   void updateLocal(QDomElement& elem);
00387 
00388 private:
00389   KListView *m_inactiveList;
00390   KListView *m_activeList;
00391   QComboBox *m_toolbarCombo;
00392 
00393   QToolButton *m_upAction;
00394   QToolButton *m_removeAction;
00395   QToolButton *m_insertAction;
00396   QToolButton *m_downAction;
00397 
00398 protected:
00399   virtual void virtual_hook( int id, void* data );
00400 private:
00401   KEditToolbarWidgetPrivate *d;
00402 };
00403 
00404 #endif // _KEDITTOOLBAR_H
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Sep 30 05:16:49 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003