Skip to content

Commit a448ba2

Browse files
ahunter6acmel
authored andcommitted
perf scripts python: exported-sql-viewer.py: Improve TreeModel abstraction
Instead of passing the tree root, get it from a method that can be implemented in any derived class. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: https://lkml.kernel.org/n/tip-ovcv28bg4mt9swk36ypdyz14@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent a731cc4 commit a448ba2

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

‎tools/perf/scripts/python/exported-sql-viewer.py‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ def run(self):
167167

168168
class TreeModel(QAbstractItemModel):
169169

170-
def __init__(self, root, parent=None):
170+
def __init__(self, glb, parent=None):
171171
super(TreeModel, self).__init__(parent)
172-
self.root = root
172+
self.glb = glb
173+
self.root = self.GetRoot()
173174
self.last_row_read = 0
174175

175176
def Item(self, parent):
@@ -562,8 +563,10 @@ def __init__(self, glb):
562563
class CallGraphModel(TreeModel):
563564

564565
def __init__(self, glb, parent=None):
565-
super(CallGraphModel, self).__init__(CallGraphRootItem(glb), parent)
566-
self.glb = glb
566+
super(CallGraphModel, self).__init__(glb, parent)
567+
568+
def GetRoot(self):
569+
return CallGraphRootItem(self.glb)
567570

568571
def columnCount(self, parent=None):
569572
return 7
@@ -1339,8 +1342,7 @@ class BranchModel(TreeModel):
13391342
progress = Signal(object)
13401343

13411344
def __init__(self, glb, event_id, where_clause, parent=None):
1342-
super(BranchModel, self).__init__(BranchRootItem(), parent)
1343-
self.glb = glb
1345+
super(BranchModel, self).__init__(glb, parent)
13441346
self.event_id = event_id
13451347
self.more = True
13461348
self.populated = 0
@@ -1364,6 +1366,9 @@ def __init__(self, glb, event_id, where_clause, parent=None):
13641366
self.fetcher.done.connect(self.Update)
13651367
self.fetcher.Fetch(glb_chunk_sz)
13661368

1369+
def GetRoot(self):
1370+
return BranchRootItem()
1371+
13671372
def columnCount(self, parent=None):
13681373
return 8
13691374

0 commit comments

Comments
 (0)