Diffstat (limited to 'libopie/big-screen/omodalhelper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/big-screen/omodalhelper.cpp | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/libopie/big-screen/omodalhelper.cpp b/libopie/big-screen/omodalhelper.cpp new file mode 100644 index 0000000..e3d1c70 --- a/dev/null +++ b/libopie/big-screen/omodalhelper.cpp | |||
@@ -0,0 +1,160 @@ | |||
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 <qpushbutton.h> | ||
30 | #include <qvbox.h> | ||
31 | #include <qlayout.h> | ||
32 | #include <qlabel.h> | ||
33 | |||
34 | #include "omodalhelper.h" | ||
35 | |||
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 | /* special the ancestor deletes its creator */ | ||
44 | delete m_base; | ||
45 | } | ||
46 | |||
47 | |||
48 | /* Helper Controler */ | ||
49 | /* | ||
50 | * the dialogs signal will be slotted here | ||
51 | * and we will call into m_base | ||
52 | */ | ||
53 | OModalHelperControler::OModalHelperControler( OModalHelperBase* base, QObject* parent ) | ||
54 | : QObject(parent, "OModal Helper Controler" ), m_base( base ), m_dia( 0 ), m_id( -1 ) | ||
55 | { | ||
56 | } | ||
57 | |||
58 | TransactionID OModalHelperControler::transactionID()const { | ||
59 | return m_id; | ||
60 | } | ||
61 | |||
62 | void OModalHelperControler::setTransactionID( TransactionID id ) { | ||
63 | m_dia = 0; | ||
64 | m_id = id; | ||
65 | } | ||
66 | |||
67 | QDialog* OModalHelperControler::dialog()const { | ||
68 | return m_dia; | ||
69 | } | ||
70 | |||
71 | /* | ||
72 | * If we're in the New mode we will map the QDialog | ||
73 | * to the TransactionID | ||
74 | */ | ||
75 | void OModalHelperControler::done( int result ) { | ||
76 | if ( sender() && !sender()->isA("OModalQueuedDialog") ) | ||
77 | m_dia = static_cast<QDialog*>( sender() ); | ||
78 | |||
79 | m_base->done( m_id ); | ||
80 | } | ||
81 | |||
82 | void OModalHelperControler::next() { | ||
83 | m_base->next( m_id ); | ||
84 | } | ||
85 | |||
86 | void OModalHelperControler::prev() { | ||
87 | m_base->prev( m_id ); | ||
88 | } | ||
89 | |||
90 | /* The Queued Dialog inclusive QueuedBar */ | ||
91 | struct OModalQueueBar : public QHBox { | ||
92 | QPushButton* next; | ||
93 | QPushButton* prev; | ||
94 | QLabel * label; | ||
95 | |||
96 | OModalQueueBar( QWidget* parent ); | ||
97 | void setText( const QString& str ); | ||
98 | }; | ||
99 | |||
100 | OModalQueueBar::OModalQueueBar( QWidget* parent ) | ||
101 | : QWidget( parent, "OModal Queue Bar" ) { | ||
102 | prev = new QPushButton( this ); | ||
103 | prev->setText( OModalQueuedDialog::tr("Prev") ); | ||
104 | |||
105 | label = new QLabel(this); | ||
106 | |||
107 | next = new QPushButton( this ); | ||
108 | next->setText( OModalQueuedDialog::tr("Next") ); | ||
109 | } | ||
110 | |||
111 | void OModalQueueBar::setText( const QString& str ) { | ||
112 | label->setText( str ); | ||
113 | } | ||
114 | |||
115 | |||
116 | OModalQueuedDialog::OModalQueuedDialog( QDialog* mainWidget ) | ||
117 | : QDialog(0, "OModal Queued Dialog" ) | ||
118 | { | ||
119 | QVBoxLayout *lay = new QVBoxLayout( this ); | ||
120 | |||
121 | m_bar = new OModalQueueBar( this ); | ||
122 | lay->addWidget( m_bar ); | ||
123 | |||
124 | m_center = mainWidget; | ||
125 | m_center->reparent(this, 0, QPoint(0, 0) ); | ||
126 | lay->addWidget( m_center ); | ||
127 | |||
128 | |||
129 | connect(m_bar->next, SIGNAL(clicked() ), this, | ||
130 | SIGNAL(next() ) ); | ||
131 | connect(m_bar->prev, SIGNAL(clicked() ), this, | ||
132 | SIGNAL(prev() ) ); | ||
133 | |||
134 | } | ||
135 | |||
136 | OModalQueuedDialog::~OModalQueuedDialog() { | ||
137 | } | ||
138 | |||
139 | QDialog* OModalQueuedDialog::centerDialog()const { | ||
140 | return m_center; | ||
141 | } | ||
142 | |||
143 | void OModalQueuedDialog::setQueueBarEnabled( bool b) { | ||
144 | /* in Qt3 use setEnabled( bool ) */ | ||
145 | if (b) | ||
146 | m_bar->show(); | ||
147 | else | ||
148 | m_bar->hide(); | ||
149 | } | ||
150 | |||
151 | void OModalQueuedDialog::setRecord( int record, int count ) { | ||
152 | if (!record && !count ) { | ||
153 | hide(); | ||
154 | return; | ||
155 | }else | ||
156 | show(); | ||
157 | |||
158 | m_bar->setText( tr("Editing record %1 out of %2", | ||
159 | "Shows the current edited record out of an array of records").arg( record ). arg( count ) ); | ||
160 | } | ||