summaryrefslogtreecommitdiff
path: root/examples/simple-pim/simple.h
blob: 2a6e8cef75938bcbd03576f400ff722e4351b983 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

/*
 * A Simple widget with a button to quit
 *
 */

/*
 * The below sequence is called a guard and guards
 * against multiple inclusion of header files
 * NOTE: you need to use unique names among the header files
 */
#ifndef QUIET_SIMPLE_DEMO_H
#define QUIET_SIMPLE_DEMO_H




#include <qmainwindow.h>  // from this class we will inherit
#include <qlistview.h> // A ListView for our PIM records

#include <opie2/otodoaccess.h>
#include <opie2/odatebookaccess.h>

class QPushButton; // forward declaration to not include the header. This can save time when compiling
class QAction;
class PIMListView;
class QDate;
class QCopChannel;
namespace Opie{
namespace Ui  {
class OWait;
class OTabWidget;
}
}

/*
 * A mainwindow is a special QWidget it helps layouting
 * toolbar, statusbar, menubar. Got dockable areas
 * So in one sentence it is a MainWindow :)
 */
class MainWindow : public QMainWindow {
    Q_OBJECT
public:
    static QString appName() { return QString::fromLatin1("simple-pim"); }
    MainWindow( QWidget* parent, const char* name,  WFlags fl );
    ~MainWindow();

public slots:
    void setDocument( const QString& );
private slots:
    void slotDesktopReceive( const QCString&, const QByteArray& );
    void slotLoad();
    void slotLoadForDay(int, int, int );
    void slotLoadForDay(const QDate&);
    void slotShow();
    void slotDate();
    void slotShowRecord( const Opie::OPimRecord& );

private:
    void initUI();
    QAction *m_fire;
    QAction *m_dateAction;
    Opie::Ui::OTabWidget* m_tab;

    Opie::OPimTodoAccess     m_tb;
    Opie::ODateBookAccess m_db;
    PIMListView    *m_todoView;
    PIMListView    *m_dateView;

    int m_synced; // a counter for synced objects..
    QCopChannel    *m_desktopChannel;
    Opie::Ui::OWait          *m_loading;
};

/*
 * Instead of the simple QWidgets we will design
 * a new widget based on a QListView
 * it should show either Todos or EffectiveEvents
 */
class PIMListView :  public QListView {
    Q_OBJECT
public:
    PIMListView( QWidget* parent, const char* name, WFlags fl= 0 );
    ~PIMListView();


    void set( Opie::OPimTodoAccess::List );
    void set( const Opie::OEffectiveEvent::ValueList& );
    void showCurrentRecord();

signals:
    void showRecord( const Opie::OPimRecord& );

private:
    static QString makeString( const Opie::OEffectiveEvent& ev );

};

#endif