summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (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
@@ -35,6 +35,8 @@
#include <qwidgetstack.h>
#include <qaction.h>
#include <qtimer.h>
+#include <qvbox.h>
+#include <qlineedit.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
@@ -44,6 +46,7 @@
#include <opie/otodoaccessvcal.h>
+#include "quickeditimpl.h"
#include "todotemplatemanager.h"
#include "templateeditor.h"
#include "todoentryimpl.h"
@@ -198,8 +201,15 @@ void MainWindow::initConfig() {
m_overdue = config.readBoolEntry("ShowOverDue", TRUE );
}
void MainWindow::initUI() {
- m_stack = new QWidgetStack(this, "main stack");
- setCentralWidget( m_stack );
+ m_mainBox = new QVBox(this, "main box ");
+ m_curQuick = new QuickEditImpl(this, m_mainBox );
+ m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
+ m_quickEdit.append( m_curQuick );
+
+
+
+ m_stack = new QWidgetStack(m_mainBox, "main stack");
+ setCentralWidget( m_mainBox );
setToolBarsMovable( FALSE );
@@ -224,7 +234,7 @@ void MainWindow::initUI() {
this, SLOT(slotNewFromTemplate(int) ) );
}
void MainWindow::initViews() {
- TableView* tableView = new TableView( this, this );
+ TableView* tableView = new TableView( this, m_stack );
m_stack->addWidget( tableView, m_counter++ );
m_views.append( tableView );
m_curView = tableView;
@@ -681,3 +691,16 @@ void MainWindow::setReadAhead( uint count ) {
if (m_todoMgr.todoDB() )
m_todoMgr.todoDB()->setReadAhead( count );
}
+void MainWindow::slotQuickEntered() {
+ qWarning("entered");
+ OTodo todo = quickEditor()->todo();
+ if (todo.isEmpty() )
+ return;
+
+ m_todoMgr.add( todo );
+ currentView()->addEvent( todo );
+ raiseCurrentView();
+}
+QuickEditBase* MainWindow::quickEditor() {
+ return m_curQuick;
+}
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
@@ -37,6 +37,7 @@
#include "smalltodo.h"
#include "todoview.h"
+#include "quickedit.h"
#include "todomanager.h"
class QPopupMenu;
@@ -45,7 +46,7 @@ class QToolBar;
class QAction;
class QWidgetStack;
class Ir;
-
+class QVBox;
namespace Todo {
typedef TodoView View;
@@ -53,6 +54,7 @@ namespace Todo {
class Editor;
class TodoShow;
class TemplateEditor;
+ struct QuickEditBase;
class MainWindow : public QMainWindow {
Q_OBJECT
@@ -83,12 +85,14 @@ namespace Todo {
QString currentCategory()const;
int currentCatId();
TemplateManager* templateManager();
+ QuickEditBase* quickEditor();
void updateTodo( const OTodo& );
void populateTemplates();
Editor* currentEditor();
void setReadAhead(uint count );
private slots:
+ void slotQuickEntered();
void populateCategories();
void slotReload();
void slotFlush();
@@ -109,6 +113,7 @@ private slots:
void raiseCurrentView();
ViewBase* currentView();
ViewBase* m_curView;
+ QuickEditBase* m_curQuick;
Editor* m_curEdit;
TodoShow* currentShow();
TodoShow* m_curShow;
@@ -133,6 +138,13 @@ private slots:
*m_options,
*m_view,
*m_template;
+ /* box with two rows
+ * top will be the quick edit
+ * this will bite my ass once
+ * we want to have all parts
+ * exchangeable
+ */
+ QVBox* m_mainBox;
bool m_syncing:1;
bool m_deadline:1;
@@ -141,9 +153,11 @@ private slots:
TodoManager m_todoMgr;
QString m_curCat;
QList<ViewBase> m_views;
+ QList<QuickEditBase> m_quickEdit;
uint m_counter;
TemplateManager* m_tempManager;
+
private slots:
void slotShow(int);
void slotEdit(int);
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 @@
+#include "mainwindow.h"
+#include "quickedit.h"
+
+using namespace Todo;
+
+// not so interesting part base Implementation
+QuickEdit::QuickEdit(MainWindow* main )
+ : m_main( main ) {
+ m_sig = new QSignal();
+}
+QuickEdit::~QuickEdit() {
+ delete m_sig;
+}
+QSignal* QuickEdit::signal() {
+ return m_sig;
+}
+MainWindow* QuickEdit::mainWindow() {
+ return m_main;
+}
+void QuickEdit::commit() {
+ m_sig->activate();
+}
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 @@
+#ifndef OPIE_QUICK_EDIT_H
+#define OPIE_QUICK_EDIT_H
+
+#include <qsignal.h>
+#include <qwidget.h>
+
+#include <opie/otodo.h>
+
+namespace Todo{
+ class MainWindow;
+ struct QuickEditBase {
+ virtual OTodo todo()const = 0l;
+ virtual QSignal* signal() = 0l;
+ virtual QWidget* widget() = 0l;
+ };
+ /*
+ * this is my second try
+ * of signal and slots with namespaces
+ * and templates
+ * I use a different approach now
+ * I give a QSignal away
+ * and have a protected method called emit
+ */
+ /**
+ * Quick edit is meant to quickly enter
+ * OTodos in a fast way
+ */
+ class QuickEdit : public QuickEditBase{
+ public:
+ QuickEdit(MainWindow* main );
+ virtual ~QuickEdit();
+ //OTodo todo()const;
+ QSignal* signal();
+ //QWidget* widget();
+ protected:
+ MainWindow* mainWindow();
+ void commit();
+ private:
+ MainWindow* m_main;
+ QSignal* m_sig;
+ };
+};
+
+
+#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 @@
+#include <qlineedit.h>
+
+#include <opie/oclickablelabel.h>
+
+#include "mainwindow.h"
+#include "quickeditimpl.h"
+
+
+QuickEditImpl::QuickEditImpl( Todo::MainWindow* win, QWidget* arent )
+ : QHBox(arent), Todo::QuickEdit(win) {
+ m_lbl = new OClickableLabel(this );
+ m_lbl->setMinimumWidth(12);
+ m_lbl->setText("3");
+
+ m_edit = new QLineEdit(this );
+
+ m_enter = new OClickableLabel(this);
+ m_enter->setText("Enter");
+
+ m_more = new OClickableLabel(this);
+ m_more->setText("More");
+
+
+ // connect
+ connect(m_lbl, SIGNAL(clicked() ),
+ this, SLOT(slotPrio()) );
+ connect(m_enter, SIGNAL(clicked() ),
+ this, SLOT(slotEnter() ) );
+ connect(m_more, SIGNAL(clicked() ),
+ this, SLOT(slotMore() ) );
+
+ m_menu = 0l;
+ reinit();
+ setMaximumHeight( m_edit->sizeHint().height() );
+}
+QuickEditImpl::~QuickEditImpl() {
+
+}
+OTodo QuickEditImpl::todo()const {
+ return m_todo;
+}
+QWidget* QuickEditImpl::widget() {
+ return this;
+}
+QSize QuickEditImpl::sizeHint()const{
+ return m_edit->sizeHint();
+}
+void QuickEditImpl::slotEnter() {
+ OTodo todo;
+
+
+ if (!m_edit->text().isEmpty() ) {
+ todo.setUid(1 ); // new uid
+ todo.setPriority( m_lbl->text().toInt() );
+ todo.setSummary( m_edit->text() );
+ if ( mainWindow()->currentCatId() != 0 )
+ todo.setCategories( mainWindow()->currentCatId() );
+
+ m_todo = todo;
+ commit();
+ }
+ m_todo = todo;
+ reinit();
+}
+void QuickEditImpl::slotPrio() {
+ m_state++;
+ if (m_state > 2 )
+ m_state = 0;
+
+ switch(m_state ) {
+ case 0:
+ m_lbl->setText( "1" );
+ break;
+ case 2:
+ m_lbl->setText( "5" );
+ break;
+ case 1:
+ default:
+ m_lbl->setText( "3");
+ break;
+ }
+}
+void QuickEditImpl::slotMore() {
+}
+void QuickEditImpl::reinit() {
+ m_state = 1;
+ m_lbl->setText("3");
+ m_edit->clear();
+}
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 @@
+#ifndef OPIE_QUICK_EDIT_IMPL_H
+#define OPIE_QUICK_EDIT_IMPL_H
+
+#include <qhbox.h>
+
+#include "quickedit.h"
+
+class QLineEdit;
+class QLabel;
+
+class QuickEditImpl : public QHBox, public Todo::QuickEdit {
+ Q_OBJECT
+public:
+ QuickEditImpl( Todo::MainWindow* win , QWidget* parent);
+ ~QuickEditImpl();
+ OTodo todo()const;
+ QWidget* widget();
+ QSize sizeHint()const;
+private slots:
+ void slotEnter();
+ void slotPrio();
+ void slotMore();
+private:
+ void reinit();
+ int m_state;
+ QLabel* m_lbl;
+ QLineEdit* m_edit;
+ QLabel* m_enter;
+ QLabel* m_more;
+ QPopupMenu* m_menu;
+ OTodo m_todo;
+};
+
+#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
@@ -126,8 +126,10 @@ void TableView::showOverDue( bool ) {
}
void TableView::updateView( ) {
+ qWarning("update view");
m_row = false;
- startTimer( 2000 );
+ static int id;
+ id = startTimer(2000 );
/* FIXME we want one page to be read!
*
* Calculate that screensize
@@ -148,6 +150,8 @@ void TableView::updateView( ) {
QTime t;
t.start();
setNumRows( it.count() );
+ if ( it.count() == 0 )
+ killTimer(id);
int elc = time.elapsed();
qWarning("Adding took %d", elc/1000 );
setUpdatesEnabled( true );
@@ -162,13 +166,12 @@ void TableView::setTodo( int, const OTodo&) {
sort();
/* repaint */
- QTable::update();
+ repaint();
}
void TableView::addEvent( const OTodo&) {
- sort();
/* fix problems of not showing the 'Haken' */
- QTable::repaint();
+ updateView();
}
/*
* find the event
@@ -428,6 +431,9 @@ void TableView::slotPriority() {
*
*/
void TableView::timerEvent( QTimerEvent* ev ) {
+ if (sorted().count() == 0 )
+ return;
+
int row = currentRow();
qWarning("TimerEvent %d", row);
if ( m_row ) {
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
@@ -15,7 +15,9 @@ HEADERS = smalltodo.h \
textviewshow.h \
templateeditor.h \
templatedialog.h \
- templatedialogimpl.h
+ templatedialogimpl.h \
+ quickedit.h \
+ quickeditimpl.h
SOURCES = smalltodo.cpp \
todomanager.cpp \
@@ -31,7 +33,9 @@ SOURCES = smalltodo.cpp \
textviewshow.cpp \
templateeditor.cpp \
templatedialog.cpp \
- templatedialogimpl.cpp
+ templatedialogimpl.cpp \
+ quickeditimpl.cpp \
+ quickedit.cpp
INTERFACES = todoentry.ui
TARGET = todolist