This file is indexed.

/usr/include/Wt/Ext/TableView is in libwtext-dev 3.3.6+dfsg-1.1.

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
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef EXT_TABLE_VIEW_H_
#define EXT_TABLE_VIEW_H_

#include <map>
#include <Wt/WJavaScript>
#include <Wt/Ext/Panel>

namespace Wt {

  class WAbstractItemModel;
  class WModelIndex;

  namespace Ext {

    class DataStore;
    class FormField;

/*! \class TableView Wt/Ext/TableView Wt/Ext/TableView
 *  \brief A widget that displays data in a table.
 *
 * This class is an MVC view widget, which works in conjunction with a
 * WAbstractItemModel for the data. The model may be set (and changed)
 * using setModel().
 *
 * The widget may be configured to allow the user to hide or resize
 * columns, sort on column data, or reorder columns using drag&drop.
 *
 * By default, the table is not editable. Use setEditor() to specify a
 * form field that may be used for inline editing for a particular
 * column. Changes are then reflected in the model().
 *
 * The table supports single and multiple selection modes, that work
 * on a row-level, or cell-level. The latter option is enforced when
 * the table is editable.
 *
 * By default, the data of the model is stored client-side, but this
 * may be changed using setDataLocation() to be server-side. The
 * latter option allows, in conjunction with a paging tool bar (see
 * createPagingToolBar()) to support viewing (and editing) of large
 * data sets.
 *
 * Although TableView inherits from Container (through Panel),
 * specifying a layout for adding or removing widgets is not
 * supported. The Panel methods to specify tool bars, titles, and
 * buttons are however supported.
 *
 * \image html ExtTableView-1.png "Example of a TableView"
 * \image html ExtTableView-2.png "Example of a editing in a TableView using a ComboBox"
 *
 * <h3>CSS</h3>
 *
 * A TableView has the <tt>table.x-grid3-row-table</tt> style
 * classes.
 * \ingroup ext
 */
class WT_EXT_API TableView : public Panel
{
public:
  /*! \brief Create a new table view.
   *
   * You should specify a model using setModel(WAbstractItemModel *).
   */
  TableView(WContainerWidget *parent = 0);

  /*! \brief Specify the model.
   *
   * You can change the model at any time, with the contraint that you
   * should keep the same column configuration.
   *
   * You may also reset the same model. This will result in
   * retransmission of the model from scratch. In some cases, this
   * could result in a higher preformance when you have removed many
   * rows or modified a lot of data.
   */
  void setModel(WAbstractItemModel *model);

  /*! \brief Return the model.
   *
   * \sa setModel(WAbstractItemModel *)
   */
  WAbstractItemModel *model() const { return model_; }

  /*! \brief Let the table view resize columns to fit their contents.
   *
   * By default, columns are sized using the column sizes that are
   * provided. Using this method, this is changed to let columns
   * expand to fit the entire table. By setting <i>onResize</i>, this
   * is done also whenever the entire table or one of the columns is
   * resized.
   */
  void resizeColumnsToContents(bool onResize = false);

  /*! \brief Set the column which will auto-expand to take the
   *         remaining space.
   *
   * By default the last column will do that.
   */
  void setAutoExpandColumn(int column, int minWidth = 50, int maxWidth = 1000);

  /*! \brief Return the column index of the column that auto-expands.
   */
  int autoExpandColumn() const;

  /*! \brief Configure the location of the data.
   *
   * By default, data is stored at the client, and therefore entirely
   * transmitted when rendering the table for the first
   * time. Alternatively, the data may be kept at the server. Unless a
   * paging tool bar is configured however, this will still cause the
   * entire table to be anyway, after the table is rendered. When a paging
   * tool bar is configured, only a single page of data is displayed, and
   * transmitted, giving the best performance for big data sets.
   *
   * \sa createPagingToolBar()
   */
  void setDataLocation(DataLocation dataLocation);

  /*! \brief Allow the user to move columns using drag and drop.
   *
   * Setting movable to true, enables the user to move columns around by
   * drag and drop.
   *
   * <i>Note: this currently breaks the CellSelection mode to record
   * the view column number, but not the data column number.</i>
   *
   * \sa columnsMovable()
   */
  void setColumnsMovable(bool movable);

  /*! \brief Return if columns are movable.
   *
   * \sa setColumnsMovable(bool)
   */
  bool columnsMovable() const { return columnMove_; }

  /*! \brief Render rows with alternating colors.
   *
   * By defaults, all rows are rendered using the same color.
   *
   * \sa alternatingRowColors()
   */
  void setAlternatingRowColors(bool enable);

  /*! \brief Return if rows are rendered with alternating colors.
   *
   * \sa setAlternatingRowColors(bool)
   */
  bool alternatingRowColors() const { return alternatingRowColors_; }

  /*! \brief Configure if the row under the mouse will be highlighted.
   *
   * By default, the row under the mouse is not highlighted.
   *
   * \sa highlightMouseOver()
   */
  void setHighlightMouseOver(bool highlight);

  /*! \brief Return if the row under the mouse will be highlighted.
   */
  bool highlightMouseOver() const { return highlightMouseOver_; }  

  // Configuration settings for individual columns

  /*! \brief Change the visibility of a column.
   *
   * \sa isColumnHidden(int), enableColumnHiding(int, bool)
   */
  void setColumnHidden(int column, bool hide);

  /*! \brief Return if a column is hidden.
   *
   * \sa setColumnHidden(int, bool)
   */
  bool isColumnHidden(int column) const;

  /*! \brief Hide a column.
   *
   * \sa showColumn(int), setColumnHidden(int, bool)
   */
  void hideColumn(int column);

  /*! \brief Show a column.
   *
   * \sa hideColumn(int), setColumnHidden(int, bool)
   */
  void showColumn(int column);

  /*! \brief Set the column width (in pixels) for a column.
   *
   * \sa columnWidth(int)
   */
  void setColumnWidth(int column, int pixels);

  /*! \brief Return the column width.
   *
   * \sa setColumnWidth(int, int)
   */
  int columnWidth(int column) const;

  /*! \brief Set the horizontal content alignment of a column.
   *
   * The default value is \link Wt::AlignLeft AlignLeft\endlink.
   * The alignment parameter is a horizontal alignment flag.
   */
  void setColumnAlignment(int column, AlignmentFlag alignment);

  /*! \brief Return the horizontal content alignment of a column.
   *
   * \sa setColumnAlignment(int, AlignmentFlag)
   */
  AlignmentFlag columnAlignment(int column) const;

  /*! \brief Allow a column to be sorted by the user.
   *
   * \sa isColumnSortable(int)
   */
  void setColumnSortable(int column, bool sortable);

  /*! \brief Return if a column is sortable.
   *
   * \sa setColumnSortable(int, bool)
   */
  bool isColumnSortable(int column) const;

  /*! \brief Allow a column to be hidden through its context menu.
   *
   * \sa isColumnHidingEnabled(int)
   */
  void enableColumnHiding(int column, bool enable);

  /*! \brief Return if a column may be hidden through its context menu.
   *
   * \sa enableColumnHiding(int, bool)
   */
  bool isColumnHidingEnabled(int column) const;

  /*! \brief Configure an editor for the given column.
   *
   * Sets an inline editor that will be used to edit values in this column.
   * The edited value will be reflected in the data model.
   *
   * When configuring an editor, the selectionBehaviour() is set to
   * \link Wt::SelectItems SelectItems\endlink mode.
   *
   * \sa LineEdit, NumberField, DateField, ComboBox
   */
  void setEditor(int column, FormField *editor);

  /*! \brief Configure a custom renderer for the given column.
   *
   * Sets a JavaScript function to render values in the given column.
   * The JavaScript function takes one argument (the value), which has
   * a type that corresponds to the C++ type:
   * <table>
   *   <tr><td><b>C++ type</b></td><td><b>JavaScript type</b></td></tr>
   *   <tr><td>WString</td><td>string</td></tr>
   *   <tr><td>WDate</td><td>Ext.Date</td></tr>
   *   <tr><td><i>number</i> type</td><td>number</td></tr>
   * </table>
   *
   * An example of rendererJS for numerical data, which renders positive
   * values in green and negative values in red could be:
   * \code
   * function change(val) {
   *   if (val > 0){
   *     return '\<span style="color:green;"\>' + val + '\</span\>';
   *   } else if(val < 0) {
   *     return '\<span style="color:red;"\>' + val + '\</span\>';
   *   }
   *   return val;
   * }
   * \endcode
   *
   * \sa dateRenderer()
   */
  void setRenderer(int column, const std::string& rendererJS);

  /*! \brief Configure a page size to browse the data page by page.
   *
   * By setting a <i>pageSize</i> that is different from -1, the table
   * view will display only single pages of the whole data set. You
   * should probably add a paging tool bar to allow the user to scroll
   * through the pages.
   *
   * \sa pageSize(), createPagingToolBar()
   */
  void setPageSize(int pageSize);

  /*! \brief Return the page size.
   *
   * \sa setPageSize(int)
   */
  int pageSize() const { return pageSize_; }

  /*! \brief Create a paging tool bar.
   *
   * Create a toolbar that provides paging controls for this
   * table. You should configure the page size using setPageSize(int).
   *
   * \sa setPageSize(int), setDataLocation(DataLocation)
   * \sa setBottomToolBar(ToolBar *), setTopToolBar(ToolBar *)
   */
  ToolBar *createPagingToolBar();

  virtual void refresh();

  /*! \brief Create a date renderer for the given format.
   *
   * The result is a JavaScript function that renders WDate (or more
   * precisely, Ext.Date) values according to the given format, for
   * use in setRenderer()
   *
   * \sa setRenderer()
   * \sa \link WDate::toString(const WString&) const WDate::toString(const WString& format) \endlink
   */
  static std::string dateRenderer(const WString& format);

  /*! \brief Give a cell focus
   *
   * When selectionBehavior() is \link Wt::SelectRows
   * SelectRows\endlink, only the <i>row</i> argument is used, and the
   * effect is to select a particular row.
   *
   * Even when selectionMode() is \link Wt::ExtendedSelection
   * ExtendedSelection\endlink, this method will first clear
   * selection, and the result is that the given
   * <i>row</i>,<i>column</i> will be the only selected cell.
   *
   * \sa currentRow(), currentColumn(), currentCellChanged() signal
   * \sa setSelectionMode(SelectionMode),
   *     setSelectionBehavior(SelectionBehavior)
   */
  void setCurrentCell(int row, int column);

  /*! \brief Return the index of the row currently selected
   *
   * \sa currentColumn(), setCurrentCell(int, int)
   */
  int currentRow() const { return currentRow_; }

  /*! \brief Return the index of the column currently selected
   *
   * \sa currentRow(), setCurrentCell(int, int)
   */
  int currentColumn() const { return currentColumn_; }

  /*! \brief The list of rows that are currently selected.
   *
   * This is the way to retrieve the list of currently selected rows
   * when selectionBehavior() is \link Wt::SelectRows
   * SelectRows\endlink. This list is always empty when
   * selectionBehavior() is \link Wt::SelectItems SelectItems\endlink
   * and you should use currentRow() and currentColumn() instead.
   */
  const std::vector<int>&     selectedRows() { return selectedRows_; }

  /*! \brief Clear the current selection.
   *
   * \sa setCurrentCell(int, int)
   */
  void clearSelection();

  /*! \brief Return the current selection mode.
   *
   * \sa setSelectionMode(SelectionMode)
   */
  SelectionMode selectionMode() const { return selectionMode_; }

  /*! \brief Set the selection mode.
   *
   * The selection mode determines if no, only one, or multiple items may
   * be selected.
   *
   * <i>When selectionBehavior() is \link Wt::SelectItems
   * SelectItems\endlink, \link Wt::ExtendedSelection
   * ExtendedSelection\endlink is not supported.</i>
   */
  void setSelectionMode(SelectionMode mode);

  /*! \brief Set the selection behaviour.
   *
   * The selection behavior defines the unit of selection. The selection
   * behavior also determines the set of methods that must be used to
   * inspect the current selection.
   *
   * You may either:
   *  - use \link Wt::SelectRows SelectRows\endlink to
   *    only select whole rows, and use the method selectedRows() to
   *    inspect the current selection.
   *  - or use \link Wt::SelectItems SelectItems\endlink to select
   *    (a single) individual item, and use the methods currentColumn(),
   *    currentRow(), setCurrentCell() to inspect and modify the current
   *    selection.
   */
  void setSelectionBehavior(SelectionBehavior behavior);

  /*! \brief Return the current selection behaviour.
   *
   * \sa selectionBehavior()
   */
  SelectionBehavior selectionBehavior() const { return selectionBehavior_; }

  /*! \brief %Signal emitted when a cell is clicked.
   *
   * The signal arguments are row and column of the cell that is clicked.
   *
   * \sa currentCellChanged()
   */
  Signal<int, int>& cellClicked() { return cellClicked_; }

  /*! \brief %Signal emitted when a new cell received focus.
   *
   * This signal is only emitted when selectionBehavior() is \link
   * Wt::SelectItems SelectItems\endlink.  The four arguments are
   * <i>row</i>, <i>column</i>, <i>prevrow</i>, <i>prevcolumn</i>
   * which hold respectively the location of the new focussed cell,
   * and the previously focussed cell.
   *
   * Values of -1 indicate 'no selection'.
   */
  Signal<int, int, int, int>& currentCellChanged()
    { return currentCellChanged_; }

  /*! \brief %Signal emitted when the selection changes.
   *
   * \sa currentRow(), currentColumn() when selectionBehavior() is
   * \link Wt::SelectItems SelectItems\endlink
   * \sa selectedRows() when selectionBehavior() is \link Wt::SelectRows
   * SelectRows\endlink.
   */
  Signal<>& itemSelectionChanged() { return itemSelectionChanged_; }

protected:
  virtual void updateExt();
  virtual void createConfig(std::ostream& config);
  virtual std::string extClassName() const;

private:
  Signal<int, int> cellClicked_;
  Signal<int, int, int, int> currentCellChanged_;
  Signal<> itemSelectionChanged_;

  DataLocation        dataLocation_;
  WAbstractItemModel *model_;
  SelectionMode       selectionMode_;
  SelectionBehavior   selectionBehavior_;

  std::vector<int>    selectedRows_;
  int                 currentRow_, currentColumn_;
  int                 pageSize_;

  struct ColumnModel {
    bool        sortable_;
    bool        hideable_;
    bool        hidden_;
    bool        resizable_;
    int         width_;
    FormField  *editor_;
    std::string rendererJS_;
    AlignmentFlag alignment_;

    ColumnModel();
    ~ColumnModel();
  };

  typedef std::map<int, ColumnModel> ColumnMap;
  ColumnMap columnInfo_;
  int  autoExpandColumn_;
  int  autoExpandColumnMinWidth_;
  int  autoExpandColumnMaxWidth_;
  bool autoFill_;
  bool forceFit_;
  bool columnMove_;
  bool alternatingRowColors_;
  bool highlightMouseOver_;

  DataStore *dataStore_;

  std::vector<Wt::Signals::connection> modelConnections_;

  virtual std::string createJS(DomElement *inContainer);

  void modelColumnsInserted(const WModelIndex& parent, int start, int end);
  void modelColumnsRemoved(const WModelIndex& parent, int start, int end);
  void modelRowsInserted(const WModelIndex& parent, int start, int end);
  void modelRowsRemoved(const WModelIndex& parent, int start, int end);
  void modelDataChanged(const WModelIndex& topLeft,
			const WModelIndex& bottomRight);
  void modelLayoutChanged();

  JSignal<std::string,int,std::string> edited_;
  JSignal<std::string> selectionChanged_;
  JSignal<std::string, int> rawCellClicked_;
  void onEdit(std::string field, int rowId, std::string value);
  void onSelectionChange(const std::string selection);
  void onCellClicked(std::string field, int rowId);

  void shiftSelectedRows(int start, int count);
};

  }
}

#endif // EXT_TABLE_VIEW_H_