Beispiel #1
0
    def mouseMoveEvent(self, event):
        TableView.mouseMoveEvent(self, event)
        if not self.data:
            return

        index = self.indexAt(event.pos())
        # Cursor isn't on a row
        if not index.isValid():
            self.setCursor(Qt.ArrowCursor)
            return

        # get data
        field = unicode(self.columns[index.column()])
        arg_data = self.model().data(self.model().index(index.row(), index.column(), self.rootIndex()), Qt.UserRole).toPyObject()

        arg = arg_types[field]

        hand = False
        if self.cumulative_mode:
            filters = self.fetcher.getArgs()
            args = arg_types[field].get_pagelink_args(field, arg_data)
            for key, value in args.iteritems():
                if key in filters:
                    hand = True
            if not hand and field in filters:
                hand = True
        elif self.current_page:
            hand = bool(self.current_page.get_pagelink_default(field, arg_data))

        if hand:
            self.setCursor(Qt.OpenHandCursor)
        else:
            self.setCursor(Qt.ArrowCursor)
Beispiel #2
0
    def __init__(self, fetcher, parent):
        TableView.__init__(self, parent)
        NulogBaseFragmentView.__init__(self, fetcher)

        # Disable edition
        self.setEditTriggers(QAbstractItemView.NoEditTriggers)

        # Define the callback when headers are clicked (sorting function)
        self.connect(self.header, SIGNAL('sectionPressed(int)'), self.sortView)

        self.header.setSortIndicatorShown(True)
Beispiel #3
0
    def mousePressEvent(self, event):

        TableView.mousePressEvent(self, event)
        if event.button() != Qt.RightButton or not self.data:
            return

        index = self.indexAt(event.pos())
        # Cursor isn't on a row
        if not index.isValid():
            return

        if self.indexWidget(index):
            return

        # get data
        field = unicode(self.columns[index.column()])
        arg_data = self.model().data(self.model().index(index.row(), index.column(), self.rootIndex()), Qt.UserRole).toPyObject()

        # Create a menu to display all pages...
        menu = QMenu(self)

        copyAction = QAction(self.tr('Copy text'), self)
        self.connect(copyAction, SIGNAL('triggered()'), self.copySelection)
        menu.addAction(copyAction)

        if self.fragment.type != 'IDSIPSTable':
            packetinfoAction = QAction(self.tr('Packet details'), self)
            self.connect(packetinfoAction, SIGNAL('triggered()'), self._openPacketInfo)
            menu.addAction(packetinfoAction)

        for action in arg_data.actions():
            action.setParent(self)
            menu.addAction(action)

        menu.addSeparator()
        if self.current_page:
            pages = self.current_page.get_pagelinks(field, arg_data)
            if self.user_settings and pages:
                for page in pages:
                    title = self.user_settings['pages'].pages[page].title
                    action = QAction(tr('Open "%s" view') % title, self)

                    # Usefull data used when action is triggered
                    data = [page, field, unicode(arg_data.label), unicode(arg_data.value)]
                    data = QVariant(data)
                    # With PyQt 4.7.3, data type is List instead of StringList:
                    # force the cast to StringList
                    data.convert(QVariant.StringList)
                    action.setData(data)
                    menu.addAction(action)

        #if pages:
        #    menu.addSeparator()

        # And ask user if he wants to create a new page...
        #createPageAction = QAction(self.tr('Create a new view for this entity...'), self)
        #self.connect(createPageAction, SIGNAL("triggered()"), lambda: self.createPageEvent(field, arg_data.label, arg_data.value))
        #menu.addAction(createPageAction)

        self.connect(menu, SIGNAL('triggered(QAction*)'), self.loadPageEvent)

        menu.exec_(event.globalPos())