File indexing completed on 2024-09-22 05:16:06
0001 /* 0002 This file is part of the Kasten Framework, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2007-2008 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 "setremotecontroller.hpp" 0010 0011 // Kasten core 0012 #include <Kasten/DocumentSyncManager> 0013 #include <Kasten/AbstractDocument> 0014 // KF 0015 #include <KActionCollection> 0016 #include <KStandardAction> 0017 #include <KXMLGUIClient> 0018 // Qt 0019 #include <QAction> 0020 0021 namespace Kasten { 0022 0023 SetRemoteController::SetRemoteController(DocumentSyncManager* syncManager, KXMLGUIClient* guiClient) 0024 : mSyncManager(syncManager) 0025 { 0026 mSaveAsAction = KStandardAction::saveAs(this, &SetRemoteController::saveAs, this); 0027 0028 guiClient->actionCollection()->addAction(mSaveAsAction->objectName(), mSaveAsAction); 0029 0030 setTargetModel(nullptr); 0031 } 0032 0033 void SetRemoteController::setTargetModel(AbstractModel* model) 0034 { 0035 mDocument = model ? model->findBaseModel<AbstractDocument*>() : nullptr; 0036 0037 const bool canBeSaved = mDocument ? 0038 (mDocument->synchronizer() || 0039 mSyncManager->hasSynchronizerForLocal(mDocument->mimeType())) : 0040 false; 0041 0042 mSaveAsAction->setEnabled(canBeSaved); 0043 } 0044 0045 void SetRemoteController::saveAs() 0046 { 0047 mSyncManager->setSynchronizer(mDocument); 0048 } 0049 0050 } 0051 0052 #include "moc_setremotecontroller.cpp"