summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2010-11-10 11:21:53 +0100
committerOlivier Goffart <olivier.goffart@nokia.com>2011-05-11 17:37:48 +0200
commitd49c561b7374bf72684c6eaea6e65c71f69e0150 (patch)
treef3c3712acb5197a86bd99a08a9f454ad47b98964 /doc
parent1355da4b0f212921aeff201960a11ef8de6625a0 (diff)
Add the QIdentityProxyModel.
Older commit history is in KDE svn: http://websvn.kde.org/trunk/KDE/kdelibs/kdeui/itemviews/kidentityproxymodel.cpp?view=log Ammended to update the license headers. Merge-request: 900 Reviewed-by: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> Conflicts: doc/src/frameworks-technologies/model-view-programming.qdoc tests/auto/headers/tst_headers.cpp (cherry picked from b00089261eafbdf5f92ed94d7fb20b402bfcaeb2)
Diffstat (limited to 'doc')
-rw-r--r--doc/src/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/doc/src/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp b/doc/src/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp
new file mode 100644
index 0000000000..8bd65208cb
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB,
+** a KDAB Group company, info@kdab.com,
+** author Stephen Kelly <stephen.kelly@kdab.com>
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module 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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+//! [0]
+class DateFormatProxyModel : public QIdentityProxyModel
+{
+ // ...
+
+ void setDateFormatString(const QString &formatString)
+ {
+ m_formatString = formatString;
+ }
+
+ QVariant data(const QModelIndex &index, int role)
+ {
+ if (role != Qt::DisplayRole)
+ return QIdentityProxyModel::data(index, role);
+
+ const QDateTime dateTime = sourceModel()->data(SourceClass::DateRole).toDateTime();
+
+ return dateTime.toString(m_formatString);
+ }
+
+private:
+ QString m_formatString;
+};
+//! [0]