• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MerginMaps / input / 6655250127

26 Oct 2023 02:02PM UTC coverage: 62.234% (-0.07%) from 62.308%
6655250127

push

github

web-flow
Merge pull request #2867 from MerginMaps/other_elems

HTML, Text, Spacer "other form widgets" + "show label"

7483 of 12024 relevant lines covered (62.23%)

122.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.96
/app/attributes/attributedata.cpp
1
/***************************************************************************
2
 attributedata.cpp
3
  --------------------------------------
4
  Date                 : 22.4.2021
5
  Copyright            : (C) 2021 by Peter Petrik
6
  Email                : zilolv@gmail.com
7
 ***************************************************************************
8
 *                                                                         *
9
 *   This program is free software; you can redistribute it and/or modify  *
10
 *   it under the terms of the GNU General Public License as published by  *
11
 *   the Free Software Foundation; either version 2 of the License, or     *
12
 *   (at your option) any later version.                                   *
13
 *                                                                         *
14
 ***************************************************************************/
15

16

17
#include "attributedata.h"
18

19
FormItem::FormItem( const QUuid &id,
100✔
20
                    const QgsField &field,
21
                    const QString &groupName,
22
                    const int parentTabId,
23
                    FormItem::FormItemType type,
24
                    const QString &name,
25
                    bool showName,
26
                    bool isEditable,
27
                    const QgsEditorWidgetSetup &editorWidgetSetup,
28
                    int fieldIndex,
29
                    const QgsExpression &visibilityExpression,
30
                    const QgsRelation &relation
31
                  )
100✔
32
  : mId( id )
100✔
33
  , mField( field )
100✔
34
  , mGroupName( groupName )
100✔
35
  , mParentTabId( parentTabId )
100✔
36
  , mType( type )
100✔
37
  , mName( name )
100✔
38
  , mShowName( showName )
100✔
39
  , mIsEditable( isEditable )
100✔
40
  , mEditorWidgetSetup( editorWidgetSetup )
100✔
41
  , mFieldIndex( fieldIndex )
100✔
42
  , mVisibilityExpression( visibilityExpression )
100✔
43
  , mRelation( relation ) // no relation for type field
100✔
44
{
45
}
100✔
46

47
FormItem *FormItem::createFieldItem( const QUuid &id,
88✔
48
                                     const QgsField &field,
49
                                     const QString &groupName,
50
                                     int parentTabId,
51
                                     const QString &name, bool showName,
52
                                     bool isEditable,
53
                                     const QgsEditorWidgetSetup
54
                                     &editorWidgetSetup,
55
                                     int fieldIndex,
56
                                     const QgsExpression &visibilityExpression
57
                                   )
58
{
59
  return new FormItem(
60
           id,
61
           field,
62
           groupName,
63
           parentTabId,
64
           FormItem::Field,
65
           name,
66
           showName,
67
           isEditable,
68
           editorWidgetSetup,
69
           fieldIndex,
70
           visibilityExpression,
71
           QgsRelation()
176✔
72
         );
176✔
73
}
74

75
FormItem *FormItem::createRelationItem( const QUuid &id,
4✔
76
                                        const QString &groupName,
77
                                        int parentTabId,
78
                                        const QString &name,
79
                                        bool showName,
80
                                        const QgsExpression &visibilityExpression,
81
                                        const QgsRelation &relation
82
                                      )
83
{
84
  FormItem *item = new FormItem(
85
    id,
86
    QgsField(),
8✔
87
    groupName,
88
    parentTabId,
89
    FormItem::Relation,
90
    name,
91
    showName,
92
    true,
93
    QgsEditorWidgetSetup(),
8✔
94
    -1,
95
    visibilityExpression,
96
    relation
97
  );
4✔
98
  return item;
4✔
99
}
100

101
FormItem *FormItem::createSpacerItem(
4✔
102
  const QUuid &id,
103
  const QString &groupName,
104
  int parentTabId,
105
  const QString &name,
106
  bool isHLine,
107
  const QgsExpression &visibilityExpression
108
)
109
{
110
  QVariantMap map;
4✔
111
  map["IsHLine"] = isHLine;
4✔
112
  map["ConfigType"] = "merginmaps-custom-config";
4✔
113
  QgsEditorWidgetSetup config( "spacer", map );
4✔
114

115
  return new FormItem(
116
           id,
117
           QgsField(),
8✔
118
           groupName,
119
           parentTabId,
120
           FormItem::Spacer,
121
           name,
122
           false, // label is never shown for spacer
123
           false,
124
           config,
125
           -1,
126
           visibilityExpression,
127
           QgsRelation()
8✔
128
         );
8✔
129
}
4✔
130

131
FormItem *FormItem::createRichTextItem(
4✔
132
  const QUuid &id,
133
  const QString &groupName,
134
  int parentTabId,
135
  const QString &name,
136
  bool showName,
137
  const QString &text,
138
  bool isHtml,
139
  const QgsExpression &visibilityExpression
140
)
141
{
142
  QVariantMap map;
4✔
143
  map["UseHtml"] = isHtml;
4✔
144
  map["Definition"] = text;
4✔
145
  map["ConfigType"] = "merginmaps-custom-config";
4✔
146

147
  QgsEditorWidgetSetup config( "richtext", map );
4✔
148

149
  FormItem *fi = new FormItem(
150
    id,
151
    QgsField(),
8✔
152
    groupName,
153
    parentTabId,
154
    FormItem::RichText,
155
    name,
156
    showName,
157
    false,
158
    config,
159
    -1,
160
    visibilityExpression,
161
    QgsRelation()
8✔
162
  );
4✔
163

164
  fi->setRawValue( text );
4✔
165
  return fi;
4✔
166
}
4✔
167

168
FormItem::FormItemType FormItem::type() const
2,782✔
169
{
170
  return mType;
2,782✔
171
}
172

173
QString FormItem::name() const
843✔
174
{
175
  return mName;
843✔
176
}
177

178
bool FormItem::isEditable() const
×
179
{
180
  return mIsEditable;
×
181
}
182

183
QString FormItem::editorWidgetType() const
2,289✔
184
{
185
  if ( mType == FormItem::Relation )
2,289✔
186
    return QStringLiteral( "relation" );
4✔
187

188
  return mEditorWidgetSetup.type();
2,285✔
189
}
190

191
QVariantMap FormItem::editorWidgetConfig() const
518✔
192
{
193
  return mEditorWidgetSetup.config();
518✔
194
}
195

196
int FormItem::fieldIndex() const
1,817✔
197
{
198
  return mFieldIndex;
1,817✔
199
}
200

201
QString FormItem::validationMessage() const
889✔
202
{
203
  return mValidationMessage;
889✔
204
}
205

206
void FormItem::setValidationMessage( QString message )
50✔
207
{
208
  mValidationMessage = message;
50✔
209
}
50✔
210

211
FieldValidator::ValidationStatus FormItem::validationStatus() const
80✔
212
{
213
  return mValidationStatus;
80✔
214
}
215

216
void FormItem::setValidationStatus( FieldValidator::ValidationStatus status )
50✔
217
{
218
  mValidationStatus = status;
50✔
219
}
50✔
220

221
bool FormItem::isVisible() const
384✔
222
{
223
  return mVisible;
384✔
224
}
225

226
void FormItem::setVisible( bool visible )
90✔
227
{
228
  mVisible = visible;
90✔
229
}
90✔
230

231
QUuid FormItem::id() const
721✔
232
{
233
  return mId;
721✔
234
}
235

236
int FormItem::parentTabId() const
×
237
{
238
  return mParentTabId;
×
239
}
240

241
QgsExpression FormItem::visibilityExpression() const
824✔
242
{
243
  return mVisibilityExpression;
824✔
244
}
245

246
bool FormItem::visible() const
832✔
247
{
248
  return mVisible;
832✔
249
}
250

251
QgsField FormItem::field() const
2,587✔
252
{
253
  return mField;
2,587✔
254
}
255

256
QString FormItem::groupName() const
6✔
257
{
258
  return mGroupName;
6✔
259
}
260

261
QVariant FormItem::originalValue() const
62✔
262
{
263
  return mOriginalValue;
62✔
264
}
265

266
void FormItem::setOriginalValue( const QVariant &originalValue )
129✔
267
{
268
  mOriginalValue = originalValue;
129✔
269
}
129✔
270

271
QgsRelation FormItem::relation() const
5✔
272
{
273
  return mRelation;
5✔
274
}
275

276
bool FormItem::showName() const
×
277
{
278
  return mShowName;
×
279
}
280

281
QVariant FormItem::rawValue() const
763✔
282
{
283
  return mRawValue;
763✔
284
}
285

286
void FormItem::setRawValue( const QVariant &rawValue )
253✔
287
{
288
  mRawValue = rawValue;
253✔
289
}
253✔
290

291

292
TabItem::TabItem( const int &id,
20✔
293
                  const QString &name,
294
                  const QVector<QUuid> &formItems,
295
                  const QgsExpression &visibilityExpression )
20✔
296
  : mTabIndex( id )
20✔
297
  , mName( name )
20✔
298
  , mFormItems( formItems )
20✔
299
  , mVisibilityExpression( visibilityExpression )
20✔
300
{
301
}
20✔
302

303
QString TabItem::name() const
7✔
304
{
305
  return mName;
7✔
306
}
307

308
bool TabItem::isVisible() const
152✔
309
{
310
  return mVisible;
152✔
311
}
312

313
void TabItem::setVisible( bool visible )
18✔
314
{
315
  mVisible = visible;
18✔
316
}
18✔
317

318
int TabItem::tabIndex() const
44✔
319
{
320
  return mTabIndex;
44✔
321
}
322

323
QgsExpression TabItem::visibilityExpression() const
118✔
324
{
325
  return mVisibilityExpression;
118✔
326
}
327

328
const QVector<QUuid> TabItem::formItems() const
41✔
329
{
330
  return mFormItems;
41✔
331
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc