Diffstat (limited to 'core/pim/todo/taskeditoroverviewimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/todo/taskeditoroverviewimpl.cpp | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/core/pim/todo/taskeditoroverviewimpl.cpp b/core/pim/todo/taskeditoroverviewimpl.cpp new file mode 100644 index 0000000..b9b2ae6 --- a/dev/null +++ b/core/pim/todo/taskeditoroverviewimpl.cpp | |||
@@ -0,0 +1,169 @@ | |||
1 | #include <qapplication.h> | ||
2 | #include <qcheckbox.h> | ||
3 | #include <qcombobox.h> | ||
4 | #include <qpopupmenu.h> | ||
5 | |||
6 | #include <qpe/datebookmonth.h> | ||
7 | #include <qpe/categoryselect.h> | ||
8 | #include <qpe/timestring.h> | ||
9 | |||
10 | #include "taskeditoroverviewimpl.h" | ||
11 | |||
12 | /* | ||
13 | * we need to hack | ||
14 | */ | ||
15 | |||
16 | TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* name ) | ||
17 | : TaskEditorOverView( parent, name ) { | ||
18 | init(); | ||
19 | } | ||
20 | TaskEditorOverViewImpl::~TaskEditorOverViewImpl() { | ||
21 | } | ||
22 | void TaskEditorOverViewImpl::load( const OTodo& todo) { | ||
23 | QDate date = QDate::currentDate(); | ||
24 | QString str = TimeString::longDateString( date ); | ||
25 | |||
26 | emit recurranceEnabled( FALSE ); | ||
27 | ckbStart->setChecked( FALSE ); | ||
28 | btnStart->setText( str ); | ||
29 | |||
30 | ckbComp->setChecked( FALSE ); | ||
31 | btnComp->setText( str ); | ||
32 | |||
33 | cmbProgress->setCurrentItem( todo.progress()/20 ); | ||
34 | cmbSum->insertItem( todo.summary(), 0 ); | ||
35 | cmbSum->setCurrentItem( 0 ); | ||
36 | |||
37 | ckbDue->setChecked( todo.hasDueDate() ); | ||
38 | btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); | ||
39 | |||
40 | cmbPrio->setCurrentItem( todo.priority() -1 ); | ||
41 | ckbCompleted->setChecked( todo.isCompleted() ); | ||
42 | |||
43 | comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); | ||
44 | |||
45 | } | ||
46 | void TaskEditorOverViewImpl::save( OTodo& to) { | ||
47 | qWarning("save it now"); | ||
48 | if ( ckbDue->isChecked() ) { | ||
49 | to.setDueDate( m_due ); | ||
50 | to.setHasDueDate( true ); | ||
51 | }else | ||
52 | to.setHasDueDate( false ); | ||
53 | if ( comboCategory->currentCategory() != -1 ) { | ||
54 | QArray<int> arr = comboCategory->currentCategories(); | ||
55 | to.setCategories( arr ); | ||
56 | } | ||
57 | to.setPriority( cmbPrio->currentItem() + 1 ); | ||
58 | to.setCompleted( ckbCompleted->isChecked() ); | ||
59 | to.setSummary( cmbSum->currentText() ); | ||
60 | to.setProgress( cmbProgress->currentItem() * 20 ); | ||
61 | } | ||
62 | /* | ||
63 | * here we will init the basic view | ||
64 | * one Popup for each Date Button | ||
65 | * and some other signal and slots connection | ||
66 | */ | ||
67 | void TaskEditorOverViewImpl::init() { | ||
68 | QDate curDate = QDate::currentDate(); | ||
69 | m_start = m_comp = m_due = curDate; | ||
70 | QString str = TimeString::longDateString( curDate ); | ||
71 | |||
72 | /* Start Date Picker */ | ||
73 | m_startPop = new QPopupMenu(this); | ||
74 | m_startBook = new DateBookMonth(m_startPop, 0, TRUE ); | ||
75 | m_startPop->insertItem( m_startBook ); | ||
76 | connect( m_startBook, SIGNAL( dateClicked(int, int, int) ), | ||
77 | this, SLOT(slotStartChanged(int, int, int) ) ); | ||
78 | |||
79 | |||
80 | /* Due Date Picker */ | ||
81 | m_duePop = new QPopupMenu(this); | ||
82 | m_dueBook = new DateBookMonth(m_duePop, 0, TRUE ); | ||
83 | m_duePop->insertItem( m_dueBook ); | ||
84 | connect( m_dueBook, SIGNAL( dateClicked(int, int, int) ), | ||
85 | this, SLOT(slotDueChanged(int, int, int) ) ); | ||
86 | |||
87 | m_compPop = new QPopupMenu(this); | ||
88 | m_compBook = new DateBookMonth(m_compPop, 0, TRUE ); | ||
89 | m_compPop->insertItem(m_compBook ); | ||
90 | connect( m_compBook, SIGNAL(dateClicked(int, int, int) ), | ||
91 | this, SLOT(slotCompletedChanged(int, int, int) ) ); | ||
92 | |||
93 | |||
94 | /* | ||
95 | * another part of the hack | ||
96 | * it's deprecated in Qt2 but | ||
97 | * still available in my qt-copy of Qt3.1beta2 | ||
98 | */ | ||
99 | btnDue->setIsMenuButton( TRUE ); | ||
100 | btnStart->setIsMenuButton( TRUE ); | ||
101 | btnComp->setIsMenuButton( TRUE ); | ||
102 | |||
103 | /* now connect the hack */ | ||
104 | connect(btnDue, SIGNAL(clicked() ), | ||
105 | this, SLOT(hackySlotHack2() ) ); | ||
106 | connect(btnStart, SIGNAL(clicked() ), | ||
107 | this, SLOT(hackySlotHack1() ) ); | ||
108 | connect(btnComp, SIGNAL(clicked() ), | ||
109 | this, SLOT(hackySlotHack3() ) ); | ||
110 | |||
111 | /* recurrance */ | ||
112 | connect(CheckBox7, SIGNAL(clicked() ), | ||
113 | this, SLOT(slotRecClicked() ) ); | ||
114 | } | ||
115 | |||
116 | void TaskEditorOverViewImpl::slotStartChecked() { | ||
117 | qWarning("slotStartChecked"); | ||
118 | btnStart->setEnabled( ckbStart->isChecked() ); | ||
119 | } | ||
120 | void TaskEditorOverViewImpl::slotStartChanged(int y, int m, int d) { | ||
121 | m_start.setYMD( y, m, d ); | ||
122 | btnStart->setText( TimeString::longDateString( m_start ) ); | ||
123 | } | ||
124 | void TaskEditorOverViewImpl::slotDueChecked() { | ||
125 | btnDue->setEnabled( ckbDue->isChecked() ); | ||
126 | qWarning("slotDueChecked"); | ||
127 | } | ||
128 | void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) { | ||
129 | m_due.setYMD(y, m, d ); | ||
130 | btnDue->setText( TimeString::longDateString( m_due ) ); | ||
131 | } | ||
132 | void TaskEditorOverViewImpl::slotCompletedChecked() { | ||
133 | btnComp->setEnabled( ckbComp->isChecked() ); | ||
134 | qWarning("slotCompletedChecked"); | ||
135 | } | ||
136 | void TaskEditorOverViewImpl::slotCompletedChanged(int y, int m, int d) { | ||
137 | m_comp.setYMD( y, m, d ); | ||
138 | btnComp->setText( TimeString::longDateString( m_comp ) ); | ||
139 | } | ||
140 | /* | ||
141 | * called by a button pressed event... | ||
142 | * three slots to avoid ugly name() tests | ||
143 | * to sender() | ||
144 | */ | ||
145 | void TaskEditorOverViewImpl::hackySlotHack1() { | ||
146 | btnStart->setDown( FALSE ); | ||
147 | popup( btnStart, m_startPop ); | ||
148 | } | ||
149 | void TaskEditorOverViewImpl::hackySlotHack2() { | ||
150 | btnDue->setDown( FALSE ); | ||
151 | popup( btnDue, m_duePop ); | ||
152 | } | ||
153 | void TaskEditorOverViewImpl::hackySlotHack3() { | ||
154 | btnComp->setDown( FALSE ); | ||
155 | popup( btnComp, m_compPop ); | ||
156 | } | ||
157 | void TaskEditorOverViewImpl::slotRecClicked() { | ||
158 | qWarning("enabled recurrance"); | ||
159 | emit recurranceEnabled( CheckBox7->isChecked() ); | ||
160 | } | ||
161 | /* | ||
162 | * GPL from TT QPushButton code | ||
163 | */ | ||
164 | void TaskEditorOverViewImpl::popup( QPushButton* pu, QPopupMenu* pop) { | ||
165 | if ( pu->mapToGlobal( QPoint(0, pu->rect().bottom() ) ).y() + pop->sizeHint().height() <= qApp->desktop()->height() ) | ||
166 | pop->exec( pu->mapToGlobal( pu->rect().bottomLeft() ) ); | ||
167 | else | ||
168 | pop->exec( pu->mapToGlobal( pu->rect().topLeft() - QPoint(0, pu->sizeHint().height() ) ) ); | ||
169 | } | ||