• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kgpg

  • sources
  • kde-4.14
  • kdeutils
  • kgpg
selectexpirydate.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002 Jean-Baptiste Mardelle <bj@altern.org>
3  * Copyright (C) 2007 Jimmy Gilles <jimmygilles@gmail.com>
4  * Copyright (C) 2008 Rolf Eike Beer <kde@opensource.sf-tec.de>
5  */
6 
7 /***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "selectexpirydate.h"
17 
18 #include <QCheckBox>
19 #include <QVBoxLayout>
20 
21 #include <KDatePicker>
22 #include <KLocale>
23 
24 SelectExpiryDate::SelectExpiryDate(QWidget* parent, QDateTime date)
25  : KDialog(parent)
26 {
27  setCaption(i18n("Choose New Expiration"));
28  setButtons(Ok | Cancel);
29  setDefaultButton(Ok);
30  setModal(true);
31 
32  QWidget *page = new QWidget(this);
33  m_unlimited = new QCheckBox(i18nc("Key has unlimited lifetime", "Unlimited"), page);
34  m_unlimited->setChecked(date.isNull());
35 
36  if (date.isNull())
37  date = QDateTime::currentDateTime();
38 
39  m_datepicker = new KDatePicker(date.date(), page);
40  if (date.isNull()) {
41  m_datepicker->setEnabled(false);
42  m_unlimited->setChecked(true);
43  }
44 
45  QVBoxLayout *layout = new QVBoxLayout(page);
46  layout->setSpacing(3);
47  layout->addWidget(m_datepicker);
48  layout->addWidget(m_unlimited);
49 
50  connect(m_unlimited, SIGNAL(toggled(bool)), this, SLOT(slotEnableDate(bool)));
51  connect(m_datepicker, SIGNAL(dateChanged(QDate)), this, SLOT(slotCheckDate(QDate)));
52  connect(m_datepicker, SIGNAL(dateEntered(QDate)), this, SLOT(slotCheckDate(QDate)));
53 
54  setMainWidget(page);
55  show();
56 
57  slotEnableDate(m_unlimited->isChecked());
58 }
59 
60 QDateTime SelectExpiryDate::date() const
61 {
62  if (m_unlimited->isChecked())
63  return QDateTime();
64  else
65  return QDateTime(m_datepicker->date());
66 }
67 
68 void SelectExpiryDate::slotCheckDate(const QDate& date)
69 {
70  enableButtonOk(QDateTime(date) >= QDateTime::currentDateTime());
71 }
72 
73 void SelectExpiryDate::slotEnableDate(const bool ison)
74 {
75  m_datepicker->setEnabled(!ison);
76  if (ison)
77  enableButtonOk(true);
78  else
79  slotCheckDate(m_datepicker->date());
80 }
81 
82 #include "selectexpirydate.moc"
QWidget
KDialog
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
SelectExpiryDate::SelectExpiryDate
SelectExpiryDate(QWidget *parent=0, QDateTime date=QDateTime())
Definition: selectexpirydate.cpp:24
QCheckBox
QVBoxLayout
QDate
SelectExpiryDate::date
QDateTime date() const
Definition: selectexpirydate.cpp:60
QAbstractButton::setChecked
void setChecked(bool)
QDateTime::currentDateTime
QDateTime currentDateTime()
QDateTime::isNull
bool isNull() const
QDateTime::date
QDate date() const
selectexpirydate.h
QBoxLayout::setSpacing
void setSpacing(int spacing)
QDateTime
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:42:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kgpg

Skip menu "kgpg"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal