-rw-r--r-- | examples/simple-pim/config.in | 2 | ||||
-rw-r--r-- | examples/simple-pim/example.pro | 2 | ||||
-rw-r--r-- | examples/simple-pim/simple.cpp | 39 | ||||
-rw-r--r-- | examples/simple-pim/simple.h | 26 |
4 files changed, 37 insertions, 32 deletions
diff --git a/examples/simple-pim/config.in b/examples/simple-pim/config.in index 5d80f21..aa1a426 100644 --- a/examples/simple-pim/config.in +++ b/examples/simple-pim/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config SIMPLE_PIM_EXAMPLE | 1 | config SIMPLE_PIM_EXAMPLE |
2 | boolean "Mainwindow with PIM and QCOP usage" | 2 | boolean "Mainwindow with PIM and QCOP usage" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIEPIM2 |
diff --git a/examples/simple-pim/example.pro b/examples/simple-pim/example.pro index c3aab53..ebcdb2b 100644 --- a/examples/simple-pim/example.pro +++ b/examples/simple-pim/example.pro | |||
@@ -7,11 +7,11 @@ HEADERS = simple.h | |||
7 | SOURCES = simple.cpp | 7 | SOURCES = simple.cpp |
8 | 8 | ||
9 | 9 | ||
10 | INCLUDEPATH += $(OPIEDIR)/include | 10 | INCLUDEPATH += $(OPIEDIR)/include |
11 | DEPENDPATH += $(OPIEDIR)/include | 11 | DEPENDPATH += $(OPIEDIR)/include |
12 | 12 | ||
13 | 13 | ||
14 | # we now also include opie | 14 | # we now also include opie |
15 | LIBS += -lqpe -lopie | 15 | LIBS += -lqpe -lopiepim2 -lopieui2 |
16 | 16 | ||
17 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/examples/simple-pim/simple.cpp b/examples/simple-pim/simple.cpp index 029e71b..50905bf 100644 --- a/examples/simple-pim/simple.cpp +++ b/examples/simple-pim/simple.cpp | |||
@@ -12,50 +12,51 @@ | |||
12 | 12 | ||
13 | #include <qpe/qpeapplication.h> // the QPEApplication | 13 | #include <qpe/qpeapplication.h> // the QPEApplication |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | #include <qpe/sound.h> | 15 | #include <qpe/sound.h> |
16 | #include <qpe/qcopenvelope_qws.h> | 16 | #include <qpe/qcopenvelope_qws.h> |
17 | #include <qpe/datebookmonth.h> | 17 | #include <qpe/datebookmonth.h> |
18 | #include <qpe/timestring.h> | 18 | #include <qpe/timestring.h> |
19 | 19 | ||
20 | #include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching | 20 | #include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching |
21 | #include <opie/otabwidget.h> | 21 | #include <opie2/otabwidget.h> |
22 | #include <opie/owait.h> | 22 | #include <opie2/owait.h> |
23 | 23 | ||
24 | #include "simple.h" | 24 | #include "simple.h" |
25 | 25 | ||
26 | /* | 26 | /* |
27 | * implementation of simple | 27 | * implementation of simple |
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * The factory is used for quicklaunching | 31 | * The factory is used for quicklaunching |
32 | * 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 | 32 | * 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 |
33 | * | 33 | * |
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 | using namespace Opie::Core; | ||
38 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) | 39 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
39 | 40 | ||
40 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) | 41 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) |
41 | : QMainWindow( parent, name, fl ) { | 42 | : QMainWindow( parent, name, fl ) { |
42 | setCaption(tr("My MainWindow") ); | 43 | setCaption(tr("My MainWindow") ); |
43 | 44 | ||
44 | m_desktopChannel = 0; | 45 | m_desktopChannel = 0; |
45 | m_loading = 0; | 46 | m_loading = 0; |
46 | 47 | ||
47 | initUI(); | 48 | initUI(); |
48 | 49 | ||
49 | 50 | ||
50 | /* | 51 | /* |
51 | * Tab widget as central | 52 | * Tab widget as central |
52 | */ | 53 | */ |
53 | m_tab = new OTabWidget(this); | 54 | m_tab = new Opie::Ui::OTabWidget(this); |
54 | 55 | ||
55 | setCentralWidget( m_tab ); | 56 | setCentralWidget( m_tab ); |
56 | 57 | ||
57 | m_todoView = new PIMListView(m_tab, "Todo view" ); | 58 | m_todoView = new PIMListView(m_tab, "Todo view" ); |
58 | m_tab->addTab( m_todoView,"todo/TodoList", tr("Todos") ); | 59 | m_tab->addTab( m_todoView,"todo/TodoList", tr("Todos") ); |
59 | 60 | ||
60 | m_dateView = new PIMListView(m_tab, "Datebook view" ); | 61 | m_dateView = new PIMListView(m_tab, "Datebook view" ); |
61 | m_tab->addTab( m_dateView, "datebook/DateBook", tr("Events") ); | 62 | m_tab->addTab( m_dateView, "datebook/DateBook", tr("Events") ); |
@@ -206,17 +207,17 @@ void MainWindow::slotLoad() { | |||
206 | m_synced++; | 207 | m_synced++; |
207 | 208 | ||
208 | if ( QCopChannel::isRegistered("QPE/Application/datebook") ) { | 209 | if ( QCopChannel::isRegistered("QPE/Application/datebook") ) { |
209 | QCopEnvelope env("QPE/Application/datebook", "flush()" ); | 210 | QCopEnvelope env("QPE/Application/datebook", "flush()" ); |
210 | }else | 211 | }else |
211 | m_synced++; | 212 | m_synced++; |
212 | 213 | ||
213 | /* we will provide a wait scrren */ | 214 | /* we will provide a wait scrren */ |
214 | m_loading = new OWait(this, "wait screen" ); | 215 | m_loading = new Opie::Ui::OWait(this, "wait screen" ); |
215 | } | 216 | } |
216 | 217 | ||
217 | void MainWindow::slotDesktopReceive(const QCString& cmd, const QByteArray& data ) { | 218 | void MainWindow::slotDesktopReceive(const QCString& cmd, const QByteArray& data ) { |
218 | /* the bytearray was filled with the QDataStream now | 219 | /* the bytearray was filled with the QDataStream now |
219 | * we open it read only to get the value(s) | 220 | * we open it read only to get the value(s) |
220 | */ | 221 | */ |
221 | QDataStream stream(data, IO_ReadOnly ); | 222 | QDataStream stream(data, IO_ReadOnly ); |
222 | /* | 223 | /* |
@@ -271,17 +272,17 @@ void MainWindow::slotShow() { | |||
271 | PIMListView *view = static_cast<PIMListView*>(m_tab->currentWidget() ); | 272 | PIMListView *view = static_cast<PIMListView*>(m_tab->currentWidget() ); |
272 | 273 | ||
273 | /* ask the view to send a signal */ | 274 | /* ask the view to send a signal */ |
274 | view->showCurrentRecord(); | 275 | view->showCurrentRecord(); |
275 | 276 | ||
276 | } | 277 | } |
277 | 278 | ||
278 | /* as answer this slot will be called */ | 279 | /* as answer this slot will be called */ |
279 | void MainWindow::slotShowRecord( const OPimRecord& rec) { | 280 | void MainWindow::slotShowRecord( const Opie::OPimRecord& rec) { |
280 | /* got a parent but still is a toplevel MODAL dialog */ | 281 | /* got a parent but still is a toplevel MODAL dialog */ |
281 | QDialog* dia = new QDialog(this,"dialog",TRUE ); | 282 | QDialog* dia = new QDialog(this,"dialog",TRUE ); |
282 | QVBoxLayout *box = new QVBoxLayout( dia ); | 283 | QVBoxLayout *box = new QVBoxLayout( dia ); |
283 | dia->setCaption( tr("View Record") ); | 284 | dia->setCaption( tr("View Record") ); |
284 | 285 | ||
285 | 286 | ||
286 | QTextView *view = new QTextView(dia ); | 287 | QTextView *view = new QTextView(dia ); |
287 | view->setText( rec.toRichText() ); | 288 | view->setText( rec.toRichText() ); |
@@ -339,76 +340,76 @@ namespace { | |||
339 | * A struct is a special class. Everything is public by | 340 | * A struct is a special class. Everything is public by |
340 | * default. | 341 | * default. |
341 | */ | 342 | */ |
342 | struct PIMListViewItem : public QListViewItem { | 343 | struct PIMListViewItem : public QListViewItem { |
343 | /* | 344 | /* |
344 | *currently no hierachies are planed for the example | 345 | *currently no hierachies are planed for the example |
345 | * so only one constructor with a QListView as parent | 346 | * so only one constructor with a QListView as parent |
346 | */ | 347 | */ |
347 | PIMListViewItem( QListView*, OPimRecord* record ); | 348 | PIMListViewItem( QListView*, Opie::OPimRecord* record ); |
348 | ~PIMListViewItem(); | 349 | ~PIMListViewItem(); |
349 | 350 | ||
350 | /* used by the QListViewItem to easily allow identifiying of different | 351 | /* used by the QListViewItem to easily allow identifiying of different |
351 | * items. Values greater than 1000 should be used */ | 352 | * items. Values greater than 1000 should be used */ |
352 | int rtti()const; | 353 | int rtti()const; |
353 | OPimRecord* record()const; | 354 | Opie::OPimRecord* record()const; |
354 | 355 | ||
355 | private: | 356 | private: |
356 | OPimRecord* m_record; | 357 | Opie::OPimRecord* m_record; |
357 | }; | 358 | }; |
358 | 359 | ||
359 | PIMListViewItem::PIMListViewItem( QListView *p, OPimRecord* rec ) | 360 | PIMListViewItem::PIMListViewItem( QListView *p, Opie::OPimRecord* rec ) |
360 | : QListViewItem(p), m_record( rec ) { | 361 | : QListViewItem(p), m_record( rec ) { |
361 | } | 362 | } |
362 | 363 | ||
363 | PIMListViewItem::~PIMListViewItem() { | 364 | PIMListViewItem::~PIMListViewItem() { |
364 | /* we've the onwership so we need to delete it */ | 365 | /* we've the onwership so we need to delete it */ |
365 | delete m_record; | 366 | delete m_record; |
366 | } | 367 | } |
367 | 368 | ||
368 | OPimRecord* PIMListViewItem::record()const { | 369 | Opie::OPimRecord* PIMListViewItem::record()const { |
369 | return m_record; | 370 | return m_record; |
370 | } | 371 | } |
371 | 372 | ||
372 | } | 373 | } |
373 | 374 | ||
374 | 375 | ||
375 | PIMListView::PIMListView( QWidget* widget, const char* name, WFlags fl ) | 376 | PIMListView::PIMListView( QWidget* widget, const char* name, WFlags fl ) |
376 | : QListView(widget, name, fl ) | 377 | : QListView(widget, name, fl ) |
377 | { | 378 | { |
378 | addColumn("Summary"); | 379 | addColumn("Summary"); |
379 | } | 380 | } |
380 | 381 | ||
381 | PIMListView::~PIMListView() { | 382 | PIMListView::~PIMListView() { |
382 | 383 | ||
383 | } | 384 | } |
384 | 385 | ||
385 | void PIMListView::set( OTodoAccess::List list ) { | 386 | void PIMListView::set( Opie::OPimTodoAccess::List list ) { |
386 | /* clear first and then add new items */ | 387 | /* clear first and then add new items */ |
387 | clear(); | 388 | clear(); |
388 | 389 | ||
389 | OTodoAccess::List::Iterator it; | 390 | Opie::OPimTodoAccess::List::Iterator it; |
390 | for (it = list.begin(); it != list.end(); ++it ) { | 391 | for (it = list.begin(); it != list.end(); ++it ) { |
391 | /* | 392 | /* |
392 | * make a new item which automatically gets added to the listview | 393 | * make a new item which automatically gets added to the listview |
393 | * and call the copy c'tor to create a new OTodo | 394 | * and call the copy c'tor to create a new OPimTodo |
394 | */ | 395 | */ |
395 | PIMListViewItem *i = new PIMListViewItem(this, new OTodo( *it ) ); | 396 | PIMListViewItem *i = new PIMListViewItem(this, new Opie::OPimTodo( *it ) ); |
396 | i->setText(0, (*it).summary() ); | 397 | i->setText(0, (*it).summary() ); |
397 | } | 398 | } |
398 | } | 399 | } |
399 | 400 | ||
400 | void PIMListView::set( const OEffectiveEvent::ValueList& lst ) { | 401 | void PIMListView::set( const Opie::OEffectiveEvent::ValueList& lst ) { |
401 | /* clear first and then add items */ | 402 | /* clear first and then add items */ |
402 | clear(); | 403 | clear(); |
403 | 404 | ||
404 | OEffectiveEvent::ValueList::ConstIterator it; | 405 | Opie::OEffectiveEvent::ValueList::ConstIterator it; |
405 | for ( it = lst.begin(); it != lst.end(); ++it ) { | 406 | for ( it = lst.begin(); it != lst.end(); ++it ) { |
406 | PIMListViewItem *i = new PIMListViewItem(this, new OEvent( (*it).event() ) ); | 407 | PIMListViewItem *i = new PIMListViewItem(this, new Opie::OPimEvent( (*it).event() ) ); |
407 | i->setText( 0, PIMListView::makeString( (*it) ) ); | 408 | i->setText( 0, PIMListView::makeString( (*it) ) ); |
408 | } | 409 | } |
409 | 410 | ||
410 | } | 411 | } |
411 | 412 | ||
412 | void PIMListView::showCurrentRecord() { | 413 | void PIMListView::showCurrentRecord() { |
413 | /* it could be possible that their is no currentItem */ | 414 | /* it could be possible that their is no currentItem */ |
414 | if (!currentItem() ) | 415 | if (!currentItem() ) |
@@ -420,17 +421,17 @@ void PIMListView::showCurrentRecord() { | |||
420 | * use rtti() to check in a switch() case | 421 | * use rtti() to check in a switch() case |
421 | */ | 422 | */ |
422 | PIMListViewItem *item = static_cast<PIMListViewItem*>( currentItem() ); | 423 | PIMListViewItem *item = static_cast<PIMListViewItem*>( currentItem() ); |
423 | 424 | ||
424 | /* finally you see how to emit a signal */ | 425 | /* finally you see how to emit a signal */ |
425 | emit showRecord( (*item->record() ) ); | 426 | emit showRecord( (*item->record() ) ); |
426 | } | 427 | } |
427 | 428 | ||
428 | QString PIMListView::makeString( const OEffectiveEvent& ev ) { | 429 | QString PIMListView::makeString( const Opie::OEffectiveEvent& ev ) { |
429 | QString str; | 430 | QString str; |
430 | str += ev.description(); | 431 | str += ev.description(); |
431 | if ( !ev.event().isAllDay() ) { | 432 | if ( !ev.event().isAllDay() ) { |
432 | if ( ev.startDate() != ev.endDate() ) { | 433 | if ( ev.startDate() != ev.endDate() ) { |
433 | str += tr("Start ") + TimeString::timeString( ev.event().startDateTime().time() ); | 434 | str += tr("Start ") + TimeString::timeString( ev.event().startDateTime().time() ); |
434 | str += " - " + TimeString::longDateString( ev.startDate() ); | 435 | str += " - " + TimeString::longDateString( ev.startDate() ); |
435 | str += tr("End ") + TimeString::timeString( ev.event().endDateTime().time() ); | 436 | str += tr("End ") + TimeString::timeString( ev.event().endDateTime().time() ); |
436 | str += " - " + TimeString::longDateString( ev.endDate() ); | 437 | str += " - " + TimeString::longDateString( ev.endDate() ); |
diff --git a/examples/simple-pim/simple.h b/examples/simple-pim/simple.h index bf9ede7..2a6e8ce 100644 --- a/examples/simple-pim/simple.h +++ b/examples/simple-pim/simple.h | |||
@@ -13,26 +13,30 @@ | |||
13 | #define QUIET_SIMPLE_DEMO_H | 13 | #define QUIET_SIMPLE_DEMO_H |
14 | 14 | ||
15 | 15 | ||
16 | 16 | ||
17 | 17 | ||
18 | #include <qmainwindow.h> // from this class we will inherit | 18 | #include <qmainwindow.h> // from this class we will inherit |
19 | #include <qlistview.h> // A ListView for our PIM records | 19 | #include <qlistview.h> // A ListView for our PIM records |
20 | 20 | ||
21 | #include <opie/otodoaccess.h> | 21 | #include <opie2/otodoaccess.h> |
22 | #include <opie/odatebookaccess.h> | 22 | #include <opie2/odatebookaccess.h> |
23 | 23 | ||
24 | class QPushButton; // forward declaration to not include the header. This can save time when compiling | 24 | class QPushButton; // forward declaration to not include the header. This can save time when compiling |
25 | class QAction; | 25 | class QAction; |
26 | class PIMListView; | 26 | class PIMListView; |
27 | class QDate; | 27 | class QDate; |
28 | class QCopChannel; | 28 | class QCopChannel; |
29 | namespace Opie{ | ||
30 | namespace Ui { | ||
29 | class OWait; | 31 | class OWait; |
30 | class OTabWidget; | 32 | class OTabWidget; |
33 | } | ||
34 | } | ||
31 | 35 | ||
32 | /* | 36 | /* |
33 | * A mainwindow is a special QWidget it helps layouting | 37 | * A mainwindow is a special QWidget it helps layouting |
34 | * toolbar, statusbar, menubar. Got dockable areas | 38 | * toolbar, statusbar, menubar. Got dockable areas |
35 | * So in one sentence it is a MainWindow :) | 39 | * So in one sentence it is a MainWindow :) |
36 | */ | 40 | */ |
37 | class MainWindow : public QMainWindow { | 41 | class MainWindow : public QMainWindow { |
38 | Q_OBJECT | 42 | Q_OBJECT |
@@ -45,51 +49,51 @@ public slots: | |||
45 | void setDocument( const QString& ); | 49 | void setDocument( const QString& ); |
46 | private slots: | 50 | private slots: |
47 | void slotDesktopReceive( const QCString&, const QByteArray& ); | 51 | void slotDesktopReceive( const QCString&, const QByteArray& ); |
48 | void slotLoad(); | 52 | void slotLoad(); |
49 | void slotLoadForDay(int, int, int ); | 53 | void slotLoadForDay(int, int, int ); |
50 | void slotLoadForDay(const QDate&); | 54 | void slotLoadForDay(const QDate&); |
51 | void slotShow(); | 55 | void slotShow(); |
52 | void slotDate(); | 56 | void slotDate(); |
53 | void slotShowRecord( const OPimRecord& ); | 57 | void slotShowRecord( const Opie::OPimRecord& ); |
54 | 58 | ||
55 | private: | 59 | private: |
56 | void initUI(); | 60 | void initUI(); |
57 | QAction *m_fire; | 61 | QAction *m_fire; |
58 | QAction *m_dateAction; | 62 | QAction *m_dateAction; |
59 | OTabWidget* m_tab; | 63 | Opie::Ui::OTabWidget* m_tab; |
60 | 64 | ||
61 | OTodoAccess m_tb; | 65 | Opie::OPimTodoAccess m_tb; |
62 | ODateBookAccess m_db; | 66 | Opie::ODateBookAccess m_db; |
63 | PIMListView *m_todoView; | 67 | PIMListView *m_todoView; |
64 | PIMListView *m_dateView; | 68 | PIMListView *m_dateView; |
65 | 69 | ||
66 | int m_synced; // a counter for synced objects.. | 70 | int m_synced; // a counter for synced objects.. |
67 | QCopChannel *m_desktopChannel; | 71 | QCopChannel *m_desktopChannel; |
68 | OWait *m_loading; | 72 | Opie::Ui::OWait *m_loading; |
69 | }; | 73 | }; |
70 | 74 | ||
71 | /* | 75 | /* |
72 | * Instead of the simple QWidgets we will design | 76 | * Instead of the simple QWidgets we will design |
73 | * a new widget based on a QListView | 77 | * a new widget based on a QListView |
74 | * it should show either Todos or EffectiveEvents | 78 | * it should show either Todos or EffectiveEvents |
75 | */ | 79 | */ |
76 | class PIMListView : public QListView { | 80 | class PIMListView : public QListView { |
77 | Q_OBJECT | 81 | Q_OBJECT |
78 | public: | 82 | public: |
79 | PIMListView( QWidget* parent, const char* name, WFlags fl= 0 ); | 83 | PIMListView( QWidget* parent, const char* name, WFlags fl= 0 ); |
80 | ~PIMListView(); | 84 | ~PIMListView(); |
81 | 85 | ||
82 | 86 | ||
83 | void set( OTodoAccess::List ); | 87 | void set( Opie::OPimTodoAccess::List ); |
84 | void set( const OEffectiveEvent::ValueList& ); | 88 | void set( const Opie::OEffectiveEvent::ValueList& ); |
85 | void showCurrentRecord(); | 89 | void showCurrentRecord(); |
86 | 90 | ||
87 | signals: | 91 | signals: |
88 | void showRecord( const OPimRecord& ); | 92 | void showRecord( const Opie::OPimRecord& ); |
89 | 93 | ||
90 | private: | 94 | private: |
91 | static QString makeString( const OEffectiveEvent& ev ); | 95 | static QString makeString( const Opie::OEffectiveEvent& ev ); |
92 | 96 | ||
93 | }; | 97 | }; |
94 | 98 | ||
95 | #endif | 99 | #endif |