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

umbrello/umbrello

  • sources
  • kde-4.14
  • kdesdk
  • umbrello
  • umbrello
optionstate.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * This program is free software; you can redistribute it and/or modify *
3  * it under the terms of the GNU General Public License as published by *
4  * the Free Software Foundation; either version 2 of the License, or *
5  * (at your option) any later version. *
6  * *
7  * copyright (C) 2006-2014 *
8  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9  ***************************************************************************/
10 
11 #include "optionstate.h"
12 
13 #include <kglobal.h>
14 
15 namespace Settings {
16 
17  /*
18  * Impt: This ensures creation of OptionState object after
19  * QApplication thereby avoiding nasty font rendering issues
20  * which occurs due to creation of QFont objects before
21  * QApplication object is created.
22  */
23  K_GLOBAL_STATIC(OptionState, opState)
24 
25  OptionState& optionState()
26  {
27  return *opState;
28  }
29 
30  void setOptionState(const OptionState& optstate)
31  {
32  *opState = optstate;
33  }
34 
35  void saveToXMI(QDomElement& element, const OptionState& optstate)
36  {
37  // uistate
38  element.setAttribute(QLatin1String("usefillcolor"), optstate.uiState.useFillColor);
39  element.setAttribute(QLatin1String("fillcolor"), optstate.uiState.fillColor.name());
40  element.setAttribute(QLatin1String("linecolor"), optstate.uiState.lineColor.name());
41  element.setAttribute(QLatin1String("linewidth"), optstate.uiState.lineWidth);
42  element.setAttribute(QLatin1String("textcolor"), optstate.uiState.textColor.name());
43  element.setAttribute(QLatin1String("font"), optstate.uiState.font.toString());
44  element.setAttribute(QLatin1String("backgroundcolor"), optstate.uiState.backgroundColor.name());
45  element.setAttribute(QLatin1String("griddotcolor"), optstate.uiState.gridDotColor.name());
46  // classstate
47  element.setAttribute(QLatin1String("showattsig"), optstate.classState.showAttSig);
48  element.setAttribute(QLatin1String("showatts"), optstate.classState.showAtts);
49  element.setAttribute(QLatin1String("showopsig"), optstate.classState.showOpSig);
50  element.setAttribute(QLatin1String("showops"), optstate.classState.showOps);
51  element.setAttribute(QLatin1String("showpackage"), optstate.classState.showPackage);
52  element.setAttribute(QLatin1String("showattribassocs"), optstate.classState.showAttribAssocs);
53  element.setAttribute(QLatin1String("showpubliconly"), optstate.classState.showPublicOnly);
54  element.setAttribute(QLatin1String("showscope"), optstate.classState.showVisibility);
55  element.setAttribute(QLatin1String("showstereotype"), optstate.classState.showStereoType);
56  }
57 
58  bool loadFromXMI(QDomElement& element, OptionState& optstate)
59  {
60  // uistate
61  QString usefillcolor = element.attribute(QLatin1String("usefillcolor"), QLatin1String("0"));
62  optstate.uiState.useFillColor = (bool)usefillcolor.toInt();
63  QString fillcolor = element.attribute(QLatin1String("fillcolor"));
64  if (!fillcolor.isEmpty())
65  optstate.uiState.fillColor = QColor(fillcolor);
66  QString linecolor = element.attribute(QLatin1String("linecolor"));
67  if (!linecolor.isEmpty())
68  optstate.uiState.lineColor = QColor(linecolor);
69  QString linewidth = element.attribute(QLatin1String("linewidth"));
70  if (!linewidth.isEmpty())
71  optstate.uiState.lineWidth = linewidth.toInt();
72  QString textColor = element.attribute(QLatin1String("textcolor"));
73  if (!textColor.isEmpty())
74  optstate.uiState.textColor = QColor(textColor);
75  QString font = element.attribute(QLatin1String("font"));
76  if (!font.isEmpty()) {
77  optstate.uiState.font.fromString(font);
78  optstate.uiState.font.setUnderline(false);
79  }
80  QString backgroundColor = element.attribute(QLatin1String("backgroundcolor"));
81  if (!backgroundColor.isEmpty())
82  optstate.uiState.backgroundColor = QColor(backgroundColor);
83  QString gridDotColor = element.attribute(QLatin1String("griddotcolor"));
84  if (!gridDotColor.isEmpty())
85  optstate.uiState.gridDotColor = QColor(gridDotColor);
86  // classstate
87  QString temp = element.attribute(QLatin1String("showattsig"), QLatin1String("0"));
88  optstate.classState.showAttSig = (bool)temp.toInt();
89  temp = element.attribute(QLatin1String("showatts"), QLatin1String("0"));
90  optstate.classState.showAtts = (bool)temp.toInt();
91  temp = element.attribute(QLatin1String("showopsig"), QLatin1String("0"));
92  optstate.classState.showOpSig = (bool)temp.toInt();
93  temp = element.attribute(QLatin1String("showops"), QLatin1String("0"));
94  optstate.classState.showOps = (bool)temp.toInt();
95  temp = element.attribute(QLatin1String("showpackage"), QLatin1String("0"));
96  optstate.classState.showPackage = (bool)temp.toInt();
97  temp = element.attribute(QLatin1String("showattribassocs"), QLatin1String("0"));
98  optstate.classState.showAttribAssocs = (bool)temp.toInt();
99  temp = element.attribute(QLatin1String("showscope"), QLatin1String("0"));
100  optstate.classState.showVisibility = (bool)temp.toInt();
101  temp = element.attribute(QLatin1String("showstereotype"), QLatin1String("0"));
102  optstate.classState.showStereoType = (bool)temp.toInt();
103  temp = element.attribute(QLatin1String("showpubliconly"), QLatin1String("0"));
104  optstate.classState.showPublicOnly = (bool)temp.toInt();
105 
106  return true;
107  }
108 
109 } // namespace Settings
Settings::UIState::lineWidth
uint lineWidth
Definition: optionstate.h:55
Settings::UIState::lineColor
QColor lineColor
Definition: optionstate.h:54
Settings::ClassState::showOpSig
bool showOpSig
Definition: optionstate.h:68
Settings::optionState
OptionState & optionState()
Definition: optionstate.cpp:25
QColor::name
QString name() const
QDomElement::attribute
QString attribute(const QString &name, const QString &defValue) const
Settings::ClassState::showOps
bool showOps
Definition: optionstate.h:65
Settings::ClassState::showAtts
bool showAtts
Definition: optionstate.h:64
QFont::setUnderline
void setUnderline(bool enable)
Settings::ClassState::showPublicOnly
bool showPublicOnly
Definition: optionstate.h:71
Settings::loadFromXMI
bool loadFromXMI(QDomElement &element, OptionState &optstate)
Definition: optionstate.cpp:58
Settings::OptionState
Definition: optionstate.h:142
Settings::UIState::fillColor
QColor fillColor
Definition: optionstate.h:53
QFont::fromString
bool fromString(const QString &descrip)
optionstate.h
QDomElement::setAttribute
void setAttribute(const QString &name, const QString &value)
Settings::ClassState::showPackage
bool showPackage
Definition: optionstate.h:69
Settings::UIState::gridDotColor
QColor gridDotColor
Definition: optionstate.h:59
QString::toInt
int toInt(bool *ok, int base) const
QString::isEmpty
bool isEmpty() const
Settings::ClassState::showStereoType
bool showStereoType
Definition: optionstate.h:66
QString
QColor
Settings::OptionState::uiState
UIState uiState
Definition: optionstate.h:144
Settings::UIState::textColor
QColor textColor
Definition: optionstate.h:56
Settings::saveToXMI
void saveToXMI(QDomElement &element, const OptionState &optstate)
Definition: optionstate.cpp:35
QFont::toString
QString toString() const
QLatin1String
Settings::UIState::useFillColor
bool useFillColor
Definition: optionstate.h:52
Settings::UIState::backgroundColor
QColor backgroundColor
Definition: optionstate.h:58
Settings::UIState::font
QFont font
Definition: optionstate.h:57
Settings::setOptionState
void setOptionState(const OptionState &optstate)
Definition: optionstate.cpp:30
Settings::ClassState::showVisibility
bool showVisibility
Definition: optionstate.h:63
QDomElement
Settings::OptionState::classState
ClassState classState
Definition: optionstate.h:145
Settings::ClassState::showAttribAssocs
bool showAttribAssocs
Definition: optionstate.h:70
Settings::ClassState::showAttSig
bool showAttSig
Definition: optionstate.h:67
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:40:26 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

umbrello/umbrello

Skip menu "umbrello/umbrello"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • umbrello
  •   umbrello

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