summaryrefslogtreecommitdiff
path: root/core
authorzecke <zecke>2003-02-24 13:34:03 (UTC)
committer zecke <zecke>2003-02-24 13:34:03 (UTC)
commitb04ced09167d910e5cab1981bde295e2e8185fee (patch) (side-by-side diff)
tree2623e1553968654b133343ce7333995243216201 /core
parentcfecfd53c433a3b530e4abcef51e81feae3c8641 (diff)
downloadopie-b04ced09167d910e5cab1981bde295e2e8185fee.zip
opie-b04ced09167d910e5cab1981bde295e2e8185fee.tar.gz
opie-b04ced09167d910e5cab1981bde295e2e8185fee.tar.bz2
Add Implementation for Templates, Locations, Descriptions
add some more stuff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook2/datebook2.pro3
-rw-r--r--core/pim/datebook2/editor.cpp24
-rw-r--r--core/pim/datebook2/editor.h13
-rw-r--r--core/pim/datebook2/mainwindow.cpp97
-rw-r--r--core/pim/datebook2/mainwindow.h24
-rw-r--r--core/pim/datebook2/managertemplate.h23
-rw-r--r--core/pim/datebook2/stringmanager.cpp108
-rw-r--r--core/pim/datebook2/stringmanager.h14
-rw-r--r--core/pim/datebook2/templatemanager.cpp167
-rw-r--r--core/pim/datebook2/templatemanager.h22
-rw-r--r--core/pim/datebook2/view.h10
11 files changed, 447 insertions, 58 deletions
diff --git a/core/pim/datebook2/datebook2.pro b/core/pim/datebook2/datebook2.pro
index 2ad906e..0b59309 100644
--- a/core/pim/datebook2/datebook2.pro
+++ b/core/pim/datebook2/datebook2.pro
@@ -18,7 +18,8 @@ SOURCES = main.cpp \
stringmanager.cpp \
templatemanager.cpp \
show.cpp \
- view.cpp
+ view.cpp \
+ editor.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
diff --git a/core/pim/datebook2/editor.cpp b/core/pim/datebook2/editor.cpp
new file mode 100644
index 0000000..a51aab6
--- a/dev/null
+++ b/core/pim/datebook2/editor.cpp
@@ -0,0 +1,24 @@
+#include "mainwindow.h"
+
+#include "editor.h"
+
+using namespace Datebook;
+
+Editor::Editor( MainWindow* win, QWidget*)
+ : m_win( win )
+{}
+Editor::~Editor() {
+
+}
+DescriptionManager Editor::descriptions()const {
+ return m_win->descriptionManager();
+}
+LocationManager Editor::locations()const {
+ return m_win->locationManager();
+}
+void Editor::setDescriptions( const DescriptionManager& dsc) {
+ m_win->setDescriptionManager( dsc );
+}
+void Editor::setLocations( const LocationManager& loc) {
+ m_win->setLocationManager( loc );
+}
diff --git a/core/pim/datebook2/editor.h b/core/pim/datebook2/editor.h
index 53e8718..3fcfaa4 100644
--- a/core/pim/datebook2/editor.h
+++ b/core/pim/datebook2/editor.h
@@ -16,13 +16,13 @@ namespace Datebook {
class Editor {
public:
Editor( MainWindow*, QWidget* parent );
- virtual Editor();
+ virtual ~Editor();
- bool newEvent( const QDate& );
- bool newEvent( const QDateTime& start, const QDateTime& end );
- bool edit( const OEvent& );
+ virtual bool newEvent( const QDate& ) = 0;
+ virtual bool newEvent( const QDateTime& start, const QDateTime& end ) = 0;
+ virtual bool edit( const OEvent&, bool showRec = TRUE ) = 0;
- OEvent event()const;
+ virtual OEvent event()const = 0;
protected:
DescriptionManager descriptions()const;
@@ -30,6 +30,9 @@ namespace Datebook {
void setDescriptions( const DescriptionManager& );
void setLocations( const LocationManager& );
+ private:
+ MainWindow* m_win;
+
};
}
diff --git a/core/pim/datebook2/mainwindow.cpp b/core/pim/datebook2/mainwindow.cpp
index 44de6b0..68525b3 100644
--- a/core/pim/datebook2/mainwindow.cpp
+++ b/core/pim/datebook2/mainwindow.cpp
@@ -13,6 +13,7 @@
#include <qpe/qpemessagebox.h>
#include <qpe/resource.h>
+#include "editor.h"
#include "show.h"
#include "templatemanager.h"
#include "bookmanager.h"
@@ -22,14 +23,14 @@
using namespace Datebook;
MainWindow::MainWindow()
- : OPimMainWindow( "Datebook", 0, 0 ) {
+ : OPimMainWindow( "Datebook", 0, 0 ), m_descMan( "Descriptions" ), m_locMan( "Locations" )
+{
setIcon( Resource::loadPixmap( "datebook_icon" ) );
initUI();
initManagers();
initView();
initConfig();
- raiseCurrentView();
QTimer::singleShot(0, this, SLOT(populate() ) );
QCopChannel* chan = new QCopChannel( "QPE/System", this );
@@ -41,6 +42,12 @@ MainWindow::MainWindow()
this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) );
}
MainWindow::~MainWindow() {
+ m_tempMan.save();
+ m_locMan.save();
+ m_descMan.save();
+
+ manager()->save();
+ delete m_manager;
}
void MainWindow::doSetDocument( const QString& str ) {
@@ -95,8 +102,12 @@ void MainWindow::initUI() {
mb->insertItem( tr("Settings" ), m_popSetting );
m_popTemplate = new QPopupMenu( this );
+ m_popTemplate->setCheckable( TRUE );
+ connect( m_popTemplate, SIGNAL(activated(int) ),
+ this, SLOT(slotNewFromTemplate(int) ) );
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 );
@@ -130,6 +141,10 @@ void MainWindow::initUI() {
a->addTo( m_popSetting );
connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) );
+ a = new QAction( tr("Configure Templates"), QString::null, 0, 0 );
+ a->addTo( m_popSetting );
+ connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureTemp() ) );
+
connect( qApp, SIGNAL(clockChanged(bool) ),
this, SLOT(slotClockChanged(bool) ) );
connect( qApp, SIGNAL(weekChanged(bool) ),
@@ -146,8 +161,12 @@ void MainWindow::initView() {
}
void MainWindow::initManagers() {
m_manager = new BookManager;
- m_locMan = new LocationManager( tr("Locations") );
- m_descMan = new DescriptionManager( tr("Descriptions") );
+
+ m_tempMan.load();
+ m_locMan.load();
+ m_descMan.load();
+
+ setTemplateMenu();
}
void MainWindow::raiseCurrentView() {
@@ -186,15 +205,21 @@ void MainWindow::slotReceive( const QCString&, const QByteArray& ) {
BookManager* MainWindow::manager() {
return m_manager;
}
-TemplateManager* MainWindow::templateManager() {
+TemplateManager MainWindow::templateManager() {
return m_tempMan;
}
-LocationManager* MainWindow::locationManager() {
+LocationManager MainWindow::locationManager() {
return m_locMan;
}
-DescriptionManager* MainWindow::descriptionManager() {
+DescriptionManager MainWindow::descriptionManager() {
return m_descMan;
}
+void MainWindow::setLocationManager( const LocationManager& loc) {
+ m_locMan = loc;
+}
+void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) {
+ m_descMan = dsc;
+}
Show* MainWindow::eventShow() {
return m_show;
}
@@ -202,10 +227,29 @@ void MainWindow::slotAction( QAction* act ) {
}
void MainWindow::slotConfigureLocs() {
-
+ LocationManagerDialog dlg( locationManager() );
+ dlg.setCaption( tr("Configure Locations") );
+ dlg.showMaximized();
+ if (dlg.exec() == QDialog::Accepted ) {
+ setLocationManager( dlg.manager() );
+ }
}
void MainWindow::slotConfigureDesc() {
-
+ DescriptionManagerDialog dlg( descriptionManager() );
+ dlg.setCaption( tr("Configure Descriptions") );
+ dlg.showMaximized();
+ if (dlg.exec() == QDialog::Accepted ) {
+ setDescriptionManager( dlg.manager() );
+ }
+}
+void MainWindow::slotConfigureTemp() {
+ TemplateDialog dlg( templateManager(), editor() );
+ dlg.setCaption( tr("Configure Templates") );
+ dlg.showMaximized();
+ if ( dlg.exec() == QDialog::Accepted ) {
+ m_tempMan = dlg.manager();
+ setTemplateMenu();
+ }
}
void MainWindow::hideShow() {
@@ -224,3 +268,38 @@ bool MainWindow::viewAP()const{
bool MainWindow::viewStartMonday()const {
}
+void MainWindow::setTemplateMenu() {
+ m_popTemplate->clear();
+
+ QStringList list = templateManager().names();
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
+ m_popTemplate->insertItem( (*it) );
+ }
+}
+/*
+ * get the name of the item with the id id
+ * then ask for an OEvent from the manager
+ */
+void MainWindow::slotNewFromTemplate(int id ) {
+ QString name = m_popTemplate->text( id );
+
+ OEvent ev = templateManager().value( name );
+
+ if ( editor()->edit( ev ) ) {
+ ev = editor()->event();
+ ev.setUid( -1 );
+ manager()->add( ev );
+
+ /*
+ * no we'll find out if the current view
+ * should show the new event
+ * and then we will ask it to refresh
+ * FIXME for now we'll call a refresh
+ */
+ currentView()->reschedule();
+ raiseCurrentView();
+ }
+}
+Editor* MainWindow::editor() {
+ return m_edit;
+}
diff --git a/core/pim/datebook2/mainwindow.h b/core/pim/datebook2/mainwindow.h
index 60ea4c4..3c22637 100644
--- a/core/pim/datebook2/mainwindow.h
+++ b/core/pim/datebook2/mainwindow.h
@@ -7,6 +7,7 @@
#include "descriptionmanager.h"
#include "locationmanager.h"
+#include "templatemanager.h"
#include "view.h"
class QAction;
@@ -14,14 +15,14 @@ class QWidgetStack;
class QPopupMenu;
class QPEToolBar;
namespace Datebook {
-
- class TemplateManager;
class BookManager;
class Show;
+ class Editor;
class MainWindow : public OPimMainWindow {
Q_OBJECT
friend class Show; // to avoid QObject
friend class View; // to avoid QObject
+ friend class Editor;
public:
MainWindow();
~MainWindow();
@@ -42,7 +43,10 @@ namespace Datebook {
void slotAction( QAction* ); // View changed
void slotConfigureLocs(); // Configure the Locations
void slotConfigureDesc(); // Configure the Desc
+ void slotConfigureTemp();
+ void slotNewFromTemplate(int ); // called when someone chooses the template menu
+ void setTemplateMenu(); // updates the templateMenu
protected slots:
void populate();
@@ -64,10 +68,13 @@ namespace Datebook {
QPopupMenu* templateMenu();
View* currentView();
BookManager* manager();
- TemplateManager* templateManager();
- LocationManager* locationManager();
- DescriptionManager* descriptionManager();
+ TemplateManager templateManager();
+ LocationManager locationManager();
+ DescriptionManager descriptionManager();
+ void setLocationManager( const LocationManager& );
+ void setDescriptionManager( const DescriptionManager& );
Show* eventShow();
+ Editor* editor();
private: // friend functions for Show
void hideShow(); // to hide the view
@@ -89,10 +96,11 @@ namespace Datebook {
QPopupMenu* m_popSetting;
QPopupMenu* m_popTemplate;
BookManager* m_manager;
- TemplateManager* m_tempMan;
- DescriptionManager* m_descMan;
- LocationManager* m_locMan;
+ TemplateManager m_tempMan;
+ DescriptionManager m_descMan;
+ LocationManager m_locMan;
Show* m_show;
+ Editor* m_edit;
};
}
diff --git a/core/pim/datebook2/managertemplate.h b/core/pim/datebook2/managertemplate.h
index cdf121d..72fab3a 100644
--- a/core/pim/datebook2/managertemplate.h
+++ b/core/pim/datebook2/managertemplate.h
@@ -12,26 +12,21 @@ namespace Datebook {
*/
template<class T>
class ManagerTemplate {
- typedef typename QMap<QString, T>::Iterator Iterator;
+ typedef typename QMap<QString, T>::ConstIterator Iterator;
public:
ManagerTemplate();
virtual ~ManagerTemplate();
virtual void add( const QString&, const T& t );
void remove( const QString& );
- bool load();
- bool save();
+ virtual bool load() = 0;
+ virtual bool save() = 0;
- QStringList names();
+ QStringList names()const;
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() {
@@ -48,15 +43,7 @@ namespace Datebook {
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 ManagerTemplate<T>::names()const {
QStringList lst;
Iterator it;
for ( it = m_map.begin(); it != m_map.end(); ++it ) {
diff --git a/core/pim/datebook2/stringmanager.cpp b/core/pim/datebook2/stringmanager.cpp
index 77bc88a..715a4b1 100644
--- a/core/pim/datebook2/stringmanager.cpp
+++ b/core/pim/datebook2/stringmanager.cpp
@@ -1,3 +1,9 @@
+#include <qhbox.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qlistview.h>
+#include <qlineedit.h>
+
#include <qpe/config.h>
#include "stringmanager.h"
@@ -13,7 +19,7 @@ StringManager::~StringManager() {
void StringManager::add( const QString& str ) {
ManagerTemplate<QString>::add(str, str);
}
-bool StringManager::doLoad() {
+bool StringManager::load() {
Config qpe( "datebook-"+m_base );
qpe.setGroup(m_base );
QStringList list = qpe.readListEntry( "Names", 0x1f );
@@ -22,21 +28,111 @@ bool StringManager::doLoad() {
return true;
}
-bool StringManager::doSave() {
- Config qpe( "datebook"+m_base );
+bool StringManager::save() {
+ Config qpe( "datebook-"+m_base );
qpe.setGroup(m_base);
qpe.writeEntry( "Names", names(), 0x1f );
return false;
}
+QString StringManager::baseName()const {
+ return m_base;
+}
+
-StringManagerDialog::StringManagerDialog(const StringManager& )
+StringManagerDialog::StringManagerDialog(const StringManager& man)
: QDialog(0, 0, true ) {
+ m_base = man.baseName();
+
+ QVBoxLayout* lay = new QVBoxLayout( this );
+
+ m_view = new QListView( this );
+ m_view->addColumn( QString::null );
+ lay->addWidget( m_view );
+
+ QHBox* box = new QHBox( this );
+
+ QPushButton* b = new QPushButton( box );
+ b->setText( tr("&Add") );
+ connect(b, SIGNAL(clicked() ), this, SLOT(slotAdd() ) );
+
+ b = new QPushButton( box );
+ b->setText( tr("&Remove") );
+ connect(b, SIGNAL(clicked() ), this, SLOT(slotRemove() ) );
+
+ b = new QPushButton( box );
+ b->setText( tr("Rename") );
+ connect(b, SIGNAL(clicked() ), this, SLOT(slotRename() ) );
+
+ lay->addWidget( box );
+
+ init( man );
}
StringManagerDialog::~StringManagerDialog() {
-
}
StringManager StringManagerDialog::manager()const {
- return StringManager();
+ StringManager man(m_base );
+ QListViewItemIterator it(m_view);
+ while ( it.current() ) {
+ man.add( it.current()->text(0) );
+ ++it;
+ }
+
+ return man;
+}
+void StringManagerDialog::init( const StringManager& _man ) {
+ QStringList::Iterator it;
+ QStringList man = _man.names();
+ for ( it = man.begin(); it != man.end(); ++it )
+ (void)new QListViewItem( m_view, (*it) );
+
+}
+
+namespace {
+ class InputDialog : public QDialog{
+ public:
+ InputDialog( const QString& text );
+ ~InputDialog();
+
+ QString text()const;
+ private:
+ QLineEdit* m_lneEdit;
+ };
+ InputDialog::InputDialog(const QString& text )
+ : QDialog(0, 0, true ) {
+ m_lneEdit = new QLineEdit( this );
+ m_lneEdit->setText( text );
+ }
+ InputDialog::~InputDialog() {
+ }
+ QString InputDialog::text() const{
+ return m_lneEdit->text();
+ }
+
+}
+
+void StringManagerDialog::slotAdd() {
+ InputDialog dlg(QString::null);
+ dlg.setCaption( tr("Add") );
+ if ( dlg.exec() == QDialog::Accepted )
+ (void)new QListViewItem( m_view, dlg.text() );
+
+}
+void StringManagerDialog::slotRename() {
+ QListViewItem* item = m_view->currentItem();
+ if (!item) return;
+
+ InputDialog dlg(item->text(0) );
+ dlg.setCaption( tr("Rename") );
+
+ if ( dlg.exec() == QDialog::Accepted )
+ item->setText( 0, dlg.text() );
+}
+void StringManagerDialog::slotRemove() {
+ QListViewItem* item = m_view->currentItem();
+ if (!item) return;
+
+ m_view->takeItem( item );
+ delete item;
}
diff --git a/core/pim/datebook2/stringmanager.h b/core/pim/datebook2/stringmanager.h
index ac0d4bd..2eee43f 100644
--- a/core/pim/datebook2/stringmanager.h
+++ b/core/pim/datebook2/stringmanager.h
@@ -5,6 +5,7 @@
#include "managertemplate.h"
+class QListView;
namespace Datebook {
/**
* StringManager is a generic manager
@@ -25,10 +26,11 @@ namespace Datebook {
* cause we do not have a value :)
*/
void add( const QString& );
+ bool load();
+ bool save();
+ QString baseName()const;
private:
QString m_base;
- bool doLoad();
- bool doSave();
};
/**
@@ -41,6 +43,14 @@ namespace Datebook {
~StringManagerDialog();
StringManager manager()const;
+ private slots:
+ void init( const StringManager& );
+ void slotAdd();
+ void slotRemove();
+ void slotRename();
+ private:
+ QListView* m_view;
+ QString m_base;
};
}
diff --git a/core/pim/datebook2/templatemanager.cpp b/core/pim/datebook2/templatemanager.cpp
index b620cf7..541fec0 100644
--- a/core/pim/datebook2/templatemanager.cpp
+++ b/core/pim/datebook2/templatemanager.cpp
@@ -1,3 +1,16 @@
+#include <qdatetime.h>
+#include <qlistview.h>
+#include <qlayout.h>
+#include <qhbox.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+
+#include <qpe/config.h>
+
+#include <opie/odatebookaccess.h>
+#include <opie/odatebookaccessbackend_xml.h>
+
+#include "editor.h"
#include "templatemanager.h"
using namespace Datebook;
@@ -8,18 +21,164 @@ TemplateManager::TemplateManager() {
}
TemplateManager::~TemplateManager() {
}
-bool TemplateManager::doSave() {
+bool TemplateManager::save() {
+ QStringList lst = names();
+ Config conf( "datebook-templates");
+ conf.setGroup( "___Names___");
+ conf.writeEntry( "Names", names(), 0x1f );
+
+ for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
+ conf.setGroup( (*it) );
+ conf.writeEntry( "Uid", value( (*it) ).uid() );
+ }
+
return true;
}
-bool TemplateManager::doLoad() {
+bool TemplateManager::load() {
+ Config conf( "datebook-templates");
+ conf.setGroup( "___Names___");
+ QStringList lst = conf.readListEntry( "Names", 0x1f );
+ for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
+ conf.setGroup( (*it) );
+ add( (*it), OEvent() );
+ }
return true;
}
-TemplateDialog::TemplateDialog( const TemplateManager& )
+namespace {
+ class TemplateItem : public QListViewItem {
+ public:
+ TemplateItem( QListView*, const QString& text,
+ const OEvent& );
+ ~TemplateItem();
+
+ QString text()const;
+ OEvent event()const;
+
+ void setText( const QString& text );
+ void setEvent( const OEvent& );
+ private:
+ QString m_text;
+ OEvent m_event;
+ };
+ TemplateItem::TemplateItem( QListView* view,
+ const QString& text,
+ const OEvent& ev )
+ : QListViewItem( view ), m_event(ev) {
+ QListViewItem::setText( 0, text );
+ }
+ TemplateItem::~TemplateItem() {
+ }
+ void TemplateItem::setText( const QString& text ) {
+ QListViewItem::setText( 0, text );
+ m_text = text;
+ }
+ void TemplateItem::setEvent( const OEvent& ev ) {
+ m_event = ev;
+ }
+ QString TemplateItem::text()const {
+ return m_text;
+ }
+ OEvent TemplateItem::event()const {
+
+ }
+
+ class InputDialog : public QDialog{
+ public:
+ InputDialog( const QString& text );
+ ~InputDialog();
+
+ QString text()const;
+ private:
+ QLineEdit* m_lneEdit;
+ };
+ InputDialog::InputDialog(const QString& text )
+ : QDialog(0, 0, true ) {
+ m_lneEdit = new QLineEdit( this );
+ m_lneEdit->setText( text );
+ }
+ InputDialog::~InputDialog() {
+ }
+ QString InputDialog::text() const{
+ return m_lneEdit->text();
+ }
+}
+
+TemplateDialog::TemplateDialog( const TemplateManager& man, Editor* edit )
: QDialog(0, 0, true ) {
+ QVBoxLayout* lay = new QVBoxLayout(this);
+ m_view = new QListView( this );
+ m_view->addColumn( tr("Template Names") );
+ lay->addWidget( m_view );
+
+ QHBox* box = new QHBox( this );
+ lay->addWidget( box );
+
+ QPushButton* b = new QPushButton( box );
+ b->setText(tr("&Add") );
+ connect( b, SIGNAL(clicked() ), this, SLOT(slotAdd() ) );
+
+ b = new QPushButton( box );
+ b->setText(tr("&Edit") );
+ connect( b, SIGNAL(clicked() ), this, SLOT(slotEdit() ) );
+
+ b = new QPushButton( box );
+ b->setText(tr("&Rename") );
+ connect(b, SIGNAL(clicked() ), this, SLOT(slotRename() ) );
+
+ b = new QPushButton( box );
+ b->setText(tr("Re&move") );
+ connect(b, SIGNAL(clicked() ), this, SLOT(slotRemove() ) );
+
+ init( man );
+ m_edit = edit;
}
TemplateDialog::~TemplateDialog() {
}
+void TemplateDialog::slotAdd() {
+ if ( m_edit->newEvent( QDate::currentDate() ) ) {
+ (void)new TemplateItem( m_view, tr("New Template"), m_edit->event() );
+ }
+}
+void TemplateDialog::slotEdit() {
+ TemplateItem* item = static_cast<TemplateItem*>( m_view->currentItem() );
+ if (!item) return;
+
+ if (m_edit->edit( item->event() ) )
+ item->setEvent( m_edit->event() );
+
+}
+void TemplateDialog::slotRemove() {
+ QListViewItem* item = m_view->currentItem();
+ if (!item) return;
+
+ m_view->takeItem( item );
+ delete item;
+}
+void TemplateDialog::slotRename() {
+ TemplateItem* item = static_cast<TemplateItem*>( m_view->currentItem() );
+ if (!item) return;
+
+ InputDialog dlg( item->text() );
+ dlg.setCaption( tr("Rename") );
+ if ( dlg.exec() == QDialog::Accepted )
+ item->setText( dlg.text() );
+
+}
TemplateManager TemplateDialog::manager()const {
- return TemplateManager();
+ TemplateManager manager;
+
+ QListViewItemIterator it(m_view);
+ while ( it.current() ) {
+ TemplateItem* item = static_cast<TemplateItem*>( it.current() );
+ manager.add( item->text(), item->event() );
+ ++it;
+ }
+ return manager;
+}
+void TemplateDialog::init( const TemplateManager& man ) {
+ QStringList list = man.names();
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
+ (void)new TemplateItem( m_view, (*it), man.value( (*it) ) );
+ }
}
diff --git a/core/pim/datebook2/templatemanager.h b/core/pim/datebook2/templatemanager.h
index f885677..91d8b2e 100644
--- a/core/pim/datebook2/templatemanager.h
+++ b/core/pim/datebook2/templatemanager.h
@@ -7,18 +7,19 @@
#include "managertemplate.h"
+class QListView;
namespace Datebook {
/**
* The OEvent Template Manager
*/
+ class Editor;
class TemplateManager : public ManagerTemplate<OEvent> {
public:
TemplateManager();
~TemplateManager();
- private:
- virtual bool doSave();
- virtual bool doLoad();
+ bool save();
+ bool load();
};
/**
* a QDialog for editing it
@@ -26,10 +27,21 @@ namespace Datebook {
class TemplateDialog : public QDialog {
Q_OBJECT
public:
- TemplateDialog(const TemplateManager& man);
+ TemplateDialog(const TemplateManager& man, Editor*);
~TemplateDialog();
- virtual TemplateManager manager()const;
+ TemplateManager manager()const;
+
+ private slots:
+ void init( const TemplateManager& );
+ void slotAdd();
+ void slotEdit();
+ void slotRename();
+ void slotRemove();
+
+ private:
+ QListView* m_view;
+ Editor* m_edit;
};
}
diff --git a/core/pim/datebook2/view.h b/core/pim/datebook2/view.h
index e2312a3..2236aad 100644
--- a/core/pim/datebook2/view.h
+++ b/core/pim/datebook2/view.h
@@ -19,6 +19,16 @@ namespace Datebook {
static bool calcWeek( const QDate& d, int &week, int &year, bool startOnMonday = false );
virtual QPixmap pixmap()const = 0;
+
+ /**
+ * non translatable name or type
+ */
+ virtual QCString type()const = 0;
+
+ /**
+ * shown to the user
+ */
+ virtual QString name()const = 0;
virtual QString description()const = 0;
/**