Added recently-used products tab to SelectProductDialog.

This commit is contained in:
Jim Evins
2016-04-03 18:42:01 -04:00
parent 46ef01d4e4
commit 50e52d6675
8 changed files with 371 additions and 193 deletions
+3
View File
@@ -27,6 +27,7 @@
#include "MergeRecord.h"
#include "libglabels/Template.h"
#include "Settings.h"
// Forward References
@@ -265,6 +266,8 @@ inline void LabelModel::setTmplate( const glabels::Template* tmplate )
mModified = true;
emit changed();
emit sizeChanged();
Settings::addToRecentTemplateList( tmplate->name() );
}
}
+32 -6
View File
@@ -60,12 +60,12 @@ SelectProductDialog::SelectProductDialog( QWidget *parent )
QList<glabels::Template*> tmplates = glabels::Db::templates();
templatePicker->setTemplates( tmplates );
templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked(),
allCategoriesRadio->isChecked(),
mCategoryIdList );
if ( Settings::recentTemplateList().count() > 0 )
{
modeNotebook->setCurrentIndex(1);
}
onModeTabChanged();
}
///
@@ -84,6 +84,32 @@ const glabels::Template* SelectProductDialog::tmplate() const
}
///
/// Mode Notebook Tab Changed Slot
///
void SelectProductDialog::onModeTabChanged()
{
switch (modeNotebook->currentIndex())
{
case 0:
// Search Tab
templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked(),
allCategoriesRadio->isChecked(),
mCategoryIdList );
break;
case 1:
// Recent Tab
templatePicker->applyFilter( Settings::recentTemplateList() );
break;
default:
qDebug() << "onModeTabChanged(): unknown tab!";
}
}
///
/// Search Entry Text Changed Slot
///
+1
View File
@@ -50,6 +50,7 @@ public:
// Slots
/////////////////////////////////
private slots:
void onModeTabChanged();
void onSearchEntryTextChanged();
void onSearchClearButtonClicked();
void onPageSizeCheckClicked();
+33
View File
@@ -217,3 +217,36 @@ void Settings::setSearchCategoryList( const QStringList& searchCategoryList )
emit mInstance->changed();
}
QStringList Settings::recentTemplateList()
{
QStringList defaultList;
mInstance->beginGroup( "Recent" );
QStringList returnList = mInstance->value( "templateList", defaultList ).toStringList();
mInstance->endGroup();
return returnList;
}
void Settings::addToRecentTemplateList( const QString& name )
{
mInstance->beginGroup( "Recent" );
QStringList list = mInstance->value( "templateList" ).toStringList();
list.removeAll( name );
list.prepend( name );
while ( list.count() > 10 )
{
list.removeLast();
}
mInstance->setValue( "templateList", list );
mInstance->endGroup();
emit mInstance->changed();
}
+3
View File
@@ -78,6 +78,9 @@ public:
static QStringList searchCategoryList();
static void setSearchCategoryList( const QStringList& searchCategoryList );
static QStringList recentTemplateList();
static void addToRecentTemplateList( const QString& name );
private:
static Settings* mInstance;
+34 -2
View File
@@ -52,9 +52,9 @@ void TemplatePicker::setTemplates( const QList <glabels::Template*> &tmplates )
///
/// Apply Filter to Narrow Template Choices
/// Apply Filter to Narrow Template Choices by search criteria
///
void TemplatePicker::applyFilter( const QString &searchString,
void TemplatePicker::applyFilter( const QString& searchString,
bool isoMask, bool usMask, bool otherMask,
bool anyCategory, const QStringList& categoryIds )
{
@@ -97,6 +97,38 @@ void TemplatePicker::applyFilter( const QString &searchString,
}
///
/// Apply Filter to Narrow Template Choices by a list of names
///
void TemplatePicker::applyFilter( const QStringList& names )
{
foreach ( QListWidgetItem *item, findItems( "*", Qt::MatchWildcard ) )
{
TemplatePickerItem *tItem = dynamic_cast<TemplatePickerItem *>(item);
bool match = false;
foreach ( QString name, names )
{
if ( tItem->tmplate()->name() == name )
{
match = true;
break;
}
}
if ( match )
{
item->setHidden( false );
}
else
{
item->setHidden( true );
item->setSelected( false );
}
}
}
///
/// Get Currently Selected Template
///
+3 -1
View File
@@ -53,10 +53,12 @@ public:
/////////////////////////////////
// Methods
/////////////////////////////////
void applyFilter( const QString &searchString,
void applyFilter( const QString& searchString,
bool isoMask, bool usMask, bool otherMask,
bool anyCategory, const QStringList& categoryIds );
void applyFilter( const QStringList& names );
const glabels::Template *selectedTemplate();
};
+262 -184
View File
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>987</width>
<width>997</width>
<height>661</height>
</rect>
</property>
@@ -19,176 +19,237 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Search</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLineEdit" name="searchEntry">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
<property name="placeholderText">
<string>Search</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="searchClearButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/16x16/actions/edit-clear.png</normaloff>:/icons/16x16/actions/edit-clear.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>146</width>
<height>87</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="title">
<string>Filter by paper size</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QCheckBox" name="pageSizeIsoCheck">
<property name="text">
<string>ISO sizes</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="pageSizeUsCheck">
<property name="text">
<string>US sizes</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="pageSizeOtherCheck">
<property name="text">
<string>Other</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Filter by category</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QRadioButton" name="allCategoriesRadio">
<property name="text">
<string>All</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="selectedCategoriesRadio">
<property name="text">
<string>Selected</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="categoriesCheckContainer" native="true">
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
<widget class="QTabWidget" name="modeNotebook">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="search">
<attribute name="title">
<string>Search all</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<number>6</number>
</property>
<property name="spacing">
<number>0</number>
<property name="bottomMargin">
<number>6</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="categoriesLayout">
<property name="spacing">
<number>3</number>
<item>
<widget class="QLineEdit" name="searchEntry">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="leftMargin">
<number>20</number>
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
</layout>
<property name="placeholderText">
<string>Search</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="searchClearButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/16x16/actions/edit-clear.png</normaloff>:/icons/16x16/actions/edit-clear.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>146</width>
<height>87</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="title">
<string>Filter by paper size</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QCheckBox" name="pageSizeIsoCheck">
<property name="text">
<string>ISO sizes</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="pageSizeUsCheck">
<property name="text">
<string>US sizes</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="pageSizeOtherCheck">
<property name="text">
<string>Other</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Filter by category</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QRadioButton" name="allCategoriesRadio">
<property name="text">
<string>All</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="selectedCategoriesRadio">
<property name="text">
<string>Selected</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="categoriesCheckContainer" native="true">
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="categoriesLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>20</number>
</property>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Search entire product database.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="recent">
<attribute name="title">
<string>Recent</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Select from recently used products.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="TemplatePicker" name="templatePicker">
@@ -245,8 +306,8 @@
<slot>onPageSizeCheckClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>35</x>
<y>169</y>
<x>75</x>
<y>207</y>
</hint>
<hint type="destinationlabel">
<x>8</x>
@@ -261,8 +322,8 @@
<slot>onPageSizeCheckClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>38</x>
<y>144</y>
<x>78</x>
<y>184</y>
</hint>
<hint type="destinationlabel">
<x>4</x>
@@ -277,12 +338,12 @@
<slot>onTemplatePickerSelectionChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>232</x>
<y>550</y>
<x>483</x>
<y>561</y>
</hint>
<hint type="destinationlabel">
<x>244</x>
<y>697</y>
<y>660</y>
</hint>
</hints>
</connection>
@@ -293,8 +354,8 @@
<slot>onPageSizeCheckClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>40</x>
<y>112</y>
<x>80</x>
<y>161</y>
</hint>
<hint type="destinationlabel">
<x>2</x>
@@ -314,7 +375,7 @@
</hint>
<hint type="destinationlabel">
<x>689</x>
<y>704</y>
<y>660</y>
</hint>
</hints>
</connection>
@@ -325,8 +386,8 @@
<slot>onSearchClearButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>177</x>
<y>52</y>
<x>231</x>
<y>103</y>
</hint>
<hint type="destinationlabel">
<x>190</x>
@@ -341,8 +402,8 @@
<slot>onSearchEntryTextChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>69</x>
<y>48</y>
<x>93</x>
<y>104</y>
</hint>
<hint type="destinationlabel">
<x>2</x>
@@ -357,11 +418,11 @@
<slot>onCategoryRadioClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>36</x>
<y>226</y>
<x>76</x>
<y>270</y>
</hint>
<hint type="destinationlabel">
<x>-5</x>
<x>0</x>
<y>223</y>
</hint>
</hints>
@@ -373,8 +434,8 @@
<slot>onCategoryRadioClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>32</x>
<y>246</y>
<x>72</x>
<y>294</y>
</hint>
<hint type="destinationlabel">
<x>1</x>
@@ -382,6 +443,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>modeNotebook</sender>
<signal>currentChanged(int)</signal>
<receiver>SelectProductDialog</receiver>
<slot>onModeTabChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>59</x>
<y>25</y>
</hint>
<hint type="destinationlabel">
<x>4</x>
<y>26</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>onSearchClearButtonClicked()</slot>
@@ -392,5 +469,6 @@
<slot>onSelectButtonClicked()</slot>
<slot>onPageSizeCheckClicked()</slot>
<slot>onCategoryRadioClicked()</slot>
<slot>onModeTabChanged()</slot>
</slots>
</ui>