Exemple #1
0
 def addParentMatches(self, parent_list):
     lineMatchHits = 0
     for parent_key, parent_value in parent_list.items():
         if g.isString(parent_key):
             v = self.c.fileCommands.gnxDict.get(parent_key)
             h = v.h if v else parent_key
             it = QtWidgets.QListWidgetItem(h, self.lw)
         else:
             it = QtWidgets.QListWidgetItem(parent_key.h, self.lw)
         f = it.font()
         f.setItalic(True)
         it.setFont(f)
         if self.addItem(it, (parent_key, None)): return lineMatchHits
         for p in parent_value:
             it = QtWidgets.QListWidgetItem("    " + p.h, self.lw)
             f = it.font()
             f.setBold(True)
             it.setFont(f)
             if self.addItem(it, (p, None)): return lineMatchHits
             if hasattr(p, "matchiter"):  #p might be not have body matches
                 ms = matchlines(p.b, p.matchiter)
                 for ml, pos in ms:
                     lineMatchHits += 1
                     it = QtWidgets.QListWidgetItem("    " + "    " + ml,
                                                    self.lw)
                     if self.addItem(it, (p, pos)): return lineMatchHits
     return lineMatchHits
 def addParentMatches(self, parent_list):
     lineMatchHits = 0
     for parent_key, parent_value in parent_list.items():
         if g.isString(parent_key):
             it = QtWidgets.QListWidgetItem(parent_key, self.lw)
         else:
             it = QtWidgets.QListWidgetItem(parent_key.h, self.lw)
         f = it.font()
         f.setItalic(True)
         it.setFont(f)
         self.its[id(it)] = (parent_key, None)
         for p in parent_value:
             it = QtWidgets.QListWidgetItem("    " + p.h, self.lw)
             f = it.font()
             f.setBold(True)
             it.setFont(f)
             self.its[id(it)] = (p, None)
             if hasattr(p, "matchiter"):  #p might be not have body matches
                 ms = matchlines(p.b, p.matchiter)
                 for ml, pos in ms:
                     lineMatchHits += 1
                     it = QtWidgets.QListWidgetItem("    " + "    " + ml,
                                                    self.lw)
                     self.its[id(it)] = (p, pos)
     return lineMatchHits
Exemple #3
0
 def addBodyMatches(self, poslist):
     lineMatchHits = 0
     for p in poslist:
         it = QtWidgets.QListWidgetItem(p.h, self.lw)
         f = it.font()
         f.setBold(True)
         it.setFont(f)
         if self.addItem(it, (p, None)): return lineMatchHits
         ms = matchlines(p.b, p.matchiter)
         for ml, pos in ms:
             lineMatchHits += 1
             it = QtWidgets.QListWidgetItem("    " + ml, self.lw)
             if self.addItem(it, (p, pos)): return lineMatchHits
     return lineMatchHits
Exemple #4
0
    def addBodyMatches(self, poslist):

        for p in poslist:
            it = QtWidgets.QListWidgetItem(p.h, self.lw)
            f = it.font()
            f.setBold(True)
            it.setFont(f)

            self.its[id(it)] = (p, None)
            ms = matchlines(p.b, p.matchiter)
            for ml, pos in ms:
                #print "ml",ml,"pos",pos
                it = QtWidgets.QListWidgetItem(ml, self.lw)
                self.its[id(it)] = (p, pos)
Exemple #5
0
    def addHeadlineMatches(self, poslist):

        for p in poslist:
            it = QtWidgets.QListWidgetItem(p.h, self.lw)
            f = it.font()
            f.setBold(True)
            it.setFont(f)
            if self.addItem(it, (p, None)): return
    def addHeadlineMatches(self, poslist):

        for p in poslist:
            it = QtWidgets.QListWidgetItem(p.h, self.lw)
            f = it.font()
            f.setBold(True)
            it.setFont(f)
            self.its[id(it)] = (p, None)
Exemple #7
0
 def loadList(self, lst):
     self.UI.linkList.clear()
     for item in lst:
         if isinstance(item, (tuple, list)):
             list_item = QtWidgets.QListWidgetItem(item[0])
             list_item.setToolTip(item[1])
             self.UI.linkList.addItem(list_item)
         else:
             self.UI.linkList.addItem(item)
        def update_list(self):
            c = self.c
            gnxDict = c.fileCommands.gnxDict
            key = str(self.comboBox.currentText()).strip()
            current_tags = self.tc.get_all_tags()
            if key not in current_tags and key not in self.custom_searches:
                if len(re.split(self.search_re, key)) > 1:
                    self.custom_searches.append(key)

            query = re.split(self.search_re, key)
            tags = []
            operations = []
            for i, s in enumerate(query):
                if i % 2 == 0:
                    tags.append(s.strip())
                else:
                    operations.append(s.strip())
            tags.reverse()
            operations.reverse()

            resultset = set(self.tc.get_tagged_gnxes(tags.pop()))
            while operations:
                op = operations.pop()
                nodes = set(self.tc.get_tagged_gnxes(tags.pop()))
                if op == '&':
                    resultset &= nodes
                elif op == '|':
                    resultset |= nodes
                elif op == '-':
                    resultset -= nodes
                elif op == '^':
                    resultset ^= nodes

            self.listWidget.clear()
            self.mapping = {}
            for gnx in resultset:
                n = gnxDict.get(gnx)
                if n is not None:
                    item = QtWidgets.QListWidgetItem(n.h)
                    self.listWidget.addItem(item)
                    self.mapping[id(item)] = n
            count = self.listWidget.count()
            self.label.clear()
            self.label.setText("Total: %s nodes" % count)
Exemple #9
0
    def update_list(self):
        key = str(self.comboBox.currentText()).strip()
        current_tags = self.tc.get_all_tags()
        if key not in current_tags and key not in self.custom_searches:
            if len(re.split(self.search_re, key)) > 1:
                self.custom_searches.append(key)

        query = re.split(self.search_re, key)

        tags = []
        operations = []
        for i in range(len(query)):
            if i % 2 == 0:
                tags.append(query[i].strip())
            else:
                operations.append(query[i].strip())
        tags.reverse()
        operations.reverse()

        resultset = set(self.tc.get_tagged_nodes(tags.pop()))
        while len(operations) > 0:
            op = operations.pop()
            nodes = set(self.tc.get_tagged_nodes(tags.pop()))
            if op == '&':
                resultset &= nodes
            elif op == '|':
                resultset |= nodes
            elif op == '-':
                resultset -= nodes
            elif op == '^':
                resultset ^= nodes

        self.listWidget.clear()
        self.mapping = {}
        for n in resultset:
            item = QtWidgets.QListWidgetItem(n.h)
            self.listWidget.addItem(item)
            self.mapping[id(item)] = n
        count = self.listWidget.count()
        self.label.clear()
        self.label.setText("Total: %s nodes" % count)
Exemple #10
0
 def addGeneric(self, text, f):
     """ Add generic callback """
     it = QtWidgets.QListWidgetItem(text, self.lw)
     self.its[id(it)] = f
     return it