testtreeview.cpp 3.28 KB
Newer Older
Christian Stenger's avatar
Christian Stenger committed
1
2
/****************************************************************************
**
Christian Stenger's avatar
Christian Stenger committed
3
** Copyright (C) 2015 The Qt Company Ltd
Christian Stenger's avatar
Christian Stenger committed
4
** All rights reserved.
Christian Stenger's avatar
Christian Stenger committed
5
6
** For any questions to The Qt Company, please use contact form at
** http://www.qt.io/contact-us
Christian Stenger's avatar
Christian Stenger committed
7
8
9
10
11
12
**
** This file is part of the Qt Creator Enterprise Auto Test Add-on.
**
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
Christian Stenger's avatar
Christian Stenger committed
13
** a written agreement between you and The Qt Company.
Christian Stenger's avatar
Christian Stenger committed
14
15
**
** If you have questions regarding the use of this file, please use
Christian Stenger's avatar
Christian Stenger committed
16
** contact form at http://www.qt.io/contact-us
Christian Stenger's avatar
Christian Stenger committed
17
18
19
20
21
**
****************************************************************************/

#include "autotestconstants.h"
#include "testcodeparser.h"
22
#include "testrunner.h"
Christian Stenger's avatar
Christian Stenger committed
23
#include "testtreeitem.h"
24
#include "testtreeitemdelegate.h"
Christian Stenger's avatar
Christian Stenger committed
25
26
27
#include "testtreemodel.h"
#include "testtreeview.h"

28
#include <coreplugin/coreconstants.h>
Christian Stenger's avatar
Christian Stenger committed
29
30
#include <coreplugin/icore.h>

31
32
#include <coreplugin/find/itemviewfind.h>

Christian Stenger's avatar
Christian Stenger committed
33
34
35
36
37
#include <cpptools/cppmodelmanager.h>

#include <projectexplorer/project.h>
#include <projectexplorer/session.h>

38
39
#include <qmljstools/qmljsmodelmanager.h>

Christian Stenger's avatar
Christian Stenger committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <texteditor/texteditor.h>

#include <QToolButton>
#include <QVBoxLayout>

namespace Autotest {
namespace Internal {

TestTreeView::TestTreeView(QWidget *parent)
    : NavigationTreeView(parent),
      m_context(new Core::IContext(this))
{
    setExpandsOnDoubleClick(false);
    m_context->setWidget(this);
    m_context->setContext(Core::Context(Constants::AUTOTEST_CONTEXT));
    Core::ICore::addContextObject(m_context);
}

void TestTreeView::selectAll()
{
60
    changeCheckStateAll(Qt::Checked);
Christian Stenger's avatar
Christian Stenger committed
61
62
63
64
}

void TestTreeView::deselectAll()
{
65
    changeCheckStateAll(Qt::Unchecked);
Christian Stenger's avatar
Christian Stenger committed
66
67
68
}

// this avoids the re-evaluation of parent nodes when modifying the child nodes (setData())
69
void TestTreeView::changeCheckStateAll(const Qt::CheckState checkState)
Christian Stenger's avatar
Christian Stenger committed
70
{
71
    const TestTreeModel *model = TestTreeModel::instance();
72

73
74
    // 3 == Auto Tests, Quick Tests and Google Tests - must be raised if there will be others
    for (int rootRow = 0; rootRow < 3; ++rootRow) {
75
76
77
78
79
80
81
82
83
84
        QModelIndex currentRootIndex = model->index(rootRow, 0, rootIndex());
        if (!currentRootIndex.isValid())
            return;
        int count = model->rowCount(currentRootIndex);
        QModelIndex last;
        for (int classesRow = 0; classesRow < count; ++classesRow) {
            const QModelIndex classesIndex = model->index(classesRow, 0, currentRootIndex);
            int funcCount = model->rowCount(classesIndex);
            TestTreeItem *item = static_cast<TestTreeItem *>(classesIndex.internalPointer());
            if (item) {
Christian Stenger's avatar
Christian Stenger committed
85
                item->setChecked(checkState);
86
87
88
89
90
91
92
93
94
                if (!item->childCount())
                    last = classesIndex;
            }
            for (int functionRow = 0; functionRow < funcCount; ++functionRow) {
                last = model->index(functionRow, 0, classesIndex);
                TestTreeItem *item = static_cast<TestTreeItem *>(last.internalPointer());
                if (item)
                    item->setChecked(checkState);
            }
Christian Stenger's avatar
Christian Stenger committed
95
        }
96
        emit dataChanged(currentRootIndex, last);
Christian Stenger's avatar
Christian Stenger committed
97
98
99
100
101
    }
}

} // namespace Internal
} // namespace Autotest