Added simple page size filtering.

This commit is contained in:
Jim Evins
2013-11-13 00:04:00 -05:00
parent 5ce9121801
commit 1c02315db9
7 changed files with 77 additions and 17 deletions
+29 -1
View File
@@ -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() );
}
}
}
+1
View File
@@ -36,6 +36,7 @@ namespace gLabels
private slots:
void searchEntryTextChanged( const QString &text );
void pageSizeRadioToggled( bool checked );
};
+7 -3
View File
@@ -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 );
+1 -1
View File
@@ -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: