kdecore Library: kaccelmanager_private.h Source File (kdecore Library)

| # kdecore Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kaccelmanager_private.h

    00001 /*  This file is part of the KDE project
    00002     Copyright (C) 2002 Matthias H�zer-Klpfel <mhk@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 as published by the Free Software Foundation; either
    00007     version 2 of the License, or (at your option) any later version.
    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
    00020
    00021 #ifndef __KACCELMANAGER_PRIVATE_H__
    00022 #define __KACCELMANAGER_PRIVATE_H__
    00023
    00024
    00025 #include <qstring.h>
    00026 #include <qmemarray.h>
    00027 #include <qvaluelist.h>
    00028 #include <qobject.h>
    00029
    00030 class QWidgetStack;
    00031
    00042 class KAccelString
    00043 {
    00044 public:
    00045
    00046   KAccelString() : m_pureText(), m_accel(-1) {};
    00047   KAccelString(const QString &input, int initalWeight=-1);
    00048
    00049   void calculateWeights(int initialWeight);
    00050
    00051   const QString &pure() const { return m_pureText; };
    00052   QString accelerated() const;
    00053
    00054   int accel() const { return m_accel; };
    00055   void setAccel(int accel) { m_accel = accel; };
    00056
    00057   int originalAccel() const { return m_orig_accel; }
    00058   QString originalText() const { return m_origText; }
    00059
    00060   QChar accelerator() const;
    00061
    00062   int maxWeight(int &index, const QString &used);
    00063
    00064   bool operator == (const KAccelString &c) const { return m_pureText == c.m_pureText && m_accel == c.m_accel && m_orig_accel == c.m_orig_accel; }
    00065
    00066
    00067 private:
    00068
    00069   int stripAccelerator(QString &input);
    00070
    00071   void dump();
    00072
    00073   QString        m_pureText,  m_origText;
    00074   int            m_accel, m_orig_accel;
    00075   QMemArray<int> m_weight;
    00076
    00077 };
    00078
    00079
    00080 typedef QValueList<KAccelString> KAccelStringList;
    00081
    00082
    00090 class KAccelManagerAlgorithm
    00091 {
    00092 public:
    00093
    00094   enum {
    00095     // Default control weight
    00096     DEFAULT_WEIGHT = 50,
    00097     // Additional weight for first character in string
    00098     FIRST_CHARACTER_EXTRA_WEIGHT = 50,
    00099     // Additional weight for the beginning of a word
    00100     WORD_BEGINNING_EXTRA_WEIGHT = 50,
    00101     // Additional weight for the dialog buttons (large, we basically never want these reassigned)
    00102     DIALOG_BUTTON_EXTRA_WEIGHT = 300,
    00103     // Additional weight for a 'wanted' accelerator
    00104     WANTED_ACCEL_EXTRA_WEIGHT = 150,
    00105     // Default weight for an 'action' widget (ie, pushbuttons)
    00106     ACTION_ELEMENT_WEIGHT = 50,
    00107     // Default weight for group boxes (low priority)
    00108     GROUP_BOX_WEIGHT = -2000,
    00109     // Default weight for menu titles
    00110     MENU_TITLE_WEIGHT = 250,
    00111     // Additional weight for KDE standard accelerators
    00112     STANDARD_ACCEL = 300
    00113   };
    00114
    00115   static void findAccelerators(KAccelStringList &result, QString &used);
    00116
    00117 };
    00118
    00119
    00120 class QPopupMenu;
    00121
    00122
    00132 class KPopupAccelManager : public QObject
    00133 {
    00134   Q_OBJECT
    00135
    00136 public:
    00137
    00138   static void manage(QPopupMenu *popup);
    00139
    00140
    00141 protected:
    00142
    00143   KPopupAccelManager(QPopupMenu *popup);
    00144
    00145
    00146 private slots:
    00147
    00148   void aboutToShow();
    00149
    00150
    00151 private:
    00152
    00153   void calculateAccelerators();
    00154
    00155   void findMenuEntries(KAccelStringList &list);
    00156   void setMenuEntries(const KAccelStringList &list);
    00157
    00158   QPopupMenu       *m_popup;
    00159   KAccelStringList m_entries;
    00160   int              m_count;
    00161
    00162 };
    00163
    00164
    00165 class QWidgetStackAccelManager : public QObject
    00166 {
    00167   Q_OBJECT
    00168
    00169 public:
    00170
    00171   static void manage(QWidgetStack *popup);
    00172
    00173
    00174 protected:
    00175
    00176   QWidgetStackAccelManager(QWidgetStack *popup);
    00177
    00178
    00179 private slots:
    00180
    00181   void aboutToShow(QWidget *);
    00182     bool eventFilter ( QObject * watched, QEvent * e );
    00183
    00184 private:
    00185
    00186   void calculateAccelerators();
    00187
    00188   QWidgetStack     *m_stack;
    00189   KAccelStringList m_entries;
    00190
    00191 };
    00192
    00193
    00194 #endif

This file is part of the documentation for kdecore Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:18:00 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003