summaryrefslogtreecommitdiffabout
path: root/libkdepim
Side-by-side diff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/addresseeview.cpp282
-rw-r--r--libkdepim/addresseeview.h60
-rw-r--r--libkdepim/categoryeditdialog.cpp135
-rw-r--r--libkdepim/categoryeditdialog.h62
-rw-r--r--libkdepim/categoryeditdialog.moc0
-rw-r--r--libkdepim/categoryeditdialog_base.cpp154
-rw-r--r--libkdepim/categoryeditdialog_base.h58
-rw-r--r--libkdepim/categoryeditdialog_base.moc0
-rw-r--r--libkdepim/categoryselectdialog.cpp173
-rw-r--r--libkdepim/categoryselectdialog.h69
-rw-r--r--libkdepim/categoryselectdialog.moc0
-rw-r--r--libkdepim/categoryselectdialog_base.cpp128
-rw-r--r--libkdepim/categoryselectdialog_base.h53
-rw-r--r--libkdepim/categoryselectdialog_base.moc0
-rw-r--r--libkdepim/kdateedit.cpp486
-rw-r--r--libkdepim/kdateedit.h140
-rw-r--r--libkdepim/kdateedit.moc0
-rw-r--r--libkdepim/kdatepicker.cpp472
-rw-r--r--libkdepim/kdatepicker.h181
-rw-r--r--libkdepim/kdatepicker.moc0
-rw-r--r--libkdepim/kdepim.pro.back34
-rw-r--r--libkdepim/kincidenceformatter.cpp326
-rw-r--r--libkdepim/kincidenceformatter.h42
-rw-r--r--libkdepim/kinputdialog.cpp14
-rw-r--r--libkdepim/kinputdialog.h15
-rw-r--r--libkdepim/kpimprefs.cpp59
-rw-r--r--libkdepim/kpimprefs.h53
-rw-r--r--libkdepim/kprefs.cpp463
-rw-r--r--libkdepim/kprefs.h301
-rw-r--r--libkdepim/kprefsdialog.cpp410
-rw-r--r--libkdepim/kprefsdialog.h446
-rw-r--r--libkdepim/kprefsdialog.moc0
-rw-r--r--libkdepim/ksyncprofile.cpp125
-rw-r--r--libkdepim/ksyncprofile.h106
-rw-r--r--libkdepim/libkdepim.pro50
-rw-r--r--libkdepim/libkdepimE.pro43
36 files changed, 4940 insertions, 0 deletions
diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp
new file mode 100644
index 0000000..deafd34
--- a/dev/null
+++ b/libkdepim/addresseeview.cpp
@@ -0,0 +1,282 @@
+/*
+ This file is part of libkdepim.
+
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <kabc/address.h>
+#include <kabc/addressee.h>
+#include <kabc/phonenumber.h>
+#include <kglobal.h>
+//US#include <kglobalsettings.h>
+#include <kiconloader.h>
+#include <klocale.h>
+//US #include <kstringhandler.h>
+#include <qscrollview.h>
+#include <qregexp.h>
+#include <qfile.h>
+#include <qapplication.h>
+
+
+#include "addresseeview.h"
+
+using namespace KPIM;
+
+AddresseeView::AddresseeView( QWidget *parent, const char *name )
+//US : KTextBrowser( parent, name )
+ : QTextBrowser( parent, name )
+
+
+{
+//US setWrapPolicy( QTextEdit::AtWordBoundary );
+ setLinkUnderline( false );
+ // setVScrollBarMode( QScrollView::AlwaysOff );
+ //setHScrollBarMode( QScrollView::AlwaysOff );
+
+//US QStyleSheet *sheet = styleSheet();
+//US QStyleSheetItem *link = sheet->item( "a" );
+//US link->setColor( KGlobalSettings::linkColor() );
+
+}
+
+void AddresseeView::setAddressee( const KABC::Addressee& addr )
+{
+ mAddressee = addr;
+
+ // clear view
+ setText( QString::null );
+
+ if ( mAddressee.isEmpty() )
+ return;
+
+ QString name = ( mAddressee.formattedName().isEmpty() ?
+ mAddressee.assembledName() : mAddressee.formattedName() );
+
+ QString dynamicPart;
+
+ KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
+ KABC::PhoneNumber::List::ConstIterator phoneIt;
+ for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
+ dynamicPart += QString(
+ "<tr><td align=\"right\"><b>%1</b></td>"
+ "<td align=\"left\">%2</td></tr>" )
+ .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) )
+ .arg( (*phoneIt).number() );
+ }
+
+ QStringList emails = mAddressee.emails();
+ QStringList::ConstIterator emailIt;
+ QString type = i18n( "Email" );
+ for ( emailIt = emails.begin(); emailIt != emails.end(); ++emailIt ) {
+ dynamicPart += QString(
+ "<tr><td align=\"right\"><b>%1</b></td>"
+ "<td align=\"left\"><a href=\"mailto:%2\">%3</a></td></tr>" )
+ .arg( type )
+ .arg( *emailIt )
+ .arg( *emailIt );
+ type = i18n( "Other" );
+ }
+
+ if ( !mAddressee.url().url().isEmpty() ) {
+ dynamicPart += QString(
+ "<tr><td align=\"right\"><b>%1</b></td>"
+ "<td align=\"left\">%2</td></tr>" )
+ .arg( i18n( "Homepage" ) )
+//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
+ .arg( mAddressee.url().url() );
+ //qDebug("AddresseeView::setAddressee has to be verified.");
+ }
+
+ KABC::Address::List addresses = mAddressee.addresses();
+ KABC::Address::List::ConstIterator addrIt;
+ for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
+ if ( true /*(*addrIt).label().isEmpty()*/ ) {
+ QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
+//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
+ //qDebug("adresss %s ",formattedAddress.latin1() );
+ formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
+ //qDebug("AddresseeView::setAddressee has to be verified.");
+
+ dynamicPart += QString(
+ "<tr><td align=\"right\"><b>%1</b></td>"
+ "<td align=\"left\">%2</td></tr>" )
+ .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
+ .arg( formattedAddress );
+ } else {
+
+ dynamicPart += QString(
+ "<tr><td align=\"right\"><b>%1</b></td>"
+ "<td align=\"left\">%2</td></tr>" )
+ .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
+//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
+ .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
+
+ }
+ }
+
+ QString notes;
+ if ( !mAddressee.note().isEmpty() ) {
+ notes = QString(
+ "<tr>"
+ "<td align=\"right\" valign=\"top\"><b>%1:</b></td>" // note label
+ "<td align=\"left\">%2</td>" // note
+ "</tr>" ).arg( i18n( "Notes" ) )
+//US .arg( mAddressee.note().replace( '\n', "<br>" ) );
+ .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
+ //qDebug("AddresseeView::setAddressee has to be verified.");
+ }
+
+ QString aRole = "";
+ QString aOrga = "";
+ if ( true /*!mAddressee.role().isEmpty()*/ ) {
+ aRole = "<tr>"
+ "<td align=\"left\">" + mAddressee.role() + "</td>"
+ "</tr>";
+ }
+ if ( true /*!mAddressee.organization().isEmpty()*/ ) {
+ aOrga = "<tr>"
+ "<td align=\"left\">" + mAddressee.organization() + "</td>" ;
+ "</tr>";
+ }
+ mText = "";
+ QString picString = "";
+ KABC::Picture picture = mAddressee.photo();
+ bool picAvailintern = false;
+ bool picAvailUrl = false;
+ if (! picture.undefined() ) {
+ picAvailintern = (picture.isIntern() && !picture.data().isNull());
+ picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
+ }
+ if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
+ if ( picAvailintern ) {
+ QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
+ } else {
+ if ( picAvailUrl ) {
+ QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() ));
+ } else {
+ QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) );
+ }
+ }
+ picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
+ mText = QString::fromLatin1(
+ "<html>"
+ "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
+ "<table>"
+ "<tr>"
+ "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
+ "%3"
+ "</td>"
+ "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
+ "</tr>"
+ "%5" // role
+ "%6" // organization
+ "<td colspan=\"2\">&nbsp;</td>"
+ "%7" // dynamic part
+ "%8" // notes
+ "</table>"
+ "</body>"
+ "</html>")
+//US
+ .arg( /*KGlobalSettings::textColor().name()*/ "black" )
+//US
+ .arg( /*KGlobalSettings::baseColor().name()*/ "white" )
+ .arg( picString )
+ .arg( name )
+ .arg( aRole )
+ .arg( aOrga )
+ .arg( dynamicPart )
+ .arg( notes );
+
+ } else { // no picture!
+
+mText = "<table width=\"100%\">\n";
+ //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
+#ifdef DESKTOP_VERSION
+ mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
+#else
+ mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>";
+#endif
+
+#ifdef DESKTOP_VERSION
+ mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>";
+#else
+ mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>";
+#endif
+ mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
+
+ mText += "<table><td colspan=\"2\">&nbsp;</td>";
+ /*
+ mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>"
+ "<td align=\"left\"><b>%2</b></td></tr>" )
+ .arg( i18n(" ") )
+ .arg( name );
+ */
+ if ( ! mAddressee.role().isEmpty() )
+ mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
+ "<td align=\"left\">%2</td></tr>" )
+ .arg( i18n(" ") )
+ .arg( mAddressee.role());
+ if ( ! mAddressee.organization().isEmpty() )
+ mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
+ "<td align=\"left\">%2</td></tr>" )
+ .arg( i18n(" ") )
+ .arg( mAddressee.organization());
+ mText += dynamicPart;
+ mText += notes;
+ mText += "</table>";
+
+ }
+
+ // at last display it...
+ setText( mText );
+}
+
+KABC::Addressee AddresseeView::addressee() const
+{
+ return mAddressee;
+}
+void AddresseeView::addTag(const QString & tag,const QString & text)
+{
+ if ( text.isEmpty() )
+ return;
+ int number=text.contains("\n");
+ QString str = "<" + tag + ">";
+ QString tmpText=text;
+ QString tmpStr=str;
+ if(number !=-1)
+ {
+ if (number > 0) {
+ int pos=0;
+ QString tmp;
+ for(int i=0;i<=number;i++) {
+ pos=tmpText.find("\n");
+ tmp=tmpText.left(pos);
+ tmpText=tmpText.right(tmpText.length()-pos-1);
+ tmpStr+=tmp+"<br>";
+ }
+ }
+ else tmpStr += tmpText;
+ tmpStr+="</" + tag + ">";
+ mText.append(tmpStr);
+ }
+ else
+ {
+ str += text + "</" + tag + ">";
+ mText.append(str);
+ }
+}
diff --git a/libkdepim/addresseeview.h b/libkdepim/addresseeview.h
new file mode 100644
index 0000000..598ef0d
--- a/dev/null
+++ b/libkdepim/addresseeview.h
@@ -0,0 +1,60 @@
+/*
+ This file is part of libkdepim.
+
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef KPIM_ADDRESSEEVIEW_H
+#define KPIM_ADDRESSEEVIEW_H
+
+#include <kabc/addressee.h>
+
+//US #include <ktextbrowser.h>
+#include <qtextbrowser.h>
+
+namespace KPIM {
+
+//US class AddresseeView : public KTextBrowser
+class AddresseeView : public QTextBrowser
+{
+ public:
+ AddresseeView( QWidget *parent = 0, const char *name = 0 );
+
+ /**
+ Sets the addressee object. The addressee is displayed immediately.
+
+ @param addr The addressee object.
+ */
+ void setAddressee( const KABC::Addressee& addr );
+
+ /**
+ Returns the current addressee object.
+ */
+ KABC::Addressee addressee() const;
+
+ private:
+ KABC::Addressee mAddressee;
+ QString mText;
+ void addTag(const QString & tag,const QString & text);
+ class AddresseeViewPrivate;
+ AddresseeViewPrivate *d;
+};
+
+}
+
+#endif
diff --git a/libkdepim/categoryeditdialog.cpp b/libkdepim/categoryeditdialog.cpp
new file mode 100644
index 0000000..87172c1
--- a/dev/null
+++ b/libkdepim/categoryeditdialog.cpp
@@ -0,0 +1,135 @@
+/*
+ This file is part of libkdepim.
+ Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qstringlist.h>
+#include <qlineedit.h>
+#include <qlistview.h>
+#include <qheader.h>
+#include <qpushbutton.h>
+#include <qapplication.h>
+
+#include "kpimprefs.h"
+
+#include "categoryeditdialog.h"
+
+using namespace KPIM;
+
+CategoryEditDialog::CategoryEditDialog( KPimPrefs *prefs, QWidget* parent,
+ const char* name, bool modal,
+ WFlags fl )
+ : CategoryEditDialog_base( parent, name, modal, fl ),
+ mPrefs( prefs )
+{
+ mCategories->header()->hide();
+
+ QStringList::Iterator it;
+ bool categoriesExist=false;
+ for (it = mPrefs->mCustomCategories.begin();
+ it != mPrefs->mCustomCategories.end(); ++it ) {
+ new QListViewItem(mCategories,*it);
+ categoriesExist=true;
+ }
+
+ connect(mCategories,SIGNAL(selectionChanged(QListViewItem *)),
+ SLOT(editItem(QListViewItem *)));
+ connect(mEdit,SIGNAL(textChanged ( const QString & )),this,SLOT(slotTextChanged(const QString &)));
+ mButtonRemove->setEnabled(categoriesExist);
+ mButtonModify->setEnabled(categoriesExist);
+ mButtonAdd->setEnabled(!mEdit->text().isEmpty());
+ if ( QApplication::desktop()->width() > 460 )
+ resize( 300, 360 );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+CategoryEditDialog::~CategoryEditDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void CategoryEditDialog::slotTextChanged(const QString &text)
+{
+ mButtonAdd->setEnabled(!text.isEmpty());
+}
+
+void CategoryEditDialog::add()
+{
+ if (!mEdit->text().isEmpty()) {
+ new QListViewItem(mCategories,mEdit->text());
+ mEdit->setText("");
+ mButtonRemove->setEnabled(mCategories->childCount()>0);
+ mButtonModify->setEnabled(mCategories->childCount()>0);
+ }
+}
+
+void CategoryEditDialog::remove()
+{
+ if (mCategories->currentItem()) {
+ delete mCategories->currentItem();
+ mButtonRemove->setEnabled(mCategories->childCount()>0);
+ mButtonModify->setEnabled(mCategories->childCount()>0);
+ }
+}
+
+void CategoryEditDialog::modify()
+{
+ if (!mEdit->text().isEmpty()) {
+ if (mCategories->currentItem()) {
+ mCategories->currentItem()->setText(0,mEdit->text());
+ }
+ }
+}
+void CategoryEditDialog::accept()
+{
+ slotOk();
+}
+
+void CategoryEditDialog::slotOk()
+{
+ slotApply();
+ QDialog::accept();
+}
+
+void CategoryEditDialog::slotApply()
+{
+ mPrefs->mCustomCategories.clear();
+
+ QListViewItem *item = mCategories->firstChild();
+ while(item) {
+ mPrefs->mCustomCategories.append(item->text(0));
+ item = item->nextSibling();
+ }
+ mPrefs->writeConfig();
+
+ emit categoryConfigChanged();
+}
+
+void CategoryEditDialog::editItem(QListViewItem *item)
+{
+ mEdit->setText(item->text(0));
+ mButtonRemove->setEnabled(true);
+ mButtonModify->setEnabled(true);
+}
+
+#include "categoryeditdialog.moc"
diff --git a/libkdepim/categoryeditdialog.h b/libkdepim/categoryeditdialog.h
new file mode 100644
index 0000000..027cb98
--- a/dev/null
+++ b/libkdepim/categoryeditdialog.h
@@ -0,0 +1,62 @@
+/*
+ This file is part of libkdepim.
+ Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+#ifndef KPIM_CATEGORYEDITDIALOG_H
+#define KPIM_CATEGORYEDITDIALOG_H
+
+#include <libkdepim/categoryeditdialog_base.h>
+
+class KPimPrefs;
+
+namespace KPIM {
+
+class CategoryEditDialog : public CategoryEditDialog_base
+{
+ Q_OBJECT
+ public:
+ CategoryEditDialog( KPimPrefs *prefs, QWidget* parent = 0,
+ const char* name = 0,
+ bool modal = FALSE, WFlags fl = 0 );
+ ~CategoryEditDialog();
+
+ public slots:
+ void add();
+ void remove();
+ void modify();
+ void accept();
+
+ void slotOk();
+ void slotApply();
+
+ signals:
+ void categoryConfigChanged();
+
+ private slots:
+ void editItem(QListViewItem *item);
+ void slotTextChanged(const QString &text);
+
+ KPimPrefs *mPrefs;
+};
+
+}
+
+#endif
diff --git a/libkdepim/categoryeditdialog.moc b/libkdepim/categoryeditdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/libkdepim/categoryeditdialog.moc
diff --git a/libkdepim/categoryeditdialog_base.cpp b/libkdepim/categoryeditdialog_base.cpp
new file mode 100644
index 0000000..ac99190
--- a/dev/null
+++ b/libkdepim/categoryeditdialog_base.cpp
@@ -0,0 +1,154 @@
+#include <klocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryeditdialog_base.ui'
+**
+** Created: Sat Mar 29 21:46:09 2003
+** by: The User Interface Compiler ()
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "categoryeditdialog_base.h"
+
+#include <qvariant.h>
+#include <qheader.h>
+#include <qlineedit.h>
+#include <qlistview.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a CategoryEditDialog_base as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * TRUE to construct a modal dialog.
+ */
+CategoryEditDialog_base::CategoryEditDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl )
+ : QDialog( parent, name, true, fl )
+
+{
+ if ( !name )
+ setName( "CategoryEditDialog_base" );
+ CategoryEditDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "CategoryEditDialog_baseLayout");
+
+ mEdit = new QLineEdit( this, "mEdit" );
+
+ CategoryEditDialog_baseLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 );
+
+ Layout13 = new QHBoxLayout( 0, 0, 6, "Layout13");
+
+ // mButtonHelp = new QPushButton( this, "mButtonHelp" );
+ //mButtonHelp->setAutoDefault( TRUE );
+ //Layout13->addWidget( mButtonHelp );
+ //QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ //Layout13->addItem( spacer );
+
+ //mApply = new QPushButton( this, "mApply" );
+ // Layout13->addWidget( mApply );
+
+ mButtonOk = new QPushButton( this, "mButtonOk" );
+ mButtonOk->setAutoDefault( TRUE );
+ mButtonOk->setDefault( TRUE );
+ Layout13->addWidget( mButtonOk );
+
+ mButtonCancel = new QPushButton( this, "mButtonCancel" );
+ mButtonCancel->setAutoDefault( TRUE );
+ Layout13->addWidget( mButtonCancel );
+
+ CategoryEditDialog_baseLayout->addMultiCellLayout( Layout13, 2, 2, 0, 1 );
+
+ mCategories = new QListView( this, "mCategories" );
+ mCategories->addColumn( tr2i18n( "Category" ) );
+
+ CategoryEditDialog_baseLayout->addWidget( mCategories, 0, 0 );
+
+ layout103 = new QVBoxLayout( 0, 0, 6, "layout103");
+
+ mButtonAdd = new QPushButton( this, "mButtonAdd" );
+ layout103->addWidget( mButtonAdd );
+
+ mButtonModify = new QPushButton( this, "mButtonModify" );
+ layout103->addWidget( mButtonModify );
+
+ mButtonRemove = new QPushButton( this, "mButtonRemove" );
+ layout103->addWidget( mButtonRemove );
+ QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ layout103->addItem( spacer_2 );
+
+ CategoryEditDialog_baseLayout->addLayout( layout103, 0, 1 );
+ languageChange();
+ resize( sizeHint() );
+
+ // signals and slots connections
+ connect( mButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ connect( mButtonAdd, SIGNAL( clicked() ), this, SLOT( add() ) );
+ connect( mButtonModify, SIGNAL( clicked() ), this, SLOT( modify() ) );
+ connect( mButtonRemove, SIGNAL( clicked() ), this, SLOT( remove() ) );
+ connect( mButtonOk, SIGNAL( clicked() ), this, SLOT( slotOk() ) );
+ //connect( mApply, SIGNAL( clicked() ), this, SLOT( slotApply() ) );
+
+ // tab order
+ // setTabOrder( mCategories, mEdit );
+// setTabOrder( mEdit, mButtonAdd );
+// setTabOrder( mButtonAdd, mButtonModify );
+// setTabOrder( mButtonModify, mButtonRemove );
+// setTabOrder( mButtonRemove, mButtonHelp );
+// setTabOrder( mButtonHelp, mApply );
+// setTabOrder( mApply, mButtonOk );
+// setTabOrder( mButtonOk, mButtonCancel );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+CategoryEditDialog_base::~CategoryEditDialog_base()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void CategoryEditDialog_base::languageChange()
+{
+ setCaption( tr2i18n( "Edit Categories" ) );
+ // mButtonHelp->setText( tr2i18n( "&Help" ) );
+ // mApply->setText( tr2i18n( "&Apply" ) );
+ mButtonOk->setText( tr2i18n( "&OK" ) );
+ mButtonCancel->setText( tr2i18n( "&Cancel" ) );
+ mCategories->header()->setLabel( 0, tr2i18n( "Category" ) );
+ mButtonAdd->setText( tr2i18n( "A&dd" ) );
+ mButtonModify->setText( tr2i18n( "&Modify" ) );
+ mButtonRemove->setText( tr2i18n( "&Remove" ) );
+}
+
+void CategoryEditDialog_base::add()
+{
+ qWarning( "CategoryEditDialog_base::add(): Not implemented yet" );
+}
+
+void CategoryEditDialog_base::modify()
+{
+ qWarning( "CategoryEditDialog_base::modify(): Not implemented yet" );
+}
+
+void CategoryEditDialog_base::slotApply()
+{
+ qWarning( "CategoryEditDialog_base::slotApply(): Not implemented yet" );
+}
+
+void CategoryEditDialog_base::remove()
+{
+ qWarning( "CategoryEditDialog_base::remove(): Not implemented yet" );
+}
+
+void CategoryEditDialog_base::slotOk()
+{
+ qWarning( "CategoryEditDialog_base::slotOk(): Not implemented yet" );
+}
+
+#include "categoryeditdialog_base.moc"
diff --git a/libkdepim/categoryeditdialog_base.h b/libkdepim/categoryeditdialog_base.h
new file mode 100644
index 0000000..5557ad0
--- a/dev/null
+++ b/libkdepim/categoryeditdialog_base.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+** Form interface generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryeditdialog_base.ui'
+**
+** Created: Sat Mar 29 21:45:20 2003
+** by: The User Interface Compiler ()
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#ifndef CATEGORYEDITDIALOG_BASE_H
+#define CATEGORYEDITDIALOG_BASE_H
+
+#include <qvariant.h>
+#include <qdialog.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QLineEdit;
+class QListView;
+class QListViewItem;
+class QPushButton;
+
+class CategoryEditDialog_base : public QDialog
+{
+ Q_OBJECT
+
+public:
+ CategoryEditDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~CategoryEditDialog_base();
+
+ QLineEdit* mEdit;
+ QPushButton* mButtonHelp;
+ QPushButton* mApply;
+ QPushButton* mButtonOk;
+ QPushButton* mButtonCancel;
+ QListView* mCategories;
+ QPushButton* mButtonAdd;
+ QPushButton* mButtonModify;
+ QPushButton* mButtonRemove;
+
+public slots:
+ virtual void add();
+ virtual void modify();
+ virtual void slotApply();
+ virtual void remove();
+ virtual void slotOk();
+
+protected:
+ QGridLayout* CategoryEditDialog_baseLayout;
+ QHBoxLayout* Layout13;
+ QVBoxLayout* layout103;
+
+protected slots:
+ virtual void languageChange();
+};
+
+#endif // CATEGORYEDITDIALOG_BASE_H
diff --git a/libkdepim/categoryeditdialog_base.moc b/libkdepim/categoryeditdialog_base.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/libkdepim/categoryeditdialog_base.moc
diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp
new file mode 100644
index 0000000..7b0aced
--- a/dev/null
+++ b/libkdepim/categoryselectdialog.cpp
@@ -0,0 +1,173 @@
+/*
+ This file is part of libkdepim.
+ Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qlistview.h>
+#include <qpushbutton.h>
+#include <qheader.h>
+#include <qapp.h>
+#include <qmessagebox.h>
+
+
+#include <libkdepim/categoryeditdialog.h>
+#include "categoryselectdialog.h"
+
+#include "kpimprefs.h"
+
+using namespace KPIM;
+
+CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent,
+ const char* name,
+ bool modal, WFlags fl )
+ : CategorySelectDialog_base( parent, name, true, fl ),
+ mPrefs( prefs )
+{
+ mCategories->header()->hide();
+
+ setCategories();
+
+ connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog()));
+ if ( qApp->desktop()->height() < 321 )
+ setMaximumHeight( QApplication::desktop()->height() - 50 );
+ else
+ setMaximumHeight( QApplication::desktop()->height() - 80 );
+ if ( QApplication::desktop()->width() > 460 )
+ resize( 260, 360 );
+}
+void CategorySelectDialog::editCategoriesDialog()
+{
+ KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this );
+
+ ced->exec();
+ delete ced;
+ setCategories();
+}
+void CategorySelectDialog::setCategories()
+{
+ mCategories->clear();
+ mCategoryList.clear();
+
+ QStringList::Iterator it;
+
+ for (it = mPrefs->mCustomCategories.begin();
+ it != mPrefs->mCustomCategories.end(); ++it ) {
+ new QCheckListItem(mCategories,*it,QCheckListItem::CheckBox);
+ }
+}
+
+CategorySelectDialog::~CategorySelectDialog()
+{
+}
+
+void CategorySelectDialog::setSelected(const QStringList &selList)
+{
+ clear();
+
+ QStringList::ConstIterator it;
+ QStringList notFound;
+ bool found = false;
+ for (it=selList.begin();it!=selList.end();++it) {
+ //qDebug(" CategorySelectDialog::setSelected(");
+ QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
+ while (item) {
+ if (item->text() == *it) {
+ item->setOn(true);
+ found = true;
+ break;
+ }
+ item = (QCheckListItem *)item->nextSibling();
+ }
+// if ( ! found ) {
+
+//emit updateCategoriesGlobal();
+// QMessageBox::information( this, "KO/E: Information!",
+// "Categories found, which were not\n"
+// "in list of categories!\n"
+// "message",
+// "OK", "", 0,
+// 0, 1 );
+// setSelected(selList);
+// return;
+// }
+ }
+}
+
+QStringList CategorySelectDialog::selectedCategories() const
+{
+ return mCategoryList;
+}
+
+void CategorySelectDialog::slotApply()
+{
+ QStringList categories;
+ QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
+ while (item) {
+ if (item->isOn()) {
+ categories.append(item->text());
+ }
+ item = (QCheckListItem *)item->nextSibling();
+ }
+
+ QString categoriesStr = categories.join(",");
+
+ mCategoryList = categories;
+
+ emit categoriesSelected(categories);
+ emit categoriesSelected(categoriesStr);
+}
+void CategorySelectDialog::accept()
+{
+ slotOk();
+}
+
+void CategorySelectDialog::slotOk()
+{
+ slotApply();
+ QDialog::accept();
+}
+
+void CategorySelectDialog::clear()
+{
+ QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
+ while (item) {
+ item->setOn(false);
+ item = (QCheckListItem *)item->nextSibling();
+ }
+}
+
+void CategorySelectDialog::updateCategoryConfig()
+{
+ QStringList selected;
+ QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
+ while (item) {
+ if (item->isOn()) {
+ selected.append(item->text());
+ }
+ item = (QCheckListItem *)item->nextSibling();
+ }
+
+ setCategories();
+
+ setSelected(selected);
+}
+
+#include "categoryselectdialog.moc"
diff --git a/libkdepim/categoryselectdialog.h b/libkdepim/categoryselectdialog.h
new file mode 100644
index 0000000..8507dc4
--- a/dev/null
+++ b/libkdepim/categoryselectdialog.h
@@ -0,0 +1,69 @@
+/*
+ This file is part of libkdepim.
+ Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+#ifndef KPIM_CATEGORYSELECTDIALOG_H
+#define KPIM_CATEGORYSELECTDIALOG_H
+
+#include <libkdepim/categoryselectdialog_base.h>
+
+class KPimPrefs;
+
+namespace KPIM {
+
+class CategorySelectDialog : public CategorySelectDialog_base
+{
+ Q_OBJECT
+ public:
+ CategorySelectDialog( KPimPrefs *prefs, QWidget* parent = 0,
+ const char* name = 0,
+ bool modal = FALSE, WFlags fl = 0 );
+ ~CategorySelectDialog();
+
+ void setCategories();
+ void setSelected(const QStringList &selList);
+
+ QStringList selectedCategories() const;
+
+ public slots:
+ void slotOk();
+ void slotApply();
+ void clear();
+ void accept();
+ void editCategoriesDialog();
+ void updateCategoryConfig();
+
+ signals:
+ void categoriesSelected(const QString &);
+ void categoriesSelected(const QStringList &);
+ void editCategories();
+
+ private:
+ KPimPrefs *mPrefs;
+ QStringList mCategoryList;
+
+ class CategorySelectDialogPrivate;
+ CategorySelectDialogPrivate *d;
+};
+
+}
+
+#endif
diff --git a/libkdepim/categoryselectdialog.moc b/libkdepim/categoryselectdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/libkdepim/categoryselectdialog.moc
diff --git a/libkdepim/categoryselectdialog_base.cpp b/libkdepim/categoryselectdialog_base.cpp
new file mode 100644
index 0000000..5e5fa72
--- a/dev/null
+++ b/libkdepim/categoryselectdialog_base.cpp
@@ -0,0 +1,128 @@
+#include <klocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryselectdialog_base.ui'
+**
+** Created: Sat Mar 29 21:46:05 2003
+** by: The User Interface Compiler ()
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "categoryselectdialog_base.h"
+
+#include <qvariant.h>
+#include <qheader.h>
+#include <qlistview.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a CategorySelectDialog_base as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * TRUE to construct a modal dialog.
+ */
+CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl )
+ : QDialog( parent, name, modal, fl )
+
+{
+ if ( !name )
+ setName( "CategorySelectDialog_base" );
+ CategorySelectDialog_baseLayout = new QVBoxLayout( this, 11, 6, "CategorySelectDialog_baseLayout");
+
+ mCategories = new QListView( this, "mCategories" );
+ mCategories->addColumn( i18n( "Category" ) );
+ CategorySelectDialog_baseLayout->addWidget( mCategories );
+
+ Layout12 = new QHBoxLayout( 0, 0, 6, "Layout12");
+
+ mClear = new QPushButton( this, "mClear" );
+ Layout12->addWidget( mClear );
+ // QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ //Layout12->addItem( spacer );
+
+ mButtonEdit = new QPushButton( this, "mButtonEdit" );
+ Layout12->addWidget( mButtonEdit );
+ CategorySelectDialog_baseLayout->addLayout( Layout12 );
+
+ Layout11 = new QHBoxLayout( 0, 0, 6, "Layout11");
+
+ //mButtonHelp = new QPushButton( this, "mButtonHelp" );
+ //Layout11->addWidget( mButtonHelp );
+ //QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ // Layout11->addItem( spacer_2 );
+
+ //mApply = new QPushButton( this, "mApply" );
+ // Layout11->addWidget( mApply );
+
+ mButtonOk = new QPushButton( this, "mButtonOk" );
+ mButtonOk->setOn( FALSE );
+ mButtonOk->setDefault( TRUE );
+ Layout11->addWidget( mButtonOk );
+
+ mButtonCancel = new QPushButton( this, "mButtonCancel" );
+ Layout11->addWidget( mButtonCancel );
+ CategorySelectDialog_baseLayout->addLayout( Layout11 );
+ languageChange();
+ // resize( sizeHint() );
+
+ // signals and slots connections
+ connect( mButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ connect( mButtonOk, SIGNAL( clicked() ), this, SLOT( slotOk() ) );
+ connect( mClear, SIGNAL( clicked() ), this, SLOT( clear() ) );
+ //connect( mApply, SIGNAL( clicked() ), this, SLOT( slotApply() ) );
+
+ // tab order
+ setTabOrder( mCategories, mClear );
+ setTabOrder( mClear, mButtonEdit );
+ setTabOrder( mButtonEdit, mButtonOk );//mButtonHelp );
+ // setTabOrder( mButtonHelp, mApply );
+ // setTabOrder( mApply, mButtonOk );
+ setTabOrder( mButtonOk, mButtonCancel );
+ // showMaximized();
+ //raise();
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+CategorySelectDialog_base::~CategorySelectDialog_base()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void CategorySelectDialog_base::languageChange()
+{
+ setCaption( i18n( "Select Categories" ) );
+ mCategories->header()->setLabel( 0, tr2i18n( "Category" ) );
+ mClear->setText( i18n( " &Deselect All " ) );
+ mButtonEdit->setText( i18n( " &Edit Categories " ) );
+ // mButtonHelp->setText( tr2i18n( "&Help" ) );
+ //mApply->setText( i18n( "&Apply" ) );
+ mButtonOk->setText( i18n( "&OK" ) );
+ mButtonCancel->setText( i18n( "&Cancel" ) );
+}
+
+void CategorySelectDialog_base::clear()
+{
+ qWarning( "CategorySelectDialog_base::clear(): Not implemented yet" );
+}
+
+void CategorySelectDialog_base::slotApply()
+{
+ qWarning( "CategorySelectDialog_base::slotApply(): Not implemented yet" );
+}
+
+void CategorySelectDialog_base::slotOk()
+{
+ qWarning( "CategorySelectDialog_base::slotOk(): Not implemented yet" );
+}
+
+#include "categoryselectdialog_base.moc"
diff --git a/libkdepim/categoryselectdialog_base.h b/libkdepim/categoryselectdialog_base.h
new file mode 100644
index 0000000..af905ed
--- a/dev/null
+++ b/libkdepim/categoryselectdialog_base.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+** Form interface generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryselectdialog_base.ui'
+**
+** Created: Sat Mar 29 21:45:20 2003
+** by: The User Interface Compiler ()
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#ifndef CATEGORYSELECTDIALOG_BASE_H
+#define CATEGORYSELECTDIALOG_BASE_H
+
+#include <qvariant.h>
+#include <qdialog.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QListView;
+class QListViewItem;
+class QPushButton;
+
+class CategorySelectDialog_base : public QDialog
+{
+ Q_OBJECT
+
+public:
+ CategorySelectDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~CategorySelectDialog_base();
+
+ QListView* mCategories;
+ QPushButton* mClear;
+ QPushButton* mButtonEdit;
+ QPushButton* mButtonHelp;
+ QPushButton* mApply;
+ QPushButton* mButtonOk;
+ QPushButton* mButtonCancel;
+
+public slots:
+ virtual void clear();
+ virtual void slotApply();
+ virtual void slotOk();
+
+protected:
+ QVBoxLayout* CategorySelectDialog_baseLayout;
+ QHBoxLayout* Layout12;
+ QHBoxLayout* Layout11;
+
+protected slots:
+ virtual void languageChange();
+};
+
+#endif // CATEGORYSELECTDIALOG_BASE_H
diff --git a/libkdepim/categoryselectdialog_base.moc b/libkdepim/categoryselectdialog_base.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/libkdepim/categoryselectdialog_base.moc
diff --git a/libkdepim/kdateedit.cpp b/libkdepim/kdateedit.cpp
new file mode 100644
index 0000000..60bd2cf
--- a/dev/null
+++ b/libkdepim/kdateedit.cpp
@@ -0,0 +1,486 @@
+/*
+ This file is part of libkdepim.
+
+ Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qapplication.h>
+#include <qevent.h>
+#include <qlineedit.h>
+#include <qpixmap.h>
+#include <qpushbutton.h>
+
+#include <kdatepicker.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <knotifyclient.h>
+#include <qpalette.h>
+
+#include "kdateedit.h"
+#include "kdateedit.moc"
+
+KDateEdit::KDateEdit(QWidget *parent, const char *name, bool withoutDP )
+ : QHBox(parent, name)
+{
+ dateFormShort = true;
+ withoutDp = withoutDP;
+ mDateEdit = new QLineEdit(this);
+ mDateEdit->setText(KGlobal::locale()->formatDate(QDate::currentDate(),dateFormShort));
+ setFocusProxy(mDateEdit);
+ mDateEdit->installEventFilter(this);
+
+ // Highlight Background and Textcolor
+ QPalette palette = QWidget::palette();
+ unsigned char red, green, blue;
+ red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10;
+ green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10;
+ blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10;
+ palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) );
+ palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) );
+ mDateEdit->setPalette( palette );
+
+ if ( withoutDP ) {
+ mDateFrame = 0;
+ mDateButton = 0;
+ mDatePicker = 0;
+ } else {
+ QPixmap pixmap = SmallIcon("smallcal");
+ mDateButton = new QPushButton(this);
+ mDateButton->setPixmap(pixmap);
+
+ mDateFrame = new QVBox(0,0,WType_Popup);
+ // mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
+ mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
+ mDateFrame->setLineWidth(3);
+ mDateFrame->hide();
+
+ mDatePicker = new KDatePicker(mDateFrame,QDate::currentDate());
+ connect(mDatePicker,SIGNAL(dateEntered(QDate)),SLOT(setDate(QDate)));
+ connect(mDatePicker,SIGNAL(dateEntered(QDate)),SIGNAL(dateChanged(QDate)));
+ connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(setDate(QDate)));
+ connect(mDatePicker,SIGNAL(dateSelected(QDate)),SIGNAL(dateChanged(QDate)));
+ connect(mDatePicker,SIGNAL(dateSelected(QDate)),mDateFrame,SLOT(hide()));
+ connect(mDateButton,SIGNAL(clicked()),SLOT(toggleDatePicker()));
+
+ //mDateFrame->resize( 400, 300 );
+
+ }
+ connect(mDateEdit,SIGNAL(returnPressed()),SLOT(lineEnterPressed()));
+ connect(mDateEdit,SIGNAL(textChanged(const QString &)),
+ SLOT(textChanged(const QString &)));
+
+ // Create the keyword list. This will be used to match against when the user
+ // enters information.
+ mKeywordMap[i18n("tomorrow")] = 1;
+ mKeywordMap[i18n("today")] = 0;
+ mKeywordMap[i18n("yesterday")] = -1;
+
+ /*
+ * This loop uses some math tricks to figure out the offset in days
+ * to the next date the given day of the week occurs. There
+ * are two cases, that the new day is >= the current day, which means
+ * the new day has not occured yet or that the new day < the current day,
+ * which means the new day is already passed (so we need to find the
+ * day in the next week).
+ */
+ QString dayName;
+ int currentDay = QDate::currentDate().dayOfWeek();
+ for (int i = 1; i <= 7; ++i)
+ {
+ dayName = KGlobal::locale()->weekDayName(i).lower();
+ if (i >= currentDay)
+ mKeywordMap[dayName] = i - currentDay;
+ else
+ mKeywordMap[dayName] = 7 - currentDay + i;
+ }
+
+ mTextChanged = false;
+ mHandleInvalid = false;
+ QWidget::setTabOrder( mDateEdit, mDateButton );
+}
+
+KDateEdit::~KDateEdit()
+{
+ delete mDateFrame;
+}
+
+void KDateEdit::setDate(QDate newDate)
+{
+ if (!newDate.isValid() && !mHandleInvalid)
+ return;
+ if ( readDate() == newDate )
+ return;
+ QString dateString = "";
+ if(newDate.isValid())
+ dateString = KGlobal::locale()->formatDate( newDate, dateFormShort );
+
+ mTextChanged = false;
+
+ // We do not want to generate a signal here, since we explicity setting
+ // the date
+ bool b = mDateEdit->signalsBlocked();
+ mDateEdit->blockSignals(true);
+ mDateEdit->setText(dateString);
+ mDateEdit->blockSignals(b);
+}
+
+void KDateEdit::setDate( QDate date,int *cpos,const int key ,const bool dateFormShort)
+{
+ QString dateForm = dateFormShort ?
+ KGlobal::locale()->dateFormatShort() :
+ KGlobal::locale()->dateFormat();
+
+ int begin = dateForm.find("%");
+ int space = 0;
+ int allStrLength = 0;
+ int strLength = 0;
+ int repeat = 0;
+
+ // witch? Day, Month or Year switch?
+ while(1){
+ switch ( dateForm.at(begin + 1).latin1() )
+ {
+ case 'd':// 16 (month day)
+ strLength = 2; //Ok
+ break;
+ case 'm':// 01 (month)
+ strLength = 2; //Ok
+ break;
+ case 'a':// Mon (Weekday)
+ strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length();
+ break;
+ case 'A':// Monday (Weekday)
+ strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length();
+ break;
+ case 'b':// Jan (monthName)
+ strLength = KGlobal::locale()->monthName(date.month(), true).length();
+ break;
+ case 'B':// January (monthName)
+ strLength = KGlobal::locale()->monthName(date.month(), false).length();
+ break;
+ case 'y':// 04 (year short)
+ strLength = 2; //Ok
+ break;
+ case 'Y':// 2004 (year)
+ strLength = 4; //Ok
+ break;
+ default:
+ break;
+ }
+ space = begin - (repeat++ * 2);
+ // all select? then dayswitch
+ if( (mDateEdit->text().length() == mDateEdit->markedText().length() ) &&
+ ( (dateForm.at(begin + 1).latin1() == 'd') ||
+ (dateForm.at(begin + 1).latin1() == 'a') ||
+ (dateForm.at(begin + 1).latin1() == 'A') ) ) {
+ break;
+ }
+ // mDateEdit-StringPos == CursorPosition(cpos) then break and set date
+ if( ( (space + allStrLength) <= *cpos && *cpos <= (space + allStrLength + strLength) ) || *cpos < begin ) {
+ break;
+ }
+ allStrLength += strLength;
+ begin = dateForm.find("%", begin +1);
+ }
+
+ // set date
+ switch ( dateForm.at(begin + 1).latin1() ) {
+ case 'd':
+ case 'a':
+ case 'A':
+ if(key == Key_Up) {
+ setDate( date.addDays( 1 ) );
+ }
+ else if(key == Key_Down) {
+ setDate( date.addDays( -1 ) );
+ }
+ maxDay = readDate().day();
+ break;
+ case 'm':
+ case 'b':
+ case 'B':
+ if(key == Key_Up) {
+ int year = ((date.month()+1)>12)?date.year()+1:date.year();
+ int month = ((date.month()+1)>12)?1:date.month()+1;
+ int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay;
+ setDate( QDate( year, month, day ) );
+ } else if(key == Key_Down) {
+ int year = ((date.month()-1)<1)?date.year()-1:date.year();
+ int month = ((date.month()-1)<1)?12:date.month()-1;
+ int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay;
+ setDate( QDate( year, month, day ) );
+ }
+ break;
+ case 'y':
+ case 'Y':
+ if(key == Key_Up) {
+ setDate( QDate( date.year() + 1, date.month() , date.day()) );
+ }
+ else if(key == Key_Down) {
+ setDate( QDate( date.year() - 1, date.month() , date.day()) );
+ }
+ break;
+/* default:
+ if(key == Key_Up) {
+ setDate( date.addDays( 1 ) );
+ } else if(key == Key_Down) {
+ setDate( date.addDays( -1 ) );
+ }
+ break;*/
+ }
+
+ date = readDate();
+ begin = dateForm.find("%");
+ int allSelectStrLength = 0;
+ int selectStrLength = 0;
+
+ // set selection do new date an set cursor at end of selection
+ for(int i = 0; i < repeat; i++){
+ switch ( dateForm.at(begin + 1).latin1() )
+ {
+ case 'd':// 16 (month day)
+ selectStrLength = 2; //Ok
+ break;
+ case 'm':// 01 (month)
+ selectStrLength = 2; //Ok
+ break;
+ case 'a':// Mon (Weekday short)
+ selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length();
+ break;
+ case 'A':// Monday (Weekday)
+ selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length();
+ break;
+ case 'b':// Jan (monthName short)
+ selectStrLength = KGlobal::locale()->monthName(date.month(), true).length();
+ break;
+ case 'B':// January (monthName)
+ selectStrLength = KGlobal::locale()->monthName(date.month(), false).length();
+ break;
+ case 'y':// 04 (year short)
+ selectStrLength = 2; //Ok
+ break;
+ case 'Y':// 2004 (year)
+ selectStrLength = 4; //Ok
+ break;
+ default:
+ break;
+ }
+ space = begin - (i * 2);
+ allSelectStrLength += selectStrLength;
+ begin = dateForm.find("%", begin +1);
+ }
+ // set selection from begin of date
+ setSelect( space + allSelectStrLength - selectStrLength , selectStrLength);
+ *cpos = space + allSelectStrLength;
+ emit(dateChanged(date));
+
+ return;
+}
+
+void KDateEdit::setHandleInvalid(bool handleInvalid)
+{
+ mHandleInvalid = handleInvalid;
+}
+
+void KDateEdit::setEnabled(bool on)
+{
+ mDateEdit->setEnabled(on);
+ mDateButton->setEnabled(on);
+}
+
+QDate KDateEdit::date() const
+{
+ QDate date = readDate();
+
+ if (date.isValid() || mHandleInvalid) {
+ return date;
+ } else {
+ KNotifyClient::beep();
+ return QDate::currentDate();
+ }
+}
+
+void KDateEdit::keyPressEvent(QKeyEvent *e)
+{
+ QDate date = readDate();
+ int cpos = mDateEdit->cursorPosition();
+
+ switch(e->key())
+ {
+ case Key_Escape:
+ mDateEdit->deselect();
+ case Key_Tab:
+ QHBox::keyPressEvent(e);
+ break;
+ case Key_Up:
+ // when date invalid then set to currend and return
+ if(!date.isValid()) {
+ date = QDate::currentDate();
+ setDate(date);
+ mDateEdit->setCursorPosition(cpos);
+ emit(dateChanged(date));
+ QString text = i18n( "You entered an invalid date!\n Date changed to current date." );
+ KMessageBox::information( 0, text );
+ return;
+ }
+ setDate(date, &cpos, Key_Up, dateFormShort);
+ break;
+ case Key_Down:
+ // when date invalid then set to current and return
+ if(!date.isValid()) {
+ date = QDate::currentDate();
+ setDate(date);
+ mDateEdit->setCursorPosition(cpos);
+ emit(dateChanged(date));
+ QString text = i18n( "You entered an invalid date!\n Date changed to current date." );
+ KMessageBox::information( 0, text );
+ return;
+ }
+ setDate(date, &cpos, Key_Down, dateFormShort);
+ break;
+ default:
+ QHBox::keyPressEvent(e);
+ break;
+ } // switch
+ mDateEdit->setCursorPosition(cpos);
+}
+
+void KDateEdit::setSelect( int from, int to )
+{
+// return;
+ mDateEdit->setSelection( from , to );
+}
+
+void KDateEdit::toggleDatePicker()
+{
+ if( mDateFrame->isVisible() ) {
+ mDateFrame->hide();
+ } else {
+ QPoint tmpPoint = mapToGlobal(mDateButton->geometry().bottomRight());
+ QSize datepickersize = mDatePicker->sizeHint();
+
+ if ( tmpPoint.x() < 7+datepickersize.width() ) tmpPoint.setX( 7+datepickersize.width() );
+
+ int h = QApplication::desktop()->height();
+
+ if ( tmpPoint.y() + datepickersize.height() > h ) tmpPoint.setY( h - datepickersize.height() );
+
+ mDateFrame->setGeometry(tmpPoint.x()-datepickersize.width()-7, tmpPoint.y(),
+ datepickersize.width()+2*mDateFrame->lineWidth(), datepickersize.height()+2*mDateFrame->lineWidth());
+
+ QDate date = readDate();
+ if(date.isValid()) {
+ mDatePicker->setDate(date);
+ } else {
+ mDatePicker->setDate(QDate::currentDate());
+ }
+ mDateFrame->show();
+ }
+}
+
+
+void KDateEdit::lineEnterPressed()
+{
+ QDate date = readDate();
+
+ if(date.isValid())
+ {
+ // Update the edit. This is needed if the user has entered a
+ // word rather than the actual date.
+ setDate(date);
+ emit(dateChanged(date));
+ emit returnPressed();
+ }
+ else
+ {
+ if ( withoutDp ) {
+ KNotifyClient::beep();
+ } else {
+ if ( !mDateEdit->text().isEmpty() ) {
+ mTextChanged = false;
+ QString text = i18n( "You entered an invalid date!\n Will use current date instead." );
+ if ( KMessageBox::warningContinueCancel( 0, text ) == KMessageBox::Continue ) {
+ setDate( QDate::currentDate() );
+ emit dateChanged( QDate::currentDate() );
+ }
+ }
+ }
+ }
+}
+
+bool KDateEdit::inputIsValid()
+{
+ return readDate().isValid();
+}
+
+QDate KDateEdit::readDate() const
+{
+ QString text = mDateEdit->text();
+ QDate date;
+
+ if (mKeywordMap.contains(text.lower()))
+ {
+ date = QDate::currentDate().addDays(mKeywordMap[text.lower()]);
+ }
+ else
+ {
+ date = KGlobal::locale()->readDate(text);
+ }
+
+ return date;
+}
+
+bool KDateEdit::eventFilter(QObject *, QEvent *e)
+{
+ // We only process the focus out event if the text has changed
+ // since we got focus
+ if ((e->type() == QEvent::FocusOut) && mTextChanged)
+ {
+ lineEnterPressed();
+ mTextChanged = false;
+ }
+ // switch dateFormShort by double klick with mouse
+ else if (e->type() == QEvent::MouseButtonDblClick)
+ {
+ dateFormShort = dateFormShort?false:true;
+ mDateEdit->setText(KGlobal::locale()->formatDate(readDate(),dateFormShort));
+ }
+ else if (e->type() == QEvent::FocusIn)
+ {
+ maxDay = readDate().day();
+ }
+
+ return false;
+}
+
+void KDateEdit::textChanged(const QString &)
+{
+ if(mHandleInvalid && mDateEdit->text().stripWhiteSpace().isEmpty()) {
+ QDate date; //invalid date
+ emit(dateChanged(date));
+ } else {
+ mTextChanged = true;
+ }
+ maxDay = readDate().day();
+}
diff --git a/libkdepim/kdateedit.h b/libkdepim/kdateedit.h
new file mode 100644
index 0000000..742d843
--- a/dev/null
+++ b/libkdepim/kdateedit.h
@@ -0,0 +1,140 @@
+/*
+ This file is part of libkdepim.
+
+ Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+#ifndef KDATEEDIT_H
+#define KDATEEDIT_H
+
+#include <qhbox.h>
+#include <qvbox.h>
+#include <qdatetime.h>
+#include <qmap.h>
+
+class QLineEdit;
+class QPushButton;
+class QObject;
+class QEvent;
+class KDatePicker;
+class KDateValidator;
+
+/**
+* A date editing widget that consists of a line edit followed by
+* a small push button. The line edit contains the date in text form,
+* and the push button will display a 'popup' style date picker.
+*
+* This widget also supports advanced features like allowing the user
+* to type in the day name to get the date. The following keywords
+* are supported (in the native language): tomorrow, yesturday, today,
+* monday, tuesday, wednesday, thursday, friday, saturday, sunday.
+*
+* @author Cornelius Schumacher <schumacher@kde.org>
+* @author Mike Pilone <mpilone@slac.com>
+*/
+class KDateEdit : public QHBox
+{
+ Q_OBJECT
+ public:
+ KDateEdit(QWidget *parent=0, const char *name=0, bool withoutDP = false );
+ virtual ~KDateEdit();
+
+ /** @return True if the date in the text edit is valid,
+ * false otherwise. This will not modify the display of the date,
+ * but only check for validity.
+ */
+ bool inputIsValid();
+
+ /** @return The date entered. This will not
+ * modify the display of the date, but only return it.
+ */
+ QDate date() const;
+
+ /** @param handleInvalid If true the date edit accepts invalid dates
+ * and displays them as the empty ("") string. It also returns an invalid date.
+ * If false (default) invalid dates are not accepted and instead the date
+ * of today will be returned.
+ */
+ void setHandleInvalid(bool handleInvalid);
+
+ /** Checks for a focus out event. The display of the date is updated
+ * to display the proper date when the focus leaves.
+ */
+ virtual bool eventFilter(QObject *o, QEvent *e);
+
+ signals:
+ /** This signal is emitted whenever the user modifies the date. This
+ * may not get emitted until the user presses enter in the line edit or
+ * focus leaves the widget (ie: the user confirms their selection).
+ */
+ void dateChanged(QDate);
+ void returnPressed();
+ public slots:
+ /** Sets the date.
+ *
+ * @param date The new date to display. This date must be valid or
+ * it will not be displayed.
+ */
+ void setDate(QDate date);
+ // set Date with key_up key_down to relation of cursor Position
+ // and set selection from begin to end of single date
+ void setDate(QDate, int *cpos, const int, const bool);
+
+ /** Sets the date edit to be enabled or disabled (grayed out)
+ *
+ * @param on Enabled if true, disabled if false
+ */
+ void setEnabled(bool on);
+
+ protected slots:
+ void toggleDatePicker();
+ void lineEnterPressed();
+ void textChanged(const QString &);
+
+ private:
+ /** Reads the text from the line edit. If the text is a keyword, the
+ * word will be translated to a date. If the text is not a keyword, the
+ * text will be interpreted as a date.
+ */
+ QDate readDate() const;
+
+ /** Maps the text that the user can enter to the offset in days from
+ * today. For example, the text 'tomorrow' is mapped to +1.
+ */
+ QMap<QString, int> mKeywordMap;
+ bool mTextChanged;
+ bool mHandleInvalid;
+
+ QPushButton *mDateButton;
+ QLineEdit *mDateEdit;
+ KDatePicker *mDatePicker;
+ QVBox *mDateFrame;
+ int maxDay;
+ bool withoutDp;
+
+ protected:
+ virtual void keyPressEvent(QKeyEvent *qke);
+ void setSelect ( int, int );
+ bool dateFormShort;
+ char lengthMonthName;
+
+};
+
+#endif
diff --git a/libkdepim/kdateedit.moc b/libkdepim/kdateedit.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/libkdepim/kdateedit.moc
diff --git a/libkdepim/kdatepicker.cpp b/libkdepim/kdatepicker.cpp
new file mode 100644
index 0000000..6e5ec0f
--- a/dev/null
+++ b/libkdepim/kdatepicker.cpp
@@ -0,0 +1,472 @@
+/* -*- C++ -*-
+ This file is part of the KDE libraries
+ Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
+ (C) 1998-2001 Mirko Boehm (mirko@kde.org)
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "kdatepicker.h"
+#include <kglobal.h>
+#include <kapplication.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <qframe.h>
+#include <qpainter.h>
+#include <qdialog.h>
+#include <qtoolbutton.h>
+#include <qfont.h>
+#include <qapplication.h>
+#include <qlineedit.h>
+#include <qvalidator.h>
+#include <kdebug.h>
+#include <knotifyclient.h>
+#include "kdatetbl.h"
+#include "kdateedit.h"
+#include "kdatepicker.moc"
+
+
+KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name)
+ : QFrame(parent,name),
+ yearForward(new QToolButton(this)),
+ yearBackward(new QToolButton(this)),
+ monthForward(new QToolButton(this)),
+ monthBackward(new QToolButton(this)),
+ selectMonth(new QToolButton(this)),
+ selectYear(new QToolButton(this)),
+ //line(new QLineEdit(this)),
+ val(new KDateValidator(this))
+ //table(new KDateTable(this)),
+ //fontsize(1)
+{
+ // -----
+ int size = 12;
+ if ( QApplication::desktop()->width() >= 480 )
+ size = 18;
+ fontsize = size;
+ setFont ( QFont("helvetica",size) );
+ table = new KDateTable(this);
+ setFontSize(size);
+ //line->setValidator(val);
+ lineDate = new KDateEdit( this, "dateediipicker", true );
+ yearForward->setPixmap(SmallIcon("2rightarrowB"));
+ yearBackward->setPixmap(SmallIcon("2leftarrowB"));
+ monthForward->setPixmap(SmallIcon("1rightarrowB"));
+ monthBackward->setPixmap(SmallIcon("1leftarrowB"));
+
+ setDate(dt); // set button texts
+ connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate)));
+ connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot()));
+ connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked()));
+ connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked()));
+ connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked()));
+ connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked()));
+ connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked()));
+ connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked()));
+ //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
+ connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate)));
+ connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
+ table->setFocus();
+
+}
+
+KDatePicker::~KDatePicker()
+{
+}
+
+void
+KDatePicker::resizeEvent(QResizeEvent*)
+{
+ QWidget *buttons[] = {
+ yearBackward,
+ monthBackward,
+ selectMonth,
+ selectYear,
+ monthForward,
+ yearForward };
+ const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]);
+ QSize sizes[NoOfButtons];
+ int buttonHeight=0;
+ int count;
+ int w;
+ int x=0;
+ // ----- calculate button row height:
+ for(count=0; count<NoOfButtons; ++count) {
+ int xS = buttons[count]->sizeHint().width();
+ int yS = buttons[count]->sizeHint().height();
+ sizes[count]=QSize ( xS+10, yS );
+ buttonHeight=QMAX(buttonHeight, sizes[count].height());
+ }
+ buttonHeight += 10;
+ // ----- calculate size of the month button:
+ w=0;
+ for(count=0; count<NoOfButtons; ++count) {
+ if(buttons[count]!=selectMonth)
+ {
+ w+=sizes[count].width();
+ } else {
+ x=count;
+ }
+ }
+ sizes[x].setWidth(width()-w); // stretch the month button
+ // ----- place the buttons:
+ x=0;
+ for(count=0; count<NoOfButtons; ++count)
+ {
+ w=sizes[count].width();
+ buttons[count]->setGeometry(x, 0, w, buttonHeight);
+ x+=w;
+ }
+ // ----- place the line edit for direct input:
+ sizes[0]=lineDate->sizeHint();
+ //line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height());
+ lineDate->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height());
+ // ----- adjust the table:
+ table->setGeometry(0, buttonHeight, width(),
+ height()-buttonHeight-sizes[0].height());
+}
+
+void
+KDatePicker::dateChangedSlot(QDate date)
+{
+ lineDate->setDate( date );//(KGlobal::locale()->formatDate(date, true));
+ //line->setText(KGlobal::locale()->formatDate(date, true));
+ emit(dateChanged(date));
+}
+
+void
+KDatePicker::tableClickedSlot()
+{
+
+ emit(dateSelected(table->getDate()));
+ emit(tableClicked());
+}
+
+const QDate&
+KDatePicker::getDate() const
+{
+ return table->getDate();
+}
+
+const QDate &
+KDatePicker::date() const
+{
+ return table->getDate();
+}
+
+void KDatePicker::slotSetDate( QDate date )
+{
+
+ if(date.isValid()) {
+ QString temp;
+ // -----
+ table->setDate(date);
+ selectMonth->setText(KGlobal::locale()->monthName(date.month(), false));
+ temp.setNum(date.year());
+ selectYear->setText(temp);
+ //line->setText(KGlobal::locale()->formatDate(date, true));
+ lineDate->setDate( date );
+ }
+
+}
+bool
+KDatePicker::setDate(const QDate& date)
+{
+ table->setFocus();
+ if(date.isValid()) {
+ QString temp;
+ // -----
+ table->setDate(date);
+ selectMonth->setText(KGlobal::locale()->monthName(date.month(), false));
+ temp.setNum(date.year());
+ selectYear->setText(temp);
+ //line->setText(KGlobal::locale()->formatDate(date, true));
+ lineDate->setDate( date );
+ return true;
+ } else {
+
+ return false;
+ }
+
+
+}
+
+void
+KDatePicker::monthForwardClicked()
+{
+ QDate temp=table->getDate();
+ int day=temp.day();
+ // -----
+ if(temp.month()==12) {
+ temp.setYMD(temp.year()+1, 1, 1);
+ } else {
+ temp.setYMD(temp.year(), temp.month()+1, 1);
+ }
+ if(temp.daysInMonth()<day) {
+ temp.setYMD(temp.year(), temp.month(), temp.daysInMonth());
+ } else {
+ temp.setYMD(temp.year(), temp.month(), day);
+ }
+ // assert(temp.isValid());
+ setDate(temp);
+}
+
+void
+KDatePicker::monthBackwardClicked()
+{
+ QDate temp=table->getDate();
+ int day=temp.day();
+ // -----
+ if(temp.month()==1)
+ {
+ temp.setYMD(temp.year()-1, 12, 1);
+ } else {
+ temp.setYMD(temp.year(), temp.month()-1, 1);
+ }
+ if(temp.daysInMonth()<day)
+ {
+ temp.setYMD(temp.year(), temp.month(), temp.daysInMonth());
+ } else {
+ temp.setYMD(temp.year(), temp.month(), day);
+ }
+ // assert(temp.isValid());
+ setDate(temp);
+}
+
+void
+KDatePicker::yearForwardClicked()
+{
+ QDate temp=table->getDate();
+ int day=temp.day();
+ // -----
+ temp.setYMD(temp.year()+1, temp.month(), 1);
+ if(temp.daysInMonth()<day)
+ {
+ temp.setYMD(temp.year(), temp.month(), temp.daysInMonth());
+ } else {
+ temp.setYMD(temp.year(), temp.month(), day);
+ }
+ // assert(temp.isValid());
+ setDate(temp);
+}
+
+void
+KDatePicker::yearBackwardClicked()
+{
+ QDate temp=table->getDate();
+ int day=temp.day();
+ // -----
+ temp.setYMD(temp.year()-1, temp.month(), 1);
+ if(temp.daysInMonth()<day)
+ {
+ temp.setYMD(temp.year(), temp.month(), temp.daysInMonth());
+ } else {
+ temp.setYMD(temp.year(), temp.month(), day);
+ }
+ // assert(temp.isValid());
+ setDate(temp);
+}
+
+void
+KDatePicker::selectMonthClicked()
+{
+ int month;
+ KPopupFrame* popup = new KPopupFrame(this);
+ KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(fontsize, popup);
+ // -----
+ picker->resize(picker->sizeHint());
+ popup->setMainWidget(picker);
+ picker->setFocus();
+ connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
+ if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height()))))
+ {
+ QDate date;
+ int day;
+ // -----
+ month=picker->getResult();
+ date=table->getDate();
+ day=date.day();
+ // ----- construct a valid date in this month:
+ date.setYMD(date.year(), month, 1);
+ date.setYMD(date.year(), month, QMIN(day, date.daysInMonth()));
+ // ----- set this month
+ setDate(date);
+ } else {
+ KNotifyClient::beep();
+ }
+ delete popup;
+}
+
+void
+KDatePicker::selectYearClicked()
+{
+ int year;
+ KPopupFrame* popup = new KPopupFrame(this);
+ KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup);
+ // -----
+ picker->resize(picker->sizeHint());
+ popup->setMainWidget(picker);
+ connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
+ picker->setFocus();
+ if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height()))))
+ {
+ QDate date;
+ int day;
+ // -----
+ year=picker->getYear();
+ date=table->getDate();
+ day=date.day();
+ // ----- construct a valid date in this month:
+ date.setYMD(year, date.month(), 1);
+ date.setYMD(year, date.month(), QMIN(day, date.daysInMonth()));
+ // ----- set this month
+ setDate(date);
+ } else {
+ KNotifyClient::beep();
+ }
+ delete popup;
+}
+
+void
+KDatePicker::setEnabled(bool enable)
+{
+ QWidget *widgets[]= {
+ yearForward, yearBackward, monthForward, monthBackward,
+ selectMonth, selectYear,
+ lineDate, table };
+ const int Size=sizeof(widgets)/sizeof(widgets[0]);
+ int count;
+ // -----
+ for(count=0; count<Size; ++count)
+ {
+ widgets[count]->setEnabled(enable);
+ }
+}
+
+void
+KDatePicker::lineEnterPressed()
+{
+ QDate temp;
+ // -----
+ temp = lineDate->date();
+ //if(val->date(line->text(), temp)==QValidator::Acceptable)
+ //{
+ emit(dateEntered(temp));
+ setDate(temp);
+ // } else {
+// KNotifyClient::beep();
+// }
+}
+
+QSize
+KDatePicker::sizeHint() const
+{
+ QSize tableSize=table->sizeHint();
+ QWidget *buttons[]={
+ yearBackward,
+ monthBackward,
+ selectMonth,
+ selectYear,
+ monthForward,
+ yearForward };
+ const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]);
+ QSize sizes[NoOfButtons];
+ int cx=0, cy=0, count;
+ // ----- store the size hints:
+ for(count=0; count<NoOfButtons; ++count)
+ {
+ sizes[count]=buttons[count]->sizeHint();
+ if(buttons[count]==selectMonth)
+ {
+ cx+=maxMonthRect.width()+15;
+ } else {
+ cx+=sizes[count].width()+15;
+ }
+ cy=QMAX(sizes[count].height(), cy);
+ }
+ // ----- calculate width hint:
+ cx=QMAX(cx, tableSize.width()); // line edit ignored
+ if ( cx > QApplication::desktop()->width() -5 )
+ cx = QApplication::desktop()->width() -5;
+ // ----- calculate height hint:
+ cy+=tableSize.height()+lineDate->sizeHint().height();
+
+ return QSize(cx, cy);
+}
+
+void
+KDatePicker::setFontSize(int s)
+{
+ QWidget *buttons[]= {
+ // yearBackward,
+ // monthBackward,
+ selectMonth,
+ selectYear,
+ // monthForward,
+ // yearForward
+ };
+ const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]);
+ int count;
+ QFont font;
+ QRect r;
+ // -----
+ fontsize=s;
+ for(count=0; count<NoOfButtons; ++count)
+ {
+ font=buttons[count]->font();
+ font.setPointSize(s);
+ buttons[count]->setFont(font);
+ }
+ QFontMetrics metrics(selectMonth->fontMetrics());
+ for(int i=1; i <= 12; ++i)
+ { // maxMonthRect is used by sizeHint()
+ r=metrics.boundingRect(KGlobal::locale()->monthName(i, false));
+ maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width()));
+ maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height()));
+ }
+ table->setFontSize(s);
+}
+
+void KDatePicker::virtual_hook( int id, void* data )
+{ /*BASE::virtual_hook( id, data );*/ }
+
+void KDatePicker::keyPressEvent ( QKeyEvent * e )
+{
+ switch ( e->key() ) {
+ case Qt::Key_Right:
+ monthForwardClicked();
+ break;
+ case Qt::Key_Left:
+ monthBackwardClicked();
+ break;
+
+ case Qt::Key_Down:
+ yearForwardClicked();
+
+ break;
+
+ case Qt::Key_Up:
+ yearBackwardClicked();
+ break;
+
+ case Qt::Key_Return:
+ tableClickedSlot();
+ break;
+
+ default:
+ break;
+ }
+
+}
diff --git a/libkdepim/kdatepicker.h b/libkdepim/kdatepicker.h
new file mode 100644
index 0000000..6625357
--- a/dev/null
+++ b/libkdepim/kdatepicker.h
@@ -0,0 +1,181 @@
+/* -*- C++ -*-
+ This file is part of the KDE libraries
+ Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
+ (C) 1998-2001 Mirko Boehm (mirko@kde.org)
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+#ifndef MICROKDE_KDATEPICKER_H
+#define MICROKDE_KDATEPICKER_H
+#include <qdatetime.h>
+#include <qframe.h>
+#include <qevent.h>
+
+class QLineEdit;
+class QToolButton;
+class KDateValidator;
+class KDateTable;
+class KDateEdit;
+
+/**
+ * Provides a widget for calendar date input.
+ *
+ * Different from the
+ * previous versions, it now emits two types of signals, either
+ * @ref dateSelected() or @ref dateEntered() (see documentation for both
+ * signals).
+ *
+ * A line edit has been added in the newer versions to allow the user
+ * to select a date directly by entering numbers like 19990101
+ * or 990101.
+ *
+ * @image kdatepicker.png KDatePicker
+ *
+ * @version $Id$
+ * @author Tim Gilman, Mirko Boehm
+ *
+ * @short A date selection widget.
+ **/
+class KDatePicker: public QFrame
+{
+ Q_OBJECT
+public:
+ /** The usual constructor. The given date will be displayed
+ * initially.
+ **/
+ KDatePicker(QWidget *parent=0,
+ QDate=QDate::currentDate(),
+ const char *name=0);
+ /**
+ * The destructor.
+ **/
+ virtual ~KDatePicker();
+
+ /** The size hint for date pickers. The size hint recommends the
+ * minimum size of the widget so that all elements may be placed
+ * without clipping. This sometimes looks ugly, so when using the
+ * size hint, try adding 28 to each of the reported numbers of
+ * pixels.
+ **/
+ QSize sizeHint() const;
+
+ /**
+ * Sets the date.
+ *
+ * @returns @p false and does not change anything
+ * if the date given is invalid.
+ **/
+ bool setDate(const QDate&);
+
+ /**
+ * Returns the selected date.
+ * @deprecated
+ **/
+ const QDate& getDate() const;
+
+ /**
+ * @returns the selected date.
+ */
+ const QDate &date() const;
+
+ /**
+ * Enables or disables the widget.
+ **/
+ void setEnabled(bool);
+
+ /**
+ * Sets the font size of the widgets elements.
+ **/
+ void setFontSize(int);
+ /**
+ * Returns the font size of the widget elements.
+ */
+ int fontSize() const
+ { return fontsize; }
+protected:
+ /// the resize event
+ void resizeEvent(QResizeEvent*);
+ /// the year forward button
+ QToolButton *yearForward;
+ /// the year backward button
+ QToolButton *yearBackward;
+ /// the month forward button
+ QToolButton *monthForward;
+ /// the month backward button
+ QToolButton *monthBackward;
+ /// the button for selecting the month directly
+ QToolButton *selectMonth;
+ /// the button for selecting the year directly
+ QToolButton *selectYear;
+ /// the line edit to enter the date directly
+ //QLineEdit *line;
+ KDateEdit *lineDate;
+ /// the validator for the line edit:
+ KDateValidator *val;
+ /// the date table
+ KDateTable *table;
+ /// the size calculated during resize events
+ // QSize sizehint;
+ /// the widest month string in pixels:
+ QSize maxMonthRect;
+protected slots:
+ void dateChangedSlot(QDate);
+ void tableClickedSlot();
+ void monthForwardClicked();
+ void monthBackwardClicked();
+ void yearForwardClicked();
+ void yearBackwardClicked();
+ void selectMonthClicked();
+ void selectYearClicked();
+ void lineEnterPressed();
+ void slotSetDate(QDate);
+signals:
+ /** This signal is emitted each time the selected date is changed.
+ * Usually, this does not mean that the date has been entered,
+ * since the date also changes, for example, when another month is
+ * selected.
+ * @see dateSelected
+ */
+ void dateChanged(QDate);
+ /** This signal is emitted each time a day has been selected by
+ * clicking on the table (hitting a day in the current month). It
+ * has the same meaning as dateSelected() in older versions of
+ * KDatePicker.
+ */
+ void dateSelected(QDate);
+ /** This signal is emitted when enter is pressed and a VALID date
+ * has been entered before into the line edit. Connect to both
+ * dateEntered() and dateSelected() to receive all events where the
+ * user really enters a date.
+ */
+ void dateEntered(QDate);
+ /** This signal is emitted when the day has been selected by
+ * clicking on it in the table.
+ */
+ void tableClicked();
+
+private:
+ /// the font size for the widget
+ int fontsize;
+
+protected:
+ virtual void virtual_hook( int id, void* data );
+private:
+ class KDatePickerPrivate;
+ KDatePickerPrivate *d;
+ void keyPressEvent ( QKeyEvent * ) ;
+};
+
+#endif // KDATEPICKER_H
diff --git a/libkdepim/kdatepicker.moc b/libkdepim/kdatepicker.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/libkdepim/kdatepicker.moc
diff --git a/libkdepim/kdepim.pro.back b/libkdepim/kdepim.pro.back
new file mode 100644
index 0000000..4dfc301
--- a/dev/null
+++ b/libkdepim/kdepim.pro.back
@@ -0,0 +1,34 @@
+TEMPLATE = lib
+CONFIG = qt warn_on release
+TARGET = kdepim
+INCLUDEPATH += ../microkde ../qtcompat
+INCLUDEPATH += . ..
+LIBS += -lmicrokde
+OBJECTS_DIR = obj/$(PLATFORM)
+MOC_DIR = moc
+DESTDIR=$(QPEDIR)/lib
+
+INTERFACES = \
+
+HEADERS = \
+ categoryeditdialog.h \
+ categoryeditdialog_base.h \
+ categoryselectdialog.h \
+ categoryselectdialog_base.h \
+ kdateedit.h \
+ kinputdialog.h \
+ kpimprefs.h \
+ kprefs.h \
+ kprefsdialog.h \
+
+SOURCES = \
+ categoryeditdialog.cpp \
+ categoryeditdialog_base.cpp \
+ categoryselectdialog.cpp \
+ categoryselectdialog_base.cpp \
+ kdateedit.cpp \
+ kinputdialog.cpp \
+ kpimprefs.cpp \
+ kprefs.cpp \
+ kprefsdialog.cpp \
+
diff --git a/libkdepim/kincidenceformatter.cpp b/libkdepim/kincidenceformatter.cpp
new file mode 100644
index 0000000..4815519
--- a/dev/null
+++ b/libkdepim/kincidenceformatter.cpp
@@ -0,0 +1,326 @@
+#include "kincidenceformatter.h"
+#include <kstaticdeleter.h>
+#include <kglobal.h>
+#include <klocale.h>
+#ifndef KORG_NOKABC
+#include <kabc/stdaddressbook.h>
+#define size count
+#endif
+
+KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
+static KStaticDeleter<KIncidenceFormatter> insd;
+
+QString KIncidenceFormatter::getFormattedText( Incidence * inc )
+{
+// #ifndef QT_NO_INPUTDIALOG
+// return QInputDialog::getItem( caption, label, items, current, editable );
+// #else
+// return QString::null;
+// #endif
+ mText = "";
+ if ( inc->type() == "Event" )
+ setEvent((Event *) inc );
+ else if ( inc->type() == "Todo" )
+ setTodo((Todo *) inc );
+ return mText;
+}
+
+KIncidenceFormatter* KIncidenceFormatter::instance()
+{
+ if (!mInstance) {
+ mInstance = insd.setObject(new KIncidenceFormatter());
+ }
+ return mInstance;
+}
+KIncidenceFormatter::~KIncidenceFormatter()
+{
+ if (mInstance == this)
+ mInstance = insd.setObject(0);
+ //qDebug("KIncidenceFormatter::~KIncidenceFormatter ");
+}
+KIncidenceFormatter::KIncidenceFormatter()
+{
+ mColorMode = 0;
+}
+void KIncidenceFormatter::setEvent(Event *event)
+{
+ int mode = 0;
+ mCurrentIncidence = event;
+ bool shortDate = true;
+ if ( mode == 0 ) {
+ addTag("h3",event->summary());
+ }
+ else {
+ if ( mColorMode == 1 ) {
+ mText +="<font color=\"#00A000\">";
+ }
+ if ( mColorMode == 2 ) {
+ mText +="<font color=\"#C00000\">";
+ }
+ // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
+ if ( mode == 1 ) {
+ addTag("h2",i18n( "Local: " ) +event->summary());
+ } else {
+ addTag("h2",i18n( "Remote: " ) +event->summary());
+ }
+ addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
+ if ( mColorMode )
+ mText += "</font>";
+ }
+ if (event->cancelled ()) {
+ mText +="<font color=\"#B00000\">";
+ addTag("i",i18n("This event has been cancelled!"));
+ mText.append("<br>");
+ mText += "</font>";
+ }
+ if (!event->location().isEmpty()) {
+ addTag("b",i18n("Location: "));
+ mText.append(event->location()+"<br>");
+ }
+ if (event->doesFloat()) {
+ if (event->isMultiDay()) {
+ mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
+ .arg(event->dtStartDateStr(shortDate))
+ .arg(event->dtEndDateStr(shortDate)));
+ } else {
+ mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
+ }
+ } else {
+ if (event->isMultiDay()) {
+ mText.append(i18n("<p><b>From:</b> %1</p> ")
+ .arg(event->dtStartStr( shortDate)));
+ mText.append(i18n("<p><b>To:</b> %1</p>")
+ .arg(event->dtEndStr(shortDate)));
+ } else {
+ mText.append(i18n("<p><b>On:</b> %1</p> ")
+ .arg(event->dtStartDateStr( shortDate )));
+ mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
+ .arg(event->dtStartTimeStr())
+ .arg(event->dtEndTimeStr()));
+ }
+ }
+
+ if (event->recurrence()->doesRecur()) {
+
+ QString recurText = event->recurrence()->recurrenceText();
+ addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
+ bool last;
+ QDate start = QDate::currentDate();
+ QDate next;
+ next = event->recurrence()->getPreviousDate( start , &last );
+ if ( !last ) {
+ next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
+ addTag("p",i18n("Next recurrence is on: ")+ KGlobal::locale()->formatDate( next, shortDate ) );
+ //addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
+ } else {
+ addTag("p",i18n("<b>Last recurrence was on:</b>") );
+ addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
+ }
+ }
+
+
+ if (event->isAlarmEnabled()) {
+ Alarm *alarm =event->alarms().first() ;
+ QDateTime t = alarm->time();
+ int min = t.secsTo( event->dtStart() )/60;
+ QString s =i18n("(%1 min before)").arg( min );
+ addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
+ //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
+ //addTag("p",s);
+ }
+
+ addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
+ // mText.append(event->secrecyStr()+"<br>");
+ formatCategories(event);
+ if (!event->description().isEmpty()) {
+ addTag("p",i18n("<b>Details: </b>"));
+ addTag("p",event->description());
+ }
+
+
+ formatReadOnly(event);
+ formatAttendees(event);
+
+
+}
+
+void KIncidenceFormatter::setTodo(Todo *event )
+{
+ int mode = 0;
+ mCurrentIncidence = event;
+ bool shortDate = true;
+ if (mode == 0 )
+ addTag("h3",event->summary());
+ else {
+ if ( mColorMode == 1 ) {
+ mText +="<font color=\"#00A000\">";
+ }
+ if ( mColorMode == 2 ) {
+ mText +="<font color=\"#B00000\">";
+ }
+ if ( mode == 1 ) {
+ addTag("h2",i18n( "Local: " ) +event->summary());
+ } else {
+ addTag("h2",i18n( "Remote: " ) +event->summary());
+ }
+ addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
+ if ( mColorMode )
+ mText += "</font>";
+ }
+ if (event->cancelled ()) {
+ mText +="<font color=\"#B00000\">";
+ addTag("i",i18n("This todo has been cancelled!"));
+ mText.append("<br>");
+ mText += "</font>";
+ }
+
+ if (!event->location().isEmpty()) {
+ addTag("b",i18n("Location: "));
+ mText.append(event->location()+"<br>");
+ }
+ if (event->hasDueDate()) {
+ mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
+ }
+ mText.append(i18n("<p><b>Priority:</b> %2</p>")
+ .arg(QString::number(event->priority())));
+
+ mText.append(i18n("<p><i>%1 % completed</i></p>")
+ .arg(event->percentComplete()));
+ addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
+ formatCategories(event);
+ if (!event->description().isEmpty()) {
+ addTag("p",i18n("<b>Details: </b>"));
+ addTag("p",event->description());
+ }
+
+
+
+ formatReadOnly(event);
+ formatAttendees(event);
+
+}
+
+void KIncidenceFormatter::setJournal(Journal* )
+{
+
+}
+
+void KIncidenceFormatter::formatCategories(Incidence *event)
+{
+ if (!event->categoriesStr().isEmpty()) {
+ addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() );
+ //mText.append(event->categoriesStr());
+ }
+}
+void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
+{
+ int number=text.contains("\n");
+ QString str = "<" + tag + ">";
+ QString tmpText=text;
+ QString tmpStr=str;
+ if(number !=-1)
+ {
+ if (number > 0) {
+ int pos=0;
+ QString tmp;
+ for(int i=0;i<=number;i++) {
+ pos=tmpText.find("\n");
+ tmp=tmpText.left(pos);
+ tmpText=tmpText.right(tmpText.length()-pos-1);
+ tmpStr+=tmp+"<br>";
+ }
+ }
+ else tmpStr += tmpText;
+ tmpStr+="</" + tag + ">";
+ mText.append(tmpStr);
+ }
+ else
+ {
+ str += text + "</" + tag + ">";
+ mText.append(str);
+ }
+}
+
+void KIncidenceFormatter::formatAttendees(Incidence *event)
+{
+ QPtrList<Attendee> attendees = event->attendees();
+ if (attendees.count()) {
+ QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
+ addTag("h3",i18n("Organizer"));
+ mText.append("<ul><li>");
+#ifndef KORG_NOKABC
+
+ KABC::AddressBook *add_book = KABC::StdAddressBook::self();
+ KABC::Addressee::List addressList;
+ addressList = add_book->findByEmail(event->organizer());
+ KABC::Addressee o = addressList.first();
+ if (!o.isEmpty() && addressList.size()<2) {
+ mText += "<a href=\"uid:" + o.uid() + "\">";
+ mText += o.formattedName();
+ mText += "</a>\n";
+ } else {
+ mText.append(event->organizer());
+ }
+#else
+ mText.append(event->organizer());
+#endif
+ if (iconPath) {
+ mText += " <a href=\"mailto:" + event->organizer() + "\">";
+ mText += "<IMG src=\"" + iconPath + "\">";
+ mText += "</a>\n";
+ }
+ mText.append("</li></ul>");
+
+ addTag("h3",i18n("Attendees"));
+ Attendee *a;
+ mText.append("<ul>");
+ for(a=attendees.first();a;a=attendees.next()) {
+#ifndef KORG_NOKABC
+ if (a->name().isEmpty()) {
+ addressList = add_book->findByEmail(a->email());
+ KABC::Addressee o = addressList.first();
+ if (!o.isEmpty() && addressList.size()<2) {
+ mText += "<a href=\"uid:" + o.uid() + "\">";
+ mText += o.formattedName();
+ mText += "</a>\n";
+ } else {
+ mText += "<li>";
+ mText.append(a->email());
+ mText += "\n";
+ }
+ } else {
+ mText += "<li><a href=\"uid:" + a->uid() + "\">";
+ if (!a->name().isEmpty()) mText += a->name();
+ else mText += a->email();
+ mText += "</a>\n";
+ }
+#else
+ //qDebug("nokabc ");
+ mText += "<li><a href=\"uid:" + a->uid() + "\">";
+ if (!a->name().isEmpty()) mText += a->name();
+ else mText += a->email();
+ mText += "</a>\n";
+#endif
+
+ if (!a->email().isEmpty()) {
+ if (iconPath) {
+ mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
+ mText += "<IMG src=\"" + iconPath + "\">";
+ mText += "</a>\n";
+ }
+ }
+ if (a->status() != Attendee::NeedsAction )
+ mText +="[" + a->statusStr() + "] ";
+ if (a->role() == Attendee::Chair )
+ mText +="(" + a->roleStr().left(1) + ".)";
+ }
+ mText.append("</li></ul>");
+ }
+}
+
+void KIncidenceFormatter::formatReadOnly(Incidence *event)
+{
+ if (event->isReadOnly()) {
+ addTag("p","<em>(" + i18n("read-only") + ")</em>");
+ }
+}
diff --git a/libkdepim/kincidenceformatter.h b/libkdepim/kincidenceformatter.h
new file mode 100644
index 0000000..8fe259a
--- a/dev/null
+++ b/libkdepim/kincidenceformatter.h
@@ -0,0 +1,42 @@
+#ifndef KINCIDENCENFORMATTER_H
+#define KINCIDENCENFORMATTER_H
+
+#include <qstring.h>
+#include <qobject.h>
+
+#include "libkcal/incidence.h"
+#include "libkcal/event.h"
+#include "libkcal/todo.h"
+#include "libkcal/journal.h"
+
+using namespace KCal;
+
+class KIncidenceFormatter : public QObject
+{
+ public:
+ static KIncidenceFormatter* instance();
+ KIncidenceFormatter();
+ ~KIncidenceFormatter();
+ QString getFormattedText( Incidence * inc );
+
+ void setEvent(Event *event);
+ void setTodo(Todo *event );
+ void setJournal(Journal* );
+
+ protected:
+ int mColorMode;
+ void addTag(const QString & tag,const QString & text);
+
+ void formatCategories(Incidence *event);
+ void formatAttendees(Incidence *event);
+ void formatReadOnly(Incidence *event);
+
+ private:
+ bool mSyncMode;
+
+ QString mText;
+ Incidence* mCurrentIncidence;
+ static KIncidenceFormatter* mInstance;
+};
+
+#endif
diff --git a/libkdepim/kinputdialog.cpp b/libkdepim/kinputdialog.cpp
new file mode 100644
index 0000000..0c31ca9
--- a/dev/null
+++ b/libkdepim/kinputdialog.cpp
@@ -0,0 +1,14 @@
+#include "kinputdialog.h"
+
+#include <qinputdialog.h>
+
+QString KInputDialog::getItem( const QString &caption, const QString &label,
+ const QStringList &items, int current,
+ bool editable )
+{
+#ifndef QT_NO_INPUTDIALOG
+ return QInputDialog::getItem( caption, label, items, current, editable );
+#else
+ return QString::null;
+#endif
+}
diff --git a/libkdepim/kinputdialog.h b/libkdepim/kinputdialog.h
new file mode 100644
index 0000000..0072391
--- a/dev/null
+++ b/libkdepim/kinputdialog.h
@@ -0,0 +1,15 @@
+#ifndef KINPUTDIALOG_H
+#define KINPUTDIALOG_H
+
+#include <qstring.h>
+#include <qstringlist.h>
+
+class KInputDialog
+{
+ public:
+ static QString getItem( const QString &caption, const QString &label,
+ const QStringList &items, int current,
+ bool editable );
+};
+
+#endif
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp
new file mode 100644
index 0000000..ce4c540
--- a/dev/null
+++ b/libkdepim/kpimprefs.cpp
@@ -0,0 +1,59 @@
+/*
+ This file is part of libkdepim.
+ Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <kglobal.h>
+#include <kconfig.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+#include "kpimprefs.h"
+
+KPimPrefs::KPimPrefs( const QString &name ) :
+ KPrefs( name )
+{
+}
+
+KPimPrefs::~KPimPrefs()
+{
+}
+
+void KPimPrefs::usrSetDefaults()
+{
+ setCategoryDefaults();
+}
+
+void KPimPrefs::usrReadConfig()
+{
+ kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl;
+
+ config()->setGroup("General");
+ mCustomCategories = config()->readListEntry("Custom Categories");
+ if (mCustomCategories.isEmpty()) setCategoryDefaults();
+}
+
+
+void KPimPrefs::usrWriteConfig()
+{
+ config()->setGroup("General");
+ config()->writeEntry("Custom Categories",mCustomCategories);
+}
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
new file mode 100644
index 0000000..05a564c
--- a/dev/null
+++ b/libkdepim/kpimprefs.h
@@ -0,0 +1,53 @@
+/*
+ This file is part of libkdepim.
+ Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+#ifndef KPIMPREFS_H
+#define KPIMPREFS_H
+
+#include <qstringlist.h>
+
+#include "kprefs.h"
+
+class KPimPrefs : public KPrefs
+{
+ public:
+ KPimPrefs( const QString &name = QString::null );
+
+ virtual ~KPimPrefs();
+
+ /** Set preferences to default values */
+ void usrSetDefaults();
+
+ /** Read preferences from config file */
+ void usrReadConfig();
+
+ /** Write preferences to config file */
+ void usrWriteConfig();
+
+ public:
+ QStringList mCustomCategories;
+
+ protected:
+ virtual void setCategoryDefaults() = 0;
+};
+
+#endif
diff --git a/libkdepim/kprefs.cpp b/libkdepim/kprefs.cpp
new file mode 100644
index 0000000..f5e5e5a
--- a/dev/null
+++ b/libkdepim/kprefs.cpp
@@ -0,0 +1,463 @@
+/*
+ This file is part of KOrganizer.
+ Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+// $Id$
+
+#include <qcolor.h>
+
+#include <kconfig.h>
+#include <kstandarddirs.h>
+#include <kglobal.h>
+#include <kdebug.h>
+
+#include "kprefs.h"
+
+class KPrefsItemBool : public KPrefsItem {
+ public:
+ KPrefsItemBool(const QString &group,const QString &name,bool *,bool defaultValue=true);
+ virtual ~KPrefsItemBool() {}
+
+ void setDefault();
+ void readConfig(KConfig *);
+ void writeConfig(KConfig *);
+
+ private:
+ bool *mReference;
+ bool mDefault;
+};
+
+class KPrefsItemInt : public KPrefsItem {
+ public:
+ KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0);
+ virtual ~KPrefsItemInt() {}
+
+ void setDefault();
+ void readConfig(KConfig *);
+ void writeConfig(KConfig *);
+
+ private:
+ int *mReference;
+ int mDefault;
+};
+
+
+class KPrefsItemColor : public KPrefsItem {
+ public:
+ KPrefsItemColor(const QString &group,const QString &name,QColor *,
+ const QColor &defaultValue=QColor(128,128,128));
+ virtual ~KPrefsItemColor() {}
+
+ void setDefault();
+ void readConfig(KConfig *);
+ void writeConfig(KConfig *);
+
+ private:
+ QColor *mReference;
+ QColor mDefault;
+};
+
+
+class KPrefsItemFont : public KPrefsItem {
+ public:
+ KPrefsItemFont(const QString &group,const QString &name,QFont *,
+ const QFont &defaultValue=QFont("helvetica",12));
+ virtual ~KPrefsItemFont() {}
+
+ void setDefault();
+ void readConfig(KConfig *);
+ void writeConfig(KConfig *);
+
+ private:
+ QFont *mReference;
+ QFont mDefault;
+};
+
+
+class KPrefsItemString : public KPrefsItem {
+ public:
+ KPrefsItemString(const QString &group,const QString &name,QString *,
+ const QString &defaultValue="", bool isPassword=false);
+ virtual ~KPrefsItemString() {}
+
+ void setDefault();
+ void readConfig(KConfig *);
+ void writeConfig(KConfig *);
+
+ private:
+ QString *mReference;
+ QString mDefault;
+ bool mPassword;
+};
+
+
+class KPrefsItemStringList : public KPrefsItem {
+ public:
+ KPrefsItemStringList(const QString &group,const QString &name,QStringList *,
+ const QStringList &defaultValue=QStringList());
+ virtual ~KPrefsItemStringList() {}
+
+ void setDefault();
+ void readConfig(KConfig *);
+ void writeConfig(KConfig *);
+
+ private:
+ QStringList *mReference;
+ QStringList mDefault;
+};
+
+
+class KPrefsItemIntList : public KPrefsItem {
+ public:
+ KPrefsItemIntList(const QString &group,const QString &name,QValueList<int> *,
+ const QValueList<int> &defaultValue=QValueList<int>());
+ virtual ~KPrefsItemIntList() {}
+
+ void setDefault();
+ void readConfig(KConfig *);
+ void writeConfig(KConfig *);
+
+ private:
+ QValueList<int> *mReference;
+ QValueList<int> mDefault;
+};
+
+
+KPrefsItemBool::KPrefsItemBool(const QString &group,const QString &name,
+ bool *reference,bool defaultValue) :
+ KPrefsItem(group,name)
+{
+ mReference = reference;
+ mDefault = defaultValue;
+}
+
+void KPrefsItemBool::setDefault()
+{
+ *mReference = mDefault;
+}
+
+void KPrefsItemBool::writeConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ config->writeEntry(mName,*mReference);
+}
+
+
+void KPrefsItemBool::readConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ *mReference = config->readBoolEntry(mName,mDefault);
+}
+
+
+KPrefsItemInt::KPrefsItemInt(const QString &group,const QString &name,
+ int *reference,int defaultValue) :
+ KPrefsItem(group,name)
+{
+ mReference = reference;
+ mDefault = defaultValue;
+}
+
+void KPrefsItemInt::setDefault()
+{
+ *mReference = mDefault;
+}
+
+void KPrefsItemInt::writeConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ config->writeEntry(mName,*mReference);
+}
+
+void KPrefsItemInt::readConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ *mReference = config->readNumEntry(mName,mDefault);
+}
+
+
+KPrefsItemColor::KPrefsItemColor(const QString &group,const QString &name,
+ QColor *reference,const QColor &defaultValue) :
+ KPrefsItem(group,name)
+{
+ mReference = reference;
+ mDefault = defaultValue;
+}
+
+void KPrefsItemColor::setDefault()
+{
+ *mReference = mDefault;
+}
+
+void KPrefsItemColor::writeConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ config->writeEntry(mName,*mReference);
+}
+
+void KPrefsItemColor::readConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ *mReference = config->readColorEntry(mName,&mDefault);
+
+}
+
+
+KPrefsItemFont::KPrefsItemFont(const QString &group,const QString &name,
+ QFont *reference,const QFont &defaultValue) :
+ KPrefsItem(group,name)
+{
+ mReference = reference;
+ mDefault = defaultValue;
+}
+
+void KPrefsItemFont::setDefault()
+{
+ *mReference = mDefault;
+}
+
+void KPrefsItemFont::writeConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ config->writeEntry(mName,*mReference);
+}
+
+void KPrefsItemFont::readConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ *mReference = config->readFontEntry(mName,&mDefault);
+}
+
+
+QString endecryptStr( const QString &aStr )
+{
+ QString result;
+ uint i;
+ for ( i = 0; i < aStr.length(); i++)
+ result += (aStr.at(i).unicode() < 0x20) ?
+ aStr.at(i) :
+ QChar(0x1001F - aStr.at(i).unicode());
+ return result;
+}
+
+
+KPrefsItemString::KPrefsItemString(const QString &group,const QString &name,
+ QString *reference,const QString &defaultValue,
+ bool isPassword) :
+ KPrefsItem(group,name)
+{
+ mReference = reference;
+ mDefault = defaultValue;
+ mPassword = isPassword;
+}
+
+void KPrefsItemString::setDefault()
+{
+ *mReference = mDefault;
+}
+
+void KPrefsItemString::writeConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ if ( mPassword )
+ config->writeEntry(mName, endecryptStr( *mReference ) );
+ else
+ config->writeEntry(mName,*mReference);
+}
+
+void KPrefsItemString::readConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+
+ QString value;
+ if ( mPassword ) {
+ value = config->readEntry( mName, endecryptStr( mDefault ) );
+ *mReference = endecryptStr( value );
+ } else {
+ *mReference = config->readEntry( mName, mDefault );
+ }
+}
+
+
+KPrefsItemStringList::KPrefsItemStringList(const QString &group,const QString &name,
+ QStringList *reference,const QStringList &defaultValue) :
+ KPrefsItem(group,name)
+{
+ mReference = reference;
+ mDefault = defaultValue;
+}
+
+void KPrefsItemStringList::setDefault()
+{
+ *mReference = mDefault;
+}
+
+void KPrefsItemStringList::writeConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ config->writeEntry(mName,*mReference);
+}
+
+void KPrefsItemStringList::readConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ *mReference = config->readListEntry(mName);
+}
+
+
+KPrefsItemIntList::KPrefsItemIntList(const QString &group,const QString &name,
+ QValueList<int> *reference,const QValueList<int> &defaultValue) :
+ KPrefsItem(group,name)
+{
+ mReference = reference;
+ mDefault = defaultValue;
+}
+
+void KPrefsItemIntList::setDefault()
+{
+ *mReference = mDefault;
+}
+
+void KPrefsItemIntList::writeConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ config->writeEntry(mName,*mReference);
+}
+
+void KPrefsItemIntList::readConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ *mReference = config->readIntListEntry(mName);
+}
+
+
+QString *KPrefs::mCurrentGroup = 0;
+
+KPrefs::KPrefs(const QString &configname)
+{
+ if (!configname.isEmpty()) {
+ //qDebug("KPrefs::KPrefs %s",configname.latin1() );
+ mConfig = new KConfig(locateLocal("config",configname));
+ } else {
+ mConfig = KGlobal::config();
+ }
+
+ mItems.setAutoDelete(true);
+
+ // Set default group
+ if (mCurrentGroup == 0) mCurrentGroup = new QString("No Group");
+}
+
+KPrefs::~KPrefs()
+{
+ if (mConfig != KGlobal::config()) {
+ delete mConfig;
+ }
+}
+
+void KPrefs::setCurrentGroup(const QString &group)
+{
+ if (mCurrentGroup) delete mCurrentGroup;
+ mCurrentGroup = new QString(group);
+}
+
+KConfig *KPrefs::config() const
+{
+ return mConfig;
+}
+
+void KPrefs::setDefaults()
+{
+ KPrefsItem *item;
+ for(item = mItems.first();item;item = mItems.next()) {
+ item->setDefault();
+ }
+
+ usrSetDefaults();
+}
+
+void KPrefs::readConfig()
+{
+ KPrefsItem *item;
+ for(item = mItems.first();item;item = mItems.next()) {
+ item->readConfig(mConfig);
+ }
+
+ usrReadConfig();
+}
+
+void KPrefs::writeConfig()
+{
+ KPrefsItem *item;
+ for(item = mItems.first();item;item = mItems.next()) {
+ item->writeConfig(mConfig);
+ }
+
+ usrWriteConfig();
+
+ mConfig->sync();
+}
+
+
+void KPrefs::addItem(KPrefsItem *item)
+{
+ mItems.append(item);
+}
+
+void KPrefs::addItemBool(const QString &key,bool *reference,bool defaultValue)
+{
+ addItem(new KPrefsItemBool(*mCurrentGroup,key,reference,defaultValue));
+}
+
+void KPrefs::addItemInt(const QString &key,int *reference,int defaultValue)
+{
+ addItem(new KPrefsItemInt(*mCurrentGroup,key,reference,defaultValue));
+}
+
+void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue)
+{
+ addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue));
+}
+
+void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue)
+{
+ addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue));
+}
+
+void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue)
+{
+ addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false));
+}
+
+void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue)
+{
+ addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true));
+}
+
+void KPrefs::addItemStringList(const QString &key,QStringList *reference,
+ const QStringList &defaultValue)
+{
+ addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue));
+}
+
+void KPrefs::addItemIntList(const QString &key,QValueList<int> *reference,
+ const QValueList<int> &defaultValue)
+{
+ addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue));
+}
diff --git a/libkdepim/kprefs.h b/libkdepim/kprefs.h
new file mode 100644
index 0000000..7014bb8
--- a/dev/null
+++ b/libkdepim/kprefs.h
@@ -0,0 +1,301 @@
+/*
+ This file is part of KOrganizer.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+#ifndef _KPREFS_H
+#define _KPREFS_H
+// $Id$
+
+#include <qptrlist.h>
+#include <qcolor.h>
+#include <qfont.h>
+#include <qstringlist.h>
+
+class KConfig;
+
+/**
+ @short Class for storing a preferences setting
+ @author Cornelius Schumacher
+ @see KPref
+
+ This class represents one preferences setting as used by @ref KPrefs.
+ Subclasses of KPrefsItem implement storage functions for a certain type of
+ setting. Normally you don't have to use this class directly. Use the special
+ addItem() functions of KPrefs instead. If you subclass this class you will
+ have to register instances with the function KPrefs::addItem().
+*/
+class KPrefsItem {
+ public:
+ /**
+ Constructor.
+
+ @param group Config file group.
+ @param name Config file key.
+ */
+ KPrefsItem(const QString &group,const QString &name) :
+ mGroup(group),mName(name) {}
+ /**
+ Destructor.
+ */
+ virtual ~KPrefsItem() {}
+
+ /**
+ This function is called by @ref KPrefs to set this setting to its default
+ value.
+ */
+ virtual void setDefault() = 0;
+ /**
+ This function is called by @ref KPrefs to read the value for this setting
+ from a config file.
+ value.
+ */
+ virtual void readConfig(KConfig *) = 0;
+ /**
+ This function is called by @ref KPrefs to write the value of this setting
+ to a config file.
+ */
+ virtual void writeConfig(KConfig *) = 0;
+
+ protected:
+ QString mGroup;
+ QString mName;
+};
+
+/**
+ @short Class for handling preferences settings for an application.
+ @author Cornelius Schumacher
+ @see KPrefsItem
+
+ This class provides an interface to preferences settings. Preferences items
+ can be registered by the addItem() function corresponding to the data type of
+ the seetting. KPrefs then handles reading and writing of config files and
+ setting of default values.
+
+ Normally you will subclass KPrefs, add data members for the preferences
+ settings and register the members in the constructor of the subclass.
+
+ Example:
+ <pre>
+ class MyPrefs : public KPrefs {
+ public:
+ MyPrefs()
+ {
+ setCurrentGroup("MyGroup");
+ addItemBool("MySetting1",&mMyBool,false);
+ addItemColor("MySetting2",&mMyColor,QColor(1,2,3));
+
+ setCurrentGroup("MyOtherGroup");
+ addItemFont("MySetting3",&mMyFont,QFont("helvetica",12));
+ }
+
+ bool mMyBool;
+ QColor mMyColor;
+ QFont mMyFont;
+ }
+ </pre>
+
+ It might be convenient in many cases to make this subclass of KPrefs a
+ singleton for global access from all over the application without passing
+ references to the KPrefs object around.
+
+ You can set all values to default values by calling @ref setDefaults(), write
+ the data to the configuration file by calling @ref writeConfig() and read the
+ data from the configuration file by calling @ref readConfig().
+
+ If you have items, which are not covered by the existing addItem() functions
+ you can add customized code for reading, writing and default setting by
+ implementing the functions @ref usrSetDefaults(), @ref usrReadConfig() and
+ @ref usrWriteConfig().
+
+ Internally preferences settings are stored in instances of subclasses of
+ @ref KPrefsItem. You can also add KPrefsItem subclasses for your own types
+ and call the generic @ref addItem() to register them.
+*/
+
+class KPrefs {
+ public:
+ /**
+ Constructor.
+
+ @param configname name of config file. If no name is given, the default
+ config file as returned by kapp()->config() is used.
+ */
+ KPrefs(const QString &configname=QString::null);
+ /**
+ Destructor
+ */
+ virtual ~KPrefs();
+
+ /**
+ Set preferences to default values. All registered items are set to their
+ default values.
+ */
+ void setDefaults();
+
+ /**
+ Read preferences from config file. All registered items are set to the
+ values read from disk.
+ */
+ void readConfig();
+
+ /**
+ Write preferences to config file. The values of all registered items are
+ written to disk.
+ */
+ void writeConfig();
+
+ /**
+ Set the config file group for subsequent addItem() calls. It is valid
+ until setCurrentGroup() is called with a new argument. Call this before
+ you add any items. The default value is "No Group".
+ */
+ static void setCurrentGroup(const QString &group);
+
+ /**
+ Register a custom @ref KPrefsItem.
+ */
+ void addItem(KPrefsItem *);
+
+ /**
+ Register an item of type bool.
+
+ @param key Key used in config file.
+ @param reference Pointer to the variable, which is set by readConfig()
+ and setDefaults() calls and read by writeConfig() calls.
+ @param defaultValue Default value, which is used by setDefaults() and
+ when the config file does not yet contain the key of
+ this item.
+ */
+ void addItemBool(const QString &key,bool *reference,
+ bool defaultValue=false);
+ /**
+ Register an item of type int.
+
+ @param key Key used in config file.
+ @param reference Pointer to the variable, which is set by readConfig()
+ and setDefaults() calls and read by writeConfig() calls.
+ @param defaultValue Default value, which is used by setDefaults() and
+ when the config file does not yet contain the key of
+ this item.
+ */
+ void addItemInt(const QString &key,int *reference,
+ int defaultValue=0);
+ /**
+ Register an item of type QColor.
+
+ @param key Key used in config file.
+ @param reference Pointer to the variable, which is set by readConfig()
+ and setDefaults() calls and read by writeConfig() calls.
+ @param defaultValue Default value, which is used by setDefaults() and
+ when the config file does not yet contain the key of
+ this item.
+ */
+ void addItemColor(const QString &key,QColor *reference,
+ const QColor &defaultValue=QColor(128,128,128));
+ /**
+ Register an item of type QFont.
+
+ @param key Key used in config file.
+ @param reference Pointer to the variable, which is set by readConfig()
+ and setDefaults() calls and read by writeConfig() calls.
+ @param defaultValue Default value, which is used by setDefaults() and
+ when the config file does not yet contain the key of
+ this item.
+ */
+ void addItemFont(const QString &key,QFont *reference,
+ const QFont &defaultValue=QFont("helvetica",12));
+ /**
+ Register an item of type QString.
+
+ @param key Key used in config file.
+ @param reference Pointer to the variable, which is set by readConfig()
+ and setDefaults() calls and read by writeConfig() calls.
+ @param defaultValue Default value, which is used by setDefaults() and
+ when the config file does not yet contain the key of
+ this item.
+ */
+ void addItemString(const QString &key,QString *reference,
+ const QString &defaultValue="");
+ /**
+ Register a password item of type QString. The string value is written
+ encrypted to the config file. Note that the current encryption scheme
+ is very weak.
+
+ @param key Key used in config file.
+ @param reference Pointer to the variable, which is set by readConfig()
+ and setDefaults() calls and read by writeConfig() calls.
+ @param defaultValue Default value, which is used by setDefaults() and
+ when the config file does not yet contain the key of
+ this item.
+ */
+ void addItemPassword(const QString &key,QString *reference,
+ const QString &defaultValue="");
+ /**
+ Register an item of type QStringList.
+
+ @param key Key used in config file.
+ @param reference Pointer to the variable, which is set by readConfig()
+ and setDefaults() calls and read by writeConfig() calls.
+ @param defaultValue Default value, which is used by setDefaults() and
+ when the config file does not yet contain the key of
+ this item.
+ */
+ void addItemStringList(const QString &key,QStringList *reference,
+ const QStringList &defaultValue=QStringList());
+
+ /**
+ Register an item of type QValueList<int>.
+
+ @param key Key used in config file.
+ @param reference Pointer to the variable, which is set by readConfig()
+ and setDefaults() calls and read by writeConfig() calls.
+ @param defaultValue Default value, which is used by setDefaults() and
+ when the config file does not yet contain the key of
+ this item.
+ */
+ void addItemIntList(const QString &key,QValueList<int> *reference,
+ const QValueList<int> &defaultValue=QValueList<int>());
+
+ protected:
+ /**
+ Implemented by subclasses that use special defaults.
+ */
+ virtual void usrSetDefaults() {};
+ /**
+ Implemented by subclasses that read special config values.
+ */
+ virtual void usrReadConfig() {};
+ /**
+ Implemented by subclasses that write special config values.
+ */
+ virtual void usrWriteConfig() {};
+
+ /**
+ Return the @ref KConfig object used for reading and writing the settings.
+ */
+ KConfig *config() const;
+
+ private:
+ static QString *mCurrentGroup;
+
+ KConfig *mConfig; // pointer to KConfig object
+
+ QPtrList<KPrefsItem> mItems;
+};
+
+#endif
diff --git a/libkdepim/kprefsdialog.cpp b/libkdepim/kprefsdialog.cpp
new file mode 100644
index 0000000..3a39ea9
--- a/dev/null
+++ b/libkdepim/kprefsdialog.cpp
@@ -0,0 +1,410 @@
+/*
+ This file is part of KOrganizer.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+// $Id$
+
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qgroupbox.h>
+#include <qbuttongroup.h>
+#include <qlineedit.h>
+#include <qfont.h>
+#include <qslider.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qvbox.h>
+#include <qhbox.h>
+#include <qspinbox.h>
+#include <qdatetime.h>
+#include <qframe.h>
+#include <qcombobox.h>
+#include <qcheckbox.h>
+#include <qradiobutton.h>
+#include <qpushbutton.h>
+#include <qapplication.h>
+
+#include <kcolorbutton.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kfontdialog.h>
+#include <kmessagebox.h>
+#include <kcolordialog.h>
+#include <kiconloader.h>
+
+#include "kprefs.h"
+
+#include "kprefsdialog.h"
+#include "kprefsdialog.moc"
+
+KPrefsWidBool::KPrefsWidBool(const QString &text,bool *reference,
+ QWidget *parent)
+{
+ mReference = reference;
+
+ mCheck = new QCheckBox(text,parent);
+}
+
+void KPrefsWidBool::readConfig()
+{
+ mCheck->setChecked(*mReference);
+}
+
+void KPrefsWidBool::writeConfig()
+{
+ *mReference = mCheck->isChecked();
+}
+
+QCheckBox *KPrefsWidBool::checkBox()
+{
+ return mCheck;
+}
+
+
+KPrefsWidColor::KPrefsWidColor(const QString &text,QColor *reference,
+ QWidget *parent)
+{
+ mReference = reference;
+
+ mButton = new KColorButton(parent);
+ mLabel = new QLabel(mButton, text, parent);
+ mButton->setColor( *mReference );
+ mButton->setColor( Qt::red );
+
+}
+
+KPrefsWidColor::~KPrefsWidColor()
+{
+// kdDebug(5300) << "KPrefsWidColor::~KPrefsWidColor()" << endl;
+}
+
+void KPrefsWidColor::readConfig()
+{
+ mButton->setColor(*mReference);
+}
+
+void KPrefsWidColor::writeConfig()
+{
+ *mReference = mButton->color();
+}
+
+QLabel *KPrefsWidColor::label()
+{
+ return mLabel;
+}
+
+KColorButton *KPrefsWidColor::button()
+{
+ return mButton;
+}
+
+KPrefsWidFont::KPrefsWidFont(const QString &sampleText,const QString &labelText,
+ QFont *reference,QWidget *parent)
+{
+ mReference = reference;
+
+ mLabel = new QLabel(labelText, parent);
+
+ mPreview = new QLabel(sampleText,parent);
+ mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken);
+
+ mButton = new QPushButton(i18n("Choose..."), parent);
+ connect(mButton,SIGNAL(clicked()),SLOT(selectFont()));
+ mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 );
+ mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 );
+}
+
+KPrefsWidFont::~KPrefsWidFont()
+{
+}
+
+void KPrefsWidFont::readConfig()
+{
+ mPreview->setFont(*mReference);
+}
+
+void KPrefsWidFont::writeConfig()
+{
+ *mReference = mPreview->font();
+}
+
+QLabel *KPrefsWidFont::label()
+{
+ return mLabel;
+}
+
+QLabel *KPrefsWidFont::preview()
+{
+ return mPreview;
+}
+
+QPushButton *KPrefsWidFont::button()
+{
+ return mButton;
+}
+
+void KPrefsWidFont::selectFont()
+{
+ QFont myFont(mPreview->font());
+ bool ok;
+ myFont = KFontDialog::getFont(myFont, ok);
+ if ( ok ) {
+ mPreview->setFont(myFont);
+ }
+}
+
+
+KPrefsWidTime::KPrefsWidTime(const QString &text,int *reference,
+ QWidget *parent)
+{
+ mReference = reference;
+
+ mLabel = new QLabel(text,parent);
+ mSpin = new QSpinBox(0,23,1,parent);
+ mSpin->setSuffix(":00");
+}
+
+void KPrefsWidTime::readConfig()
+{
+ mSpin->setValue(*mReference);
+}
+
+void KPrefsWidTime::writeConfig()
+{
+ *mReference = mSpin->value();
+}
+
+QLabel *KPrefsWidTime::label()
+{
+ return mLabel;
+}
+
+QSpinBox *KPrefsWidTime::spinBox()
+{
+ return mSpin;
+}
+
+
+KPrefsWidRadios::KPrefsWidRadios(const QString &text,int *reference,
+ QWidget *parent)
+{
+ mReference = reference;
+
+ mBox = new QButtonGroup(1,Qt::Horizontal,text,parent);
+}
+
+KPrefsWidRadios::~KPrefsWidRadios()
+{
+}
+
+void KPrefsWidRadios::addRadio(const QString &text)
+{
+ new QRadioButton(text,mBox);
+}
+
+QButtonGroup *KPrefsWidRadios::groupBox()
+{
+ return mBox;
+}
+
+void KPrefsWidRadios::readConfig()
+{
+ mBox->setButton(*mReference);
+}
+
+void KPrefsWidRadios::writeConfig()
+{
+ *mReference = mBox->id(mBox->selected());
+}
+
+
+KPrefsWidString::KPrefsWidString(const QString &text,QString *reference,
+ QWidget *parent, QLineEdit::EchoMode echomode)
+{
+ mReference = reference;
+
+ mLabel = new QLabel(text,parent);
+ mEdit = new QLineEdit(parent);
+ mEdit->setEchoMode( echomode );
+}
+
+KPrefsWidString::~KPrefsWidString()
+{
+}
+
+void KPrefsWidString::readConfig()
+{
+ mEdit->setText(*mReference);
+}
+
+void KPrefsWidString::writeConfig()
+{
+ *mReference = mEdit->text();
+}
+
+QLabel *KPrefsWidString::label()
+{
+ return mLabel;
+}
+
+QLineEdit *KPrefsWidString::lineEdit()
+{
+ return mEdit;
+}
+
+
+KPrefsDialog::KPrefsDialog(KPrefs *prefs,QWidget *parent,char *name,bool modal) :
+ KDialogBase(IconList,i18n("Preferences"),Ok|Cancel|Default,Ok,parent,
+ name,modal,true)
+{
+ mPrefs = prefs;
+
+// This seems to cause a crash on exit. Investigate later.
+// mPrefsWids.setAutoDelete(true);
+
+ connect(this,SIGNAL(defaultClicked()),SLOT(slotDefault()));
+ //connect(this,SIGNAL(cancelClicked()),SLOT(slotDefault()));
+ //connect(this,SIGNAL(cancelClicked()),SLOT(reject()));
+}
+
+KPrefsDialog::~KPrefsDialog()
+{
+}
+
+void KPrefsDialog::addWid(KPrefsWid *wid)
+{
+ mPrefsWids.append(wid);
+}
+
+KPrefsWidBool *KPrefsDialog::addWidBool(const QString &text,bool *reference,QWidget *parent)
+{
+ KPrefsWidBool *w = new KPrefsWidBool(text,reference,parent);
+ addWid(w);
+ return w;
+}
+
+KPrefsWidTime *KPrefsDialog::addWidTime(const QString &text,int *reference,QWidget *parent)
+{
+ KPrefsWidTime *w = new KPrefsWidTime(text,reference,parent);
+ addWid(w);
+ return w;
+}
+
+KPrefsWidColor *KPrefsDialog::addWidColor(const QString &text,QColor *reference,QWidget *parent)
+{
+ KPrefsWidColor *w = new KPrefsWidColor(text,reference,parent);
+ addWid(w);
+ return w;
+}
+
+KPrefsWidRadios *KPrefsDialog::addWidRadios(const QString &text,int *reference,QWidget *parent)
+{
+ KPrefsWidRadios *w = new KPrefsWidRadios(text,reference,parent);
+ addWid(w);
+ return w;
+}
+
+KPrefsWidString *KPrefsDialog::addWidString(const QString &text,QString *reference,QWidget *parent)
+{
+ KPrefsWidString *w = new KPrefsWidString(text,reference,parent);
+ addWid(w);
+ return w;
+}
+
+KPrefsWidString *KPrefsDialog::addWidPassword(const QString &text,QString *reference,QWidget *parent)
+{
+ KPrefsWidString *w = new KPrefsWidString(text,reference,parent,QLineEdit::Password);
+ addWid(w);
+ return w;
+}
+
+KPrefsWidFont *KPrefsDialog::addWidFont(const QString &sampleText,const QString &buttonText,
+ QFont *reference,QWidget *parent)
+{
+ KPrefsWidFont *w = new KPrefsWidFont(sampleText,buttonText,reference,parent);
+ addWid(w);
+ return w;
+}
+
+void KPrefsDialog::setDefaults()
+{
+ mPrefs->setDefaults();
+
+ readConfig();
+}
+
+void KPrefsDialog::readConfig()
+{
+// kdDebug(5300) << "KPrefsDialog::readConfig()" << endl;
+
+ KPrefsWid *wid;
+ for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) {
+ wid->readConfig();
+ }
+
+ usrReadConfig();
+}
+
+void KPrefsDialog::writeConfig()
+{
+// kdDebug(5300) << "KPrefsDialog::writeConfig()" << endl;
+
+ KPrefsWid *wid;
+ for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) {
+ wid->writeConfig();
+ }
+
+ usrWriteConfig();
+
+// kdDebug(5300) << "KPrefsDialog::writeConfig() now writing..." << endl;
+
+ mPrefs->writeConfig();
+
+// kdDebug(5300) << "KPrefsDialog::writeConfig() done" << endl;
+}
+
+
+void KPrefsDialog::slotApply()
+{
+ writeConfig();
+ emit configChanged();
+}
+
+void KPrefsDialog::slotOk()
+{
+ slotApply();
+ QDialog::accept();
+}
+void KPrefsDialog::accept()
+{
+ slotOk();
+}
+
+void KPrefsDialog::slotDefault()
+{
+ if (KMessageBox::warningContinueCancel(this,
+ i18n("You are about to set all\npreferences to default values.\nAll "
+ "custom modifications will be lost."),i18n("Setting Default Preferences"),
+ i18n("Continue"))
+ == KMessageBox::Continue) setDefaults();
+}
diff --git a/libkdepim/kprefsdialog.h b/libkdepim/kprefsdialog.h
new file mode 100644
index 0000000..dceab01
--- a/dev/null
+++ b/libkdepim/kprefsdialog.h
@@ -0,0 +1,446 @@
+/*
+ This file is part of KOrganizer.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+#ifndef _KPREFSDIALOG_H
+#define _KPREFSDIALOG_H
+// $Id$
+
+#include <qptrlist.h>
+#include <qlineedit.h>
+
+#include <kdialogbase.h>
+
+class KPrefs;
+class KPrefsDialog;
+
+class KColorButton;
+class QCheckBox;
+class QLabel;
+class QSpinBox;
+class QButtonGroup;
+
+/**
+ @short Base class for widgets used by @ref KPrefsDialog.
+ @author Cornelius Schumacher
+ @see KPrefsDialog
+
+ This class provides the interface for the preferences widgets used by
+ KPrefsDialog.
+*/
+class KPrefsWid
+{
+ public:
+ /**
+ This function is called to read value of the setting from the
+ stored configuration and display it in the widget.
+ */
+ virtual void readConfig() = 0;
+ /**
+ This function is called to write the current setting of the widget to the
+ stored configuration.
+ */
+ virtual void writeConfig() = 0;
+};
+
+/**
+ @short Widget for bool settings in @ref KPrefsDialog.
+
+ This class provides a widget for configuring bool values. It is meant to be
+ used by KPrefsDialog. The user is responsible for the layout management.
+*/
+class KPrefsWidBool : public KPrefsWid
+{
+ public:
+ /**
+ Create a bool widget consisting of a QCheckbox.
+
+ @param text Text of QCheckBox.
+ @param reference Pointer to variable read and written by this widget.
+ @param parent Parent widget.
+ */
+ KPrefsWidBool(const QString &text,bool *reference,QWidget *parent);
+
+ /**
+ Return the QCheckbox used by this widget.
+ */
+ QCheckBox *checkBox();
+
+ void readConfig();
+ void writeConfig();
+
+ private:
+ bool *mReference;
+
+ QCheckBox *mCheck;
+};
+
+/**
+ @short Widget for time settings in @ref KPrefsDialog.
+
+ This class provides a widget for configuring time values. It is meant to be
+ used by KPrefsDialog. The user is responsible for the layout management.
+*/
+class KPrefsWidTime : public KPrefsWid
+{
+ public:
+ /**
+ Create a time widget consisting of a label and a spinbox.
+
+ @param text Text of Label.
+ @param reference Pointer to variable read and written by this widget.
+ @param parent Parent widget.
+ */
+ KPrefsWidTime(const QString &text,int *reference,QWidget *parent);
+
+ /**
+ Return QLabel used by this widget.
+ */
+ QLabel *label();
+ /**
+ Return QSpinBox used by this widget.
+ */
+ QSpinBox *spinBox();
+
+ void readConfig();
+ void writeConfig();
+
+ private:
+ int *mReference;
+
+ QLabel *mLabel;
+ QSpinBox *mSpin;
+};
+
+/**
+ @short Widget for color settings in @ref KPrefsDialog.
+
+ This class provides a widget for configuring color values. It is meant to be
+ used by KPrefsDialog. The user is responsible for the layout management.
+*/
+class KPrefsWidColor : public QObject, public KPrefsWid
+{
+ Q_OBJECT
+ public:
+ /**
+ Create a color widget consisting of a test field and a button for opening
+ a color dialog.
+
+ @param text Text of button.
+ @param reference Pointer to variable read and written by this widget.
+ @param parent Parent widget.
+ */
+ KPrefsWidColor(const QString &text,QColor *reference,QWidget *parent);
+ /**
+ Destruct color setting widget.
+ */
+ ~KPrefsWidColor();
+
+ /**
+ Return QLabel for the button
+ */
+ QLabel *label();
+ /**
+ Return button opening the color dialog.
+ */
+ KColorButton *button();
+
+ void readConfig();
+ void writeConfig();
+
+ private:
+ QColor *mReference;
+
+ QLabel *mLabel;
+ KColorButton *mButton;
+};
+
+/**
+ @short Widget for font settings in @ref KPrefsDialog.
+
+ This class provides a widget for configuring font values. It is meant to be
+ used by KPrefsDialog. The user is responsible for the layout management.
+*/
+class KPrefsWidFont : public QObject, public KPrefsWid
+{
+ Q_OBJECT
+ public:
+ /**
+ Create a font widget consisting of a test field and a button for opening
+ a font dialog.
+
+ @param label Text of label.
+ @param reference Pointer to variable read and written by this widget.
+ @param parent Parent widget.
+ */
+ KPrefsWidFont(const QString &sampleText,const QString &labelText,
+ QFont *reference,QWidget *parent);
+ /**
+ Destruct font setting widget.
+ */
+ ~KPrefsWidFont();
+
+ /**
+ Return label.
+ */
+ QLabel *label();
+ /**
+ Return QFrame used as preview field.
+ */
+ QLabel *preview();
+ /**
+ Return button opening the font dialog.
+ */
+ QPushButton *button();
+
+ void readConfig();
+ void writeConfig();
+
+ protected slots:
+ void selectFont();
+
+ private:
+ QFont *mReference;
+
+ QLabel *mLabel;
+ QLabel *mPreview;
+ QPushButton *mButton;
+};
+
+/**
+ @short Widget for settings represented by a group of radio buttons in
+ @ref KPrefsDialog.
+
+ This class provides a widget for configuring selections. It is meant to be
+ used by KPrefsDialog. The user is responsible for the layout management. The
+ setting is interpreted as an int value, corresponding to the position of the
+ radio button. The position of the button is defined by the sequence of @ref
+ addRadio() calls, starting with 0.
+*/
+class KPrefsWidRadios : public KPrefsWid
+{
+ public:
+ /**
+ Create a widget for selection of an option. It consists of a box with
+ several radio buttons.
+
+ @param text Text of main box.
+ @param reference Pointer to variable read and written by this widget.
+ @param parent Parent widget.
+ */
+ KPrefsWidRadios(const QString &text,int *reference,QWidget *parent);
+ virtual ~KPrefsWidRadios();
+
+ /**
+ Add a radio button.
+
+ @param text Text of the button.
+ */
+ void addRadio(const QString &text);
+
+ /**
+ Return the box widget used by this widget.
+ */
+ QButtonGroup *groupBox();
+
+ void readConfig();
+ void writeConfig();
+
+ private:
+ int *mReference;
+
+ QButtonGroup *mBox;
+};
+
+
+/**
+ @short Widget for string settings in @ref KPrefsDialog.
+
+ This class provides a widget for configuring string values. It is meant to be
+ used by KPrefsDialog. The user is responsible for the layout management.
+*/
+class KPrefsWidString : public KPrefsWid
+{
+ public:
+ /**
+ Create a string widget consisting of a test label and a line edit.
+
+ @param text Text of label.
+ @param reference Pointer to variable read and written by this widget.
+ @param parent Parent widget.
+ */
+ KPrefsWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal);
+ /**
+ Destructor.
+ */
+ virtual ~KPrefsWidString();
+
+ /**
+ Return label used by this widget.
+ */
+ QLabel *label();
+ /**
+ Return QLineEdit used by this widget.
+ */
+ QLineEdit *lineEdit();
+
+ void readConfig();
+ void writeConfig();
+
+ private:
+ QString *mReference;
+
+ QLabel *mLabel;
+ QLineEdit *mEdit;
+};
+
+
+/**
+ @short Base class for a preferences dialog.
+
+ This class provides the framework for a preferences dialog. You have to
+ subclass it and add the code to create the actual configuration widgets and
+ do the layout management.
+
+ KPrefsDialog provides functions to add subclasses of @ref KPrefsWid. For
+ these widgets the reading, writing and setting to default values is handled
+ automatically. Custom widgets have to be handled in the functions @ref
+ usrReadConfig() and @ref usrWriteConfig().
+*/
+class KPrefsDialog : public KDialogBase
+{
+ Q_OBJECT
+ public:
+ /**
+ Create a KPrefsDialog for a KPrefs object.
+
+ @param prefs KPrefs object used to access te configuration.
+ @param parent Parent widget.
+ @param name Widget name.
+ @param modal true, if dialog has to be modal, false for non-modal.
+ */
+ KPrefsDialog(KPrefs *prefs,QWidget *parent=0,char *name=0,bool modal=false);
+ /**
+ Destructor.
+ */
+ virtual ~KPrefsDialog();
+
+ /**
+ Register a custom KPrefsWid object.
+ */
+ void addWid(KPrefsWid *);
+ /**
+ Register a @ref KPrefsWidBool object.
+
+ @param text Text of bool widget.
+ @param reference Reference to variable storing the setting.
+ @param parent Parent widget.
+ */
+ KPrefsWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent);
+ /**
+ Register a @ref KPrefsWidTime object.
+
+ @param text Text of time widget.
+ @param reference Reference to variable storing the setting.
+ @param parent Parent widget.
+ */
+ KPrefsWidTime *addWidTime(const QString &text,int *reference,QWidget *parent);
+ /**
+ Register a @ref KPrefsWidColor object.
+
+ @param text Text of color widget.
+ @param reference Reference to variable storing the setting.
+ @param parent Parent widget.
+ */
+ KPrefsWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent);
+ /**
+ Register a @ref KPrefsWidRadios object.
+
+ @param text Text of radio button box widget.
+ @param reference Reference to variable storing the setting.
+ @param parent Parent widget.
+ */
+ KPrefsWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent);
+ /**
+ Register a @ref KPrefsWidString object.
+
+ @param text Text of string widget.
+ @param reference Reference to variable storing the setting.
+ @param parent Parent widget.
+ */
+ KPrefsWidString *addWidString(const QString &text,QString *reference,QWidget *parent);
+ /**
+ Register a password @ref KPrefsWidString object, with echomode set to QLineEdit::Password.
+
+ @param text Text of string widget.
+ @param reference Reference to variable storing the setting.
+ @param parent Parent widget.
+ */
+ KPrefsWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent);
+ /**
+ Register a @ref KPrefsWidFont object.
+
+ @param sampleText Sample text of font widget.
+ @param buttonText Button text of font widget.
+ @param reference Reference to variable storing the setting.
+ @param parent Parent widget.
+ */
+ KPrefsWidFont *addWidFont(const QString &sampleText,const QString &buttonText,
+ QFont *reference,QWidget *parent);
+
+ public slots:
+ /** Set all widgets to default values. */
+ void setDefaults();
+
+ /** Read preferences from config file. */
+ void readConfig();
+
+ /** Write preferences to config file. */
+ void writeConfig();
+
+ signals:
+ /** Emitted when the a changed configuration has been stored. */
+ void configChanged();
+
+ protected slots:
+ /** Apply changes to preferences */
+ void slotApply();
+
+ void accept();
+ /** Accept changes to preferences and close dialog */
+ void slotOk();
+
+ /** Set preferences to default values */
+ void slotDefault();
+
+ protected:
+ /** Implement this to read custom configuration widgets. */
+ virtual void usrReadConfig() {}
+ /** Implement this to write custom configuration widgets. */
+ virtual void usrWriteConfig() {}
+
+ private:
+ KPrefs *mPrefs;
+
+ QPtrList<KPrefsWid> mPrefsWids;
+};
+
+#endif
diff --git a/libkdepim/kprefsdialog.moc b/libkdepim/kprefsdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/libkdepim/kprefsdialog.moc
diff --git a/libkdepim/ksyncprofile.cpp b/libkdepim/ksyncprofile.cpp
new file mode 100644
index 0000000..d6d8fa3
--- a/dev/null
+++ b/libkdepim/ksyncprofile.cpp
@@ -0,0 +1,125 @@
+/*
+ This file is part of KOrganizer.
+ Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+// $Id$
+
+#include <qcolor.h>
+
+#include <kconfig.h>
+#include <kstandarddirs.h>
+#include <kglobal.h>
+#include <kdebug.h>
+
+#include "ksyncprofile.h"
+
+
+KSyncProfile::KSyncProfile( const char * name): QObject (0, name )
+{
+ setDefault();
+}
+KSyncProfile::~KSyncProfile()
+{
+
+}
+
+
+KSyncProfile* KSyncProfile::clone()
+{
+ KSyncProfile* myClone = new KSyncProfile();
+ myClone->setPreSyncCommand( mPreSyncCommand );
+ myClone->setPostSyncCommand( mPostSyncCommand );
+ myClone->setLocalTempFile( mLocalTempFile);
+ myClone->setRemoteFileName( mRemoteFileName );
+ myClone->setShowSummaryAfterSync( mShowSummaryAfterSync );
+ myClone->setAskForPreferences( mAskForPreferences);
+ myClone->setWriteBackExisting(mWriteBackExisting );
+ myClone->setWriteBackFile( mWriteBackFile);
+ myClone->setIncludeInRingSync( mIncludeInRingSync );
+ myClone->setSyncPrefs( mSyncPrefs);
+ myClone->setIsLocalFileSync( mIsLocalFileSync );
+ myClone->setName( "noName" );
+ return myClone;
+}
+
+
+void KSyncProfile::setDefault()
+{
+ mName = "noName";
+ mPreSyncCommand = i18n("command for downloading remote file to local device");
+ mPostSyncCommand = i18n("command for uploading local temp file to remote device");
+ mLocalTempFile = "/tmp/mycalendar.ics";
+ mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics";
+ mShowSummaryAfterSync = true;
+ mAskForPreferences = true;
+ mWriteBackExisting = false;
+ mWriteBackFile = true;
+ mIncludeInRingSync = false;
+ mSyncPrefs = SYNC_PREF_ASK;
+ mIsLocalFileSync = true;
+
+}
+void KSyncProfile::readConfig(KConfig *config )
+{
+ config->setGroup("SyncProfiles");
+ QString prefix = "Profile_"+mName+"_";
+ //mName = config->readEntry( prefix+ "Name", mName );
+ mPreSyncCommand = config->readEntry( prefix+ "PreSyncCommand",mPreSyncCommand );
+ mPostSyncCommand = config->readEntry( prefix+ "PostSyncCommand", mPostSyncCommand );
+ mIncludeInRingSync = config->readBoolEntry( prefix+ "IncludeInRingSync",mIncludeInRingSync );
+ mLocalTempFile = config->readEntry( prefix+ "LocalTempFile", mLocalTempFile );
+ mRemoteFileName = config->readEntry( prefix+ "RemoteFileName", mRemoteFileName );
+ mShowSummaryAfterSync = config->readBoolEntry( prefix+ "ShowSummaryAfterSync", mShowSummaryAfterSync );
+ mAskForPreferences = config->readBoolEntry( prefix+ "AskForPreferences",mAskForPreferences );
+ mWriteBackExisting = config->readBoolEntry( prefix+ "WriteBackExisting",mWriteBackExisting );
+ mSyncPrefs = config->readNumEntry( prefix+ "SyncPrefs", mSyncPrefs );
+ mIsLocalFileSync= config->readBoolEntry( prefix+ "IsLocalFileSync", mIsLocalFileSync );
+}
+void KSyncProfile::writeConfig( KConfig * config )
+{
+ config->setGroup("SyncProfiles");
+ QString prefix = "Profile_"+mName+"_";
+ // config->writeEntry( prefix+ "Name", mName );
+ config->writeEntry( prefix+ "PreSyncCommand",mPreSyncCommand );
+ config->writeEntry( prefix+ "PostSyncCommand", mPostSyncCommand );
+ config->writeEntry( prefix+ "IncludeInRingSync",mIncludeInRingSync );
+ config->writeEntry( prefix+ "LocalTempFile", mLocalTempFile );
+ config->writeEntry( prefix+ "RemoteFileName", mRemoteFileName );
+ config->writeEntry( prefix+ "ShowSummaryAfterSync", mShowSummaryAfterSync );
+ config->writeEntry( prefix+ "AskForPreferences",mAskForPreferences );
+ config->writeEntry( prefix+ "WriteBackExisting",mWriteBackExisting );
+ config->writeEntry( prefix+ "SyncPrefs", mSyncPrefs );
+ config->writeEntry( prefix+ "IsLocalFileSync", mIsLocalFileSync );
+}
+
+/*
+class KPrefsItemInt : public KPrefsItem {
+ public:
+ KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0);
+ virtual ~KPrefsItemInt() {}
+
+ void setDefault();
+ void readConfig(KConfig *);
+ void writeConfig(KConfig *);
+
+ private:
+ int *mReference;
+ int mDefault;
+};
+*/
diff --git a/libkdepim/ksyncprofile.h b/libkdepim/ksyncprofile.h
new file mode 100644
index 0000000..238ffad
--- a/dev/null
+++ b/libkdepim/ksyncprofile.h
@@ -0,0 +1,106 @@
+/*
+ This file is part of KOrganizer.
+ Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+#ifndef _KSYNCPROFILE_H
+#define _KSYNCPROFILE_H
+
+#include <qptrlist.h>
+#include <qcolor.h>
+#include <qfont.h>
+#include <qstringlist.h>
+#include <qobject.h>
+#include <qstring.h>
+
+#define SYNC_PREF_LOCAL 0
+#define SYNC_PREF_REMOTE 1
+#define SYNC_PREF_NEWEST 2
+#define SYNC_PREF_ASK 3
+#define SYNC_PREF_FORCE_LOCAL 4
+#define SYNC_PREF_FORCE_REMOTE 5
+#define SYNC_PREF_TAKE_BOTH 6
+
+class KConfig;
+
+/**
+ @short Class for storing a preferences setting
+ @author Cornelius Schumacher
+ @see KPref
+
+ This class represents one preferences setting as used by @ref KPrefs.
+ Subclasses of KPrefsItem implement storage functions for a certain type of
+ setting. Normally you don't have to use this class directly. Use the special
+ addItem() functions of KPrefs instead. If you subclass this class you will
+ have to register instances with the function KPrefs::addItem().
+*/
+class KSyncProfile : public QObject {
+ public:
+ KSyncProfile( const char * name = 0);
+ ~KSyncProfile() ;
+
+ KSyncProfile* clone();
+ void setDefault();
+ void readConfig(KConfig *);
+ void writeConfig(KConfig *);
+ void setName( const QString& n ) {mName = n;}
+ QString getName( ) { return mName;}
+ void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;}
+ QString getPreSyncCommand( ) { return mPreSyncCommand; }
+ void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;}
+ QString getPostSyncCommand( ) { return mPostSyncCommand;}
+
+ void setLocalTempFile( const QString& n ) { mLocalTempFile= n;}
+ QString getLocalTempFile( ) { return mLocalTempFile;}
+ void setRemoteFileName( const QString& n ) { mRemoteFileName = n;}
+ QString getRemoteFileName( ) { return mRemoteFileName;}
+ /*
+ void set( const QString& n ) { = n;}
+ QString get( ) { return ;}
+ */
+
+ void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;}
+ bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;}
+ void setAskForPreferences( bool b ) { mAskForPreferences= b;}
+ bool getAskForPreferences( ) { return mAskForPreferences;}
+ void setWriteBackExisting( bool b ) { mWriteBackExisting = b;}
+ bool getWriteBackExisting( ) { return mWriteBackExisting;}
+ void setWriteBackFile( bool b ) { mWriteBackFile= b;}
+ bool getWriteBackFile( ) { return mWriteBackFile;}
+ void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;}
+ bool getIncludeInRingSync( ) { return mIncludeInRingSync;}
+ void setSyncPrefs( int n ) { mSyncPrefs= n;}
+ int getSyncPrefs( ) { return mSyncPrefs;}
+ void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;}
+ bool getIsLocalFileSync( ) { return mIsLocalFileSync;}
+
+ private:
+ QString mName;
+ QString mPreSyncCommand;
+ QString mPostSyncCommand;
+ QString mLocalTempFile;
+ QString mRemoteFileName;
+ bool mIncludeInRingSync;
+ int mSyncPrefs;
+ bool mWriteBackFile;
+ bool mWriteBackExisting;
+ bool mAskForPreferences;
+ bool mShowSummaryAfterSync;
+ bool mIsLocalFileSync;
+};
+
+#endif
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
new file mode 100644
index 0000000..b490899
--- a/dev/null
+++ b/libkdepim/libkdepim.pro
@@ -0,0 +1,50 @@
+TEMPLATE = lib
+CONFIG = qt warn_on
+DEFINES +=KORG_NOKABC
+TARGET = microkdepim
+INCLUDEPATH += ../microkde ../libkabcwrap ../microkde/kdecore . ..
+DESTDIR=../bin
+
+DEFINES += DESKTOP_VERSION
+include( ../variables.pri )
+unix : {
+OBJECTS_DIR = obj/unix
+MOC_DIR = moc/unix
+}
+win32: {
+DEFINES += _WIN32_
+OBJECTS_DIR = obj/win
+MOC_DIR = moc/win
+}
+INTERFACES = \
+
+HEADERS = \
+ categoryeditdialog.h \
+ categoryeditdialog_base.h \
+ categoryselectdialog.h \
+ categoryselectdialog_base.h \
+ kdateedit.h \
+ kdatepicker.h \
+ kinputdialog.h \
+ kincidenceformatter.h \
+ kpimprefs.h \
+ kprefs.h \
+ kprefsdialog.h \
+ addresseeview.h \
+ ksyncprofile.h
+
+SOURCES = \
+ categoryeditdialog.cpp \
+ categoryeditdialog_base.cpp \
+ categoryselectdialog.cpp \
+ categoryselectdialog_base.cpp \
+ kdateedit.cpp \
+ kdatepicker.cpp \
+ kinputdialog.cpp \
+ kincidenceformatter.cpp \
+ kpimprefs.cpp \
+ kprefs.cpp \
+ kprefsdialog.cpp \
+ addresseeview.cpp \
+ ksyncprofile.cpp
+
diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro
new file mode 100644
index 0000000..05abaa5
--- a/dev/null
+++ b/libkdepim/libkdepimE.pro
@@ -0,0 +1,43 @@
+TEMPLATE = lib
+CONFIG += qt warn_on
+TARGET = microkdepim
+INCLUDEPATH += ../microkde ../qtcompat ../libkabcwrap ../microkde/kdecore
+INCLUDEPATH += . ..
+LIBS += -lmicrokde
+OBJECTS_DIR = obj/$(PLATFORM)
+MOC_DIR = moc/$(PLATFORM)
+DESTDIR=$(QPEDIR)/lib
+
+
+INTERFACES = \
+
+HEADERS = \
+ categoryeditdialog.h \
+ categoryeditdialog_base.h \
+ categoryselectdialog.h \
+ categoryselectdialog_base.h \
+ kdateedit.h \
+ kdatepicker.h \
+ kinputdialog.h \
+ kincidenceformatter.h \
+ kpimprefs.h \
+ kprefs.h \
+ kprefsdialog.h \
+ addresseeview.h \
+ ksyncprofile.h
+
+
+SOURCES = \
+ categoryeditdialog.cpp \
+ categoryeditdialog_base.cpp \
+ categoryselectdialog.cpp \
+ categoryselectdialog_base.cpp \
+ kdateedit.cpp \
+ kinputdialog.cpp \
+ kdatepicker.cpp \
+ kincidenceformatter.cpp \
+ kpimprefs.cpp \
+ kprefs.cpp \
+ kprefsdialog.cpp \
+ addresseeview.cpp \
+ ksyncprofile.cpp