File indexing completed on 2024-05-19 04:36:22
0001 /* This file is part of the TikZKit project. 0002 * 0003 * Copyright (C) 2014-2015 Dominik Haumann <dhaumann@kde.org> 0004 * 0005 * This library is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU Library General Public License as published 0007 * by the Free Software Foundation, either version 2 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, see 0017 * <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #include "Transaction.h" 0021 #include "Document.h" 0022 0023 namespace tikz { 0024 namespace core { 0025 0026 Transaction::Transaction(Document *document) 0027 : Transaction(document, QString()) 0028 { 0029 } 0030 0031 Transaction::Transaction(Document * document, const QString & name) 0032 : m_document(document) 0033 { 0034 // Alghouth it works in release-mode, we usually want a valid document 0035 Q_ASSERT(document != nullptr); 0036 0037 // start the editing transaction 0038 if (m_document) { 0039 m_document->beginTransaction(name); 0040 } 0041 } 0042 0043 void Transaction::cancel() 0044 { 0045 if (m_document) { 0046 m_document->cancelTransaction(); 0047 } 0048 } 0049 0050 void Transaction::finish() 0051 { 0052 if (m_document) { 0053 m_document->finishTransaction(); 0054 m_document = nullptr; 0055 } 0056 } 0057 0058 bool Transaction::isRunning() const 0059 { 0060 return m_document != nullptr; 0061 } 0062 0063 Transaction::~Transaction() 0064 { 0065 // finish the editing transaction, if applicable 0066 finish(); 0067 } 0068 0069 } 0070 } 0071 0072 // kate: indent-width 4; replace-tabs on;