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
@@ -26,33 +26,36 @@
*/
#include <unistd.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qtoolbar.h>
#include <qpopupmenu.h>
#include <qwidgetstack.h>
#include <qaction.h>
#include <qtimer.h>
+#include <qvbox.h>
+#include <qlineedit.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qpe/ir.h>
#include <qpe/resource.h>
#include <qpe/qpemessagebox.h>
#include <opie/otodoaccessvcal.h>
+#include "quickeditimpl.h"
#include "todotemplatemanager.h"
#include "templateeditor.h"
#include "todoentryimpl.h"
#include "tableview.h"
#include "textviewshow.h"
#include "todoeditor.h"
#include "mainwindow.h"
using namespace Todo;
@@ -189,51 +192,58 @@ void MainWindow::initActions() {
}
/* m_curCat from Config */
void MainWindow::initConfig() {
Config config( "todo" );
config.setGroup( "View" );
m_completed = config.readBoolEntry( "ShowComplete", TRUE );
m_curCat = config.readEntry( "Category", QString::null );
m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
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 );
m_tool = new QToolBar( this );
m_tool->setHorizontalStretchable( TRUE );
m_bar = new QMenuBar( m_tool );
/** QPopupMenu */
m_edit = new QPopupMenu( this );
m_options = new QPopupMenu( this );
m_view = new QPopupMenu( this );
m_catMenu = new QPopupMenu( this );
m_template = new QPopupMenu( this );
m_catMenu->setCheckable( TRUE );
m_template->setCheckable( TRUE );
connect(m_catMenu, SIGNAL(activated(int) ),
this, SLOT(setCategory(int) ) );
connect(m_template, SIGNAL(activated(int) ),
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;
connectBase( tableView );
/* add QString type + QString configname to
* the View menu
* and subdirs for multiple views
*/
}
void MainWindow::initEditor() {
m_curEdit = new Editor();
}
@@ -672,12 +682,25 @@ void MainWindow::updateTodo( const OTodo& ev) {
* update the view menu
*/
void MainWindow::slotUpdate3( QWidget* ) {
}
void MainWindow::updateList() {
m_todoMgr.updateList();
}
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
@@ -28,40 +28,42 @@
#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 "quickedit.h"
#include "todomanager.h"
class QPopupMenu;
class QMenuBar;
class QToolBar;
class QAction;
class QWidgetStack;
class Ir;
-
+class QVBox;
namespace Todo {
typedef TodoView View;
class TemplateManager;
class Editor;
class TodoShow;
class TemplateEditor;
+ struct QuickEditBase;
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();
@@ -74,85 +76,97 @@ namespace Todo {
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();
+ QuickEditBase* quickEditor();
void updateTodo( const OTodo& );
void populateTemplates();
Editor* currentEditor();
void setReadAhead(uint count );
private slots:
+ void slotQuickEntered();
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;
+ QuickEditBase* m_curQuick;
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;
+ /* 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;
bool m_completed:1;
bool m_overdue:1;
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);
private slots:
void slotUpdate3( QWidget* );
void slotNewFromTemplate(int id );
void slotNew();
void slotDuplicate();
void slotDelete();
void slotDeleteAll();
void slotDeleteCompleted();
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
@@ -117,67 +117,70 @@ int TableView::current() {
return uid;
}
QString TableView::currentRepresentation() {
return text( currentRow(), 2);
}
/* show overdue */
void TableView::showOverDue( bool ) {
clear();
updateView();
}
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
*/
todoWindow()->setReadAhead( 4 );
sort();
OTodoAccess::List::Iterator it, end;
it = sorted().begin();
end = sorted().end();
qWarning("setTodos");
QTime time;
time.start();
m_enablePaint = false;
setUpdatesEnabled( false );
viewport()->setUpdatesEnabled( false );
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 );
viewport()->setUpdatesEnabled( true );
viewport()->update();
m_enablePaint = true;
int el = time.elapsed();
qWarning("adding took %d", el/1000 );
}
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
* and then replace the complete row
*/
void TableView::replaceEvent( const OTodo& ev) {
addEvent( ev );
}
/*
* re aligning table can be slow too
* FIXME: look what performs better
* either this or the old align table
@@ -419,24 +422,27 @@ void TableView::setCellContentFromEditor(int row, int col ) {
}
void TableView::slotPriority() {
setCellContentFromEditor( currentRow(), currentColumn() );
}
/*
* We'll use the TimerEvent to read ahead or to keep the cahce always
* filled enough.
* We will try to read ahead 4 items in both ways
* up and down. On odd or even we will currentRow()+-4 or +-9
*
*/
void TableView::timerEvent( QTimerEvent* ev ) {
+ if (sorted().count() == 0 )
+ return;
+
int row = currentRow();
qWarning("TimerEvent %d", row);
if ( m_row ) {
int ro = row-4;
if (ro < 0 ) ro = 0;
sorted()[ro];
ro = row+4;
sorted()[ro];
} else {
int ro = row + 8;
sorted()[ro];
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
@@ -6,41 +6,45 @@ HEADERS = smalltodo.h \
todomanager.h \
mainwindow.h \
todoview.h \
todoentryimpl.h \
tableview.h \
tableitems.h \
todotemplatemanager.h \
todoeditor.h \
todoshow.h \
textviewshow.h \
templateeditor.h \
templatedialog.h \
- templatedialogimpl.h
+ templatedialogimpl.h \
+ quickedit.h \
+ quickeditimpl.h
SOURCES = smalltodo.cpp \
todomanager.cpp \
mainwindow.cpp \
main.cpp \
todoentryimpl.cpp \
tableview.cpp \
tableitems.cpp \
todoview.cpp \
todotemplatemanager.cpp \
todoeditor.cpp \
todoshow.cpp \
textviewshow.cpp \
templateeditor.cpp \
templatedialog.cpp \
- templatedialogimpl.cpp
+ templatedialogimpl.cpp \
+ quickeditimpl.cpp \
+ quickedit.cpp
INTERFACES = todoentry.ui
TARGET = todolist
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie
TRANSLATIONS = ../../../i18n/de/todolist.ts \
../../../i18n/en/todolist.ts \
../../../i18n/es/todolist.ts \
../../../i18n/fr/todolist.ts \
../../../i18n/hu/todolist.ts \