author | zecke <zecke> | 2004-08-14 15:43:08 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-08-14 15:43:08 (UTC) |
commit | 7657b6986a600ec1b3626c83e8f19036bf69e493 (patch) (unidiff) | |
tree | d8196d985a24663e9777dcc811f54b0eaf1abc9b /inputmethods | |
parent | 3df06db9e6fd268c7d234be05b01a2303dc0f7ba (diff) | |
download | opie-7657b6986a600ec1b3626c83e8f19036bf69e493.zip opie-7657b6986a600ec1b3626c83e8f19036bf69e493.tar.gz opie-7657b6986a600ec1b3626c83e8f19036bf69e493.tar.bz2 |
Do not delete the parent in dtor, when the parent called you for
destruction
-rw-r--r-- | inputmethods/dasher/QtDasherPlugin.cc | 2 | ||||
-rw-r--r-- | inputmethods/dasher/QtDasherScreen.cc | 2 |
2 files changed, 1 insertions, 3 deletions
diff --git a/inputmethods/dasher/QtDasherPlugin.cc b/inputmethods/dasher/QtDasherPlugin.cc index f491769..50d4539 100644 --- a/inputmethods/dasher/QtDasherPlugin.cc +++ b/inputmethods/dasher/QtDasherPlugin.cc | |||
@@ -1,79 +1,79 @@ | |||
1 | #include "QtDasherPlugin.h" | 1 | #include "QtDasherPlugin.h" |
2 | 2 | ||
3 | #include <qpe/global.h> | 3 | #include <qpe/global.h> |
4 | 4 | ||
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qlist.h> | 6 | #include <qlist.h> |
7 | #include <qbitmap.h> | 7 | #include <qbitmap.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qvbox.h> | 9 | #include <qvbox.h> |
10 | #include <qdialog.h> | 10 | #include <qdialog.h> |
11 | #include <qscrollview.h> | 11 | #include <qscrollview.h> |
12 | #include <qpopupmenu.h> | 12 | #include <qpopupmenu.h> |
13 | #include <qhbuttongroup.h> | 13 | #include <qhbuttongroup.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qwindowsystem_qws.h> | 16 | #include <qwindowsystem_qws.h> |
17 | 17 | ||
18 | QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QFrame(parent,name,f) | 18 | QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QFrame(parent,name,f) |
19 | { | 19 | { |
20 | (new QHBoxLayout(this))->setAutoAdd(TRUE); | 20 | (new QHBoxLayout(this))->setAutoAdd(TRUE); |
21 | interface = new CDasherInterface; | 21 | interface = new CDasherInterface; |
22 | interface->SetSystemLocation("/opt/QtPalmtop/share/dasher/"); | 22 | interface->SetSystemLocation("/opt/QtPalmtop/share/dasher/"); |
23 | interface->Unpause(0); | 23 | interface->Unpause(0); |
24 | interface->Start(); | 24 | interface->Start(); |
25 | d = new QtDasherScreen(240,100,interface,this,this); | 25 | d = new QtDasherScreen(240,100,interface,this,this); |
26 | interface->ChangeMaxBitRate(2.5); | 26 | interface->ChangeMaxBitRate(2.5); |
27 | d->show(); | 27 | d->show(); |
28 | utf8_codec = new QUtf8Codec; | 28 | utf8_codec = new QUtf8Codec; |
29 | } | 29 | } |
30 | 30 | ||
31 | QSize QtDasherPlugin::sizeHint() const | 31 | QSize QtDasherPlugin::sizeHint() const |
32 | { | 32 | { |
33 | return QSize(240,100); | 33 | return QSize(240,100); |
34 | } | 34 | } |
35 | 35 | ||
36 | QtDasherPlugin::~QtDasherPlugin() | 36 | QtDasherPlugin::~QtDasherPlugin() |
37 | { | 37 | { |
38 | delete d; | 38 | delete interface; |
39 | } | 39 | } |
40 | 40 | ||
41 | void QtDasherPlugin::resetState() | 41 | void QtDasherPlugin::resetState() |
42 | { | 42 | { |
43 | flushcount=0; | 43 | flushcount=0; |
44 | interface->Start(); | 44 | interface->Start(); |
45 | interface->Redraw(); | 45 | interface->Redraw(); |
46 | } | 46 | } |
47 | 47 | ||
48 | void QtDasherPlugin::unflush() | 48 | void QtDasherPlugin::unflush() |
49 | { | 49 | { |
50 | if (flushcount==0) | 50 | if (flushcount==0) |
51 | return; | 51 | return; |
52 | for (; flushcount>0; flushcount--) { | 52 | for (; flushcount>0; flushcount--) { |
53 | deletetext(); | 53 | deletetext(); |
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
57 | void QtDasherPlugin::output(int Symbol) | 57 | void QtDasherPlugin::output(int Symbol) |
58 | { | 58 | { |
59 | std::string label = interface->GetEditText(Symbol); | 59 | std::string label = interface->GetEditText(Symbol); |
60 | QString unicodestring = utf8_codec->toUnicode(label.c_str()); | 60 | QString unicodestring = utf8_codec->toUnicode(label.c_str()); |
61 | for (int i=0; i<int(unicodestring.length()); i++) { | 61 | for (int i=0; i<int(unicodestring.length()); i++) { |
62 | emit key( unicodestring[i].unicode(), 0, 0, true, false ); | 62 | emit key( unicodestring[i].unicode(), 0, 0, true, false ); |
63 | emit key( unicodestring[i].unicode(), 0, 0, false, false ); | 63 | emit key( unicodestring[i].unicode(), 0, 0, false, false ); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | void QtDasherPlugin::deletetext() | 67 | void QtDasherPlugin::deletetext() |
68 | { | 68 | { |
69 | emit key( 0, Qt::Key_Backspace, 0, true, false); | 69 | emit key( 0, Qt::Key_Backspace, 0, true, false); |
70 | emit key( 0, Qt::Key_Backspace, 0, false, false); | 70 | emit key( 0, Qt::Key_Backspace, 0, false, false); |
71 | } | 71 | } |
72 | 72 | ||
73 | void QtDasherPlugin::flush(int Symbol) | 73 | void QtDasherPlugin::flush(int Symbol) |
74 | { | 74 | { |
75 | if (Symbol==0) | 75 | if (Symbol==0) |
76 | return; | 76 | return; |
77 | output(Symbol); | 77 | output(Symbol); |
78 | flushcount++; | 78 | flushcount++; |
79 | } | 79 | } |
diff --git a/inputmethods/dasher/QtDasherScreen.cc b/inputmethods/dasher/QtDasherScreen.cc index 2179cfb..b8a554c 100644 --- a/inputmethods/dasher/QtDasherScreen.cc +++ b/inputmethods/dasher/QtDasherScreen.cc | |||
@@ -34,98 +34,96 @@ QtDasherScreen::QtDasherScreen (int _width, int _height, | |||
34 | interface->SetSettingsStore(new CSettingsStore); | 34 | interface->SetSettingsStore(new CSettingsStore); |
35 | 35 | ||
36 | interface->ChangeLanguageModel(0); | 36 | interface->ChangeLanguageModel(0); |
37 | interface->ChangeView(0); | 37 | interface->ChangeView(0); |
38 | interface->ChangeEdit(_edit); | 38 | interface->ChangeEdit(_edit); |
39 | edit = _edit; | 39 | edit = _edit; |
40 | 40 | ||
41 | 41 | ||
42 | /* interface->GetFontSizes(&FontSizes); | 42 | /* interface->GetFontSizes(&FontSizes); |
43 | 43 | ||
44 | for (int i=0; i<FontSizes.size(); i++) { | 44 | for (int i=0; i<FontSizes.size(); i++) { |
45 | if (FontSizes[i]>Fonts.size()) | 45 | if (FontSizes[i]>Fonts.size()) |
46 | Fonts.resize((FontSizes[i])+1); | 46 | Fonts.resize((FontSizes[i])+1); |
47 | Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]); | 47 | Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]); |
48 | // Fonts[FontSizes[i]].setPixelSize(FontSizes[i]); | 48 | // Fonts[FontSizes[i]].setPixelSize(FontSizes[i]); |
49 | } | 49 | } |
50 | */ | 50 | */ |
51 | interface->ChangeScreen(this); | 51 | interface->ChangeScreen(this); |
52 | 52 | ||
53 | paused=true; | 53 | paused=true; |
54 | 54 | ||
55 | QTimer *tmr = new QTimer(this); | 55 | QTimer *tmr = new QTimer(this); |
56 | connect (tmr, SIGNAL(timeout()), SLOT(timer())); | 56 | connect (tmr, SIGNAL(timeout()), SLOT(timer())); |
57 | tmr->start(200); | 57 | tmr->start(200); |
58 | 58 | ||
59 | } | 59 | } |
60 | 60 | ||
61 | long QtDasherScreen::get_time() | 61 | long QtDasherScreen::get_time() |
62 | { | 62 | { |
63 | long s_now; | 63 | long s_now; |
64 | long ms_now; | 64 | long ms_now; |
65 | 65 | ||
66 | struct timeval tv; | 66 | struct timeval tv; |
67 | struct timezone tz; | 67 | struct timezone tz; |
68 | 68 | ||
69 | gettimeofday( &tv, &tz ); | 69 | gettimeofday( &tv, &tz ); |
70 | 70 | ||
71 | s_now = tv.tv_sec-1054487600; | 71 | s_now = tv.tv_sec-1054487600; |
72 | 72 | ||
73 | ms_now = tv.tv_usec / 1000; | 73 | ms_now = tv.tv_usec / 1000; |
74 | 74 | ||
75 | return( long(s_now*1000 + ms_now) ); | 75 | return( long(s_now*1000 + ms_now) ); |
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | QtDasherScreen::~QtDasherScreen() | 79 | QtDasherScreen::~QtDasherScreen() |
80 | { | 80 | { |
81 | delete painter; | 81 | delete painter; |
82 | delete interface; | ||
83 | delete edit; | ||
84 | } | 82 | } |
85 | 83 | ||
86 | QColor QtDasherScreen::getColor(int Color, const Opts::ColorSchemes ColorScheme) const | 84 | QColor QtDasherScreen::getColor(int Color, const Opts::ColorSchemes ColorScheme) const |
87 | { | 85 | { |
88 | switch (ColorScheme) { | 86 | switch (ColorScheme) { |
89 | case Dasher::Opts::Nodes1: | 87 | case Dasher::Opts::Nodes1: |
90 | switch (Color) { | 88 | switch (Color) { |
91 | case 0: return QColor (180, 245, 180); | 89 | case 0: return QColor (180, 245, 180); |
92 | case 1: return QColor (160, 200, 160); | 90 | case 1: return QColor (160, 200, 160); |
93 | case 2: return QColor (0, 255, 255); | 91 | case 2: return QColor (0, 255, 255); |
94 | default: abort (); | 92 | default: abort (); |
95 | } | 93 | } |
96 | case Dasher::Opts::Nodes2: | 94 | case Dasher::Opts::Nodes2: |
97 | switch (Color) { | 95 | switch (Color) { |
98 | case 0: return QColor (255, 185, 255); | 96 | case 0: return QColor (255, 185, 255); |
99 | case 1: return QColor (140, 200, 255); | 97 | case 1: return QColor (140, 200, 255); |
100 | case 2: return QColor (255, 175, 175); | 98 | case 2: return QColor (255, 175, 175); |
101 | default: abort (); | 99 | default: abort (); |
102 | } | 100 | } |
103 | case Dasher::Opts::Special1: return QColor (240, 240, 240); | 101 | case Dasher::Opts::Special1: return QColor (240, 240, 240); |
104 | case Dasher::Opts::Special2: return QColor (255, 255, 255); | 102 | case Dasher::Opts::Special2: return QColor (255, 255, 255); |
105 | case Dasher::Opts::Groups: | 103 | case Dasher::Opts::Groups: |
106 | switch (Color) { | 104 | switch (Color) { |
107 | case 0: return QColor (255, 255, 0); | 105 | case 0: return QColor (255, 255, 0); |
108 | case 1: return QColor (255, 100, 100); | 106 | case 1: return QColor (255, 100, 100); |
109 | case 2: return QColor (0, 255, 0); | 107 | case 2: return QColor (0, 255, 0); |
110 | default: abort (); | 108 | default: abort (); |
111 | } | 109 | } |
112 | case Dasher::Opts::Objects: return QColor (0, 0, 0); | 110 | case Dasher::Opts::Objects: return QColor (0, 0, 0); |
113 | default: abort(); | 111 | default: abort(); |
114 | } | 112 | } |
115 | } | 113 | } |
116 | 114 | ||
117 | void QtDasherScreen::DrawRectangle(int x1, int y1, int x2, int y2, | 115 | void QtDasherScreen::DrawRectangle(int x1, int y1, int x2, int y2, |
118 | int Color, Opts::ColorSchemes ColorScheme) const | 116 | int Color, Opts::ColorSchemes ColorScheme) const |
119 | { | 117 | { |
120 | painter->setBrush (getColor (Color, ColorScheme)); | 118 | painter->setBrush (getColor (Color, ColorScheme)); |
121 | painter->drawRect (x1, y1, x2-x1, y2-y1); | 119 | painter->drawRect (x1, y1, x2-x1, y2-y1); |
122 | } | 120 | } |
123 | 121 | ||
124 | static void Points_to_QPointArray(const Dasher::CDasherScreen::point* const points, | 122 | static void Points_to_QPointArray(const Dasher::CDasherScreen::point* const points, |
125 | int number, | 123 | int number, |
126 | QPointArray &qpa) | 124 | QPointArray &qpa) |
127 | { | 125 | { |
128 | for (int i = 0; i < number; i++) { | 126 | for (int i = 0; i < number; i++) { |
129 | qpa.setPoint (i, points[i].x, points[i].y); | 127 | qpa.setPoint (i, points[i].x, points[i].y); |
130 | } | 128 | } |
131 | } | 129 | } |