1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the test suite of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include <QHeaderView>
45 #include "ErrorItem.h"
47 #include "TestResult.h"
48 #include "TreeModel.h"
49 #include "XDTItemItem.h"
51 #include "TestResultView.h"
53 using namespace QPatternistSDK;
55 TestResultView::TestResultView(QWidget *const p) : QDockWidget(QLatin1String("Test Result View"), p)
58 setObjectName(QLatin1String("TestResultView"));
59 setWidget(new QWidget());
62 QStringList astColumns;
63 astColumns << QLatin1String("Node Name")
64 << QLatin1String("Details")
65 << QLatin1String("Static Type")
66 << QLatin1String("Required Type");
67 astView->setModel(new TreeModel(astColumns, this));
69 QStringList itemColumns;
70 itemColumns << QLatin1String("#")
71 << QLatin1String("Value")
72 << QLatin1String("Type");
73 itemListResult->setModel(new TreeModel(itemColumns, this));
75 QStringList errColumns;
76 errColumns << QLatin1String("Severity")
77 << QLatin1String("Error Code")
78 << QLatin1String("Message");
79 messageOutput->setModel(new TreeModel(errColumns, this));
80 messageOutput->horizontalHeader()->setStretchLastSection(true);
83 void TestResultView::displayTestResult(const TestResult *const result)
91 /* ------- the Test Status Label --------- */
92 resultStatus->setText(result->status() ? TestResult::displayName(result->status())
93 : QLatin1String("Not Applicable"));
94 /* --------------------------------------- */
96 /* ------------ the AST View ------------- */
97 ASTItem *astTree = result->astTree();
98 static_cast<TreeModel *>(astView->model())->setRoot(astTree);
99 /* --------------------------------------- */
101 /* ------- the Error code/msg View ------- */
102 ErrorItem *msgRoot = new ErrorItem(ErrorHandler::Message(), 0);
104 const ErrorHandler::Message::List msgs(result->messages());
105 ErrorHandler::Message::List::const_iterator it(msgs.constBegin());
106 const ErrorHandler::Message::List::const_iterator end(msgs.constEnd());
108 for(; it != end; ++it)
109 msgRoot->appendChild(new ErrorItem(*it, msgRoot));
111 TreeModel *etm = static_cast<TreeModel *>(messageOutput->model());
112 etm->setRoot(msgRoot);
113 /* --------------------------------------- */
115 const QPatternist::Item::List items(result->items());
116 /* ----- the Serialized Output View ------ */
117 serializedResult->setPlainText(result->asSerialized());
118 /* --------------------------------------- */
120 /* ------ the Item List Output View ------ */
121 XDTItemItem *itemRoot = new XDTItemItem(QPatternist::Item(), 0);
122 QPatternist::Item item;
124 QPatternist::Item::List::const_iterator itemIt(items.constBegin());
125 const QPatternist::Item::List::const_iterator itemsEnd(items.constEnd());
127 for(; itemIt != itemsEnd; ++itemIt)
128 itemRoot->appendChild(new XDTItemItem(*itemIt, itemRoot));
130 TreeModel *itm = static_cast<TreeModel *>(itemListResult->model());
131 itm->setRoot(itemRoot);
132 /* --------------------------------------- */
135 void TestResultView::displayTestResult(TestCase *const tc)
138 displayTestResult(tc->testResult());
143 void TestResultView::displayNone()
147 tm = static_cast<TreeModel *>(astView->model());
151 tm = static_cast<TreeModel *>(messageOutput->model());
155 tm = static_cast<TreeModel *>(itemListResult->model());
159 serializedResult->clear();
160 resultStatus->clear();
163 // vim: et:ts=4:sw=4:sts=4