summaryrefslogtreecommitdiff
authorzecke <zecke>2004-11-03 22:57:37 (UTC)
committer zecke <zecke>2004-11-03 22:57:37 (UTC)
commit07900eb7986f63e56072b1fb8fe5dbf846c8519d (patch) (unidiff)
treefb1242d501314408de6328e43ced421a274f9c48
parentc85842bfd4b008eb6bd7527f0511f36dbf693ba5 (diff)
downloadopie-07900eb7986f63e56072b1fb8fe5dbf846c8519d.zip
opie-07900eb7986f63e56072b1fb8fe5dbf846c8519d.tar.gz
opie-07900eb7986f63e56072b1fb8fe5dbf846c8519d.tar.bz2
-Make struct s_button (simpad button) really internal
-Make the s_button array static and invisible -Use namespace { instead of 'using namespace...;'
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp27
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h12
2 files changed, 23 insertions, 16 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index ebf0cbb..9fde7f9 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -42,36 +42,48 @@
42#include <qpe/sound.h> 42#include <qpe/sound.h>
43#include <qpe/qcopenvelope_qws.h> 43#include <qpe/qcopenvelope_qws.h>
44#include <opie2/okeyfilter.h> 44#include <opie2/okeyfilter.h>
45 45
46/* STD */ 46/* STD */
47#include <fcntl.h> 47#include <fcntl.h>
48#include <math.h> 48#include <math.h>
49#include <stdlib.h> 49#include <stdlib.h>
50#include <signal.h> 50#include <signal.h>
51#include <sys/ioctl.h> 51#include <sys/ioctl.h>
52#include <sys/time.h> 52#include <sys/time.h>
53#include <unistd.h> 53#include <unistd.h>
54#ifndef QT_NO_SOUND 54#ifndef QT_NO_SOUND
55#include <linux/soundcard.h> 55#include <linux/soundcard.h>
56#endif 56#endif
57 57
58using namespace Opie::Core; 58namespace Opie {
59using namespace Opie::Core::Internal; 59namespace Core {
60namespace Internal {
61namespace {
62struct s_button {
63 uint model;
64 Qt::Key code;
65 char *utext;
66 char *pix;
67 char *fpressedservice;
68 char *fpressedaction;
69 char *fheldservice;
70 char *fheldaction;
71};
60 72
61struct s_button simpad_buttons [] = { 73static struct s_button simpad_buttons [] = {
62 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 74 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
63 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 75 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
64 "devicebuttons/simpad_lower_up", 76 "devicebuttons/simpad_lower_up",
65 "datebook", "nextView()", 77 "datebook", "nextView()",
66 "today", "raise()" }, 78 "today", "raise()" },
67 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 79 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
68 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 80 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
69 "devicebuttons/simpad_lower_down", 81 "devicebuttons/simpad_lower_down",
70 "addressbook", "raise()", 82 "addressbook", "raise()",
71 "addressbook", "beamBusinessCard()" }, 83 "addressbook", "beamBusinessCard()" },
72 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 84 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
73 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 85 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
74 "devicebuttons/simpad_lower_right", 86 "devicebuttons/simpad_lower_right",
75 "QPE/TaskBar", "toggleMenu()", 87 "QPE/TaskBar", "toggleMenu()",
76 "QPE/TaskBar", "toggleStartMenu()" }, 88 "QPE/TaskBar", "toggleStartMenu()" },
77 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 89 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
@@ -100,32 +112,34 @@ struct s_button simpad_buttons [] = {
100 "devicebuttons/simpad_upper_left", 112 "devicebuttons/simpad_upper_left",
101 "QPE/Rotation", "flip()", 113 "QPE/Rotation", "flip()",
102 "QPE/Rotation", "flip()" }, 114 "QPE/Rotation", "flip()" },
103 /* 115 /*
104 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 116 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
105 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 117 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
106 "devicebuttons/simpad_lower_upper", 118 "devicebuttons/simpad_lower_upper",
107 "QPE/Launcher", "home()", 119 "QPE/Launcher", "home()",
108 "buttonsettings", "raise()" }, 120 "buttonsettings", "raise()" },
109 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 121 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
110 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 122 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
111 "devicebuttons/simpad_upper_lower", 123 "devicebuttons/simpad_upper_lower",
112 "QPE/Launcher", "home()", 124 "QPE/Launcher", "home()",
113 "buttonsettings", "raise()" }, 125 "buttonsettings", "raise()" },
114 */ 126 */
115}; 127};
128}
129
116 130
117void SIMpad::init(const QString&) 131void SIMpad::init(const QString&)
118{ 132{
119 d->m_vendorstr = "SIEMENS"; 133 d->m_vendorstr = "SIEMENS";
120 d->m_vendor = Vendor_SIEMENS; 134 d->m_vendor = Vendor_SIEMENS;
121 135
122 136
123 //TODO Implement model checking 137 //TODO Implement model checking
124 //FIXME For now we assume an SL4 138 //FIXME For now we assume an SL4
125 139
126 d->m_modelstr = "SL4"; 140 d->m_modelstr = "SL4";
127 d->m_model = Model_SIMpad_SL4; 141 d->m_model = Model_SIMpad_SL4;
128 142
129 switch ( d->m_model ) { 143 switch ( d->m_model ) {
130 default: 144 default:
131 d->m_rotation = Rot0; 145 d->m_rotation = Rot0;
@@ -136,33 +150,34 @@ void SIMpad::init(const QString&)
136 } 150 }
137 151
138 //Distribution detecting code is now in base class 152 //Distribution detecting code is now in base class
139 m_leds [0] = m_leds [1] = Led_Off; 153 m_leds [0] = m_leds [1] = Led_Off;
140 154
141 m_power_timer = 0; 155 m_power_timer = 0;
142 156
143} 157}
144 158
145void SIMpad::initButtons() 159void SIMpad::initButtons()
146{ 160{
147 if ( d->m_buttons ) 161 if ( d->m_buttons )
148 return; 162 return;
149 163
150 d->m_buttons = new QValueList <ODeviceButton>; 164 d->m_buttons = new QValueList <ODeviceButton>;
151 165
152 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 166 uint size = sizeof(simpad_buttons)/sizeof(s_button);
167 for ( uint i = 0; i < size; i++ ) {
153 s_button *sb = simpad_buttons + i; 168 s_button *sb = simpad_buttons + i;
154 ODeviceButton b; 169 ODeviceButton b;
155 170
156 if (( sb->model & d->m_model ) == d->m_model ) { 171 if (( sb->model & d->m_model ) == d->m_model ) {
157 b. setKeycode ( sb->code ); 172 b. setKeycode ( sb->code );
158 b. setUserText ( QObject::tr ( "Button", sb->utext )); 173 b. setUserText ( QObject::tr ( "Button", sb->utext ));
159 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 174 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
160 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 175 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
161 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 176 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
162 177
163 d->m_buttons->append ( b ); 178 d->m_buttons->append ( b );
164 } 179 }
165 } 180 }
166 reloadButtonMapping(); 181 reloadButtonMapping();
167} 182}
168 183
@@ -368,16 +383,20 @@ int SIMpad::displayBrightnessResolution() const
368/* 383/*
369 * The MQ200 DRAM content is lost during suspend 384 * The MQ200 DRAM content is lost during suspend
370 * so we will just repaint every widget on resume 385 * so we will just repaint every widget on resume
371 */ 386 */
372void SIMpad::updateAllWidgets() { 387void SIMpad::updateAllWidgets() {
373 QWidgetList *list = QApplication::allWidgets(); 388 QWidgetList *list = QApplication::allWidgets();
374 QWidgetListIt it( *list ); 389 QWidgetListIt it( *list );
375 QWidget *wid; 390 QWidget *wid;
376 391
377 while ((wid=it.current()) != 0 ) { 392 while ((wid=it.current()) != 0 ) {
378 wid->update(); 393 wid->update();
379 ++it; 394 ++it;
380 } 395 }
381 396
382 delete list; 397 delete list;
383} 398}
399
400}
401}
402}
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
index c25b911..41b94d1 100644
--- a/libopie2/opiecore/device/odevice_simpad.h
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -55,33 +55,21 @@ class SIMpad : public ODevice
55 virtual void playAlarmSound(); 55 virtual void playAlarmSound();
56 56
57 virtual QValueList <OLed> ledList() const; 57 virtual QValueList <OLed> ledList() const;
58 virtual QValueList <OLedState> ledStateList( OLed led ) const; 58 virtual QValueList <OLedState> ledStateList( OLed led ) const;
59 virtual OLedState ledState( OLed led ) const; 59 virtual OLedState ledState( OLed led ) const;
60 virtual bool setLedState( OLed led, OLedState st ); 60 virtual bool setLedState( OLed led, OLedState st );
61 61
62protected: 62protected:
63 virtual void timerEvent( QTimerEvent *te ); 63 virtual void timerEvent( QTimerEvent *te );
64 64
65 int m_power_timer; 65 int m_power_timer;
66 66
67 OLedState m_leds [2]; 67 OLedState m_leds [2];
68private: 68private:
69 static void updateAllWidgets(); 69 static void updateAllWidgets();
70}; 70};
71
72struct s_button {
73 uint model;
74 Qt::Key code;
75 char *utext;
76 char *pix;
77 char *fpressedservice;
78 char *fpressedaction;
79 char *fheldservice;
80 char *fheldaction;
81};
82
83} 71}
84} 72}
85} 73}
86 74
87#endif 75#endif