libyui  3.10.0
YTimezoneSelector.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YTimezoneSelector.cc
20 
21  Author: Stephan Kulow <coolo@suse.de>
22 
23 /-*/
24 
25 
26 #define YUILogComponent "ui"
27 #include "YUILog.h"
28 
29 #include "YUISymbols.h"
30 #include "YTimezoneSelector.h"
31 
32 using std::string;
33 
34 
36 {
37  bool dummy;
38 };
39 
40 
41 
42 
44  const string & pixmap,
45  const std::map<string, string> & timezones )
46  : YWidget( parent )
47 {
48 }
49 
50 
52 {
53  // NOP
54 }
55 
56 
57 const YPropertySet &
59 {
60  static YPropertySet propSet;
61 
62  if ( propSet.isEmpty() )
63  {
64  propSet.add( YProperty( YUIProperty_Value, YStringProperty ) );
65  propSet.add( YProperty( YUIProperty_CurrentItem, YStringProperty ) );
66  propSet.add( YWidget::propertySet() );
67  }
68 
69  return propSet;
70 }
71 
72 
73 bool
74 YTimezoneSelector::setProperty( const string & propertyName, const YPropertyValue & val )
75 {
76  propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
77 
78  if ( propertyName == YUIProperty_Value )
79  {
80  setCurrentZone( val.stringVal(), true );
81  return true; // success -- no special handling necessary
82  }
83  if ( propertyName == YUIProperty_CurrentItem )
84  {
85  setCurrentZone( val.stringVal(), false );
86  return true; // success -- no special handling necessary
87  }
88  return YWidget::setProperty( propertyName, val );
89 }
90 
91 
93 YTimezoneSelector::getProperty( const string & propertyName )
94 {
95  propertySet().check( propertyName ); // throws exceptions if not found
96 
97  if ( propertyName == YUIProperty_Value ) return YPropertyValue( currentZone() );
98  if ( propertyName == YUIProperty_CurrentItem ) return YPropertyValue( currentZone() );
99 
100  return YWidget::getProperty( propertyName );
101 }
YPropertySet::add
void add(const YProperty &prop)
Add a property to this property set.
Definition: YProperty.cc:146
YWidget
Abstract base class of all UI widgets.
Definition: YWidget.h:55
YTimezoneSelector::getProperty
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YTimezoneSelector.cc:93
YTimezoneSelector::YTimezoneSelector
YTimezoneSelector(YWidget *parent, const std::string &pixmap, const std::map< std::string, std::string > &timezones)
Constructor.
Definition: YTimezoneSelector.cc:43
YPropertySet
A set of properties to check names and types against.
Definition: YProperty.h:198
YPropertySet::isEmpty
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
Definition: YProperty.h:263
YPropertyValue::stringVal
std::string stringVal() const
Methods to get the value of this property.
Definition: YProperty.h:180
YPropertyValue::type
YPropertyType type() const
Returns the type of this property value.
Definition: YProperty.h:169
YWidget::getProperty
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YWidget.cc:457
YProperty
Class for widget properties.
Definition: YProperty.h:52
YTimezoneSelector::currentZone
virtual std::string currentZone() const =0
subclasses have to implement this to return value
YPropertySet::check
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
Definition: YProperty.cc:88
YTimezoneSelector::propertySet
virtual const YPropertySet & propertySet()
Return this class's property set.
Definition: YTimezoneSelector.cc:58
YPropertyValue
Transport class for the value of simple properties.
Definition: YProperty.h:105
YTimezoneSelector::~YTimezoneSelector
virtual ~YTimezoneSelector()
Destructor.
Definition: YTimezoneSelector.cc:51
YTimezoneSelector::setCurrentZone
virtual void setCurrentZone(const std::string &zone, bool zoom)=0
subclasses have to implement this to set value
YTimezoneSelector::setProperty
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
Definition: YTimezoneSelector.cc:74
YWidget::setProperty
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
Definition: YWidget.cc:432
YTimezoneSelectorPrivate
Definition: YTimezoneSelector.cc:36
YWidget::propertySet
virtual const YPropertySet & propertySet()
Return this class's property set.
Definition: YWidget.cc:395