GraphTool  1.0
Tool for analyzing and graphically visualizing code dependencies for Ericsson.
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
filter_model.h
1 
5 #ifndef FILTER_MODEL_H
6 #define FILTER_MODEL_H
7 
8 #include <QList>
9 #include <QStandardItem>
10 #include <string>
11 #include "module.h"
12 #include "dependency.h"
13 #include "mem_type.h"
14 
15 class FilterModel {
16  public:
17 
21  static QList<QStandardItem*> rootNode(std::string name, std::string type, bool enabled, bool inverted) {
22  QList<QStandardItem*> item;
23  item << new QStandardItem(QString::fromStdString(name))
24  << new QStandardItem(QString::fromStdString(type))
25  << new QStandardItem((inverted ? "Exclude" : "Include"));
26  item[0]->setCheckable(true);
27  item[0]->setCheckState((enabled ? Qt::Checked : Qt::Unchecked));
28  item[0]->setEditable(false);
29  item[1]->setEditable(false);
30  item[2]->setEditable(false);
31 
32  return item;
33  }
34 
38  static void empty_filter(QStandardItem& parent, std::string type) {
39  if(type.compare("regex") == 0) {
40  FilterModel::regex(parent);
41  } else if(type.compare("dependency_degree") == 0) {
42  FilterModel::dependency_degree(parent);
43  } else if(type.compare("run_block") == 0) {
44  FilterModel::run_block(parent);
45  } else if(type.compare("lpm_ldm") == 0) {
46  FilterModel::lpm_ldm(parent, 0);
47  } else if(type.compare("diff") == 0){
48  FilterModel::diff(parent);
49  }
50  }
51 
52  static void diff(QStandardItem& parent, std::string type = ""){
53  QList<QStandardItem*> keyValue;
54  keyValue << new QStandardItem("Difference")
55  << new QStandardItem(QString::fromStdString(type));
56 
57  keyValue.first()->setEditable(false);
58  keyValue[0]->setSelectable(false);
59  keyValue[1]->setSelectable(false);
60  parent.appendRow(keyValue);
61  }
62 
63  static void regex(QStandardItem& parent, std::string pattern="") {
64  QList<QStandardItem*> keyValue;
65  keyValue << new QStandardItem("Regular Expression")
66  << new QStandardItem(QString::fromStdString(pattern));
67 
68  keyValue.first()->setEditable(false);
69  keyValue[0]->setSelectable(false);
70  keyValue[1]->setSelectable(false);
71  parent.appendRow(keyValue);
72  }
73 
74  static void dependency_degree(QStandardItem& parent, int min_degree=-1, int max_degree=-1) {
75  QList<QStandardItem*> minValue;
76  minValue << new QStandardItem("Min Degree")
77  << new QStandardItem(QString::number(min_degree));
78  minValue.first()->setEditable(false);
79  minValue[0]->setSelectable(false);
80  minValue[1]->setSelectable(false);
81  parent.appendRow(minValue);
82 
83  QList<QStandardItem*> maxValue;
84  maxValue << new QStandardItem("Max Degree")
85  << new QStandardItem(QString::number(max_degree));
86  maxValue.first()->setEditable(false);
87  maxValue[0]->setSelectable(false);
88  maxValue[1]->setSelectable(false);
89  parent.appendRow(maxValue);
90  }
91 
92  template<typename DepType>
93  static void lpm_ldm(QStandardItem& parent, DepType dep_type = GraphTool::UNDEFINED) {
94  QList<QStandardItem*> keyValue;
95  keyValue << new QStandardItem("Type");
96  if(dep_type == GraphTool::LPM) {
97  keyValue << new QStandardItem("LPM");
98  }
99  else if(dep_type == GraphTool::LDM) {
100  keyValue << new QStandardItem("LDM");
101  }
102  else if(dep_type == GraphTool::LDM_LPM) {
103  keyValue << new QStandardItem("Both");
104  }
105  else {
106  keyValue << new QStandardItem("Undefined");
107  }
108 
109  keyValue.first()->setEditable(false);
110  keyValue[0]->setSelectable(false);
111  keyValue[1]->setSelectable(false);
112  parent.appendRow(keyValue);
113  }
114 
115  static void run_block(QStandardItem& parent, std::string query_string="") {
116  QList<QStandardItem*> keyValue;
117  keyValue << new QStandardItem("Query String")
118  << new QStandardItem(QString::fromStdString(query_string));
119 
120  keyValue.first()->setEditable(false);
121  keyValue[0]->setSelectable(false);
122  keyValue[1]->setSelectable(false);
123  parent.appendRow(keyValue);
124  }
125 
129  static void formatting_properties(QStandardItem& parent, std::string opacityStr="255", std::string colorStr="red", bool hide=false) {
130  QList<QStandardItem*> opacity;
131  opacity << new QStandardItem("Opacity")
132  << new QStandardItem(QString::fromStdString(opacityStr));
133  opacity.first()->setEditable(false);
134  opacity[0]->setSelectable(false);
135  opacity[1]->setSelectable(false);
136  parent.appendRow(opacity);
137 
138  QList<QStandardItem*> color;
139  color << new QStandardItem("Color")
140  << new QStandardItem(QString::fromStdString(colorStr));
141  color.first()->setEditable(false);
142  color[0]->setSelectable(false);
143  color[1]->setSelectable(false);
144  parent.appendRow(color);
145 
146  QList<QStandardItem*> hidden;
147  hidden << new QStandardItem("Hide");
148  if(hide)
149  hidden << new QStandardItem("Yes");
150  else
151  hidden << new QStandardItem("No");
152  hidden.first()->setEditable(false);
153  hidden[0]->setSelectable(false);
154  hidden[1]->setSelectable(false);
155  parent.appendRow(hidden);
156  }
157 
161  static std::map<std::string, std::string> filter_types() {
162  std::map<std::string, std::string> ret;
163  ret["Dependency Degree"] = "dependency_degree";
164  ret["LPM/LDM"] = "lpm_ldm";
165  ret["Run block"] = "run_block";
166  ret["Regular Expression"] = "regex";
167  ret["Difference"] = "diff";
168  return ret;
169  }
170 };
171 
172 #endif
static QList< QStandardItem * > rootNode(std::string name, std::string type, bool enabled, bool inverted)
Definition: filter_model.h:21
static std::map< std::string, std::string > filter_types()
Definition: filter_model.h:161
static void empty_filter(QStandardItem &parent, std::string type)
Definition: filter_model.h:38
static void formatting_properties(QStandardItem &parent, std::string opacityStr="255", std::string colorStr="red", bool hide=false)
Definition: filter_model.h:129
Definition: filter_model.h:15