E5Gui/E5ErrorMessageFilterDialog.py

Mon, 08 Jul 2013 22:36:10 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Mon, 08 Jul 2013 22:36:10 +0200
branch
Py2 comp.
changeset 2791
a9577f248f04
parent 2697
1cd7fa670b05
child 3057
10516539f238
permissions
-rw-r--r--

Merge with default branch.

# -*- coding: utf-8 -*-

# Copyright (c) 2013 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to manage the list of messages to be ignored.
"""

from __future__ import unicode_literals    # __IGNORE_WARNING__

from PyQt4.QtCore import pyqtSlot, Qt
from PyQt4.QtGui import QDialog, QStringListModel, QSortFilterProxyModel, \
    QInputDialog, QLineEdit

from .Ui_E5ErrorMessageFilterDialog import Ui_E5ErrorMessageFilterDialog


class E5ErrorMessageFilterDialog(QDialog, Ui_E5ErrorMessageFilterDialog):
    """
    Class implementing a dialog to manage the list of messages to be ignored.
    """
    def __init__(self, messageFilters, parent=None):
        """
        Constructor
        
        @param messageFilters list of message filters to be edited (list of strings)
        @param parent reference to the parent widget (QWidget)
        """
        super(E5ErrorMessageFilterDialog, self).__init__(parent)
        self.setupUi(self)
        
        self.__model = QStringListModel(messageFilters, self)
        self.__model.sort(0)
        self.__proxyModel = QSortFilterProxyModel(self)
        self.__proxyModel.setFilterCaseSensitivity(Qt.CaseInsensitive)
        self.__proxyModel.setSourceModel(self.__model)
        self.filterList.setModel(self.__proxyModel)
        
        self.searchEdit.textChanged.connect(self.__proxyModel.setFilterFixedString)
        
        self.removeButton.clicked[()].connect(self.filterList.removeSelected)
        self.removeAllButton.clicked[()].connect(self.filterList.removeAll)
    
    @pyqtSlot()
    def on_addButton_clicked(self):
        """
        Private slot to add an entry to the list.
        """
        filter, ok = QInputDialog.getText(
            self,
            self.trUtf8("Error Messages Filter"),
            self.trUtf8("Enter message filter to add to the list:"),
            QLineEdit.Normal)
        if ok and filter != "" and filter not in self.__model.stringList():
            self.__model.insertRow(self.__model.rowCount())
            self.__model.setData(
                self.__model.index(self.__model.rowCount() - 1), filter)
            self.__model.sort(0)
    
    def getFilters(self):
        """
        Public method to get the list of message filters.
        
        @return error message filters (list of strings)
        """
        return self.__model.stringList()[:]

eric ide

mercurial