Commit 197700dc authored by Tobias Koenig's avatar Tobias Koenig

bring back free/busy edit widget

svn path=/trunk/KDE/kdepim/kcontactmanager/editor/; revision=915961
parent f943b1a1
......@@ -24,6 +24,7 @@
#include "dateeditwidget.h"
#include "displaynameeditwidget.h"
#include "emaileditwidget.h"
#include "freebusyeditwidget.h"
#include "imagewidget.h"
#include "imeditwidget.h"
#include "nameeditwidget.h"
......@@ -95,7 +96,7 @@ class ContactEditor::Private
KLineEdit *mAssistantWidget;
// widgets from groupware group
KUrlRequester *mFreeBusyWidget;
FreeBusyEditWidget *mFreeBusyWidget;
// widgets from notes group
KTextEdit *mNotesWidget;
......@@ -340,7 +341,7 @@ void ContactEditor::Private::initGuiBusinessTab()
label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
groupwareLayout->addWidget( label, 0, 0 );
mFreeBusyWidget = new KUrlRequester;
mFreeBusyWidget = new FreeBusyEditWidget;
label->setBuddy( mFreeBusyWidget );
groupwareLayout->addWidget( mFreeBusyWidget, 0, 1 );
......@@ -436,7 +437,7 @@ ContactEditor::~ContactEditor()
KConfigGroup group( &config, "General" );
group.writeEntry( "DisplayNameType", (int)d->mDisplayNameWidget->displayType() );
delete d;
}
......@@ -474,6 +475,7 @@ void ContactEditor::loadContact( const KABC::Addressee &contact )
d->mAssistantWidget->setText( d->loadCustom( contact, "X-AssistantsName" ) );
// groupware group
d->mFreeBusyWidget->loadContact( contact );
// notes group
d->mNotesWidget->setPlainText( contact.note() );
......@@ -520,6 +522,7 @@ void ContactEditor::storeContact( KABC::Addressee &contact ) const
d->storeCustom( contact, "X-AssistantsName", d->mAssistantWidget->text().trimmed() );
// groupware group
d->mFreeBusyWidget->storeContact( contact );
// notes group
contact.setNote( d->mNotesWidget->toPlainText() );
......
/*
This file is part of KContactManager.
Copyright (c) 2009 Tobias Koenig <tokoe@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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "freebusyeditwidget.h"
#include <QtGui/QHBoxLayout>
#include <kabc/addressee.h>
#include <kcal/freebusyurlstore.h>
#include <kurlrequester.h>
FreeBusyEditWidget::FreeBusyEditWidget( QWidget *parent )
: QWidget( parent )
{
QHBoxLayout *layout = new QHBoxLayout( this );
layout->setMargin( 0 );
mURL = new KUrlRequester;
layout->addWidget( mURL );
}
FreeBusyEditWidget::~FreeBusyEditWidget()
{
}
void FreeBusyEditWidget::loadContact( const KABC::Addressee &contact )
{
if ( contact.preferredEmail().isEmpty() )
return;
mURL->setUrl( KCal::FreeBusyUrlStore::self()->readUrl( contact.preferredEmail() ) );
}
void FreeBusyEditWidget::storeContact( KABC::Addressee &contact ) const
{
if ( contact.preferredEmail().isEmpty() )
return;
KCal::FreeBusyUrlStore::self()->writeUrl( contact.preferredEmail(), mURL->url().url() );
KCal::FreeBusyUrlStore::self()->sync();
}
void FreeBusyEditWidget::setReadOnly( bool readOnly )
{
mURL->setEnabled( !readOnly );
}
#include "freebusyeditwidget.moc"
/*
This file is part of KContactManager.
Copyright (c) 2009 Tobias Koenig <tokoe@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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef FREEBUSYEDITWIDGET_H
#define FREEBUSYEDITWIDGET_H
#include <QtGui/QWidget>
namespace KABC
{
class Addressee;
}
class KUrlRequester;
class FreeBusyEditWidget : public QWidget
{
Q_OBJECT
public:
FreeBusyEditWidget( QWidget *parent = 0 );
~FreeBusyEditWidget();
void loadContact( const KABC::Addressee &contact );
void storeContact( KABC::Addressee &contact ) const;
void setReadOnly( bool readOnly );
private:
KUrlRequester *mURL;
bool mReadOnly;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment