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

mcallegari / qlcplus / 18357067171

08 Oct 2025 08:16PM UTC coverage: 34.26% (+2.2%) from 32.066%
18357067171

push

github

mcallegari
Merge branch 'master' into filedialog

1282 of 4424 new or added lines in 152 files covered. (28.98%)

1342 existing lines in 152 files now uncovered.

17704 of 51675 relevant lines covered (34.26%)

19430.31 hits per line

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

0.0
/ui/src/virtualconsole/vcwidgetselection.cpp
1
/*
2
  Q Light Controller Plus
3
  vcwidgetselection.cpp
4

5
  Copyright (c) Massimo Callegari
6

7
  Licensed under the Apache License, Version 2.0 (the "License");
8
  you may not use this file except in compliance with the License.
9
  You may obtain a copy of the License at
10

11
      http://www.apache.org/licenses/LICENSE-2.0.txt
12

13
  Unless required by applicable law or agreed to in writing, software
14
  distributed under the License is distributed on an "AS IS" BASIS,
15
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
  See the License for the specific language governing permissions and
17
  limitations under the License.
18
*/
19

20
#include <QPushButton>
21
#include <QDebug>
22
#include <QSettings>
23

24
#include "vcwidgetselection.h"
25
#include "virtualconsole.h"
26
#include "vcframe.h"
27

28
#define KColumnName         0
29
#define KColumnType         1
30

31
#define SETTINGS_GEOMETRY "vcwidgetselection/geometry"
32

UNCOV
33
VCWidgetSelection::VCWidgetSelection(QList<int> filters, QWidget *parent)
×
34
    : QDialog(parent)
35
    , m_filters(filters)
×
36
{
37
    setupUi(this);
×
38

39
    m_tree->setRootIsDecorated(false);
×
40
    m_tree->setSelectionMode(QAbstractItemView::SingleSelection);
×
41
    m_tree->setAllColumnsShowFocus(true);
×
42

NEW
43
    QSettings settings;
×
NEW
44
    QVariant geometrySettings = settings.value(SETTINGS_GEOMETRY);
×
NEW
45
    if (geometrySettings.isValid() == true)
×
NEW
46
        restoreGeometry(geometrySettings.toByteArray());
×
47

UNCOV
48
    connect(m_tree, SIGNAL(itemSelectionChanged()),
×
49
            this, SLOT(slotItemSelectionChanged()));
50
    connect(m_tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
×
51
            this, SLOT(slotItemDoubleClicked(QTreeWidgetItem*)));
52

53
    updateWidgetsTree();
×
54

55
    slotItemSelectionChanged();
×
56
}
×
57

58
VCWidgetSelection::~VCWidgetSelection()
×
59
{
NEW
60
    QSettings settings;
×
NEW
61
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
UNCOV
62
}
×
63

64
VCWidget *VCWidgetSelection::getSelectedWidget()
×
65
{
66
    int selIdx = m_tree->currentIndex().row();
×
67
    if (selIdx >= 0)
×
68
        return m_widgetsList.at(selIdx);
×
69
    return NULL;
×
70
}
71

72
QList<VCWidget *> VCWidgetSelection::getChildren(VCWidget *obj)
×
73
{
74
    QList<VCWidget *> list;
×
75
    if (obj == NULL)
×
76
        return list;
×
77
    QListIterator <VCWidget*> it(obj->findChildren<VCWidget*>());
×
78
    while (it.hasNext() == true)
×
79
    {
80
        VCWidget* child = it.next();
×
81
        qDebug() << Q_FUNC_INFO << "append: " << child->caption();
×
82
        if (m_filters.isEmpty() || m_filters.contains(child->type()))
×
83
            list.append(child);
×
84
    }
85
    return list;
×
UNCOV
86
}
×
87

88
void VCWidgetSelection::updateWidgetsTree()
×
89
{
90
    VCFrame *contents = VirtualConsole::instance()->contents();
×
91
    m_widgetsList = getChildren(contents);
×
92

93
    foreach (QObject *object, m_widgetsList)
×
94
    {
95
        VCWidget *widget = qobject_cast<VCWidget *>(object);
×
96

97
        QTreeWidgetItem *item = new QTreeWidgetItem(m_tree);
×
98
        item->setText(KColumnName, widget->caption());
×
99
        item->setIcon(KColumnName, VCWidget::typeToIcon(widget->type()));
×
100
        item->setText(KColumnType, VCWidget::typeToString(widget->type()));
×
UNCOV
101
    }
×
102
}
×
103

104
void VCWidgetSelection::slotItemSelectionChanged()
×
105
{
106
    if (m_tree->currentIndex().row() < 0)
×
107
    {
108
        // No widget selected
109
        m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
×
110
    }
111
    else
112
        m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
×
113
}
×
114

115
void VCWidgetSelection::slotItemDoubleClicked(QTreeWidgetItem* item)
×
116
{
117
    if (item == NULL)
×
118
        return;
×
119

120
    accept();
×
121
}
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