author | mickeyl <mickeyl> | 2004-01-15 15:32:10 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-15 15:32:10 (UTC) |
commit | 84bb8c9046007fe2adfaa016aded88b961c65e62 (patch) (unidiff) | |
tree | 8d7a57903b8c66ed28943a7d112cef93dd94111c /libopie2/opieui/big-screen/omodalhelper.cpp | |
parent | ac1e2b945965ee8caabd658e90f9e234fc622619 (diff) | |
download | opie-84bb8c9046007fe2adfaa016aded88b961c65e62.zip opie-84bb8c9046007fe2adfaa016aded88b961c65e62.tar.gz opie-84bb8c9046007fe2adfaa016aded88b961c65e62.tar.bz2 |
libopie1 (bigscreen) --> libopie2/opieui
Diffstat (limited to 'libopie2/opieui/big-screen/omodalhelper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/big-screen/omodalhelper.cpp | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/libopie2/opieui/big-screen/omodalhelper.cpp b/libopie2/opieui/big-screen/omodalhelper.cpp new file mode 100644 index 0000000..19aa64f --- a/dev/null +++ b/libopie2/opieui/big-screen/omodalhelper.cpp | |||
@@ -0,0 +1,179 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "omodalhelper.h" | ||
30 | |||
31 | /* QT */ | ||
32 | #include <qpushbutton.h> | ||
33 | #include <qvbox.h> | ||
34 | #include <qlayout.h> | ||
35 | #include <qlabel.h> | ||
36 | |||
37 | /* Signal handling */ | ||
38 | OModalHelperSignal::OModalHelperSignal( OModalHelperBase* base, QObject* parent ) | ||
39 | : QObject( parent, "OModal Helper Signal" ), m_base( base ) | ||
40 | {} | ||
41 | |||
42 | OModalHelperSignal::~OModalHelperSignal() | ||
43 | { | ||
44 | /* special the ancestor deletes its creator */ | ||
45 | delete m_base; | ||
46 | } | ||
47 | |||
48 | |||
49 | /* Helper Controler */ | ||
50 | /* | ||
51 | * the dialogs signal will be slotted here | ||
52 | * and we will call into m_base | ||
53 | */ | ||
54 | OModalHelperControler::OModalHelperControler( OModalHelperBase* base, QObject* parent ) | ||
55 | : QObject(parent, "OModal Helper Controler" ), m_base( base ), m_dia( 0 ), m_id( -1 ) | ||
56 | {} | ||
57 | |||
58 | TransactionID OModalHelperControler::transactionID()const | ||
59 | { | ||
60 | return m_id; | ||
61 | } | ||
62 | |||
63 | void OModalHelperControler::setTransactionID( TransactionID id ) | ||
64 | { | ||
65 | m_dia = 0; | ||
66 | m_id = id; | ||
67 | } | ||
68 | |||
69 | QDialog* OModalHelperControler::dialog()const | ||
70 | { | ||
71 | return m_dia; | ||
72 | } | ||
73 | |||
74 | /* | ||
75 | * If we're in the New mode we will map the QDialog | ||
76 | * to the TransactionID | ||
77 | */ | ||
78 | void OModalHelperControler::done( int result ) | ||
79 | { | ||
80 | if ( sender() && !sender()->isA("OModalQueuedDialog") ) | ||
81 | m_dia = static_cast<QDialog*>( sender() ); | ||
82 | |||
83 | m_base->done( result, m_id ); | ||
84 | } | ||
85 | |||
86 | void OModalHelperControler::next() | ||
87 | { | ||
88 | m_base->next( m_id ); | ||
89 | } | ||
90 | |||
91 | void OModalHelperControler::prev() | ||
92 | { | ||
93 | m_base->prev( m_id ); | ||
94 | } | ||
95 | |||
96 | /* The Queued Dialog inclusive QueuedBar */ | ||
97 | struct OModalQueueBar : public QHBox | ||
98 | { | ||
99 | QPushButton* next; | ||
100 | QPushButton* prev; | ||
101 | QLabel * label; | ||
102 | |||
103 | OModalQueueBar( QWidget* parent ); | ||
104 | void setText( const QString& str ); | ||
105 | }; | ||
106 | |||
107 | OModalQueueBar::OModalQueueBar( QWidget* parent ) | ||
108 | : QWidget( parent, "OModal Queue Bar" ) | ||
109 | { | ||
110 | prev = new QPushButton( this ); | ||
111 | prev->setText( OModalQueuedDialog::tr("Prev") ); | ||
112 | |||
113 | label = new QLabel(this); | ||
114 | |||
115 | next = new QPushButton( this ); | ||
116 | next->setText( OModalQueuedDialog::tr("Next") ); | ||
117 | } | ||
118 | |||
119 | void OModalQueueBar::setText( const QString& str ) | ||
120 | { | ||
121 | label->setText( str ); | ||
122 | } | ||
123 | |||
124 | |||
125 | OModalQueuedDialog::OModalQueuedDialog( QDialog* mainWidget ) | ||
126 | : QDialog(0, "OModal Queued Dialog" ) | ||
127 | { | ||
128 | QVBoxLayout *lay = new QVBoxLayout( this ); | ||
129 | |||
130 | m_bar = new OModalQueueBar( this ); | ||
131 | lay->addWidget( m_bar ); | ||
132 | |||
133 | m_center = mainWidget; | ||
134 | m_center->reparent(this, 0, QPoint(0, 0) ); | ||
135 | lay->addWidget( m_center ); | ||
136 | |||
137 | |||
138 | connect(m_bar->next, SIGNAL(clicked() ), this, | ||
139 | SIGNAL(next() ) ); | ||
140 | connect(m_bar->prev, SIGNAL(clicked() ), this, | ||
141 | SIGNAL(prev() ) ); | ||
142 | |||
143 | } | ||
144 | |||
145 | OModalQueuedDialog::~OModalQueuedDialog() | ||
146 | {} | ||
147 | |||
148 | QDialog* OModalQueuedDialog::centerDialog()const | ||
149 | { | ||
150 | return m_center; | ||
151 | } | ||
152 | |||
153 | void OModalQueuedDialog::setQueueBarEnabled( bool b) | ||
154 | { | ||
155 | /* in Qt3 use setEnabled( bool ) */ | ||
156 | if (b) | ||
157 | m_bar->show(); | ||
158 | else | ||
159 | m_bar->hide(); | ||
160 | } | ||
161 | |||
162 | void OModalQueuedDialog::setRecord( int record, int count ) | ||
163 | { | ||
164 | if (!record && !count ) | ||
165 | { | ||
166 | hide(); | ||
167 | return; | ||
168 | } | ||
169 | else | ||
170 | show(); | ||
171 | |||
172 | if ( count > 1 ) | ||
173 | m_bar->show(); | ||
174 | else | ||
175 | m_bar->hide(); | ||
176 | |||
177 | m_bar->setText( tr("Editing record %1 out of %2", | ||
178 | "Shows the current edited record out of an array of records").arg( record ). arg( count ) ); | ||
179 | } | ||