Merge changes Ib95dd5ab,Icdcef7ee,I0bc87d27
[trojita.git] / tests / Utils / ModelEvents.cpp
bloba7c942c98d5d70822b0249efc545ad42d2b077c9
1 /* Copyright (C) 2012 - 2013 Peter Amidon <peter@picnicpark.org>
3 This file is part of the Trojita Qt IMAP e-mail client,
4 http://trojita.flaska.net/
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of
9 the License or (at your option) version 3 or any later version
10 accepted by the membership of KDE e.V. (or its successor approved
11 by the membership of KDE e.V.), which shall act as a proxy
12 defined in Section 14 of version 3 of the license.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include <QtTest>
24 #include "ModelEvents.h"
25 #include "Common/MetaTypes.h"
27 namespace QTest
29 template<>
30 char *toString(const ModelInsertRemoveEvent &event)
32 QString buf;
33 QDebug(&buf) << "parent:" << event.parent
34 << "start:" << event.start
35 << "end:" << event.end;
36 return qstrdup(buf.toUtf8().constData());
39 template<>
40 char *toString(const ModelMoveEvent &event)
42 QString buf;
43 QDebug(&buf) << "sourceParent:" << event.sourceParent << "sourceStart:" << event.sourceStart
44 << "sourceEnd:" << event.sourceEnd << "destinationParent:" << event.destinationParent
45 << "destinationRow:" << event.destinationRow;
46 return qstrdup(buf.toUtf8().constData());
50 ModelInsertRemoveEvent::ModelInsertRemoveEvent(const QVariantList &values)
52 parent = qvariant_cast<QModelIndex>(values.at(0));
53 start = values.at(1).toInt();
54 end = values.at(2).toInt();
57 ModelInsertRemoveEvent::ModelInsertRemoveEvent(const QModelIndex &parent, int start, int end) :
58 parent(parent), start(start), end(end)
62 bool ModelInsertRemoveEvent::operator==(const ModelInsertRemoveEvent &b) const
64 return ((parent == b.parent) && (start == b.start) && (end == b.end));
67 ModelMoveEvent::ModelMoveEvent(const QVariantList &values)
69 sourceParent = qvariant_cast<QModelIndex>(values.at(0));
70 sourceStart = values.at(1).toInt();
71 sourceEnd = values.at(2).toInt();
72 destinationParent = qvariant_cast<QModelIndex>(values.at(3));
73 destinationRow = values.at(4).toInt();
76 ModelMoveEvent::ModelMoveEvent(const QModelIndex &sourceParent, int sourceStart, int sourceEnd,
77 const QModelIndex &destinationParent, int destinationRow) :
78 sourceParent(sourceParent), sourceStart(sourceStart), sourceEnd(sourceEnd),
79 destinationParent(destinationParent), destinationRow(destinationRow)
83 bool ModelMoveEvent::operator==(const ModelMoveEvent &b) const
85 return (sourceParent == b.sourceParent) && (sourceStart == b.sourceStart) && (sourceEnd == b.sourceEnd) &&
86 (destinationParent == b.destinationParent) && (destinationRow == b.destinationRow);