File indexing completed on 2025-01-05 05:23:24

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 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 "overwriteonlycontroller.hpp"
0010 
0011 // Okteta core
0012 #include <Okteta/AbstractByteArrayModel>
0013 // KF
0014 #include <KXMLGUIClient>
0015 #include <KLocalizedString>
0016 #include <KActionCollection>
0017 #include <KToggleAction>
0018 
0019 namespace Kasten {
0020 
0021 OverwriteOnlyController::OverwriteOnlyController(KXMLGUIClient* guiClient)
0022 {
0023     mSetOverwriteOnlyAction = new KToggleAction(i18nc("@option:check", "Overwrite only"), this);
0024     connect(mSetOverwriteOnlyAction, &QAction::triggered, this, &OverwriteOnlyController::setOverwriteOnly);
0025 
0026     guiClient->actionCollection()->addAction(QStringLiteral("isoverwriteonly"), mSetOverwriteOnlyAction);
0027 
0028     setTargetModel(nullptr);
0029 }
0030 
0031 void OverwriteOnlyController::setTargetModel(AbstractModel* model)
0032 {
0033     Q_UNUSED(model)
0034 //     if( mByteArrayModel ) mByteArrayModel->disconnect( mSetOverwriteOnlyAction );
0035 
0036     mByteArrayModel = nullptr; // view ? view->baseModel() : nullptr;
0037 
0038     if (mByteArrayModel) {
0039 //         mSetOverwriteOnlyAction->setChecked( mByteArrayModel->isOverwriteOnly() );
0040 
0041 //         connect( mByteArrayModel, SIGNAL(overwriteOnlyChanged(bool)),
0042 //                  mSetOverwriteOnlyAction, SLOT(setChecked(bool)) );
0043 //         connect( mByteArrayModel, SIGNAL(modifiableChanged(bool)),
0044 //                  mSetOverwriteOnlyAction, SLOT(setEnabled(bool)) );
0045     }
0046 
0047     mSetOverwriteOnlyAction->setEnabled(false);  // mByteArrayModel ? mByteArrayModel->isModifiable() : false );
0048 }
0049 
0050 void OverwriteOnlyController::setOverwriteOnly(bool isOverwriteOnly)
0051 {
0052     Q_UNUSED(isOverwriteOnly)
0053 //     mByteArrayModel->setOverwriteOnly( isOverwriteOnly );
0054 }
0055 
0056 }
0057 
0058 #include "moc_overwriteonlycontroller.cpp"