File indexing completed on 2024-11-24 04:53:12

0001 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net>
0002 
0003    This file is part of the Trojita Qt IMAP e-mail client,
0004    http://trojita.flaska.net/
0005 
0006    This program is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU General Public License as
0008    published by the Free Software Foundation; either version 2 of
0009    the License or (at your option) version 3 or any later version
0010    accepted by the membership of KDE e.V. (or its successor approved
0011    by the membership of KDE e.V.), which shall act as a proxy
0012    defined in Section 14 of version 3 of the license.
0013 
0014    This program is distributed in the hope that it will be useful,
0015    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017    GNU General Public License for more details.
0018 
0019    You should have received a copy of the GNU General Public License
0020    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 */
0022 #include <QDebug>
0023 #include "ModelWatcher.h"
0024 
0025 namespace Imap
0026 {
0027 
0028 namespace Mailbox
0029 {
0030 
0031 void ModelWatcher::setModel(QAbstractItemModel *model)
0032 {
0033     connect(model, &QAbstractItemModel::columnsAboutToBeInserted, this, &ModelWatcher::columnsAboutToBeInserted);
0034     connect(model, &QAbstractItemModel::columnsAboutToBeRemoved, this, &ModelWatcher::columnsAboutToBeRemoved);
0035     connect(model, &QAbstractItemModel::rowsAboutToBeInserted, this, &ModelWatcher::rowsAboutToBeInserted);
0036     connect(model, &QAbstractItemModel::rowsAboutToBeRemoved, this, &ModelWatcher::rowsAboutToBeRemoved);
0037     connect(model, &QAbstractItemModel::columnsInserted, this, &ModelWatcher::columnsInserted);
0038     connect(model, &QAbstractItemModel::columnsRemoved, this, &ModelWatcher::columnsRemoved);
0039     connect(model, &QAbstractItemModel::rowsInserted, this, &ModelWatcher::rowsInserted);
0040     connect(model, &QAbstractItemModel::rowsRemoved, this, &ModelWatcher::rowsRemoved);
0041     connect(model, &QAbstractItemModel::dataChanged, this, &ModelWatcher::dataChanged);
0042     connect(model, &QAbstractItemModel::headerDataChanged, this, &ModelWatcher::headerDataChanged);
0043 
0044     connect(model, &QAbstractItemModel::rowsAboutToBeMoved, this, &ModelWatcher::rowsAboutToBeMoved);
0045     connect(model, &QAbstractItemModel::rowsMoved, this, &ModelWatcher::rowsMoved);
0046     connect(model, &QAbstractItemModel::columnsAboutToBeMoved, this, &ModelWatcher::columnsAboutToBeMoved);
0047     connect(model, &QAbstractItemModel::columnsMoved, this, &ModelWatcher::columnsMoved);
0048     connect(model, &QAbstractItemModel::layoutAboutToBeChanged, this, &ModelWatcher::layoutAboutToBeChanged);
0049     connect(model, &QAbstractItemModel::layoutChanged, this, &ModelWatcher::layoutChanged);
0050     connect(model, &QAbstractItemModel::modelAboutToBeReset, this, &ModelWatcher::modelAboutToBeReset);
0051     connect(model, &QAbstractItemModel::modelReset, this, &ModelWatcher::modelReset);
0052 }
0053 
0054 void ModelWatcher::columnsAboutToBeInserted(const QModelIndex &parent, int start, int end)
0055 {
0056     qDebug() << sender()->objectName() << "columnsAboutToBeInserted(" << parent << start << end << ")";
0057 }
0058 
0059 void ModelWatcher::columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
0060 {
0061     qDebug() << sender()->objectName() << "columnsAboutToBeRemoved(" << parent << start << end << ")";
0062 }
0063 
0064 void ModelWatcher::columnsInserted(const QModelIndex &parent, int start, int end)
0065 {
0066     qDebug() << sender()->objectName() << "columnsInserted(" << parent << start << end << ")";
0067 }
0068 
0069 void ModelWatcher::columnsRemoved(const QModelIndex &parent, int start, int end)
0070 {
0071     qDebug() << sender()->objectName() << "columnsRemoved(" << parent << start << end << ")";
0072 }
0073 
0074 void ModelWatcher::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
0075 {
0076     qDebug() << sender()->objectName() << "dataChanged(" << topLeft << bottomRight << ")";
0077     if (!m_ignoreData)
0078         qDebug() << "new data" << topLeft.data(Qt::DisplayRole);
0079 }
0080 void ModelWatcher::headerDataChanged(Qt::Orientation orientation, int first, int last)
0081 {
0082     qDebug() << sender()->objectName() << "headerDataChanged(" << orientation << first << last << ")";
0083 }
0084 void ModelWatcher::layoutAboutToBeChanged()
0085 {
0086     qDebug() << sender()->objectName() << "layoutAboutToBeChanged()";
0087 }
0088 
0089 void ModelWatcher::layoutChanged()
0090 {
0091     qDebug() << sender()->objectName() << "layoutChanged()";
0092 }
0093 
0094 void ModelWatcher::modelAboutToBeReset()
0095 {
0096     qDebug() << sender()->objectName() << "modelAboutToBeReset()";
0097 }
0098 
0099 void ModelWatcher::modelReset()
0100 {
0101     qDebug() << sender()->objectName() << "modelReset()";
0102 }
0103 
0104 void ModelWatcher::rowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
0105 {
0106     qDebug() << sender()->objectName() << "rowsAboutToBeInserted(" << parent << start << end << ")";
0107 }
0108 
0109 void ModelWatcher::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
0110 {
0111     qDebug() << sender()->objectName() << "rowsAboutToBeRemoved(" << parent << start << end << ")";
0112 }
0113 
0114 void ModelWatcher::rowsInserted(const QModelIndex &parent, int start, int end)
0115 {
0116     qDebug() << sender()->objectName() << "rowsInserted(" << parent << start << end << ")";
0117 }
0118 
0119 void ModelWatcher::rowsRemoved(const QModelIndex &parent, int start, int end)
0120 {
0121     qDebug() << sender()->objectName() << "rowsRemoved(" << parent << start << end << ")";
0122 }
0123 
0124 void ModelWatcher::rowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd,
0125                                       const QModelIndex &destinationParent, int destinationRow)
0126 {
0127     qDebug() << sender()->objectName() << "rowsAboutToBeMoved" << sourceParent << sourceStart << sourceEnd <<
0128                 destinationParent << destinationRow;
0129 }
0130 
0131 void ModelWatcher::rowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
0132 {
0133     qDebug() << sender()->objectName() << "rowsMoved" << parent << start << end << destination << row;
0134 }
0135 
0136 void ModelWatcher::columnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd,
0137                                          const QModelIndex &destinationParent, int destinationColumn)
0138 {
0139     qDebug() << sender()->objectName() << "columnsAboutToBeMoved" << sourceParent << sourceStart << sourceEnd <<
0140                 destinationParent << destinationColumn;
0141 }
0142 
0143 void ModelWatcher::columnsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column)
0144 {
0145     qDebug() << sender()->objectName() << "columnsMoved" << parent << start << end << destination << column;
0146 }
0147 
0148 }
0149 
0150 }