-rw-r--r-- | examples/main-tab/simple.cpp | 2 | ||||
-rw-r--r-- | examples/simple-pim/simple.cpp | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/examples/main-tab/simple.cpp b/examples/main-tab/simple.cpp index 69dd00f..c5a6d5a 100644 --- a/examples/main-tab/simple.cpp +++ b/examples/main-tab/simple.cpp | |||
@@ -1,91 +1,91 @@ | |||
1 | #include <qaction.h> // action | 1 | #include <qaction.h> // action |
2 | #include <qmenubar.h> // menubar | 2 | #include <qmenubar.h> // menubar |
3 | #include <qtoolbar.h> // toolbar | 3 | #include <qtoolbar.h> // toolbar |
4 | #include <qlabel.h> // a label | 4 | #include <qlabel.h> // a label |
5 | #include <qpushbutton.h> // the header file for the QPushButton | 5 | #include <qpushbutton.h> // the header file for the QPushButton |
6 | #include <qlayout.h> | 6 | #include <qlayout.h> |
7 | 7 | ||
8 | #include <qpe/qpeapplication.h> // the QPEApplication | 8 | #include <qpe/qpeapplication.h> // the QPEApplication |
9 | #include <qpe/resource.h> | 9 | #include <qpe/resource.h> |
10 | #include <qpe/sound.h> | 10 | #include <qpe/sound.h> |
11 | 11 | ||
12 | #include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching | 12 | #include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching |
13 | #include <opie/otabwidget.h> | 13 | #include <opie/otabwidget.h> |
14 | 14 | ||
15 | #include "simple.h" | 15 | #include "simple.h" |
16 | 16 | ||
17 | /* | 17 | /* |
18 | * implementation of simple | 18 | * implementation of simple |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * The factory is used for quicklaunching | 22 | * The factory is used for quicklaunching |
23 | * It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro | 23 | * It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro |
24 | * | 24 | * |
25 | * Depending on the global quick launch setting this will create | 25 | * Depending on the global quick launch setting this will create |
26 | * either a main method or one for our component plugin system | 26 | * either a main method or one for our component plugin system |
27 | */ | 27 | */ |
28 | 28 | ||
29 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) | 29 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
30 | 30 | ||
31 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) | 31 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) |
32 | : QMainWindow( parent, name, fl ) { | 32 | : QMainWindow( parent, name, fl ) { |
33 | setCaption(tr("My MainWindow") ); | 33 | setCaption(tr("My MainWindow") ); |
34 | 34 | ||
35 | initUI(); | 35 | initUI(); |
36 | 36 | ||
37 | 37 | ||
38 | /* | 38 | /* |
39 | * Tab widget as central | 39 | * Tab widget as central |
40 | */ | 40 | */ |
41 | OTabWidget *tab = new OTabWidget(this); | 41 | OTabWidget *tab = new OTabWidget(this); |
42 | connect(tab, SIGNAL(currentChanged(QWidget*) ), | 42 | connect(tab, SIGNAL(currentChanged(QWidget*) ), |
43 | this, SLOT( slotCurrentChanged( QWidget* ) ) ); | 43 | this, SLOT( slotCurrentChanged(QWidget*) ) ); |
44 | setCentralWidget( tab ); | 44 | setCentralWidget( tab ); |
45 | 45 | ||
46 | Simple1 *simple1 = new Simple1( this ); | 46 | Simple1 *simple1 = new Simple1( this ); |
47 | tab->addTab( simple1, "new", tr("Simple1") ); | 47 | tab->addTab( simple1, "new", tr("Simple1") ); |
48 | tab->setCurrentTab( tr("Simple1") ); | 48 | tab->setCurrentTab( tr("Simple1") ); |
49 | 49 | ||
50 | Simple2 *simple2 = new Simple2( this ); | 50 | Simple2 *simple2 = new Simple2( this ); |
51 | tab->addTab( simple2, "trash", tr("Simple2") ); | 51 | tab->addTab( simple2, "trash", tr("Simple2") ); |
52 | 52 | ||
53 | m_oldCurrent = simple1; | 53 | m_oldCurrent = simple1; |
54 | 54 | ||
55 | connect(m_fire, SIGNAL(activated() ), | 55 | connect(m_fire, SIGNAL(activated() ), |
56 | simple1, SLOT(slotFire() ) ); | 56 | simple1, SLOT(slotFire() ) ); |
57 | } | 57 | } |
58 | 58 | ||
59 | MainWindow::~MainWindow() { | 59 | MainWindow::~MainWindow() { |
60 | // again nothing to delete because Qt takes care | 60 | // again nothing to delete because Qt takes care |
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | ||
64 | void MainWindow::setDocument( const QString& /*str*/ ) { | 64 | void MainWindow::setDocument( const QString& /*str*/ ) { |
65 | } | 65 | } |
66 | void MainWindow::slotCurrentChanged( QWidget *wid) { | 66 | void MainWindow::slotCurrentChanged( QWidget *wid) { |
67 | disconnect(m_fire, SIGNAL(activated() ), | 67 | disconnect(m_fire, SIGNAL(activated() ), |
68 | m_oldCurrent, SLOT(slotFire() ) ); | 68 | m_oldCurrent, SLOT(slotFire() ) ); |
69 | connect(m_fire, SIGNAL(activated() ), | 69 | connect(m_fire, SIGNAL(activated() ), |
70 | wid, SLOT(slotFire() ) ); | 70 | wid, SLOT(slotFire() ) ); |
71 | 71 | ||
72 | m_oldCurrent = wid; | 72 | m_oldCurrent = wid; |
73 | } | 73 | } |
74 | 74 | ||
75 | void MainWindow::initUI() { | 75 | void MainWindow::initUI() { |
76 | 76 | ||
77 | setToolBarsMovable( false ); | 77 | setToolBarsMovable( false ); |
78 | 78 | ||
79 | QToolBar *menuBarHolder = new QToolBar( this ); | 79 | QToolBar *menuBarHolder = new QToolBar( this ); |
80 | 80 | ||
81 | menuBarHolder->setHorizontalStretchable( true ); | 81 | menuBarHolder->setHorizontalStretchable( true ); |
82 | QMenuBar *mb = new QMenuBar( menuBarHolder ); | 82 | QMenuBar *mb = new QMenuBar( menuBarHolder ); |
83 | QToolBar *tb = new QToolBar( this ); | 83 | QToolBar *tb = new QToolBar( this ); |
84 | 84 | ||
85 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 85 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
86 | 86 | ||
87 | 87 | ||
88 | QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), | 88 | QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), |
89 | QString::null, 0, this, "quit_action" ); | 89 | QString::null, 0, this, "quit_action" ); |
90 | /* | 90 | /* |
91 | * Connect quit to the QApplication quit slot | 91 | * Connect quit to the QApplication quit slot |
diff --git a/examples/simple-pim/simple.cpp b/examples/simple-pim/simple.cpp index 3e9fcd3..029e71b 100644 --- a/examples/simple-pim/simple.cpp +++ b/examples/simple-pim/simple.cpp | |||
@@ -34,100 +34,100 @@ | |||
34 | * Depending on the global quick launch setting this will create | 34 | * Depending on the global quick launch setting this will create |
35 | * either a main method or one for our component plugin system | 35 | * either a main method or one for our component plugin system |
36 | */ | 36 | */ |
37 | 37 | ||
38 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) | 38 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
39 | 39 | ||
40 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) | 40 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) |
41 | : QMainWindow( parent, name, fl ) { | 41 | : QMainWindow( parent, name, fl ) { |
42 | setCaption(tr("My MainWindow") ); | 42 | setCaption(tr("My MainWindow") ); |
43 | 43 | ||
44 | m_desktopChannel = 0; | 44 | m_desktopChannel = 0; |
45 | m_loading = 0; | 45 | m_loading = 0; |
46 | 46 | ||
47 | initUI(); | 47 | initUI(); |
48 | 48 | ||
49 | 49 | ||
50 | /* | 50 | /* |
51 | * Tab widget as central | 51 | * Tab widget as central |
52 | */ | 52 | */ |
53 | m_tab = new OTabWidget(this); | 53 | m_tab = new OTabWidget(this); |
54 | 54 | ||
55 | setCentralWidget( m_tab ); | 55 | setCentralWidget( m_tab ); |
56 | 56 | ||
57 | m_todoView = new PIMListView(m_tab, "Todo view" ); | 57 | m_todoView = new PIMListView(m_tab, "Todo view" ); |
58 | m_tab->addTab( m_todoView,"todo/TodoList", tr("Todos") ); | 58 | m_tab->addTab( m_todoView,"todo/TodoList", tr("Todos") ); |
59 | 59 | ||
60 | m_dateView = new PIMListView(m_tab, "Datebook view" ); | 60 | m_dateView = new PIMListView(m_tab, "Datebook view" ); |
61 | m_tab->addTab( m_dateView, "datebook/DateBook", tr("Events") ); | 61 | m_tab->addTab( m_dateView, "datebook/DateBook", tr("Events") ); |
62 | 62 | ||
63 | /* now connect the actions */ | 63 | /* now connect the actions */ |
64 | /* | 64 | /* |
65 | * we connect the activated to our show | 65 | * we connect the activated to our show |
66 | * and on activation we will show a detailed | 66 | * and on activation we will show a detailed |
67 | * summary of the record | 67 | * summary of the record |
68 | */ | 68 | */ |
69 | connect(m_fire, SIGNAL(activated() ), | 69 | connect(m_fire, SIGNAL(activated() ), |
70 | this, SLOT(slotShow() ) ); | 70 | this, SLOT(slotShow() ) ); |
71 | 71 | ||
72 | /* | 72 | /* |
73 | * We will change the date | 73 | * We will change the date |
74 | */ | 74 | */ |
75 | connect(m_dateAction, SIGNAL(activated() ), | 75 | connect(m_dateAction, SIGNAL(activated() ), |
76 | this, SLOT(slotDate() ) ); | 76 | this, SLOT(slotDate() ) ); |
77 | 77 | ||
78 | /* | 78 | /* |
79 | * connect the show signal of the PIMListView | 79 | * connect the show signal of the PIMListView |
80 | * to a slot to show a dialog | 80 | * to a slot to show a dialog |
81 | */ | 81 | */ |
82 | connect(m_todoView, SIGNAL(showRecord(const OPimRecord& ) ), | 82 | connect(m_todoView, SIGNAL(showRecord(const OPimRecord&) ), |
83 | this, SLOT(slotShowRecord(const OPimRecord& ) ) ); | 83 | this, SLOT(slotShowRecord(const OPimRecord&) ) ); |
84 | connect(m_dateView, SIGNAL(showRecord(const OPimRecord& ) ), | 84 | connect(m_dateView, SIGNAL(showRecord(const OPimRecord&) ), |
85 | this, SLOT(slotShowRecord(const OPimRecord& ) ) ); | 85 | this, SLOT(slotShowRecord(const OPimRecord&) ) ); |
86 | 86 | ||
87 | /* | 87 | /* |
88 | * Now comes the important lines of code for this example | 88 | * Now comes the important lines of code for this example |
89 | * We do not directly call load but delay loading until | 89 | * We do not directly call load but delay loading until |
90 | * all Events are dispatches and handled. | 90 | * all Events are dispatches and handled. |
91 | * SO we will load once our window is mapped to screen | 91 | * SO we will load once our window is mapped to screen |
92 | * to achieve that we use a QTimer::singleShot | 92 | * to achieve that we use a QTimer::singleShot |
93 | * After 10 milli seconds the timer fires and on TimerEvent | 93 | * After 10 milli seconds the timer fires and on TimerEvent |
94 | * out slot slotLoad will be called | 94 | * out slot slotLoad will be called |
95 | * Remember this a Constructor to construct your object and not | 95 | * Remember this a Constructor to construct your object and not |
96 | * to load | 96 | * to load |
97 | */ | 97 | */ |
98 | QTimer::singleShot( 10, this, SLOT(slotLoad() ) ); | 98 | QTimer::singleShot( 10, this, SLOT(slotLoad() ) ); |
99 | } | 99 | } |
100 | 100 | ||
101 | MainWindow::~MainWindow() { | 101 | MainWindow::~MainWindow() { |
102 | // again nothing to delete because Qt takes care | 102 | // again nothing to delete because Qt takes care |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | void MainWindow::setDocument( const QString& /*str*/ ) { | 106 | void MainWindow::setDocument( const QString& /*str*/ ) { |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | void MainWindow::initUI() { | 110 | void MainWindow::initUI() { |
111 | 111 | ||
112 | setToolBarsMovable( false ); | 112 | setToolBarsMovable( false ); |
113 | 113 | ||
114 | QToolBar *menuBarHolder = new QToolBar( this ); | 114 | QToolBar *menuBarHolder = new QToolBar( this ); |
115 | 115 | ||
116 | menuBarHolder->setHorizontalStretchable( true ); | 116 | menuBarHolder->setHorizontalStretchable( true ); |
117 | QMenuBar *mb = new QMenuBar( menuBarHolder ); | 117 | QMenuBar *mb = new QMenuBar( menuBarHolder ); |
118 | QToolBar *tb = new QToolBar( this ); | 118 | QToolBar *tb = new QToolBar( this ); |
119 | 119 | ||
120 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 120 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
121 | 121 | ||
122 | 122 | ||
123 | QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), | 123 | QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), |
124 | QString::null, 0, this, "quit_action" ); | 124 | QString::null, 0, this, "quit_action" ); |
125 | /* | 125 | /* |
126 | * Connect quit to the QApplication quit slot | 126 | * Connect quit to the QApplication quit slot |
127 | */ | 127 | */ |
128 | connect(a, SIGNAL(activated() ), | 128 | connect(a, SIGNAL(activated() ), |
129 | qApp, SLOT(quit() ) ); | 129 | qApp, SLOT(quit() ) ); |
130 | a->addTo( fileMenu ); | 130 | a->addTo( fileMenu ); |
131 | 131 | ||
132 | a = new QAction(tr("View Current"), | 132 | a = new QAction(tr("View Current"), |
133 | Resource::loadIconSet("zoom"), | 133 | Resource::loadIconSet("zoom"), |
@@ -144,98 +144,98 @@ void MainWindow::initUI() { | |||
144 | a = new QAction(tr("Choose Date"), | 144 | a = new QAction(tr("Choose Date"), |
145 | Resource::loadIconSet("day"), | 145 | Resource::loadIconSet("day"), |
146 | QString::null, 0, this, "choose date" ); | 146 | QString::null, 0, this, "choose date" ); |
147 | a->addTo( fileMenu ); | 147 | a->addTo( fileMenu ); |
148 | a->addTo( tb ); | 148 | a->addTo( tb ); |
149 | m_dateAction = a; | 149 | m_dateAction = a; |
150 | 150 | ||
151 | mb->insertItem(tr("File"), fileMenu ); | 151 | mb->insertItem(tr("File"), fileMenu ); |
152 | 152 | ||
153 | } | 153 | } |
154 | 154 | ||
155 | void MainWindow::slotLoad() { | 155 | void MainWindow::slotLoad() { |
156 | /* | 156 | /* |
157 | * There is no real shared access in the PIM API | 157 | * There is no real shared access in the PIM API |
158 | * It wasn't finish cause of health problems of one | 158 | * It wasn't finish cause of health problems of one |
159 | * of the authors so we do something fancy and use QCOP | 159 | * of the authors so we do something fancy and use QCOP |
160 | * the IPC system to get a current copy | 160 | * the IPC system to get a current copy |
161 | */ | 161 | */ |
162 | /* NOTES to QCOP: QCOP operates over channels and use QDataStream | 162 | /* NOTES to QCOP: QCOP operates over channels and use QDataStream |
163 | * to send data. You can check if a channel isRegistered or hook | 163 | * to send data. You can check if a channel isRegistered or hook |
164 | * yourself to that channel. A Channel is QCString and normally | 164 | * yourself to that channel. A Channel is QCString and normally |
165 | * prefix with QPE/ and then the system in example QPE/System, | 165 | * prefix with QPE/ and then the system in example QPE/System, |
166 | * QPE/Desktop a special channel is the application channel | 166 | * QPE/Desktop a special channel is the application channel |
167 | * it QPE/Application/appname this channel gets created on app | 167 | * it QPE/Application/appname this channel gets created on app |
168 | * startup by QPEApplication. QCOP is asynchronous | 168 | * startup by QPEApplication. QCOP is asynchronous |
169 | * | 169 | * |
170 | * To send you'll use QCopEnevelope | 170 | * To send you'll use QCopEnevelope |
171 | * | 171 | * |
172 | */ | 172 | */ |
173 | /* | 173 | /* |
174 | * What we will do is first is get to know if either | 174 | * What we will do is first is get to know if either |
175 | * datebook or todolist are running if so we will kindly | 175 | * datebook or todolist are running if so we will kindly |
176 | * asked to save the data for us. | 176 | * asked to save the data for us. |
177 | * If neither are running we can load directly | 177 | * If neither are running we can load directly |
178 | */ | 178 | */ |
179 | if (!QCopChannel::isRegistered("QPE/Application/todolist") && | 179 | if (!QCopChannel::isRegistered("QPE/Application/todolist") && |
180 | !QCopChannel::isRegistered("QPE/Application/datebook") ) { | 180 | !QCopChannel::isRegistered("QPE/Application/datebook") ) { |
181 | m_db.load(); | 181 | m_db.load(); |
182 | m_tb.load(); | 182 | m_tb.load(); |
183 | return slotLoadForDay( QDate::currentDate() ); | 183 | return slotLoadForDay( QDate::currentDate() ); |
184 | } | 184 | } |
185 | 185 | ||
186 | /* | 186 | /* |
187 | * prepare our answer machine the QCopChannel | 187 | * prepare our answer machine the QCopChannel |
188 | * QPE/Desktop will send "flushDone(QString)" when | 188 | * QPE/Desktop will send "flushDone(QString)" when |
189 | * the flush is done it emits a signal on receive | 189 | * the flush is done it emits a signal on receive |
190 | */ | 190 | */ |
191 | m_desktopChannel = new QCopChannel("QPE/Desktop"); | 191 | m_desktopChannel = new QCopChannel("QPE/Desktop"); |
192 | connect(m_desktopChannel, SIGNAL(received(const QCString&, const QByteArray& ) ), | 192 | connect(m_desktopChannel, SIGNAL(received(const QCString&,const QByteArray&) ), |
193 | this, SLOT(slotDesktopReceive(const QCString&, const QByteArray& ) ) ); | 193 | this, SLOT(slotDesktopReceive(const QCString&,const QByteArray&) ) ); |
194 | /* the numberof synced channels will be set to zero */ | 194 | /* the numberof synced channels will be set to zero */ |
195 | m_synced = 0; | 195 | m_synced = 0; |
196 | 196 | ||
197 | /* | 197 | /* |
198 | * We use {} around the QCopEnvelope because it sends its | 198 | * We use {} around the QCopEnvelope because it sends its |
199 | * data on destruction of QCopEnvelope with | 199 | * data on destruction of QCopEnvelope with |
200 | */ | 200 | */ |
201 | /* check again if not present increment synced*/ | 201 | /* check again if not present increment synced*/ |
202 | if ( QCopChannel::isRegistered("QPE/Application/todolist") ) { | 202 | if ( QCopChannel::isRegistered("QPE/Application/todolist") ) { |
203 | QCopEnvelope env("QPE/Application/todolist", "flush()" ); | 203 | QCopEnvelope env("QPE/Application/todolist", "flush()" ); |
204 | // env << data; but we do not have any parameters here | 204 | // env << data; but we do not have any parameters here |
205 | }else | 205 | }else |
206 | m_synced++; | 206 | m_synced++; |
207 | 207 | ||
208 | if ( QCopChannel::isRegistered("QPE/Application/datebook") ) { | 208 | if ( QCopChannel::isRegistered("QPE/Application/datebook") ) { |
209 | QCopEnvelope env("QPE/Application/datebook", "flush()" ); | 209 | QCopEnvelope env("QPE/Application/datebook", "flush()" ); |
210 | }else | 210 | }else |
211 | m_synced++; | 211 | m_synced++; |
212 | 212 | ||
213 | /* we will provide a wait scrren */ | 213 | /* we will provide a wait scrren */ |
214 | m_loading = new OWait(this, "wait screen" ); | 214 | m_loading = new OWait(this, "wait screen" ); |
215 | } | 215 | } |
216 | 216 | ||
217 | void MainWindow::slotDesktopReceive(const QCString& cmd, const QByteArray& data ) { | 217 | void MainWindow::slotDesktopReceive(const QCString& cmd, const QByteArray& data ) { |
218 | /* the bytearray was filled with the QDataStream now | 218 | /* the bytearray was filled with the QDataStream now |
219 | * we open it read only to get the value(s) | 219 | * we open it read only to get the value(s) |
220 | */ | 220 | */ |
221 | QDataStream stream(data, IO_ReadOnly ); | 221 | QDataStream stream(data, IO_ReadOnly ); |
222 | /* | 222 | /* |
223 | * we're only interested in the flushDone | 223 | * we're only interested in the flushDone |
224 | */ | 224 | */ |
225 | if ( cmd == "flushDone(QString)" ) { | 225 | if ( cmd == "flushDone(QString)" ) { |
226 | QString appname; | 226 | QString appname; |
227 | stream >> appname; // get the first argument out of stream | 227 | stream >> appname; // get the first argument out of stream |
228 | if (appname == QString::fromLatin1("datebook") || | 228 | if (appname == QString::fromLatin1("datebook") || |
229 | appname == QString::fromLatin1("todolist") ) | 229 | appname == QString::fromLatin1("todolist") ) |
230 | m_synced++; | 230 | m_synced++; |
231 | } | 231 | } |
232 | 232 | ||
233 | /* | 233 | /* |
234 | * If we synced both we can go ahead | 234 | * If we synced both we can go ahead |
235 | * In future this is not needed anymore when we finally | 235 | * In future this is not needed anymore when we finally |
236 | * implemented X-Ref and other PIM features | 236 | * implemented X-Ref and other PIM features |
237 | */ | 237 | */ |
238 | if (m_synced >= 2 ) { | 238 | if (m_synced >= 2 ) { |
239 | delete m_loading; | 239 | delete m_loading; |
240 | delete m_desktopChannel; | 240 | delete m_desktopChannel; |
241 | /* now we finally can start doing the actual loading */ | 241 | /* now we finally can start doing the actual loading */ |
@@ -262,98 +262,98 @@ void MainWindow::slotLoadForDay(const QDate& date) { | |||
262 | 262 | ||
263 | /* all todos for today including the ones without dueDate */ | 263 | /* all todos for today including the ones without dueDate */ |
264 | m_todoView->set( m_tb.effectiveToDos(date, date ) ); | 264 | m_todoView->set( m_tb.effectiveToDos(date, date ) ); |
265 | m_dateView->set( m_db.effectiveEvents( date, date ) ); | 265 | m_dateView->set( m_db.effectiveEvents( date, date ) ); |
266 | } | 266 | } |
267 | 267 | ||
268 | /* we want to show the current record */ | 268 | /* we want to show the current record */ |
269 | void MainWindow::slotShow() { | 269 | void MainWindow::slotShow() { |
270 | /* we only added PIMListViews so we can safely cast */ | 270 | /* we only added PIMListViews so we can safely cast */ |
271 | PIMListView *view = static_cast<PIMListView*>(m_tab->currentWidget() ); | 271 | PIMListView *view = static_cast<PIMListView*>(m_tab->currentWidget() ); |
272 | 272 | ||
273 | /* ask the view to send a signal */ | 273 | /* ask the view to send a signal */ |
274 | view->showCurrentRecord(); | 274 | view->showCurrentRecord(); |
275 | 275 | ||
276 | } | 276 | } |
277 | 277 | ||
278 | /* as answer this slot will be called */ | 278 | /* as answer this slot will be called */ |
279 | void MainWindow::slotShowRecord( const OPimRecord& rec) { | 279 | void MainWindow::slotShowRecord( const OPimRecord& rec) { |
280 | /* got a parent but still is a toplevel MODAL dialog */ | 280 | /* got a parent but still is a toplevel MODAL dialog */ |
281 | QDialog* dia = new QDialog(this,"dialog",TRUE ); | 281 | QDialog* dia = new QDialog(this,"dialog",TRUE ); |
282 | QVBoxLayout *box = new QVBoxLayout( dia ); | 282 | QVBoxLayout *box = new QVBoxLayout( dia ); |
283 | dia->setCaption( tr("View Record") ); | 283 | dia->setCaption( tr("View Record") ); |
284 | 284 | ||
285 | 285 | ||
286 | QTextView *view = new QTextView(dia ); | 286 | QTextView *view = new QTextView(dia ); |
287 | view->setText( rec.toRichText() ); | 287 | view->setText( rec.toRichText() ); |
288 | box->addWidget( view ); | 288 | box->addWidget( view ); |
289 | /* | 289 | /* |
290 | * execute via QPEApplication | 290 | * execute via QPEApplication |
291 | * this allows QPEApplication to make a sane decision | 291 | * this allows QPEApplication to make a sane decision |
292 | * on the size | 292 | * on the size |
293 | */ | 293 | */ |
294 | dia->showMaximized(); | 294 | dia->showMaximized(); |
295 | QPEApplication::execDialog( dia ); | 295 | QPEApplication::execDialog( dia ); |
296 | delete dia; | 296 | delete dia; |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | void MainWindow::slotDate() { | 300 | void MainWindow::slotDate() { |
301 | /* | 301 | /* |
302 | * called by the action we will show a Popup | 302 | * called by the action we will show a Popup |
303 | * at the current mouse position with a DateChooser | 303 | * at the current mouse position with a DateChooser |
304 | * to select the day | 304 | * to select the day |
305 | */ | 305 | */ |
306 | qWarning("slot Date"); | 306 | qWarning("slot Date"); |
307 | QPopupMenu *menu = new QPopupMenu(); | 307 | QPopupMenu *menu = new QPopupMenu(); |
308 | /* A Month to select a date from TRUE for auto close */ | 308 | /* A Month to select a date from TRUE for auto close */ |
309 | DateBookMonth *month = new DateBookMonth(menu, 0, true ); | 309 | DateBookMonth *month = new DateBookMonth(menu, 0, true ); |
310 | connect(month, SIGNAL(dateClicked(int, int, int) ), | 310 | connect(month, SIGNAL(dateClicked(int,int,int) ), |
311 | this, SLOT(slotLoadForDay(int, int, int) ) ); | 311 | this, SLOT(slotLoadForDay(int,int,int) ) ); |
312 | 312 | ||
313 | menu->insertItem( month ); | 313 | menu->insertItem( month ); |
314 | 314 | ||
315 | menu->exec( QCursor::pos() ); | 315 | menu->exec( QCursor::pos() ); |
316 | 316 | ||
317 | /* | 317 | /* |
318 | * we do not need to delete month because | 318 | * we do not need to delete month because |
319 | * we delete its parent menu | 319 | * we delete its parent menu |
320 | */ | 320 | */ |
321 | 321 | ||
322 | delete menu; | 322 | delete menu; |
323 | } | 323 | } |
324 | 324 | ||
325 | /* | 325 | /* |
326 | * An anonymous namespace this symbol is only available here | 326 | * An anonymous namespace this symbol is only available here |
327 | * so truely private | 327 | * so truely private |
328 | */ | 328 | */ |
329 | namespace { | 329 | namespace { |
330 | /* not static cause namespace does that what static would do */ | 330 | /* not static cause namespace does that what static would do */ |
331 | const int RTTI = 5050; | 331 | const int RTTI = 5050; |
332 | /* | 332 | /* |
333 | * every ListView got Items. we've special pim items | 333 | * every ListView got Items. we've special pim items |
334 | * holding ownership and the pointer to a pim record | 334 | * holding ownership and the pointer to a pim record |
335 | * it can't hold a pimrecord directly because this | 335 | * it can't hold a pimrecord directly because this |
336 | * would introduce slicing... any break | 336 | * would introduce slicing... any break |
337 | */ | 337 | */ |
338 | /* | 338 | /* |
339 | * A struct is a special class. Everything is public by | 339 | * A struct is a special class. Everything is public by |
340 | * default. | 340 | * default. |
341 | */ | 341 | */ |
342 | struct PIMListViewItem : public QListViewItem { | 342 | struct PIMListViewItem : public QListViewItem { |
343 | /* | 343 | /* |
344 | *currently no hierachies are planed for the example | 344 | *currently no hierachies are planed for the example |
345 | * so only one constructor with a QListView as parent | 345 | * so only one constructor with a QListView as parent |
346 | */ | 346 | */ |
347 | PIMListViewItem( QListView*, OPimRecord* record ); | 347 | PIMListViewItem( QListView*, OPimRecord* record ); |
348 | ~PIMListViewItem(); | 348 | ~PIMListViewItem(); |
349 | 349 | ||
350 | /* used by the QListViewItem to easily allow identifiying of different | 350 | /* used by the QListViewItem to easily allow identifiying of different |
351 | * items. Values greater than 1000 should be used */ | 351 | * items. Values greater than 1000 should be used */ |
352 | int rtti()const; | 352 | int rtti()const; |
353 | OPimRecord* record()const; | 353 | OPimRecord* record()const; |
354 | 354 | ||
355 | private: | 355 | private: |
356 | OPimRecord* m_record; | 356 | OPimRecord* m_record; |
357 | }; | 357 | }; |
358 | 358 | ||
359 | PIMListViewItem::PIMListViewItem( QListView *p, OPimRecord* rec ) | 359 | PIMListViewItem::PIMListViewItem( QListView *p, OPimRecord* rec ) |