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

mcallegari / qlcplus / 6683238402

29 Oct 2023 12:10PM UTC coverage: 28.07%. Remained the same
6683238402

push

github

mcallegari
engine: fix build

15385 of 54809 relevant lines covered (28.07%)

20267.63 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

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

27
#define KColumnName         0
28
#define KColumnType         1
29

30
VCWidgetSelection::VCWidgetSelection(QList<int> filters, QWidget *parent)
×
31
    : QDialog(parent)
32
    , m_filters(filters)
×
33
{
34
    setupUi(this);
×
35

36
    m_tree->setRootIsDecorated(false);
×
37
    m_tree->setSelectionMode(QAbstractItemView::SingleSelection);
×
38
    m_tree->setAllColumnsShowFocus(true);
×
39

40
    connect(m_tree, SIGNAL(itemSelectionChanged()),
×
41
            this, SLOT(slotItemSelectionChanged()));
42
    connect(m_tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
×
43
            this, SLOT(slotItemDoubleClicked(QTreeWidgetItem*)));
44

45
    updateWidgetsTree();
×
46

47
    slotItemSelectionChanged();
×
48
}
×
49

50
VCWidgetSelection::~VCWidgetSelection()
×
51
{
52

53
}
×
54

55
VCWidget *VCWidgetSelection::getSelectedWidget()
×
56
{
57
    int selIdx = m_tree->currentIndex().row();
×
58
    if (selIdx >= 0)
×
59
        return m_widgetsList.at(selIdx);
×
60
    return NULL;
×
61
}
62

63
QList<VCWidget *> VCWidgetSelection::getChildren(VCWidget *obj)
×
64
{
65
    QList<VCWidget *> list;
×
66
    if (obj == NULL)
×
67
        return list;
×
68
    QListIterator <VCWidget*> it(obj->findChildren<VCWidget*>());
×
69
    while (it.hasNext() == true)
×
70
    {
71
        VCWidget* child = it.next();
×
72
        qDebug() << Q_FUNC_INFO << "append: " << child->caption();
×
73
        if (m_filters.isEmpty() || m_filters.contains(child->type()))
×
74
            list.append(child);
×
75
    }
76
    return list;
×
77
}
78

79
void VCWidgetSelection::updateWidgetsTree()
×
80
{
81
    VCFrame *contents = VirtualConsole::instance()->contents();
×
82
    m_widgetsList = getChildren(contents);
×
83

84
    foreach (QObject *object, m_widgetsList)
×
85
    {
86
        VCWidget *widget = qobject_cast<VCWidget *>(object);
×
87

88
        QTreeWidgetItem *item = new QTreeWidgetItem(m_tree);
×
89
        item->setText(KColumnName, widget->caption());
×
90
        item->setIcon(KColumnName, VCWidget::typeToIcon(widget->type()));
×
91
        item->setText(KColumnType, VCWidget::typeToString(widget->type()));
×
92
    }
93
}
×
94

95
void VCWidgetSelection::slotItemSelectionChanged()
×
96
{
97
    if (m_tree->currentIndex().row() < 0)
×
98
    {
99
        // No widget selected
100
        m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
×
101
    }
102
    else
103
        m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
×
104
}
×
105

106
void VCWidgetSelection::slotItemDoubleClicked(QTreeWidgetItem* item)
×
107
{
108
    if (item == NULL)
×
109
        return;
×
110

111
    accept();
×
112
}
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