SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
DateTimeItemDefinition.h
1 //=========================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //=========================================================================
10 // .NAME DateTimeItemDefinition.h -
11 // .SECTION Description
12 // .SECTION See Also
13 
14 #ifndef smtk_attribute_DateTimeItemDefinition_h
15 #define smtk_attribute_DateTimeItemDefinition_h
16 
17 #include "smtk/attribute/ItemDefinition.h"
18 #include "smtk/common/DateTimeZonePair.h"
19 #include <string>
20 
21 namespace smtk
22 {
23 namespace attribute
24 {
25 class SMTKCORE_EXPORT DateTimeItemDefinition : public ItemDefinition
26 {
27 public:
29  static smtk::attribute::DateTimeItemDefinitionPtr New(const std::string& myName)
30  {
32  }
33 
34  ~DateTimeItemDefinition() override;
35  Item::Type type() const override;
36 
37  const ::smtk::common::DateTimeZonePair& defaultValue() const { return m_defaultValue; }
38  bool setDefaultValue(const ::smtk::common::DateTimeZonePair& value);
39  bool hasDefault() const { return m_hasDefault; }
40 
41  std::size_t numberOfRequiredValues() const { return m_numberOfRequiredValues; }
42  bool setNumberOfRequiredValues(std::size_t esize);
43 
44  bool isValueValid(const ::smtk::common::DateTimeZonePair& value) const;
45 
46  // Returns or sets the display format to use in UI elements.
47  // SMTK uses the Qt datetime format expressions documented at
48  // http://doc.qt.io/qt-4.8/qdatetime.html#toString
49  void setDisplayFormat(const std::string& format) { m_displayFormat = format; }
50  std::string displayFormat() const { return m_displayFormat; }
51 
52  // Returns or sets flag indicating if a time zone component can be included
53  // in the item representation. When set, the UI will include an option to
54  // specify a TimeZone with the DateTime data.
55  void setUseTimeZone(bool mode) { m_useTimeZone = mode; }
56  bool useTimeZone() const { return m_useTimeZone; }
57 
58  // Returns or sets flag specifying if UI components include
59  // a pop-up calendar widget.
60  void setEnableCalendarPopup(bool mode) { m_useCalendarPopup = mode; }
61  bool useCalendarPopup() const { return m_useCalendarPopup; }
62 
63  smtk::attribute::ItemPtr buildItem(Attribute* owningAttribute, int itemPosition) const override;
64  smtk::attribute::ItemPtr buildItem(Item* owningItem, int position, int subGroupPosition)
65  const override;
66 
68  smtk::attribute::ItemDefinition::CopyInfo& info) const override;
69 
70 protected:
71  DateTimeItemDefinition(const std::string& myName);
72 
73  ::smtk::common::DateTimeZonePair m_defaultValue;
74  bool m_hasDefault;
75  std::size_t m_numberOfRequiredValues;
76 
77  // Specifies format string to use in item UI.
78  std::string m_displayFormat;
79 
80  // Specifies whether to include TimeZone option in item UI.
81  bool m_useTimeZone;
82 
83  // Specifies whether to include calendar popup in item UI.
84  bool m_useCalendarPopup;
85 
86 private:
87 };
88 } // namespace attribute
89 } // namespace smtk
90 
91 #endif /* smtk_attribute_DateTimeItemDefinition_h */
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
smtk::attribute::Item::Type
Type
Definition: Item.h:52
smtk::attribute::DateTimeItemDefinition
Definition: DateTimeItemDefinition.h:25
smtk::attribute::ItemDefinition
Definition: ItemDefinition.h:37
smtk::attribute::ItemDefinition::CopyInfo
Definition: ItemDefinition.h:47
smtk::attribute::Item
Definition: Item.h:43
smtkTypeMacro
#define smtkTypeMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:51
smtk::attribute::DateTimeItemDefinitionPtr
smtk::shared_ptr< smtk::attribute::DateTimeItemDefinition > DateTimeItemDefinitionPtr
Definition: PublicPointerDefs.h:489
smtk::common::DateTimeZonePair
Definition: DateTimeZonePair.h:24
smtk::attribute::Attribute
Represent a (possibly composite) value according to a definition.
Definition: Attribute.h:49
smtk::attribute::ItemPtr
smtk::shared_ptr< smtk::attribute::Item > ItemPtr
Definition: PublicPointerDefs.h:467
smtk::attribute::ItemDefinitionPtr
smtk::shared_ptr< smtk::attribute::ItemDefinition > ItemDefinitionPtr
Definition: PublicPointerDefs.h:473