Added recently-used products tab to SelectProductDialog.
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "MergeRecord.h"
|
#include "MergeRecord.h"
|
||||||
#include "libglabels/Template.h"
|
#include "libglabels/Template.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
|
|
||||||
// Forward References
|
// Forward References
|
||||||
@@ -265,6 +266,8 @@ inline void LabelModel::setTmplate( const glabels::Template* tmplate )
|
|||||||
mModified = true;
|
mModified = true;
|
||||||
emit changed();
|
emit changed();
|
||||||
emit sizeChanged();
|
emit sizeChanged();
|
||||||
|
|
||||||
|
Settings::addToRecentTemplateList( tmplate->name() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,12 +60,12 @@ SelectProductDialog::SelectProductDialog( QWidget *parent )
|
|||||||
QList<glabels::Template*> tmplates = glabels::Db::templates();
|
QList<glabels::Template*> tmplates = glabels::Db::templates();
|
||||||
templatePicker->setTemplates( tmplates );
|
templatePicker->setTemplates( tmplates );
|
||||||
|
|
||||||
templatePicker->applyFilter( searchEntry->text(),
|
if ( Settings::recentTemplateList().count() > 0 )
|
||||||
pageSizeIsoCheck->isChecked(),
|
{
|
||||||
pageSizeUsCheck->isChecked(),
|
modeNotebook->setCurrentIndex(1);
|
||||||
pageSizeOtherCheck->isChecked(),
|
}
|
||||||
allCategoriesRadio->isChecked(),
|
|
||||||
mCategoryIdList );
|
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
|
/// Search Entry Text Changed Slot
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public:
|
|||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
|
void onModeTabChanged();
|
||||||
void onSearchEntryTextChanged();
|
void onSearchEntryTextChanged();
|
||||||
void onSearchClearButtonClicked();
|
void onSearchClearButtonClicked();
|
||||||
void onPageSizeCheckClicked();
|
void onPageSizeCheckClicked();
|
||||||
|
|||||||
@@ -217,3 +217,36 @@ void Settings::setSearchCategoryList( const QStringList& searchCategoryList )
|
|||||||
|
|
||||||
emit mInstance->changed();
|
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();
|
||||||
|
}
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ public:
|
|||||||
static QStringList searchCategoryList();
|
static QStringList searchCategoryList();
|
||||||
static void setSearchCategoryList( const QStringList& searchCategoryList );
|
static void setSearchCategoryList( const QStringList& searchCategoryList );
|
||||||
|
|
||||||
|
static QStringList recentTemplateList();
|
||||||
|
static void addToRecentTemplateList( const QString& name );
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Settings* mInstance;
|
static Settings* mInstance;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ 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 isoMask, bool usMask, bool otherMask,
|
||||||
@@ -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
|
/// Get Currently Selected Template
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ public:
|
|||||||
bool isoMask, bool usMask, bool otherMask,
|
bool isoMask, bool usMask, bool otherMask,
|
||||||
bool anyCategory, const QStringList& categoryIds );
|
bool anyCategory, const QStringList& categoryIds );
|
||||||
|
|
||||||
|
void applyFilter( const QStringList& names );
|
||||||
|
|
||||||
const glabels::Template *selectedTemplate();
|
const glabels::Template *selectedTemplate();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>987</width>
|
<width>997</width>
|
||||||
<height>661</height>
|
<height>661</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -19,13 +19,31 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
|
<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">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="title">
|
<property name="topMargin">
|
||||||
<string>Search</string>
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="searchEntry">
|
<widget class="QLineEdit" name="searchEntry">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -66,7 +84,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
@@ -175,7 +192,9 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
<spacer name="verticalSpacer_2">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@@ -188,7 +207,49 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</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>
|
</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>
|
||||||
<item>
|
<item>
|
||||||
<widget class="TemplatePicker" name="templatePicker">
|
<widget class="TemplatePicker" name="templatePicker">
|
||||||
@@ -245,8 +306,8 @@
|
|||||||
<slot>onPageSizeCheckClicked()</slot>
|
<slot>onPageSizeCheckClicked()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>35</x>
|
<x>75</x>
|
||||||
<y>169</y>
|
<y>207</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>8</x>
|
<x>8</x>
|
||||||
@@ -261,8 +322,8 @@
|
|||||||
<slot>onPageSizeCheckClicked()</slot>
|
<slot>onPageSizeCheckClicked()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>38</x>
|
<x>78</x>
|
||||||
<y>144</y>
|
<y>184</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>4</x>
|
<x>4</x>
|
||||||
@@ -277,12 +338,12 @@
|
|||||||
<slot>onTemplatePickerSelectionChanged()</slot>
|
<slot>onTemplatePickerSelectionChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>232</x>
|
<x>483</x>
|
||||||
<y>550</y>
|
<y>561</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>244</x>
|
<x>244</x>
|
||||||
<y>697</y>
|
<y>660</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@@ -293,8 +354,8 @@
|
|||||||
<slot>onPageSizeCheckClicked()</slot>
|
<slot>onPageSizeCheckClicked()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>40</x>
|
<x>80</x>
|
||||||
<y>112</y>
|
<y>161</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>2</x>
|
<x>2</x>
|
||||||
@@ -314,7 +375,7 @@
|
|||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>689</x>
|
<x>689</x>
|
||||||
<y>704</y>
|
<y>660</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@@ -325,8 +386,8 @@
|
|||||||
<slot>onSearchClearButtonClicked()</slot>
|
<slot>onSearchClearButtonClicked()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>177</x>
|
<x>231</x>
|
||||||
<y>52</y>
|
<y>103</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>190</x>
|
<x>190</x>
|
||||||
@@ -341,8 +402,8 @@
|
|||||||
<slot>onSearchEntryTextChanged()</slot>
|
<slot>onSearchEntryTextChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>69</x>
|
<x>93</x>
|
||||||
<y>48</y>
|
<y>104</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>2</x>
|
<x>2</x>
|
||||||
@@ -357,11 +418,11 @@
|
|||||||
<slot>onCategoryRadioClicked()</slot>
|
<slot>onCategoryRadioClicked()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>36</x>
|
<x>76</x>
|
||||||
<y>226</y>
|
<y>270</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>-5</x>
|
<x>0</x>
|
||||||
<y>223</y>
|
<y>223</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
@@ -373,8 +434,8 @@
|
|||||||
<slot>onCategoryRadioClicked()</slot>
|
<slot>onCategoryRadioClicked()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>32</x>
|
<x>72</x>
|
||||||
<y>246</y>
|
<y>294</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>1</x>
|
<x>1</x>
|
||||||
@@ -382,6 +443,22 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</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>
|
</connections>
|
||||||
<slots>
|
<slots>
|
||||||
<slot>onSearchClearButtonClicked()</slot>
|
<slot>onSearchClearButtonClicked()</slot>
|
||||||
@@ -392,5 +469,6 @@
|
|||||||
<slot>onSelectButtonClicked()</slot>
|
<slot>onSelectButtonClicked()</slot>
|
||||||
<slot>onPageSizeCheckClicked()</slot>
|
<slot>onPageSizeCheckClicked()</slot>
|
||||||
<slot>onCategoryRadioClicked()</slot>
|
<slot>onCategoryRadioClicked()</slot>
|
||||||
|
<slot>onModeTabChanged()</slot>
|
||||||
</slots>
|
</slots>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user