Initial skeletal View implementation.
This commit is contained in:
@@ -20,6 +20,7 @@ set (glabels_sources
|
|||||||
TextNode.cpp
|
TextNode.cpp
|
||||||
NewLabelDialog.cpp
|
NewLabelDialog.cpp
|
||||||
SimplePreview.cpp
|
SimplePreview.cpp
|
||||||
|
View.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set (glabels_qobject_headers
|
set (glabels_qobject_headers
|
||||||
@@ -30,6 +31,7 @@ set (glabels_qobject_headers
|
|||||||
TemplatePicker.h
|
TemplatePicker.h
|
||||||
NewLabelDialog.h
|
NewLabelDialog.h
|
||||||
SimplePreview.h
|
SimplePreview.h
|
||||||
|
View.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (glabels_forms
|
set (glabels_forms
|
||||||
|
|||||||
+6
-6
@@ -42,8 +42,8 @@ namespace glabels
|
|||||||
object->setParent( this );
|
object->setParent( this );
|
||||||
mObjectList << object;
|
mObjectList << object;
|
||||||
|
|
||||||
connect( object, SIGNAL(changed()), this, SLOT(objectChanged(LabelModelObject*)) );
|
connect( object, SIGNAL(changed()), this, SLOT(onObjectChanged()) );
|
||||||
connect( object, SIGNAL(moved()), this, SLOT(objectMoved(LabelModelObject*)) );
|
connect( object, SIGNAL(moved()), this, SLOT(onObjectMoved()) );
|
||||||
|
|
||||||
mModified = true;
|
mModified = true;
|
||||||
|
|
||||||
@@ -52,20 +52,20 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabelModel::onObjectChanged( LabelModelObject* object )
|
void LabelModel::onObjectChanged()
|
||||||
{
|
{
|
||||||
mModified = true;
|
mModified = true;
|
||||||
|
|
||||||
emit objectChanged( object );
|
emit objectChanged( qobject_cast<LabelModelObject*>(sender()) );
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabelModel::onObjectMoved( LabelModelObject* object )
|
void LabelModel::onObjectMoved()
|
||||||
{
|
{
|
||||||
mModified = true;
|
mModified = true;
|
||||||
|
|
||||||
emit objectMoved( object );
|
emit objectMoved( qobject_cast<LabelModelObject*>(sender()) );
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -158,12 +158,13 @@ namespace glabels
|
|||||||
void setSelectionLineColorNode( ColorNode lineColorNode );
|
void setSelectionLineColorNode( ColorNode lineColorNode );
|
||||||
void setSelectionFillColorNode( ColorNode fillColorNode );
|
void setSelectionFillColorNode( ColorNode fillColorNode );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onObjectChanged( LabelModelObject* object );
|
void onObjectChanged();
|
||||||
void onObjectMoved( LabelModelObject* object );
|
void onObjectMoved();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ namespace glabels
|
|||||||
rectItem->setBrush( brush );
|
rectItem->setBrush( brush );
|
||||||
|
|
||||||
QPen pen( lineColorNode().color() );
|
QPen pen( lineColorNode().color() );
|
||||||
|
pen.setJoinStyle( Qt::MiterJoin );
|
||||||
pen.setWidthF( lineWidth() );
|
pen.setWidthF( lineWidth() );
|
||||||
rectItem->setPen( pen );
|
rectItem->setPen( pen );
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ namespace glabels
|
|||||||
rectItem->setBrush( brush );
|
rectItem->setBrush( brush );
|
||||||
|
|
||||||
QPen pen( lineColorNode().color() );
|
QPen pen( lineColorNode().color() );
|
||||||
|
pen.setJoinStyle( Qt::MiterJoin );
|
||||||
pen.setWidthF( lineWidth() );
|
pen.setWidthF( lineWidth() );
|
||||||
rectItem->setPen( pen );
|
rectItem->setPen( pen );
|
||||||
|
|
||||||
|
|||||||
+27
-2
@@ -26,9 +26,13 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "libglabels/Db.h"
|
||||||
|
#include "LabelModelBoxObject.h"
|
||||||
#include "Icons.h"
|
#include "Icons.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "Help.h"
|
#include "Help.h"
|
||||||
|
#include "View.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
@@ -36,8 +40,29 @@ namespace glabels
|
|||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
{
|
{
|
||||||
/////////////// TEMPORARY TESTING ///////////////
|
/////////////// TEMPORARY TESTING ///////////////
|
||||||
#if 1
|
#if 0
|
||||||
QLabel *tmp = new QLabel( "Coming Soon..." );
|
QLabel* tmp = new QLabel( "Coming Soon..." );
|
||||||
|
#else
|
||||||
|
LabelModel* model = new LabelModel();
|
||||||
|
const libglabels::Template* tmplate = libglabels::Db::lookupTemplateFromName( "Avery 3612" );
|
||||||
|
model->setTmplate( tmplate );
|
||||||
|
LabelModelBoxObject* object = new LabelModelBoxObject();
|
||||||
|
object->setW( 36 );
|
||||||
|
object->setH( 36 );
|
||||||
|
object->setX0( 72 );
|
||||||
|
object->setY0( 72 );
|
||||||
|
object->setFillColorNode( ColorNode( QColor( 0, 255, 0 ) ) );
|
||||||
|
object->setLineColorNode( ColorNode( QColor( 0, 0, 0 ) ) );
|
||||||
|
object->setLineWidth( 4 );
|
||||||
|
object->setShadowColorNode( ColorNode( QColor( 0, 0, 0 ) ) );
|
||||||
|
object->setShadowOpacity( 0.25 );
|
||||||
|
object->setShadowX( 5 );
|
||||||
|
object->setShadowY( 5 );
|
||||||
|
object->setShadow( true );
|
||||||
|
model->addObject( object );
|
||||||
|
|
||||||
|
View* tmp = new View();
|
||||||
|
tmp->setModel( model );
|
||||||
#endif
|
#endif
|
||||||
setCentralWidget( tmp );
|
setCentralWidget( tmp );
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/* View.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 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 "View.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
View::View( QWidget *parent ) : QGraphicsView(parent), mScale(1), mModel(0)
|
||||||
|
{
|
||||||
|
mScene = new QGraphicsScene();
|
||||||
|
setScene( mScene );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void View::setModel( LabelModel* model )
|
||||||
|
{
|
||||||
|
mModel = model;
|
||||||
|
|
||||||
|
foreach (LabelModelObject* object, model->objectList() )
|
||||||
|
{
|
||||||
|
QGraphicsItem* item = object->createGraphicsItem();
|
||||||
|
mScene->addItem( item );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
/* View.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 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 glabels_View_h
|
||||||
|
#define glabels_View_h
|
||||||
|
|
||||||
|
#include <QGraphicsView>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
|
||||||
|
#include "LabelModel.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
class View : public QGraphicsView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
View( QWidget *parent = 0 );
|
||||||
|
|
||||||
|
void setModel( LabelModel* model );
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGraphicsScene* mScene;
|
||||||
|
double mScale;
|
||||||
|
|
||||||
|
LabelModel* mModel;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // glabels_View_h
|
||||||
Reference in New Issue
Block a user