Some style cleanup of LabelModel.h
This commit is contained in:
+159
-52
@@ -31,14 +31,23 @@
|
|||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class LabelModel : public QObject
|
class LabelModel : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Lifecycle
|
||||||
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
LabelModel();
|
LabelModel();
|
||||||
virtual ~LabelModel() {}
|
virtual ~LabelModel() {}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
@@ -51,83 +60,75 @@ namespace glabels
|
|||||||
void objectToTop( LabelModelObject* object );
|
void objectToTop( LabelModelObject* object );
|
||||||
void objectToBottom( LabelModelObject* object );
|
void objectToBottom( LabelModelObject* object );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Properties
|
||||||
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
bool isModified() const { return mModified; }
|
inline bool isModified() const;
|
||||||
void clearModified() { mModified = false; }
|
inline void clearModified();
|
||||||
|
|
||||||
const QString &filename() const { return mFilename; }
|
inline const QString& filename() const;
|
||||||
void setFilename( const QString &filename )
|
inline void setFilename( const QString &filename );
|
||||||
{
|
|
||||||
if ( mFilename != filename )
|
|
||||||
{
|
|
||||||
mFilename = filename;
|
|
||||||
emit nameChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int compressionLevel() const { return mCompressionLevel; }
|
inline int compressionLevel() const;
|
||||||
void setCompressionLevel( int compressionLevel ) { mCompressionLevel = compressionLevel; }
|
inline void setCompressionLevel( int compressionLevel );
|
||||||
|
|
||||||
const libglabels::Template* tmplate() const { return mTmplate; }
|
inline const libglabels::Template* tmplate() const;
|
||||||
void setTmplate( const libglabels::Template* tmplate )
|
inline void setTmplate( const libglabels::Template* tmplate );
|
||||||
{
|
|
||||||
if (mTmplate != tmplate)
|
|
||||||
{
|
|
||||||
mTmplate = tmplate;
|
|
||||||
mFrame = tmplate->frames().first();
|
|
||||||
mModified = true;
|
|
||||||
emit changed();
|
|
||||||
emit sizeChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool rotate() const { return mRotate; }
|
inline bool rotate() const;
|
||||||
void setRotate( bool rotate )
|
inline void setRotate( bool rotate );
|
||||||
{
|
|
||||||
if (mRotate != rotate)
|
|
||||||
{
|
|
||||||
mRotate = rotate;
|
|
||||||
mModified = true;
|
|
||||||
emit changed();
|
|
||||||
emit sizeChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double w() const { return mRotate ? mFrame->h() : mFrame->w(); }
|
inline double w() const;
|
||||||
double h() const { return mRotate ? mFrame->w() : mFrame->h(); }
|
inline double h() const;
|
||||||
|
|
||||||
|
inline const QList<LabelModelObject*>& objectList() const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Manage objects
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
void addObject( LabelModelObject* object );
|
void addObject( LabelModelObject* object );
|
||||||
|
|
||||||
void deleteObject( LabelModelObject* object );
|
void deleteObject( LabelModelObject* object );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Manipulate selection
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
void selectObject( LabelModelObject* object );
|
void selectObject( LabelModelObject* object );
|
||||||
|
|
||||||
void unselectObject( LabelModelObject* object );
|
void unselectObject( LabelModelObject* object );
|
||||||
|
|
||||||
void selectAll();
|
void selectAll();
|
||||||
|
|
||||||
void unselectAll();
|
void unselectAll();
|
||||||
|
void selectRegion( const LabelRegion& region );
|
||||||
void selectRegion( const LabelRegion ®ion );
|
|
||||||
|
|
||||||
bool isSelectionEmpty();
|
bool isSelectionEmpty();
|
||||||
|
|
||||||
bool isSelectionAtomic();
|
bool isSelectionAtomic();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Get selected objects
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
QList<LabelModelObject*> getSelection();
|
QList<LabelModelObject*> getSelection();
|
||||||
|
|
||||||
LabelModelObject* getFirstSelectedObject();
|
LabelModelObject* getFirstSelectedObject();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Query selection capabilities
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
bool canSelectionText();
|
bool canSelectionText();
|
||||||
bool canSelectionFill();
|
bool canSelectionFill();
|
||||||
bool canSelectionLineColor();
|
bool canSelectionLineColor();
|
||||||
bool canSelectionLineWidth();
|
bool canSelectionLineWidth();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Operations on selections
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
void deleteSelection();
|
void deleteSelection();
|
||||||
void raiseSelectionToTop();
|
void raiseSelectionToTop();
|
||||||
void lowerSelectionToBottom();
|
void lowerSelectionToBottom();
|
||||||
@@ -145,7 +146,7 @@ namespace glabels
|
|||||||
void centerSelectionHoriz();
|
void centerSelectionHoriz();
|
||||||
void centerSelectionVert();
|
void centerSelectionVert();
|
||||||
void moveSelection( double dx, double dy );
|
void moveSelection( double dx, double dy );
|
||||||
void setSelectionFontFamily( const QString &fontFamily );
|
void setSelectionFontFamily( const QString& fontFamily );
|
||||||
void setSelectionFontSize( double fontSize );
|
void setSelectionFontSize( double fontSize );
|
||||||
void setSelectionFontWeight( QFont::Weight fontWeight );
|
void setSelectionFontWeight( QFont::Weight fontWeight );
|
||||||
void setSelectionFontItalicFlag( bool fontItalicFlag );
|
void setSelectionFontItalicFlag( bool fontItalicFlag );
|
||||||
@@ -157,24 +158,130 @@ namespace glabels
|
|||||||
void setSelectionLineColorNode( ColorNode lineColorNode );
|
void setSelectionLineColorNode( ColorNode lineColorNode );
|
||||||
void setSelectionFillColorNode( ColorNode fillColorNode );
|
void setSelectionFillColorNode( ColorNode fillColorNode );
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Slots
|
||||||
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onObjectChanged( LabelModelObject* object );
|
void onObjectChanged( LabelModelObject* object );
|
||||||
void onObjectMoved( LabelModelObject* object );
|
void onObjectMoved( LabelModelObject* object );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private data
|
||||||
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QList<LabelModelObject*> mObjectList;
|
|
||||||
|
|
||||||
bool mModified;
|
bool mModified;
|
||||||
QString mFilename;
|
QString mFilename;
|
||||||
int mCompressionLevel;
|
int mCompressionLevel;
|
||||||
const libglabels::Template* mTmplate;
|
const libglabels::Template* mTmplate;
|
||||||
const libglabels::Frame* mFrame;
|
const libglabels::Frame* mFrame;
|
||||||
bool mRotate;
|
bool mRotate;
|
||||||
|
|
||||||
|
QList<LabelModelObject*> mObjectList;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// INLINE METHODS
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
|
inline bool LabelModel::isModified() const
|
||||||
|
{
|
||||||
|
return mModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void LabelModel::clearModified()
|
||||||
|
{
|
||||||
|
mModified = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QString& LabelModel::filename() const
|
||||||
|
{
|
||||||
|
return mFilename;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void LabelModel::setFilename( const QString &filename )
|
||||||
|
{
|
||||||
|
if ( mFilename != filename )
|
||||||
|
{
|
||||||
|
mFilename = filename;
|
||||||
|
emit nameChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline int LabelModel::compressionLevel() const
|
||||||
|
{
|
||||||
|
return mCompressionLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void LabelModel::setCompressionLevel( int compressionLevel )
|
||||||
|
{
|
||||||
|
mCompressionLevel = compressionLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const libglabels::Template* LabelModel::tmplate() const
|
||||||
|
{
|
||||||
|
return mTmplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void LabelModel::setTmplate( const libglabels::Template* tmplate )
|
||||||
|
{
|
||||||
|
if (mTmplate != tmplate)
|
||||||
|
{
|
||||||
|
mTmplate = tmplate;
|
||||||
|
mFrame = tmplate->frames().first();
|
||||||
|
mModified = true;
|
||||||
|
emit changed();
|
||||||
|
emit sizeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool LabelModel::rotate() const
|
||||||
|
{
|
||||||
|
return mRotate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void LabelModel::setRotate( bool rotate )
|
||||||
|
{
|
||||||
|
if (mRotate != rotate)
|
||||||
|
{
|
||||||
|
mRotate = rotate;
|
||||||
|
mModified = true;
|
||||||
|
emit changed();
|
||||||
|
emit sizeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double LabelModel::w() const
|
||||||
|
{
|
||||||
|
return mRotate ? mFrame->h() : mFrame->w();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline double LabelModel::h() const
|
||||||
|
{
|
||||||
|
return mRotate ? mFrame->w() : mFrame->h();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const QList<LabelModelObject*>& LabelModel::objectList() const
|
||||||
|
{
|
||||||
|
return mObjectList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // glabels_LabelModel_h
|
#endif // glabels_LabelModel_h
|
||||||
|
|||||||
Reference in New Issue
Block a user