Added similar list to NewLabelDialog.

This commit is contained in:
Jim Evins
2013-11-15 21:58:28 -05:00
parent 932ab5b65b
commit 1f5e555e00
6 changed files with 58 additions and 9 deletions
+26
View File
@@ -411,6 +411,32 @@ namespace libglabels
}
QStringList Db::getNameListOfSimilarTemplates( const QString &name )
{
QStringList list;
const Template *tmplate1 = lookupTemplateFromName( name );
if ( tmplate1 == NULL )
{
qDebug( "Unknown template name: \"%s\".", qPrintable(name) );
return list;
}
foreach (const Template *tmplate2, mTemplates )
{
if ( tmplate1->name() != tmplate2->name() )
{
if ( tmplate1->isSimilarTo( tmplate2 ) )
{
list << tmplate2->name();
}
}
}
return list;
}
void Db::registerUserTemplate( Template *templat )
{
// TODO
+1
View File
@@ -86,6 +86,7 @@ namespace libglabels
static const Template *lookupTemplateFromName( const QString &name );
static const Template *lookupTemplateFromBrandPart( const QString &brand, const QString &part );
static bool isTemplateKnown( const QString &brand, const QString &part );
static QStringList getNameListOfSimilarTemplates( const QString &name );
static void registerUserTemplate( Template *tmplate );
static void deleteUserTemplateByName( const QString &name );
+5 -5
View File
@@ -156,19 +156,19 @@ namespace libglabels
}
bool Template::isSimilarTo( const Template &other ) const
bool Template::isSimilarTo( const Template *other ) const
{
// Does page size match?
if ( (mPaperId != other.mPaperId) ||
(mPageWidth != other.mPageWidth ) ||
(mPageHeight != other.mPageHeight ) )
if ( (mPaperId != other->mPaperId) ||
(mPageWidth != other->mPageWidth ) ||
(mPageHeight != other->mPageHeight ) )
{
return false;
}
// Are frames similar
Frame *frame1 = mFrames.first();
Frame *frame2 = other.mFrames.first();
Frame *frame2 = other->mFrames.first();
if ( !frame1->isSimilarTo( frame2 ) )
{
return false;
+1 -1
View File
@@ -97,7 +97,7 @@ namespace libglabels
bool operator==( const Template &other ) const;
bool hasCategory( const QString &categoryId ) const;
bool isSimilarTo( const Template &other ) const;
bool isSimilarTo( const Template *other ) const;
private: