kaccelmanager_private.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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
00091 class KAccelManagerAlgorithm
00092 {
00093 public:
00094
00095 static const int DEFAULT_WEIGHT;
00096
00097 static const int FIRST_CHARACTER_EXTRA_WEIGHT;
00098 static const int WORD_BEGINNING_EXTRA_WEIGHT;
00099 static const int WANTED_ACCEL_EXTRA_WEIGHT;
00100 static const int DIALOG_BUTTON_EXTRA_WEIGHT;
00101 static const int STANDARD_ACCEL;
00102
00103 static const int ACTION_ELEMENT_WEIGHT;
00104 static const int GROUP_BOX_WEIGHT;
00105 static const int MENU_TITLE_WEIGHT;
00106
00107 static void findAccelerators(KAccelStringList &result, QString &used);
00108
00109 };
00110
00111
00112 class QPopupMenu;
00113
00114
00125 class KPopupAccelManager : public QObject
00126 {
00127 Q_OBJECT
00128
00129 public:
00130
00131 static void manage(QPopupMenu *popup);
00132
00133
00134 protected:
00135
00136 KPopupAccelManager(QPopupMenu *popup);
00137
00138
00139 private slots:
00140
00141 void aboutToShow();
00142
00143
00144 private:
00145
00146 void calculateAccelerators();
00147
00148 void findMenuEntries(KAccelStringList &list);
00149 void setMenuEntries(const KAccelStringList &list);
00150
00151 QPopupMenu *m_popup;
00152 KAccelStringList m_entries;
00153 int m_count;
00154
00155 };
00156
00157
00158 #endif
This file is part of the documentation for kdecore Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 4 22:43:28 2004 by
doxygen 1.3.6-20040222 written by
Dimitri van Heesch, © 1997-2003