summaryrefslogtreecommitdiff
path: root/core/pim/datebook2/mainwindow.cpp
authorzecke <zecke>2003-02-24 13:34:03 (UTC)
committer zecke <zecke>2003-02-24 13:34:03 (UTC)
commitb04ced09167d910e5cab1981bde295e2e8185fee (patch) (unidiff)
tree2623e1553968654b133343ce7333995243216201 /core/pim/datebook2/mainwindow.cpp
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/pim/datebook2/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook2/mainwindow.cpp97
1 files changed, 88 insertions, 9 deletions
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 @@
13#include <qpe/qpemessagebox.h> 13#include <qpe/qpemessagebox.h>
14#include <qpe/resource.h> 14#include <qpe/resource.h>
15 15
16#include "editor.h"
16#include "show.h" 17#include "show.h"
17#include "templatemanager.h" 18#include "templatemanager.h"
18#include "bookmanager.h" 19#include "bookmanager.h"
@@ -22,14 +23,14 @@
22using namespace Datebook; 23using namespace Datebook;
23 24
24MainWindow::MainWindow() 25MainWindow::MainWindow()
25 : OPimMainWindow( "Datebook", 0, 0 ) { 26 : OPimMainWindow( "Datebook", 0, 0 ), m_descMan( "Descriptions" ), m_locMan( "Locations" )
27{
26 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 28 setIcon( Resource::loadPixmap( "datebook_icon" ) );
27 initUI(); 29 initUI();
28 initManagers(); 30 initManagers();
29 initView(); 31 initView();
30 initConfig(); 32 initConfig();
31 33
32 raiseCurrentView();
33 QTimer::singleShot(0, this, SLOT(populate() ) ); 34 QTimer::singleShot(0, this, SLOT(populate() ) );
34 35
35 QCopChannel* chan = new QCopChannel( "QPE/System", this ); 36 QCopChannel* chan = new QCopChannel( "QPE/System", this );
@@ -41,6 +42,12 @@ MainWindow::MainWindow()
41 this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); 42 this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) );
42} 43}
43MainWindow::~MainWindow() { 44MainWindow::~MainWindow() {
45 m_tempMan.save();
46 m_locMan.save();
47 m_descMan.save();
48
49 manager()->save();
50 delete m_manager;
44} 51}
45void MainWindow::doSetDocument( const QString& str ) { 52void MainWindow::doSetDocument( const QString& str ) {
46 53
@@ -95,8 +102,12 @@ void MainWindow::initUI() {
95 mb->insertItem( tr("Settings" ), m_popSetting ); 102 mb->insertItem( tr("Settings" ), m_popSetting );
96 103
97 m_popTemplate = new QPopupMenu( this ); 104 m_popTemplate = new QPopupMenu( this );
105 m_popTemplate->setCheckable( TRUE );
106 connect( m_popTemplate, SIGNAL(activated(int) ),
107 this, SLOT(slotNewFromTemplate(int) ) );
98 m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); 108 m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0);
99 109
110
100 QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), 111 QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"),
101 QString::null, 0, this, 0 ); 112 QString::null, 0, this, 0 );
102 a->addTo( m_toolBar ); 113 a->addTo( m_toolBar );
@@ -130,6 +141,10 @@ void MainWindow::initUI() {
130 a->addTo( m_popSetting ); 141 a->addTo( m_popSetting );
131 connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) ); 142 connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) );
132 143
144 a = new QAction( tr("Configure Templates"), QString::null, 0, 0 );
145 a->addTo( m_popSetting );
146 connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureTemp() ) );
147
133 connect( qApp, SIGNAL(clockChanged(bool) ), 148 connect( qApp, SIGNAL(clockChanged(bool) ),
134 this, SLOT(slotClockChanged(bool) ) ); 149 this, SLOT(slotClockChanged(bool) ) );
135 connect( qApp, SIGNAL(weekChanged(bool) ), 150 connect( qApp, SIGNAL(weekChanged(bool) ),
@@ -146,8 +161,12 @@ void MainWindow::initView() {
146} 161}
147void MainWindow::initManagers() { 162void MainWindow::initManagers() {
148 m_manager = new BookManager; 163 m_manager = new BookManager;
149 m_locMan = new LocationManager( tr("Locations") ); 164
150 m_descMan = new DescriptionManager( tr("Descriptions") ); 165 m_tempMan.load();
166 m_locMan.load();
167 m_descMan.load();
168
169 setTemplateMenu();
151} 170}
152void MainWindow::raiseCurrentView() { 171void MainWindow::raiseCurrentView() {
153 172
@@ -186,15 +205,21 @@ void MainWindow::slotReceive( const QCString&, const QByteArray& ) {
186BookManager* MainWindow::manager() { 205BookManager* MainWindow::manager() {
187 return m_manager; 206 return m_manager;
188} 207}
189TemplateManager* MainWindow::templateManager() { 208TemplateManager MainWindow::templateManager() {
190 return m_tempMan; 209 return m_tempMan;
191} 210}
192LocationManager* MainWindow::locationManager() { 211LocationManager MainWindow::locationManager() {
193 return m_locMan; 212 return m_locMan;
194} 213}
195DescriptionManager* MainWindow::descriptionManager() { 214DescriptionManager MainWindow::descriptionManager() {
196 return m_descMan; 215 return m_descMan;
197} 216}
217void MainWindow::setLocationManager( const LocationManager& loc) {
218 m_locMan = loc;
219}
220void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) {
221 m_descMan = dsc;
222}
198Show* MainWindow::eventShow() { 223Show* MainWindow::eventShow() {
199 return m_show; 224 return m_show;
200} 225}
@@ -202,10 +227,29 @@ void MainWindow::slotAction( QAction* act ) {
202 227
203} 228}
204void MainWindow::slotConfigureLocs() { 229void MainWindow::slotConfigureLocs() {
205 230 LocationManagerDialog dlg( locationManager() );
231 dlg.setCaption( tr("Configure Locations") );
232 dlg.showMaximized();
233 if (dlg.exec() == QDialog::Accepted ) {
234 setLocationManager( dlg.manager() );
235 }
206} 236}
207void MainWindow::slotConfigureDesc() { 237void MainWindow::slotConfigureDesc() {
208 238 DescriptionManagerDialog dlg( descriptionManager() );
239 dlg.setCaption( tr("Configure Descriptions") );
240 dlg.showMaximized();
241 if (dlg.exec() == QDialog::Accepted ) {
242 setDescriptionManager( dlg.manager() );
243 }
244}
245void MainWindow::slotConfigureTemp() {
246 TemplateDialog dlg( templateManager(), editor() );
247 dlg.setCaption( tr("Configure Templates") );
248 dlg.showMaximized();
249 if ( dlg.exec() == QDialog::Accepted ) {
250 m_tempMan = dlg.manager();
251 setTemplateMenu();
252 }
209} 253}
210void MainWindow::hideShow() { 254void MainWindow::hideShow() {
211 255
@@ -224,3 +268,38 @@ bool MainWindow::viewAP()const{
224bool MainWindow::viewStartMonday()const { 268bool MainWindow::viewStartMonday()const {
225 269
226} 270}
271void MainWindow::setTemplateMenu() {
272 m_popTemplate->clear();
273
274 QStringList list = templateManager().names();
275 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
276 m_popTemplate->insertItem( (*it) );
277 }
278}
279/*
280 * get the name of the item with the id id
281 * then ask for an OEvent from the manager
282 */
283void MainWindow::slotNewFromTemplate(int id ) {
284 QString name = m_popTemplate->text( id );
285
286 OEvent ev = templateManager().value( name );
287
288 if ( editor()->edit( ev ) ) {
289 ev = editor()->event();
290 ev.setUid( -1 );
291 manager()->add( ev );
292
293 /*
294 * no we'll find out if the current view
295 * should show the new event
296 * and then we will ask it to refresh
297 * FIXME for now we'll call a refresh
298 */
299 currentView()->reschedule();
300 raiseCurrentView();
301 }
302}
303Editor* MainWindow::editor() {
304 return m_edit;
305}