-rw-r--r-- | core/pim/todo/mainwindow.cpp | 29 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 16 | ||||
-rw-r--r-- | core/pim/todo/quickedit.cpp | 22 | ||||
-rw-r--r-- | core/pim/todo/quickedit.h | 45 | ||||
-rw-r--r-- | core/pim/todo/quickeditimpl.cpp | 89 | ||||
-rw-r--r-- | core/pim/todo/quickeditimpl.h | 34 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 14 | ||||
-rw-r--r-- | core/pim/todo/todo.pro | 8 |
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 @@ -14,57 +14,60 @@ : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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; MainWindow::MainWindow( QWidget* parent, const char* name ) { m_syncing = false; m_counter = 0; m_tempManager = new TemplateManager(); m_tempManager->load(); initUI(); initConfig(); initViews(); initActions(); @@ -177,75 +180,82 @@ void MainWindow::initActions() { 0, this, 0, TRUE ); a->addTo( m_view ); a->setOn( showOverDue() ); connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); m_view->insertSeparator(); m_bar->insertItem( tr("View"), m_view ); /* templates */ m_edit->insertItem(tr("New from template"), m_template, -1, 0 ); } /* 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(); } void MainWindow::initShow() { m_curShow = new TextViewShow(this); m_stack->addWidget( m_curShow->widget() , m_counter++ ); } MainWindow::~MainWindow() { delete templateManager(); } void MainWindow::connectBase( ViewBase* base) { base->connectShow( this, SLOT(slotShow(int) ) ); base->connectEdit( this, SLOT(slotEdit(int) ) ); base->connectUpdateSmall( this, SLOT(slotUpate1(int, const Todo::SmallTodo&) )); @@ -660,24 +670,37 @@ void MainWindow::slotEdit( int uid ) { raiseCurrentView(); } /* void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { m_todoMgr.update( uid, ev ); } */ void MainWindow::updateTodo( const OTodo& ev) { m_todoMgr.update( ev.uid() , ev ); } /* The view changed it's configuration * 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 @@ -16,155 +16,169 @@ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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(); QPopupMenu* view(); QToolBar* toolbar(); void updateList(); OTodoAccess::List list()const; 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(); void slotEdit(); void slotFind(); void setCategory( int ); void slotShowDeadLine( bool ); void slotShowCompleted( bool ); void setDocument( const QString& ); void slotBeam(); 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 @@ -105,91 +105,94 @@ TableView::~TableView() { } void TableView::slotShowMenu() { QPopupMenu *menu = todoWindow()->contextMenu( current() ); menu->exec(QCursor::pos() ); delete menu; } QString TableView::type() const { return QString::fromLatin1( tr("Table View") ); } int TableView::current() { int uid = sorted().uidAt(currentRow() ); qWarning("uid %d", uid ); 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 */ void TableView::removeEvent( int ) { updateView(); } void TableView::setShowCompleted( bool b) { qWarning("Show Completed %d" + b ); updateView(); } void TableView::setShowDeadline( bool b) { qWarning("Show DeadLine %d" + b ); if (b) showColumn(3 ); @@ -407,44 +410,47 @@ void TableView::setCellContentFromEditor(int row, int col ) { if ( col == 1 ) { QWidget* wid = cellWidget(row, 1 ); if ( wid->inherits("QComboBox") ) { int pri = ((QComboBox*)wid)->currentItem() + 1; OTodo todo = sorted()[row]; if ( todo.priority() != pri ) { todo.setPriority( pri ); TodoView::update( todo.uid(), todo ); updateView(); } } } } 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]; ro = row-8; if (ro < 0 ) ro = 0; sorted()[ro]; } m_row = !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 @@ -1,55 +1,59 @@ TEMPLATE = app CONFIG = qt warn_on release DESTDIR = $(OPIEDIR)/bin 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 \ ../../../i18n/ja/todolist.ts \ ../../../i18n/ko/todolist.ts \ ../../../i18n/no/todolist.ts \ ../../../i18n/pl/todolist.ts \ ../../../i18n/pt/todolist.ts \ ../../../i18n/pt_BR/todolist.ts \ ../../../i18n/sl/todolist.ts \ ../../../i18n/zh_CN/todolist.ts \ ../../../i18n/zh_TW/todolist.ts |