Closed MVC loop for VariablesView.
This commit is contained in:
@@ -41,10 +41,10 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void EditVariableDialog::setVariable( const model::Variable& variable )
|
void EditVariableDialog::setVariable( const model::Variable& variable )
|
||||||
{
|
{
|
||||||
typeCombo->setCurrentIndex( variable.type() );
|
typeCombo->setCurrentIndex( static_cast<int>(variable.type()) );
|
||||||
nameEdit->setText( variable.name() );
|
nameEdit->setText( variable.name() );
|
||||||
valueEdit->setText( variable.value() );
|
valueEdit->setText( variable.value() );
|
||||||
incrementCombo->setCurrentIndex( variable.incrementPolicy() );
|
incrementCombo->setCurrentIndex( static_cast<int>(variable.increment()) );
|
||||||
stepSizeEdit->setText( variable.stepSize() );
|
stepSizeEdit->setText( variable.stepSize() );
|
||||||
|
|
||||||
updateControls();
|
updateControls();
|
||||||
@@ -59,7 +59,7 @@ namespace glabels
|
|||||||
return model::Variable( static_cast<model::Variable::Type>(typeCombo->currentIndex()),
|
return model::Variable( static_cast<model::Variable::Type>(typeCombo->currentIndex()),
|
||||||
nameEdit->text(),
|
nameEdit->text(),
|
||||||
valueEdit->text(),
|
valueEdit->text(),
|
||||||
static_cast<model::Variable::IncrementPolicy>(incrementCombo->currentIndex()),
|
static_cast<model::Variable::Increment>(incrementCombo->currentIndex()),
|
||||||
stepSizeEdit->text() );
|
stepSizeEdit->text() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,24 +104,24 @@ namespace glabels
|
|||||||
void EditVariableDialog::updateControls()
|
void EditVariableDialog::updateControls()
|
||||||
{
|
{
|
||||||
model::Variable::Type type = static_cast<model::Variable::Type>(typeCombo->currentIndex());
|
model::Variable::Type type = static_cast<model::Variable::Type>(typeCombo->currentIndex());
|
||||||
model::Variable::IncrementPolicy incrementPolicy = static_cast<model::Variable::IncrementPolicy>(incrementCombo->currentIndex());
|
model::Variable::Increment increment = static_cast<model::Variable::Increment>(incrementCombo->currentIndex());
|
||||||
|
|
||||||
if ( type != model::Variable::TYPE_NUMERIC )
|
if ( type != model::Variable::Type::NUMERIC )
|
||||||
{
|
{
|
||||||
incrementCombo->setCurrentIndex( model::Variable::INCREMENT_NEVER );
|
incrementCombo->setCurrentIndex( static_cast<int>(model::Variable::Increment::NEVER) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( incrementPolicy == model::Variable::INCREMENT_NEVER )
|
if ( increment == model::Variable::Increment::NEVER )
|
||||||
{
|
{
|
||||||
stepSizeEdit->setText( "0" );
|
stepSizeEdit->setText( "0" );
|
||||||
}
|
}
|
||||||
|
|
||||||
incrementLabel->setEnabled( type == model::Variable::TYPE_NUMERIC );
|
incrementLabel->setEnabled( type == model::Variable::Type::NUMERIC );
|
||||||
incrementCombo->setEnabled( type == model::Variable::TYPE_NUMERIC );
|
incrementCombo->setEnabled( type == model::Variable::Type::NUMERIC );
|
||||||
stepSizeLabel->setEnabled( (type == model::Variable::TYPE_NUMERIC) &&
|
stepSizeLabel->setEnabled( (type == model::Variable::Type::NUMERIC) &&
|
||||||
(incrementPolicy != model::Variable::INCREMENT_NEVER) );
|
(increment != model::Variable::Increment::NEVER) );
|
||||||
stepSizeEdit->setEnabled( (type == model::Variable::TYPE_NUMERIC) &&
|
stepSizeEdit->setEnabled( (type == model::Variable::Type::NUMERIC) &&
|
||||||
(incrementPolicy != model::Variable::INCREMENT_NEVER) );
|
(increment != model::Variable::Increment::NEVER) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+104
-4
@@ -22,9 +22,22 @@
|
|||||||
|
|
||||||
#include "EditVariableDialog.h"
|
#include "EditVariableDialog.h"
|
||||||
|
|
||||||
|
#include <QTableWidgetItem>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
enum ICol {
|
||||||
|
I_COL_NAME = 0,
|
||||||
|
I_COL_TYPE = 1,
|
||||||
|
I_COL_VALUE = 2,
|
||||||
|
I_COL_INCREMENT = 3,
|
||||||
|
I_COL_STEP_SIZE = 4
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -58,8 +71,9 @@ namespace glabels
|
|||||||
mUndoRedoModel = undoRedoModel;
|
mUndoRedoModel = undoRedoModel;
|
||||||
|
|
||||||
updateControls();
|
updateControls();
|
||||||
|
loadTable();
|
||||||
|
|
||||||
//connect( mModel, SIGNAL(variablesChanged()), this, SLOT(onVariablesChanged()) );
|
connect( mModel, SIGNAL(variablesChanged()), this, SLOT(onVariablesChanged()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -79,16 +93,17 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
EditVariableDialog dialog( this );
|
EditVariableDialog dialog( this );
|
||||||
|
|
||||||
model::Variable v( model::Variable::TYPE_NUMERIC,
|
model::Variable v( model::Variable::Type::NUMERIC,
|
||||||
"x",
|
"x",
|
||||||
"0",
|
"0",
|
||||||
model::Variable::INCREMENT_NEVER,
|
model::Variable::Increment::NEVER,
|
||||||
"0" );
|
"0" );
|
||||||
dialog.setVariable( v );
|
dialog.setVariable( v );
|
||||||
|
|
||||||
if ( dialog.exec() == QDialog::Accepted )
|
if ( dialog.exec() == QDialog::Accepted )
|
||||||
{
|
{
|
||||||
qDebug() << "Add OK.";
|
mModel->variables()->addVariable( dialog.variable() );
|
||||||
|
selectVariable( dialog.variable().name() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +113,22 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void VariablesView::onEditButtonClicked()
|
void VariablesView::onEditButtonClicked()
|
||||||
{
|
{
|
||||||
|
int iRow = table->selectedItems()[0]->row();
|
||||||
|
QString name = table->item( iRow, I_COL_NAME )->text();
|
||||||
|
|
||||||
|
if ( mModel->variables()->hasVariable( name ) )
|
||||||
|
{
|
||||||
|
model::Variable v = mModel->variables()->value( name );
|
||||||
|
|
||||||
|
EditVariableDialog dialog( this );
|
||||||
|
dialog.setVariable( v );
|
||||||
|
|
||||||
|
if ( dialog.exec() == QDialog::Accepted )
|
||||||
|
{
|
||||||
|
mModel->variables()->replaceVariable( name, dialog.variable() );
|
||||||
|
selectVariable( dialog.variable().name() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -106,6 +137,20 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void VariablesView::onDeleteButtonClicked()
|
void VariablesView::onDeleteButtonClicked()
|
||||||
{
|
{
|
||||||
|
int iRow = table->selectedItems()[0]->row();
|
||||||
|
|
||||||
|
QString name = table->item( iRow, I_COL_NAME )->text();
|
||||||
|
mModel->variables()->deleteVariable( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Variables Changed
|
||||||
|
///
|
||||||
|
void VariablesView::onVariablesChanged()
|
||||||
|
{
|
||||||
|
// Reload table from variables
|
||||||
|
loadTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -121,4 +166,59 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// load table from variables
|
||||||
|
///
|
||||||
|
void VariablesView::loadTable()
|
||||||
|
{
|
||||||
|
table->clearContents();
|
||||||
|
table->setRowCount( mModel->variables()->size() );
|
||||||
|
|
||||||
|
int iRow = 0;
|
||||||
|
for( const auto& v : *mModel->variables() )
|
||||||
|
{
|
||||||
|
auto* typeItem = new QTableWidgetItem( model::Variable::typeToI18nString(v.type()) );
|
||||||
|
typeItem->setFlags( typeItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setItem( iRow, I_COL_TYPE, typeItem );
|
||||||
|
|
||||||
|
auto* nameItem = new QTableWidgetItem( v.name() );
|
||||||
|
nameItem->setFlags( nameItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setItem( iRow, I_COL_NAME, nameItem );
|
||||||
|
|
||||||
|
auto* valueItem = new QTableWidgetItem( v.value() );
|
||||||
|
valueItem->setFlags( valueItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setItem( iRow, I_COL_VALUE, valueItem );
|
||||||
|
|
||||||
|
auto* incrementItem = new QTableWidgetItem( model::Variable::incrementToI18nString(v.increment()) );
|
||||||
|
incrementItem->setFlags( incrementItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setItem( iRow, I_COL_INCREMENT, incrementItem );
|
||||||
|
|
||||||
|
auto* stepSizeItem = new QTableWidgetItem( v.stepSize() );
|
||||||
|
stepSizeItem->setFlags( stepSizeItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setItem( iRow, I_COL_STEP_SIZE, stepSizeItem );
|
||||||
|
|
||||||
|
table->showRow( iRow );
|
||||||
|
iRow++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void VariablesView::selectVariable( const QString& name )
|
||||||
|
{
|
||||||
|
int iRow = 0;
|
||||||
|
for( const auto& v : *mModel->variables() )
|
||||||
|
{
|
||||||
|
if ( v.name() == name )
|
||||||
|
{
|
||||||
|
qDebug() << "Selecting row " << iRow;
|
||||||
|
table->setCurrentCell( iRow, 0,
|
||||||
|
(QItemSelectionModel::Select|QItemSelectionModel::Rows) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
iRow++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ namespace glabels
|
|||||||
void onAddButtonClicked();
|
void onAddButtonClicked();
|
||||||
void onEditButtonClicked();
|
void onEditButtonClicked();
|
||||||
void onDeleteButtonClicked();
|
void onDeleteButtonClicked();
|
||||||
|
void onVariablesChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
@@ -71,6 +72,8 @@ namespace glabels
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
void updateControls();
|
void updateControls();
|
||||||
|
void loadTable();
|
||||||
|
void selectVariable( const QString& name );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ set (Model_sources
|
|||||||
TextNode.cpp
|
TextNode.cpp
|
||||||
Units.cpp
|
Units.cpp
|
||||||
Variable.cpp
|
Variable.cpp
|
||||||
|
Variables.cpp
|
||||||
Vendor.cpp
|
Vendor.cpp
|
||||||
XmlCategoryParser.cpp
|
XmlCategoryParser.cpp
|
||||||
XmlLabelCreator.cpp
|
XmlLabelCreator.cpp
|
||||||
@@ -81,6 +82,7 @@ set (Model_qobject_headers
|
|||||||
ModelTextObject.h
|
ModelTextObject.h
|
||||||
PageRenderer.h
|
PageRenderer.h
|
||||||
Settings.h
|
Settings.h
|
||||||
|
Variables.h
|
||||||
)
|
)
|
||||||
|
|
||||||
qt5_wrap_cpp (Model_moc_sources ${Model_qobject_headers})
|
qt5_wrap_cpp (Model_moc_sources ${Model_qobject_headers})
|
||||||
|
|||||||
@@ -57,7 +57,10 @@ namespace glabels
|
|||||||
Model::Model()
|
Model::Model()
|
||||||
: mUntitledInstance(0), mModified(true), mRotate(false)
|
: mUntitledInstance(0), mModified(true), mRotate(false)
|
||||||
{
|
{
|
||||||
|
mVariables = new Variables();
|
||||||
mMerge = new merge::None();
|
mMerge = new merge::None();
|
||||||
|
|
||||||
|
connect( mVariables, SIGNAL(changed()), this, SLOT(onVariablesChanged()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -66,6 +69,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
Model::~Model()
|
Model::~Model()
|
||||||
{
|
{
|
||||||
|
delete mVariables;
|
||||||
delete mMerge;
|
delete mMerge;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,6 +306,15 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get variables object
|
||||||
|
///
|
||||||
|
Variables* Model::variables() const
|
||||||
|
{
|
||||||
|
return mVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get merge object
|
/// Get merge object
|
||||||
///
|
///
|
||||||
@@ -451,6 +464,17 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Variables Changed Slot
|
||||||
|
///
|
||||||
|
void Model::onVariablesChanged()
|
||||||
|
{
|
||||||
|
setModified();
|
||||||
|
emit changed();
|
||||||
|
emit variablesChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Merge Source Changed Slot
|
/// Merge Source Changed Slot
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "Template.h"
|
#include "Template.h"
|
||||||
|
#include "Variables.h"
|
||||||
|
|
||||||
#include "merge/Merge.h"
|
#include "merge/Merge.h"
|
||||||
#include "merge/Record.h"
|
#include "merge/Record.h"
|
||||||
@@ -76,6 +77,7 @@ namespace glabels
|
|||||||
void sizeChanged();
|
void sizeChanged();
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
void modifiedChanged();
|
void modifiedChanged();
|
||||||
|
void variablesChanged();
|
||||||
void mergeChanged();
|
void mergeChanged();
|
||||||
void mergeSourceChanged();
|
void mergeSourceChanged();
|
||||||
void mergeSelectionChanged();
|
void mergeSelectionChanged();
|
||||||
@@ -107,6 +109,8 @@ namespace glabels
|
|||||||
|
|
||||||
const QList<ModelObject*>& objectList() const;
|
const QList<ModelObject*>& objectList() const;
|
||||||
|
|
||||||
|
Variables* variables() const;
|
||||||
|
|
||||||
merge::Merge* merge() const;
|
merge::Merge* merge() const;
|
||||||
void setMerge( merge::Merge* merge );
|
void setMerge( merge::Merge* merge );
|
||||||
|
|
||||||
@@ -213,6 +217,7 @@ namespace glabels
|
|||||||
private slots:
|
private slots:
|
||||||
void onObjectChanged();
|
void onObjectChanged();
|
||||||
void onObjectMoved();
|
void onObjectMoved();
|
||||||
|
void onVariablesChanged();
|
||||||
void onMergeSourceChanged();
|
void onMergeSourceChanged();
|
||||||
void onMergeSelectionChanged();
|
void onMergeSelectionChanged();
|
||||||
|
|
||||||
@@ -229,6 +234,7 @@ namespace glabels
|
|||||||
|
|
||||||
QList<ModelObject*> mObjectList;
|
QList<ModelObject*> mObjectList;
|
||||||
|
|
||||||
|
Variables* mVariables;
|
||||||
merge::Merge* mMerge;
|
merge::Merge* mMerge;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+65
-8
@@ -26,15 +26,15 @@ namespace glabels
|
|||||||
namespace model
|
namespace model
|
||||||
{
|
{
|
||||||
|
|
||||||
Variable::Variable( Variable::Type type,
|
Variable::Variable( Variable::Type type,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const QString& value,
|
const QString& value,
|
||||||
Variable::IncrementPolicy incrementPolicy,
|
Variable::Increment increment,
|
||||||
const QString& stepSize )
|
const QString& stepSize )
|
||||||
: mType(type),
|
: mType(type),
|
||||||
mName(name),
|
mName(name),
|
||||||
mValue(value),
|
mValue(value),
|
||||||
mIncrementPolicy(incrementPolicy),
|
mIncrement(increment),
|
||||||
mStepSize(stepSize)
|
mStepSize(stepSize)
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
@@ -59,9 +59,9 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Variable::IncrementPolicy Variable::incrementPolicy() const
|
Variable::Increment Variable::increment() const
|
||||||
{
|
{
|
||||||
return mIncrementPolicy;
|
return mIncrement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -70,5 +70,62 @@ namespace glabels
|
|||||||
return mStepSize;
|
return mStepSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::typeToI18nString( Type type )
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Type::NUMERIC:
|
||||||
|
return tr("Numeric");
|
||||||
|
case Type::STRING:
|
||||||
|
return tr("String");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::typeToIdString( Type type )
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Type::NUMERIC:
|
||||||
|
return "numeric";
|
||||||
|
case Type::STRING:
|
||||||
|
return "string";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::incrementToI18nString( Increment increment )
|
||||||
|
{
|
||||||
|
switch (increment)
|
||||||
|
{
|
||||||
|
case Increment::NEVER:
|
||||||
|
return tr("Never");
|
||||||
|
case Increment::PER_COPY:
|
||||||
|
return tr("Per copy");
|
||||||
|
case Increment::PER_MERGE_RECORD:
|
||||||
|
return tr("Per merge record");
|
||||||
|
case Increment::PER_PAGE:
|
||||||
|
return tr("Per page");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::incrementToIdString( Increment increment )
|
||||||
|
{
|
||||||
|
switch (increment)
|
||||||
|
{
|
||||||
|
case Increment::NEVER:
|
||||||
|
return "never";
|
||||||
|
case Increment::PER_COPY:
|
||||||
|
return "per_copy";
|
||||||
|
case Increment::PER_MERGE_RECORD:
|
||||||
|
return "per_merge_record";
|
||||||
|
case Increment::PER_PAGE:
|
||||||
|
return "per_page";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-19
@@ -22,6 +22,7 @@
|
|||||||
#define model_Variable_h
|
#define model_Variable_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
@@ -32,19 +33,21 @@ namespace glabels
|
|||||||
|
|
||||||
class Variable
|
class Variable
|
||||||
{
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(Variable)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Type
|
enum class Type
|
||||||
{
|
{
|
||||||
TYPE_NUMERIC,
|
NUMERIC,
|
||||||
TYPE_STRING
|
STRING
|
||||||
};
|
};
|
||||||
|
|
||||||
enum IncrementPolicy
|
enum class Increment
|
||||||
{
|
{
|
||||||
INCREMENT_NEVER,
|
NEVER,
|
||||||
INCREMENT_PER_COPY,
|
PER_COPY,
|
||||||
INCREMENT_PER_MERGE_RECORD,
|
PER_MERGE_RECORD,
|
||||||
INCREMENT_PER_PAGE
|
PER_PAGE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -54,26 +57,32 @@ namespace glabels
|
|||||||
Variable( Type type,
|
Variable( Type type,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const QString& value,
|
const QString& value,
|
||||||
IncrementPolicy incrementPolicy = INCREMENT_NEVER,
|
Increment increment = Increment::NEVER,
|
||||||
const QString& stepSize = "0" );
|
const QString& stepSize = "0" );
|
||||||
|
|
||||||
virtual ~Variable() = default;
|
virtual ~Variable() = default;
|
||||||
|
|
||||||
|
|
||||||
Type type() const;
|
Type type() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
QString value() const;
|
QString value() const;
|
||||||
IncrementPolicy incrementPolicy() const;
|
Increment increment() const;
|
||||||
QString stepSize() const;
|
QString stepSize() const;
|
||||||
|
|
||||||
|
|
||||||
|
static QString typeToI18nString( Type type );
|
||||||
|
static QString typeToIdString( Type type );
|
||||||
|
|
||||||
|
static QString incrementToI18nString( Increment increment );
|
||||||
|
static QString incrementToIdString( Increment increment );
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type mType;
|
Type mType;
|
||||||
QString mName;
|
QString mName;
|
||||||
QString mValue;
|
QString mValue;
|
||||||
IncrementPolicy mIncrementPolicy;
|
Increment mIncrement;
|
||||||
QString mStepSize;
|
QString mStepSize;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/* Variables.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Variables.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
namespace model
|
||||||
|
{
|
||||||
|
///
|
||||||
|
/// Copy constructor
|
||||||
|
///
|
||||||
|
Variables::Variables( const Variables* variables )
|
||||||
|
: QMap<QString,Variable>(*variables)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Clone
|
||||||
|
///
|
||||||
|
Variables* Variables::clone() const
|
||||||
|
{
|
||||||
|
return new Variables( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Do we have variable?
|
||||||
|
///
|
||||||
|
bool Variables::hasVariable( const QString& name ) const
|
||||||
|
{
|
||||||
|
return contains(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Add variable ( will replace if name is the same )
|
||||||
|
///
|
||||||
|
void Variables::addVariable( const Variable& variable )
|
||||||
|
{
|
||||||
|
insert( variable.name(), variable );
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Delete variable
|
||||||
|
///
|
||||||
|
void Variables::deleteVariable( const QString& name )
|
||||||
|
{
|
||||||
|
remove( name );
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Replace variable
|
||||||
|
///
|
||||||
|
void Variables::replaceVariable( const QString& origName, const Variable& variable )
|
||||||
|
{
|
||||||
|
remove( origName );
|
||||||
|
insert( variable.name(), variable );
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace model
|
||||||
|
|
||||||
|
} // namespace glabels
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/* Variables.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef model_Variables_h
|
||||||
|
#define model_Variables_h
|
||||||
|
|
||||||
|
|
||||||
|
#include "Variable.h"
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
namespace model
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Variables Collection
|
||||||
|
///
|
||||||
|
class Variables : public QObject, public QMap<QString,Variable>
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
Variables() = default;
|
||||||
|
Variables( const Variables* variables );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
Variables* clone() const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
bool hasVariable( const QString& name ) const;
|
||||||
|
void addVariable( const Variable& variable );
|
||||||
|
void deleteVariable( const QString& name );
|
||||||
|
void replaceVariable( const QString& name, const Variable& variable );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void changed();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // model_Variables_h
|
||||||
@@ -1082,6 +1082,33 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>Variable</name>
|
||||||
|
<message>
|
||||||
|
<source>Numeric</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>String</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Never</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Per copy</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Per merge record</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Per page</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>VariablesView</name>
|
<name>VariablesView</name>
|
||||||
<message>
|
<message>
|
||||||
|
|||||||
Reference in New Issue
Block a user