summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook2/.cvsignore18
-rw-r--r--core/pim/datebook2/DESIGN29
-rw-r--r--core/pim/datebook2/bookmanager.h40
-rw-r--r--core/pim/datebook2/datebook2.pro13
-rw-r--r--core/pim/datebook2/descriptionmanager.h11
-rw-r--r--core/pim/datebook2/editor.h36
-rw-r--r--core/pim/datebook2/locationmanager.h14
-rw-r--r--core/pim/datebook2/main.cpp15
-rw-r--r--core/pim/datebook2/mainwindow.cpp70
-rw-r--r--core/pim/datebook2/mainwindow.h41
-rw-r--r--core/pim/datebook2/managertemplate.h36
-rw-r--r--core/pim/datebook2/show.h44
-rw-r--r--core/pim/datebook2/stringmanager.h46
-rw-r--r--core/pim/datebook2/templatemanager.h36
-rw-r--r--core/pim/datebook2/view.h122
15 files changed, 571 insertions, 0 deletions
diff --git a/core/pim/datebook2/.cvsignore b/core/pim/datebook2/.cvsignore
new file mode 100644
index 0000000..fdde933
--- a/dev/null
+++ b/core/pim/datebook2/.cvsignore
@@ -0,0 +1,18 @@
+Makefile*
+datebookdayheader.cpp
+datebookdayheader.h
+datebooksettingsbase.cpp
+datebooksettingsbase.h
+datebookweekheader.cpp
+datebookweekheader.h
+datebookweeklstdayhdr.cpp
+datebookweeklstdayhdr.h
+datebookweeklstheader.cpp
+datebookweeklstheader.h
+dateentry.cpp
+dateentry.h
+moc_*
+noteentry.cpp
+noteentry.h
+repeatentrybase.cpp
+repeatentrybase.h
diff --git a/core/pim/datebook2/DESIGN b/core/pim/datebook2/DESIGN
new file mode 100644
index 0000000..7442e81
--- a/dev/null
+++ b/core/pim/datebook2/DESIGN
@@ -0,0 +1,29 @@
+A small abstract about the design
+
+First of all we've a namespace called Datebook
+
+class MainWindow is our QMainWindow and PimMainWindow
+ it's the center of all datebook operations.
+ It loads all Views, Configs, Shows, Manager
+ and dispatches between them
+
+the Interface declarations use protected methods instead
+of signals because templates and signals does not match
+that nicely.
+I add friend declarations to the mainwindow so that we've a
+tight interface of interactions and know that it works.
+friend can not be inherited so all got enough abstraction. The
+dependency on the MainWindow is acceptable.
+
+Then we've a small DB Manager class which is responsible
+for controlling the ODateBookAccess class and to resolve
+other records ( due todo items, Birthdays.. )
+
+Show - Show can show richtext of OEvent
+View - The basic view
+MainWindow - The mainwindow with all the actions
+Editor - The editor interface to edit and create OEvents
+AlarmManager - A widget to take care of alarm activation
+ManagerTemplate,StringManager - Responsible for managing strings
+ for the Location and Description ComboBox
+TemplateManager - the OEvent TemplateManager \ No newline at end of file
diff --git a/core/pim/datebook2/bookmanager.h b/core/pim/datebook2/bookmanager.h
new file mode 100644
index 0000000..44ad8ed
--- a/dev/null
+++ b/core/pim/datebook2/bookmanager.h
@@ -0,0 +1,40 @@
+#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();
+ bool save();
+
+ OEvent event( int uid );
+ OEffectiveEvent::ValueList list( const QDate& from,
+ const QDate& to );
+ ODateBookAccess::List allRecords()const;
+
+ void add( const OEvent& );
+ void update( const OEvent& );
+ void remove( int uid );
+ void remove( const QArray<int>& );
+
+ QPtrList<OPimRecord> records( const QDate& from,
+ const QDate& to );
+ };
+}
+
+#endif
diff --git a/core/pim/datebook2/datebook2.pro b/core/pim/datebook2/datebook2.pro
new file mode 100644
index 0000000..9d6ef4c
--- a/dev/null
+++ b/core/pim/datebook2/datebook2.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+CONFIG += qt warn_on release
+DESTDIR = $(OPIEDIR)/bin
+HEADERS = mainwindow.h
+SOURCES = main.cpp \
+ mainwindow.cpp
+
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -lopie
+TARGET = datebook2
+
+include ( $(OPIEDIR)/include.pro )
diff --git a/core/pim/datebook2/descriptionmanager.h b/core/pim/datebook2/descriptionmanager.h
new file mode 100644
index 0000000..5ab5769
--- a/dev/null
+++ b/core/pim/datebook2/descriptionmanager.h
@@ -0,0 +1,11 @@
+#ifndef OPIE_DATEBOOK_DESCRIPTION_MANAGER_H
+#define OPIE_DATEBOOK_DESCRIPTION_MANAGER_H
+
+#include "stringmanager.h"
+
+namespace Datebook {
+ typedef StringManager DescriptionManager;
+ typedef StringManagerDialog DescriptionManagerDialog;
+}
+
+#endif
diff --git a/core/pim/datebook2/editor.h b/core/pim/datebook2/editor.h
new file mode 100644
index 0000000..53e8718
--- a/dev/null
+++ b/core/pim/datebook2/editor.h
@@ -0,0 +1,36 @@
+#ifndef OPIE_DATEBOOK_EDITOR_H
+#define OPIE_DATEBOOK_EDITOR_H
+
+#include <qdialog.h>
+
+#include <opie/oevent.h>
+
+#include "descriptionmanager.h"
+#include "locationmanager.h"
+
+namespace Datebook {
+ class MainWindow;
+ /**
+ * This is the editor interface
+ */
+ class Editor {
+ public:
+ Editor( MainWindow*, QWidget* parent );
+ virtual Editor();
+
+ bool newEvent( const QDate& );
+ bool newEvent( const QDateTime& start, const QDateTime& end );
+ bool edit( const OEvent& );
+
+ OEvent event()const;
+
+ protected:
+ DescriptionManager descriptions()const;
+ LocationManager locations()const;
+ void setDescriptions( const DescriptionManager& );
+ void setLocations( const LocationManager& );
+
+ };
+}
+
+#endif
diff --git a/core/pim/datebook2/locationmanager.h b/core/pim/datebook2/locationmanager.h
new file mode 100644
index 0000000..102480f
--- a/dev/null
+++ b/core/pim/datebook2/locationmanager.h
@@ -0,0 +1,14 @@
+#ifndef OPIE_LOCATION_MANAGER_H
+#define OPIE_LOCATION_MANAGER_H
+
+#include "stringmanager.h"
+
+namespace Datebook {
+ /**
+ * life can be so simple
+ */
+ typedef StringManager LocationManager;
+ typedef StringManagerDialog LocationManagerDialog;
+}
+
+#endif
diff --git a/core/pim/datebook2/main.cpp b/core/pim/datebook2/main.cpp
new file mode 100644
index 0000000..14bdc60
--- a/dev/null
+++ b/core/pim/datebook2/main.cpp
@@ -0,0 +1,15 @@
+#include "mainwindow.h"
+
+#include <qpe/qpeapplication.h>
+
+
+int main( int argc, char* argv[] ) {
+ QPEApplication app( argc, argv );
+
+ Datebook::MainWindow mw;
+ mw.setCaption( QObject::tr("Opie Datebook") );
+
+ app.showMainWidget( &mw );
+
+ return app.exec();
+}
diff --git a/core/pim/datebook2/mainwindow.cpp b/core/pim/datebook2/mainwindow.cpp
new file mode 100644
index 0000000..2f214b8
--- a/dev/null
+++ b/core/pim/datebook2/mainwindow.cpp
@@ -0,0 +1,70 @@
+#include <qwidgetstack.h>
+#include <qlabel.h>
+#include <qaction.h>
+
+#include <qpe/ir.h>
+#include <qpe/qpemenubar.h>
+#include <qpe/qpemessagebox.h>
+#include <qpe/resource.h>
+
+
+#include "mainwindow.h"
+
+
+using namespace Datebook;
+
+MainWindow::MainWindow()
+ : OPimMainWindow( "Datebook", 0, 0 ) {
+ initUI();
+ initConfig();
+ initView();
+ initManagers();
+
+ raiseCurrentView();
+ QTimer::singleShot(0, this, SLOT(populate() ) );
+}
+MainWindow::~MainWindow() {
+
+}
+void MainWindow::doSetDocument( const QString& str ) {
+
+}
+void MainWindow::flush() {
+
+}
+void MainWindow::reload() {
+
+}
+int MainWindow::create() {
+
+}
+bool MainWindow::remove( int uid ) {
+
+}
+void MainWindow::beam( int uid ) {
+
+}
+void MainWindow::show( int uid ) {
+
+}
+void MainWindow::add( const OPimRecord& ) {
+
+}
+void MainWindow::edit( int uid ) {
+
+}
+void MainWindow::initUI() {
+
+}
+void MainWindow::initConfig() {
+
+}
+void MainWindow::initView() {
+
+}
+void MainWindow::initManagers() {
+
+}
+void MainWindow::raiseCurrentView() {
+
+}
diff --git a/core/pim/datebook2/mainwindow.h b/core/pim/datebook2/mainwindow.h
new file mode 100644
index 0000000..5ea0c89
--- a/dev/null
+++ b/core/pim/datebook2/mainwindow.h
@@ -0,0 +1,41 @@
+#ifndef DATE_BOOK_MAIN_WINDOW_H
+#define DATE_BOOK_MAIN_WINDOW_H
+
+#include <qlist.h>
+
+#include <opie/opimmainwindow.h>
+
+namespace Datebook {
+
+ class MainWindow : public OPimMainWindow {
+ Q_OBJECT
+ 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
+
+ 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 add( const OPimRecord& );
+
+ private:
+ QList<View> m_view; // the Views.. not autoDelete
+
+ };
+}
+
+#endif
diff --git a/core/pim/datebook2/managertemplate.h b/core/pim/datebook2/managertemplate.h
new file mode 100644
index 0000000..668fda7
--- a/dev/null
+++ b/core/pim/datebook2/managertemplate.h
@@ -0,0 +1,36 @@
+#ifndef OPIE_DATE_BOOK_MANAGER_TEMPLATE_H
+#define OPIE_DATE_BOOK_MANAGER_TEMPLATE_H
+
+#include <qdialog.h>
+#include <qstring.h>
+
+namespace Datebook {
+ /**
+ * ManagerTemplate is a template which manages
+ * all kind of managers :)
+ */
+ template<class T>
+ class ManagerTemplate {
+ public:
+ ManagerTemplate();
+ ~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;
+
+ };
+}
+
+#endif
diff --git a/core/pim/datebook2/show.h b/core/pim/datebook2/show.h
new file mode 100644
index 0000000..37d22fe
--- a/dev/null
+++ b/core/pim/datebook2/show.h
@@ -0,0 +1,44 @@
+#ifndef OPIE_DATEBOOK_SHOW_H
+#define OPIE_DATEBOOK_SHOW_H
+
+#include <qstring.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);
+
+ /**
+ * the Widget
+ */
+ virtual QWidget* widget() = 0;
+ protected:
+ /**
+ * the show is over
+ * ask the mainwindow to hide
+ */
+ void hideMe();
+
+ };
+}
+
+#endif
diff --git a/core/pim/datebook2/stringmanager.h b/core/pim/datebook2/stringmanager.h
new file mode 100644
index 0000000..a11bd2a
--- a/dev/null
+++ b/core/pim/datebook2/stringmanager.h
@@ -0,0 +1,46 @@
+#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();
+
+ /**
+ * override the add implementation
+ * cause we do not have a value :)
+ */
+ void add( const QString& );
+ private:
+ void doLoad();
+ void doSave();
+ };
+
+ /**
+ * A Generic Editor for StringManager
+ */
+ class StringManagerDialog : public QDialog {
+ Q_OBJECT
+ public:
+ StringManagerDialog( const StringManager& );
+ ~StringManager();
+
+ StringManager manager()const;
+ };
+}
+
+#endif
diff --git a/core/pim/datebook2/templatemanager.h b/core/pim/datebook2/templatemanager.h
new file mode 100644
index 0000000..f885677
--- a/dev/null
+++ b/core/pim/datebook2/templatemanager.h
@@ -0,0 +1,36 @@
+#ifndef OPIE_DATEBOOK_TEMPLATE_MANAGER_ZECKE_H_RANDOM_CAUSE_BJARNE
+#define OPIE_DATEBOOK_TEMPLATE_MANAGER_ZECKE_H_RANDOM_CAUSE_BJARNE
+
+#include <qobject.h>
+
+#include <opie/oevent.h>
+
+#include "managertemplate.h"
+
+namespace Datebook {
+ /**
+ * The OEvent Template Manager
+ */
+ class TemplateManager : public ManagerTemplate<OEvent> {
+ public:
+ TemplateManager();
+ ~TemplateManager();
+
+ private:
+ virtual bool doSave();
+ virtual bool doLoad();
+ };
+ /**
+ * a QDialog for editing it
+ */
+ class TemplateDialog : public QDialog {
+ Q_OBJECT
+ public:
+ TemplateDialog(const TemplateManager& man);
+ ~TemplateDialog();
+
+ virtual TemplateManager manager()const;
+ };
+}
+
+#endif
diff --git a/core/pim/datebook2/view.h b/core/pim/datebook2/view.h
new file mode 100644
index 0000000..a7bc1d8
--- a/dev/null
+++ b/core/pim/datebook2/view.h
@@ -0,0 +1,122 @@
+#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;
+
+ 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;
+
+ /**
+ * loadConfig
+ * saveConfig
+ */
+ void loadConfig( Config* );
+ void saveConfig( Config* );
+
+ /**
+ * the current range
+ */
+ void currentRange( const QDateTime& src, const QDateTime& from);
+
+ /**
+ * 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!!
+ */
+ virtual void showDay( const QDate& date ) = 0;
+
+ /**
+ * return the widget
+ */
+ virtual QWidget* widget();
+
+ /**
+ * the view needs an update!
+ */
+ virtual void reschedule() = 0
+ protected:
+ void popup( int );
+ 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 );
+ };
+}
+
+#endif