~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to incidenceeditor-ng/freebusyurldialog.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
 
3
 
 
4
  This program is free software; you can redistribute it and/or modify
 
5
  it under the terms of the GNU General Public License as published by
 
6
  the Free Software Foundation; either version 2 of the License, or
 
7
  (at your option) any later version.
 
8
 
 
9
  This program is distributed in the hope that it will be useful,
 
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
12
  GNU General Public License for more details.
 
13
 
 
14
  You should have received a copy of the GNU General Public License along
 
15
  with this program; if not, write to the Free Software Foundation, Inc.,
 
16
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
17
 
 
18
  As a special exception, permission is given to link this program
 
19
  with any edition of Qt, and distribute the resulting executable,
 
20
  without including the source code for Qt in the source distribution.
 
21
*/
 
22
 
 
23
#include "freebusyurldialog.h"
 
24
 
 
25
#include <KCalCore/FreeBusyUrlStore>
 
26
 
 
27
#include <KLineEdit>
 
28
#include <KLocale>
 
29
 
 
30
#include <QBoxLayout>
 
31
#include <KDebug>
 
32
#include <QFrame>
 
33
#include <QLabel>
 
34
 
 
35
using namespace IncidenceEditorNG;
 
36
 
 
37
FreeBusyUrlDialog::FreeBusyUrlDialog( AttendeeData::Ptr attendee, QWidget *parent )
 
38
  : KDialog( parent )
 
39
{
 
40
  QFrame *topFrame = new QFrame( this );
 
41
  setMainWidget( topFrame );
 
42
  setModal( true );
 
43
  setCaption( i18n( "Edit Free/Busy Location" ) );
 
44
  setButtons( Ok|Cancel );
 
45
  setDefaultButton( Ok );
 
46
 
 
47
  QBoxLayout *topLayout = new QVBoxLayout( topFrame );
 
48
  topLayout->setSpacing( spacingHint() );
 
49
  topLayout->setMargin( 0 );
 
50
 
 
51
  mWidget = new FreeBusyUrlWidget( attendee, topFrame );
 
52
  topLayout->addWidget( mWidget );
 
53
 
 
54
  mWidget->loadConfig();
 
55
  connect( this, SIGNAL(okClicked()), this, SLOT(slotOk()) );
 
56
}
 
57
 
 
58
void FreeBusyUrlDialog::slotOk()
 
59
{
 
60
  mWidget->saveConfig();
 
61
  accept();
 
62
}
 
63
 
 
64
FreeBusyUrlWidget::FreeBusyUrlWidget( AttendeeData::Ptr attendee, QWidget *parent )
 
65
  : QWidget( parent ), mAttendee( attendee )
 
66
{
 
67
  QBoxLayout *topLayout = new QVBoxLayout( this );
 
68
  topLayout->setSpacing( KDialog::spacingHint() );
 
69
 
 
70
  QLabel *label =
 
71
    new QLabel( i18n( "Location of Free/Busy information for %1 <placeholder>%2</placeholder>:",
 
72
                     mAttendee->name(), mAttendee->email() ), this );
 
73
  topLayout->addWidget( label );
 
74
 
 
75
  mUrlEdit = new KLineEdit( this );
 
76
  mUrlEdit->setFocus();
 
77
  topLayout->addWidget( mUrlEdit );
 
78
}
 
79
 
 
80
FreeBusyUrlWidget::~FreeBusyUrlWidget()
 
81
{
 
82
}
 
83
 
 
84
void FreeBusyUrlWidget::loadConfig()
 
85
{
 
86
  kDebug();
 
87
 
 
88
  const QString url = KCalCore::FreeBusyUrlStore::self()->readUrl( mAttendee->email() );
 
89
  mUrlEdit->setText( url );
 
90
}
 
91
 
 
92
void FreeBusyUrlWidget::saveConfig()
 
93
{
 
94
  kDebug();
 
95
 
 
96
  const QString url = mUrlEdit->text();
 
97
  KCalCore::FreeBusyUrlStore::self()->writeUrl( mAttendee->email(), url );
 
98
  KCalCore::FreeBusyUrlStore::self()->sync();
 
99
}
 
100
 
 
101
#include "freebusyurldialog.moc"