Fix no newlines warnings. Patch by Peter Oberndorfer
[kdevelopdvcssupport.git] / veritas / mainpage_
blobf7dc8675a2616c14842b1d08fadf4214d4e79329
1 /* KDevelop xUnit plugin
2  *
3  * Copyright 2006 systest.ch <qxrunner@systest.ch>
4  * Copyright 2008 Manuel Breugelmans <mbr.nxi@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
22 // WARNING this documentation is completly outdated
23 // TODO update it
25 /*!
26  * \file  mainpage.h
27  *
28  * \brief Contains documentation.
29  *
30  * This file contains text and doxygen formatting commands for the
31  * \ref main "Main Page" and other parts of the API documentation.
32  */
34 /*!<!--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-->*/
36 /*!
37 \page license License
38 \verbatim
40 QxRunner Library
41 Copyright (C) 2006 systest.ch
43 This library is free software; you can redistribute it and/or modify it under
44 the terms of the GNU Lesser General Public License as published by the Free
45 Software Foundation; either version 2.1 of the License, or (at your option)
46 any later version.
48 This library is distributed in the hope that it will be useful, but WITHOUT
49 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
50 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
51 details.
53 You should have received a copy of the GNU Lesser General Public License
54 along with this library; if not, write to the Free Software Foundation, Inc.,
55 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
57 \endverbatim
61 namespace QxRunner   // Enables doxygen to create links to documented items
65 /*!<!--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-->*/
67 /*!
68 \mainpage
70 \image html qxrunner_64x64.png
72 <!------------------------------------------------------------------->
74 \section intro Introduction
76 The QxRunner library helps in developing small C++ GUI applications
77 where the user can select from a list of items for execution. Each
78 executed item returns a result which is displayed accordingly. By
79 subclassing from RunnerModel and RunnerItem it is possible to create
80 this type of GUI application with little effort.
82 The library is based on the model/view framework of Qt. It is
83 recommended to become familiar with this framework before writing
84 QxRunner applications.
87 /*!<!--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-->*/
89 /*!
90 \page runner_model_item Runner Model and Runner Item
92 RunnerModel and RunnerItem are the two classes of most interest for
93 those wanting to write their own QxRunner based program. By subclassing
94 these classes and linking with the QxRunner library one has the program
95 ready.
97 These sections give some insight into these classes. Please also read
98 the RunnerModel and RunnerItem description .
100 <!------------------------------------------------------------------->
102 \section runner_model The Runner Model
104 The RunnerModel class implements a tree model with the data contained
105 in RunnerItem objects. At initialization time the model gets populated
106 with RunnerItem objects that are linked together in a pointer-based tree
107 structure or in a less complex non-hierarchical list. Thus RunnerModel
108 isn't limited to represent tree strucutures only. A simple
109 non-hierarchical list can be seen as a tree structure with parent items
110 only that have no child items.
112 Generally, a RunnerItem has a parent item, and can have a number of
113 child items. Each RunnerItem object contains information about its place
114 in the tree structure, it can return its parent item and its row number.
115 The use of a pointer-based tree structure allows to store the runner
116 item object pointer in the QModelIndex which refers to the runner item.
117 Use QModelIndex's \c internalPointer() method to get the pointer.
119 There must be a root item in the tree structure of the model which is
120 the top level parent of all runner items. The root item has no parent
121 item. It is never referenced outside the model but defines the number
122 of columns and the column headers for the views attached to the model.
123 Although the root item is automatically assigned a row number of 0,
124 this information is never used by the model.
126 The model can run code in the runner items and observe their execution.
127 Signals are fired to inform the environment about ongoing execution
128 status. The current model implementation only executes code in items
129 which have no children, but this could change in the future. Therefore
130 the code in a runner item should check whether it is a parent or not.
131 Only selected runner items get executed. Execution is strictly sequential,
132 i.e. the first runner item found for execution in the tree structure is
133 run, or if it has children these are run, then the next selected sibling
134 item is run and so on.
136 Runner items get executed asynchronously in a separate thread allocated
137 by RunnerModelThread. Stopping item execution is only possible in the
138 moment between termination of a runner item and the start of the next one.
139 The thread isn't stopped the 'hard way' by terminating it which is dangerous
140 and discouraged in the Qt documentation. Instead a flag is set which
141 indicates that the thread must stop. This flag is checked regularly in the
142 method that drives item execution.
144 Data updates with RunnerModel::setData() are not possible during item
145 execution. Although the code in runner items can do anything thinkable
146 it is recommended to keep the code to a minimum and to forego lengthy
147 operations because a running item can't be interrupted.
149 Due to the parallelism induced by the thread the item execution must be
150 synchronized with clients that consume item execution related information.
151 The GUI for example displays state information about item execution. If
152 the items are executing faster in the thread than the GUI is able to upate
153 its widgets in its own thread the information shown in the GUI won't be
154 reasonable. Therefore the model waits after each executed item until the
155 signals it emits are completely processed by the signal receivers.
157 The model can be set to minimal update mode. In this mode only a reduced
158 amount of item data and execution state information is returned. It's up
159 to clients to decide when this is useful. QxRunner uses minimal update
160 mode to speed up item execution because not all item data must be updated
161 in views for an executing runner item.
163 Data changes from the outside of the model with RunnerModel::setData()
164 are allowed for the selected flag in column 0 only. Of course there
165 occur data changes all the time during item execution but this happens
166 behind the scenes.
168 The model name uniquely identifies a model which has its unique structure.
169 It is used to identify the settings of a program using the model.
170 Therefore it's not recommended to use a version number or other variable
171 information as part of the model name. Furthermore it is essential that
172 the model name can be part of a valid filename, i.e. no special characters
173 must be used in the name.
175 \note
176  The RunnerModel isn't designed to add additional RunnerItem instances
177  to the model after it is constructed and set up.
179 <!------------------------------------------------------------------->
181 \subsection results_model The Results Model
183 The ResultsModel is tightly coupled to the RunnerModel, more
184 precisely, the RunnerModel class creates the ResultsModel to hold the
185 results of its runner items and defines the model structure. The
186 ResultsModel class has mainly been introduced because the RunnerModel
187 class isn't suitable for displaying chronological data as a simple
188 non-hierarchical list instead of in a tree structure.
190 <!------------------------------------------------------------------->
192 \section runner_item The Runner Item
194 All runner items have the same number of columns. The first two columns
195 have a fixed meaning which should not be overriden:
197 - Column 0 has the name of the item. This column also carries the
198   selected flag which indicates whether a runner item is selected for
199   execution or not. In views this flag is presented as a checkbox.
200 - Column 1 is the textual representation of the result after a
201   runner item has been executed. In general this result text is set
202   by QxRunner but can also be provided otherwise. In the latter case
203   the semantical meaning should be that of describing a result type.
205 The other columns, if any, can be used freely.
207 \note
208  It is important that all RunnerItem objects in RunnerModel
209  have the same number of columns otherwise some view manipulations
210  could throw assertions as learned by experience. Therefore the
211  RunnerItem constructor takes care of the correct number of columns
212  for an item.
214 \sa \ref runner_item_index
217 /*!<!--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-->*/
220 \page implementation_ascpects Implementation Aspects
222 <!------------------------------------------------------------------->
224 \section settings Settings
226 Program settings are kept in INI text files. Settings must be managed
227 for programs using this library and not for the library itself. Therefore
228 the AppSettings class gives the INI file an unique name based on the
229 application executable name. Since different executables could use the
230 same runner model it further makes sense to save settings for a specific
231 model type rather than for a particular program. It's assumed that users
232 running different programs with the same model type expect that settings
233 are applied on a per model type basis.
235 An application name specific INI file only gets one entry which is the
236 name of the model used by the program. The model name identifies the INI
237 file containing the 'real' settings. If no usable model name is available
238 the settings are kept in the INI file with the executable specific name.
240 At the moment there's support for only one settings file for a particular
241 program. This could change in the future if applications get the ability
242 to support loading different models at run-time.
244 All INI files created by the AppSettings class are stored in a folder
245 named \b qxrunner in the user-specific location for INI files on the
246 target platform.
248 <!------------------------------------------------------------------->
250 \section qt_forms Qt Forms
252 Qt Designer is used for GUI design. Implementation of the forms is done
253 using the single inheritance approach as described in the Qt documentation.
254 GUI classes simply call the uic generated base class's constructor and
255 then set up the form's user interface by calling the Ui object's
256 setupUi() function.
258 <!------------------------------------------------------------------->
260 \section agument_validation Argument Validation
262 Where applicable the methods of a class perform simple validation of
263 arguments to prevent from crashes. In case of invalid arguments the
264 methods either do nothing or return values indicating false or something
265 similar that fits according to the context.
267 <!------------------------------------------------------------------->
269 \section runner_item_index Runner Item Index
271 When programming with the model/view framework one is confronted with
272 indexes and items again and again. An index can refer to an item of a
273 model or a view. To know the meaning of an index depends on the context
274 where it is used. One cannot deduce from the index variable type to what
275 kind of item it refers to, since its always a QModelIndex type.
277 Sometimes it is essential to have a QModelIndex that refers to a
278 RunnerItem instance. In comments and the documentation the term
279 <i>runner item index</i> is used to refer to such a QModelIndex.
280 To make this clear in code the index variable gets named accordingly.
281 Also methods related to such a QModelIndex have appropriate names, for
282 example:
284 \code
285 QModelIndex runnerItemIndex;
286 runnerItemIndex = mapToRunnerItemIndex(index(row, 0));
287 \endcode
289 The pointer to the RunnerItem object is retrieved with QModelIndex's
290 \c internalPointer() method:
292 \code
293 QModelIndex runnerItemIndex = mapToRunnerItemIndex(index(row, 0));
295 RunnerItem* item = runnerItemIndex.internalPointer();
297 if (item->isSelected())
299  ...
301 else
303  ...
305 \endcode
307 An \a item in general is a term used in descriptions or is part of an
308 abstract concept. The RunnerItem on the other side is a type of this
309 library. Therefore <i>runner item</i> is used in comments, the
310 documentation or as part of a variable or method name of this library
311 when it must be made clear that it has to do with a RunnerItem type.
313 \note
314  A QModelIndex is located in a given row and column in a model.
315  If not mentioned otherwise the library code uses the index
316  of column 0 for a <i>runner item index</i> returned by a method,
317  provided as an argument in a signal or saved for later use.
319 \sa \ref runner_model_item
321 <!------------------------------------------------------------------->
323 \section selected_item Selected Item
325 A selected item is one that has been chosen from the items presented
326 in \ref runner_view for execution. But often \a selected means that
327 something is highlighted in the GUI too. To distinguish between these
328 two different meanings the term \a highlighted is used in the code to
329 emphasize when something in the GUI is, well, selected in the meaning
330 of the latter. For example in method names:
332 \code
333 void setHighlightedRow(const QModelIndex& index) const;
334 \endcode
336 <!------------------------------------------------------------------->
338 \section main_window The Main Window
340 RunnerWindow is the class that implements the main window for a
341 QxRunner application. It creates the most relevant objects and seams
342 them together. It's responsible to store the appliciation settings at
343 program exit and to restore the main window from the settings at next
344 program start-up.
346 Users can customize the look of the main window to some extents. On
347 the other side developers have few possibilites to influence the
348 initial appearance of the main window. This is on purpose because it's
349 assumed that it should be the user's choice to define how the window
350 appears.
352 The main window adapts to its model by providing just those interface
353 elements that make sense. If a model, for example, has no runner items
354 that return a QxRunner::RunInfo result the button for filtering info
355 results isn't visible. If there is no valid model then nearly all user
356 interaction elements are disabled.
358 The main window starts item execution in the RunnerModel and prevents
359 user interactions that could distract the ongoing item execution.
361 \note
362  The statusbar shows counters for the number of different result
363  types returned from runner items. Even when a particular result
364  type isn't expected it will be shown in the statusbar. This can
365  give a hint to the developer of a QxRunner application that the
366  runner item or the model code must be corrected.
368 \sa \ref result_types
370 <!------------------------------------------------------------------->
372 \section views Views, View Controllers and Proxy Models
374 There are 2 views in the main window which represent data from the
375 models. The views always have as many columns as defined in the model
376 they are representing. There are only horizontal headers for the views.
378 The views represent the data of the model they are attached to either
379 as a simple non-hierarchical list of items without children or as
380 a hierarchical tree structure where items that have children can be
381 expanded (children are visible) or collapsed (children are hidden).
383 Users can define the column visibilities in the ColumnsDialog. Column 0
384 is the most important one and cannot be hidden. Hiding or showing of a
385 column is done by disabling or enabling it in the proxy model as described
386 under \ref proxy_models.
388 \subsection runner_view The Runner View
390 The runner view is attached to a RunnerProxyModel which in turn has
391 a RunnerModel as its source model. The view represents the runner
392 items according to the tree structure defined in the model. The items
393 to be executed are selected in the runner view. The selected flag
394 is represented with a checkbox. Parent item checkboxes are tri-state
395 to show whether all, none or some of its children are selected. Fine
396 grained control over the view is implemented in RunnerViewController.
398 Sorting of columns isn't supported in the runner view.
400 \subsection results_view The Results View
402 The results view is attached to a ResultsProxyModel which in turn has
403 a ResultsModel as its source model. The view represents the runner item
404 results as a simple non-hierarchical list of items without children.
405 Results of certain types can be filtered out in the results view. Fine
406 grained control over the view is implemented in ResultsViewController.
408 The results view allows sorting of columns  when there is data in the
409 results model. If sorting is enabled the sort indicator in the header of
410 the active column is shown and the items are sorted in the corresponding
411 sort order. When the results get removed from the results model sorting
412 also gets disabled.
414 \subsection view_controllers View Controllers
416 Due to the chosen approach for GUI design (see \ref qt_forms) it was
417 not appropriate to subclass from QTreeView to implement view specific
418 behaviour. Instead composition was chosen by introducing view controller
419 classes which acquire a reference to the view object at run-time.
421 Controller classes expect that the controlled view is attached to a model.
422 Specific view controllers subclass ViewControllerCommon.
424 \subsection proxy_models Proxy Models
426 Views in QxRunner access data through a sorting filter proxy model
427 which refers to the 'real' data in a source model.
429 No column of a model ever gets filtered out because this would change
430 the structure of the model for a view. Therefore a view always has
431 as many columns as defined in the source model of a proxy model which
432 greatly simplifies view handling. But columns can be 'disabled' which
433 is done by maintaing a flag for each column. Disabled columns are not
434 visible in a view (which must be guaranteed by the GUI classes that
435 control a view). Therefore no data should be returned for disabled
436 columns to improve performance. This must be guaranteed by the sorting
437 filter model classes which derive from ProxyModelCommon.
439 A proxy model can be set to active or inactive. How this is used depends
440 on the classes that subclass ProxyModelCommon which merely maintains the
441 state of the active flag.
443 <!------------------------------------------------------------------->
445 \section symbols Exported Symbols
447 This applies for the Win32 world only. By default symbols of the library
448 are 'hidden' when created as a DLL. Therefore symbols, in particular
449 classes, that must be accessible from the outside of the library are
450 exported with the QXRUNNER_EXPORT macro:
452 \code
453 class QXRUNNER_EXPORT RunnerItem
455 public: // Operations
456  ...
457 \endcode
459 Only a few classes are exported right now, the other classes are for
460 internal use only. This might be reconsidered in the future and more
461 classes could become exported to be used somewhere outside the library.
464 /*!<!--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-->*/
467 \page result_types Result Types
469 At the end of its execution a runner item returns a result code to report
470 the execution status. The result code is of type QxRunner::RunnerResult.
471 This set of predefined result types is inspired by good old
472 <a target="_blank" href="http://h71000.www7.hp.com/DOC/82final/5973/5973pro_022.html">
473 VMS condition handling</a>.
475 All result types except QxRunner::RunSuccess and QxRunner::RunException
476 should have an accompanying result message which describes the reason for
477 the result. A RunnerModel knows which result types to expect from its runner
478 items. The GUI can retrieve the expected result set from the model and adjust
479 its appearance accordingly. Developers of a new model may limit the expected
480 results to a subset of QxRunner::RunnerResult.
482 \note
483  Runner items shouldn't return the QxRunner::RunException code. It
484  is used by QxRunner to indicate failed execution of a runner item.
485  Exceptions aren't filtered out by ResultsProxyModel since they
486  mostly turn out to be a programming error in RunnerItem::run().
487  Developers should patch that code by implementing a reasonable
488  error handling.
489  <br>
490  <br>
491  A further developed version of the library could also provide a
492  result message reporting the error reason for an exception.
495 /*!<!--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-->*/
498 \namespace QxRunner
500 \brief Namespace for the QxRunner library entities.
502 \namespace Ui
504 \brief Generated GUI components expose their widgets and layouts in the
505        Ui namespace.
507 The Ui namespace is defined by the uic generated files for the forms
508 created with Qt Designer. It contains all the widgets and layouts used
509 in the forms which expose their elements via the Ui namespace to other
510 objects in the project.
513 /*!<!--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-->*/
516 \page examples Examples
518 The demo program shipped with the QxRunner library can be used as the starting
519 point for developping a QxRunner based program. It subclasses RunnerModel and
520 RunnerItem and uses a Runner instance in the main program to launch the
521 GUI. The model constructs a tree structure of runner items which randomly
522 generate a result of type QxRunner::RunnerResult. An item also reports the
523 location of where in the code the result was created and supplies a related
524 result message.
527 For a deeper insight into the details of the model/view framework and how to
528 create a basic model to use with Qt's standard view classes see the
529 <i>Simple Tree Model Example</i> provided with the Qt installation. And, yes,
530 much of this example documentation uses slightly modified text from that Qt
531 example.
533 \section demo_model The Demo Model
535 \subsection demo_model_header Demo Model Header File
537 The constructor takes an argument containing the data that the model will
538 share with views. The \c name() method returns the model name used by QxRunner
539 for display in the about box and as the identifier for the settings file. The
540 model's internal data structure is populated with \c DemoItem instances by the
541 \c setupModelData() helper method. The model isn't designed to add data
542 to the model after it is constructed and set up.
544 \includelineno demomodel.h
546 \subsection demo_model_impl Demo Model Implementation File
548 The constructor creates the root item for the model. This item only contains
549 horizontal header data. It is also used to reference the internal data structure
550 that contains the model data, and it is used to represent an imaginary parent
551 of top-level items in the model. The model's internal data structure is
552 populated with items by the \c setupModelData() function. The destructor does
553 nothing, it relies on the parent RunnerModel destructor who deletes the root
554 item and all of its descendants when the model is destroyed.
556 The \c setupModelData() method sets up the initial data in the model. It
557 iterates over a list of 'keywords' which define the position of an item in the
558 tree strucuture and the related item name. Of course this is a very simple model
559 and is only intended for demonstrational purposes.
561 The keyword meanings are:
563 - \b L0 defines a top level item.
564 - \b L1 defines an item which is a child of a L0 item and itself has child
565         items, thus starts a new branch.
566 - \b L2 defines an item which is a child of a L1 item and itself has child
567         items, thus starts a new branch.
568 - \b L3 defines an item which is a child of a L2 item and itself has child
569         items, thus starts a new branch.
570 - \b CH defines a child item which has no child items of itws own (a leaf). It
571         is appended as a child to the last parent item encountered in the list.
573 \includelineno demomodel.cpp
575 \section demo_item The Demo Item
577 \subsection demo_item_header Demo Item Header File
579 The constructor is used to record the item's parent and the data associated with
580 each column. The abstract \c run() method from the parent RunnerItem class must be
581 reimplemented and contains the custom code that gets executed when the items are
582 run by QxRunner.
584 \includelineno demoitem.h
586 \subsection demo_item_impl Demo Item Implementation File
588 The constructor simply calls the parent RunnerItem constructor. The destructor does
589 nothing, it relies on the parent RunnerItem destructor who ensures that all child
590 items get deleted.
592 The \c run() method first checks whether it is a parent item or not (see
593 \ref runner_model). Only leafs have custom logic for execution. If it is a child
594 the method randomly creates a result type and fills related data into the item columns.
595 A special case is the <i>unhandled exception</i> which gets caught by the model. The
596 commented out code at the beginning was used during development to slow down item
597 execution.
599 \includelineno demoitem.cpp
601 \section demo_main The Demo Main Program
603 The main program is straightforward:
605 \includelineno main.cpp
608 } // namespace