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 / KoSelectAction.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-30  |  3.3 KB  |  91 lines

  1. /* This file is part of the KDE project
  2.    Copyright (C) 2004 Peter Simonsson <psn@linux.se>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License as published by the Free Software Foundation; either
  7.    version 2 of the License, or (at your option) any later version.
  8.  
  9.    This library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public License
  15.    along with this library; see the file COPYING.LIB.  If not, write to
  16.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.  * Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef KOSELECTACTION_H
  20. #define KOSELECTACTION_H
  21.  
  22. #include <kaction.h>
  23. #include <koffice_export.h>
  24. class KPopupMenu;
  25. class QPoint;
  26.  
  27. /** An action that provides a menu with items that can be selected.
  28.  * The main difference between this action and a KSelectAction is that
  29.  * it is plugged into a toolbar as a dropdown menu and not as a combobox.
  30.  */
  31. class KOFFICEUI_EXPORT KoSelectAction : public KAction
  32. {
  33.   Q_OBJECT
  34.   public:
  35.     /** Constructs a KoSelectAction with a text and an icon.
  36.      * @param text The text that will be displayed.
  37.      * @param icon The dynamically loaded icon that goes with this action.
  38.      * @param parent This action's parent.
  39.      * @param name An internal name for this action.
  40.      */
  41.     KoSelectAction(const QString& text, const QString& icon, QObject* parent = 0, const char* name = 0);
  42.     /** Same as above, but it also connects a slot to the selectionChanged(int) signal.
  43.      * @param text The text that will be displayed.
  44.      * @param icon The dynamically loaded icon that goes with this action.
  45.      * @param receiver The SLOT's parent.
  46.      * @param slot The SLOT to invoke when a selectionChanged(int) signal is emited.
  47.      * @param parent This action's parent.
  48.      * @param name An internal name for this action.
  49.      */
  50.     KoSelectAction(const QString& text, const QString& icon, const QObject* receiver,
  51.       const char* slot, QObject* parent, const char* name = 0);
  52.     ~KoSelectAction();
  53.  
  54.     /** Returns a pointer to the popup menu. */
  55.     KPopupMenu* popupMenu() const;
  56.     /** Shows the popup menu.
  57.      * @param global Position at which the popup menu is shown.
  58.      */
  59.     void popup(const QPoint& global);
  60.   
  61.     virtual int plug(QWidget* widget, int index = -1);
  62.     
  63.     /** Returns the index of the currently selected item. */
  64.     virtual int currentSelection();
  65.  
  66.     /** If the current selection selection should be shown or not in the menu */
  67.     void setShowCurrentSelection(bool show);
  68.  
  69.   signals:
  70.     /** Emited when the selection changed */
  71.     void selectionChanged(int);
  72.  
  73.   public slots:
  74.     /** Set which item that should be selected.
  75.      * @param index Index of item that should be selected
  76.      */
  77.     virtual void setCurrentSelection(int index);
  78.   
  79.   protected slots:
  80.     /** Execute an item. By default it sets the item as selected and emits the selectionChanged signal.
  81.      * @param index Index of the item that should be executed.
  82.      */
  83.     virtual void execute(int index);
  84.         
  85.   private:
  86.     class KoSelectActionPrivate;
  87.     KoSelectActionPrivate* d;
  88. };
  89.  
  90. #endif
  91.