Improved design of category selection in SelectProductDialog.

This commit is contained in:
Jim Evins
2016-04-03 01:01:14 -04:00
parent 9d1fcbaca3
commit 46ef01d4e4
3 changed files with 93 additions and 55 deletions
+18 -27
View File
@@ -39,14 +39,17 @@ SelectProductDialog::SelectProductDialog( QWidget *parent )
pageSizeUsCheck->setChecked( Settings::searchUsPaperSizes() ); pageSizeUsCheck->setChecked( Settings::searchUsPaperSizes() );
pageSizeOtherCheck->setChecked( Settings::searchOtherPaperSizes() ); pageSizeOtherCheck->setChecked( Settings::searchOtherPaperSizes() );
anyCategoryCheck->setChecked( Settings::searchAllCategories() ); allCategoriesRadio->setChecked( Settings::searchAllCategories() );
selectedCategoriesRadio->setChecked( !Settings::searchAllCategories() );
categoriesCheckContainer->setEnabled( !Settings::searchAllCategories() );
mCategoryIdList = Settings::searchCategoryList(); mCategoryIdList = Settings::searchCategoryList();
QList<glabels::Category*> categories = glabels::Db::categories(); QList<glabels::Category*> categories = glabels::Db::categories();
foreach ( glabels::Category *category, categories ) foreach ( glabels::Category *category, categories )
{ {
QCheckBox* check = new QCheckBox( category->name() ); QCheckBox* check = new QCheckBox( category->name() );
check->setChecked( mCategoryIdList.contains( category->id() ) || anyCategoryCheck->isChecked() ); check->setChecked( mCategoryIdList.contains( category->id() ) );
categoriesLayout->addWidget( check ); categoriesLayout->addWidget( check );
mCheckToCategoryMap[check] = category->id(); mCheckToCategoryMap[check] = category->id();
@@ -61,7 +64,7 @@ SelectProductDialog::SelectProductDialog( QWidget *parent )
pageSizeIsoCheck->isChecked(), pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(), pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked(), pageSizeOtherCheck->isChecked(),
anyCategoryCheck->isChecked(), allCategoriesRadio->isChecked(),
mCategoryIdList ); mCategoryIdList );
} }
@@ -90,7 +93,7 @@ void SelectProductDialog::onSearchEntryTextChanged()
pageSizeIsoCheck->isChecked(), pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(), pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked(), pageSizeOtherCheck->isChecked(),
anyCategoryCheck->isChecked(), allCategoriesRadio->isChecked(),
mCategoryIdList ); mCategoryIdList );
} }
@@ -117,32 +120,27 @@ void SelectProductDialog::onPageSizeCheckClicked()
pageSizeIsoCheck->isChecked(), pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(), pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked(), pageSizeOtherCheck->isChecked(),
anyCategoryCheck->isChecked(), allCategoriesRadio->isChecked(),
mCategoryIdList ); mCategoryIdList );
} }
/// ///
/// Any category Check Clicked Slot /// Category Radio Clicked Slot
/// ///
void SelectProductDialog::onAnyCategoryCheckClicked() void SelectProductDialog::onCategoryRadioClicked()
{ {
if ( anyCategoryCheck->isChecked() ) categoriesCheckContainer->setEnabled( selectedCategoriesRadio->isChecked() );
{
foreach( QCheckBox* check, mCheckToCategoryMap.keys() )
{
check->setChecked( true );
}
}
loadCategoryList(); loadCategoryList();
templatePicker->applyFilter( searchEntry->text(), templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoCheck->isChecked(), pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(), pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked(), pageSizeOtherCheck->isChecked(),
anyCategoryCheck->isChecked(), allCategoriesRadio->isChecked(),
mCategoryIdList ); mCategoryIdList );
Settings::setSearchAllCategories( allCategoriesRadio->isChecked() );
} }
@@ -151,21 +149,17 @@ void SelectProductDialog::onAnyCategoryCheckClicked()
/// ///
void SelectProductDialog::onCategoryCheckClicked() void SelectProductDialog::onCategoryCheckClicked()
{ {
bool allFlag = true;
foreach( QCheckBox* check, mCheckToCategoryMap.keys() )
{
allFlag = allFlag && check->isChecked();
}
anyCategoryCheck->setChecked( allFlag );
loadCategoryList(); loadCategoryList();
templatePicker->applyFilter( searchEntry->text(), templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoCheck->isChecked(), pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(), pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked(), pageSizeOtherCheck->isChecked(),
anyCategoryCheck->isChecked(), allCategoriesRadio->isChecked(),
mCategoryIdList ); mCategoryIdList );
Settings::setSearchCategoryList( mCategoryIdList );
} }
@@ -213,7 +207,4 @@ void SelectProductDialog::loadCategoryList()
mCategoryIdList.append( mCheckToCategoryMap[check] ); mCategoryIdList.append( mCheckToCategoryMap[check] );
} }
} }
Settings::setSearchAllCategories( anyCategoryCheck->isChecked() );
Settings::setSearchCategoryList( mCategoryIdList );
} }
+1 -1
View File
@@ -53,7 +53,7 @@ private slots:
void onSearchEntryTextChanged(); void onSearchEntryTextChanged();
void onSearchClearButtonClicked(); void onSearchClearButtonClicked();
void onPageSizeCheckClicked(); void onPageSizeCheckClicked();
void onAnyCategoryCheckClicked(); void onCategoryRadioClicked();
void onCategoryCheckClicked(); void onCategoryCheckClicked();
void onTemplatePickerSelectionChanged(); void onTemplatePickerSelectionChanged();
void onCancelButtonClicked(); void onCancelButtonClicked();
+67 -20
View File
@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>967</width> <width>987</width>
<height>660</height> <height>661</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -34,6 +34,12 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
<property name="placeholderText"> <property name="placeholderText">
<string>Search</string> <string>Search</string>
</property> </property>
@@ -94,6 +100,9 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>3</number>
</property>
<item> <item>
<widget class="QCheckBox" name="pageSizeIsoCheck"> <widget class="QCheckBox" name="pageSizeIsoCheck">
<property name="text"> <property name="text">
@@ -123,27 +132,49 @@
<property name="title"> <property name="title">
<string>Filter by category</string> <string>Filter by category</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item row="1" column="0" rowspan="2"> <property name="spacing">
<layout class="QVBoxLayout" name="categoriesLayout"> <number>3</number>
<item>
<widget class="QCheckBox" name="anyCategoryCheck">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property> </property>
<item>
<widget class="QRadioButton" name="allCategoriesRadio">
<property name="text"> <property name="text">
<string>All categories</string> <string>All</string>
</property> </property>
</widget> </widget>
</item> </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> </layout>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
@@ -320,18 +351,34 @@
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>anyCategoryCheck</sender> <sender>allCategoriesRadio</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>SelectProductDialog</receiver> <receiver>SelectProductDialog</receiver>
<slot>onAnyCategoryCheckClicked()</slot> <slot>onCategoryRadioClicked()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>31</x> <x>36</x>
<y>234</y> <y>226</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>-7</x> <x>-5</x>
<y>240</y> <y>223</y>
</hint>
</hints>
</connection>
<connection>
<sender>selectedCategoriesRadio</sender>
<signal>clicked()</signal>
<receiver>SelectProductDialog</receiver>
<slot>onCategoryRadioClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>32</x>
<y>246</y>
</hint>
<hint type="destinationlabel">
<x>1</x>
<y>252</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@@ -344,6 +391,6 @@
<slot>onCancelButtonClicked()</slot> <slot>onCancelButtonClicked()</slot>
<slot>onSelectButtonClicked()</slot> <slot>onSelectButtonClicked()</slot>
<slot>onPageSizeCheckClicked()</slot> <slot>onPageSizeCheckClicked()</slot>
<slot>onAnyCategoryCheckClicked()</slot> <slot>onCategoryRadioClicked()</slot>
</slots> </slots>
</ui> </ui>