libyui  3.3.2
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 
34 {
35  bool dummy;
36 };
37 
38 
39 
40 
42  const std::string &pixmap,
43  const std::map<std::string, std::string> &timezones )
44  : YWidget( parent )
45 {
46 }
47 
48 
50 {
51  // NOP
52 }
53 
54 
55 const YPropertySet &
57 {
58  static YPropertySet propSet;
59 
60  if ( propSet.isEmpty() )
61  {
62  propSet.add( YProperty( YUIProperty_Value, YStringProperty ) );
63  propSet.add( YProperty( YUIProperty_CurrentItem, YStringProperty ) );
64  propSet.add( YWidget::propertySet() );
65  }
66 
67  return propSet;
68 }
69 
70 
71 bool
72 YTimezoneSelector::setProperty( const std::string & propertyName, const YPropertyValue & val )
73 {
74  propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
75 
76  if ( propertyName == YUIProperty_Value )
77  {
78  setCurrentZone( val.stringVal(), true );
79  return true; // success -- no special handling necessary
80  }
81  if ( propertyName == YUIProperty_CurrentItem )
82  {
83  setCurrentZone( val.stringVal(), false );
84  return true; // success -- no special handling necessary
85  }
86  return YWidget::setProperty( propertyName, val );
87 }
88 
89 
91 YTimezoneSelector::getProperty( const std::string & propertyName )
92 {
93  propertySet().check( propertyName ); // throws exceptions if not found
94 
95  if ( propertyName == YUIProperty_Value ) return YPropertyValue( currentZone() );
96  if ( propertyName == YUIProperty_CurrentItem ) return YPropertyValue( currentZone() );
97  return YWidget::getProperty( propertyName );
98 }
bool isEmpty() const
Returns &#39;true&#39; if this property set does not contain anything.
Definition: YProperty.h:263
Transport class for the value of simple properties.
Definition: YProperty.h:104
void add(const YProperty &prop)
Add a property to this property set.
Definition: YProperty.cc:145
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
Definition: YWidget.cc:428
A set of properties to check names and types against.
Definition: YProperty.h:197
virtual const YPropertySet & propertySet()
Return this class&#39;s property set.
Definition: YWidget.cc:393
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YWidget.cc:453
std::string stringVal() const
Methods to get the value of this property.
Definition: YProperty.h:180
Class for widget properties.
Definition: YProperty.h:51
virtual ~YTimezoneSelector()
Destructor.
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
virtual const YPropertySet & propertySet()
Return this class&#39;s property set.
virtual std::string currentZone() const =0
subclasses have to implement this to return value
void check(const std::string &propertyName) const
Check if a property &#39;propertyName&#39; exists in this property set.
Definition: YProperty.cc:87
Abstract base class of all UI widgets.
Definition: YWidget.h:54
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
virtual void setCurrentZone(const std::string &zone, bool zoom)=0
subclasses have to implement this to set value
YPropertyType type() const
Returns the type of this property value.
Definition: YProperty.h:169
YTimezoneSelector(YWidget *parent, const std::string &pixmap, const std::map< std::string, std::string > &timezones)
Constructor.