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/>.
24 #include "ModelEvents.h"
25 #include "Common/MetaTypes.h"
30 char *toString(const ModelInsertRemoveEvent
&event
)
33 QDebug(&buf
) << "parent:" << event
.parent
34 << "start:" << event
.start
35 << "end:" << event
.end
;
36 return qstrdup(buf
.toUtf8().constData());
40 char *toString(const ModelMoveEvent
&event
)
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
);