Change copyrights from Nokia to Digia
[profile/ivi/qtxmlpatterns.git] / tests / auto / xmlpatternsview / view / MainWindow.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef PatternistSDK_MainWindow_H
43 #define PatternistSDK_MainWindow_H
44
45 #include <QtDebug>
46 #include <QUrl>
47
48 #include "ui_ui_MainWindow.h"
49 #include "DebugExpressionFactory.h"
50 #include "TestSuite.h"
51
52 QT_BEGIN_HEADER
53
54 QT_BEGIN_NAMESPACE
55
56 namespace QPatternistSDK
57 {
58     class FunctionSignaturesView;
59     class TestCase;
60     class TestCaseView;
61     class TestResultView;
62     class TreeModel;
63     class UserTestCase;
64
65     /**
66      * @short The main window of the PatternistSDKView application.
67      *
68      * MainWindow is heavily influenced by Qt's examples covering recent files,
69      * main window usage, QSettings, and other central parts.
70      *
71      * @ingroup PatternistSDK
72      * @author Frans Englich <frans.englich@nokia.com>
73      */
74     class MainWindow : public QMainWindow,
75                        private Ui_MainWindow
76     {
77         Q_OBJECT
78     public:
79         MainWindow();
80         virtual ~MainWindow();
81
82         /**
83          * Takes care of saving QSettings.
84          */
85         virtual void closeEvent(QCloseEvent *event);
86
87     Q_SIGNALS:
88         /**
89          * Emitted whenever a test case is selected. The test case
90          * selected is @p tc. If something that wasn't a test case
91          * was selected, such as a test group or that a new test suite was
92          * opened, @p tc is @c null.
93          */
94         void testCaseSelected(TestCase *const tc);
95
96     private Q_SLOTS:
97         /**
98          * The Open action calls this slot. It is responsible
99          * for opening a test suite catalog file.
100          */
101         void on_actionOpen_triggered();
102
103         void on_actionOpenXSLTSCatalog_triggered();
104
105         void on_actionOpenXSDTSCatalog_triggered();
106
107         /**
108          * Executes the selected test case or test group.
109          */
110         void on_actionExecute_triggered();
111
112         /**
113          * @param file the name of the catalog to open.
114          * @param reportError whether the user should be notified about a loading error. If @c true,
115          * an informative message box will be displayed, if any errors occurred.
116          */
117         void openCatalog(const QUrl &file, const bool reportError,
118                          const TestSuite::SuiteType suitType);
119
120         void openRecentFile();
121
122         void on_testSuiteView_clicked(const QModelIndex &index);
123
124         void on_sourceTab_currentChanged(int index);
125         void on_sourceInput_textChanged();
126
127         /**
128          * Restarts the program by executing restartApplication.sh loaded as a QResource file,
129          * combined with shutting down this instance.
130          */
131         void on_actionRestart_triggered();
132
133         void writeSettings();
134
135     private:
136         /**
137          * Saves typing a long line.
138          *
139          * @returns the source model the index in the proxy @p proxyIndex corresponds to.
140          */
141         inline QModelIndex sourceIndex(const QModelIndex &proxyIndex) const;
142
143         /**
144          * Saves typing a long line.
145          *
146          * @returns the source model for the test suite view, by walking through the
147          * proxy model.
148          */
149         inline TreeModel *sourceModel() const;
150
151         void setupMenu();
152         void setupActions();
153         void readSettings();
154         void setCurrentFile(const QUrl &fileName);
155         void updateRecentFileActions();
156
157         UserTestCase *const         m_userTC;
158
159         enum {MaximumRecentFiles = 5};
160         QAction *                   m_recentFileActs[MaximumRecentFiles];
161
162         /**
163          * The current selected test case.
164          */
165         TestCase *                  m_currentTC;
166         QUrl                        m_previousOpenedCatalog;
167         TestCaseView *              testCaseView;
168         TestResultView *            testResultView;
169         FunctionSignaturesView *    functionView;
170         TestSuite::SuiteType        m_currentSuiteType;
171     };
172 }
173 QT_END_NAMESPACE
174
175 QT_END_HEADER
176
177 #endif
178 // vim: et:ts=4:sw=4:sts=4