34 #include "knotes/resourcemanager.h"
35 #include "knotes/resourcelocal.h"
37 #include <libkcal/journal.h>
40 KNotesResourceManager::KNotesResourceManager()
41 : TQObject( 0,
"KNotes Resource Manager" )
43 m_manager =
new KRES::Manager<ResourceNotes>(
"notes" );
44 m_manager->addObserver(
this );
45 m_manager->readConfig();
48 KNotesResourceManager::~KNotesResourceManager()
53 void KNotesResourceManager::load()
55 if ( !m_manager->standardResource() )
57 kdWarning(5500) <<
"No standard resource yet." << endl;
59 m_manager->add( resource );
60 m_manager->setStandardResource( resource );
64 KRES::Manager<ResourceNotes>::ActiveIterator it;
65 for ( it = m_manager->activeBegin(); it != m_manager->activeEnd(); ++it )
67 if ( (*it)->isOpen() ) {
68 kdDebug(5500) << (*it)->resourceName() <<
" is already open" << endl;
72 kdDebug(5500) <<
"Opening resource " + (*it)->resourceName() << endl;
73 (*it)->setManager(
this );
79 void KNotesResourceManager::save()
81 KRES::Manager<ResourceNotes>::ActiveIterator it;
82 for ( it = m_manager->activeBegin(); it != m_manager->activeEnd(); ++it )
88 bool KNotesResourceManager::addNewNote( KCal::Journal *journal )
93 if ( resource->addNote( journal ) ) {
94 registerNote( resource, journal );
98 kdWarning(5500) << k_funcinfo <<
"no resource!" << endl;
103 void KNotesResourceManager::registerNote(
ResourceNotes *resource,
104 KCal::Journal *journal )
107 m_resourceMap.insert( journal->uid(), resource );
108 emit sigRegisteredNote( journal );
111 void KNotesResourceManager::deleteNote( KCal::Journal *journal )
116 TQString uid = journal->uid();
121 res->deleteNote( journal );
122 m_resourceMap.remove( uid );
126 emit sigDeregisteredNote( journal );
130 KCal::Alarm::List KNotesResourceManager::alarms(
const TQDateTime& from,
const TQDateTime& to )
132 KCal::Alarm::List result;
134 KRES::Manager<ResourceNotes>::ActiveIterator it;
135 for ( it = m_manager->activeBegin(); it != m_manager->activeEnd(); ++it )
137 KCal::Alarm::List list = (*it)->alarms( from, to );
138 KCal::Alarm::List::ConstIterator it;
139 for ( it = list.constBegin(); it != list.constEnd(); ++it )
140 result.append( *it );
146 void KNotesResourceManager::resourceAdded(
ResourceNotes *resource )
148 kdDebug(5500) <<
"Resource added: " << resource->resourceName() << endl;
150 if ( !resource->isActive() )
153 if ( resource->isOpen() ) {
154 kdDebug(5500) << resource->resourceName() <<
" is already open" << endl;
158 resource->setManager(
this );
159 if ( resource->open() )
163 void KNotesResourceManager::resourceModified(
ResourceNotes *resource )
165 kdDebug(5500) <<
"Resource modified: " << resource->resourceName() << endl;
168 void KNotesResourceManager::resourceDeleted(
ResourceNotes *resource )
170 kdDebug(5500) <<
"Resource deleted: " << resource->resourceName() << endl;
174 #include "resourcemanager.moc"
This class provides the interfaces for a KNotes resource.