author | clem <clem> | 2004-10-08 14:28:40 (UTC) |
---|---|---|
committer | clem <clem> | 2004-10-08 14:28:40 (UTC) |
commit | 057abc0180c8d821960d6957a8c3f64f0b86b229 (patch) (unidiff) | |
tree | 5aaadbd1924a89637ccf534ed91493b6406d8a5b /libopie2 | |
parent | 0e41f335c0db28250216a5292a2b7bcee2a1cf4a (diff) | |
download | opie-057abc0180c8d821960d6957a8c3f64f0b86b229.zip opie-057abc0180c8d821960d6957a8c3f64f0b86b229.tar.gz opie-057abc0180c8d821960d6957a8c3f64f0b86b229.tar.bz2 |
small doxygen doc fixes
-rw-r--r-- | libopie2/opiecore/okeyfilter.cpp | 8 | ||||
-rw-r--r-- | libopie2/opieui/big-screen/omodalhelper.h | 2 | ||||
-rw-r--r-- | libopie2/opieui/otabinfo.h | 5 |
3 files changed, 5 insertions, 10 deletions
diff --git a/libopie2/opiecore/okeyfilter.cpp b/libopie2/opiecore/okeyfilter.cpp index a517333..61b7909 100644 --- a/libopie2/opiecore/okeyfilter.cpp +++ b/libopie2/opiecore/okeyfilter.cpp | |||
@@ -1,148 +1,148 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> | 3 | =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> |
4 | .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "okeyfilter.h" | 29 | #include "okeyfilter.h" |
30 | #include "device/odevice.h" | 30 | #include "device/odevice.h" |
31 | #include "odebug.h" | 31 | #include "odebug.h" |
32 | 32 | ||
33 | namespace Opie { | 33 | namespace Opie { |
34 | namespace Core { | 34 | namespace Core { |
35 | 35 | ||
36 | class OKeyFilterPrivate:public OKeyFilter, QWSServer::KeyboardFilter | 36 | class OKeyFilterPrivate:public OKeyFilter, QWSServer::KeyboardFilter |
37 | { | 37 | { |
38 | static QValueList<QWSServer::KeyboardFilter*> filterList; | 38 | static QValueList<QWSServer::KeyboardFilter*> filterList; |
39 | static QValueList<QWSServer::KeyboardFilter*> preFilterList; | 39 | static QValueList<QWSServer::KeyboardFilter*> preFilterList; |
40 | protected: | 40 | protected: |
41 | OKeyFilterPrivate(const OKeyFilterPrivate&):OKeyFilter(),QWSServer::KeyboardFilter(){}; | 41 | OKeyFilterPrivate(const OKeyFilterPrivate&):OKeyFilter(),QWSServer::KeyboardFilter(){}; |
42 | virtual void addPreHandler(QWSServer::KeyboardFilter*); | 42 | virtual void addPreHandler(QWSServer::KeyboardFilter* aFilter); |
43 | virtual void remPreHandler(QWSServer::KeyboardFilter*); | 43 | virtual void remPreHandler(QWSServer::KeyboardFilter* aFilter); |
44 | 44 | ||
45 | public: | 45 | public: |
46 | OKeyFilterPrivate(); | 46 | OKeyFilterPrivate(); |
47 | virtual ~OKeyFilterPrivate(); | 47 | virtual ~OKeyFilterPrivate(); |
48 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 48 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
49 | virtual void addHandler(QWSServer::KeyboardFilter*); | 49 | virtual void addHandler(QWSServer::KeyboardFilter* aFilter); |
50 | virtual void remHandler(QWSServer::KeyboardFilter*); | 50 | virtual void remHandler(QWSServer::KeyboardFilter* aFilter); |
51 | }; | 51 | }; |
52 | 52 | ||
53 | QValueList<QWSServer::KeyboardFilter*> OKeyFilterPrivate::filterList; | 53 | QValueList<QWSServer::KeyboardFilter*> OKeyFilterPrivate::filterList; |
54 | QValueList<QWSServer::KeyboardFilter*> OKeyFilterPrivate::preFilterList; | 54 | QValueList<QWSServer::KeyboardFilter*> OKeyFilterPrivate::preFilterList; |
55 | 55 | ||
56 | OKeyFilter::OKeyFilter() | 56 | OKeyFilter::OKeyFilter() |
57 | { | 57 | { |
58 | } | 58 | } |
59 | 59 | ||
60 | OKeyFilter::~OKeyFilter() | 60 | OKeyFilter::~OKeyFilter() |
61 | { | 61 | { |
62 | } | 62 | } |
63 | 63 | ||
64 | OKeyFilter* OKeyFilter::inst() | 64 | OKeyFilter* OKeyFilter::inst() |
65 | { | 65 | { |
66 | static OKeyFilter*ofilter = 0; | 66 | static OKeyFilter*ofilter = 0; |
67 | if (!ofilter) { | 67 | if (!ofilter) { |
68 | ofilter = new OKeyFilterPrivate; | 68 | ofilter = new OKeyFilterPrivate; |
69 | } | 69 | } |
70 | return ofilter; | 70 | return ofilter; |
71 | } | 71 | } |
72 | 72 | ||
73 | bool OKeyFilterPrivate::filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 73 | bool OKeyFilterPrivate::filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
74 | { | 74 | { |
75 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | 75 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; |
76 | for (iter=preFilterList.begin();iter!=preFilterList.end();++iter) { | 76 | for (iter=preFilterList.begin();iter!=preFilterList.end();++iter) { |
77 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { | 77 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { |
78 | return true; | 78 | return true; |
79 | } | 79 | } |
80 | } | 80 | } |
81 | for (iter=filterList.begin();iter!=filterList.end();++iter) { | 81 | for (iter=filterList.begin();iter!=filterList.end();++iter) { |
82 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { | 82 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { |
83 | return true; | 83 | return true; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | return false; | 86 | return false; |
87 | } | 87 | } |
88 | 88 | ||
89 | void OKeyFilterPrivate::addHandler(QWSServer::KeyboardFilter*aF) | 89 | void OKeyFilterPrivate::addHandler(QWSServer::KeyboardFilter*aF) |
90 | { | 90 | { |
91 | if (!aF) return; | 91 | if (!aF) return; |
92 | if (filterList.find(aF)!=filterList.end()) { | 92 | if (filterList.find(aF)!=filterList.end()) { |
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | odebug << "adding a keyboard filter handler"<<oendl; | 95 | odebug << "adding a keyboard filter handler"<<oendl; |
96 | filterList.append(aF); | 96 | filterList.append(aF); |
97 | } | 97 | } |
98 | 98 | ||
99 | void OKeyFilterPrivate::remHandler(QWSServer::KeyboardFilter*aF) | 99 | void OKeyFilterPrivate::remHandler(QWSServer::KeyboardFilter*aF) |
100 | { | 100 | { |
101 | if (!aF) return; | 101 | if (!aF) return; |
102 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | 102 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; |
103 | if ( (iter=filterList.find(aF))==filterList.end() ) { | 103 | if ( (iter=filterList.find(aF))==filterList.end() ) { |
104 | return; | 104 | return; |
105 | } | 105 | } |
106 | odebug << "removing a keyboard filter handler"<<oendl; | 106 | odebug << "removing a keyboard filter handler"<<oendl; |
107 | filterList.remove(iter); | 107 | filterList.remove(iter); |
108 | } | 108 | } |
109 | 109 | ||
110 | void OKeyFilterPrivate::addPreHandler(QWSServer::KeyboardFilter*aF) | 110 | void OKeyFilterPrivate::addPreHandler(QWSServer::KeyboardFilter*aF) |
111 | { | 111 | { |
112 | if (!aF) return; | 112 | if (!aF) return; |
113 | if (preFilterList.find(aF)!=preFilterList.end()) { | 113 | if (preFilterList.find(aF)!=preFilterList.end()) { |
114 | return; | 114 | return; |
115 | } | 115 | } |
116 | odebug << "adding a preferred keyboard filter handler"<<oendl; | 116 | odebug << "adding a preferred keyboard filter handler"<<oendl; |
117 | preFilterList.append(aF); | 117 | preFilterList.append(aF); |
118 | } | 118 | } |
119 | 119 | ||
120 | void OKeyFilterPrivate::remPreHandler(QWSServer::KeyboardFilter*aF) | 120 | void OKeyFilterPrivate::remPreHandler(QWSServer::KeyboardFilter*aF) |
121 | { | 121 | { |
122 | if (!aF) return; | 122 | if (!aF) return; |
123 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | 123 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; |
124 | if ( (iter=preFilterList.find(aF))==preFilterList.end() ) { | 124 | if ( (iter=preFilterList.find(aF))==preFilterList.end() ) { |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | odebug << "removing a preferred keyboard filter handler"<<oendl; | 127 | odebug << "removing a preferred keyboard filter handler"<<oendl; |
128 | preFilterList.remove(iter); | 128 | preFilterList.remove(iter); |
129 | } | 129 | } |
130 | 130 | ||
131 | OKeyFilterPrivate::OKeyFilterPrivate() | 131 | OKeyFilterPrivate::OKeyFilterPrivate() |
132 | :OKeyFilter(),QWSServer::KeyboardFilter() | 132 | :OKeyFilter(),QWSServer::KeyboardFilter() |
133 | { | 133 | { |
134 | filterList.clear(); | 134 | filterList.clear(); |
135 | preFilterList.clear(); | 135 | preFilterList.clear(); |
136 | if ( isQWS( ) ) { | 136 | if ( isQWS( ) ) { |
137 | QWSServer::setKeyboardFilter ( this ); | 137 | QWSServer::setKeyboardFilter ( this ); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | OKeyFilterPrivate::~OKeyFilterPrivate() | 141 | OKeyFilterPrivate::~OKeyFilterPrivate() |
142 | { | 142 | { |
143 | } | 143 | } |
144 | 144 | ||
145 | /* namespace Core */ | 145 | /* namespace Core */ |
146 | } | 146 | } |
147 | /* namespace Opie */ | 147 | /* namespace Opie */ |
148 | } | 148 | } |
diff --git a/libopie2/opieui/big-screen/omodalhelper.h b/libopie2/opieui/big-screen/omodalhelper.h index 096cec4..ed6fee3 100644 --- a/libopie2/opieui/big-screen/omodalhelper.h +++ b/libopie2/opieui/big-screen/omodalhelper.h | |||
@@ -1,774 +1,774 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef OMODALHELPER_H | 29 | #ifndef OMODALHELPER_H |
30 | #define OMODALHELPER_H | 30 | #define OMODALHELPER_H |
31 | 31 | ||
32 | /* QT*/ | 32 | /* QT*/ |
33 | #include <qdialog.h> | 33 | #include <qdialog.h> |
34 | #include <qwidget.h> | 34 | #include <qwidget.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | #include <qvariant.h> | 37 | #include <qvariant.h> |
38 | 38 | ||
39 | typedef int TransactionID; | 39 | typedef int TransactionID; |
40 | 40 | ||
41 | class QDialog; | 41 | class QDialog; |
42 | 42 | ||
43 | namespace Opie | 43 | namespace Opie |
44 | { | 44 | { |
45 | 45 | ||
46 | class OModalHelperControler; | 46 | class OModalHelperControler; |
47 | class OModalHelperSignal; | 47 | class OModalHelperSignal; |
48 | 48 | ||
49 | struct OModalHelperBase | 49 | struct OModalHelperBase |
50 | { | 50 | { |
51 | virtual void done( int status, TransactionID ) = 0; | 51 | virtual void done( int status, TransactionID ) = 0; |
52 | virtual void next( TransactionID ) = 0; | 52 | virtual void next( TransactionID ) = 0; |
53 | virtual void prev( TransactionID ) = 0; | 53 | virtual void prev( TransactionID ) = 0; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * Modality sucks! ;) But it is easy to work with | 57 | * Modality sucks! ;) But it is easy to work with |
58 | * do exec() on a dialog and you know everything is funky. | 58 | * do exec() on a dialog and you know everything is funky. |
59 | * You only need to have one Dialog loaded and so on. | 59 | * You only need to have one Dialog loaded and so on. |
60 | * This class helps you to work like with modality and help | 60 | * This class helps you to work like with modality and help |
61 | * you to keep things in sync | 61 | * you to keep things in sync |
62 | * It's a template class but it sends signals once one Item is ready | 62 | * It's a template class but it sends signals once one Item is ready |
63 | * the signals contains the status and id of the item and then you | 63 | * the signals contains the status and id of the item and then you |
64 | * need fetch it. | 64 | * need fetch it. |
65 | * Handled Records will stay available until the first call to retrieve | 65 | * Handled Records will stay available until the first call to retrieve |
66 | * either the record via the TransactionID or via the QValueList<Record>. Note | 66 | * either the record via the TransactionID or via the QValueList<Record>. Note |
67 | * that most functions do not take handled records into account. | 67 | * that most functions do not take handled records into account. |
68 | * Also if you edit an record external you can tell this class and it'll | 68 | * Also if you edit an record external you can tell this class and it'll |
69 | * call the merge() function of your widget to maybe merge in these changes. | 69 | * call the merge() function of your widget to maybe merge in these changes. |
70 | * It also supports multiple modes. Either it can create new dialogs | 70 | * It also supports multiple modes. Either it can create new dialogs |
71 | * for each item or it can queue them depending on your usage. But it is | 71 | * for each item or it can queue them depending on your usage. But it is |
72 | * so smart that if only one item is shown that the queue bar is not shown | 72 | * so smart that if only one item is shown that the queue bar is not shown |
73 | * See the example for simple usage. | 73 | * See the example for simple usage. |
74 | * | 74 | * |
75 | * @short helps to life without modaility | 75 | * @short helps to life without modaility |
76 | * @author hOlgAr | 76 | * @author hOlgAr |
77 | * @version 0.01 | 77 | * @version 0.01 |
78 | */ | 78 | */ |
79 | template<class Dialog, class Record, typename Id = int> | 79 | template<class Dialog, class Record, typename Id = int> |
80 | class OModalHelper : private OModalHelperBase | 80 | class OModalHelper : private OModalHelperBase |
81 | { | 81 | { |
82 | friend class OModalHelperSignal; | 82 | friend class OModalHelperSignal; |
83 | friend class OModalHelperControler; | 83 | friend class OModalHelperControler; |
84 | public: | 84 | public: |
85 | typedef QValueList<Record> RecordList; | 85 | typedef QValueList<Record> RecordList; |
86 | typedef QMap<Id, Record> IdMap; | 86 | typedef QMap<Id, Record> IdMap; |
87 | typedef QMap<TransactionID, Id> TransactionMap; | 87 | typedef QMap<TransactionID, Id> TransactionMap; |
88 | typedef QMap<QDialog*, TransactionID> DialogMap | 88 | typedef QMap<QDialog*, TransactionID> DialogMap |
89 | enum Mode { Queue, New }; | 89 | enum Mode { Queue, New }; |
90 | OModalHelper(enum Mode mode, QObject* parnet ); | 90 | OModalHelper(enum Mode mode, QObject* parnet ); |
91 | 91 | ||
92 | bool handles( Id id)const; | 92 | bool handles( Id id)const; |
93 | TransactionID transactionID( Id id)const; | 93 | TransactionID transactionID( Id id)const; |
94 | 94 | ||
95 | void suspend( bool = true ); | 95 | void suspend( bool = true ); |
96 | 96 | ||
97 | void cancel(); | 97 | void cancel(); |
98 | void cancel( TransactionID ); | 98 | void cancel( TransactionID ); |
99 | 99 | ||
100 | void connectDone( QObject* rec, const char* slot ); | 100 | void connectDone( QObject* rec, const char* slot ); |
101 | void connectAccepted( QObject* rec, const char* slot ); | 101 | void connectAccepted( QObject* rec, const char* slot ); |
102 | void connectRejected( QObject* rec, const char* slot ); | 102 | void connectRejected( QObject* rec, const char* slot ); |
103 | 103 | ||
104 | TransactionID handle( Id id, const Record& rec = Record() ); | 104 | TransactionID handle( Id id, const Record& rec = Record() ); |
105 | 105 | ||
106 | void edited( Id, int what, const QVariant& data ); | 106 | void edited( Id, int what, const QVariant& data ); |
107 | 107 | ||
108 | Record record( TransactionID )const; | 108 | Record record( TransactionID )const; |
109 | RecordList recordsDone()const; | 109 | RecordList recordsDone()const; |
110 | private: | 110 | private: |
111 | virtual void done( int, TransactionID ); | 111 | virtual void done( int, TransactionID ); |
112 | virtual void next( TransactionID ); | 112 | virtual void next( TransactionID ); |
113 | virtual void prev( TransactionID ); | 113 | virtual void prev( TransactionID ); |
114 | 114 | ||
115 | Record nextRecord( TransactionID &, int & )const; | 115 | Record nextRecord( TransactionID &, int & )const; |
116 | Record prevRecord( TransactionID &, int & )const; | 116 | Record prevRecord( TransactionID &, int & )const; |
117 | int pos( TransactionID )const; | 117 | int pos( TransactionID )const; |
118 | Dialog* newDialogRecord( const Record& ); | 118 | Dialog* newDialogRecord( const Record& ); |
119 | 119 | ||
120 | private: | 120 | private: |
121 | OModalHelperDialog *queuedDialog()const; // generate or recycle | 121 | OModalHelperDialog *queuedDialog()const; // generate or recycle |
122 | OModalHelperDialog *m_dialog; | 122 | OModalHelperDialog *m_dialog; |
123 | OModalHelperSignal *m_signal; // our signal | 123 | OModalHelperSignal *m_signal; // our signal |
124 | OModalHelperControler *m_controler; | 124 | OModalHelperControler *m_controler; |
125 | IdMap m_ids; // maps ids (uids) to a record | 125 | IdMap m_ids; // maps ids (uids) to a record |
126 | IdMap m_doneIds; | 126 | IdMap m_doneIds; |
127 | TransactionMap m_transactions; // activate transactions | 127 | TransactionMap m_transactions; // activate transactions |
128 | TransactionMap m_done; // done and waiting for getting picked | 128 | TransactionMap m_done; // done and waiting for getting picked |
129 | DialogMap m_editing; // only used for New Mode | 129 | DialogMap m_editing; // only used for New Mode |
130 | enum Mode m_mode; // the mode we're in | 130 | enum Mode m_mode; // the mode we're in |
131 | bool m_disabled :1; | 131 | bool m_disabled :1; |
132 | }; | 132 | }; |
133 | 133 | ||
134 | 134 | ||
135 | 135 | ||
136 | /* ### FIXME use namespace with Qt3 */ | 136 | /* ### FIXME use namespace with Qt3 */ |
137 | 137 | ||
138 | /* | 138 | /* |
139 | * A note on flow. The Signal is used for QT Signals when | 139 | * A note on flow. The Signal is used for QT Signals when |
140 | * a record is done. | 140 | * a record is done. |
141 | * There is either one controler and this controler slot will | 141 | * There is either one controler and this controler slot will |
142 | * be connected to a dialog signal. | 142 | * be connected to a dialog signal. |
143 | * In Queue we get the next and prev signals and call the Helper. | 143 | * In Queue we get the next and prev signals and call the Helper. |
144 | * this then changes the Record of the dialog and sets the transactionId | 144 | * this then changes the Record of the dialog and sets the transactionId |
145 | * of the controler. | 145 | * of the controler. |
146 | * For the new mode | 146 | * For the new mode |
147 | * | 147 | * |
148 | */ | 148 | */ |
149 | 149 | ||
150 | class OModalHelperSignal : public QObject | 150 | class OModalHelperSignal : public QObject |
151 | { | 151 | { |
152 | Q_OBJECT | 152 | Q_OBJECT |
153 | public: | 153 | public: |
154 | OModalHelperSignal(OModalHelperBase* base, QObject* parent); | 154 | OModalHelperSignal(OModalHelperBase* base, QObject* parent); |
155 | ~OModalHelperSignal(); | 155 | ~OModalHelperSignal(); |
156 | 156 | ||
157 | signals: | 157 | signals: |
158 | done( int status, TransactionID transaction ); | 158 | done( int status, TransactionID transaction ); |
159 | accepted( TransactionID transaction ); | 159 | accepted( TransactionID transaction ); |
160 | rejected( TransactionID transaction ); | 160 | rejected( TransactionID transaction ); |
161 | 161 | ||
162 | private: | 162 | private: |
163 | OModalHelperBase* m_base; | 163 | OModalHelperBase* m_base; |
164 | }; | 164 | }; |
165 | 165 | ||
166 | 166 | ||
167 | class OModalHelperControler : public QObject | 167 | class OModalHelperControler : public QObject |
168 | { | 168 | { |
169 | Q_OBJECT | 169 | Q_OBJECT |
170 | public: | 170 | public: |
171 | OModalHelperControler( OModalHelperBase* , QObject* parent); | 171 | OModalHelperControler( OModalHelperBase* , QObject* parent); |
172 | virtual TransactionID transactionID()const; | 172 | virtual TransactionID transactionID()const; |
173 | void setTransactionID( TransactionID id ); | 173 | void setTransactionID( TransactionID id ); |
174 | QDialog* dialog()const; | 174 | QDialog* dialog()const; |
175 | 175 | ||
176 | public slots: | 176 | public slots: |
177 | virtual void done(int result ); | 177 | virtual void done(int result ); |
178 | virtual void next(); | 178 | virtual void next(); |
179 | virtual void prev(); | 179 | virtual void prev(); |
180 | private: | 180 | private: |
181 | QDialog *m_dia; | 181 | QDialog *m_dia; |
182 | TransactionID m_id; | 182 | TransactionID m_id; |
183 | OModalHelperBase *m_base; | 183 | OModalHelperBase *m_base; |
184 | } | 184 | } |
185 | 185 | ||
186 | struct OModalQueueBar; | 186 | struct OModalQueueBar; |
187 | class OModalQueuedDialog : public QDialog | 187 | class OModalQueuedDialog : public QDialog |
188 | { | 188 | { |
189 | Q_OBJECT | 189 | Q_OBJECT |
190 | public: | 190 | public: |
191 | OModalQueuedDialog(QDialog *mainWidget); | 191 | OModalQueuedDialog(QDialog *mainWidget); |
192 | ~OModalQueuedDialog(); | 192 | ~OModalQueuedDialog(); |
193 | 193 | ||
194 | QDialog* centerDialog()const; | 194 | QDialog* centerDialog()const; |
195 | 195 | ||
196 | void setQueueBarEnabled( bool = true ); | 196 | void setQueueBarEnabled( bool = true ); |
197 | void setRecord( int record, int count ); | 197 | void setRecord( int record, int count ); |
198 | 198 | ||
199 | signals: | 199 | signals: |
200 | void next(); | 200 | void next(); |
201 | void prev(); | 201 | void prev(); |
202 | 202 | ||
203 | private: | 203 | private: |
204 | OModalQueueBar *m_bar; | 204 | OModalQueueBar *m_bar; |
205 | QDialog *m_center; | 205 | QDialog *m_center; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | /* | 209 | /* |
210 | * Tcpp Template Implementation | 210 | * Tcpp Template Implementation |
211 | */ | 211 | */ |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * This is the simple Template c'tor. It takes the mode | 214 | * This is the simple Template c'tor. It takes the mode |
215 | * this helper should operate in and the parent object. | 215 | * this helper should operate in and the parent object. |
216 | * This helper will be deleted when the parent gets deleted | 216 | * This helper will be deleted when the parent gets deleted |
217 | * or you delete it yourself. | 217 | * or you delete it yourself. |
218 | * | 218 | * |
219 | * @param mode The mode this dialog should be in | 219 | * @param mode The mode this dialog should be in |
220 | * @param parent The parent QObject of this helper. | 220 | * @param parent The parent QObject of this helper. |
221 | */ | 221 | */ |
222 | template<class Dialog, class Record, typename Id> | 222 | template<class Dialog, class Record, typename Id> |
223 | OModalHelper<Dialog, Record, Id>::OModalHelper( enum Mode mode, QObject* parent ) | 223 | OModalHelper<Dialog, Record, Id>::OModalHelper( enum Mode mode, QObject* parent ) |
224 | { | 224 | { |
225 | m_disabled = false; | 225 | m_disabled = false; |
226 | m_mode = mode; | 226 | m_mode = mode; |
227 | m_signal = new OModalHelperSignal( this, parent ); | 227 | m_signal = new OModalHelperSignal( this, parent ); |
228 | m_controler = new OModalHelperControler( this, m_signal ); | 228 | m_controler = new OModalHelperControler( this, m_signal ); |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | /** | 232 | /** |
233 | * This functions looks for your record and sees if it is | 233 | * This functions looks for your record and sees if it is |
234 | * handled with this helper. Note that done records | 234 | * handled with this helper. Note that done records |
235 | * will not be returned. | 235 | * will not be returned. |
236 | * | 236 | * |
237 | * @return true if the record is currenlty edited otherwise false | 237 | * @return true if the record is currenlty edited otherwise false |
238 | * | 238 | * |
239 | * @param Id The id which might be handled | 239 | * @param id The id which might be handled |
240 | */ | 240 | */ |
241 | template<class Dialog, class Record, typename Id> | 241 | template<class Dialog, class Record, typename Id> |
242 | bool OModalHelper<Dialog, Record, Id>::handles( Id id )const | 242 | bool OModalHelper<Dialog, Record, Id>::handles( Id id )const |
243 | { | 243 | { |
244 | if ( m_transactions.isEmpty() ) | 244 | if ( m_transactions.isEmpty() ) |
245 | return false; | 245 | return false; |
246 | 246 | ||
247 | TransactionMap::ConstIterator it = m_transactions.begin(); | 247 | TransactionMap::ConstIterator it = m_transactions.begin(); |
248 | for ( ; it != m_transactions.end(); ++it ) | 248 | for ( ; it != m_transactions.end(); ++it ) |
249 | if ( it.data() == id ) | 249 | if ( it.data() == id ) |
250 | return true; | 250 | return true; |
251 | 251 | ||
252 | return false; | 252 | return false; |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | /** | 256 | /** |
257 | * just like handles( Id ) but returns the TransactionId | 257 | * just like handles( Id ) but returns the TransactionId |
258 | */ | 258 | */ |
259 | template<class Dialog, class Record, typename Id> | 259 | template<class Dialog, class Record, typename Id> |
260 | TransactionID OModalHelper<Dialog, Record, Id>::transactionID( Id id)const | 260 | TransactionID OModalHelper<Dialog, Record, Id>::transactionID( Id id)const |
261 | { | 261 | { |
262 | if ( m_transactions.isEmpty() || !m_ids.contains( id ) ) | 262 | if ( m_transactions.isEmpty() || !m_ids.contains( id ) ) |
263 | return 0; | 263 | return 0; |
264 | 264 | ||
265 | TransactionMap::ConstIterator it = m_transactions.begin(); | 265 | TransactionMap::ConstIterator it = m_transactions.begin(); |
266 | for ( ; it != m_transactions.end(); ++it ) | 266 | for ( ; it != m_transactions.end(); ++it ) |
267 | if ( it.data() == id ) | 267 | if ( it.data() == id ) |
268 | return it.key(); | 268 | return it.key(); |
269 | 269 | ||
270 | return 0; | 270 | return 0; |
271 | } | 271 | } |
272 | 272 | ||
273 | /** | 273 | /** |
274 | * If you're requested to flush your data and you do not want | 274 | * If you're requested to flush your data and you do not want |
275 | * to call cancel with this method you can disable and enabled | 275 | * to call cancel with this method you can disable and enabled |
276 | * all dialogs. | 276 | * all dialogs. |
277 | * The state gets saved so if you want to handle a new record the dialog | 277 | * The state gets saved so if you want to handle a new record the dialog |
278 | * will be disabled as well. | 278 | * will be disabled as well. |
279 | * | 279 | * |
280 | * @param sus If true setDisabled(TRUE) will be called otherwise FALSE | 280 | * @param sus If true setDisabled(TRUE) will be called otherwise FALSE |
281 | */ | 281 | */ |
282 | template<class Dialog, class Record, typename Id> | 282 | template<class Dialog, class Record, typename Id> |
283 | void OModalHelper<Dialog, Record, Id>::suspend(bool sus) | 283 | void OModalHelper<Dialog, Record, Id>::suspend(bool sus) |
284 | { | 284 | { |
285 | m_disabled = sus; | 285 | m_disabled = sus; |
286 | if (m_mode == New ) | 286 | if (m_mode == New ) |
287 | for (DialogMap::Iterator it = m_editing.begin(); it != m_editing.end(); ++it ) | 287 | for (DialogMap::Iterator it = m_editing.begin(); it != m_editing.end(); ++it ) |
288 | it.key()->setDisabled( sus ); | 288 | it.key()->setDisabled( sus ); |
289 | else if (m_dialog ) | 289 | else if (m_dialog ) |
290 | queuedDialog()->setDisabled( sus ); | 290 | queuedDialog()->setDisabled( sus ); |
291 | } | 291 | } |
292 | 292 | ||
293 | /** | 293 | /** |
294 | * Cancel will cancel all current operations and clear the list | 294 | * Cancel will cancel all current operations and clear the list |
295 | * of done operations as well. | 295 | * of done operations as well. |
296 | * This also clears all done operations you did not popped | 296 | * This also clears all done operations you did not popped |
297 | */ | 297 | */ |
298 | template<class Dialog, class Record, typename Id> | 298 | template<class Dialog, class Record, typename Id> |
299 | void OModalHelper<Dialog, Record, Id>::cancel() | 299 | void OModalHelper<Dialog, Record, Id>::cancel() |
300 | { | 300 | { |
301 | m_ids.clear(); | 301 | m_ids.clear(); |
302 | m_doneIds.clear(); | 302 | m_doneIds.clear(); |
303 | m_done.clear(); | 303 | m_done.clear(); |
304 | m_transactions.clear(); | 304 | m_transactions.clear(); |
305 | 305 | ||
306 | /* we also need to remove the QDialogs */ | 306 | /* we also need to remove the QDialogs */ |
307 | /* and hide the queue dialog if present */ | 307 | /* and hide the queue dialog if present */ |
308 | if (m_mode == New && !m_editing.isEmpty() ) | 308 | if (m_mode == New && !m_editing.isEmpty() ) |
309 | { | 309 | { |
310 | for (DialogMap::Iterator it = m_editing.begin(); it != m_editing.end(); ++it ) | 310 | for (DialogMap::Iterator it = m_editing.begin(); it != m_editing.end(); ++it ) |
311 | delete it.key(); | 311 | delete it.key(); |
312 | 312 | ||
313 | m_editing.clear(); | 313 | m_editing.clear(); |
314 | } | 314 | } |
315 | else if (m_dialog ) | 315 | else if (m_dialog ) |
316 | queuedDialog()->setRecord( 0, 0 ); | 316 | queuedDialog()->setRecord( 0, 0 ); |
317 | 317 | ||
318 | m_controler->setTransactionID( 0 ); | 318 | m_controler->setTransactionID( 0 ); |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | /** | 322 | /** |
323 | * This cancels editing of the record behind the Transaction Number | 323 | * This cancels editing of the record behind the Transaction Number |
324 | * Note that if editing is already done it will also be removed from this list | 324 | * Note that if editing is already done it will also be removed from this list |
325 | */ | 325 | */ |
326 | template<class Dialog, class Record, typename Id> | 326 | template<class Dialog, class Record, typename Id> |
327 | void OModalHelper::cancel( TransactionID tid ) | 327 | void OModalHelper::cancel( TransactionID tid ) |
328 | { | 328 | { |
329 | /* wrong tid */ | 329 | /* wrong tid */ |
330 | if (!m_transactions.contains( tid ) && !m_done.contains( tid) ) | 330 | if (!m_transactions.contains( tid ) && !m_done.contains( tid) ) |
331 | return; | 331 | return; |
332 | 332 | ||
333 | if (m_mode == New ) | 333 | if (m_mode == New ) |
334 | /* reverse map eek */ | 334 | /* reverse map eek */ |
335 | for (DialogMap::Iterator it = m_editing.begin(); it != m_editing.end(); ++it ) | 335 | for (DialogMap::Iterator it = m_editing.begin(); it != m_editing.end(); ++it ) |
336 | if ( it.data() == tid ) | 336 | if ( it.data() == tid ) |
337 | { | 337 | { |
338 | it.key()->hide(); | 338 | it.key()->hide(); |
339 | delete it.key(); | 339 | delete it.key(); |
340 | it = m_editing.remove( it ); | 340 | it = m_editing.remove( it ); |
341 | break; | 341 | break; |
342 | } | 342 | } |
343 | 343 | ||
344 | /* now remove from the various maps done and currently editing map*/ | 344 | /* now remove from the various maps done and currently editing map*/ |
345 | if (m_transactions.contains( tid ) ) | 345 | if (m_transactions.contains( tid ) ) |
346 | m_ids.remove( m_transactions[tid] ); | 346 | m_ids.remove( m_transactions[tid] ); |
347 | if (m_done.contains( tid ) ) | 347 | if (m_done.contains( tid ) ) |
348 | m_doneIds.remove( m_done[tid ] ); | 348 | m_doneIds.remove( m_done[tid ] ); |
349 | m_done.remove( tid ); | 349 | m_done.remove( tid ); |
350 | m_transactions.remove( tid ); | 350 | m_transactions.remove( tid ); |
351 | 351 | ||
352 | next( 0 ); | 352 | next( 0 ); |
353 | } | 353 | } |
354 | 354 | ||
355 | /** | 355 | /** |
356 | * Connect to the done Signal. SIGNAL( done(int, TransactionID ) ) | 356 | * Connect to the done Signal. SIGNAL( done(int, TransactionID ) ) |
357 | * This signal gets emitted whenever a Record was accepted or rejected | 357 | * This signal gets emitted whenever a Record was accepted or rejected |
358 | * | 358 | * |
359 | * @param rec The object where the slot belongs to | 359 | * @param rec The object where the slot belongs to |
360 | * @param slot The slot which should be called. See the needed parameter above | 360 | * @param slot The slot which should be called. See the needed parameter above |
361 | */ | 361 | */ |
362 | template<class Dialog, class Record, typename Id> | 362 | template<class Dialog, class Record, typename Id> |
363 | void OModalHelper<Dialog, Record, Id>::connectDone( QObject* rec, const char* slot ) | 363 | void OModalHelper<Dialog, Record, Id>::connectDone( QObject* rec, const char* slot ) |
364 | { | 364 | { |
365 | QObject::connect(m_signal, SIGNAL(done(int, TransactionID) ), | 365 | QObject::connect(m_signal, SIGNAL(done(int, TransactionID) ), |
366 | rec, slot ); | 366 | rec, slot ); |
367 | } | 367 | } |
368 | 368 | ||
369 | /** | 369 | /** |
370 | * Connect to the accepted Signal. SIGNAL( accepted(TransactionID ) ) | 370 | * Connect to the accepted Signal. SIGNAL( accepted(TransactionID ) ) |
371 | * This signal gets emitted whenever a Record was accepted | 371 | * This signal gets emitted whenever a Record was accepted |
372 | * | 372 | * |
373 | * @param rec The object where the slot belongs to | 373 | * @param rec The object where the slot belongs to |
374 | * @param slot The slot which should be called. See the needed parameter above | 374 | * @param slot The slot which should be called. See the needed parameter above |
375 | */ | 375 | */ |
376 | template<class Dialog, class Record, typename Id> | 376 | template<class Dialog, class Record, typename Id> |
377 | void OModalHelper<Dialog, Record, Id>::connectAccepted( QObject* rec, const char* slot ) | 377 | void OModalHelper<Dialog, Record, Id>::connectAccepted( QObject* rec, const char* slot ) |
378 | { | 378 | { |
379 | QObject::connect(m_signal, SIGNAL(accepted(TransactionID) ), | 379 | QObject::connect(m_signal, SIGNAL(accepted(TransactionID) ), |
380 | rec, slot ); | 380 | rec, slot ); |
381 | } | 381 | } |
382 | 382 | ||
383 | /** | 383 | /** |
384 | * Same as the accepted method but this one gets emitted if the dialog | 384 | * Same as the accepted method but this one gets emitted if the dialog |
385 | * got rejected. | 385 | * got rejected. |
386 | * SIGNAL( rejected(TransactionID) ) | 386 | * SIGNAL( rejected(TransactionID) ) |
387 | * | 387 | * |
388 | * @param rec The QObject of the slot | 388 | * @param rec The QObject of the slot |
389 | * @param slot The slot make sure the signature is correct | 389 | * @param slot The slot make sure the signature is correct |
390 | */ | 390 | */ |
391 | template<class Dialog, class Record, typename Id> | 391 | template<class Dialog, class Record, typename Id> |
392 | void OModalHelper<Dialog, Record, Id>::connectRejected( QObject* rec, const char* slot ) | 392 | void OModalHelper<Dialog, Record, Id>::connectRejected( QObject* rec, const char* slot ) |
393 | { | 393 | { |
394 | QObject::connect(m_signal, SIGNAL(rejected(TransactionID) ), | 394 | QObject::connect(m_signal, SIGNAL(rejected(TransactionID) ), |
395 | rec, slot ); | 395 | rec, slot ); |
396 | } | 396 | } |
397 | 397 | ||
398 | /** | 398 | /** |
399 | * Tell the helper to handle a record. If the record is currently handled | 399 | * Tell the helper to handle a record. If the record is currently handled |
400 | * it will be made active. | 400 | * it will be made active. |
401 | * Already handled record which are waiting getting popped are not taken into account | 401 | * Already handled record which are waiting getting popped are not taken into account |
402 | * Otherwise this helpers make the record editable. | 402 | * Otherwise this helpers make the record editable. |
403 | * The record supplied needs to have a valid copy operator and constructor. | 403 | * The record supplied needs to have a valid copy operator and constructor. |
404 | * In the case where the record is already present the parameter gets discarded. | 404 | * In the case where the record is already present the parameter gets discarded. |
405 | * If you want the new record to be taken you need to cancel the Transaction first | 405 | * If you want the new record to be taken you need to cancel the Transaction first |
406 | * | 406 | * |
407 | * @param id The Identification of the Record. For PIM it would uid() | 407 | * @param id The Identification of the Record. For PIM it would uid() |
408 | * @param rec The record we want to be edited | 408 | * @param rec The record we want to be edited |
409 | * | 409 | * |
410 | * @returns This functions returns the TransactionId assigned to the record | 410 | * @returns This functions returns the TransactionId assigned to the record |
411 | * | 411 | * |
412 | */ | 412 | */ |
413 | template<class Dialog, class Record, typename Id> | 413 | template<class Dialog, class Record, typename Id> |
414 | TransactionID OModalHelper<Dialog, Record, Id>::handle( Id id, const Record& rec ) | 414 | TransactionID OModalHelper<Dialog, Record, Id>::handle( Id id, const Record& rec ) |
415 | { | 415 | { |
416 | static TransactionID t_id = 0; | 416 | static TransactionID t_id = 0; |
417 | /* | 417 | /* |
418 | *this method consists out of two parts divided each into New and Queued Mode. | 418 | *this method consists out of two parts divided each into New and Queued Mode. |
419 | * Either we have the dialog already, in this case we need to highlight the widget | 419 | * Either we have the dialog already, in this case we need to highlight the widget |
420 | * Or we need to add it. | 420 | * Or we need to add it. |
421 | */ | 421 | */ |
422 | TransactionID tid = 0; | 422 | TransactionID tid = 0; |
423 | /* we already have the record lets see if it was done or not */ | 423 | /* we already have the record lets see if it was done or not */ |
424 | if ( !(tid = transactionID( id ) ) ) | 424 | if ( !(tid = transactionID( id ) ) ) |
425 | { | 425 | { |
426 | if (m_mode == New ) | 426 | if (m_mode == New ) |
427 | { | 427 | { |
428 | /* lets find the dialog and show it need to reverse map*/ | 428 | /* lets find the dialog and show it need to reverse map*/ |
429 | for (DialogMap::Iterator it = m_editing.begin(); it != m_editing.end(); ++it ) | 429 | for (DialogMap::Iterator it = m_editing.begin(); it != m_editing.end(); ++it ) |
430 | if ( it.data() == tid ) | 430 | if ( it.data() == tid ) |
431 | it.key()->show(); | 431 | it.key()->show(); |
432 | } | 432 | } |
433 | else if (m_controler->transactionID() != tid ) | 433 | else if (m_controler->transactionID() != tid ) |
434 | { | 434 | { |
435 | int po = pos( tid ); | 435 | int po = pos( tid ); |
436 | m_controler->setTransactionID( tid ); | 436 | m_controler->setTransactionID( tid ); |
437 | static_cast<Dialog*>( queuedDialog()->centerDialog() )->setRecord( m_ids[ m_transactions[tid] ] ); | 437 | static_cast<Dialog*>( queuedDialog()->centerDialog() )->setRecord( m_ids[ m_transactions[tid] ] ); |
438 | queuedDialog()->setRecord( po, m_transactions.count() ); | 438 | queuedDialog()->setRecord( po, m_transactions.count() ); |
439 | } | 439 | } |
440 | } | 440 | } |
441 | else | 441 | else |
442 | { | 442 | { |
443 | tid = ++t_id; | 443 | tid = ++t_id; |
444 | m_transactions.insert( tid, id ); | 444 | m_transactions.insert( tid, id ); |
445 | m_ids.insert( id, rec ); | 445 | m_ids.insert( id, rec ); |
446 | 446 | ||
447 | if (m_mode == New ) | 447 | if (m_mode == New ) |
448 | m_editing.insert( newDialogRecord( rec ), tid ); | 448 | m_editing.insert( newDialogRecord( rec ), tid ); |
449 | else | 449 | else |
450 | { | 450 | { |
451 | m_controler->setTransactionID( tid ); | 451 | m_controler->setTransactionID( tid ); |
452 | static_cast<Dialog*>( queuedDialog()->centerDialog() )->setRecord( rec ); | 452 | static_cast<Dialog*>( queuedDialog()->centerDialog() )->setRecord( rec ); |
453 | queuedDialog()->setRecord( m_transactions.count(), m_transactions.count() ); | 453 | queuedDialog()->setRecord( m_transactions.count(), m_transactions.count() ); |
454 | } | 454 | } |
455 | } | 455 | } |
456 | return tid; | 456 | return tid; |
457 | } | 457 | } |
458 | 458 | ||
459 | /** | 459 | /** |
460 | * The goal of this helper is to help you to create non blocking | 460 | * The goal of this helper is to help you to create non blocking |
461 | * GUIs. In the example of the todolist you can have the edit dialog | 461 | * GUIs. In the example of the todolist you can have the edit dialog |
462 | * but still change the priority or completion inline even if you currently | 462 | * but still change the priority or completion inline even if you currently |
463 | * edit the record. | 463 | * edit the record. |
464 | * Your Dialog needs to have a Method setData(int,const QVariant& ) which will be called | 464 | * Your Dialog needs to have a Method setData(int,const QVariant& ) which will be called |
465 | * in these cases. | 465 | * in these cases. |
466 | * If you edit anything while a record is edited call this function to merge the | 466 | * If you edit anything while a record is edited call this function to merge the |
467 | * change in. Note if the record is not handled here we will ignore the request | 467 | * change in. Note if the record is not handled here we will ignore the request |
468 | * | 468 | * |
469 | */ | 469 | */ |
470 | template<class Dialog, class Record, typename Id> | 470 | template<class Dialog, class Record, typename Id> |
471 | void OModalHelper<Dialog, Record, Id>::edited( Id id, int what, const QVariant& data ) | 471 | void OModalHelper<Dialog, Record, Id>::edited( Id id, int what, const QVariant& data ) |
472 | { | 472 | { |
473 | int tid; | 473 | int tid; |
474 | if (!( tid = transactionID( id ) ) ) | 474 | if (!( tid = transactionID( id ) ) ) |
475 | return; | 475 | return; |
476 | 476 | ||
477 | if (m_mode == New ) | 477 | if (m_mode == New ) |
478 | { | 478 | { |
479 | for (DialogMap::Iterator it= m_editing.begin(); it != m_editing.end(); ++it ) | 479 | for (DialogMap::Iterator it= m_editing.begin(); it != m_editing.end(); ++it ) |
480 | if ( it.data() == tid ) | 480 | if ( it.data() == tid ) |
481 | it.key()->setData( what, data ); | 481 | it.key()->setData( what, data ); |
482 | } | 482 | } |
483 | else | 483 | else |
484 | { | 484 | { |
485 | int po = pos( tid ); | 485 | int po = pos( tid ); |
486 | Dialog* dia = static_cast<Dialog*>( queuedDialog()->centerDialog() ); | 486 | Dialog* dia = static_cast<Dialog*>( queuedDialog()->centerDialog() ); |
487 | dia->setRecord( m_ids[id] ); | 487 | dia->setRecord( m_ids[id] ); |
488 | dia->setData( what, data ); | 488 | dia->setData( what, data ); |
489 | queuedDialog()->setRecord( pos, m_transactions.count() ); | 489 | queuedDialog()->setRecord( pos, m_transactions.count() ); |
490 | } | 490 | } |
491 | } | 491 | } |
492 | 492 | ||
493 | /** | 493 | /** |
494 | * This functions either returns the unedited record the done record | 494 | * This functions either returns the unedited record the done record |
495 | * or a new empty Record using Record(). | 495 | * or a new empty Record using Record(). |
496 | * If a done record is retrieved all traces are removed inside this class. This | 496 | * If a done record is retrieved all traces are removed inside this class. This |
497 | * is what was called popping a record. This means when you call this function | 497 | * is what was called popping a record. This means when you call this function |
498 | * with the same TransactionID an Empty record is retrieved. | 498 | * with the same TransactionID an Empty record is retrieved. |
499 | * | 499 | * |
500 | */ | 500 | */ |
501 | template<class Dialog, class Record, typename Id> | 501 | template<class Dialog, class Record, typename Id> |
502 | Record OModalHelper<Dialog, Record, Id>::record( TransactionID tid)const | 502 | Record OModalHelper<Dialog, Record, Id>::record( TransactionID tid)const |
503 | { | 503 | { |
504 | if (m_transactions.contains( tid ) ) | 504 | if (m_transactions.contains( tid ) ) |
505 | return m_ids[ m_transactions[tid] ]; | 505 | return m_ids[ m_transactions[tid] ]; |
506 | else if (m_done.contains( tid ) ) | 506 | else if (m_done.contains( tid ) ) |
507 | { | 507 | { |
508 | Record rec = m_doneIds[ m_done[ tid] ]; | 508 | Record rec = m_doneIds[ m_done[ tid] ]; |
509 | m_doneIds.remove( m_done[ tid ] ); | 509 | m_doneIds.remove( m_done[ tid ] ); |
510 | m_done.remove( tid ); | 510 | m_done.remove( tid ); |
511 | return rec; | 511 | return rec; |
512 | } | 512 | } |
513 | else | 513 | else |
514 | return Record(); | 514 | return Record(); |
515 | } | 515 | } |
516 | 516 | ||
517 | /** | 517 | /** |
518 | * Returns all done Records and removes all references to them internally. A 2nd call to this will | 518 | * Returns all done Records and removes all references to them internally. A 2nd call to this will |
519 | * only contain done record that where edited past the point | 519 | * only contain done record that where edited past the point |
520 | */ | 520 | */ |
521 | template<class Dialog, class Record, typename Id> | 521 | template<class Dialog, class Record, typename Id> |
522 | OModalHelper<Dialog,Record,Id>::RecordList OModalHelper<Dialog, Record, Id>::recordsDone()const | 522 | OModalHelper<Dialog,Record,Id>::RecordList OModalHelper<Dialog, Record, Id>::recordsDone()const |
523 | { | 523 | { |
524 | RecordList list; | 524 | RecordList list; |
525 | 525 | ||
526 | for (IdMap::ConstIterator it = m_doneIds.begin(); it != m_doneIds.end(); ++it ) | 526 | for (IdMap::ConstIterator it = m_doneIds.begin(); it != m_doneIds.end(); ++it ) |
527 | list.append( it.data() ); | 527 | list.append( it.data() ); |
528 | 528 | ||
529 | /* clean up */ | 529 | /* clean up */ |
530 | m_done.clear(); | 530 | m_done.clear(); |
531 | m_doneIds.clear(); | 531 | m_doneIds.clear(); |
532 | 532 | ||
533 | return list; | 533 | return list; |
534 | } | 534 | } |
535 | 535 | ||
536 | 536 | ||
537 | /** | 537 | /** |
538 | * @internal | 538 | * @internal |
539 | */ | 539 | */ |
540 | template<class Dialog, class Record, typename Id> | 540 | template<class Dialog, class Record, typename Id> |
541 | void OModalHelper<Dialog, Record, Id>::done( int status, TransactionID tid) | 541 | void OModalHelper<Dialog, Record, Id>::done( int status, TransactionID tid) |
542 | { | 542 | { |
543 | /* If we're in New mode the transaction Id does not count */ | 543 | /* If we're in New mode the transaction Id does not count */ |
544 | Record rec; | 544 | Record rec; |
545 | 545 | ||
546 | if (m_mode == New ) | 546 | if (m_mode == New ) |
547 | { | 547 | { |
548 | Dialog *dia = static_cast<Dialog*>( m_controler->dialog() ); | 548 | Dialog *dia = static_cast<Dialog*>( m_controler->dialog() ); |
549 | m_controler->setTransactionID( 0 ); // set the internal dialog to 0l again | 549 | m_controler->setTransactionID( 0 ); // set the internal dialog to 0l again |
550 | tid = m_editing[ dia ]; | 550 | tid = m_editing[ dia ]; |
551 | m_editing.remove( dia ); | 551 | m_editing.remove( dia ); |
552 | rec = dia->record(); | 552 | rec = dia->record(); |
553 | delete dia; | 553 | delete dia; |
554 | } | 554 | } |
555 | else | 555 | else |
556 | rec = queuedDialog()->record(); | 556 | rec = queuedDialog()->record(); |
557 | 557 | ||
558 | Id id = m_transactions[ tid ]; | 558 | Id id = m_transactions[ tid ]; |
559 | if (result == QDialog::Accept ) | 559 | if (result == QDialog::Accept ) |
560 | { | 560 | { |
561 | m_doneIds.insert( is, rec ); | 561 | m_doneIds.insert( is, rec ); |
562 | m_done.insert( tid, id ); | 562 | m_done.insert( tid, id ); |
563 | } | 563 | } |
564 | 564 | ||
565 | m_transactions.remove( tid ); | 565 | m_transactions.remove( tid ); |
566 | m_ids.remove( id ); | 566 | m_ids.remove( id ); |
567 | 567 | ||
568 | 568 | ||
569 | if (status == QDialog::Accept ) | 569 | if (status == QDialog::Accept ) |
570 | emit m_signal->accepted( tid ); | 570 | emit m_signal->accepted( tid ); |
571 | else | 571 | else |
572 | emit m_signal->rejected( tid ); | 572 | emit m_signal->rejected( tid ); |
573 | 573 | ||
574 | emit m_signal->done( result, tid ); | 574 | emit m_signal->done( result, tid ); |
575 | 575 | ||
576 | next( 0 ); | 576 | next( 0 ); |
577 | } | 577 | } |
578 | 578 | ||
579 | /** | 579 | /** |
580 | * @internal | 580 | * @internal |
581 | */ | 581 | */ |
582 | template<class Dialog, class Record, typename Id> | 582 | template<class Dialog, class Record, typename Id> |
583 | void OModalHelper<Dialog, Record, Id>::next( TransactionID tid) | 583 | void OModalHelper<Dialog, Record, Id>::next( TransactionID tid) |
584 | { | 584 | { |
585 | if (m_mode == New ) | 585 | if (m_mode == New ) |
586 | return; | 586 | return; |
587 | 587 | ||
588 | if (! (m_transactions.count() ) ) | 588 | if (! (m_transactions.count() ) ) |
589 | { | 589 | { |
590 | m_controler->setTransactionID( 0 ); | 590 | m_controler->setTransactionID( 0 ); |
591 | queuedDialog()->setRecord( 0, 0 ); | 591 | queuedDialog()->setRecord( 0, 0 ); |
592 | return; | 592 | return; |
593 | } | 593 | } |
594 | 594 | ||
595 | int next; | 595 | int next; |
596 | Record rec; | 596 | Record rec; |
597 | 597 | ||
598 | /* save the maybe edited record before switching */ | 598 | /* save the maybe edited record before switching */ |
599 | Dialog *dia = static_cast<Dialog*>( queuedDialog()->centerDialog() ); | 599 | Dialog *dia = static_cast<Dialog*>( queuedDialog()->centerDialog() ); |
600 | rec = dia->record(); | 600 | rec = dia->record(); |
601 | m_ids.replace( m_transactions[tid], rec ); | 601 | m_ids.replace( m_transactions[tid], rec ); |
602 | 602 | ||
603 | rec = nextRecord( tid, next ); | 603 | rec = nextRecord( tid, next ); |
604 | queuedDialog()->setRecord( next, m_transactions.count() ); | 604 | queuedDialog()->setRecord( next, m_transactions.count() ); |
605 | dia->setRecord( rec ); | 605 | dia->setRecord( rec ); |
606 | 606 | ||
607 | m_controler->setTransactionID( tid ); // was changed during the next call | 607 | m_controler->setTransactionID( tid ); // was changed during the next call |
608 | } | 608 | } |
609 | 609 | ||
610 | /** | 610 | /** |
611 | * @internal | 611 | * @internal |
612 | */ | 612 | */ |
613 | /* | 613 | /* |
614 | * code duplication should create a template fcuntion | 614 | * code duplication should create a template fcuntion |
615 | * which takes a pointer to a function ( next, prev ) function | 615 | * which takes a pointer to a function ( next, prev ) function |
616 | */ | 616 | */ |
617 | template<class Dialog, class Record, typename Id> | 617 | template<class Dialog, class Record, typename Id> |
618 | void OModalHelper<Dialog, Record, Id>::prev( TransactionID tid ) | 618 | void OModalHelper<Dialog, Record, Id>::prev( TransactionID tid ) |
619 | { | 619 | { |
620 | if (m_mode == New ) | 620 | if (m_mode == New ) |
621 | return; | 621 | return; |
622 | 622 | ||
623 | if (! (m_transactions.count()) ) | 623 | if (! (m_transactions.count()) ) |
624 | { | 624 | { |
625 | m_controler->setTransactionID( 0 ); | 625 | m_controler->setTransactionID( 0 ); |
626 | queuedDialog()->setRecord( 0, 0 ); | 626 | queuedDialog()->setRecord( 0, 0 ); |
627 | return; | 627 | return; |
628 | } | 628 | } |
629 | 629 | ||
630 | int prev; | 630 | int prev; |
631 | Record rec; | 631 | Record rec; |
632 | 632 | ||
633 | /* save the maybe edited record before switching */ | 633 | /* save the maybe edited record before switching */ |
634 | Dialog *dia = static_cast<Dialog*>( queuedDialog()->centerDialog() ); | 634 | Dialog *dia = static_cast<Dialog*>( queuedDialog()->centerDialog() ); |
635 | rec = dia->record(); | 635 | rec = dia->record(); |
636 | m_ids.replace( m_transactions[tid], rec ); | 636 | m_ids.replace( m_transactions[tid], rec ); |
637 | 637 | ||
638 | rec = prevRecord( tid, prev ); | 638 | rec = prevRecord( tid, prev ); |
639 | queuedDialog()->setRecord( prev, m_transactions.count() ); | 639 | queuedDialog()->setRecord( prev, m_transactions.count() ); |
640 | dia->setRecord( rec ); | 640 | dia->setRecord( rec ); |
641 | 641 | ||
642 | m_controler->setTransactionID( tid ); // was changed during the next call | 642 | m_controler->setTransactionID( tid ); // was changed during the next call |
643 | } | 643 | } |
644 | 644 | ||
645 | /** | 645 | /** |
646 | * @internal | 646 | * @internal |
647 | */ | 647 | */ |
648 | template<class Dialog, class Record, typename Id> | 648 | template<class Dialog, class Record, typename Id> |
649 | Record OModalHelper<Dialog, Record, Id>::nextRecord( TransactionID &tid, int &po ) | 649 | Record OModalHelper<Dialog, Record, Id>::nextRecord( TransactionID &tid, int &po ) |
650 | { | 650 | { |
651 | /* if tid is == 0 we will take the first one */ | 651 | /* if tid is == 0 we will take the first one */ |
652 | /* pos starts at 1 here */ | 652 | /* pos starts at 1 here */ |
653 | /* we know we're only called if there are records */ | 653 | /* we know we're only called if there are records */ |
654 | Record rec; | 654 | Record rec; |
655 | TransactionMap::Iterator it; | 655 | TransactionMap::Iterator it; |
656 | if (!tid ) | 656 | if (!tid ) |
657 | { | 657 | { |
658 | po = 1; | 658 | po = 1; |
659 | TransactionMap::Iterator it = m_transactions.begin(); | 659 | TransactionMap::Iterator it = m_transactions.begin(); |
660 | } | 660 | } |
661 | else | 661 | else |
662 | { | 662 | { |
663 | po = pos( tid ); | 663 | po = pos( tid ); |
664 | /* if it is the last take the first as next */ | 664 | /* if it is the last take the first as next */ |
665 | if ( po == m_transactions.count() ) | 665 | if ( po == m_transactions.count() ) |
666 | { | 666 | { |
667 | po = 1; | 667 | po = 1; |
668 | it = m_transactions.begin(); | 668 | it = m_transactions.begin(); |
669 | } | 669 | } |
670 | else | 670 | else |
671 | { | 671 | { |
672 | /* we know we're not the last and there is one after us */ | 672 | /* we know we're not the last and there is one after us */ |
673 | it = m_transactions.find( tid ); | 673 | it = m_transactions.find( tid ); |
674 | ++it; ++po; | 674 | ++it; ++po; |
675 | } | 675 | } |
676 | } | 676 | } |
677 | 677 | ||
678 | tid = it.key(); | 678 | tid = it.key(); |
679 | rec = m_ids[ tid ]; | 679 | rec = m_ids[ tid ]; |
680 | return rec; | 680 | return rec; |
681 | } | 681 | } |
682 | 682 | ||
683 | /** | 683 | /** |
684 | * @internal | 684 | * @internal |
685 | */ | 685 | */ |
686 | template<class Dialog, class Record, typename Id> | 686 | template<class Dialog, class Record, typename Id> |
687 | Record OModalHelper<Dialog, Record, Id>::prevRecord( TransactionID& tid, int& pos ) | 687 | Record OModalHelper<Dialog, Record, Id>::prevRecord( TransactionID& tid, int& pos ) |
688 | { | 688 | { |
689 | /* if tid is == 0 we will take the first one */ | 689 | /* if tid is == 0 we will take the first one */ |
690 | /* pos starts at 1 here */ | 690 | /* pos starts at 1 here */ |
691 | /* we know we're only called if there are records */ | 691 | /* we know we're only called if there are records */ |
692 | Record rec; | 692 | Record rec; |
693 | TransactionMap::Iterator it; | 693 | TransactionMap::Iterator it; |
694 | if (!tid ) | 694 | if (!tid ) |
695 | { | 695 | { |
696 | po = 1; | 696 | po = 1; |
697 | TransactionMap::Iterator it = m_transactions.begin(); | 697 | TransactionMap::Iterator it = m_transactions.begin(); |
698 | } | 698 | } |
699 | else | 699 | else |
700 | { | 700 | { |
701 | po = pos( tid ); | 701 | po = pos( tid ); |
702 | /* if it is the last take the first as next */ | 702 | /* if it is the last take the first as next */ |
703 | if ( po == 1 ) | 703 | if ( po == 1 ) |
704 | { | 704 | { |
705 | po = m_transactions.count(); | 705 | po = m_transactions.count(); |
706 | it = m_transactions.end(); | 706 | it = m_transactions.end(); |
707 | --it; | 707 | --it; |
708 | } | 708 | } |
709 | else | 709 | else |
710 | { | 710 | { |
711 | /* we know we're not the first and there is one before us */ | 711 | /* we know we're not the first and there is one before us */ |
712 | it = m_transactions.find( tid ); | 712 | it = m_transactions.find( tid ); |
713 | --it; --po; | 713 | --it; --po; |
714 | } | 714 | } |
715 | } | 715 | } |
716 | 716 | ||
717 | tid = it.key(); | 717 | tid = it.key(); |
718 | rec = m_ids[ tid ]; | 718 | rec = m_ids[ tid ]; |
719 | return rec; | 719 | return rec; |
720 | } | 720 | } |
721 | 721 | ||
722 | /** | 722 | /** |
723 | * @internal | 723 | * @internal |
724 | */ | 724 | */ |
725 | template<class Dialog, class Record, typename Id> | 725 | template<class Dialog, class Record, typename Id> |
726 | int OModalHelper<Dialog, Record, Id>::pos( TransactionID id)const | 726 | int OModalHelper<Dialog, Record, Id>::pos( TransactionID id)const |
727 | { | 727 | { |
728 | int i = 1; | 728 | int i = 1; |
729 | for ( TransactionMap::ConstIterator it = m_transactions.begin(); it != m_transactions.end(); ++it, i++ ) | 729 | for ( TransactionMap::ConstIterator it = m_transactions.begin(); it != m_transactions.end(); ++it, i++ ) |
730 | if ( it.key() == id ) | 730 | if ( it.key() == id ) |
731 | return i; | 731 | return i; |
732 | 732 | ||
733 | 733 | ||
734 | return 0; | 734 | return 0; |
735 | } | 735 | } |
736 | 736 | ||
737 | /** | 737 | /** |
738 | * @internal | 738 | * @internal |
739 | */ | 739 | */ |
740 | template<class Dialog, class Record, typename Id> | 740 | template<class Dialog, class Record, typename Id> |
741 | Dialog* OModalHelper<Dialog, Record, Id>::newDialogRecord( const Record& rec ) | 741 | Dialog* OModalHelper<Dialog, Record, Id>::newDialogRecord( const Record& rec ) |
742 | { | 742 | { |
743 | Dialog* dia = new Dialog; | 743 | Dialog* dia = new Dialog; |
744 | dia->setRecord( rec ); | 744 | dia->setRecord( rec ); |
745 | dia->setDisabled( m_disabled ); | 745 | dia->setDisabled( m_disabled ); |
746 | 746 | ||
747 | QObject::connect(dia, SIGNAL(done(int) ), | 747 | QObject::connect(dia, SIGNAL(done(int) ), |
748 | m_controler, SLOT(done(int) ) ); | 748 | m_controler, SLOT(done(int) ) ); |
749 | 749 | ||
750 | /* FIXME big screen QPEApplication needs fixed*/ | 750 | /* FIXME big screen QPEApplication needs fixed*/ |
751 | dia->show(); | 751 | dia->show(); |
752 | } | 752 | } |
753 | 753 | ||
754 | template<class Record, class Dialog, typename Id> | 754 | template<class Record, class Dialog, typename Id> |
755 | OModalHelperDialog* OModalHelper<Record, Dialog, Id>::queuedDialog()const | 755 | OModalHelperDialog* OModalHelper<Record, Dialog, Id>::queuedDialog()const |
756 | { | 756 | { |
757 | if (!m_dialog ) | 757 | if (!m_dialog ) |
758 | { | 758 | { |
759 | m_dialog = new OModalHelperDialog; | 759 | m_dialog = new OModalHelperDialog; |
760 | m_dialog->setEnabled( m_disabled ); | 760 | m_dialog->setEnabled( m_disabled ); |
761 | 761 | ||
762 | QObject::connect(m_dialog, SIGNAL(done(int) ), | 762 | QObject::connect(m_dialog, SIGNAL(done(int) ), |
763 | m_controler, SLOT(done(int) ) ); | 763 | m_controler, SLOT(done(int) ) ); |
764 | QObject::connect(m_dialog, SIGNAL(next() ), | 764 | QObject::connect(m_dialog, SIGNAL(next() ), |
765 | m_controler, SLOT(next() ) ); | 765 | m_controler, SLOT(next() ) ); |
766 | QObject::connect(m_dialog, SIGNAL(prev() ), | 766 | QObject::connect(m_dialog, SIGNAL(prev() ), |
767 | m_controler, SLOT(prev() ) ); | 767 | m_controler, SLOT(prev() ) ); |
768 | } | 768 | } |
769 | return m_dialog; | 769 | return m_dialog; |
770 | } | 770 | } |
771 | 771 | ||
772 | }; | 772 | }; |
773 | 773 | ||
774 | #endif | 774 | #endif |
diff --git a/libopie2/opieui/otabinfo.h b/libopie2/opieui/otabinfo.h index 426c45a..d6d5abf 100644 --- a/libopie2/opieui/otabinfo.h +++ b/libopie2/opieui/otabinfo.h | |||
@@ -1,141 +1,136 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | 4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef OTABINFO_H | 32 | #ifndef OTABINFO_H |
33 | #define OTABINFO_H | 33 | #define OTABINFO_H |
34 | 34 | ||
35 | /* QT */ | 35 | /* QT */ |
36 | #include <qlist.h> | 36 | #include <qlist.h> |
37 | #include <qstring.h> | 37 | #include <qstring.h> |
38 | 38 | ||
39 | class QWidget; | 39 | class QWidget; |
40 | 40 | ||
41 | namespace Opie{ | 41 | namespace Opie{ |
42 | namespace Ui { | 42 | namespace Ui { |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * @class OTabInfo | 45 | * @class OTabInfo |
46 | * @brief The OTabInfo class is used internally by OTabWidget to keep track | 46 | * @brief The OTabInfo class is used internally by OTabWidget to keep track |
47 | * of widgets added to the control. | 47 | * of widgets added to the control. |
48 | * | 48 | * |
49 | * OTabInfo provides the following information about a widget added to an | 49 | * OTabInfo provides the following information about a widget added to an |
50 | * OTabWidget control: | 50 | * OTabWidget control: |
51 | * | 51 | * |
52 | * ID - integer tab bar ID | 52 | * ID - integer tab bar ID |
53 | * Control - QWidget pointer to child widget | 53 | * Control - QWidget pointer to child widget |
54 | * Label - QString text label for OTabWidget selection control | 54 | * Label - QString text label for OTabWidget selection control |
55 | * Icon - QString name of icon file | 55 | * Icon - QString name of icon file |
56 | */ | 56 | */ |
57 | class OTabInfo | 57 | class OTabInfo |
58 | { | 58 | { |
59 | public: | 59 | public: |
60 | /** | 60 | /** |
61 | * @fn OTabInfo() | 61 | * @fn OTabInfo() |
62 | * @brief Object constructor. | 62 | * @brief Object constructor. |
63 | * | ||
64 | * @param parent Pointer to parent of this control. | ||
65 | * @param name Name of control. | ||
66 | * @param s Style of widget selection control. | ||
67 | * @param p Position of the widget selection control. | ||
68 | */ | 63 | */ |
69 | OTabInfo() : i( -1 ), c( 0 ), p( 0 ), l( QString::null ) {} | 64 | OTabInfo() : i( -1 ), c( 0 ), p( 0 ), l( QString::null ) {} |
70 | 65 | ||
71 | /** | 66 | /** |
72 | * @fn OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) | 67 | * @fn OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) |
73 | * @brief Object constructor. | 68 | * @brief Object constructor. |
74 | * | 69 | * |
75 | * @param id TabBar identifier for widget. | 70 | * @param id TabBar identifier for widget. |
76 | * @param control QWidget pointer to widget. | 71 | * @param control QWidget pointer to widget. |
77 | * @param icon QString name of icon file. | 72 | * @param icon QString name of icon file. |
78 | * @param label QString text label for OTabWidget selection control. | 73 | * @param label QString text label for OTabWidget selection control. |
79 | */ | 74 | */ |
80 | OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) | 75 | OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) |
81 | : i( id ), c( control ), p( icon ), l( label ) {} | 76 | : i( id ), c( control ), p( icon ), l( label ) {} |
82 | 77 | ||
83 | /** | 78 | /** |
84 | * @fn id()const | 79 | * @fn id()const |
85 | * @brief Returns TabBar ID. | 80 | * @brief Returns TabBar ID. |
86 | */ | 81 | */ |
87 | int id() const { return i; } | 82 | int id() const { return i; } |
88 | 83 | ||
89 | /** | 84 | /** |
90 | * @fn label()const | 85 | * @fn label()const |
91 | * @brief Returns text label for widget. | 86 | * @brief Returns text label for widget. |
92 | */ | 87 | */ |
93 | const QString &label() const { return l; } | 88 | const QString &label() const { return l; } |
94 | 89 | ||
95 | /** | 90 | /** |
96 | * @fn setLabel( const QString &label ) | 91 | * @fn setLabel( const QString &label ) |
97 | * @brief Set label for tab. | 92 | * @brief Set label for tab. |
98 | * | 93 | * |
99 | * @param label QString text label for OTabWidget selection control. | 94 | * @param label QString text label for OTabWidget selection control. |
100 | */ | 95 | */ |
101 | void setLabel( const QString &label ) { l = label; } | 96 | void setLabel( const QString &label ) { l = label; } |
102 | 97 | ||
103 | /** | 98 | /** |
104 | * @fn control()const | 99 | * @fn control()const |
105 | * @brief Returns pointer to widget. | 100 | * @brief Returns pointer to widget. |
106 | */ | 101 | */ |
107 | QWidget *control() const { return c; } | 102 | QWidget *control() const { return c; } |
108 | 103 | ||
109 | /** | 104 | /** |
110 | * @fn icon()const | 105 | * @fn icon()const |
111 | * @brief Returns name of icon file. | 106 | * @brief Returns name of icon file. |
112 | */ | 107 | */ |
113 | const QString &icon() const { return p; } | 108 | const QString &icon() const { return p; } |
114 | 109 | ||
115 | /** | 110 | /** |
116 | * @fn setIcon( const QString &icon ) | 111 | * @fn setIcon( const QString &icon ) |
117 | * @brief Set icon for tab. | 112 | * @brief Set icon for tab. |
118 | * | 113 | * |
119 | * @param icon QString name of icon file. | 114 | * @param icon QString name of icon file. |
120 | */ | 115 | */ |
121 | void setIcon( const QString &icon ) { p = icon; } | 116 | void setIcon( const QString &icon ) { p = icon; } |
122 | 117 | ||
123 | private: | 118 | private: |
124 | int i; | 119 | int i; |
125 | QWidget *c; | 120 | QWidget *c; |
126 | QString p; | 121 | QString p; |
127 | QString l; | 122 | QString l; |
128 | class Private; | 123 | class Private; |
129 | Private *d; | 124 | Private *d; |
130 | }; | 125 | }; |
131 | 126 | ||
132 | /** | 127 | /** |
133 | * @class OTabInfoList | 128 | * @class OTabInfoList |
134 | * @brief A list of OTabInfo objects used by OTabWidget. | 129 | * @brief A list of OTabInfo objects used by OTabWidget. |
135 | */ | 130 | */ |
136 | typedef QList<OTabInfo> OTabInfoList; | 131 | typedef QList<OTabInfo> OTabInfoList; |
137 | 132 | ||
138 | } | 133 | } |
139 | } | 134 | } |
140 | 135 | ||
141 | #endif | 136 | #endif |