SVN_SILENT made messages (.desktop file)
[kdepim.git] / incidenceeditor-ng / freebusyurldialog.cpp
blob9daacad4d2eb9a0c9edc483cb43df491a71e6db7
1 /*
2 Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
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.
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.
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.
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.
23 #include "freebusyurldialog.h"
25 #include <KCalCore/FreeBusyUrlStore>
27 #include <KLineEdit>
28 #include <KLocalizedString>
30 #include <QBoxLayout>
31 #include <QDebug>
32 #include <QFrame>
33 #include <QLabel>
34 #include <KConfigGroup>
35 #include <QDialogButtonBox>
36 #include <QPushButton>
37 #include <QVBoxLayout>
39 using namespace IncidenceEditorNG;
41 FreeBusyUrlDialog::FreeBusyUrlDialog(AttendeeData::Ptr attendee, QWidget *parent)
42 : QDialog(parent)
44 QFrame *topFrame = new QFrame(this);
45 setModal(true);
46 setWindowTitle(i18n("Edit Free/Busy Location"));
47 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
48 QVBoxLayout *mainLayout = new QVBoxLayout;
49 setLayout(mainLayout);
50 mainLayout->addWidget(topFrame);
51 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
52 okButton->setDefault(true);
53 okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
54 connect(buttonBox, &QDialogButtonBox::accepted, this, &FreeBusyUrlDialog::accept);
55 connect(buttonBox, &QDialogButtonBox::rejected, this, &FreeBusyUrlDialog::reject);
56 mainLayout->addWidget(buttonBox);
57 okButton->setDefault(true);
59 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
60 //QT5 topLayout->setSpacing( spacingHint() );
61 topLayout->setMargin(0);
63 mWidget = new FreeBusyUrlWidget(attendee, topFrame);
64 topLayout->addWidget(mWidget);
66 mWidget->loadConfig();
67 connect(okButton, &QPushButton::clicked, this, &FreeBusyUrlDialog::slotOk);
70 void FreeBusyUrlDialog::slotOk()
72 mWidget->saveConfig();
73 accept();
76 FreeBusyUrlWidget::FreeBusyUrlWidget(AttendeeData::Ptr attendee, QWidget *parent)
77 : QWidget(parent), mAttendee(attendee)
79 QBoxLayout *topLayout = new QVBoxLayout(this);
80 //TODO PORT QT5 topLayout->setSpacing( QDialog::spacingHint() );
82 QLabel *label =
83 new QLabel(xi18n("Location of Free/Busy information for %1 <placeholder>%2</placeholder>:",
84 mAttendee->name(), mAttendee->email()), this);
85 topLayout->addWidget(label);
87 mUrlEdit = new KLineEdit(this);
88 mUrlEdit->setFocus();
89 topLayout->addWidget(mUrlEdit);
92 FreeBusyUrlWidget::~FreeBusyUrlWidget()
96 void FreeBusyUrlWidget::loadConfig()
98 qDebug();
100 const QString url = KCalCore::FreeBusyUrlStore::self()->readUrl(mAttendee->email());
101 mUrlEdit->setText(url);
104 void FreeBusyUrlWidget::saveConfig()
106 qDebug();
108 const QString url = mUrlEdit->text();
109 KCalCore::FreeBusyUrlStore::self()->writeUrl(mAttendee->email(), url);
110 KCalCore::FreeBusyUrlStore::self()->sync();