Refactoring.

--HG--
branch : develop
This commit is contained in:
dismine 2013-10-27 10:10:39 +02:00
parent f2860076ee
commit 3b908ae328
14 changed files with 98 additions and 198 deletions

View File

@ -45,20 +45,15 @@
using a spin box widget.
*/
#include <QtGui>
#include "doubledelegate.h"
DoubleSpinBoxDelegate::DoubleSpinBoxDelegate(QObject *parent)
: QItemDelegate(parent)
{
}
QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */,
const QModelIndex &/* index */) const{
QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index ) const{
Q_UNUSED(option);
Q_UNUSED(index);
QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
editor->setMinimum(-10000.0);
editor->setMaximum(10000.0);
return editor;
}
@ -69,8 +64,7 @@
spinBox->setValue(value);
}
void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const{
void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const{
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
spinBox->interpretText();
qreal value = spinBox->value();
@ -78,7 +72,8 @@
model->setData(index, value, Qt::EditRole);
}
void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const{
void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
const QModelIndex &index) const{
Q_UNUSED(index)
editor->setGeometry(option.rect);
}

View File

@ -42,26 +42,15 @@
#define DOUBLEDELEGATE_H
#include <QItemDelegate>
#include <QModelIndex>
#include <QObject>
#include <QSize>
#include <QSpinBox>
class DoubleSpinBoxDelegate : public QItemDelegate{
Q_OBJECT
public:
DoubleSpinBoxDelegate(QObject *parent = 0);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
DoubleSpinBoxDelegate(QObject *parent = 0): QItemDelegate(parent){}
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
#endif

View File

@ -20,18 +20,12 @@
****************************************************************************/
#include "vapplication.h"
#include <QtGui>
#include <QMessageBox>
#include "exception/vexceptionobjecterror.h"
#include "exception/vexceptionbadid.h"
#include "exception/vexceptionconversionerror.h"
#include "exception/vexceptionemptyparameter.h"
#include "exception/vexceptionwrongparameterid.h"
VApplication::VApplication(int & argc, char ** argv) :
QApplication(argc, argv){
}
// reimplemented from QApplication so we can throw exceptions in slots
bool VApplication::notify(QObject *receiver, QEvent *event){
try {

View File

@ -3,11 +3,10 @@
#include <QApplication>
class VApplication : public QApplication
{
class VApplication : public QApplication{
Q_OBJECT
public:
VApplication(int &argc, char ** argv);
VApplication(int &argc, char ** argv): QApplication(argc, argv){}
virtual ~VApplication() {}
virtual bool notify(QObject * receiver, QEvent * event);
};

View File

@ -20,10 +20,6 @@
****************************************************************************/
#include "vcontrolpointspline.h"
#include <QPen>
#include <QBrush>
#include <QGraphicsScene>
#include <QDebug>
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &controlPoint, const QPointF &splinePoint,

View File

@ -23,12 +23,10 @@
#define VCONTROLPOINTSPLINE_H
#include <QGraphicsEllipseItem>
#include <QGraphicsLineItem>
#include <QObject>
#include "geometry/vsplinepath.h"
class VControlPointSpline : public QObject, public QGraphicsEllipseItem
{
class VControlPointSpline : public QObject, public QGraphicsEllipseItem{
Q_OBJECT
public:
VControlPointSpline(const qint32 &indexSpline, SplinePoint::Position position,
@ -38,8 +36,8 @@ signals:
void ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position,
const QPointF pos);
public slots:
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos,
const QPointF &controlPoint, const QPointF &splinePoint);
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, const QPointF &controlPoint,
const QPointF &splinePoint);
void setEnabledPoint(bool enable);
protected:
qreal radius;
@ -51,8 +49,7 @@ private:
Q_DISABLE_COPY(VControlPointSpline)
qint32 indexSpline;
SplinePoint::Position position;
qint32 LineIntersectCircle(QPointF center, qreal radius, QLineF line, QPointF &p1,
QPointF &p2) const;
qint32 LineIntersectCircle(QPointF center, qreal radius, QLineF line, QPointF &p1, QPointF &p2) const;
QPointF ClosestPoint(QLineF line, QPointF p) const;
QPointF addVector (QPointF p, QPointF p1, QPointF p2, qreal k) const;

View File

@ -20,9 +20,6 @@
****************************************************************************/
#include "vgraphicssimpletextitem.h"
#include <QGraphicsScene>
#include <QEvent>
#include <QDebug>
VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent):QGraphicsSimpleTextItem(parent),
fontSize(0){

View File

@ -20,16 +20,6 @@
****************************************************************************/
#include "vitem.h"
#include <QGraphicsScene>
#include <QDebug>
#include "options.h"
VItem::VItem():numInOutList(0){
}
VItem::VItem ( int numInList, QGraphicsItem * parent ):QGraphicsPathItem ( parent ),
numInOutList(numInList){
}
VItem::VItem (const QPainterPath & path, int numInList, QGraphicsItem * parent ):
QGraphicsPathItem ( path, parent ), numInOutList(numInList){
@ -77,7 +67,3 @@ QVariant VItem::itemChange( GraphicsItemChange change, const QVariant &value ){
void VItem::LengthChanged(){
checkItemChange();
}
void VItem::SetIndexInList( qint32 index ){
numInOutList = index;
}

View File

@ -35,14 +35,14 @@ public:
* @brief VItem конструктор за замовчуванням
*Конструктор генерує пусту деталь з номером в списку, що дорівнює 0.
*/
VItem ();
VItem ():numInOutList(0){}
/**
* @brief VItem конструктор
* @param numInList номер в списку деталей, що передається у вікно де
*укладаються деталі.
* @param parent батьківський об'єкт на сцені для даного. За замовчуванням немає.
*/
VItem (int numInList, QGraphicsItem * parent = 0);
VItem (int numInList, QGraphicsItem * parent = 0):QGraphicsPathItem (parent), numInOutList(numInList){}
/**
* @brief VItem конструктор
* @param path зображення що буде показуватися на сцені - обєкт класу QPainterPath.
@ -65,7 +65,7 @@ public slots:
* @brief SetIndexInList встановлює номер деталі в списку деталей.
* @param index номер в списку.
*/
void SetIndexInList( qint32 index );
inline void SetIndexInList( qint32 index ) {numInOutList = index;}
protected:
/**
* @brief itemChange модифікація стандартного методу itemChange. Виконується перехоплення зміни

View File

@ -20,10 +20,6 @@
****************************************************************************/
#include "vmaingraphicsscene.h"
#include <QDebug>
#include <QApplication>
#include <QScrollBar>
#include <QGraphicsItem>
VMainGraphicsScene::VMainGraphicsScene():QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1){
}
@ -46,27 +42,7 @@ void VMainGraphicsScene::ChoosedItem(qint64 id, Scene::Scenes type){
emit ChoosedObject(id, type);
}
void VMainGraphicsScene::RemoveTool(QGraphicsItem *tool){
this->removeItem(tool);
}
void VMainGraphicsScene::SetFactor(qreal factor){
scaleFactor=scaleFactor*factor;
emit NewFactor(scaleFactor);
}
qint32 VMainGraphicsScene::getVerScrollBar() const{
return verScrollBar;
}
void VMainGraphicsScene::setVerScrollBar(const qint32 &value){
verScrollBar = value;
}
qint32 VMainGraphicsScene::getHorScrollBar() const{
return horScrollBar;
}
void VMainGraphicsScene::setHorScrollBar(const qint32 &value){
horScrollBar = value;
}

View File

@ -23,25 +23,19 @@
#define VMAINGRAPHICSSCENE_H
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsSceneMouseEvent>
#include "options.h"
class VMainGraphicsScene : public QGraphicsScene
{
class VMainGraphicsScene : public QGraphicsScene{
Q_OBJECT
public:
VMainGraphicsScene();
VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = 0);
qint32 getHorScrollBar() const;
void setHorScrollBar(const qint32 &value);
qint32 getVerScrollBar() const;
void setVerScrollBar(const qint32 &value);
inline qint32 getHorScrollBar() const {return horScrollBar;}
inline void setHorScrollBar(const qint32 &value) {horScrollBar = value;}
inline qint32 getVerScrollBar() const {return verScrollBar;}
inline void setVerScrollBar(const qint32 &value) {verScrollBar = value;}
public slots:
void ChoosedItem(qint64 id, Scene::Scenes type);
void RemoveTool(QGraphicsItem *tool);
inline void RemoveTool(QGraphicsItem *tool) {this->removeItem(tool);}
void SetFactor(qreal factor);
protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);

View File

@ -20,10 +20,6 @@
****************************************************************************/
#include "vmaingraphicsview.h"
#include <QApplication>
#include <QWheelEvent>
#include <QScrollBar>
#include <QTimeLine>
VMainGraphicsView::VMainGraphicsView(QWidget *parent) :
QGraphicsView(parent), _numScheduledScalings(0){

View File

@ -20,11 +20,6 @@
****************************************************************************/
#include "vtablegraphicsview.h"
#include <QDebug>
#include <QGraphicsItem>
#include <QGuiApplication>
#include <QKeyEvent>
#include <QScrollBar>
VTableGraphicsView::VTableGraphicsView(QGraphicsScene* pScene, QWidget *parent) :
QGraphicsView(pScene, parent){
@ -43,10 +38,6 @@ void VTableGraphicsView::selectionChanged(){
}
}
void VTableGraphicsView::rotateItems(){
rotateIt();
}
void VTableGraphicsView::MirrorItem(){
QList<QGraphicsItem *> list = scene()->selectedItems();
if(list.size()>0){
@ -82,14 +73,6 @@ void VTableGraphicsView::MirrorItem(){
}
}
void VTableGraphicsView::ZoomIn(){
scale(1.1,1.1);
}
void VTableGraphicsView::ZoomOut(){
scale(1/1.1,1/1.1);
}
void VTableGraphicsView::wheelEvent(QWheelEvent *event){
if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier){
// Если нажата клавиша CTRL этот код выполнится

View File

@ -24,13 +24,11 @@
#include <QGraphicsView>
class VTableGraphicsView : public QGraphicsView
{
class VTableGraphicsView : public QGraphicsView{
Q_OBJECT
public:
enum typeMove_e { Left, Right, Up, Down };
explicit VTableGraphicsView(QGraphicsScene* pScene, QWidget *parent = 0);
VTableGraphicsView(QGraphicsScene* pScene, QWidget *parent = 0);
signals:
/**
* @brief itemChect Сигнал, що посилається коли змінюється стан вибору деталі.
@ -45,7 +43,7 @@ public slots:
/**
* @brief rotateItems слот, який виконується при натисненні кнопки повороту деталі.
*/
void rotateItems();
inline void rotateItems() {rotateIt();}
/**
* @brief MirrorItem дзеркалить об'єкт відносно вертикальної вісі семетрії об'єкта.
*/
@ -53,11 +51,11 @@ public slots:
/**
* @brief ZoomIn збільшує масштаб листа.
*/
void ZoomIn();
inline void ZoomIn() {scale(1.1,1.1);}
/**
* @brief ZoomOut зменшує масштаб листа.
*/
void ZoomOut();
inline void ZoomOut() {scale(1/1.1,1/1.1);}
protected:
/**
* @brief wheelEvent обробник повороту колеса мишки.