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:
|
||||
|
||||
Reference in New Issue
Block a user