File indexing completed on 2024-06-23 05:49:22

0001 /*
0002     This file is part of the Kasten Framework, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2007, 2012 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #include "testdocument.hpp"
0010 
0011 namespace Kasten {
0012 
0013 TestDocument::TestDocument() = default;
0014 TestDocument::TestDocument(const QByteArray& data)
0015     : mData(data)
0016 {
0017 }
0018 
0019 TestDocument::~TestDocument() = default;
0020 
0021 QString TestDocument::mimeType() const { return QStringLiteral("TestDocument"); }
0022 QString TestDocument::typeName() const { return QStringLiteral("Test Document"); }
0023 QString TestDocument::title() const { return mTitle; }
0024 ContentFlags TestDocument::contentFlags() const { return mContentFlags; }
0025 const QByteArray* TestDocument::data() const { return &mData; }
0026 
0027 void TestDocument::setData(const QByteArray& data)
0028 {
0029     const ContentFlags oldContentFlags = mContentFlags;
0030 
0031     mData = data;
0032 
0033     mContentFlags = mContentFlags | ContentHasUnstoredChanges;
0034 
0035     if (oldContentFlags != mContentFlags) {
0036         Q_EMIT contentFlagsChanged(mContentFlags);
0037     }
0038 }
0039 
0040 void TestDocument::setTitle(const QString& title)
0041 {
0042     if (mTitle != title) {
0043         mTitle = title;
0044         Q_EMIT titleChanged(title);
0045     }
0046 }
0047 
0048 void TestDocument::setContentFlags(ContentFlags contentFlags)
0049 {
0050     if (mContentFlags != contentFlags) {
0051         mContentFlags = contentFlags;
0052 
0053         Q_EMIT contentFlagsChanged(contentFlags);
0054     }
0055 }
0056 
0057 }
0058 
0059 #include "moc_testdocument.cpp"