kdeui Library API Documentation

kedittoolbar.h

00001 // -*- mode: c++; c-basic-offset: 2 -*-
00002 /* This file is part of the KDE libraries
00003    Copyright (C) 2000 Kurt Granroth <granroth@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 version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 #ifndef _KEDITTOOLBAR_H
00020 #define _KEDITTOOLBAR_H
00021 
00022 #include <qwidget.h>
00023 #include <kxmlguiclient.h>
00024 #include <kdialogbase.h>
00025 
00026 class KProcess;
00027 class KActionCollection;
00028 class QComboBox;
00029 class QToolButton;
00030 class KListView;
00031 class QListViewItem;
00032 
00033 class KEditToolbarWidget;
00034 class KEditToolbarPrivate;
00035 class KEditToolbarWidgetPrivate;
00036 namespace
00037 {
00038   class ToolbarItem;
00039   class ToolbarListView;
00040 }
00111 class KEditToolbar : public KDialogBase
00112 {
00113     Q_OBJECT
00114 public:
00145   KEditToolbar(KActionCollection *collection,
00146                const QString& xmlfile = QString::null, bool global = true,
00147                QWidget* parent = 0, const char* name = 0);
00148 
00149   //KDE 4.0: merge the two constructors
00150   /* Constructor for apps that do not use components, which has an extra argument
00151    * specifying the toolbar to be shown.
00152    * @param defaultToolbar The toolbar with this name will appear for editing.
00153    * @param collection The collection of actions to work on.
00154    * @param xmlfile The application's local resource file.
00155    * @param global If @p true, then the global resource file will also
00156    *               be parsed.
00157    * @param parent The parent of the dialog.
00158    * @param name An internal name.
00159    * @since 3.2
00160    */
00161   KEditToolbar(const QString& defaultToolbar, KActionCollection *collection,
00162                const QString& xmlfile = QString::null, bool global = true,
00163                QWidget* parent = 0, const char* name = 0);
00187   KEditToolbar(KXMLGUIFactory* factory, QWidget* parent = 0, const char* name = 0);
00188 
00189   //KDE 4.0: merge the two constructors
00199   KEditToolbar(const QString& defaultToolbar, KXMLGUIFactory* factory,
00200                QWidget* parent = 0, const char* name = 0);
00201 
00203   ~KEditToolbar();
00204 
00210   static void setDefaultToolbar(const char *toolbarName);
00211 
00212 protected slots:
00216   virtual void slotOk();
00220   virtual void slotApply();
00221 
00225   void acceptOK(bool b);
00226 
00227 signals:
00233   void newToolbarConfig();
00234 
00235 private:
00236   void init();
00237   KEditToolbarWidget *m_widget;
00238 protected:
00239   virtual void virtual_hook( int id, void* data );
00240 private:
00241   KEditToolbarPrivate *d;
00242 
00243   static const char *s_defaultToolbar;
00244 };
00245 
00246 
00267 class KEditToolbarWidget : public QWidget, virtual public KXMLGUIClient
00268 {
00269   Q_OBJECT
00270 public:
00300   KEditToolbarWidget(KActionCollection *collection,
00301                      const QString& xmlfile = QString::null,
00302                      bool global = true, QWidget *parent = 0L);
00303 
00304    //KDE 4.0: merge the two constructors
00305    /* Same as above, with an extra agrument specifying the toolbar to be shown.
00306    *
00307    * @param defaultToolbar The toolbar with this name will appear for editing.
00308    * @param collection The collection of actions to work on
00309    * @param xmlfile The application's local resource file
00310    * @param global If true, then the global resource file will also
00311    *               be parsed
00312    * @param parent This widget's parent
00313    * @since 3.2
00314    */
00315   KEditToolbarWidget(const QString& defaultToolbar,
00316                      KActionCollection *collection,
00317                      const QString& file = QString::null,
00318                      bool global = true,
00319                      QWidget *parent = 0L);
00320 
00341   KEditToolbarWidget(KXMLGUIFactory* factory, QWidget *parent = 0L);
00342 
00343    //KDE 4.0: merge the two constructors
00344    /* Same as above, with an extra agrument specifying the toolbar to be shown.
00345    *
00346    *
00347    * @param defaultToolbar The toolbar with this name will appear for editing.
00348    * @param factory Your application's factory object
00349    * @param parent This widget's parent
00350    * @since 3.2
00351    */
00352   KEditToolbarWidget(const QString& defaultToolbar,
00353                      KXMLGUIFactory* factory,
00354                      QWidget *parent = 0L);
00355 
00361   virtual ~KEditToolbarWidget();
00362 
00366   virtual KActionCollection *actionCollection() const;
00367 
00376   bool save();
00377 
00378 signals:
00382   void enableOk(bool);
00383 
00384 protected slots:
00385   void slotToolbarSelected(const QString& text);
00386 
00387   void slotInactiveSelected(QListViewItem *item);
00388   void slotActiveSelected(QListViewItem *item);
00389 
00390   void slotDropped(KListView *list, QDropEvent *e, QListViewItem *after);
00391 
00392   void slotInsertButton();
00393   void slotRemoveButton();
00394   void slotUpButton();
00395   void slotDownButton();
00396 
00397   void slotChangeIcon();
00398 
00399 private slots:
00400   void slotProcessExited( KProcess* );
00401 
00402 protected:
00403   void setupLayout();
00404 
00405   void insertActive(ToolbarItem *item, QListViewItem *before, bool prepend = false);
00406   void removeActive(ToolbarItem *item);
00407   void initNonKPart(KActionCollection *collection, const QString& file, bool global);
00408   void initKPart(KXMLGUIFactory* factory);
00409   void loadToolbarCombo(const QString& defaultToolbar = QString::null);
00410   void loadActionList(QDomElement& elem);
00411   void updateLocal(QDomElement& elem);
00412 
00413 private:
00414   ToolbarListView *m_inactiveList;
00415   ToolbarListView *m_activeList;
00416   QComboBox *m_toolbarCombo;
00417 
00418   QToolButton *m_upAction;
00419   QToolButton *m_removeAction;
00420   QToolButton *m_insertAction;
00421   QToolButton *m_downAction;
00422 
00423 protected:
00424   virtual void virtual_hook( int id, void* data );
00425 private:
00426   KEditToolbarWidgetPrivate *d;
00427 };
00428 
00429 #endif // _KEDITTOOLBAR_H
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Feb 18 15:10:18 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003