-rw-r--r-- | core/pim/datebook2/bookmanager.cpp | 67 | ||||
-rw-r--r-- | core/pim/datebook2/bookmanager.h | 7 | ||||
-rw-r--r-- | core/pim/datebook2/datebook2.pro | 19 | ||||
-rw-r--r-- | core/pim/datebook2/mainwindow.cpp | 178 | ||||
-rw-r--r-- | core/pim/datebook2/mainwindow.h | 60 | ||||
-rw-r--r-- | core/pim/datebook2/managertemplate.h | 39 | ||||
-rw-r--r-- | core/pim/datebook2/show.cpp | 25 | ||||
-rw-r--r-- | core/pim/datebook2/show.h | 15 | ||||
-rw-r--r-- | core/pim/datebook2/stringmanager.cpp | 42 | ||||
-rw-r--r-- | core/pim/datebook2/stringmanager.h | 11 | ||||
-rw-r--r-- | core/pim/datebook2/templatemanager.cpp | 25 | ||||
-rw-r--r-- | core/pim/datebook2/view.cpp | 62 | ||||
-rw-r--r-- | core/pim/datebook2/view.h | 25 |
13 files changed, 546 insertions, 29 deletions
diff --git a/core/pim/datebook2/bookmanager.cpp b/core/pim/datebook2/bookmanager.cpp new file mode 100644 index 0000000..4fcd413 --- a/dev/null +++ b/core/pim/datebook2/bookmanager.cpp @@ -0,0 +1,67 @@ +#include "bookmanager.h" + +using namespace Datebook; + +BookManager::BookManager() { + m_db = 0; +} +BookManager::~BookManager() { + delete m_db; +} +void BookManager::add( const OEvent& ev) { + if (!m_db ) return; + + m_db->add( ev ); +} +void BookManager::add( const OPimRecord& rec ) { + if (!m_db) load(); // we might where called by setDocument... before we even fully initialized + m_db->add( rec ); +} +void BookManager::update( const OEvent& up) { + if ( !m_db ) return; + m_db->replace( up ); +} +void BookManager::remove( int uid ) { + if ( !m_db ) return; + m_db->remove( uid ); +} +void BookManager::remove( const QArray<int>& ar) { + uint count = ar.count(); + for (uint i = 0; i < count; i++ ) + remove( ar[i] ); +} +QList<OPimRecord> BookManager::records( const QDate& , const QDate& ) { + return QList<OPimRecord>(); +} +bool BookManager::isLoaded() const{ + return ( m_db != 0 ); +} +bool BookManager::load() { + m_db = new ODateBookAccess; + return m_db->load(); +} +void BookManager::reload() { + if (!m_db ) return; + + m_db->reload(); +} +OEvent BookManager::event( int uid ) { + if (!m_db ) return OEvent(); + + return m_db->find( uid ); +} +ODateBookAccess::List BookManager::allRecords()const { + if (!m_db) return ODateBookAccess::List(); + + return m_db->rawEvents(); +} +OEffectiveEvent::ValueList BookManager::list( const QDate& from, + const QDate& to ) { + if (!m_db) return OEffectiveEvent::ValueList(); + + return m_db->effectiveEvents( from, to ); +} +bool BookManager::save() { + if (!m_db) return false; + return m_db->save(); +} diff --git a/core/pim/datebook2/bookmanager.h b/core/pim/datebook2/bookmanager.h index 44ad8ed..c5dee4a 100644 --- a/core/pim/datebook2/bookmanager.h +++ b/core/pim/datebook2/bookmanager.h @@ -22,2 +22,3 @@ namespace Datebook { bool load(); + void reload(); bool save(); @@ -30,2 +31,3 @@ namespace Datebook { void add( const OEvent& ); + void add( const OPimRecord& ); void update( const OEvent& ); @@ -34,4 +36,7 @@ namespace Datebook { - QPtrList<OPimRecord> records( const QDate& from, + QList<OPimRecord> records( const QDate& from, const QDate& to ); + + private: + ODateBookAccess* m_db; }; diff --git a/core/pim/datebook2/datebook2.pro b/core/pim/datebook2/datebook2.pro index 9d6ef4c..2ad906e 100644 --- a/core/pim/datebook2/datebook2.pro +++ b/core/pim/datebook2/datebook2.pro @@ -3,5 +3,20 @@ CONFIG += qt warn_on release DESTDIR = $(OPIEDIR)/bin -HEADERS = mainwindow.h +HEADERS = mainwindow.h \ + bookmanager.h \ + locationmanager.h \ + show.h \ + view.h \ + descriptionmanager.h \ + stringmanager.h \ + editor.h \ + managertemplate.h \ + templatemanager.h + SOURCES = main.cpp \ - mainwindow.cpp + mainwindow.cpp \ + bookmanager.cpp \ + stringmanager.cpp \ + templatemanager.cpp \ + show.cpp \ + view.cpp diff --git a/core/pim/datebook2/mainwindow.cpp b/core/pim/datebook2/mainwindow.cpp index 2f214b8..44de6b0 100644 --- a/core/pim/datebook2/mainwindow.cpp +++ b/core/pim/datebook2/mainwindow.cpp @@ -1 +1,3 @@ + +#include <qcopchannel_qws.h> #include <qwidgetstack.h> @@ -3,5 +5,9 @@ #include <qaction.h> +#include <qpopupmenu.h> +#include <qtimer.h> +#include <qpe/qpeapplication.h> #include <qpe/ir.h> #include <qpe/qpemenubar.h> +#include <qpe/qpetoolbar.h> #include <qpe/qpemessagebox.h> @@ -9,3 +15,5 @@ - +#include "show.h" +#include "templatemanager.h" +#include "bookmanager.h" #include "mainwindow.h" @@ -17,6 +25,7 @@ MainWindow::MainWindow() : OPimMainWindow( "Datebook", 0, 0 ) { + setIcon( Resource::loadPixmap( "datebook_icon" ) ); initUI(); - initConfig(); - initView(); initManagers(); + initView(); + initConfig(); @@ -24,5 +33,12 @@ MainWindow::MainWindow() QTimer::singleShot(0, this, SLOT(populate() ) ); + + QCopChannel* chan = new QCopChannel( "QPE/System", this ); + connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), + this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); + + chan = new QCopChannel( "QPE/Datebook", this ); + connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), + this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); } MainWindow::~MainWindow() { - } @@ -32,12 +48,13 @@ void MainWindow::doSetDocument( const QString& str ) { void MainWindow::flush() { - + manager()->save(); } void MainWindow::reload() { - + manager()->reload(); } int MainWindow::create() { - + return 0; } bool MainWindow::remove( int uid ) { - + manager()->remove( uid ); + return true; } @@ -48,5 +65,9 @@ void MainWindow::show( int uid ) { + eventShow()->show( manager()->event( uid ) ); } -void MainWindow::add( const OPimRecord& ) { - +void MainWindow::add( const OPimRecord& ad) { + manager()->add( ad ); +} +void MainWindow::edit() { + edit ( currentView()->currentItem() ); } @@ -55,4 +76,65 @@ void MainWindow::edit( int uid ) { } +/* + * init tool bars layout and so on + */ void MainWindow::initUI() { + setToolBarsMovable( false ); + + m_stack = new QWidgetStack( this ); + setCentralWidget( m_stack ); + + m_toolBar = new QPEToolBar( this ); + m_toolBar->setHorizontalStretchable( TRUE ); + + QPEMenuBar* mb = new QPEMenuBar( m_toolBar ); + m_popView = new QPopupMenu( this ); + m_popSetting = new QPopupMenu( this ); + + mb->insertItem( tr("View"), m_popView ); + mb->insertItem( tr("Settings" ), m_popSetting ); + + m_popTemplate = new QPopupMenu( this ); + m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); + + QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), + QString::null, 0, this, 0 ); + a->addTo( m_toolBar ); + a->addTo( m_popView ); + connect(a, SIGNAL( activated() ), this, SLOT( create() ) ); + + a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"), + QString::null, 0, this, 0 ); + a->addTo( m_popView ); + connect(a, SIGNAL( activated() ), this, SLOT( edit() ) ); + + a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"), + QString::null, 0, this, 0 ); + a->addTo( m_toolBar ); + connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) ); + + a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ), + QString::null, 0, this, 0 ); + a->addTo( m_toolBar ); + connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); + + a = new QAction( tr("Configure"), QString::null, 0, 0 ); + a->addTo( m_popSetting ); + connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); + + a = new QAction( tr("Configure Locations"), QString::null, 0, 0 ); + a->addTo( m_popSetting ); + connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) ); + + a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 ); + a->addTo( m_popSetting ); + connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) ); + + connect( qApp, SIGNAL(clockChanged(bool) ), + this, SLOT(slotClockChanged(bool) ) ); + connect( qApp, SIGNAL(weekChanged(bool) ), + this, SLOT(slotWeekChanged(bool) ) ); + + connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), + this, SLOT(slotAppMessage( const QCString&, const QByteArray& ) ) ); } @@ -65,3 +147,5 @@ void MainWindow::initView() { void MainWindow::initManagers() { - + m_manager = new BookManager; + m_locMan = new LocationManager( tr("Locations") ); + m_descMan = new DescriptionManager( tr("Descriptions") ); } @@ -70 +154,73 @@ void MainWindow::raiseCurrentView() { } +/* + * populate the view + */ +void MainWindow::populate() { + if (!manager()->isLoaded() ) + manager()->load(); +} +void MainWindow::slotGoToNow() { + +} +View* MainWindow::currentView() { + +} +void MainWindow::slotFind() { + +} +void MainWindow::slotConfigure() { + +} +void MainWindow::slotClockChanged( bool ) { + +} +void MainWindow::slotWeekChanged(bool ) { + +} +void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { + +} +void MainWindow::slotReceive( const QCString&, const QByteArray& ) { + +} +BookManager* MainWindow::manager() { + return m_manager; +} +TemplateManager* MainWindow::templateManager() { + return m_tempMan; +} +LocationManager* MainWindow::locationManager() { + return m_locMan; +} +DescriptionManager* MainWindow::descriptionManager() { + return m_descMan; +} +Show* MainWindow::eventShow() { + return m_show; +} +void MainWindow::slotAction( QAction* act ) { + +} +void MainWindow::slotConfigureLocs() { + +} +void MainWindow::slotConfigureDesc() { + +} +void MainWindow::hideShow() { + +} +void MainWindow::viewPopup(int ) { + +} +void MainWindow::viewAdd(const QDate& ) { + +} +void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) { + +} +bool MainWindow::viewAP()const{ +} +bool MainWindow::viewStartMonday()const { + +} diff --git a/core/pim/datebook2/mainwindow.h b/core/pim/datebook2/mainwindow.h index 5ea0c89..60ea4c4 100644 --- a/core/pim/datebook2/mainwindow.h +++ b/core/pim/datebook2/mainwindow.h @@ -7,6 +7,19 @@ +#include "descriptionmanager.h" +#include "locationmanager.h" +#include "view.h" + +class QAction; +class QWidgetStack; +class QPopupMenu; +class QPEToolBar; namespace Datebook { + class TemplateManager; + class BookManager; + class Show; class MainWindow : public OPimMainWindow { Q_OBJECT + friend class Show; // to avoid QObject + friend class View; // to avoid QObject public: @@ -21,2 +34,13 @@ namespace Datebook { void raiseCurrentView(); // raise the current View + void slotGoToNow(); // will switch the currentView to the curren date time + void slotFind(); // find!!! + void slotConfigure(); // configure the app + void slotClockChanged(bool); // clock changed + void slotWeekChanged( bool ); // week changed + void slotAppMessage( const QCString&, const QByteArray& ); // qApp message QPE/Application/datebook + void slotReceive( const QCString&, const QByteArray& ); // QPE/System and QPE/Datebook + void slotAction( QAction* ); // View changed + void slotConfigureLocs(); // Configure the Locations + void slotConfigureDesc(); // Configure the Desc + @@ -32,2 +56,3 @@ namespace Datebook { void edit( int uid ); + void edit(); void add( const OPimRecord& ); @@ -35,4 +60,37 @@ namespace Datebook { private: - QList<View> m_view; // the Views.. not autoDelete + QPEToolBar* toolbar(); + QPopupMenu* viewMenu(); + QPopupMenu* settingsMenu(); + QPopupMenu* templateMenu(); + View* currentView(); + BookManager* manager(); + TemplateManager* templateManager(); + LocationManager* locationManager(); + DescriptionManager* descriptionManager(); + Show* eventShow(); + + private: // friend functions for Show + void hideShow(); // to hide the view + // off friend Show + // friend of the view + private: + void viewPopup( int ); + void viewAdd( const QDate& date ); + void viewAdd( const QDateTime&, const QDateTime& ); + bool viewAP()const; + bool viewStartMonday()const; + // off view show + private: + QList<View> m_view; // the Views.. not autoDelete + QWidgetStack* m_stack; + QPEToolBar *m_toolBar; + QPopupMenu* m_popView; + QPopupMenu* m_popSetting; + QPopupMenu* m_popTemplate; + BookManager* m_manager; + TemplateManager* m_tempMan; + DescriptionManager* m_descMan; + LocationManager* m_locMan; + Show* m_show; }; diff --git a/core/pim/datebook2/managertemplate.h b/core/pim/datebook2/managertemplate.h index 668fda7..cdf121d 100644 --- a/core/pim/datebook2/managertemplate.h +++ b/core/pim/datebook2/managertemplate.h @@ -4,2 +4,3 @@ #include <qdialog.h> +#include <qmap.h> #include <qstring.h> @@ -13,5 +14,6 @@ namespace Datebook { class ManagerTemplate { + typedef typename QMap<QString, T>::Iterator Iterator; public: ManagerTemplate(); - ~ManagerTemplate(); + virtual ~ManagerTemplate(); @@ -33,2 +35,37 @@ namespace Datebook { }; + template<class T> + ManagerTemplate<T>::ManagerTemplate() { + } + template<class T> + ManagerTemplate<T>::~ManagerTemplate() { + } + template<class T> + void ManagerTemplate<T>::add( const QString& str, const T& t ) { + m_map.insert( str, t ); + } + template<class T> + void ManagerTemplate<T>::remove( const QString& str ) { + m_map.remove( str ); + } + template<class T> + bool ManagerTemplate<T>::load() { + return doLoad(); + } + template<class T> + bool ManagerTemplate<T>::save() { + return doSave(); + } + template<class T> + QStringList ManagerTemplate<T>::names() { + QStringList lst; + Iterator it; + for ( it = m_map.begin(); it != m_map.end(); ++it ) { + lst << it.key(); + } + return lst; + } + template<class T> + T ManagerTemplate<T>::value( const QString& str)const { + return m_map[str]; + } } diff --git a/core/pim/datebook2/show.cpp b/core/pim/datebook2/show.cpp new file mode 100644 index 0000000..ca06394 --- a/dev/null +++ b/core/pim/datebook2/show.cpp @@ -0,0 +1,25 @@ +#include "mainwindow.h" +#include "show.h" + +using namespace Datebook; + +Show::Show( MainWindow* win ) + : m_win(win ) { +} +Show::~Show() { +} +void Show::hideMe() { + m_win->hideShow(); +} + +TextShow::TextShow( QWidget* parent, MainWindow* ) + : QTextView( parent ){ +} +TextShow::~TextShow() { +} +QWidget* TextShow::widget() { + return this; +} +void TextShow::show(const OEvent& ev) { + setText( ev.toRichText() ); +} diff --git a/core/pim/datebook2/show.h b/core/pim/datebook2/show.h index 37d22fe..72775a9 100644 --- a/core/pim/datebook2/show.h +++ b/core/pim/datebook2/show.h @@ -4,2 +4,3 @@ #include <qstring.h> +#include <qtextview.h> @@ -27,3 +28,3 @@ namespace Datebook { */ - void show(const OEvent& str); + virtual void show(const OEvent& str) = 0; @@ -40,2 +41,14 @@ namespace Datebook { + private: + MainWindow* m_win; + }; + class TextShow : public QTextView { + Q_OBJECT + public: + TextShow( QWidget* parent, MainWindow* win ); + ~TextShow(); + + QWidget* widget(); + void show(const OEvent&); + }; diff --git a/core/pim/datebook2/stringmanager.cpp b/core/pim/datebook2/stringmanager.cpp new file mode 100644 index 0000000..77bc88a --- a/dev/null +++ b/core/pim/datebook2/stringmanager.cpp @@ -0,0 +1,42 @@ +#include <qpe/config.h> + +#include "stringmanager.h" + +using namespace Datebook; + +StringManager::StringManager( const QString& str ) + : m_base( str ) { +} +StringManager::~StringManager() { + +} +void StringManager::add( const QString& str ) { + ManagerTemplate<QString>::add(str, str); +} +bool StringManager::doLoad() { + Config qpe( "datebook-"+m_base ); + qpe.setGroup(m_base ); + QStringList list = qpe.readListEntry( "Names", 0x1f ); + for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) + add( (*it) ); + + return true; +} +bool StringManager::doSave() { + Config qpe( "datebook"+m_base ); + qpe.setGroup(m_base); + qpe.writeEntry( "Names", names(), 0x1f ); + + return false; +} + + +StringManagerDialog::StringManagerDialog(const StringManager& ) + : QDialog(0, 0, true ) { +} +StringManagerDialog::~StringManagerDialog() { + +} +StringManager StringManagerDialog::manager()const { + return StringManager(); +} diff --git a/core/pim/datebook2/stringmanager.h b/core/pim/datebook2/stringmanager.h index a11bd2a..ac0d4bd 100644 --- a/core/pim/datebook2/stringmanager.h +++ b/core/pim/datebook2/stringmanager.h @@ -19,3 +19,3 @@ namespace Datebook { */ - StringManager(const QString& baseName); + StringManager(const QString& baseName = QString::null); ~StringManager(); @@ -28,4 +28,5 @@ namespace Datebook { private: - void doLoad(); - void doSave(); + QString m_base; + bool doLoad(); + bool doSave(); }; @@ -38,4 +39,4 @@ namespace Datebook { public: - StringManagerDialog( const StringManager& ); - ~StringManager(); + StringManagerDialog( const StringManager&); + ~StringManagerDialog(); diff --git a/core/pim/datebook2/templatemanager.cpp b/core/pim/datebook2/templatemanager.cpp new file mode 100644 index 0000000..b620cf7 --- a/dev/null +++ b/core/pim/datebook2/templatemanager.cpp @@ -0,0 +1,25 @@ +#include "templatemanager.h" + +using namespace Datebook; + + +TemplateManager::TemplateManager() { + +} +TemplateManager::~TemplateManager() { +} +bool TemplateManager::doSave() { + return true; +} +bool TemplateManager::doLoad() { + return true; +} + +TemplateDialog::TemplateDialog( const TemplateManager& ) + : QDialog(0, 0, true ) { +} +TemplateDialog::~TemplateDialog() { +} +TemplateManager TemplateDialog::manager()const { + return TemplateManager(); +} diff --git a/core/pim/datebook2/view.cpp b/core/pim/datebook2/view.cpp new file mode 100644 index 0000000..b07c89a --- a/dev/null +++ b/core/pim/datebook2/view.cpp @@ -0,0 +1,62 @@ + +#include <opie/odatebookaccess.h> + +#include "bookmanager.h" +#include "mainwindow.h" +#include "view.h" + +using namespace Datebook; + +View::View( MainWindow* window, QWidget* ) { + m_win = window; +} +View::~View() { +} +QDate View::dateFromWeek( int week, int year, bool startOnMon ) { + +} +bool View::calcWeek( const QDate& d, int & week, int & year, bool ) { + +} +void View::loadConfig( Config* conf ) { + doLoadConfig( conf ); +} +void View::saveConfig( Config* conf ) { + doSaveConfig( conf ); +} +void View::popup( int uid ) { + m_win->viewPopup( uid ); +} +void View::add( const QDate& start ) { + m_win->viewAdd( start ); +} +void View::add( const QDateTime& start, const QDateTime& end ) { + m_win->viewAdd( start, end ); +} +void View::edit( int uid ) { + m_win->edit( uid ); +} +void View::remove( int uid ) { + m_win->remove( uid ); +} +ODateBookAccess::List View::allEvents() const{ + return m_win->manager()->allRecords(); +} +OEffectiveEvent::ValueList View::events( const QDate& from, const QDate& to ) { + return m_win->manager()->list( from, to ); +} +OEvent View::event( int uid ) const{ + return m_win->manager()->event( uid ); +} +bool View::isAP()const { + return m_win->viewAP(); +} +bool View::weekStartOnMonday()const { + return m_win->viewStartMonday(); +} +QList<OPimRecord> View::records( const QDate& on ) { + return m_win->manager()->records( on, on ); +} +QList<OPimRecord> View::records( const QDate& on, const QDate& to ) { + return m_win->manager()->records( on, to ); +} diff --git a/core/pim/datebook2/view.h b/core/pim/datebook2/view.h index a7bc1d8..e2312a3 100644 --- a/core/pim/datebook2/view.h +++ b/core/pim/datebook2/view.h @@ -15,3 +15,3 @@ namespace Datebook { View( MainWindow* window, QWidget* parent ); - virtual ~View() = 0; + virtual ~View(); @@ -24,2 +24,7 @@ namespace Datebook { /** + * return the uid of the current item or 0 + */ + virtual int currentItem()const = 0; + + /** * loadConfig @@ -32,4 +37,6 @@ namespace Datebook { * the current range + * @param src Where to write the start datetime + * @param dest Where to write the end datetime */ - void currentRange( const QDateTime& src, const QDateTime& from); + virtual void currentRange( const QDateTime& src, const QDateTime& from) = 0; @@ -48,2 +55,3 @@ namespace Datebook { * show date in your view!! + * make the date visible in the current view */ @@ -54,3 +62,3 @@ namespace Datebook { */ - virtual QWidget* widget(); + virtual QWidget* widget() = 0; @@ -59,5 +67,5 @@ namespace Datebook { */ - virtual void reschedule() = 0 + virtual void reschedule() = 0; protected: - void popup( int ); + void popup( int uid); QString toShortText(const OEffectiveEvent& eff)const; @@ -116,4 +124,7 @@ namespace Datebook { */ - QPtrList<OPimRecord> records( const QDate& on ); - QPtrList<OPimRecord> records( const QDate& start, const QDate& to ); + QList<OPimRecord> records( const QDate& on ); + QList<OPimRecord> records( const QDate& start, const QDate& to ); + + private: + MainWindow* m_win; }; |