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

kget

  • sources
  • kde-4.12
  • kdenetwork
  • kget
  • ui
  • metalinkcreator
generalwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 * Copyright (C) 2009 Matthias Fuchs <mat69@gmx.net> *
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 *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18 ***************************************************************************/
19 
20 #include "generalwidget.h"
21 
22 #include <KSystemTimeZone>
23 
24 #include "metalinker.h"
25 
26 GeneralWidget::GeneralWidget(QWidget *parent)
27  : QWidget (parent)
28 {
29  ui.setupUi(this);
30 
31  ui.dynamic->setToolTip(ui.labelDynamic->toolTip());
32 
33  connect(ui.publishedGroupBox, SIGNAL(toggled(bool)), this, SLOT(slotPublishedEnabled(bool)));
34  connect(ui.updatedGroupBox, SIGNAL(toggled(bool)), this, SLOT(slotUpdatedEnabled(bool)));
35 }
36 
37 void GeneralWidget::load(const KGetMetalink::Metalink &metalink) const
38 {
39  ui.origin->setUrl(metalink.origin);
40  ui.dynamic->setChecked(metalink.dynamic);
41 
42  ui.publishedGroupBox->setChecked(metalink.published.isValid());
43  ui.use_publishedtimeoffset->setChecked(metalink.published.timeZoneOffset.isValid());
44  if (metalink.published.isValid()) {
45  ui.published->setDateTime(metalink.published.dateTime);
46  ui.publishedoffset->setTime(metalink.published.timeZoneOffset);
47  ui.publishedNegative->setChecked(metalink.published.negativeOffset);
48  } else {
49  ui.published->setDateTime(QDateTime::currentDateTime());
50  int offset = KSystemTimeZones::local().currentOffset();
51  const bool negativeOffset = (offset < 0);
52  offset = abs(offset);
53  QTime time = QTime(0, 0, 0);
54  time = time.addSecs(abs(offset));
55  ui.publishedoffset->setTime(time);
56 
57  //to not enable publishedNegative block the signals
58  ui.use_publishedtimeoffset->blockSignals(true);
59  ui.use_publishedtimeoffset->setChecked(true);
60  ui.use_publishedtimeoffset->blockSignals(false);
61 
62  ui.publishedNegative->setChecked(negativeOffset);
63  }
64 
65  ui.updatedGroupBox->setChecked(metalink.updated.isValid());
66  ui.use_updatedtimeoffset->setChecked(metalink.updated.timeZoneOffset.isValid());
67  if (metalink.updated.isValid()) {
68  ui.updated->setDateTime(metalink.updated.dateTime);
69  ui.updatedoffset->setTime(metalink.updated.timeZoneOffset);
70  ui.updatedNegative->setChecked(metalink.updated.negativeOffset);
71  } else {
72  ui.updated->setDateTime(QDateTime::currentDateTime());
73  int offset = KSystemTimeZones::local().currentOffset();
74  const bool negativeOffset = (offset < 0);
75  QTime time = QTime(0, 0, 0);
76  time = time.addSecs(abs(offset));
77  ui.updatedoffset->setTime(time);
78 
79  //to not enable publishedNegative block the signals
80  ui.use_updatedtimeoffset->blockSignals(true);
81  ui.use_updatedtimeoffset->setChecked(true);
82  ui.use_updatedtimeoffset->blockSignals(false);
83 
84  ui.updatedNegative->setChecked(negativeOffset);
85  }
86 }
87 
88 void GeneralWidget::save(KGetMetalink::Metalink *metalink)
89 {
90  metalink->origin = KUrl(ui.origin->text());
91  metalink->dynamic = ui.dynamic->isChecked();
92 
93  metalink->published.clear();
94  if (ui.publishedGroupBox->isChecked()) {
95  metalink->published.dateTime = ui.published->dateTime();
96  if (ui.use_publishedtimeoffset->isChecked()) {
97  metalink->published.timeZoneOffset = ui.publishedoffset->time();
98  }
99  }
100 
101  metalink->updated.clear();
102  if (ui.updatedGroupBox->isChecked()) {
103  metalink->updated.dateTime = ui.updated->dateTime();
104  if (ui.use_updatedtimeoffset->isChecked()) {
105  metalink->updated.timeZoneOffset = ui.updatedoffset->time();
106  }
107  }
108 }
109 
110 void GeneralWidget::slotPublishedEnabled(bool enabled)
111 {
112  if (enabled) {
113  ui.publishedNegative->setEnabled(ui.use_publishedtimeoffset->isChecked());
114  }
115 }
116 
117 void GeneralWidget::slotUpdatedEnabled(bool enabled)
118 {
119  if (enabled) {
120  ui.updatedNegative->setEnabled(ui.use_updatedtimeoffset->isChecked());
121  }
122 }
123 
124 
125 #include "generalwidget.moc"
KGetMetalink::Metalink::dynamic
bool dynamic
Definition: metalinker.h:323
KGetMetalink::Metalink::origin
KUrl origin
Definition: metalinker.h:326
KGetMetalink::DateConstruct::negativeOffset
bool negativeOffset
Definition: metalinker.h:70
GeneralWidget::load
void load(const KGetMetalink::Metalink &metalink) const
Definition: generalwidget.cpp:37
KGetMetalink::Metalink::published
DateConstruct published
Definition: metalinker.h:325
QWidget
KGetMetalink::Metalink::updated
DateConstruct updated
Definition: metalinker.h:328
metalinker.h
GeneralWidget::save
void save(KGetMetalink::Metalink *metalink)
Definition: generalwidget.cpp:88
KGetMetalink::Metalink
Definition: metalinker.h:299
generalwidget.h
GeneralWidget::GeneralWidget
GeneralWidget(QWidget *parent=0)
Definition: generalwidget.cpp:26
KGetMetalink::DateConstruct::clear
void clear()
Definition: metalinker.cpp:144
KGetMetalink::DateConstruct::isValid
bool isValid() const
Definition: metalinker.cpp:117
KGetMetalink::DateConstruct::dateTime
QDateTime dateTime
Definition: metalinker.h:68
KGetMetalink::DateConstruct::timeZoneOffset
QTime timeZoneOffset
Definition: metalinker.h:69
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

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