-rw-r--r-- | core/pim/datebook/datebook.cpp | 1 | ||||
-rw-r--r-- | core/pim/datebook/datebooksettings.cpp | 28 | ||||
-rw-r--r-- | core/pim/datebook/datebooksettings.h | 6 | ||||
-rw-r--r-- | core/pim/datebook/holiday/national/national-holidays.pro | 4 | ||||
-rw-r--r-- | core/pim/datebook/holiday/national/nationalcfg.cpp | 9 | ||||
-rw-r--r-- | core/pim/datebook/holiday/national/nationalcfgwidget.cpp | 99 | ||||
-rw-r--r-- | core/pim/datebook/holiday/national/nationalcfgwidget.h | 39 | ||||
-rw-r--r-- | core/pim/datebook/holiday/national/nationalholiday.cpp | 13 | ||||
-rw-r--r-- | core/pim/datebook/holiday/national/nationalholiday.h | 2 | ||||
-rw-r--r-- | libopie2/opiepim/ui/oholidayplugin.h | 6 | ||||
-rw-r--r-- | libopie2/opiepim/ui/oholidayplugincfgwidget.cpp | 14 | ||||
-rw-r--r-- | libopie2/opiepim/ui/oholidayplugincfgwidget.h | 30 | ||||
-rw-r--r-- | libopie2/opiepim/ui/oholidaypluginif.h | 6 | ||||
-rw-r--r-- | libopie2/opiepim/ui/ui.pro | 8 |
14 files changed, 245 insertions, 20 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 8ae4f84..70dd7b5 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -265,2 +265,3 @@ void DateBook::slotSettings() if ( QPEApplication::execDialog( &frmSettings ) ) { + frmSettings.savePlugins(); db_holiday->pluginManager()->save(); diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp index 861e266..561dc38 100644 --- a/core/pim/datebook/datebooksettings.cpp +++ b/core/pim/datebook/datebooksettings.cpp @@ -24,2 +24,5 @@ #include <opie2/odebug.h> +#include <opie2/oholidaypluginif.h> +#include <opie2/oholidayplugin.h> +#include <opie2/oholidayplugincfgwidget.h> @@ -31,2 +34,4 @@ #include <qheader.h> +#include <qtabwidget.h> +#include <qlayout.h> @@ -92,2 +97,25 @@ void DateBookSettings::setPluginList(Opie::Core::OPluginManager*aManager,Opie::C pitem->setOn( (*it).isEnabled() ); + + Opie::Datebook::HolidayPluginIf*hif = m_loader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN); + if (!hif) continue; + Opie::Datebook::HolidayPlugin*pl = hif->plugin(); + if (!pl) continue; + Opie::Datebook::HolidayPluginConfigWidget*cfg = pl->configWidget(); + if (!cfg) continue; + QWidget * dtab = new QWidget(TabWidget,pl->description()); + QVBoxLayout*dlayout = new QVBoxLayout(dtab); + dlayout->setMargin(2); + dlayout->setSpacing(2); + cfg->reparent(dtab,0,QPoint(0,0)); + dlayout->addWidget(cfg); + TabWidget->insertTab(dtab,pl->description()); + + m_cfgWidgets.append(cfg); + } +} +void DateBookSettings::savePlugins() +{ + QValueList<Opie::Datebook::HolidayPluginConfigWidget*>::Iterator it; + for (it=m_cfgWidgets.begin();it!=m_cfgWidgets.end();++it) { + (*it)->saveConfig(); } diff --git a/core/pim/datebook/datebooksettings.h b/core/pim/datebook/datebooksettings.h index df7d32c..912088f 100644 --- a/core/pim/datebook/datebooksettings.h +++ b/core/pim/datebook/datebooksettings.h @@ -24,2 +24,3 @@ #include <qpe/categoryselect.h> +#include <qvaluelist.h> @@ -34,2 +35,5 @@ namespace Ui { } +namespace Datebook { + class HolidayPluginConfigWidget; +} } @@ -57,2 +61,3 @@ public: void setPluginList(Opie::Core::OPluginManager*,Opie::Core::OPluginLoader*); + void savePlugins(); private slots: @@ -69,2 +74,3 @@ protected: Opie::Core::OPluginLoader*m_loader; + QValueList<Opie::Datebook::HolidayPluginConfigWidget*> m_cfgWidgets; }; diff --git a/core/pim/datebook/holiday/national/national-holidays.pro b/core/pim/datebook/holiday/national/national-holidays.pro index 8b2b33e..3da9c3b 100644 --- a/core/pim/datebook/holiday/national/national-holidays.pro +++ b/core/pim/datebook/holiday/national/national-holidays.pro @@ -5,4 +5,4 @@ CONFIG += qt plugin # Input -HEADERS = nationalholiday.h nationalcfg.h -SOURCES = nationalholiday.cpp nationalcfg.cpp +HEADERS = nationalholiday.h nationalcfg.h nationalcfgwidget.h +SOURCES = nationalholiday.cpp nationalcfg.cpp nationalcfgwidget.cpp INTERFACES= diff --git a/core/pim/datebook/holiday/national/nationalcfg.cpp b/core/pim/datebook/holiday/national/nationalcfg.cpp index a293251..52c453f 100644 --- a/core/pim/datebook/holiday/national/nationalcfg.cpp +++ b/core/pim/datebook/holiday/national/nationalcfg.cpp @@ -27,3 +27,2 @@ bool NHcfg::load(const QString&aPath) _content.clear();
- odebug << "Start loading file "<<_path<<oendl;
QFile *f=new QFile(_path);
@@ -33,9 +32,5 @@ bool NHcfg::load(const QString&aPath) }
- odebug << "Source" << oendl;
QXmlInputSource is(*f);
- odebug << "Reader" << oendl;
QXmlSimpleReader reader;
- odebug << "Handler" << oendl;
reader.setContentHandler(this);
- odebug << "Error handler" << oendl;
reader.setErrorHandler(this);
@@ -43,4 +38,4 @@ bool NHcfg::load(const QString&aPath) err = "";
- odebug << "parse it" << oendl;
bool ret = reader.parse(is);
+ if (err.length()>0)
odebug << "Errors: " << err << oendl;
@@ -93,3 +88,2 @@ bool NHcfg::startElement(const QString&, const QString&,const QString& name, con bool ret = false;
- odebug << "startElement: " << name << oendl;
if (name==_key_doc) {
@@ -146,3 +140,2 @@ bool NHcfg::setName(const QXmlAttributes&attr) _contentname = attr.value(nindx);
- odebug << "Contentname = " << _contentname<<oendl;
return true;
diff --git a/core/pim/datebook/holiday/national/nationalcfgwidget.cpp b/core/pim/datebook/holiday/national/nationalcfgwidget.cpp new file mode 100644 index 0000000..6e3dd7d --- a/dev/null +++ b/core/pim/datebook/holiday/national/nationalcfgwidget.cpp @@ -0,0 +1,99 @@ +#include "nationalcfgwidget.h" + +#include <opie2/odebug.h> + +#include <qpe/config.h> +#include <qpe/qpeapplication.h> + +#include <qheader.h> +#include <qlabel.h> +#include <qlistview.h> +#include <qpushbutton.h> +#include <qlayout.h> +#include <qvariant.h> +#include <qtooltip.h> +#include <qwhatsthis.h> +#include <qheader.h> +#include <qdir.h> + +/* + * Constructs a NationalHolidayConfig which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +NationalHolidayConfigWidget::NationalHolidayConfigWidget( QWidget* parent, const char* name, WFlags fl ) + : Opie::Datebook::HolidayPluginConfigWidget( parent, name, fl ) +{ + if ( !name ) + setName( "NationalHolidayConfig" ); + resize( 206, 210 ); + setCaption( tr( "Select national config" ) ); + NationalHolidayConfigLayout = new QVBoxLayout( this ); + NationalHolidayConfigLayout->setSpacing( 2 ); + NationalHolidayConfigLayout->setMargin( 2 ); + + m_headLabel = new QLabel( this, "m_headLabel" ); + m_headLabel->setText( tr( "Select one or more configs to load" ) ); + m_headLabel->setAlignment( int( QLabel::AlignCenter ) ); + NationalHolidayConfigLayout->addWidget( m_headLabel ); + + m_Configlist = new QListView( this, "m_Configlist" ); + m_Configlist->addColumn( tr( "configfiles" ) ); + QWhatsThis::add( m_Configlist, tr( "List of found xml-files which may load." ) ); + NationalHolidayConfigLayout->addWidget( m_Configlist ); + + // signals and slots connections + connect( m_Configlist, SIGNAL( clicked(QListViewItem*) ), this, SLOT( listItemClicked(QListViewItem*) ) ); + init(); +} + +void NationalHolidayConfigWidget::init() +{ + m_Configlist->header()->hide(); + m_Configlist->setSorting(-1); + + QString path = QPEApplication::qpeDir() + "etc/nationaldays"; + QDir dir( path, "*.xml" ); + QStringList list = dir.entryList(); + QStringList::Iterator it; + Config cfg("nationaldays"); + cfg.setGroup("entries"); + files = cfg.readListEntry("files"); + QCheckListItem *pitem = 0; + + for (it=list.begin();it!=list.end();++it) { + pitem = new QCheckListItem(m_Configlist,(*it),QCheckListItem::CheckBox); + if (files.find((*it)) != files.end()) { + pitem->setOn(true); + } else { + pitem->setOn(false); + } + } +} + +/* + * Destroys the object and frees any allocated resources + */ +NationalHolidayConfigWidget::~NationalHolidayConfigWidget() +{ + // no need to delete child widgets, Qt does it all for us +} + +void NationalHolidayConfigWidget::listItemClicked(QListViewItem*item) +{ + if (!item) return; + QCheckListItem*pitem = ((QCheckListItem*)item); + QStringList::Iterator it = files.find(pitem->text(0)); + if (pitem->isOn()&&it==files.end()) { + files.append(pitem->text(0)); + } else if (!pitem->isOn() && it!=files.end()) { + files.remove(it); + } +} + +void NationalHolidayConfigWidget::saveConfig() +{ + Config cfg("nationaldays"); + cfg.setGroup("entries"); + cfg.writeEntry("files",files); +} + diff --git a/core/pim/datebook/holiday/national/nationalcfgwidget.h b/core/pim/datebook/holiday/national/nationalcfgwidget.h new file mode 100644 index 0000000..9f16aa4 --- a/dev/null +++ b/core/pim/datebook/holiday/national/nationalcfgwidget.h @@ -0,0 +1,39 @@ +#ifndef NATIONALHOLIDAYCONFIGWIDGET_H +#define NATIONALHOLIDAYCONFIGWIDGET_H + +#include <opie2/oholidayplugincfgwidget.h> + +#include <qvariant.h> +#include <qwidget.h> +#include <qstringlist.h> + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QLabel; +class QListView; +class QListViewItem; + +class NationalHolidayConfigWidget : public Opie::Datebook::HolidayPluginConfigWidget +{ + Q_OBJECT + +public: + NationalHolidayConfigWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + virtual ~NationalHolidayConfigWidget(); + + virtual void saveConfig(); + +protected slots: + virtual void listItemClicked(QListViewItem*); + +protected: + void init(); + + QVBoxLayout* NationalHolidayConfigLayout; + QLabel* m_headLabel; + QListView* m_Configlist; + QStringList files; +}; + +#endif // NATIONALHOLIDAYCONFIG_H diff --git a/core/pim/datebook/holiday/national/nationalholiday.cpp b/core/pim/datebook/holiday/national/nationalholiday.cpp index 26cd913..52f3489 100644 --- a/core/pim/datebook/holiday/national/nationalholiday.cpp +++ b/core/pim/datebook/holiday/national/nationalholiday.cpp @@ -2,2 +2,3 @@ #include "nationalcfg.h" +#include "nationalcfgwidget.h" @@ -28,3 +29,2 @@ void NationalHoliday::init() files = cfg.readListEntry("files"); - odebug << "Read " << files << oendl; } @@ -34,2 +34,4 @@ void NationalHoliday::load_days() if (init_done) return; + Config cfg("nationaldays"); + cfg.setGroup("entries"); QStringList::ConstIterator it; @@ -37,5 +39,5 @@ void NationalHoliday::load_days() for (it=files.begin();it!=files.end();++it) { - odebug << QPEApplication::qpeDir()+"/etc/nationaldays/"+(*it) << oendl; - if (!readit.load(QPEApplication::qpeDir()+"/etc/nationaldays/"+(*it))) + if (!readit.load(QPEApplication::qpeDir()+"/etc/nationaldays/"+(*it))) { continue; + } tholidaylist::ConstIterator it; @@ -122,2 +124,7 @@ QValueList<EffectiveEvent> NationalHoliday::events(const QDate&start,const QDate +Opie::Datebook::HolidayPluginConfigWidget*NationalHoliday::configWidget(QWidget *parent, const char *name, QWidget::WFlags fl) +{ + return new NationalHolidayConfigWidget(parent,name,fl); +} + EXPORT_HOLIDAY_PLUGIN(NationalHoliday); diff --git a/core/pim/datebook/holiday/national/nationalholiday.h b/core/pim/datebook/holiday/national/nationalholiday.h index 6581263..afce3f4 100644 --- a/core/pim/datebook/holiday/national/nationalholiday.h +++ b/core/pim/datebook/holiday/national/nationalholiday.h @@ -7,2 +7,3 @@ #include <opie2/oholidaypluginif.h> +#include <opie2/oholidayplugincfgwidget.h> @@ -23,2 +24,3 @@ public: virtual QValueList<EffectiveEvent> events(const QDate&,const QDate&); + virtual Opie::Datebook::HolidayPluginConfigWidget*configWidget(QWidget *parent=0, const char *name = 0, QWidget::WFlags fl = 0); diff --git a/libopie2/opiepim/ui/oholidayplugin.h b/libopie2/opiepim/ui/oholidayplugin.h index 52db0eb..192a020 100644 --- a/libopie2/opiepim/ui/oholidayplugin.h +++ b/libopie2/opiepim/ui/oholidayplugin.h @@ -7,2 +7,3 @@ #include <qmap.h> +#include <qwidget.h> @@ -13,2 +14,4 @@ namespace Datebook { +class HolidayPluginConfigWidget; + class HolidayPlugin @@ -23,4 +26,5 @@ public: virtual QValueList<EffectiveEvent> events(const QDate&,const QDate&)=0; -}; + virtual HolidayPluginConfigWidget*configWidget(QWidget *parent=0, const char *name = 0, QWidget::WFlags fl = 0 ){return 0;} +}; } diff --git a/libopie2/opiepim/ui/oholidayplugincfgwidget.cpp b/libopie2/opiepim/ui/oholidayplugincfgwidget.cpp new file mode 100644 index 0000000..43380bb --- a/dev/null +++ b/libopie2/opiepim/ui/oholidayplugincfgwidget.cpp @@ -0,0 +1,14 @@ +#include "oholidayplugincfgwidget.h" + +namespace Opie { +namespace Datebook { +HolidayPluginConfigWidget::HolidayPluginConfigWidget( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{} + +HolidayPluginConfigWidget::~HolidayPluginConfigWidget() +{} + +} +} + diff --git a/libopie2/opiepim/ui/oholidayplugincfgwidget.h b/libopie2/opiepim/ui/oholidayplugincfgwidget.h new file mode 100644 index 0000000..17af467 --- a/dev/null +++ b/libopie2/opiepim/ui/oholidayplugincfgwidget.h @@ -0,0 +1,30 @@ +#ifndef _HOLIDAY_PLUGIN_CFG_WIDGET +#define _HOLIDAY_PLUGIN_CFG_WIDGET +#include <qwidget.h> + +namespace Opie { +namespace Datebook { +class HolidayPluginConfigWidget:public QWidget +{ + Q_OBJECT +public: + /** + * This will construct the widget. The widget gets deleted once the parent + * gets deleted as in any Qt application + * + * A Parent is required! + * + * @param parent The parent of the widget + * @param name The name of the object + */ + HolidayPluginConfigWidget(QWidget *parent, const char *name = 0, WFlags fl = 0 ); + virtual ~HolidayPluginConfigWidget(); + + virtual void saveConfig()=0; +}; + +} +} + +#endif + diff --git a/libopie2/opiepim/ui/oholidaypluginif.h b/libopie2/opiepim/ui/oholidaypluginif.h index 825d3ad..618d371 100644 --- a/libopie2/opiepim/ui/oholidaypluginif.h +++ b/libopie2/opiepim/ui/oholidaypluginif.h @@ -6,4 +6,4 @@ #ifndef QT_NO_COMPONENT -//017f90d4-34fc-4dc5-aed7-498c6da6571e -#define IID_HOLIDAY_PLUGIN QUuid(0x017f90d4,0x34fc,0x4dc5,0xae,0xd7,0x49,0x8c,0x6d,0xa6,0x57,0x1e) +//c0a5f73f-975e-4492-9285-af555284c4ab +#define IID_HOLIDAY_PLUGIN QUuid(0xc0a5f73f,0x975e,0x4492,0x92,0x85,0xaf,0x55,0x52,0x84,0xc4,0xab) #endif @@ -31,3 +31,2 @@ public: QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface ) { - odebug << "HolidayPluginWrapper::queryInterface()" << oendl; *iface = 0; @@ -57,3 +56,2 @@ protected: } - } diff --git a/libopie2/opiepim/ui/ui.pro b/libopie2/opiepim/ui/ui.pro index 53c7ae2..97c8d81 100644 --- a/libopie2/opiepim/ui/ui.pro +++ b/libopie2/opiepim/ui/ui.pro @@ -3,3 +3,6 @@ HEADERS += ui/opimmainwindow.h \ ui/todayconfigwidget.h \ - ui/todayplugininterface.h + ui/todayplugininterface.h \ + ui/oholidayplugin.h \ + ui/oholidayplugincfgwidget.h \ + ui/oholidaypluginif.h @@ -7,3 +10,4 @@ SOURCES += ui/opimmainwindow.cpp \ ui/opimrecurrencewidget.cpp \ - ui/todayconfigwidget.cpp + ui/todayconfigwidget.cpp \ + ui/oholidayplugincfgwidget.cpp |