File indexing completed on 2025-01-19 05:20:20
0001 /* 0002 This file is part of the Kasten Framework, 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 "bytearrayvaluesstreamencoderconfigeditor.hpp" 0010 0011 // lib 0012 #include "bytearraytextstreamencoderpreview.hpp" 0013 // KF 0014 #include <KLocalizedString> 0015 // #include <KComboBox> 0016 // Qt 0017 #include <QFormLayout> 0018 #include <QLineEdit> 0019 0020 namespace Kasten { 0021 0022 ByteArrayValuesStreamEncoderConfigEditor::ByteArrayValuesStreamEncoderConfigEditor(ByteArrayValuesStreamEncoder* encoder, QWidget* parent) 0023 : AbstractModelStreamEncoderConfigEditor(parent) 0024 , mEncoder(encoder) 0025 { 0026 mSettings = mEncoder->settings(); 0027 0028 auto* pageLayout = new QFormLayout(this); // unknown rows 0029 pageLayout->setContentsMargins(0, 0, 0, 0); 0030 0031 #if 0 0032 // data type 0033 QLabel* label = new QLabel(i18n("Value coding:"), this); 0034 pageLayout->addWidget(label, 0, 0, Qt::AlignRight); 0035 0036 mValueCodingSelect = new KComboBox(this); 0037 QStringList list; 0038 list.append(i18nc("@item:inmenu encoding of the bytes as values in the hexadecimal format", "Hexadecimal")); 0039 list.append(i18nc("@item:inmenu encoding of the bytes as values in the decimal format", "Decimal")); 0040 list.append(i18nc("@item:inmenu encoding of the bytes as values in the octal format", "Octal")); 0041 list.append(i18nc("@item:inmenu encoding of the bytes as values in the binary format", "Binary")); 0042 mValueCodingSelect->addItems(list); 0043 mValueCodingSelect->setCurrentIndex(mSettings.valueCoding); 0044 connect(mValueCodingSelect, SIGNAL(activated(int)), SLOT(onSettingsChanged())); 0045 pageLayout->addWidget(mValueCodingSelect, 0, 1); 0046 #endif 0047 // separation string 0048 const QString separationLabel = 0049 i18nc("@label:textbox substring which separates the values", "Separation:"); 0050 0051 mSeparationEdit = new QLineEdit(this); 0052 mSeparationEdit->setClearButtonEnabled(true); 0053 mSeparationEdit->setText(mSettings.separation); 0054 connect(mSeparationEdit, &QLineEdit::textChanged, this, &ByteArrayValuesStreamEncoderConfigEditor::onSettingsChanged); 0055 pageLayout->addRow(separationLabel, mSeparationEdit); 0056 } 0057 0058 ByteArrayValuesStreamEncoderConfigEditor::~ByteArrayValuesStreamEncoderConfigEditor() = default; 0059 0060 AbstractSelectionView* ByteArrayValuesStreamEncoderConfigEditor::createPreviewView() const 0061 { 0062 return new ByteArrayTextStreamEncoderPreview(mEncoder); 0063 } 0064 0065 void ByteArrayValuesStreamEncoderConfigEditor::onSettingsChanged() 0066 { 0067 // mSettings.valueCoding = (Okteta::ValueCoding) mValueCodingSelect->currentIndex(); 0068 mSettings.separation = mSeparationEdit->text(); 0069 0070 mEncoder->setSettings(mSettings); 0071 } 0072 0073 } 0074 0075 #include "moc_bytearrayvaluesstreamencoderconfigeditor.cpp"