-rw-r--r-- | core/pim/todo/mainwindow.cpp | 52 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 1 | ||||
-rw-r--r-- | core/pim/todo/todo.pro | 2 |
3 files changed, 48 insertions, 7 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index c9c43d4..2994915 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -1,89 +1,93 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2002 <> .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . 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 <qpe/applnk.h> #include <qpe/config.h> #include <qpe/ir.h> #include <qpe/resource.h> #include <qpe/qpemessagebox.h> +#include <opie/otodoaccessvcal.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(); initEditor(); initShow(); initTemplate(); populateTemplates(); raiseCurrentView(); QTimer::singleShot(0, this, SLOT(populateCategories() ) ); } void MainWindow::initTemplate() { m_curTempEd = new TemplateEditor( this, templateManager() ); } void MainWindow::initActions() { QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); connect(a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); a->addTo(m_tool ); a->addTo(m_edit ); a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), QString::null, 0, this, 0 ); connect(a, SIGNAL(activated() ), this, SLOT( slotEdit() ) ); @@ -483,104 +487,140 @@ void MainWindow::slotDeleteCompleted() { // FIXME //m_todoMgr.remove( currentView()->completed() ); currentView()->updateView( ); } void MainWindow::slotFind() { } void MainWindow::slotEdit() { slotEdit( currentView()->current() ); } /* * set the category */ void MainWindow::setCategory( int c) { if ( c <= 0 ) return; qWarning("Iterating over cats %d", c ); for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) m_catMenu->setItemChecked(i, c == (int)i ); if (c == 1 ) { m_curCat = QString::null; setCaption( tr("Todo") + " - " + tr("All Categories" ) ); }else if ( c == (int)m_catMenu->count() - 1 ) { m_curCat = tr("Unfiled"); setCaption( tr("Todo") + " - " + tr("Unfiled") ); }else { m_curCat = m_todoMgr.categories()[c-2]; setCaption( tr("Todo") + " - " + m_curCat ); } m_catMenu->setItemChecked( c, true ); currentView()->setShowCategory( m_curCat ); raiseCurrentView(); } void MainWindow::slotShowDeadLine( bool dead) { m_deadline = dead; currentView()->setShowDeadline( dead ); } void MainWindow::slotShowCompleted( bool show) { m_completed = show; currentView()->setShowCompleted( m_completed ); } bool MainWindow::showOverDue()const { return m_overdue; } -void MainWindow::setDocument( const QString& ) { - +void MainWindow::setDocument( const QString& fi) { + DocLnk doc(fi); + if (doc.isValid() ) + receiveFile(doc.file() ); + else + receiveFile(fi ); } -void MainWindow::slotBeam() { - -} -void MainWindow::beamDone( Ir* ) { +static const char *beamfile = "/tmp/opie-todo.vcs"; +void MainWindow::slotBeam() { + ::unlink( beamfile ); + OTodo todo = event( currentView()->current() ); + OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); + OTodoAccess acc( cal ); + acc.load(); + acc.add( todo ); + acc.save(); + Ir* ir = new Ir(this ); + connect(ir, SIGNAL(done(Ir*) ), + this, SLOT(beamDone(Ir*) ) ); + ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); + +} +void MainWindow::beamDone( Ir* ir) { + delete ir; + ::unlink( beamfile ); +} +void MainWindow::receiveFile( const QString& filename ) { + OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); + OTodoAccess acc( cal ); + acc.load(); + OTodoAccess::List list = acc.allRecords(); + + QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); + + if ( QMessageBox::information(this, tr("New Tasks"), + message, QMessageBox::Ok, + QMessageBox::Cancel ) == QMessageBox::Ok ) { + OTodoAccess::List::Iterator it; + for ( it = list.begin(); it != list.end(); ++it ) + m_todoMgr.add( (*it) ); + + currentView()->updateView(); + } } void MainWindow::slotFlush() { m_syncing = FALSE; m_todoMgr.save(); } void MainWindow::slotShowDetails() { slotShow( currentView()->current() ); } /* * populate the Categories * Menu */ void MainWindow::populateCategories() { m_todoMgr.load(); m_catMenu->clear(); int id, rememberId; id = 1; rememberId = 1; m_catMenu->insertItem( tr( "All Categories" ), id++ ); m_catMenu->insertSeparator(); QStringList categories = m_todoMgr.categories(); categories.append( tr( "Unfiled" ) ); for ( QStringList::Iterator it = categories.begin(); it != categories.end(); ++it ) { m_catMenu->insertItem( *it, id ); if ( *it == currentCategory() ) rememberId = id; ++id; } setCategory( rememberId ); } bool MainWindow::showCompleted()const { return m_completed; } bool MainWindow::showDeadline()const { return m_deadline; } QString MainWindow::currentCategory()const { return m_curCat; } int MainWindow::currentCatId() { return m_todoMgr.catId( m_curCat ); } ViewBase* MainWindow::currentView() { return m_curView; diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index 598c3af..8d0c29f 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h @@ -51,96 +51,97 @@ namespace Todo { typedef TodoView View; class TemplateManager; class Editor; class TodoShow; class TemplateEditor; 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(); void updateTodo( const OTodo& ); void populateTemplates(); Editor* currentEditor(); private slots: 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; 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; 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; uint m_counter; TemplateManager* m_tempManager; private slots: void slotShow(int); diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro index 3ff78f5..f26acee 100644 --- a/core/pim/todo/todo.pro +++ b/core/pim/todo/todo.pro @@ -1,50 +1,50 @@ TEMPLATE = app -CONFIG = qt warn_on debug +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 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 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 \ |