History

perf scripts python: exported-sql-viewer.py: Factor out ReportVars

Factor out ReportVars to provide a single container for information from report dialogs.

Adrian Hunter committed 7 years ago

Commit 0bf09471 parent 0924cd61 file · +23 −14Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/exported-sql-viewer.py+23−14
@@ -1398,18 +1398,26 @@ class BranchModel(TreeModel): · 1397 unmodified lines
1398 def HasMoreRecords(self):1398 def HasMoreRecords(self):
1399 return self.more1399 return self.more
1400 1400
1401# Report Variables
1402
1403class ReportVars():
1404
1405 def __init__(self, where_clause = ""):
1406 self.where_clause = where_clause
1407
1408 def UniqueId(self):
1409 return str(self.where_clause)
1410
1401# Branch window1411# Branch window
1402 1412
1403class BranchWindow(QMdiSubWindow):1413class BranchWindow(QMdiSubWindow):
1404 1414
1405 def __init__(self, glb, event_id, name, where_clause, parent=None):1415 def __init__(self, glb, event_id, name, report_vars, parent=None):
1406 super(BranchWindow, self).__init__(parent)1416 super(BranchWindow, self).__init__(parent)
1407 1417
1408 model_name = "Branch Events " + str(event_id)1418 model_name = "Branch Events " + str(event_id) + " " + report_vars.UniqueId()
1409 if len(where_clause):
1410 model_name = where_clause + " " + model_name
1411 1419
1412 self.model = LookupCreateModel(model_name, lambda: BranchModel(glb, event_id, where_clause))1420 self.model = LookupCreateModel(model_name, lambda: BranchModel(glb, event_id, report_vars.where_clause))
1413 1421
1414 self.view = QTreeView()1422 self.view = QTreeView()
1415 self.view.setUniformRowHeights(True)1423 self.view.setUniformRowHeights(True)
@@ -1703,7 +1711,7 @@ class ReportDialogBase(QDialog): · 287 unmodified lines
1703 self.glb = glb1711 self.glb = glb
1704 1712
1705 self.name = ""1713 self.name = ""
1706 self.where_clause = ""1714 self.report_vars = ReportVars()
1707 1715
1708 self.setWindowTitle(title)1716 self.setWindowTitle(title)
1709 self.setMinimumWidth(600)1717 self.setMinimumWidth(600)
@@ -1742,6 +1750,7 @@ class ReportDialogBase(QDialog): · 32 unmodified lines
1742 self.setLayout(self.vbox);1750 self.setLayout(self.vbox);
1743 1751
1744 def Ok(self):1752 def Ok(self):
1753 vars = self.report_vars
1745 self.name = self.data_items[0].value1754 self.name = self.data_items[0].value
1746 if not self.name:1755 if not self.name:
1747 self.ShowMessage("Report name is required")1756 self.ShowMessage("Report name is required")
@@ -1751,14 +1760,14 @@ class ReportDialogBase(QDialog): · 3 unmodified lines
1751 return1760 return
1752 for d in self.data_items[1:]:1761 for d in self.data_items[1:]:
1753 if len(d.value):1762 if len(d.value):
1754 if len(self.where_clause):1763 if len(vars.where_clause):
1755 self.where_clause += " AND "1764 vars.where_clause += " AND "
1756 self.where_clause += d.value1765 vars.where_clause += d.value
1757 if len(self.where_clause):1766 if len(vars.where_clause):
1758 if self.partial:1767 if self.partial:
1759 self.where_clause = " AND ( " + self.where_clause + " ) "1768 vars.where_clause = " AND ( " + vars.where_clause + " ) "
1760 else:1769 else:
1761 self.where_clause = " WHERE " + self.where_clause + " "1770 vars.where_clause = " WHERE " + vars.where_clause + " "
1762 else:1771 else:
1763 self.ShowMessage("No selection")1772 self.ShowMessage("No selection")
1764 return1773 return
@@ -2383,13 +2392,13 @@ class MainWindow(QMainWindow): · 618 unmodified lines
2383 CallGraphWindow(self.glb, self)2392 CallGraphWindow(self.glb, self)
2384 2393
2385 def NewBranchView(self, event_id):2394 def NewBranchView(self, event_id):
2386 BranchWindow(self.glb, event_id, "", "", self)2395 BranchWindow(self.glb, event_id, "", ReportVars(), self)
2387 2396
2388 def NewSelectedBranchView(self, event_id):2397 def NewSelectedBranchView(self, event_id):
2389 dialog = SelectedBranchDialog(self.glb, self)2398 dialog = SelectedBranchDialog(self.glb, self)
2390 ret = dialog.exec_()2399 ret = dialog.exec_()
2391 if ret:2400 if ret:
2392 BranchWindow(self.glb, event_id, dialog.name, dialog.where_clause, self)2401 BranchWindow(self.glb, event_id, dialog.name, dialog.report_vars, self)
2393 2402
2394 def NewTableView(self, table_name):2403 def NewTableView(self, table_name):
2395 TableWindow(self.glb, table_name, self)2404 TableWindow(self.glb, table_name, self)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t