kdecore Library API Documentation

kaccelmanager_private.h

00001 /* This file is part of the KDE project 00002 Copyright (C) 2002 Matthias Hölzer-Klüpfel <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 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
KDE Logo
This file is part of the documentation for kdecore Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 17 11:26:05 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003