summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-09-20 13:32:47 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-09-21 08:07:55 (GMT)
commiteb1746a18933d4691fb71bf4ad5de73ded697f40 (patch)
treecf66778785cb12d9da0ec12616f4f39c7a31e174 /src/gui
parent96f0746298a1b93d0d22e3678a17e2a58d4010c7 (diff)
downloadQt-eb1746a18933d4691fb71bf4ad5de73ded697f40.zip
Qt-eb1746a18933d4691fb71bf4ad5de73ded697f40.tar.gz
Qt-eb1746a18933d4691fb71bf4ad5de73ded697f40.tar.bz2
Introduce a d-pointer to QSoftKeyManager.
Originally this was supposed to be a mostly static API, but now it looks like some more non-static members will be needed so introduce a d-pointer to store them. Reviewed-by: Alessandro Portale
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qsoftkeymanager.cpp41
-rw-r--r--src/gui/kernel/qsoftkeymanager_p.h8
2 files changed, 31 insertions, 18 deletions
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp
index 76fb378..64cffe0 100644
--- a/src/gui/kernel/qsoftkeymanager.cpp
+++ b/src/gui/kernel/qsoftkeymanager.cpp
@@ -45,6 +45,7 @@
#include "private/qt_s60_p.h"
#endif
#include "private/qsoftkeymanager_p.h"
+#include "private/qobject_p.h"
QT_BEGIN_NAMESPACE
@@ -52,8 +53,21 @@ QT_BEGIN_NAMESPACE
static const int s60CommandStart = 6000;
#endif
-QWidget *QSoftKeyManager::softKeySource = 0;
-QSoftKeyManager *QSoftKeyManager::self = 0;
+class QSoftKeyManagerPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QSoftKeyManager)
+
+public:
+ static void updateSoftKeys_sys(const QList<QAction*> &softKeys);
+
+private:
+ QHash<QAction*, Qt::Key> keyedActions;
+ static QSoftKeyManager *self;
+ static QWidget *softKeySource;
+};
+
+QWidget *QSoftKeyManagerPrivate::softKeySource = 0;
+QSoftKeyManager *QSoftKeyManagerPrivate::self = 0;
const char *QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
{
@@ -80,13 +94,13 @@ const char *QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
QSoftKeyManager *QSoftKeyManager::instance()
{
- if (!QSoftKeyManager::self)
- QSoftKeyManager::self = new QSoftKeyManager;
+ if (!QSoftKeyManagerPrivate::self)
+ QSoftKeyManagerPrivate::self = new QSoftKeyManager;
- return self;
+ return QSoftKeyManagerPrivate::self;
}
-QSoftKeyManager::QSoftKeyManager() : QObject()
+QSoftKeyManager::QSoftKeyManager() : QObject(*(new QSoftKeyManagerPrivate), 0)
{
}
@@ -121,18 +135,19 @@ QAction *QSoftKeyManager::createKeyedAction(StandardSoftKey standardKey, Qt::Key
connect(action.data(), SIGNAL(triggered()), QSoftKeyManager::instance(), SLOT(sendKeyEvent()));
- QSoftKeyManager::instance()->keyedActions.insert(action.data(), key);
+ QSoftKeyManager::instance()->d_func()->keyedActions.insert(action.data(), key);
return action.take();
}
void QSoftKeyManager::sendKeyEvent()
{
+ Q_D(QSoftKeyManager);
QAction *action = qobject_cast<QAction*>(sender());
if (!action)
return;
- Qt::Key keyToSend = keyedActions.value(action, Qt::Key_unknown);
+ Qt::Key keyToSend = d->keyedActions.value(action, Qt::Key_unknown);
if (keyToSend != Qt::Key_unknown)
QApplication::postEvent(action->parentWidget(),
@@ -168,15 +183,15 @@ bool QSoftKeyManager::event(QEvent *e)
}
} while (source);
- QSoftKeyManager::softKeySource = source;
- QSoftKeyManager::updateSoftKeys_sys(softKeys);
+ QSoftKeyManagerPrivate::softKeySource = source;
+ QSoftKeyManagerPrivate::updateSoftKeys_sys(softKeys);
return true;
}
return false;
}
#ifdef Q_WS_S60
-void QSoftKeyManager::updateSoftKeys_sys(const QList<QAction*> &softkeys)
+void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList<QAction*> &softkeys)
{
CEikButtonGroupContainer* nativeContainer = S60->buttonGroupContainer();
@@ -221,9 +236,9 @@ void QSoftKeyManager::updateSoftKeys_sys(const QList<QAction*> &softkeys)
bool QSoftKeyManager::handleCommand(int command)
{
- if (command >= s60CommandStart && QSoftKeyManager::softKeySource) {
+ if (command >= s60CommandStart && QSoftKeyManagerPrivate::softKeySource) {
int index = command - s60CommandStart;
- const QList<QAction*>& softKeys = QSoftKeyManager::softKeySource->actions();
+ const QList<QAction*>& softKeys = QSoftKeyManagerPrivate::softKeySource->actions();
if (index < softKeys.count()) {
softKeys.at(index)->activate(QAction::Trigger);
return true;
diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h
index 229df98..1bc6908 100644
--- a/src/gui/kernel/qsoftkeymanager_p.h
+++ b/src/gui/kernel/qsoftkeymanager_p.h
@@ -60,9 +60,12 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
+class QSoftKeyManagerPrivate;
+
class Q_AUTOTEST_EXPORT QSoftKeyManager : public QObject
{
Q_OBJECT
+ Q_DECLARE_PRIVATE(QSoftKeyManager)
public:
@@ -85,11 +88,6 @@ private:
QSoftKeyManager();
static QSoftKeyManager *instance();
static const char *standardSoftKeyText(StandardSoftKey standardKey);
- static void updateSoftKeys_sys(const QList<QAction*> &softKeys);
-
- static QSoftKeyManager *self;
- static QWidget *softKeySource;
- QHash<QAction*, Qt::Key> keyedActions;
protected:
bool event(QEvent *e);