Added simple page size filtering.
This commit is contained in:
+29
-1
@@ -30,17 +30,45 @@ namespace gLabels
|
||||
{
|
||||
setupUi( this );
|
||||
|
||||
// TODO: Set default based on locale
|
||||
pageSizeIsoRadio->setChecked( true );
|
||||
|
||||
QList<libglabels::Template*> tmplates = libglabels::Db::templates();
|
||||
templatePicker->setTemplates( tmplates );
|
||||
|
||||
templatePicker->applyFilter( searchEntry->text(),
|
||||
pageSizeIsoRadio->isChecked(),
|
||||
pageSizeUsRadio->isChecked(),
|
||||
pageSizeOtherRadio->isChecked() );
|
||||
|
||||
connect( searchEntry, SIGNAL(textChanged(const QString &)),
|
||||
this, SLOT(searchEntryTextChanged(const QString &)) );
|
||||
|
||||
connect( pageSizeIsoRadio, SIGNAL(toggled(bool)), this, SLOT(pageSizeRadioToggled(bool)) );
|
||||
connect( pageSizeUsRadio, SIGNAL(toggled(bool)), this, SLOT(pageSizeRadioToggled(bool)) );
|
||||
connect( pageSizeOtherRadio, SIGNAL(toggled(bool)), this, SLOT(pageSizeRadioToggled(bool)) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void NewLabelDialog::searchEntryTextChanged( const QString &text )
|
||||
{
|
||||
templatePicker->applyFilter( text );
|
||||
templatePicker->applyFilter( text,
|
||||
pageSizeIsoRadio->isChecked(),
|
||||
pageSizeUsRadio->isChecked(),
|
||||
pageSizeOtherRadio->isChecked() );
|
||||
}
|
||||
|
||||
|
||||
void NewLabelDialog::pageSizeRadioToggled( bool checked )
|
||||
{
|
||||
if ( checked )
|
||||
{
|
||||
templatePicker->applyFilter( searchEntry->text(),
|
||||
pageSizeIsoRadio->isChecked(),
|
||||
pageSizeUsRadio->isChecked(),
|
||||
pageSizeOtherRadio->isChecked() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace gLabels
|
||||
|
||||
private slots:
|
||||
void searchEntryTextChanged( const QString &text );
|
||||
void pageSizeRadioToggled( bool checked );
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -48,13 +48,17 @@ namespace gLabels
|
||||
}
|
||||
|
||||
|
||||
void TemplatePicker::applyFilter( const QString &searchString )
|
||||
void TemplatePicker::applyFilter( const QString &searchString,
|
||||
bool isoMask, bool usMask, bool otherMask )
|
||||
{
|
||||
foreach ( QListWidgetItem *item, findItems( "*", Qt::MatchWildcard ) )
|
||||
{
|
||||
TemplatePickerItem *tPitem = dynamic_cast<TemplatePickerItem *>(item);
|
||||
TemplatePickerItem *tItem = dynamic_cast<TemplatePickerItem *>(item);
|
||||
|
||||
if ( tPitem->tmplate()->name().contains( searchString, Qt::CaseInsensitive ) )
|
||||
if ( tItem->tmplate()->name().contains( searchString, Qt::CaseInsensitive ) &&
|
||||
(isoMask == tItem->tmplate()->isSizeIso()) &&
|
||||
(usMask == tItem->tmplate()->isSizeUs()) &&
|
||||
(otherMask == tItem->tmplate()->isSizeOther()) )
|
||||
{
|
||||
item->setHidden( false );
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace gLabels
|
||||
|
||||
void setTemplates( const QList <libglabels::Template*> &tmplates );
|
||||
|
||||
void applyFilter( const QString &searchString );
|
||||
void applyFilter( const QString &searchString, bool isoMask, bool usMask, bool otherMask );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -52,6 +52,9 @@ namespace libglabels
|
||||
/* PWG 5101.1-2002 size name */
|
||||
inline QString pwgSize() const { return mPwgSize; }
|
||||
|
||||
inline bool isSizeIso() const { return mPwgSize.startsWith( "iso_" ); }
|
||||
inline bool isSizeUs() const { return mPwgSize.startsWith( "na_" ); }
|
||||
|
||||
private:
|
||||
QString mId;
|
||||
QString mName;
|
||||
|
||||
@@ -28,6 +28,33 @@
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
Template::Template( const QString &brand,
|
||||
const QString &part,
|
||||
const QString &description,
|
||||
const QString &paperId,
|
||||
double pageWidth = 0,
|
||||
double pageHeight = 0 )
|
||||
: mBrand(brand),
|
||||
mPart(part),
|
||||
mDescription(description),
|
||||
mPaperId(paperId),
|
||||
mPageWidth(pageWidth),
|
||||
mPageHeight(pageHeight),
|
||||
mIsSizeIso(false),
|
||||
mIsSizeUs(false),
|
||||
mName("")
|
||||
{
|
||||
mName.append( brand ).append( " " ).append( part );
|
||||
|
||||
if ( Db::isPaperIdKnown( paperId ) )
|
||||
{
|
||||
const Paper *paper = Db::lookupPaperFromId( paperId );
|
||||
mIsSizeIso = paper->isSizeIso();
|
||||
mIsSizeUs = paper->isSizeUs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Template::Template( const Template &other )
|
||||
{
|
||||
mBrand = other.mBrand;
|
||||
@@ -36,6 +63,8 @@ namespace libglabels
|
||||
mPaperId = other.mPaperId;
|
||||
mPageWidth = other.mPageWidth;
|
||||
mPageHeight = other.mPageHeight;
|
||||
mIsSizeIso = other.mIsSizeIso;
|
||||
mIsSizeUs = other.mIsSizeUs;
|
||||
mEquivPart = other.mEquivPart;
|
||||
mName = other.mName;
|
||||
mProductUrl = other.mProductUrl;
|
||||
|
||||
+7
-12
@@ -50,18 +50,8 @@ namespace libglabels
|
||||
const QString &part,
|
||||
const QString &description,
|
||||
const QString &paperId,
|
||||
double pageWidth = 0,
|
||||
double pageHeight = 0 )
|
||||
: mBrand(brand),
|
||||
mPart(part),
|
||||
mDescription(description),
|
||||
mPaperId(paperId),
|
||||
mPageWidth(pageWidth),
|
||||
mPageHeight(pageHeight),
|
||||
mName("")
|
||||
{
|
||||
mName.append( brand ).append( " " ).append( part );
|
||||
}
|
||||
double pageWidth,
|
||||
double pageHeight );
|
||||
|
||||
Template( const Template &other );
|
||||
|
||||
@@ -84,6 +74,9 @@ namespace libglabels
|
||||
inline const QString &paperId() const { return mPaperId; }
|
||||
inline double pageWidth() const { return mPageWidth; }
|
||||
inline double pageHeight() const { return mPageHeight; }
|
||||
inline bool isSizeIso() const { return mIsSizeIso; }
|
||||
inline bool isSizeUs() const { return mIsSizeUs; }
|
||||
inline bool isSizeOther() const { return !mIsSizeIso && !mIsSizeUs; }
|
||||
|
||||
inline const QString &equivPart() const { return mEquivPart; }
|
||||
inline void setEquivPart( const QString &value ) { mEquivPart = value; }
|
||||
@@ -115,6 +108,8 @@ namespace libglabels
|
||||
QString mPaperId;
|
||||
double mPageWidth;
|
||||
double mPageHeight;
|
||||
bool mIsSizeIso;
|
||||
bool mIsSizeUs;
|
||||
|
||||
QString mEquivPart;
|
||||
QString mName;
|
||||
|
||||
Reference in New Issue
Block a user