summaryrefslogtreecommitdiff
path: root/core/pim/todo/otaskeditor.cpp
blob: eeb3c0cd64e9a17703d4f8ecf5a7554dce45ca66 (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
#include <qdatetime.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qmultilineedit.h>
#include <qscrollview.h>

#include <opie/orecurrancewidget.h>

#include "taskeditoroverviewimpl.h"
#include "taskeditoradvancedimpl.h"
#include "taskeditoralarms.h"

#include "otaskeditor.h"

OTaskEditor::OTaskEditor(int cur)
    : QDialog(0, 0, TRUE ) {
    init();
    init( cur );
}
OTaskEditor::OTaskEditor( const OTodo& to)
    : QDialog(0, 0, TRUE ) {
    init();
    init( to );
}
OTaskEditor::~OTaskEditor() {

}
void OTaskEditor::init( int cur ) {
    OTodo to;
    if ( cur != 0 )
        to.setCategories( cur );
    load(to);
    m_uid = 1; // generate a new one
}
void OTaskEditor::init( const OTodo& to ) {
    load( to );
    m_uid = to.uid();
}
OTodo OTaskEditor::todo()const{
    qWarning("saving!");
    OTodo to;
    to.setUid(m_uid );
    m_overView->save( to );
    m_adv->save( to );
    to.setRecurrence( m_rec->recurrence() );

    return to;
}
void OTaskEditor::load(const OTodo& to) {
    m_overView->load( to );
    m_adv->load( to );
    m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() );
}
void OTaskEditor::init() {
    QVBoxLayout* lay = new QVBoxLayout(this );
    QScrollView* view = new QScrollView( this );
    view->setResizePolicy( QScrollView::AutoOneFit );
    lay->addWidget( view );

    setCaption("Task Editor");
    QWidget* container = new QWidget( view->viewport() );
    view->addChild( container );

    QVBoxLayout* layo = new QVBoxLayout( container );
    m_tab = new OTabWidget(container );
    layo->addWidget( m_tab );
    /*
     * Add the Widgets
     */
    m_overView = new TaskEditorOverViewImpl(m_tab );
    m_tab->addTab( m_overView, QString::null, tr("Overview") );

    m_adv = new TaskEditorAdvancedImpl( m_tab );
    m_tab->addTab( m_adv, QString::null, tr("Advanced") );

    m_alarm = new TaskEditorAlarms( m_tab );
    m_tab->addTab( m_alarm, QString::null, tr("Alarms") );

    m_remind = new TaskEditorAlarms( m_tab );
    m_tab->addTab( m_remind, QString::null, tr("Reminders") );

    QLabel* lbl = new QLabel(m_tab );
    lbl->setText( tr("X-Ref") );
    m_tab->addTab( lbl, QString::null, tr("X-Ref") );

    m_rec = new ORecurranceWidget( true, QDate::currentDate(), this );
    m_tab->addTab( m_rec, QString::null, tr("Recurrance") );


    /* signal and slots */
    connect(m_overView, SIGNAL(recurranceEnabled(bool) ),
            m_rec, SLOT(setEnabled(bool) ) );

    /* connect due date changed to the recurrence tab */
    connect(m_overView, SIGNAL(dueDateChanged(const QDate&) ),
            m_rec, SLOT(setStartDate(const QDate& ) ) );


    m_tab->setCurrentTab( m_overView );
}