Added similar list to NewLabelDialog.
This commit is contained in:
@@ -42,6 +42,9 @@ namespace gLabels
|
|||||||
pageSizeUsRadio->isChecked(),
|
pageSizeUsRadio->isChecked(),
|
||||||
pageSizeOtherRadio->isChecked() );
|
pageSizeOtherRadio->isChecked() );
|
||||||
|
|
||||||
|
similarBrowser->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
similarBrowser->viewport()->setAutoFillBackground(false);
|
||||||
|
|
||||||
connect( searchEntry, SIGNAL(textChanged(const QString &)),
|
connect( searchEntry, SIGNAL(textChanged(const QString &)),
|
||||||
this, SLOT(searchEntryTextChanged(const QString &)) );
|
this, SLOT(searchEntryTextChanged(const QString &)) );
|
||||||
|
|
||||||
@@ -123,6 +126,25 @@ namespace gLabels
|
|||||||
|
|
||||||
QString layoutString = frame->layoutDescription();
|
QString layoutString = frame->layoutDescription();
|
||||||
layoutLabel->setText( layoutString );
|
layoutLabel->setText( layoutString );
|
||||||
|
|
||||||
|
QStringList list = libglabels::Db::getNameListOfSimilarTemplates( tmplate->name() );
|
||||||
|
if ( list.isEmpty() )
|
||||||
|
{
|
||||||
|
similarLabel->hide();
|
||||||
|
similarBrowser->hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
similarLabel->show();
|
||||||
|
similarBrowser->show();
|
||||||
|
|
||||||
|
QString similarListString;
|
||||||
|
foreach ( QString name, list )
|
||||||
|
{
|
||||||
|
similarListString += name + "\n";
|
||||||
|
}
|
||||||
|
similarBrowser->setText( similarListString );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -245,9 +245,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="label_13">
|
<widget class="QLabel" name="similarLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Similar products:</string>
|
<string>Similar to:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -261,7 +261,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>180</width>
|
<width>150</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -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 )
|
void Db::registerUserTemplate( Template *templat )
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ namespace libglabels
|
|||||||
static const Template *lookupTemplateFromName( const QString &name );
|
static const Template *lookupTemplateFromName( const QString &name );
|
||||||
static const Template *lookupTemplateFromBrandPart( const QString &brand, const QString &part );
|
static const Template *lookupTemplateFromBrandPart( const QString &brand, const QString &part );
|
||||||
static bool isTemplateKnown( 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 registerUserTemplate( Template *tmplate );
|
||||||
static void deleteUserTemplateByName( const QString &name );
|
static void deleteUserTemplateByName( const QString &name );
|
||||||
|
|||||||
@@ -156,19 +156,19 @@ namespace libglabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Template::isSimilarTo( const Template &other ) const
|
bool Template::isSimilarTo( const Template *other ) const
|
||||||
{
|
{
|
||||||
// Does page size match?
|
// Does page size match?
|
||||||
if ( (mPaperId != other.mPaperId) ||
|
if ( (mPaperId != other->mPaperId) ||
|
||||||
(mPageWidth != other.mPageWidth ) ||
|
(mPageWidth != other->mPageWidth ) ||
|
||||||
(mPageHeight != other.mPageHeight ) )
|
(mPageHeight != other->mPageHeight ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are frames similar
|
// Are frames similar
|
||||||
Frame *frame1 = mFrames.first();
|
Frame *frame1 = mFrames.first();
|
||||||
Frame *frame2 = other.mFrames.first();
|
Frame *frame2 = other->mFrames.first();
|
||||||
if ( !frame1->isSimilarTo( frame2 ) )
|
if ( !frame1->isSimilarTo( frame2 ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ namespace libglabels
|
|||||||
bool operator==( const Template &other ) const;
|
bool operator==( const Template &other ) const;
|
||||||
|
|
||||||
bool hasCategory( const QString &categoryId ) const;
|
bool hasCategory( const QString &categoryId ) const;
|
||||||
bool isSimilarTo( const Template &other ) const;
|
bool isSimilarTo( const Template *other ) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user