Pointer cleanup (#242)
- Made greater use of smart pointers, eliminating many instances of manual memory management - Do not use pointers at all for many non-polymorphic classes - Assorted other code cleanup
This commit is contained in:
@@ -129,7 +129,7 @@ namespace glabels
|
||||
|
||||
|
||||
void ColorButton::setKeys( const merge::Merge* merge,
|
||||
const model::Variables* variables )
|
||||
const model::Variables& variables )
|
||||
{
|
||||
mDialog->setKeys( merge, variables );
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace glabels
|
||||
model::ColorNode colorNode();
|
||||
|
||||
void setKeys( const merge::Merge* merge,
|
||||
const model::Variables* variables );
|
||||
const model::Variables& variables );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace glabels
|
||||
|
||||
|
||||
void ColorPaletteDialog::setKeys( const merge::Merge* merge,
|
||||
const model::Variables* variables )
|
||||
const model::Variables& variables )
|
||||
{
|
||||
if (mFieldButton)
|
||||
{
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace glabels
|
||||
void setColorNode( const model::ColorNode& colorNode );
|
||||
|
||||
void setKeys( const merge::Merge* merge,
|
||||
const model::Variables* variables );
|
||||
const model::Variables& variables );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace glabels
|
||||
/// Set Keys
|
||||
///
|
||||
void FieldButton::setKeys( const merge::Merge* merge,
|
||||
const model::Variables* variables )
|
||||
const model::Variables& variables )
|
||||
{
|
||||
// Clear old keys
|
||||
mMenu.clear();
|
||||
@@ -64,18 +64,18 @@ namespace glabels
|
||||
|
||||
// Add variable keys, if any
|
||||
mMenu.addSection( tr("Variables") );
|
||||
for ( auto& key : variables->keys() )
|
||||
for ( auto& key : variables.keys() )
|
||||
{
|
||||
auto* action = mMenu.addAction( QString( "${%1}" ).arg( key ) );
|
||||
action->setData( key );
|
||||
}
|
||||
if ( variables->keys().empty() )
|
||||
if ( variables.keys().empty() )
|
||||
{
|
||||
auto* action = mMenu.addAction( "None" );
|
||||
action->setEnabled( false );
|
||||
}
|
||||
|
||||
setEnabled( !merge->keys().empty() || !variables->keys().empty() );
|
||||
setEnabled( !merge->keys().empty() || !variables.keys().empty() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace glabels
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void setKeys( const merge::Merge* merge,
|
||||
const model::Variables* variables );
|
||||
const model::Variables& variables );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
+3
-3
@@ -52,14 +52,14 @@ namespace glabels
|
||||
SelectProductDialog dialog;
|
||||
dialog.exec();
|
||||
|
||||
const model::Template* tmplate = dialog.tmplate();
|
||||
if ( tmplate )
|
||||
auto tmplate = dialog.tmplate();
|
||||
if ( !tmplate.isNull() )
|
||||
{
|
||||
auto* model = new model::Model();
|
||||
model->setTmplate( tmplate );
|
||||
|
||||
// Intelligently decide to rotate label by default
|
||||
const model::Frame* frame = tmplate->frames().first();
|
||||
auto frame = tmplate.frame();
|
||||
model->setRotate( frame->h() > frame->w() );
|
||||
|
||||
model->clearModified();
|
||||
|
||||
+23
-23
@@ -18,6 +18,7 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "LabelEditor.h"
|
||||
|
||||
#include "Cursors.h"
|
||||
@@ -38,10 +39,10 @@
|
||||
#include "model/Markup.h"
|
||||
#include "model/Settings.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMimeData>
|
||||
#include <QMouseEvent>
|
||||
#include <QtMath>
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
namespace glabels
|
||||
@@ -95,12 +96,12 @@ namespace glabels
|
||||
|
||||
mState = IdleState;
|
||||
|
||||
mSelectRegionVisible = false;
|
||||
mResizeObject = nullptr;
|
||||
mResizeHandle = nullptr;
|
||||
mResizeHonorAspect = false;
|
||||
mCreateObjectType = Box;
|
||||
mCreateObject = nullptr;
|
||||
mSelectRegionVisible = false;
|
||||
mResizeObject = nullptr;
|
||||
mResizeHandleLocation = model::Handle::NULL_HANDLE;
|
||||
mResizeHonorAspect = false;
|
||||
mCreateObjectType = Box;
|
||||
mCreateObject = nullptr;
|
||||
|
||||
setMouseTracking( true );
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
@@ -459,15 +460,15 @@ namespace glabels
|
||||
case IdleState:
|
||||
{
|
||||
model::ModelObject* object = nullptr;
|
||||
model::Handle* handle = nullptr;
|
||||
if ( mModel->isSelectionAtomic() &&
|
||||
(handle = mModel->handleAt( mScale, xWorld, yWorld )) != nullptr )
|
||||
auto& handle = mModel->handleAt( mScale, xWorld, yWorld );
|
||||
|
||||
if ( mModel->isSelectionAtomic() && !handle.isNull() )
|
||||
{
|
||||
//
|
||||
// Start an object resize
|
||||
//
|
||||
mResizeObject = handle->owner();
|
||||
mResizeHandle = handle;
|
||||
mResizeObject = handle.owner();
|
||||
mResizeHandleLocation = handle.location();
|
||||
mResizeHonorAspect = event->modifiers() & Qt::ControlModifier;
|
||||
if ( mResizeObject->lockAspectRatio() )
|
||||
{
|
||||
@@ -632,7 +633,7 @@ namespace glabels
|
||||
|
||||
case IdleState:
|
||||
if ( mModel->isSelectionAtomic() &&
|
||||
mModel->handleAt( mScale, xWorld, yWorld ) )
|
||||
!mModel->handleAt( mScale, xWorld, yWorld ).isNull() )
|
||||
{
|
||||
setCursor( Qt::CrossCursor );
|
||||
}
|
||||
@@ -796,11 +797,10 @@ namespace glabels
|
||||
/// Handle resize motion
|
||||
///
|
||||
void
|
||||
LabelEditor::handleResizeMotion( const model::Distance& xWorld,
|
||||
const model::Distance& yWorld )
|
||||
LabelEditor::handleResizeMotion( model::Distance xWorld,
|
||||
model::Distance yWorld )
|
||||
{
|
||||
QPointF p( xWorld.pt(), yWorld.pt() );
|
||||
model::Handle::Location location = mResizeHandle->location();
|
||||
|
||||
/*
|
||||
* Change point to object relative coordinates
|
||||
@@ -824,7 +824,7 @@ namespace glabels
|
||||
* Calculate new size
|
||||
*/
|
||||
double w, h;
|
||||
switch ( location )
|
||||
switch ( mResizeHandleLocation )
|
||||
{
|
||||
case model::Handle::NW:
|
||||
w = std::max( x2 - p.x(), 0.0 );
|
||||
@@ -879,11 +879,11 @@ namespace glabels
|
||||
/*
|
||||
* Set size
|
||||
*/
|
||||
if ( !(location == model::Handle::P1) && !(location == model::Handle::P2) )
|
||||
if ( !(mResizeHandleLocation == model::Handle::P1) && !(mResizeHandleLocation == model::Handle::P2) )
|
||||
{
|
||||
if ( mResizeHonorAspect )
|
||||
{
|
||||
switch ( location )
|
||||
switch ( mResizeHandleLocation )
|
||||
{
|
||||
case model::Handle::E:
|
||||
case model::Handle::W:
|
||||
@@ -908,7 +908,7 @@ namespace glabels
|
||||
/*
|
||||
* Adjust origin, if needed.
|
||||
*/
|
||||
switch ( location )
|
||||
switch ( mResizeHandleLocation )
|
||||
{
|
||||
case model::Handle::NW:
|
||||
x0 += x2 - mResizeObject->w().pt();
|
||||
@@ -1227,9 +1227,9 @@ namespace glabels
|
||||
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||
}
|
||||
|
||||
foreach( model::Markup* markup, mModel->frame()->markups() )
|
||||
for( auto& markup : mModel->frame()->markups() )
|
||||
{
|
||||
painter->drawPath( markup->path( mModel->frame() ) );
|
||||
painter->drawPath( markup->path( *mModel->frame() ) );
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
@@ -1243,7 +1243,7 @@ namespace glabels
|
||||
void
|
||||
LabelEditor::drawObjectsLayer( QPainter* painter )
|
||||
{
|
||||
mModel->draw( painter, true, nullptr, nullptr );
|
||||
mModel->draw( painter, true, merge::NullRecord(), model::Variables() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define LabelEditor_h
|
||||
|
||||
|
||||
#include "model/Handles.h"
|
||||
#include "model/Handle.h"
|
||||
#include "model/Model.h"
|
||||
#include "model/ModelObject.h"
|
||||
#include "model/Region.h"
|
||||
@@ -135,8 +135,8 @@ namespace glabels
|
||||
// Private methods
|
||||
/////////////////////////////////////
|
||||
private:
|
||||
void handleResizeMotion( const model::Distance& xWorld,
|
||||
const model::Distance& yWorld );
|
||||
void handleResizeMotion( model::Distance xWorld,
|
||||
model::Distance yWorld );
|
||||
|
||||
void drawBgLayer( QPainter* painter );
|
||||
void drawGridLayer( QPainter* painter );
|
||||
@@ -205,9 +205,9 @@ namespace glabels
|
||||
model::Distance mMoveLastY;
|
||||
|
||||
/* ArrowResize state */
|
||||
model::ModelObject* mResizeObject;
|
||||
model::Handle* mResizeHandle;
|
||||
bool mResizeHonorAspect;
|
||||
model::ModelObject* mResizeObject;
|
||||
model::Handle::Location mResizeHandleLocation;
|
||||
bool mResizeHonorAspect;
|
||||
|
||||
/* CreateDrag state */
|
||||
CreateType mCreateObjectType;
|
||||
|
||||
+17
-36
@@ -29,7 +29,6 @@
|
||||
#include "PrintView.h"
|
||||
#include "PropertiesView.h"
|
||||
#include "StartupView.h"
|
||||
#include "UndoRedoModel.h"
|
||||
#include "VariablesView.h"
|
||||
|
||||
#include "model/Db.h"
|
||||
@@ -63,7 +62,7 @@ namespace glabels
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
MainWindow::MainWindow() : mModel(nullptr), mUndoRedoModel(nullptr)
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
setWindowIcon( QIcon::fromTheme( "glabels" ) );
|
||||
|
||||
@@ -204,30 +203,12 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
if ( mUndoRedoModel )
|
||||
{
|
||||
delete mUndoRedoModel;
|
||||
}
|
||||
if ( mModel )
|
||||
{
|
||||
delete mModel->merge(); // Ownership of final Merge instance is ours
|
||||
delete mModel->variables(); // Ownership of Variables instance is ours
|
||||
delete mModel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get model accessor
|
||||
///
|
||||
model::Model* MainWindow::model() const
|
||||
{
|
||||
return mModel;
|
||||
return mModel.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -236,15 +217,15 @@ namespace glabels
|
||||
///
|
||||
void MainWindow::setModel( model::Model* model )
|
||||
{
|
||||
mModel = model; // Ownership passes to us
|
||||
mUndoRedoModel = new UndoRedoModel( mModel );
|
||||
mModel.reset( model );
|
||||
mUndoRedoModel = std::make_unique<UndoRedoModel>( mModel.get() );
|
||||
|
||||
mPropertiesView->setModel( mModel, mUndoRedoModel );
|
||||
mLabelEditor->setModel( mModel, mUndoRedoModel );
|
||||
mObjectEditor->setModel( mModel, mUndoRedoModel );
|
||||
mMergeView->setModel( mModel, mUndoRedoModel );
|
||||
mVariablesView->setModel( mModel, mUndoRedoModel );
|
||||
mPrintView->setModel( mModel );
|
||||
mPropertiesView->setModel( mModel.get(), mUndoRedoModel.get() );
|
||||
mLabelEditor->setModel( mModel.get(), mUndoRedoModel.get() );
|
||||
mObjectEditor->setModel( mModel.get(), mUndoRedoModel.get() );
|
||||
mMergeView->setModel( mModel.get(), mUndoRedoModel.get() );
|
||||
mVariablesView->setModel( mModel.get(), mUndoRedoModel.get() );
|
||||
mPrintView->setModel( mModel.get() );
|
||||
|
||||
mEditorButton->setChecked( true );
|
||||
mPages->setCurrentIndex( EDITOR_PAGE_INDEX );
|
||||
@@ -253,11 +234,11 @@ namespace glabels
|
||||
setTitle();
|
||||
|
||||
connect( mLabelEditor, SIGNAL(contextMenuActivate(model::Point)), this, SLOT(onContextMenuActivate(model::Point)) );
|
||||
connect( mModel, SIGNAL(nameChanged()), this, SLOT(onNameChanged()) );
|
||||
connect( mModel, SIGNAL(modifiedChanged()), this, SLOT(onModifiedChanged()) );
|
||||
connect( mModel, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()) );
|
||||
connect( mModel, SIGNAL(changed()), this, SLOT(onLabelChanged()) );
|
||||
connect( mUndoRedoModel, SIGNAL(changed()), this, SLOT(onUndoRedoChanged()) );
|
||||
connect( mModel.get(), SIGNAL(nameChanged()), this, SLOT(onNameChanged()) );
|
||||
connect( mModel.get(), SIGNAL(modifiedChanged()), this, SLOT(onModifiedChanged()) );
|
||||
connect( mModel.get(), SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()) );
|
||||
connect( mModel.get(), SIGNAL(changed()), this, SLOT(onLabelChanged()) );
|
||||
connect( mUndoRedoModel.get(), SIGNAL(changed()), this, SLOT(onUndoRedoChanged()) );
|
||||
}
|
||||
|
||||
|
||||
@@ -266,7 +247,7 @@ namespace glabels
|
||||
///
|
||||
bool MainWindow::isEmpty() const
|
||||
{
|
||||
return mModel == nullptr;
|
||||
return !mModel;
|
||||
}
|
||||
|
||||
|
||||
@@ -1032,7 +1013,7 @@ namespace glabels
|
||||
///
|
||||
void MainWindow::setTitle()
|
||||
{
|
||||
if ( mModel == nullptr )
|
||||
if ( !mModel )
|
||||
{
|
||||
setWindowTitle( "gLabels" );
|
||||
}
|
||||
|
||||
+15
-5
@@ -21,6 +21,9 @@
|
||||
#ifndef MainWindow_h
|
||||
#define MainWindow_h
|
||||
|
||||
|
||||
#include "UndoRedoModel.h"
|
||||
|
||||
#include <model/Model.h>
|
||||
|
||||
#include <QAction>
|
||||
@@ -35,6 +38,8 @@
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace glabels
|
||||
{
|
||||
@@ -46,7 +51,6 @@ namespace glabels
|
||||
class PrintView;
|
||||
class PropertiesView;
|
||||
class StartupView;
|
||||
class UndoRedoModel;
|
||||
class VariablesView;
|
||||
|
||||
|
||||
@@ -63,7 +67,7 @@ namespace glabels
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
MainWindow();
|
||||
~MainWindow() override;
|
||||
virtual ~MainWindow() = default;
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
@@ -194,8 +198,17 @@ namespace glabels
|
||||
|
||||
/////////////////////////////////////
|
||||
// Private Data
|
||||
// owned and managed by us
|
||||
/////////////////////////////////////
|
||||
private:
|
||||
std::unique_ptr<model::Model> mModel;
|
||||
std::unique_ptr<UndoRedoModel> mUndoRedoModel;
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Private Data
|
||||
// owned by QMainWindow
|
||||
/////////////////////////////////////
|
||||
QMenu* fileMenu;
|
||||
QMenu* fileRecentMenu;
|
||||
QMenu* editMenu;
|
||||
@@ -219,9 +232,6 @@ namespace glabels
|
||||
QToolBar* fileToolBar;
|
||||
QToolBar* editorToolBar;
|
||||
|
||||
model::Model* mModel;
|
||||
UndoRedoModel* mUndoRedoModel;
|
||||
|
||||
QToolBar* mContents;
|
||||
QToolButton* mWelcomeButton;
|
||||
QToolButton* mEditorButton;
|
||||
|
||||
+13
-21
@@ -18,15 +18,16 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "MergeView.h"
|
||||
|
||||
#include "merge/Factory.h"
|
||||
|
||||
#include "model/FileUtil.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
namespace glabels
|
||||
@@ -48,15 +49,6 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
MergeView::~MergeView()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Set Model
|
||||
///
|
||||
@@ -144,13 +136,13 @@ namespace glabels
|
||||
{
|
||||
mBlock = true; // Don't recurse
|
||||
|
||||
const QList<merge::Record*>& records = mModel->merge()->recordList();
|
||||
auto& records = mModel->merge()->recordList();
|
||||
|
||||
int iRow = 0;
|
||||
foreach ( merge::Record* record, records )
|
||||
for ( auto& record : records )
|
||||
{
|
||||
QTableWidgetItem* item = recordsTable->item( iRow, 0 );
|
||||
item->setCheckState( record->isSelected() ? Qt::Checked : Qt::Unchecked );
|
||||
item->setCheckState( record.isSelected() ? Qt::Checked : Qt::Unchecked );
|
||||
|
||||
iRow++;
|
||||
}
|
||||
@@ -274,33 +266,33 @@ namespace glabels
|
||||
{
|
||||
mBlock = true;
|
||||
|
||||
const QList<merge::Record*>& records = merge->recordList();
|
||||
auto& records = merge->recordList();
|
||||
recordsTable->setRowCount( records.size() );
|
||||
|
||||
int iRow = 0;
|
||||
foreach ( merge::Record* record, records )
|
||||
for ( auto record : records )
|
||||
{
|
||||
// First column for primary field
|
||||
auto* item = new QTableWidgetItem();
|
||||
if ( record->contains( mPrimaryKey ) )
|
||||
if ( record.contains( mPrimaryKey ) )
|
||||
{
|
||||
auto text = printableTextForView( (*record)[mPrimaryKey] );
|
||||
auto text = printableTextForView( record[mPrimaryKey] );
|
||||
item->setText( text );
|
||||
}
|
||||
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
|
||||
item->setCheckState( record->isSelected() ? Qt::Checked : Qt::Unchecked );
|
||||
item->setCheckState( record.isSelected() ? Qt::Checked : Qt::Unchecked );
|
||||
recordsTable->setItem( iRow, 0, item );
|
||||
recordsTable->resizeColumnToContents( 0 );
|
||||
|
||||
// Starting on 2nd column, 1 column per field, skip primary field
|
||||
int iCol = 1;
|
||||
foreach ( QString key, mKeys )
|
||||
for ( auto& key : mKeys )
|
||||
{
|
||||
if ( key != mPrimaryKey )
|
||||
{
|
||||
if ( record->contains( key ) )
|
||||
if ( record.contains( key ) )
|
||||
{
|
||||
auto text = printableTextForView( (*record)[key] );
|
||||
auto text = printableTextForView( record[key] );
|
||||
auto* item = new QTableWidgetItem( text );
|
||||
item->setFlags( Qt::ItemIsEnabled );
|
||||
recordsTable->setItem( iRow, iCol, item );
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ namespace glabels
|
||||
/////////////////////////////////
|
||||
public:
|
||||
MergeView( QWidget *parent = nullptr );
|
||||
~MergeView() override;
|
||||
virtual ~MergeView() = default;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
@@ -49,14 +49,14 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
MiniPreviewPixmap::MiniPreviewPixmap( const model::Template* tmplate, int width, int height )
|
||||
MiniPreviewPixmap::MiniPreviewPixmap( const model::Template& tmplate, int width, int height )
|
||||
: QPixmap( width, height )
|
||||
{
|
||||
draw( tmplate, width, height );
|
||||
}
|
||||
|
||||
|
||||
void MiniPreviewPixmap::draw( const model::Template* tmplate, int width, int height )
|
||||
void MiniPreviewPixmap::draw( const model::Template& tmplate, int width, int height )
|
||||
{
|
||||
fill( Qt::transparent );
|
||||
|
||||
@@ -66,11 +66,11 @@ namespace glabels
|
||||
painter.setRenderHint( QPainter::Antialiasing, true );
|
||||
|
||||
// For "Roll" templates, allow extra room for tape width and continuation break lines
|
||||
model::Distance drawWidth = tmplate->pageWidth();
|
||||
model::Distance drawHeight = tmplate->pageHeight();
|
||||
if ( tmplate->isRoll() )
|
||||
model::Distance drawWidth = tmplate.pageWidth();
|
||||
model::Distance drawHeight = tmplate.pageHeight();
|
||||
if ( tmplate.isRoll() )
|
||||
{
|
||||
drawWidth = tmplate->rollWidth();
|
||||
drawWidth = tmplate.rollWidth();
|
||||
drawHeight *= 1.2;
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ namespace glabels
|
||||
}
|
||||
painter.scale( scale, scale );
|
||||
|
||||
model::Distance xOffset = ( model::Distance::pt(width/scale) - tmplate->pageWidth() ) / 2;
|
||||
model::Distance yOffset = ( model::Distance::pt(height/scale) - tmplate->pageHeight() ) / 2;
|
||||
model::Distance xOffset = ( model::Distance::pt(width/scale) - tmplate.pageWidth() ) / 2;
|
||||
model::Distance yOffset = ( model::Distance::pt(height/scale) - tmplate.pageHeight() ) / 2;
|
||||
painter.translate( xOffset.pt(), yOffset.pt() );
|
||||
|
||||
drawPaper( painter, tmplate, scale );
|
||||
@@ -96,7 +96,7 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
void MiniPreviewPixmap::drawPaper( QPainter& painter, const model::Template* tmplate, double scale )
|
||||
void MiniPreviewPixmap::drawPaper( QPainter& painter, const model::Template& tmplate, double scale )
|
||||
{
|
||||
QBrush brush( paperColor );
|
||||
QPen pen( paperOutlineColor );
|
||||
@@ -107,9 +107,9 @@ namespace glabels
|
||||
painter.setBrush( brush );
|
||||
painter.setPen( pen );
|
||||
|
||||
if ( !tmplate->isRoll() )
|
||||
if ( !tmplate.isRoll() )
|
||||
{
|
||||
painter.drawRect( 0, 0, tmplate->pageWidth().pt(), tmplate->pageHeight().pt() );
|
||||
painter.drawRect( 0, 0, tmplate.pageWidth().pt(), tmplate.pageHeight().pt() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -120,7 +120,7 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
void MiniPreviewPixmap::drawLabelOutlines( QPainter& painter, const model::Template* tmplate, double scale )
|
||||
void MiniPreviewPixmap::drawLabelOutlines( QPainter& painter, const model::Template& tmplate, double scale )
|
||||
{
|
||||
QBrush brush( labelColor );
|
||||
QPen pen( labelOutlineColor );
|
||||
@@ -131,10 +131,8 @@ namespace glabels
|
||||
painter.setBrush( brush );
|
||||
painter.setPen( pen );
|
||||
|
||||
model::Frame *frame = tmplate->frames().first();
|
||||
QVector<model::Point> origins = frame->getOrigins();
|
||||
|
||||
foreach ( model::Point p0, origins )
|
||||
auto frame = tmplate.frame();
|
||||
for ( model::Point p0 : frame->getOrigins() )
|
||||
{
|
||||
drawLabelOutline( painter, frame, p0 );
|
||||
}
|
||||
|
||||
@@ -39,13 +39,13 @@ namespace glabels
|
||||
public:
|
||||
MiniPreviewPixmap();
|
||||
|
||||
MiniPreviewPixmap( const model::Template* tmplate, int width, int height );
|
||||
MiniPreviewPixmap( const model::Template& tmplate, int width, int height );
|
||||
|
||||
|
||||
private:
|
||||
void draw( const model::Template* tmplate, int width, int height );
|
||||
void drawPaper( QPainter& painter, const model::Template* tmplate, double scale );
|
||||
void drawLabelOutlines( QPainter& painter, const model::Template* tmplate, double scale );
|
||||
void draw( const model::Template& tmplate, int width, int height );
|
||||
void drawPaper( QPainter& painter, const model::Template& tmplate, double scale );
|
||||
void drawLabelOutlines( QPainter& painter, const model::Template& tmplate, double scale );
|
||||
void drawLabelOutline( QPainter& painter, const model::Frame *frame, const model::Point& point0 );
|
||||
|
||||
};
|
||||
|
||||
+23
-15
@@ -97,18 +97,18 @@ namespace glabels
|
||||
auto tmplate = mModel->tmplate();
|
||||
|
||||
// For "Roll" templates, allow extra room to draw continuation break lines.
|
||||
model::Distance drawHeight = mModel->tmplate()->pageHeight();
|
||||
model::Distance drawHeight = mModel->tmplate().pageHeight();
|
||||
model::Distance drawOffset = 0;
|
||||
if ( tmplate->isRoll() )
|
||||
if ( tmplate.isRoll() )
|
||||
{
|
||||
drawHeight = 1.2 * tmplate->pageHeight();
|
||||
drawOffset = 0.1 * tmplate->pageHeight();
|
||||
drawHeight = 1.2 * tmplate.pageHeight();
|
||||
drawOffset = 0.1 * tmplate.pageHeight();
|
||||
}
|
||||
|
||||
// Set scene up with a 5% margin around paper
|
||||
model::Distance x = -0.05 * tmplate->pageWidth();
|
||||
model::Distance x = -0.05 * tmplate.pageWidth();
|
||||
model::Distance y = -0.05 * drawHeight - drawOffset;
|
||||
model::Distance w = 1.10 * tmplate->pageWidth();
|
||||
model::Distance w = 1.10 * tmplate.pageWidth();
|
||||
model::Distance h = 1.10 * drawHeight;
|
||||
|
||||
mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() );
|
||||
@@ -121,11 +121,15 @@ namespace glabels
|
||||
}
|
||||
}
|
||||
|
||||
void Preview::drawLabelNumberOverlaySingle(const model::Distance& x, const model::Distance& y, const QPainterPath& path, uint32_t labelInstance)
|
||||
|
||||
void Preview::drawLabelNumberOverlaySingle( model::Distance x,
|
||||
model::Distance y,
|
||||
const QPainterPath& path,
|
||||
uint32_t labelInstance)
|
||||
{
|
||||
QBrush brush( labelNumberColor );
|
||||
|
||||
model::Frame *frame = mModel->tmplate()->frames().first();
|
||||
auto frame = mModel->tmplate().frame();
|
||||
|
||||
model::Distance w = frame->w();
|
||||
model::Distance h = frame->h();
|
||||
@@ -143,18 +147,20 @@ namespace glabels
|
||||
mScene->addItem( labelNumberItem );
|
||||
}
|
||||
|
||||
|
||||
void Preview::drawLabelNumberOverlay()
|
||||
{
|
||||
model::Frame *frame = mModel->tmplate()->frames().first();
|
||||
auto frame = mModel->tmplate().frame();
|
||||
auto i = 0;
|
||||
|
||||
foreach (model::Point origin, frame->getOrigins() )
|
||||
for ( model::Point origin : frame->getOrigins() )
|
||||
{
|
||||
i++;
|
||||
drawLabelNumberOverlaySingle( origin.x(), origin.y(), frame->path(), i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Resize Event Handler
|
||||
///
|
||||
@@ -181,9 +187,9 @@ namespace glabels
|
||||
|
||||
QAbstractGraphicsShapeItem* pageItem;
|
||||
auto tmplate = mModel->tmplate();
|
||||
if ( !tmplate->isRoll() )
|
||||
if ( !tmplate.isRoll() )
|
||||
{
|
||||
pageItem = new QGraphicsRectItem( 0, 0, tmplate->pageWidth().pt(), tmplate->pageHeight().pt() );
|
||||
pageItem = new QGraphicsRectItem( 0, 0, tmplate.pageWidth().pt(), tmplate.pageHeight().pt() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -202,9 +208,9 @@ namespace glabels
|
||||
///
|
||||
void Preview::drawLabels()
|
||||
{
|
||||
model::Frame *frame = mModel->tmplate()->frames().first();
|
||||
auto frame = mModel->tmplate().frame();
|
||||
|
||||
foreach (model::Point origin, frame->getOrigins() )
|
||||
for ( model::Point origin : frame->getOrigins() )
|
||||
{
|
||||
drawLabel( origin.x(), origin.y(), frame->path() );
|
||||
}
|
||||
@@ -214,7 +220,9 @@ namespace glabels
|
||||
///
|
||||
/// Draw a Single Label at x,y
|
||||
///
|
||||
void Preview::drawLabel( const model::Distance& x, const model::Distance& y, const QPainterPath& path )
|
||||
void Preview::drawLabel( model::Distance x,
|
||||
model::Distance y,
|
||||
const QPainterPath& path )
|
||||
{
|
||||
QBrush brush( labelColor );
|
||||
QPen pen( labelOutlineColor );
|
||||
|
||||
+7
-2
@@ -70,11 +70,16 @@ namespace glabels
|
||||
private:
|
||||
void drawPaper();
|
||||
void drawLabels();
|
||||
void drawLabel( const model::Distance& x, const model::Distance& y, const QPainterPath& path );
|
||||
void drawLabel( model::Distance x,
|
||||
model::Distance y,
|
||||
const QPainterPath& path );
|
||||
|
||||
void drawPreviewOverlay();
|
||||
|
||||
void drawLabelNumberOverlaySingle(const model::Distance& x, const model::Distance& y, const QPainterPath& path, uint32_t labelInstance);
|
||||
void drawLabelNumberOverlaySingle( model::Distance x,
|
||||
model::Distance y,
|
||||
const QPainterPath& path,
|
||||
uint32_t labelInstance);
|
||||
void drawLabelNumberOverlay();
|
||||
|
||||
|
||||
|
||||
+22
-31
@@ -60,15 +60,6 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
PropertiesView::~PropertiesView()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Set Model
|
||||
///
|
||||
@@ -101,41 +92,41 @@ namespace glabels
|
||||
///
|
||||
void PropertiesView::onLabelSizeChanged()
|
||||
{
|
||||
auto* tmplate = mModel->tmplate();
|
||||
auto* frame = tmplate->frames().first();
|
||||
bool isRotated = mModel->rotate();
|
||||
auto tmplate = mModel->tmplate();
|
||||
auto frame = tmplate.frame();
|
||||
bool isRotated = mModel->rotate();
|
||||
|
||||
preview->setTemplate( tmplate );
|
||||
preview->setShowArrow( true );
|
||||
preview->setRotate( isRotated );
|
||||
|
||||
const model::Vendor* vendor = model::Db::lookupVendorFromName( tmplate->brand() );
|
||||
if ( (vendor != nullptr) && (vendor->url() != nullptr) )
|
||||
vendorLabel->setText( tmplate.brand() );
|
||||
if ( model::Db::isVendorNameKnown( tmplate.brand() ) )
|
||||
{
|
||||
QString markup = QString( "<a href='%1'>%2</a>" ).arg( vendor->url(), vendor->name() );
|
||||
vendorLabel->setText( markup );
|
||||
}
|
||||
else
|
||||
{
|
||||
vendorLabel->setText( tmplate->brand() );
|
||||
auto vendor = model::Db::lookupVendorFromName( tmplate.brand() );
|
||||
if ( !vendor.url().isEmpty() )
|
||||
{
|
||||
QString markup = QString( "<a href='%1'>%2</a>" ).arg( vendor.url(), vendor.name() );
|
||||
vendorLabel->setText( markup );
|
||||
}
|
||||
}
|
||||
|
||||
if ( tmplate->productUrl() != nullptr )
|
||||
if ( !tmplate.productUrl().isEmpty() )
|
||||
{
|
||||
QString markup = QString( "<a href='%1'>%2</a>" ).arg( tmplate->productUrl(), tmplate->part() );
|
||||
QString markup = QString( "<a href='%1'>%2</a>" ).arg( tmplate.productUrl(), tmplate.part() );
|
||||
partLabel->setText( markup );
|
||||
}
|
||||
else
|
||||
{
|
||||
partLabel->setText( tmplate->part() );
|
||||
partLabel->setText( tmplate.part() );
|
||||
}
|
||||
|
||||
descriptionLabel->setText( tmplate->description() );
|
||||
pageSizeLabel->setText( tmplate->paperDescription( mUnits ) );
|
||||
descriptionLabel->setText( tmplate.description() );
|
||||
pageSizeLabel->setText( tmplate.paperDescription( mUnits ) );
|
||||
labelSizeLabel->setText( frame->sizeDescription( mUnits ) );
|
||||
layoutLabel->setText( frame->layoutDescription() );
|
||||
|
||||
QStringList list = model::Db::getNameListOfSimilarTemplates( tmplate->name() );
|
||||
QStringList list = model::Db::getNameListOfSimilarTemplates( tmplate.name() );
|
||||
if ( list.isEmpty() )
|
||||
{
|
||||
similarProductsGroupBox->hide();
|
||||
@@ -208,8 +199,8 @@ namespace glabels
|
||||
///
|
||||
void PropertiesView::onOrientationActivated()
|
||||
{
|
||||
const model::Template* tmplate = mModel->tmplate();
|
||||
const model::Frame* frame = tmplate->frames().first();
|
||||
auto tmplate = mModel->tmplate();
|
||||
auto frame = tmplate.frame();
|
||||
|
||||
// Make sure index actually changed.
|
||||
int index = orientationCombo->currentIndex();
|
||||
@@ -243,15 +234,15 @@ namespace glabels
|
||||
SelectProductDialog selectProductDialog( this );
|
||||
selectProductDialog.exec();
|
||||
|
||||
const model::Template* tmplate = selectProductDialog.tmplate();
|
||||
if ( tmplate )
|
||||
auto tmplate = selectProductDialog.tmplate();
|
||||
if ( !tmplate.isNull() )
|
||||
{
|
||||
mUndoRedoModel->checkpoint( tr("Change Product") );
|
||||
|
||||
mModel->setTmplate( tmplate );
|
||||
|
||||
// Don't rotate circular or round labels
|
||||
const model::Frame *frame = tmplate->frames().first();
|
||||
auto frame = tmplate.frame();
|
||||
if ( frame->w() == frame->h() )
|
||||
{
|
||||
mModel->setRotate( false );
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace glabels
|
||||
/////////////////////////////////
|
||||
public:
|
||||
PropertiesView( QWidget *parent = nullptr );
|
||||
~PropertiesView() override;
|
||||
virtual ~PropertiesView() = default;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
@@ -29,16 +29,16 @@ namespace glabels
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
RollTemplatePath::RollTemplatePath( const model::Template* tmplate )
|
||||
RollTemplatePath::RollTemplatePath( const model::Template& tmplate )
|
||||
{
|
||||
if ( !tmplate->isRoll() )
|
||||
if ( !tmplate.isRoll() )
|
||||
{
|
||||
qWarning() << "Not a \"Roll\" template type.";
|
||||
}
|
||||
|
||||
model::Distance x0 = (tmplate->pageWidth() - tmplate->rollWidth()) / 2.0;
|
||||
model::Distance w = tmplate->rollWidth();
|
||||
model::Distance h = tmplate->pageHeight();
|
||||
model::Distance x0 = (tmplate.pageWidth() - tmplate.rollWidth()) / 2.0;
|
||||
model::Distance w = tmplate.rollWidth();
|
||||
model::Distance h = tmplate.pageHeight();
|
||||
model::Distance c = 0.07*h;
|
||||
model::Distance b = 0.03*h;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace glabels
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
RollTemplatePath( const model::Template* tmplate );
|
||||
RollTemplatePath( const model::Template& tmplate );
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -52,15 +52,15 @@ namespace glabels
|
||||
categoriesCheckContainer->setEnabled( !model::Settings::searchAllCategories() );
|
||||
mCategoryIdList = model::Settings::searchCategoryList();
|
||||
|
||||
QList<model::Category*> categories = model::Db::categories();
|
||||
foreach ( model::Category *category, categories )
|
||||
auto categories = model::Db::categories();
|
||||
for ( auto& category : categories )
|
||||
{
|
||||
QCheckBox* check = new QCheckBox( category->name() );
|
||||
check->setChecked( mCategoryIdList.contains( category->id() ) );
|
||||
QCheckBox* check = new QCheckBox( category.name() );
|
||||
check->setChecked( mCategoryIdList.contains( category.id() ) );
|
||||
categoriesLayout->addWidget( check );
|
||||
|
||||
mCheckList.append( check );
|
||||
mCheckToCategoryMap[check] = category->id();
|
||||
mCheckToCategoryMap[check] = category.id();
|
||||
|
||||
connect( check, SIGNAL(clicked()), this, SLOT(onCategoryCheckClicked()) );
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace glabels
|
||||
viewModeButton->setToolTip( tr( "Grid View" ) );
|
||||
}
|
||||
|
||||
QList<model::Template*> tmplates = model::Db::templates();
|
||||
auto tmplates = model::Db::templates();
|
||||
templatePicker->setTemplates( tmplates );
|
||||
|
||||
if ( model::Settings::recentTemplateList().count() > 0 )
|
||||
@@ -93,7 +93,7 @@ namespace glabels
|
||||
///
|
||||
/// Get selected template
|
||||
///
|
||||
const model::Template* SelectProductDialog::tmplate() const
|
||||
model::Template SelectProductDialog::tmplate() const
|
||||
{
|
||||
if ( mHasSelection )
|
||||
{
|
||||
@@ -101,7 +101,7 @@ namespace glabels
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
return model::Template();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,41 +229,41 @@ namespace glabels
|
||||
///
|
||||
void SelectProductDialog::onTemplatePickerSelectionChanged()
|
||||
{
|
||||
auto* tmplate = templatePicker->selectedTemplate();
|
||||
if ( !tmplate )
|
||||
auto tmplate = templatePicker->selectedTemplate();
|
||||
if ( tmplate.isNull() )
|
||||
{
|
||||
productInfoWidget->setVisible( false );
|
||||
selectButton->setEnabled( false );
|
||||
return;
|
||||
}
|
||||
|
||||
auto* frame = tmplate->frames().first();
|
||||
auto frame = tmplate.frame();
|
||||
|
||||
preview->setTemplate( tmplate );
|
||||
|
||||
const model::Vendor* vendor = model::Db::lookupVendorFromName( tmplate->brand() );
|
||||
if ( (vendor != nullptr) && (vendor->url() != nullptr) )
|
||||
vendorLabel->setText( tmplate.brand() );
|
||||
if ( model::Db::isVendorNameKnown( tmplate.brand() ) )
|
||||
{
|
||||
QString markup = QString( "<a href='%1'>%2</a>" ).arg( vendor->url(), vendor->name() );
|
||||
vendorLabel->setText( markup );
|
||||
}
|
||||
else
|
||||
{
|
||||
vendorLabel->setText( tmplate->brand() );
|
||||
auto vendor = model::Db::lookupVendorFromName( tmplate.brand() );
|
||||
if ( !vendor.url().isEmpty() )
|
||||
{
|
||||
QString markup = QString( "<a href='%1'>%2</a>" ).arg( vendor.url(), vendor.name() );
|
||||
vendorLabel->setText( markup );
|
||||
}
|
||||
}
|
||||
|
||||
if ( tmplate->productUrl() != nullptr )
|
||||
if ( !tmplate.productUrl().isEmpty() )
|
||||
{
|
||||
QString markup = QString( "<a href='%1'>%2</a>" ).arg( tmplate->productUrl(), tmplate->part() );
|
||||
QString markup = QString( "<a href='%1'>%2</a>" ).arg( tmplate.productUrl(), tmplate.part() );
|
||||
partLabel->setText( markup );
|
||||
}
|
||||
else
|
||||
{
|
||||
partLabel->setText( tmplate->part() );
|
||||
partLabel->setText( tmplate.part() );
|
||||
}
|
||||
|
||||
descriptionLabel->setText( tmplate->description() );
|
||||
pageSizeLabel->setText( tmplate->paperDescription( model::Settings::units() ) );
|
||||
descriptionLabel->setText( tmplate.description() );
|
||||
pageSizeLabel->setText( tmplate.paperDescription( model::Settings::units() ) );
|
||||
labelSizeLabel->setText( frame->sizeDescription( model::Settings::units() ) );
|
||||
layoutLabel->setText( frame->layoutDescription() );
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace glabels
|
||||
/////////////////////////////////
|
||||
// Accessors
|
||||
/////////////////////////////////
|
||||
const model::Template* tmplate() const;
|
||||
model::Template tmplate() const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
+16
-16
@@ -78,7 +78,7 @@ namespace glabels
|
||||
///
|
||||
/// Template Property Setter
|
||||
///
|
||||
void SimplePreview::setTemplate( const model::Template *tmplate )
|
||||
void SimplePreview::setTemplate( const model::Template& tmplate )
|
||||
{
|
||||
mTmplate = tmplate;
|
||||
update();
|
||||
@@ -121,21 +121,21 @@ namespace glabels
|
||||
{
|
||||
mScene->clear();
|
||||
|
||||
if ( mTmplate != nullptr )
|
||||
if ( !mTmplate.isNull() )
|
||||
{
|
||||
// For "Roll" templates, allow extra room to draw continuation break lines.
|
||||
model::Distance drawHeight = mTmplate->pageHeight();
|
||||
model::Distance drawHeight = mTmplate.pageHeight();
|
||||
model::Distance drawOffset = 0;
|
||||
if ( mTmplate->isRoll() )
|
||||
if ( mTmplate.isRoll() )
|
||||
{
|
||||
drawHeight = 1.2 * mTmplate->pageHeight();
|
||||
drawOffset = 0.1 * mTmplate->pageHeight();
|
||||
drawHeight = 1.2 * mTmplate.pageHeight();
|
||||
drawOffset = 0.1 * mTmplate.pageHeight();
|
||||
}
|
||||
|
||||
// Set scene up with a 5% margin around paper
|
||||
model::Distance x = -0.05 * mTmplate->pageWidth();
|
||||
model::Distance x = -0.05 * mTmplate.pageWidth();
|
||||
model::Distance y = -0.05 * drawHeight - drawOffset;
|
||||
model::Distance w = 1.10 * mTmplate->pageWidth();
|
||||
model::Distance w = 1.10 * mTmplate.pageWidth();
|
||||
model::Distance h = 1.10 * drawHeight;
|
||||
|
||||
mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() );
|
||||
@@ -167,9 +167,9 @@ namespace glabels
|
||||
pen.setWidthF( paperOutlineWidthPixels );
|
||||
|
||||
QAbstractGraphicsShapeItem* pageItem;
|
||||
if ( !mTmplate->isRoll() )
|
||||
if ( !mTmplate.isRoll() )
|
||||
{
|
||||
pageItem = new QGraphicsRectItem( 0, 0, mTmplate->pageWidth().pt(), mTmplate->pageHeight().pt() );
|
||||
pageItem = new QGraphicsRectItem( 0, 0, mTmplate.pageWidth().pt(), mTmplate.pageHeight().pt() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -188,9 +188,9 @@ namespace glabels
|
||||
///
|
||||
void SimplePreview::drawLabels()
|
||||
{
|
||||
model::Frame *frame = mTmplate->frames().first();
|
||||
auto frame = mTmplate.frame();
|
||||
|
||||
foreach (model::Point origin, frame->getOrigins() )
|
||||
for ( model::Point origin : frame->getOrigins() )
|
||||
{
|
||||
drawLabel( origin.x(), origin.y(), frame->path() );
|
||||
}
|
||||
@@ -200,9 +200,9 @@ namespace glabels
|
||||
///
|
||||
/// Draw a Single Label at x,y
|
||||
///
|
||||
void SimplePreview::drawLabel( const model::Distance& x,
|
||||
const model::Distance& y,
|
||||
const QPainterPath& path )
|
||||
void SimplePreview::drawLabel( model::Distance x,
|
||||
model::Distance y,
|
||||
const QPainterPath& path )
|
||||
{
|
||||
QBrush brush( labelColor );
|
||||
QPen pen( labelOutlineColor );
|
||||
@@ -223,7 +223,7 @@ namespace glabels
|
||||
///
|
||||
void SimplePreview::drawArrow()
|
||||
{
|
||||
model::Frame *frame = mTmplate->frames().first();
|
||||
auto frame = mTmplate.frame();
|
||||
|
||||
model::Distance w = frame->w();
|
||||
model::Distance h = frame->h();
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace glabels
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void setTemplate( const model::Template *tmplate );
|
||||
void setTemplate( const model::Template& tmplate );
|
||||
void setShowArrow( bool showArrow );
|
||||
void setRotate( bool rotateFlag );
|
||||
|
||||
@@ -70,7 +70,9 @@ namespace glabels
|
||||
void update();
|
||||
void drawPaper();
|
||||
void drawLabels();
|
||||
void drawLabel( const model::Distance& x, const model::Distance& y, const QPainterPath& path );
|
||||
void drawLabel( model::Distance x,
|
||||
model::Distance y,
|
||||
const QPainterPath& path );
|
||||
void drawArrow();
|
||||
|
||||
|
||||
@@ -78,11 +80,11 @@ namespace glabels
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
const model::Template* mTmplate { nullptr };
|
||||
bool mShowArrow { false };
|
||||
bool mRotateFlag { false };
|
||||
model::Template mTmplate;
|
||||
bool mShowArrow { false };
|
||||
bool mRotateFlag { false };
|
||||
|
||||
QGraphicsScene* mScene { nullptr };
|
||||
QGraphicsScene* mScene { nullptr };
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "TemplateDesigner.h"
|
||||
|
||||
#include "SelectProductDialog.h"
|
||||
@@ -34,14 +35,16 @@
|
||||
#include "model/PageRenderer.h"
|
||||
#include "model/Settings.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrinter>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtDebug>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
|
||||
|
||||
namespace glabels
|
||||
{
|
||||
@@ -367,7 +370,7 @@ namespace glabels
|
||||
///
|
||||
/// Build template from wizard pages
|
||||
///
|
||||
model::Template* TemplateDesigner::buildTemplate()
|
||||
model::Template TemplateDesigner::buildTemplate()
|
||||
{
|
||||
model::Units units = model::Settings::units();
|
||||
|
||||
@@ -379,9 +382,8 @@ namespace glabels
|
||||
model::Distance pageH( field( "pageSize.h" ).toDouble(), units );
|
||||
model::Distance pageRollW( field( "pageSize.rollW" ).toDouble(), units );
|
||||
|
||||
auto t = new model::Template( brand, part, description, paperId, pageW, pageH, pageRollW, true );
|
||||
auto t = model::Template( brand, part, description, paperId, pageW, pageH, pageRollW, "", true );
|
||||
|
||||
model::Frame* frame;
|
||||
if ( field( "shape.rect" ).toBool() )
|
||||
{
|
||||
model::Distance w( field( "rect.w" ).toDouble(), units );
|
||||
@@ -392,8 +394,10 @@ namespace glabels
|
||||
model::Distance xMargin( field( "rect.xMargin" ).toDouble(), units );
|
||||
model::Distance yMargin( field( "rect.yMargin" ).toDouble(), units );
|
||||
|
||||
frame = new model::FrameRect( w, h, r, xWaste, yWaste );
|
||||
frame->addMarkup( new model::MarkupMargin( xMargin, yMargin ) );
|
||||
model::FrameRect frame( w, h, r, xWaste, yWaste );
|
||||
frame.addMarkup( model::MarkupMargin( xMargin, yMargin ) );
|
||||
addLayouts( frame );
|
||||
t.addFrame( frame );
|
||||
}
|
||||
else if ( field( "shape.round" ).toBool() )
|
||||
{
|
||||
@@ -401,8 +405,10 @@ namespace glabels
|
||||
model::Distance waste( field( "round.waste" ).toDouble(), units );
|
||||
model::Distance margin( field( "round.margin" ).toDouble(), units );
|
||||
|
||||
frame = new model::FrameRound( r, waste );
|
||||
frame->addMarkup( new model::MarkupMargin( margin ) );
|
||||
model::FrameRound frame( r, waste );
|
||||
frame.addMarkup( model::MarkupMargin( margin ) );
|
||||
addLayouts( frame );
|
||||
t.addFrame( frame );
|
||||
}
|
||||
else if ( field( "shape.ellipse" ).toBool() )
|
||||
{
|
||||
@@ -411,8 +417,10 @@ namespace glabels
|
||||
model::Distance waste( field( "ellipse.waste" ).toDouble(), units );
|
||||
model::Distance margin( field( "ellipse.margin" ).toDouble(), units );
|
||||
|
||||
frame = new model::FrameEllipse( w, h, waste );
|
||||
frame->addMarkup( new model::MarkupMargin( margin ) );
|
||||
model::FrameEllipse frame( w, h, waste );
|
||||
frame.addMarkup( model::MarkupMargin( margin ) );
|
||||
addLayouts( frame );
|
||||
t.addFrame( frame );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -423,10 +431,22 @@ namespace glabels
|
||||
model::Distance waste( field( "cd.waste" ).toDouble(), units );
|
||||
model::Distance margin( field( "cd.margin" ).toDouble(), units );
|
||||
|
||||
frame = new model::FrameCd( r1, r2, xClip, yClip, waste );
|
||||
frame->addMarkup( new model::MarkupMargin( margin ) );
|
||||
model::FrameCd frame( r1, r2, xClip, yClip, waste );
|
||||
frame.addMarkup( model::MarkupMargin( margin ) );
|
||||
addLayouts( frame );
|
||||
t.addFrame( frame );
|
||||
}
|
||||
t->addFrame( frame );
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Add layouts to frame
|
||||
///
|
||||
void TemplateDesigner::addLayouts( model::Frame& frame )
|
||||
{
|
||||
model::Units units = model::Settings::units();
|
||||
|
||||
if ( field( "nLayouts.one" ).toBool() )
|
||||
{
|
||||
@@ -437,7 +457,7 @@ namespace glabels
|
||||
model::Distance dx( field( "oneLayout.dx" ).toDouble(), units );
|
||||
model::Distance dy( field( "oneLayout.dy" ).toDouble(), units );
|
||||
|
||||
frame->addLayout( model::Layout( nx, ny, x0, y0, dx, dy ) );
|
||||
frame.addLayout( model::Layout( nx, ny, x0, y0, dx, dy ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -455,14 +475,12 @@ namespace glabels
|
||||
model::Distance dx2( field( "twoLayout.dx2" ).toDouble(), units );
|
||||
model::Distance dy2( field( "twoLayout.dy2" ).toDouble(), units );
|
||||
|
||||
frame->addLayout( model::Layout( nx1, ny1, x01, y01, dx1, dy1 ) );
|
||||
frame->addLayout( model::Layout( nx2, ny2, x02, y02, dx2, dy2 ) );
|
||||
frame.addLayout( model::Layout( nx1, ny1, x01, y01, dx1, dy1 ) );
|
||||
frame.addLayout( model::Layout( nx2, ny2, x02, y02, dx2, dy2 ) );
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// Print test sheet
|
||||
///
|
||||
@@ -498,22 +516,22 @@ namespace glabels
|
||||
///
|
||||
/// Load wizard from template
|
||||
///
|
||||
void TemplateDesigner::loadFromTemplate( const model::Template* tmplate )
|
||||
void TemplateDesigner::loadFromTemplate( const model::Template& tmplate )
|
||||
{
|
||||
mIsBasedOnCopy = true;
|
||||
|
||||
model::Units units = model::Settings::units();
|
||||
|
||||
setField( "name.brand", tmplate->brand() );
|
||||
setField( "name.part", tmplate->part() + QString(" (%1)").arg( tr("Copy") ) );
|
||||
setField( "name.description", tmplate->description() );
|
||||
setField( "name.brand", tmplate.brand() );
|
||||
setField( "name.part", tmplate.part() + QString(" (%1)").arg( tr("Copy") ) );
|
||||
setField( "name.description", tmplate.description() );
|
||||
|
||||
setField( "pageSize.pageSize", model::Db::lookupPaperNameFromId( tmplate->paperId() ) );
|
||||
setField( "pageSize.w", tmplate->pageWidth().inUnits( units ) );
|
||||
setField( "pageSize.h", tmplate->pageHeight().inUnits( units ) );
|
||||
setField( "pageSize.rollW", tmplate->rollWidth().inUnits( units ) );
|
||||
setField( "pageSize.pageSize", model::Db::lookupPaperNameFromId( tmplate.paperId() ) );
|
||||
setField( "pageSize.w", tmplate.pageWidth().inUnits( units ) );
|
||||
setField( "pageSize.h", tmplate.pageHeight().inUnits( units ) );
|
||||
setField( "pageSize.rollW", tmplate.rollWidth().inUnits( units ) );
|
||||
|
||||
const model::Frame* frame = tmplate->frames().first();
|
||||
auto frame = tmplate.frame();
|
||||
if ( auto frameRect = dynamic_cast<const model::FrameRect*>( frame ) )
|
||||
{
|
||||
setField( "shape.rect", true );
|
||||
@@ -550,9 +568,9 @@ namespace glabels
|
||||
setField( "cd.waste", frameCd->waste().inUnits( units ) );
|
||||
}
|
||||
|
||||
foreach( auto markup, frame->markups() )
|
||||
for( auto& markup : frame->markups() )
|
||||
{
|
||||
if ( auto markupMargin = dynamic_cast<const model::MarkupMargin*>( markup ) )
|
||||
if ( auto markupMargin = dynamic_cast<const model::MarkupMargin*>( markup.get() ) )
|
||||
{
|
||||
setField( "rect.xMargin", markupMargin->xSize().inUnits( units ) );
|
||||
setField( "rect.yMargin", markupMargin->ySize().inUnits( units ) );
|
||||
@@ -565,28 +583,30 @@ namespace glabels
|
||||
auto layouts = frame->layouts();
|
||||
if ( layouts.size() == 1 )
|
||||
{
|
||||
setField( "oneLayout.nx", layouts[0].nx() );
|
||||
setField( "oneLayout.ny", layouts[0].ny() );
|
||||
setField( "oneLayout.x0", layouts[0].x0().inUnits( units ) );
|
||||
setField( "oneLayout.y0", layouts[0].y0().inUnits( units ) );
|
||||
setField( "oneLayout.dx", layouts[0].dx().inUnits( units ) );
|
||||
setField( "oneLayout.dy", layouts[0].dy().inUnits( units ) );
|
||||
setField( "oneLayout.nx", layouts.front().nx() );
|
||||
setField( "oneLayout.ny", layouts.front().ny() );
|
||||
setField( "oneLayout.x0", layouts.front().x0().inUnits( units ) );
|
||||
setField( "oneLayout.y0", layouts.front().y0().inUnits( units ) );
|
||||
setField( "oneLayout.dx", layouts.front().dx().inUnits( units ) );
|
||||
setField( "oneLayout.dy", layouts.front().dy().inUnits( units ) );
|
||||
}
|
||||
else if ( layouts.size() > 1 )
|
||||
{
|
||||
setField( "twoLayout.nx1", layouts[0].nx() );
|
||||
setField( "twoLayout.ny1", layouts[0].ny() );
|
||||
setField( "twoLayout.x01", layouts[0].x0().inUnits( units ) );
|
||||
setField( "twoLayout.y01", layouts[0].y0().inUnits( units ) );
|
||||
setField( "twoLayout.dx1", layouts[0].dx().inUnits( units ) );
|
||||
setField( "twoLayout.dy1", layouts[0].dy().inUnits( units ) );
|
||||
auto it = layouts.begin();
|
||||
setField( "twoLayout.nx1", it->nx() );
|
||||
setField( "twoLayout.ny1", it->ny() );
|
||||
setField( "twoLayout.x01", it->x0().inUnits( units ) );
|
||||
setField( "twoLayout.y01", it->y0().inUnits( units ) );
|
||||
setField( "twoLayout.dx1", it->dx().inUnits( units ) );
|
||||
setField( "twoLayout.dy1", it->dy().inUnits( units ) );
|
||||
|
||||
setField( "twoLayout.nx2", layouts[1].nx() );
|
||||
setField( "twoLayout.ny2", layouts[1].ny() );
|
||||
setField( "twoLayout.x02", layouts[1].x0().inUnits( units ) );
|
||||
setField( "twoLayout.y02", layouts[1].y0().inUnits( units ) );
|
||||
setField( "twoLayout.dx2", layouts[1].dx().inUnits( units ) );
|
||||
setField( "twoLayout.dy2", layouts[1].dy().inUnits( units ) );
|
||||
std::advance( it, 1 );
|
||||
setField( "twoLayout.nx2", it->nx() );
|
||||
setField( "twoLayout.ny2", it->ny() );
|
||||
setField( "twoLayout.x02", it->x0().inUnits( units ) );
|
||||
setField( "twoLayout.y02", it->y0().inUnits( units ) );
|
||||
setField( "twoLayout.dx2", it->dx().inUnits( units ) );
|
||||
setField( "twoLayout.dy2", it->dy().inUnits( units ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,16 +653,16 @@ namespace glabels
|
||||
SelectProductDialog dialog;
|
||||
dialog.exec();
|
||||
|
||||
const model::Template* tmplate = dialog.tmplate();
|
||||
if ( tmplate )
|
||||
auto tmplate = dialog.tmplate();
|
||||
if ( !tmplate.isNull() )
|
||||
{
|
||||
if ( auto td = dynamic_cast<TemplateDesigner*>( wizard() ) )
|
||||
{
|
||||
if ( dynamic_cast<model::FramePath*>(tmplate->frames().constFirst()) )
|
||||
if ( dynamic_cast<const model::FramePath*>(tmplate.frame()) )
|
||||
{
|
||||
td->mIsTemplatePathBased = true;
|
||||
}
|
||||
else if ( dynamic_cast<model::FrameContinuous*>(tmplate->frames().constFirst()) )
|
||||
else if ( dynamic_cast<const model::FrameContinuous*>(tmplate.frame()) )
|
||||
{
|
||||
td->mIsTemplateContinuousBased = true;
|
||||
}
|
||||
@@ -753,9 +773,9 @@ namespace glabels
|
||||
|
||||
if ( pageSizeCombo->currentText() != tr("Other") )
|
||||
{
|
||||
const model::Paper* paper = model::Db::lookupPaperFromName( pageSizeCombo->currentText() );
|
||||
wSpin->setValue( paper->width().inUnits( model::Settings::units() ) );
|
||||
hSpin->setValue( paper->height().inUnits( model::Settings::units() ) );
|
||||
auto paper = model::Db::lookupPaperFromName( pageSizeCombo->currentText() );
|
||||
wSpin->setValue( paper.width().inUnits( model::Settings::units() ) );
|
||||
hSpin->setValue( paper.height().inUnits( model::Settings::units() ) );
|
||||
}
|
||||
|
||||
registerField( "pageSize.pageSize", pageSizeCombo, "currentText" );
|
||||
@@ -789,9 +809,9 @@ namespace glabels
|
||||
|
||||
if ( !isOther && !isRoll )
|
||||
{
|
||||
const model::Paper* paper = model::Db::lookupPaperFromName( pageSizeCombo->currentText() );
|
||||
wSpin->setValue( paper->width().inUnits( model::Settings::units() ) );
|
||||
hSpin->setValue( paper->height().inUnits( model::Settings::units() ) );
|
||||
auto paper = model::Db::lookupPaperFromName( pageSizeCombo->currentText() );
|
||||
wSpin->setValue( paper.width().inUnits( model::Settings::units() ) );
|
||||
hSpin->setValue( paper.height().inUnits( model::Settings::units() ) );
|
||||
}
|
||||
|
||||
if ( !isRoll )
|
||||
@@ -1553,7 +1573,7 @@ namespace glabels
|
||||
//
|
||||
QString brand = field( "name.brand" ).toString();
|
||||
QString part = field( "name.part" ).toString();
|
||||
QString filename = model::Db::userTemplateFilename( brand, part );
|
||||
QString filename = model::Db::userTemplateFileName( brand, part );
|
||||
|
||||
if ( QFileInfo::exists(filename) )
|
||||
{
|
||||
|
||||
@@ -86,9 +86,10 @@ namespace glabels
|
||||
double itemHeight();
|
||||
double itemXWaste();
|
||||
double itemYWaste();
|
||||
model::Template* buildTemplate();
|
||||
model::Template buildTemplate();
|
||||
void addLayouts( model::Frame& frame );
|
||||
void printTestSheet();
|
||||
void loadFromTemplate( const model::Template* tmplate );
|
||||
void loadFromTemplate( const model::Template& tmplate );
|
||||
bool isBasedOnCopy();
|
||||
|
||||
|
||||
|
||||
+10
-10
@@ -112,11 +112,11 @@ namespace glabels
|
||||
///
|
||||
/// Set List of Templates to Pick From
|
||||
///
|
||||
void TemplatePicker::setTemplates( const QList<model::Template*>& tmplates )
|
||||
void TemplatePicker::setTemplates( const QList<model::Template>& tmplates )
|
||||
{
|
||||
auto mode = model::Settings::templatePickerMode();
|
||||
|
||||
foreach (model::Template *tmplate, tmplates)
|
||||
foreach (auto& tmplate, tmplates)
|
||||
{
|
||||
new TemplatePickerItem( tmplate, mode, this );
|
||||
}
|
||||
@@ -186,12 +186,12 @@ namespace glabels
|
||||
{
|
||||
if (auto* tItem = dynamic_cast<TemplatePickerItem *>(item(i)))
|
||||
{
|
||||
bool nameMask = tItem->tmplate()->name().contains( searchString, Qt::CaseInsensitive );
|
||||
bool nameMask = tItem->tmplate().name().contains( searchString, Qt::CaseInsensitive );
|
||||
|
||||
bool sizeMask =
|
||||
(isoMask && tItem->tmplate()->isSizeIso()) ||
|
||||
(usMask && tItem->tmplate()->isSizeUs()) ||
|
||||
(otherMask && tItem->tmplate()->isSizeOther());
|
||||
(isoMask && tItem->tmplate().isSizeIso()) ||
|
||||
(usMask && tItem->tmplate().isSizeUs()) ||
|
||||
(otherMask && tItem->tmplate().isSizeOther());
|
||||
|
||||
bool categoryMask;
|
||||
if ( anyCategory )
|
||||
@@ -203,7 +203,7 @@ namespace glabels
|
||||
categoryMask = false;
|
||||
foreach ( QString id, categoryIds )
|
||||
{
|
||||
categoryMask = categoryMask || tItem->tmplate()->hasCategory( id );
|
||||
categoryMask = categoryMask || tItem->tmplate().hasCategory( id );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace glabels
|
||||
bool match = false;
|
||||
foreach ( QString name, names )
|
||||
{
|
||||
if ( tItem->tmplate()->name() == name )
|
||||
if ( tItem->tmplate().name() == name )
|
||||
{
|
||||
match = true;
|
||||
break;
|
||||
@@ -268,14 +268,14 @@ namespace glabels
|
||||
///
|
||||
/// Get Currently Selected Template
|
||||
///
|
||||
const model::Template* TemplatePicker::selectedTemplate() const
|
||||
model::Template TemplatePicker::selectedTemplate() const
|
||||
{
|
||||
if ( auto* tItem = selectedItem() )
|
||||
{
|
||||
return tItem->tmplate();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return model::Template();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace glabels
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void setTemplates( const QList<model::Template*>& tmplates );
|
||||
void setTemplates( const QList<model::Template>& tmplates );
|
||||
|
||||
void setMode( QListView::ViewMode mode );
|
||||
QListView::ViewMode mode() const;
|
||||
@@ -66,8 +66,8 @@ namespace glabels
|
||||
|
||||
void applyFilter( const QStringList& names );
|
||||
|
||||
const model::Template* selectedTemplate() const;
|
||||
TemplatePickerItem* selectedItem() const;
|
||||
model::Template selectedTemplate() const;
|
||||
TemplatePickerItem* selectedItem() const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -36,9 +36,9 @@ namespace glabels
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TemplatePickerItem::TemplatePickerItem( model::Template* tmplate,
|
||||
QListView::ViewMode mode,
|
||||
QListWidget* parent )
|
||||
TemplatePickerItem::TemplatePickerItem( const model::Template& tmplate,
|
||||
QListView::ViewMode mode,
|
||||
QListWidget* parent )
|
||||
: QListWidgetItem( parent )
|
||||
{
|
||||
mTmplate = tmplate;
|
||||
@@ -55,18 +55,18 @@ namespace glabels
|
||||
///
|
||||
void TemplatePickerItem::setMode( QListView::ViewMode mode )
|
||||
{
|
||||
auto* frame = mTmplate->frames().first();
|
||||
auto frame = mTmplate.frame();
|
||||
|
||||
switch ( mode )
|
||||
{
|
||||
|
||||
case QListView::IconMode:
|
||||
setText( mTmplate->name() );
|
||||
setText( mTmplate.name() );
|
||||
break;
|
||||
|
||||
case QListView::ListMode:
|
||||
setText( "<b>" + mTmplate->name() + "</b><br/>" +
|
||||
mTmplate->description() + "<br/>" +
|
||||
setText( "<b>" + mTmplate.name() + "</b><br/>" +
|
||||
mTmplate.description() + "<br/>" +
|
||||
frame->sizeDescription( model::Settings::units() ) + "<br/>" +
|
||||
frame->layoutDescription() );
|
||||
break;
|
||||
@@ -82,7 +82,7 @@ namespace glabels
|
||||
///
|
||||
/// Template Property Getter
|
||||
///
|
||||
const model::Template *TemplatePickerItem::tmplate() const
|
||||
model::Template TemplatePickerItem::tmplate() const
|
||||
{
|
||||
return mTmplate;
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ namespace glabels
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TemplatePickerItem( model::Template* tmplate,
|
||||
QListView::ViewMode mode,
|
||||
QListWidget* parent = nullptr );
|
||||
TemplatePickerItem( const model::Template& tmplate,
|
||||
QListView::ViewMode mode,
|
||||
QListWidget* parent = nullptr );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
@@ -60,14 +60,14 @@ namespace glabels
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
const model::Template *tmplate() const;
|
||||
model::Template tmplate() const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
model::Template *mTmplate;
|
||||
model::Template mTmplate;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -38,15 +38,6 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
UndoRedoModel::~UndoRedoModel()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Checkpoint
|
||||
///
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace glabels
|
||||
/////////////////////////////////
|
||||
public:
|
||||
UndoRedoModel( model::Model* model );
|
||||
~UndoRedoModel() override;
|
||||
virtual ~UndoRedoModel() = default;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
@@ -82,15 +82,6 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
VariablesView::~VariablesView()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Set Model
|
||||
///
|
||||
@@ -132,7 +123,7 @@ namespace glabels
|
||||
|
||||
if ( dialog.exec() == QDialog::Accepted )
|
||||
{
|
||||
mModel->variables()->addVariable( dialog.variable() );
|
||||
mModel->variables().addVariable( dialog.variable() );
|
||||
selectVariable( dialog.variable().name() );
|
||||
}
|
||||
}
|
||||
@@ -146,9 +137,9 @@ namespace glabels
|
||||
int iRow = table->selectedItems()[0]->row();
|
||||
QString name = table->item( iRow, I_COL_NAME )->text();
|
||||
|
||||
if ( mModel->variables()->hasVariable( name ) )
|
||||
if ( mModel->variables().hasVariable( name ) )
|
||||
{
|
||||
model::Variable v = mModel->variables()->value( name );
|
||||
model::Variable v = mModel->variables().value( name );
|
||||
|
||||
EditVariableDialog dialog( this );
|
||||
dialog.setVariable( v );
|
||||
@@ -156,7 +147,7 @@ namespace glabels
|
||||
|
||||
if ( dialog.exec() == QDialog::Accepted )
|
||||
{
|
||||
mModel->variables()->replaceVariable( name, dialog.variable() );
|
||||
mModel->variables().replaceVariable( name, dialog.variable() );
|
||||
selectVariable( dialog.variable().name() );
|
||||
}
|
||||
}
|
||||
@@ -171,7 +162,7 @@ namespace glabels
|
||||
int iRow = table->selectedItems()[0]->row();
|
||||
|
||||
QString name = table->item( iRow, I_COL_NAME )->text();
|
||||
mModel->variables()->deleteVariable( name );
|
||||
mModel->variables().deleteVariable( name );
|
||||
}
|
||||
|
||||
|
||||
@@ -203,10 +194,10 @@ namespace glabels
|
||||
void VariablesView::loadTable()
|
||||
{
|
||||
table->clearContents();
|
||||
table->setRowCount( mModel->variables()->size() );
|
||||
table->setRowCount( mModel->variables().size() );
|
||||
|
||||
int iRow = 0;
|
||||
for( const auto& v : *mModel->variables() )
|
||||
for( const auto& v : mModel->variables() )
|
||||
{
|
||||
auto* typeItem = new QTableWidgetItem( model::Variable::typeToI18nString(v.type()) );
|
||||
typeItem->setFlags( typeItem->flags() ^ Qt::ItemIsEditable );
|
||||
@@ -237,7 +228,7 @@ namespace glabels
|
||||
void VariablesView::selectVariable( const QString& name )
|
||||
{
|
||||
int iRow = 0;
|
||||
for( const auto& v : *mModel->variables() )
|
||||
for( const auto& v : mModel->variables() )
|
||||
{
|
||||
if ( v.name() == name )
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace glabels
|
||||
/////////////////////////////////
|
||||
public:
|
||||
VariablesView( QWidget *parent = nullptr );
|
||||
~VariablesView() override;
|
||||
virtual ~VariablesView() = default;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
+3
-4
@@ -23,7 +23,6 @@
|
||||
#include "model/FileUtil.h"
|
||||
#include "model/Db.h"
|
||||
#include "model/Model.h"
|
||||
#include "model/Settings.h"
|
||||
#include "model/Version.h"
|
||||
#include "model/XmlLabelParser.h"
|
||||
|
||||
@@ -43,9 +42,9 @@ int main( int argc, char **argv )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
QCoreApplication::setOrganizationName( "glabels.org" );
|
||||
QCoreApplication::setOrganizationDomain( "glabels.org" );
|
||||
QCoreApplication::setApplicationName( "glabels-qt" );
|
||||
QCoreApplication::setOrganizationName( glabels::model::Version::ORGANIZATION_NAME );
|
||||
QCoreApplication::setOrganizationDomain( glabels::model::Version::ORGANIZATION_DOMAIN );
|
||||
QCoreApplication::setApplicationName( glabels::model::Version::APPLICATION_NAME );
|
||||
QCoreApplication::setApplicationVersion( glabels::model::Version::LONG_STRING );
|
||||
|
||||
QIcon::setThemeName( "glabels-flat" );
|
||||
|
||||
Reference in New Issue
Block a user