QElectroTech  0.70
borderproperties.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "borderproperties.h"
19 
27  columns_count(17),
28  columns_width(60.0),
29  columns_header_height(20.0),
30  display_columns(true),
31  rows_count(8),
32  rows_height(80.0),
33  rows_header_width(20.0),
34  display_rows(true)
35 {
36 }
37 
42 }
43 
49  return(
54  bp.rows_count == rows_count &&\
55  bp.rows_height == rows_height &&\
58  );
59 }
60 
66  return(!(*this == bp));
67 }
68 
73 void BorderProperties::toXml(QDomElement &e) const {
74  e.setAttribute("cols", columns_count);
75  e.setAttribute("colsize", QString("%1").arg(columns_width));
76  e.setAttribute("rows", rows_count);
77  e.setAttribute("rowsize", QString("%1").arg(rows_height));
78  e.setAttribute("displaycols", display_columns ? "true" : "false");
79  e.setAttribute("displayrows", display_rows ? "true" : "false");
80 }
81 
86 void BorderProperties::fromXml(QDomElement &e) {
87  if (e.hasAttribute("cols")) columns_count = e.attribute("cols").toInt();
88  if (e.hasAttribute("colsize")) columns_width = e.attribute("colsize").toInt();
89  if (e.hasAttribute("rows")) rows_count = e.attribute("rows").toInt();
90  if (e.hasAttribute("rowsize")) rows_height = e.attribute("rowsize").toInt();
91  if (e.hasAttribute("displaycols")) display_columns = e.attribute("displaycols") == "true";
92  if (e.hasAttribute("displayrows")) display_rows = e.attribute("displayrows") == "true";
93 }
94 
100 void BorderProperties::toSettings(QSettings &settings, const QString &prefix) const {
101  settings.setValue(prefix + "cols", columns_count);
102  settings.setValue(prefix + "colsize", columns_width);
103  settings.setValue(prefix + "displaycols", display_columns);
104  settings.setValue(prefix + "rows", rows_count);
105  settings.setValue(prefix + "rowsize", rows_height);
106  settings.setValue(prefix + "displayrows", display_rows);
107 }
108 
114 void BorderProperties::fromSettings(QSettings &settings, const QString &prefix) {
115  columns_count = settings.value(prefix + "cols", columns_count).toInt();
116  columns_width = qRound(settings.value(prefix + "colsize", columns_width).toDouble());
117  display_columns = settings.value(prefix + "displaycols", display_columns).toBool();
118 
119  rows_count = settings.value(prefix + "rows", rows_count).toInt();
120  rows_height = qRound(settings.value(prefix + "rowsize", rows_height).toDouble());
121  display_rows = settings.value(prefix + "displayrows", display_rows).toBool();
122 }
123 
129 {
130  QSettings settings;
131 
132  BorderProperties def;
133  def.fromSettings(settings, "diagrameditor/default");
134 
135  return(def);
136 }
virtual ~BorderProperties()
void toXml(QDomElement &) const
qreal columns_width
Columns width.
qreal columns_header_height
Column headers height.
void fromSettings(QSettings &, const QString &=QString())
static BorderProperties defaultProperties()
BorderProperties::defaultProperties.
bool operator!=(const BorderProperties &)
bool operator==(const BorderProperties &)
qreal rows_height
Rows height.
void toSettings(QSettings &, const QString &=QString()) const
int columns_count
Columns count.
bool display_rows
Whether to display row headers.
void fromXml(QDomElement &)
qreal rows_header_width
Row headers width.
int rows_count
Rows count.
bool display_columns
Whether to display column headers.