summaryrefslogtreecommitdiff
path: root/core/pim/todo
authorzecke <zecke>2002-10-19 02:32:30 (UTC)
committer zecke <zecke>2002-10-19 02:32:30 (UTC)
commit47ea36b68b6c7f12ae3bb777c89d813b4e1360a3 (patch) (unidiff)
treed25ec05f1ccf0db36194d5f2879fe543a34620c2 /core/pim/todo
parent7871e87fbd796c57374b23ec91890962b2ef1fe9 (diff)
downloadopie-47ea36b68b6c7f12ae3bb777c89d813b4e1360a3.zip
opie-47ea36b68b6c7f12ae3bb777c89d813b4e1360a3.tar.gz
opie-47ea36b68b6c7f12ae3bb777c89d813b4e1360a3.tar.bz2
Fix crash if todolist is empty
Fix paint update bugs.. knewly created items did not show up. an sort() QTable::update() is and was not enough A new feature. It's a quick entering method. It lacks icons and some more stuff but I like it Now redoing the Editor Dialog
Diffstat (limited to 'core/pim/todo') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp29
-rw-r--r--core/pim/todo/mainwindow.h16
-rw-r--r--core/pim/todo/quickedit.cpp22
-rw-r--r--core/pim/todo/quickedit.h45
-rw-r--r--core/pim/todo/quickeditimpl.cpp89
-rw-r--r--core/pim/todo/quickeditimpl.h34
-rw-r--r--core/pim/todo/tableview.cpp14
-rw-r--r--core/pim/todo/todo.pro8
8 files changed, 247 insertions, 10 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index a6d657c..8377573 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -37,2 +37,4 @@
37#include <qtimer.h> 37#include <qtimer.h>
38#include <qvbox.h>
39#include <qlineedit.h>
38 40
@@ -46,2 +48,3 @@
46 48
49#include "quickeditimpl.h"
47#include "todotemplatemanager.h" 50#include "todotemplatemanager.h"
@@ -200,4 +203,11 @@ void MainWindow::initConfig() {
200void MainWindow::initUI() { 203void MainWindow::initUI() {
201 m_stack = new QWidgetStack(this, "main stack"); 204 m_mainBox = new QVBox(this, "main box ");
202 setCentralWidget( m_stack ); 205 m_curQuick = new QuickEditImpl(this, m_mainBox );
206 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
207 m_quickEdit.append( m_curQuick );
208
209
210
211 m_stack = new QWidgetStack(m_mainBox, "main stack");
212 setCentralWidget( m_mainBox );
203 213
@@ -226,3 +236,3 @@ void MainWindow::initUI() {
226void MainWindow::initViews() { 236void MainWindow::initViews() {
227 TableView* tableView = new TableView( this, this ); 237 TableView* tableView = new TableView( this, m_stack );
228 m_stack->addWidget( tableView, m_counter++ ); 238 m_stack->addWidget( tableView, m_counter++ );
@@ -683 +693,14 @@ void MainWindow::setReadAhead( uint count ) {
683} 693}
694void MainWindow::slotQuickEntered() {
695 qWarning("entered");
696 OTodo todo = quickEditor()->todo();
697 if (todo.isEmpty() )
698 return;
699
700 m_todoMgr.add( todo );
701 currentView()->addEvent( todo );
702 raiseCurrentView();
703}
704QuickEditBase* MainWindow::quickEditor() {
705 return m_curQuick;
706}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 5a18e64..270cbd1 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -39,2 +39,3 @@
39#include "todoview.h" 39#include "todoview.h"
40#include "quickedit.h"
40#include "todomanager.h" 41#include "todomanager.h"
@@ -47,3 +48,3 @@ class QWidgetStack;
47class Ir; 48class Ir;
48 49class QVBox;
49 50
@@ -55,2 +56,3 @@ namespace Todo {
55 class TemplateEditor; 56 class TemplateEditor;
57 struct QuickEditBase;
56 58
@@ -85,2 +87,3 @@ namespace Todo {
85 TemplateManager* templateManager(); 87 TemplateManager* templateManager();
88 QuickEditBase* quickEditor();
86 89
@@ -91,2 +94,3 @@ namespace Todo {
91private slots: 94private slots:
95 void slotQuickEntered();
92 void populateCategories(); 96 void populateCategories();
@@ -111,2 +115,3 @@ private slots:
111 ViewBase* m_curView; 115 ViewBase* m_curView;
116 QuickEditBase* m_curQuick;
112 Editor* m_curEdit; 117 Editor* m_curEdit;
@@ -135,2 +140,9 @@ private slots:
135 *m_template; 140 *m_template;
141 /* box with two rows
142 * top will be the quick edit
143 * this will bite my ass once
144 * we want to have all parts
145 * exchangeable
146 */
147 QVBox* m_mainBox;
136 148
@@ -143,2 +155,3 @@ private slots:
143 QList<ViewBase> m_views; 155 QList<ViewBase> m_views;
156 QList<QuickEditBase> m_quickEdit;
144 uint m_counter; 157 uint m_counter;
@@ -146,2 +159,3 @@ private slots:
146 159
160
147 private slots: 161 private slots:
diff --git a/core/pim/todo/quickedit.cpp b/core/pim/todo/quickedit.cpp
new file mode 100644
index 0000000..edcd48a
--- a/dev/null
+++ b/core/pim/todo/quickedit.cpp
@@ -0,0 +1,22 @@
1#include "mainwindow.h"
2#include "quickedit.h"
3
4using namespace Todo;
5
6// not so interesting part base Implementation
7QuickEdit::QuickEdit(MainWindow* main )
8 : m_main( main ) {
9 m_sig = new QSignal();
10}
11QuickEdit::~QuickEdit() {
12 delete m_sig;
13}
14QSignal* QuickEdit::signal() {
15 return m_sig;
16}
17MainWindow* QuickEdit::mainWindow() {
18 return m_main;
19}
20void QuickEdit::commit() {
21 m_sig->activate();
22}
diff --git a/core/pim/todo/quickedit.h b/core/pim/todo/quickedit.h
new file mode 100644
index 0000000..5fe74fe
--- a/dev/null
+++ b/core/pim/todo/quickedit.h
@@ -0,0 +1,45 @@
1#ifndef OPIE_QUICK_EDIT_H
2#define OPIE_QUICK_EDIT_H
3
4#include <qsignal.h>
5#include <qwidget.h>
6
7#include <opie/otodo.h>
8
9namespace Todo{
10 class MainWindow;
11 struct QuickEditBase {
12 virtual OTodo todo()const = 0l;
13 virtual QSignal* signal() = 0l;
14 virtual QWidget* widget() = 0l;
15 };
16 /*
17 * this is my second try
18 * of signal and slots with namespaces
19 * and templates
20 * I use a different approach now
21 * I give a QSignal away
22 * and have a protected method called emit
23 */
24 /**
25 * Quick edit is meant to quickly enter
26 * OTodos in a fast way
27 */
28 class QuickEdit : public QuickEditBase{
29 public:
30 QuickEdit(MainWindow* main );
31 virtual ~QuickEdit();
32 //OTodo todo()const;
33 QSignal* signal();
34 //QWidget* widget();
35 protected:
36 MainWindow* mainWindow();
37 void commit();
38 private:
39 MainWindow* m_main;
40 QSignal* m_sig;
41 };
42};
43
44
45#endif
diff --git a/core/pim/todo/quickeditimpl.cpp b/core/pim/todo/quickeditimpl.cpp
new file mode 100644
index 0000000..2dd5b61
--- a/dev/null
+++ b/core/pim/todo/quickeditimpl.cpp
@@ -0,0 +1,89 @@
1#include <qlineedit.h>
2
3#include <opie/oclickablelabel.h>
4
5#include "mainwindow.h"
6#include "quickeditimpl.h"
7
8
9QuickEditImpl::QuickEditImpl( Todo::MainWindow* win, QWidget* arent )
10 : QHBox(arent), Todo::QuickEdit(win) {
11 m_lbl = new OClickableLabel(this );
12 m_lbl->setMinimumWidth(12);
13 m_lbl->setText("3");
14
15 m_edit = new QLineEdit(this );
16
17 m_enter = new OClickableLabel(this);
18 m_enter->setText("Enter");
19
20 m_more = new OClickableLabel(this);
21 m_more->setText("More");
22
23
24 // connect
25 connect(m_lbl, SIGNAL(clicked() ),
26 this, SLOT(slotPrio()) );
27 connect(m_enter, SIGNAL(clicked() ),
28 this, SLOT(slotEnter() ) );
29 connect(m_more, SIGNAL(clicked() ),
30 this, SLOT(slotMore() ) );
31
32 m_menu = 0l;
33 reinit();
34 setMaximumHeight( m_edit->sizeHint().height() );
35}
36QuickEditImpl::~QuickEditImpl() {
37
38}
39OTodo QuickEditImpl::todo()const {
40 return m_todo;
41}
42QWidget* QuickEditImpl::widget() {
43 return this;
44}
45QSize QuickEditImpl::sizeHint()const{
46 return m_edit->sizeHint();
47}
48void QuickEditImpl::slotEnter() {
49 OTodo todo;
50
51
52 if (!m_edit->text().isEmpty() ) {
53 todo.setUid(1 ); // new uid
54 todo.setPriority( m_lbl->text().toInt() );
55 todo.setSummary( m_edit->text() );
56 if ( mainWindow()->currentCatId() != 0 )
57 todo.setCategories( mainWindow()->currentCatId() );
58
59 m_todo = todo;
60 commit();
61 }
62 m_todo = todo;
63 reinit();
64}
65void QuickEditImpl::slotPrio() {
66 m_state++;
67 if (m_state > 2 )
68 m_state = 0;
69
70 switch(m_state ) {
71 case 0:
72 m_lbl->setText( "1" );
73 break;
74 case 2:
75 m_lbl->setText( "5" );
76 break;
77 case 1:
78 default:
79 m_lbl->setText( "3");
80 break;
81 }
82}
83void QuickEditImpl::slotMore() {
84}
85void QuickEditImpl::reinit() {
86 m_state = 1;
87 m_lbl->setText("3");
88 m_edit->clear();
89}
diff --git a/core/pim/todo/quickeditimpl.h b/core/pim/todo/quickeditimpl.h
new file mode 100644
index 0000000..d0f6c69
--- a/dev/null
+++ b/core/pim/todo/quickeditimpl.h
@@ -0,0 +1,34 @@
1#ifndef OPIE_QUICK_EDIT_IMPL_H
2#define OPIE_QUICK_EDIT_IMPL_H
3
4#include <qhbox.h>
5
6#include "quickedit.h"
7
8class QLineEdit;
9class QLabel;
10
11class QuickEditImpl : public QHBox, public Todo::QuickEdit {
12 Q_OBJECT
13public:
14 QuickEditImpl( Todo::MainWindow* win , QWidget* parent);
15 ~QuickEditImpl();
16 OTodo todo()const;
17 QWidget* widget();
18 QSize sizeHint()const;
19private slots:
20 void slotEnter();
21 void slotPrio();
22 void slotMore();
23private:
24 void reinit();
25 int m_state;
26 QLabel* m_lbl;
27 QLineEdit* m_edit;
28 QLabel* m_enter;
29 QLabel* m_more;
30 QPopupMenu* m_menu;
31 OTodo m_todo;
32};
33
34#endif
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index f4b898f..34b8b3c 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -128,4 +128,6 @@ void TableView::showOverDue( bool ) {
128void TableView::updateView( ) { 128void TableView::updateView( ) {
129 qWarning("update view");
129 m_row = false; 130 m_row = false;
130 startTimer( 2000 ); 131 static int id;
132 id = startTimer(2000 );
131 /* FIXME we want one page to be read! 133 /* FIXME we want one page to be read!
@@ -150,2 +152,4 @@ void TableView::updateView( ) {
150 setNumRows( it.count() ); 152 setNumRows( it.count() );
153 if ( it.count() == 0 )
154 killTimer(id);
151 int elc = time.elapsed(); 155 int elc = time.elapsed();
@@ -164,9 +168,8 @@ void TableView::setTodo( int, const OTodo&) {
164 /* repaint */ 168 /* repaint */
165 QTable::update(); 169 repaint();
166} 170}
167void TableView::addEvent( const OTodo&) { 171void TableView::addEvent( const OTodo&) {
168 sort();
169 172
170 /* fix problems of not showing the 'Haken' */ 173 /* fix problems of not showing the 'Haken' */
171 QTable::repaint(); 174 updateView();
172} 175}
@@ -430,2 +433,5 @@ void TableView::slotPriority() {
430void TableView::timerEvent( QTimerEvent* ev ) { 433void TableView::timerEvent( QTimerEvent* ev ) {
434 if (sorted().count() == 0 )
435 return;
436
431 int row = currentRow(); 437 int row = currentRow();
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro
index f26acee..d432e78 100644
--- a/core/pim/todo/todo.pro
+++ b/core/pim/todo/todo.pro
@@ -17,3 +17,5 @@ HEADERS = smalltodo.h \
17 templatedialog.h \ 17 templatedialog.h \
18 templatedialogimpl.h 18 templatedialogimpl.h \
19 quickedit.h \
20 quickeditimpl.h
19 21
@@ -33,3 +35,5 @@ SOURCES = smalltodo.cpp \
33 templatedialog.cpp \ 35 templatedialog.cpp \
34 templatedialogimpl.cpp 36 templatedialogimpl.cpp \
37 quickeditimpl.cpp \
38 quickedit.cpp
35 39