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 QChar accelerator() const;
00058
00059 int maxWeight(int &index, const QString &used);
00060
00061 bool operator == (const KAccelString &c) const { return m_pureText == c.m_pureText && m_accel == c.m_accel && orig_accel == c.orig_accel; }
00062
00063
00064 private:
00065
00066 int stripAccelerator(QString &input);
00067
00068 void dump();
00069
00070 QString m_pureText;
00071 int m_accel, orig_accel;
00072 QMemArray<int> m_weight;
00073
00074 };
00075
00076
00077 typedef QValueList<KAccelString> KAccelStringList;
00078
00079
00088 class KAccelManagerAlgorithm
00089 {
00090 public:
00091
00092 static const int DEFAULT_WEIGHT;
00093
00094 static const int FIRST_CHARACTER_EXTRA_WEIGHT;
00095 static const int WORD_BEGINNING_EXTRA_WEIGHT;
00096 static const int WANTED_ACCEL_EXTRA_WEIGHT;
00097 static const int DIALOG_BUTTON_EXTRA_WEIGHT;
00098
00099 static const int ACTION_ELEMENT_WEIGHT;
00100 static const int GROUP_BOX_WEIGHT;
00101 static const int MENU_TITLE_WEIGHT;
00102
00103 static void findAccelerators(KAccelStringList &result, QString &used);
00104
00105 };
00106
00107
00108 class QPopupMenu;
00109
00110
00121 class KPopupAccelManager : public QObject
00122 {
00123 Q_OBJECT
00124
00125 public:
00126
00127 static void manage(QPopupMenu *popup);
00128
00129
00130 protected:
00131
00132 KPopupAccelManager(QPopupMenu *popup);
00133
00134
00135 private slots:
00136
00137 void aboutToShow();
00138
00139
00140 private:
00141
00142 void calculateAccelerators();
00143
00144 void findMenuEntries(KAccelStringList &list);
00145 void setMenuEntries(const KAccelStringList &list);
00146
00147 QPopupMenu *m_popup;
00148 KAccelStringList m_entries;
00149 int m_count;
00150
00151 };
00152
00153
00154 #endif
This file is part of the documentation for kdelibs Version 3.1.4.