This file is indexed.

/usr/include/qxrunner/runnermodel.h is in libqxrunner-dev 0.9.2-0ubuntu4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
/*!
 * \file  runnermodel.h
 *
 * \brief Declares class RunnerModel.
 */

#ifndef RUNNERMODEL_H
#define RUNNERMODEL_H

#include "qxrunner_global.h"

#include <QAbstractItemModel>
#include <QMutex>
#include <QEvent>
#include <QPair>

namespace QxRunner {

class RunnerItem;
class ResultsModel;
class RunnerModelThread;

/*!
 * \brief The RunnerModel class maintains the core data and executes
 *        runner items.
 *
 * This class stores data using RunnerItem objects that are linked
 * together in a pointer-based tree structure.
 *
 * Selected runner items can be executed. Status about ongoing item
 * execution is reported with signals. Items execute in a separate
 * thread which requires thread synchronization. Private classes which
 * subclass QEvent are used to post data from the thread to this class.
 *
 * The model can be set to minimal update mode. In this mode the data()
 * method returns data for column 0 only and not all signals reporting
 * item execution status get fired.
 *
 * RunnerModel also creates the ResultsModel object which collects
 * the results of executed runner items.
 *
 * \sa \ref runner_model_item and \ref implementation_ascpects
 */

class QXRUNNER_EXPORT RunnerModel : public QAbstractItemModel
{
	Q_OBJECT

friend class RunnerModelThread;

public:  // Operations

	/*!
	 * Constructs a runner model with the given \a parent.
	 */
	RunnerModel(QObject* parent = 0);

	/*!
	 * Destroys this runner model. Ongoing runner item execution is
	 * stopped.
	 */
	~RunnerModel();

	/*!
	 * Returns the model name.
	 */
	virtual QString name() const = 0;

	/*!
	 * Returns supplementary information. Typically displayed in about
	 * message boxes.
	 */
	virtual QString about() const;

	/*!
	 * Returns the data stored under the given \a role for the item
	 * referred to by \a index.
	 */
	QVariant data(const QModelIndex& index, int role) const;

	/*!
	 * Sets the \a role data for the item at \a index to \a value.
	 * Returns true if successful, otherwise false.
	 */
	bool setData (const QModelIndex& index, const QVariant& value,
                  int role = Qt::EditRole);

	/*!
	 * Returns the item flags for the given \a index. Column 0 is user
	 * checkable, all other columns are read only.
	 */
	Qt::ItemFlags flags(const QModelIndex& index) const;

	/*!
	 * Returns the data for the given \a role and \a section in the
	 * header with the specified \a orientation.
	 */
	QVariant headerData(int section, Qt::Orientation orientation,
						int role = Qt::DisplayRole) const;

	/*!
	 * Returns the index of the item in the model specified by the
	 * given \a row, \a column and \a parent index.
	 */
	QModelIndex index(int row, int column,
					  const QModelIndex& parent = QModelIndex()) const;

	/*!
	 * Returns the parent of the model item with the given \a index.
	 * The returned index never corresponds to the root item.
	 */
	QModelIndex parent(const QModelIndex& index) const;

	/*!
	 * Returns the number of rows under the given \a parent, or the
	 * number of top-level items if an invalid index is specified.
	 */
	int rowCount(const QModelIndex& parent = QModelIndex()) const;

	/*!
	 * Returns the number of columns for the given \a parent, or for
	 * the root item if an invalid index is specified.
	 */
	int columnCount(const QModelIndex& parent = QModelIndex()) const;

	/*!
	 * Updates all internal counters and emits the signals which report
	 * counter values with the actual counts.
	 */
	void countItems();

	/*!
	 * Returns the result types expected from runner items. Is a
	 * combination of OR'ed QxRunner::RunnerResult values.
	 */
	int expectedResults() const;

	/*!
	 * Sets the check state for the item at \a index and any children
	 * to \a checked.
	 */
	void setItemChecked(const QModelIndex& index, bool checked);

	/*!
	 * Removes previous results and starts runner item execution.
	 * Forces attached views to update.
	 */
	void runItems();

	/*!
	 * Tries to stop item execution. Returns true if successful,
	 * otherwise false. Must probably be called several times until
	 * stopping succeeds.
	 */
	bool stopItems();

	/*!
	 * Fires itemCompleted() for every result contained in the results
	 * model. Forces attached views to update.
	 */
	void emitItemResults();

	/*!
	 * Returns true if runner items are currently being executed in
	 * the thread, otherwise false. Waits max. \a time millisecons
	 * to determine the return value.
	 */
	bool isRunning(unsigned long time = 0) const;

	/*!
	 * Returns the results model. If no results model exists one is
	 * created.
	 */
	ResultsModel* resultsModel();

signals:

	/*!
	 * This signal is emitted when the runner item referred to by
	 * \a index is started.
	 */
	void itemStarted(const QModelIndex& index) const;

	/*!
	 * This signal is emitted when the runner item referred to by
	 * \a index has completed.
	 */
	void itemCompleted(const QModelIndex& index) const;

	/*!
	 * This signal is emitted when all runner items have completed.
	 */
	void allItemsCompleted() const;

	/*!
	 * This signal is emitted when the number of runner items has
	 * changed.
	 */
	void numTotalChanged(int numItems) const;

	/*!
	 * This signal is emitted when the number of selected runner items
	 * has changed.
	 */
	void numSelectedChanged(int numItems) const;

	/*!
	 * This signal is emitted when the number of started runner items
	 * has changed.
	 */
	void numStartedChanged(int numItems) const;

	/*!
	 * This signal is emitted when the number of completed runner items
	 * has changed.
	 */
	void numCompletedChanged(int numItems) const;

	/*!
	 * This signal is emitted when the number of successfully completed
	 * runner items has changed.
	 */
	void numSuccessChanged(int numItems) const;

	/*!
	 * This signal is emitted when the number of runner items that
	 * returned an info result has changed.
	 */
	void numInfosChanged(int numItems) const;

	/*!
	 * This signal is emitted when the number of runner items that
	 * returned a warning result has changed.
	 */
	void numWarningsChanged(int numItems) const;

	/*!
	 * This signal is emitted when the number of runner items that
	 * returned an error result has changed.
	 */
	void numErrorsChanged(int numItems) const;

	/*!
	 * This signal is emitted when the number of runner items that
	 * returned a fatal error result has changed.
	 */
	void numFatalsChanged(int numItems) const;

	/*!
	 * This signal is emitted when the number of runner items that
	 * produced an unhandled error has changed.
	 */
	void numExceptionsChanged(int numItems) const;

public slots:

	/*!
	 * Sets minimal update mode to \a minimalUpdate.
	 */
	void setMinimalUpdate(bool minimalUpdate);

protected: // Operations

	/*!
	 * Returns the root item or 0 if no root item exists.
	 */
	RunnerItem* rootItem() const;

	/*!
	 * Sets \a rootItem as the root item.
	 */
	void setRootItem(RunnerItem* rootItem);

	/*!
	 * Sets the result types that must be expected from runner items.
	 * \a expectedResults is a combination of OR'ed
	 * QxRunner::RunnerResult values.
	 */
	void setExpectedResults(int expectedResults);

	/*!
	 * Returns the runner item the \a index refers to.
	 */
	RunnerItem* itemFromIndex(const QModelIndex& index) const;

private:  // Operations

	/*!
	 * Helper method to return the subset of data when in minimal
	 * update mode.
	 */
	QVariant dataForMinimalUpdate(const QModelIndex& index, int role) const;

	/*!
	 * Helper method to initialize internal data used for item check
	 * state management.
	 */
	void initializeSelectionMap();

	/*!
	 * Helper method to update internal data used for item check state
	 * management with data from \a index.
	 */
	void updateSelectionMap(const QModelIndex& index);

	/*!
	 * Entry point for thread processing in the model.
	 */
	void threadCode();

	/*!
	 * Returns true if the thread must stop, otherwise false.
	 */
	bool mustStop();

	/*!
	 * Sets the stop flag for the thread.
	 */
	void setMustStop(bool stop);

	/*!
	 * Returns true if the thread must wait, otherwise false. If
	 * \a block is true the method waits until false can be returned.
	 */
	bool mustWait(bool block = false);

	/*!
	 * Sets the wait flag for the thread.
	 */
	void setMustWait(bool wait);

	/*!
	 * Helper method to recursively clear all runner items. Starts
	 * with the runner item referred to by \a index.
	 */
	void clearItem(const QModelIndex& index);

	/*!
	 * Helper method to recursively run selected runner items. Starts
	 * with the runner item referred to by \a index.
	 */
	void runItem(const QModelIndex& index);

	/*!
	 * Helper method to recursively fire itemCompleted() for runner
	 * items with a result. Starts with the runner item referred to
	 * by \a index.
	 */
	void emitItemResult(const QModelIndex& index);

	/*!
	 * Sets the textual representation for the execution result in
	 * \a item to \a text. An existing text isn't overwritten.
	 */
	void setResultText(RunnerItem* item, const QString& text) const;

	/*!
	 * Returns true if minimal update mode is on, otherwise false.
	 */
	bool isMinimalUpdate() const;

	/*!
	 * Helper method to recursively set the check state of the parent
	 * item at \a index and its children to \a checked.
	 */
	void setParentItemChecked(const QModelIndex& index, bool checked);

	/*!
	 * Helper method to set the check state of the child item at
	 * \a index to \a checked.
	 */
	void setChildItemChecked(const QModelIndex& index, bool checked);

	/*!
	 * Returns the check state of the item at \a index. Child items
	 * are two-state and parents are tri-state.
	 */
	QVariant itemCheckState(const QModelIndex& index) const;

	/*!
	 * Processes events from the thread and fires signals with data
	 * from the events. Forces attached views to update.
	 */ 
	bool event(QEvent* event);

	// Copy and assignment not supported.
	RunnerModel(const RunnerModel&);
	RunnerModel& operator=(const RunnerModel&);

private:  // Constants

	static const int WAIT_TIME_MILLI = 200;

private:  // Attributes

	RunnerItem*        m_rootItem;
	RunnerModelThread* m_thread;
	ResultsModel*      m_resultsModel;

	QMutex m_lock;

	bool m_stop;
	bool m_wait;
	bool m_minimalUpdate;

	QModelIndex m_startedItemIndex;

	int m_expectedResults;

	int m_numSelected;
	int m_numStarted;
	int m_numSuccess;
	int m_numInfos;
	int m_numWarnings;
	int m_numErrors;
	int m_numFatals;
	int m_numExceptions;

	typedef QPair<int, int> SelectionPair;
	typedef QMap<qint64, SelectionPair> SelectionMap;

	SelectionMap m_selectionMap;

private: // Classes and related constants

	enum EventType
	{
		ItemStateChanged = QEvent::User,
		ItemGetsStarted,
		ItemCompleted,
		AllItemsCompleted
	};

	/*!
	 * Base class for events posted by the thread. The index refers
	 * to the runner item in question.
	 */ 
	class ItemStateChangedEvent : public QEvent
	{
	public: // Operations

		ItemStateChangedEvent(const QModelIndex& index,
                              QEvent::Type type = (QEvent::Type)ItemStateChanged)
          : QEvent(type), m_index(index) {}

		QModelIndex index() const { return m_index; }

	private: // Attributes

		QModelIndex m_index;
	};

	/*!
	 * Event posted to notify of a started runner item.
	 */ 
	class ItemGetsStartedEvent : public ItemStateChangedEvent
	{
	public: // Operations
		
		ItemGetsStartedEvent(const QModelIndex& index)
          : ItemStateChangedEvent(index, (QEvent::Type)ItemGetsStarted) {}
	};

	/*!
	 * Event posted to notify of a completed runner item.
	 */ 
	class ItemCompletedEvent : public ItemStateChangedEvent
	{
	public: // Operations
		
		ItemCompletedEvent(const QModelIndex& index)
          : ItemStateChangedEvent(index, (QEvent::Type)ItemCompleted) {}
	};

	/*!
	 * Event posted when all items have completed. The index is invalid.
	 */ 
	class AllItemsCompletedEvent : public ItemStateChangedEvent
	{
	public: // Operations
		
		AllItemsCompletedEvent(const QModelIndex& index)
          : ItemStateChangedEvent(index, (QEvent::Type)AllItemsCompleted) {}
	};
};

} // namespace

#endif // RUNNERMODEL_H