summaryrefslogtreecommitdiff
path: root/core/pim/todo/mainwindow.h
blob: 5a18e64c7c651e8ae25018aae74b33a857a06b29 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
               =.            This file is part of the OPIE Project
             .=l.            Copyright (c)  2002 Holger Freyther <zecke@handhelds.org>
           .>+-=
 _;:,     .>    :=|.         This program is free software; you can
.> <`_,   >  .   <=          redistribute it and/or  modify it under
:`=1 )Y*s>-.--   :           the terms of the GNU General Public
.="- .-=="i,     .._         License as published by the Free Software
 - .   .-<_>     .<>         Foundation; either version 2 of the License,
     ._= =}       :          or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s.       This program is distributed in the hope that
     +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
    : ..    .:,     . . .    without even the implied warranty of
    =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ;      Library General Public License for more
++=   -.     .`     .:       details.
 :     =  ...= . :.=-
 -.   .:....=;==+<;          You should have received a copy of the GNU
  -_. . .   )=.  =           Library General Public License along with
    --        :-=`           this library; see the file COPYING.LIB.
                             If not, write to the Free Software Foundation,
                             Inc., 59 Temple Place - Suite 330,
                             Boston, MA 02111-1307, USA.

*/

#ifndef TODO_MAIN_WINDOW_H
#define TODO_MAIN_WINDOW_H

#include <qlist.h>
#include <qmainwindow.h>

#include <opie/otodoaccess.h>
#include <opie/otodo.h>

#include "smalltodo.h"
#include "todoview.h"
#include "todomanager.h"

class QPopupMenu;
class QMenuBar;
class QToolBar;
class QAction;
class QWidgetStack;
class Ir;


namespace Todo {
    typedef TodoView View;
    class TemplateManager;
    class Editor;
    class TodoShow;
    class TemplateEditor;

    class MainWindow : public QMainWindow {
        Q_OBJECT
    public:
        MainWindow( QWidget *parent = 0,
                    const char* name = 0 );
        ~MainWindow();

        /** return a context menu for an OTodo */
        QPopupMenu* contextMenu(int uid );
        QPopupMenu* options();
        QPopupMenu* edit();
        QPopupMenu* view();
        QToolBar*   toolbar();


        void updateList();
        OTodoAccess::List list()const;
        OTodoAccess::List sorted( bool asc, int sortOrder );
        OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter );

        OTodo event(int uid );

        bool isSyncing()const;
        bool showCompleted()const;
        bool showDeadline()const;
        bool showOverDue()const;
        QString currentCategory()const;
        int currentCatId();
        TemplateManager* templateManager();

        void updateTodo( const OTodo& );
        void populateTemplates();
        Editor* currentEditor();
        void setReadAhead(uint count );
private slots:
        void populateCategories();
        void slotReload();
        void slotFlush();

    protected:
        void closeEvent( QCloseEvent* e );

    private:
        void receiveFile( const QString& filename );
        void connectBase( ViewBase* );
        void initUI();
        void initActions();
        void initConfig();
        void initViews();
        void initEditor();
        void initShow();
        void initTemplate();
        void raiseCurrentView();
        ViewBase* currentView();
        ViewBase* m_curView;
        Editor* m_curEdit;
        TodoShow* currentShow();
        TodoShow* m_curShow;
        TemplateEditor* currentTemplateEditor();
        TemplateEditor* m_curTempEd;

        QMenuBar* m_bar;
        QToolBar* m_tool;
        QAction* m_editAction,
            *m_deleteAction,
            *m_findAction,
            *m_completedAction,
            *m_showDeadLineAction,
            *m_deleteAllAction,
            *m_deleteCompleteAction,
            *m_duplicateAction,
            *m_showOverDueAction,
            *m_effectiveAction;
        QWidgetStack *m_stack;
        QPopupMenu* m_catMenu,
            *m_edit,
            *m_options,
            *m_view,
            *m_template;

        bool m_syncing:1;
        bool m_deadline:1;
        bool m_completed:1;
        bool m_overdue:1;
        TodoManager m_todoMgr;
        QString m_curCat;
        QList<ViewBase> m_views;
        uint m_counter;
        TemplateManager* m_tempManager;

     private slots:
        void slotShow(int);
        void slotEdit(int);
private slots:
        void slotUpdate3( QWidget* );
        void slotNewFromTemplate(int id );
        void slotNew();
        void slotDuplicate();
        void slotDelete();
        void slotDeleteAll();
        void slotDeleteCompleted();

        void slotEdit();
        void slotFind();

        void setCategory( int );

        void slotShowDeadLine( bool );
        void slotShowCompleted( bool );

        void setDocument( const QString& );


        void slotBeam();
        void beamDone( Ir* );
        void slotShowDetails();
        void slotShowDue( bool );
    };
};

#endif