summaryrefslogtreecommitdiff
authorzecke <zecke>2003-02-23 21:27:08 (UTC)
committer zecke <zecke>2003-02-23 21:27:08 (UTC)
commit041eda0d7482d60cd67731b81fd36104fcd3120f (patch) (side-by-side diff)
treec7bc7730b9e76e22f828291d404821f7bd922d6f
parenta195865dfdb03b4c7c972acfc8cfd87743ab3e6f (diff)
downloadopie-041eda0d7482d60cd67731b81fd36104fcd3120f.zip
opie-041eda0d7482d60cd67731b81fd36104fcd3120f.tar.gz
opie-041eda0d7482d60cd67731b81fd36104fcd3120f.tar.bz2
Implement some of the new framework
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook2/bookmanager.cpp67
-rw-r--r--core/pim/datebook2/bookmanager.h7
-rw-r--r--core/pim/datebook2/datebook2.pro19
-rw-r--r--core/pim/datebook2/mainwindow.cpp178
-rw-r--r--core/pim/datebook2/mainwindow.h60
-rw-r--r--core/pim/datebook2/managertemplate.h39
-rw-r--r--core/pim/datebook2/show.cpp25
-rw-r--r--core/pim/datebook2/show.h15
-rw-r--r--core/pim/datebook2/stringmanager.cpp42
-rw-r--r--core/pim/datebook2/stringmanager.h9
-rw-r--r--core/pim/datebook2/templatemanager.cpp25
-rw-r--r--core/pim/datebook2/view.cpp62
-rw-r--r--core/pim/datebook2/view.h25
13 files changed, 545 insertions, 28 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
@@ -1,40 +1,45 @@
#ifndef OPIE_DATE_BOOK_MANAGER_H
#define OPIE_DATE_BOOK_MANAGER_H
#include <qlist.h>
#include <opie/opimrecord.h>
#include <opie/odatebookaccess.h>
namespace Datebook {
/**
* book manager is responsible for managing the
* access
* All access to the underlying API will be done
* through this class
*/
class BookManager {
public:
BookManager();
~BookManager();
bool isLoaded()const;
bool load();
+ void reload();
bool save();
OEvent event( int uid );
OEffectiveEvent::ValueList list( const QDate& from,
const QDate& to );
ODateBookAccess::List allRecords()const;
void add( const OEvent& );
+ void add( const OPimRecord& );
void update( const OEvent& );
void remove( int uid );
void remove( const QArray<int>& );
- QPtrList<OPimRecord> records( const QDate& from,
+ QList<OPimRecord> records( const QDate& from,
const QDate& to );
+
+ private:
+ ODateBookAccess* m_db;
};
}
#endif
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
@@ -1,13 +1,28 @@
TEMPLATE = app
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
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie
TARGET = datebook2
include ( $(OPIEDIR)/include.pro )
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,70 +1,226 @@
+
+#include <qcopchannel_qws.h>
#include <qwidgetstack.h>
#include <qlabel.h>
#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>
#include <qpe/resource.h>
-
+#include "show.h"
+#include "templatemanager.h"
+#include "bookmanager.h"
#include "mainwindow.h"
using namespace Datebook;
MainWindow::MainWindow()
: OPimMainWindow( "Datebook", 0, 0 ) {
+ setIcon( Resource::loadPixmap( "datebook_icon" ) );
initUI();
- initConfig();
- initView();
initManagers();
+ initView();
+ initConfig();
raiseCurrentView();
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() {
-
}
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;
}
void MainWindow::beam( int uid ) {
}
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() );
}
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& ) ) );
}
void MainWindow::initConfig() {
}
void MainWindow::initView() {
}
void MainWindow::initManagers() {
-
+ m_manager = new BookManager;
+ m_locMan = new LocationManager( tr("Locations") );
+ m_descMan = new DescriptionManager( tr("Descriptions") );
}
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
@@ -1,41 +1,99 @@
#ifndef DATE_BOOK_MAIN_WINDOW_H
#define DATE_BOOK_MAIN_WINDOW_H
#include <qlist.h>
#include <opie/opimmainwindow.h>
+#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:
MainWindow();
~MainWindow();
private slots:
void initUI(); // init the UI
void initConfig(); // apply the config
void initView(); // init the Views..
void initManagers(); // init the Managers including templates, location and description
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
+
protected slots:
void populate();
void doSetDocument( const QString& str );
void flush();
void reload();
int create();
bool remove( int uid );
void beam( int uid );
void show( int uid );
void edit( int uid );
+ void edit();
void add( const OPimRecord& );
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;
};
}
#endif
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
@@ -1,36 +1,73 @@
#ifndef OPIE_DATE_BOOK_MANAGER_TEMPLATE_H
#define OPIE_DATE_BOOK_MANAGER_TEMPLATE_H
#include <qdialog.h>
+#include <qmap.h>
#include <qstring.h>
namespace Datebook {
/**
* ManagerTemplate is a template which manages
* all kind of managers :)
*/
template<class T>
class ManagerTemplate {
+ typedef typename QMap<QString, T>::Iterator Iterator;
public:
ManagerTemplate();
- ~ManagerTemplate();
+ virtual ~ManagerTemplate();
virtual void add( const QString&, const T& t );
void remove( const QString& );
bool load();
bool save();
QStringList names();
T value(const QString&)const;
protected:
QMap<QString, T> m_map;
private:
virtual bool doSave() = 0;
virtual bool doLoad() = 0;
};
+ 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];
+ }
}
#endif
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
@@ -1,44 +1,57 @@
#ifndef OPIE_DATEBOOK_SHOW_H
#define OPIE_DATEBOOK_SHOW_H
#include <qstring.h>
+#include <qtextview.h>
#include <opie/oevent.h>
namespace Datebook {
class MainWindow;
/**
* here is the show
* The show interface will
* show the richtext information
* of the OEvent
*/
class Show {
public:
/**
* mainwindow as parent
*/
Show(MainWindow* );
virtual ~Show();
/**
* show the OEvent
*/
- void show(const OEvent& str);
+ virtual void show(const OEvent& str) = 0;
/**
* the Widget
*/
virtual QWidget* widget() = 0;
protected:
/**
* the show is over
* ask the mainwindow to hide
*/
void hideMe();
+ private:
+ MainWindow* m_win;
+ };
+ class TextShow : public QTextView {
+ Q_OBJECT
+ public:
+ TextShow( QWidget* parent, MainWindow* win );
+ ~TextShow();
+
+ QWidget* widget();
+ void show(const OEvent&);
+
};
}
#endif
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
@@ -1,46 +1,47 @@
#ifndef OPIE_STRING_DATEBOOK_MANAGER_H
#define OPIE_STRING_DATEBOOK_MANAGER_H
#include <qstring.h>
#include "managertemplate.h"
namespace Datebook {
/**
* StringManager is a generic manager
* whick keeps track of strings
* It'll be used with the Location
* and the Description Manager
*/
class StringManager : public ManagerTemplate<QString> {
public:
/**
* baseName is used for storing
*/
- StringManager(const QString& baseName);
+ StringManager(const QString& baseName = QString::null);
~StringManager();
/**
* override the add implementation
* cause we do not have a value :)
*/
void add( const QString& );
private:
- void doLoad();
- void doSave();
+ QString m_base;
+ bool doLoad();
+ bool doSave();
};
/**
* A Generic Editor for StringManager
*/
class StringManagerDialog : public QDialog {
Q_OBJECT
public:
StringManagerDialog( const StringManager& );
- ~StringManager();
+ ~StringManagerDialog();
StringManager manager()const;
};
}
#endif
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
@@ -1,122 +1,133 @@
#ifndef OPIE_DATE_BOOK_VIEW_H
#define OPIE_DATE_BOOK_VIEW_H
#include <qpixmap.h>
#include <qwidget.h>
#include <opie/oevent.h>
#include <opie/odatebookaccess.h>
class Config;
namespace Datebook {
class MainWindow;
class View {
public:
View( MainWindow* window, QWidget* parent );
- virtual ~View() = 0;
+ virtual ~View();
static QDate dateFromWeek( int week, int year, bool startOnMonda );
static bool calcWeek( const QDate& d, int &week, int &year, bool startOnMonday = false );
virtual QPixmap pixmap()const = 0;
virtual QString description()const = 0;
/**
+ * return the uid of the current item or 0
+ */
+ virtual int currentItem()const = 0;
+
+ /**
* loadConfig
* saveConfig
*/
void loadConfig( Config* );
void saveConfig( Config* );
/**
* 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;
/**
* the clock format changed
*/
virtual void clockChanged() = 0;
/**
* the day change means that either
* monday or sunday is the week start
*/
virtual void dayChanged() = 0;
/**
* show date in your view!!
+ * make the date visible in the current view
*/
virtual void showDay( const QDate& date ) = 0;
/**
* return the widget
*/
- virtual QWidget* widget();
+ virtual QWidget* widget() = 0;
/**
* the view needs an update!
*/
- virtual void reschedule() = 0
+ virtual void reschedule() = 0;
protected:
- void popup( int );
+ void popup( int uid);
QString toShortText(const OEffectiveEvent& eff)const;
QString toText(const OEffectiveEvent& eff)const;
virtual void doLoadConfig( Config* ) = 0;
virtual void doSaveConfig( Config* ) = 0;
/**
* create a new event starting
* on start
*/
void add( const QDate& start );
/**
* create a new event in a given range
*/
void add( const QDateTime& start, const QDateTime& end );
/**
* will make the MainWindow to open the editor
*/
void edit( int uid );
/**
* remove item with uid
*/
void remove( int uid );
/**
* give access to all events
*/
ODateBookAccess::List allEvents()const;
/**
* return events
*/
OEffectiveEvent::ValueList events( const QDate& start, const QDate& end );
/**
* return an Event
*/
OEvent event( int uid )const;
/**
* Is the clock AP/PM or 24h?
*/
bool isAP()const;
/**
* if the week starts on monday?
*/
bool weekStartOnMonday()const;
/**
* return related records for days
*/
- 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;
};
}
#endif