filtering by name added

This commit is contained in:
ingvar1995 2016-03-02 23:55:12 +03:00
parent 26fcc260df
commit b9937c13cd
2 changed files with 7 additions and 5 deletions

View file

@ -102,9 +102,10 @@ class MainWindow(QtGui.QMainWindow):
self.online_contacts.setGeometry(QtCore.QRect(0, 20, 141, 22)) self.online_contacts.setGeometry(QtCore.QRect(0, 20, 141, 22))
self.online_contacts.setObjectName("online_contacts") self.online_contacts.setObjectName("online_contacts")
self.online_contacts.clicked.connect(self.filtering) self.online_contacts.clicked.connect(self.filtering)
self.lineEdit = QtGui.QLineEdit(Form) self.contact_name = QtGui.QLineEdit(Form)
self.lineEdit.setGeometry(QtCore.QRect(0, 40, 140, 28)) self.contact_name.setGeometry(QtCore.QRect(0, 40, 140, 28))
self.lineEdit.setObjectName("lineEdit") 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)) self.online_contacts.setText(QtGui.QApplication.translate("Form", "Online contacts", None, QtGui.QApplication.UnicodeUTF8))
QtCore.QMetaObject.connectSlotsByName(Form) QtCore.QMetaObject.connectSlotsByName(Form)
@ -284,4 +285,4 @@ class MainWindow(QtGui.QMainWindow):
self.messageEdit.clear() self.messageEdit.clear()
def filtering(self): def filtering(self):
self.profile.filtration(self.online_contacts.isChecked()) self.profile.filtration(self.online_contacts.isChecked(), self.contact_name.text())

View file

@ -174,8 +174,9 @@ class Profile(Contact):
def filtration(self, show_online=True, filter_str=''): def filtration(self, show_online=True, filter_str=''):
# TODO: hide elements in list # TODO: hide elements in list
filter_str = filter_str.lower()
for friend in self._friends: 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 self.show_online, self.filter_string = show_online, filter_str
def get_friend_by_number(self, num): def get_friend_by_number(self, num):