File: GraphTableWidget.h

package info (click to toggle)
tulip 3.7.0dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 39,428 kB
  • sloc: cpp: 231,403; php: 11,023; python: 1,128; sh: 671; yacc: 522; makefile: 315; xml: 63; lex: 55
file content (89 lines) | stat: -rwxr-xr-x 2,439 bytes parent folder | download
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
#ifndef GRAPHTABLEWIDGET_H
#define GRAPHTABLEWIDGET_H
#include <QtGui/QTableView>
#include <tulip/Graph.h>

class GraphTableModel;
class TulipFilterProxyModel;

/**
  * @brief Table widget object providing convinience functions for handling graph objects.
  **/
class GraphTableWidget : public QTableView {
  Q_OBJECT
public:
  //Selected : all the elements are selected.
  //Unselected : all the elements are unselected.
  //PartiallySelected : only a part of the elements are selected.
  enum SelectionStatus {Selected,Unselected,PartiallySelected};


  GraphTableWidget(QWidget* parent=NULL);
  virtual ~GraphTableWidget() {}

  void setGraph(tlp::Graph* graph,tlp::ElementType element);

  tlp::ElementType elementType()const {
    return _type;
  }

  tlp::Graph* graph()const {
    return _graph;
  }

  GraphTableModel* graphModel()const {
    return _tulipTableModel;
  }

  void update();

  /**
    * @brief Compute the selection status for the elements list.
    **/
  SelectionStatus selectionStatus(const QModelIndexList& elements)const;

  /**
    * @brief Convert the index list to ids.
    **/
  std::set<unsigned int> indexListToIds(const QModelIndexList& elementsIndexes)const;

  void highlightAllElements();

  void highlightElements(const std::set<unsigned int>& elementsToHighligh);

  /**
    * @brief Scrolls the view if necessary to show a maximum of elements in the list. Compute the element at the top left corner and move the view port to it's position.
    **/
  void scrollToFirstOf(const QModelIndexList& indexes);

  /**
    * @brief Convinience function that highlight all the elements in the list and move the viewport of the table view on the element at the top left corner.
    **/
  void highlightAndDisplayElements(const std::set<unsigned int>& elements);

  /**
    * @brief Return the selected rows from QItemSelectionModel but remove hiden rows from the result.
    *
    */
  QModelIndexList selectedRows(int columns=0)const;


  void setRowFilter(QRegExp regExp,bool showOnlySelectedElements,int columnFilter);

  void unsetRowFilter();

protected:
  void setModel(QAbstractItemModel *) {}

  tlp::Graph* _graph;
  tlp::ElementType _type;
  GraphTableModel* _tulipTableModel;
  TulipFilterProxyModel* _filterModel;



  void updateHorizontalHeaderVisibility(bool checked);

};

#endif // GRAPHTABLEWIDGET_H