From b9937c13cdfe9e34ce8a683581721a270557f6f2 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 2 Mar 2016 23:55:12 +0300 Subject: [PATCH] filtering by name added --- src/mainscreen.py | 9 +++++---- src/profile.py | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mainscreen.py b/src/mainscreen.py index 95d4839..51635bb 100644 --- a/src/mainscreen.py +++ b/src/mainscreen.py @@ -102,9 +102,10 @@ class MainWindow(QtGui.QMainWindow): self.online_contacts.setGeometry(QtCore.QRect(0, 20, 141, 22)) self.online_contacts.setObjectName("online_contacts") self.online_contacts.clicked.connect(self.filtering) - self.lineEdit = QtGui.QLineEdit(Form) - self.lineEdit.setGeometry(QtCore.QRect(0, 40, 140, 28)) - self.lineEdit.setObjectName("lineEdit") + self.contact_name = QtGui.QLineEdit(Form) + self.contact_name.setGeometry(QtCore.QRect(0, 40, 140, 28)) + self.contact_name.setObjectName("contact_name") + self.contact_name.textChanged.connect(self.filtering) self.online_contacts.setText(QtGui.QApplication.translate("Form", "Online contacts", None, QtGui.QApplication.UnicodeUTF8)) QtCore.QMetaObject.connectSlotsByName(Form) @@ -284,4 +285,4 @@ class MainWindow(QtGui.QMainWindow): self.messageEdit.clear() def filtering(self): - self.profile.filtration(self.online_contacts.isChecked()) + self.profile.filtration(self.online_contacts.isChecked(), self.contact_name.text()) diff --git a/src/profile.py b/src/profile.py index 7f69b18..a6b2fea 100644 --- a/src/profile.py +++ b/src/profile.py @@ -174,8 +174,9 @@ class Profile(Contact): def filtration(self, show_online=True, filter_str=''): # TODO: hide elements in list + filter_str = filter_str.lower() for friend in self._friends: - friend.visibility = (friend.status is not None or not show_online) and (filter_str in friend.name) + friend.visibility = (friend.status is not None or not show_online) and (filter_str in friend.name.lower()) self.show_online, self.filter_string = show_online, filter_str def get_friend_by_number(self, num):