[Tux4kids-commits] r1357 - tux4kids-admin/trunk/tux4kids-admin/src

Michał Świtakowski swistakers-guest at alioth.debian.org
Tue Aug 4 16:43:32 UTC 2009


Author: swistakers-guest
Date: 2009-08-04 16:43:32 +0000 (Tue, 04 Aug 2009)
New Revision: 1357

Modified:
   tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.h
   tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.h
   tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.cpp
   tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.h
Log:
simple filter functionality for proxy models

Modified: tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.cpp	2009-08-04 15:06:09 UTC (rev 1356)
+++ tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.cpp	2009-08-04 16:43:32 UTC (rev 1357)
@@ -23,3 +23,12 @@
 					   rightData.toString()) < 0;
 	}
 }
+
+bool ClassTableProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+{
+	QModelIndex indexName = sourceModel()->index(sourceRow, ClassTableModel::ClassName, sourceParent);
+
+	return sourceModel()->data(indexName).toString().contains(filterRegExp());
+
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.h	2009-08-04 15:06:09 UTC (rev 1356)
+++ tux4kids-admin/trunk/tux4kids-admin/src/classTableProxyModel.h	2009-08-04 16:43:32 UTC (rev 1357)
@@ -10,6 +10,7 @@
 	ClassTableProxyModel(QObject *parent = 0);
 
 	bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
+	bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
 };
 
 #endif // CLASSTABLEPROXYMODEL_H

Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp	2009-08-04 15:06:09 UTC (rev 1356)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.cpp	2009-08-04 16:43:32 UTC (rev 1357)
@@ -23,3 +23,13 @@
 	}
 }
 
+bool StudentTableProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+{
+	QModelIndex indexFirstName = sourceModel()->index(sourceRow, StudentTableModel::StudentFirstName, sourceParent);
+	QModelIndex indexLastName = sourceModel()->index(sourceRow, StudentTableModel::StudentLastName, sourceParent);
+
+	return sourceModel()->data(indexFirstName).toString().contains(filterRegExp())
+			|| sourceModel()->data(indexLastName).toString().contains(filterRegExp());
+
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.h	2009-08-04 15:06:09 UTC (rev 1356)
+++ tux4kids-admin/trunk/tux4kids-admin/src/studentTableProxyModel.h	2009-08-04 16:43:32 UTC (rev 1357)
@@ -10,6 +10,7 @@
 	StudentTableProxyModel(QObject *parent = 0);
 
 	bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
+	bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
 };
 
 #endif // STUDENTTABLEPROXYMODEL_H

Modified: tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.cpp	2009-08-04 15:06:09 UTC (rev 1356)
+++ tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.cpp	2009-08-04 16:43:32 UTC (rev 1357)
@@ -22,3 +22,13 @@
 	}
 }
 
+bool TeacherTableProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+{
+	QModelIndex indexFirstName = sourceModel()->index(sourceRow, TeacherTableModel::TeacherFirstName, sourceParent);
+	QModelIndex indexLastName = sourceModel()->index(sourceRow, TeacherTableModel::TeacherLastName, sourceParent);
+
+	return sourceModel()->data(indexFirstName).toString().contains(filterRegExp())
+			|| sourceModel()->data(indexLastName).toString().contains(filterRegExp());
+
+}
+

Modified: tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.h	2009-08-04 15:06:09 UTC (rev 1356)
+++ tux4kids-admin/trunk/tux4kids-admin/src/teacherTableProxyModel.h	2009-08-04 16:43:32 UTC (rev 1357)
@@ -10,6 +10,8 @@
 	TeacherTableProxyModel(QObject *parent = 0);
 
 	bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
+	bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
+
 };
 
 #endif // TEACHERTABLEPROXYMODEL_H




More information about the Tux4kids-commits mailing list