/usr/include/kmodelindexproxymapper.h is in kdelibs5-dev 4:4.13.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | /*
Copyright (C) 2010 Klarälvdalens Datakonsult AB,
a KDAB Group company, info@kdab.net,
author Stephen Kelly <stephen@kdab.com>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef KMODELINDEXPROXYMAPPER_H
#define KMODELINDEXPROXYMAPPER_H
#include <QObject>
#include "kdeui_export.h"
class QAbstractItemModel;
class QModelIndex;
class QItemSelection;
class KModelIndexProxyMapperPrivate;
/**
* @brief This class facilitates easy mapping of indexes and selections through proxy models.
*
* In a complex system of proxy models there can be a need to map indexes and selections between them,
* and sometimes to do so without knowledge of the path from one model to another.
*
* For example,
*
* @verbatim
* Root model
* |
* / \
* Proxy 1 Proxy 3
* | |
* Proxy 2 Proxy 4
* @endverbatim
*
* If there is a need to map indexes between proxy 2 and proxy 4, a KModelIndexProxyMapper can be created
* to facilitate mapping of indexes between them.
*
* @code
* m_indexMapper = new KModelIndexProxyMapper(proxy2, proxy4, this);
*
* ...
*
* const QModelIndex proxy4Index = m_mapLeftToRight(proxy2->index(0, 0));
* Q_ASSERT(proxy4Index.model() == proxy4);
* @endcode
*
* Note that the aim is to achieve black box connections so that there is no need for application code to
* know the structure of proxy models in the path between left and right and attempt to manually map them.
*
* @verbatim
* Root model
* |
* ---------------
* | Black Box |
* ---------------
* | |
* Proxy 2 Proxy 4
* @endverbatim
*
* @author Stephen Kelly <steveire@gmail.com>
*
*/
class KDEUI_EXPORT KModelIndexProxyMapper : public QObject
{
Q_OBJECT
public:
/**
* Constructor
*/
KModelIndexProxyMapper(const QAbstractItemModel *leftModel, const QAbstractItemModel *rightModel, QObject* parent = 0);
~KModelIndexProxyMapper();
/**
* Maps the @p index from the left model to the right model.
*/
QModelIndex mapLeftToRight(const QModelIndex &index) const;
/**
* Maps the @p index from the right model to the left model.
*/
QModelIndex mapRightToLeft(const QModelIndex &index) const;
/**
* Maps the @p selection from the left model to the right model.
*/
QItemSelection mapSelectionLeftToRight(const QItemSelection &selection) const;
/**
* Maps the @p selection from the right model to the left model.
*/
QItemSelection mapSelectionRightToLeft(const QItemSelection &selection) const;
private:
//@cond PRIVATE
Q_DECLARE_PRIVATE(KModelIndexProxyMapper)
KModelIndexProxyMapperPrivate * const d_ptr;
//@endcond
};
#endif
|