diff options
Diffstat (limited to 'examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py')
-rw-r--r-- | examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py | 75 |
1 files changed, 20 insertions, 55 deletions
diff --git a/examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py b/examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py index 93f2fe8ce..a30b0abdf 100644 --- a/examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py +++ b/examples/widgets/itemviews/basicfiltermodel/basicsortfiltermodel.py @@ -1,48 +1,10 @@ - -############################################################################# -## -## Copyright (C) 2013 Riverbank Computing Limited. -## Copyright (C) 2020 The Qt Company Ltd. -## Contact: http://www.qt.io/licensing/ -## -## This file is part of the Qt for Python examples of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:BSD$ -## You may use this file under the terms of the BSD license as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2013 Riverbank Computing Limited. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import sys from PySide6.QtCore import (QDate, QDateTime, QRegularExpression, - QSortFilterProxyModel, QTime, Qt) + QSortFilterProxyModel, QTime, Qt, Slot) from PySide6.QtGui import QStandardItemModel from PySide6.QtWidgets import (QApplication, QCheckBox, QComboBox, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit, @@ -84,11 +46,11 @@ class Window(QWidget): self._filter_syntax_combo_box = QComboBox() self._filter_syntax_combo_box.addItem("Regular expression", - REGULAR_EXPRESSION) + REGULAR_EXPRESSION) self._filter_syntax_combo_box.addItem("Wildcard", - WILDCARD) + WILDCARD) self._filter_syntax_combo_box.addItem("Fixed string", - FIXED_STRING) + FIXED_STRING) self._filter_syntax_label = QLabel("Filter &syntax:") self._filter_syntax_label.setBuddy(self._filter_syntax_combo_box) @@ -140,6 +102,7 @@ class Window(QWidget): self._proxy_model.setSourceModel(model) self._source_view.setModel(model) + @Slot() def filter_reg_exp_changed(self): syntax_nr = self._filter_syntax_combo_box.currentData() pattern = self._filter_pattern_line_edit.text() @@ -155,9 +118,11 @@ class Window(QWidget): reg_exp.setPatternOptions(options) self._proxy_model.setFilterRegularExpression(reg_exp) + @Slot() def filter_column_changed(self): self._proxy_model.setFilterKeyColumn(self._filter_column_combo_box.currentIndex()) + @Slot() def sort_changed(self): if self._sort_case_sensitivity_check_box.isChecked(): case_sensitivity = Qt.CaseSensitive @@ -182,25 +147,25 @@ def create_mail_model(parent): model.setHeaderData(2, Qt.Horizontal, "Date") add_mail(model, "Happy New Year!", "Grace K. <grace@software-inc.com>", - QDateTime(QDate(2006, 12, 31), QTime(17, 3))) + QDateTime(QDate(2006, 12, 31), QTime(17, 3))) add_mail(model, "Radically new concept", "Grace K. <grace@software-inc.com>", - QDateTime(QDate(2006, 12, 22), QTime(9, 44))) + QDateTime(QDate(2006, 12, 22), QTime(9, 44))) add_mail(model, "Accounts", "pascale@nospam.com", - QDateTime(QDate(2006, 12, 31), QTime(12, 50))) + QDateTime(QDate(2006, 12, 31), QTime(12, 50))) add_mail(model, "Expenses", "Joe Bloggs <joe@bloggs.com>", - QDateTime(QDate(2006, 12, 25), QTime(11, 39))) + QDateTime(QDate(2006, 12, 25), QTime(11, 39))) add_mail(model, "Re: Expenses", "Andy <andy@nospam.com>", - QDateTime(QDate(2007, 1, 2), QTime(16, 5))) + QDateTime(QDate(2007, 1, 2), QTime(16, 5))) add_mail(model, "Re: Accounts", "Joe Bloggs <joe@bloggs.com>", - QDateTime(QDate(2007, 1, 3), QTime(14, 18))) + QDateTime(QDate(2007, 1, 3), QTime(14, 18))) add_mail(model, "Re: Accounts", "Andy <andy@nospam.com>", - QDateTime(QDate(2007, 1, 3), QTime(14, 26))) + QDateTime(QDate(2007, 1, 3), QTime(14, 26))) add_mail(model, "Sports", "Linda Smith <linda.smith@nospam.com>", - QDateTime(QDate(2007, 1, 5), QTime(11, 33))) + QDateTime(QDate(2007, 1, 5), QTime(11, 33))) add_mail(model, "AW: Sports", "Rolf Newschweinstein <rolfn@nospam.com>", - QDateTime(QDate(2007, 1, 5), QTime(12, 0))) + QDateTime(QDate(2007, 1, 5), QTime(12, 0))) add_mail(model, "RE: Sports", "Petra Schmidt <petras@nospam.com>", - QDateTime(QDate(2007, 1, 5), QTime(12, 1))) + QDateTime(QDate(2007, 1, 5), QTime(12, 1))) return model |