From 17d8d0957c741ff2d4498f66411422242be68d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fauconnier?= Date: Tue, 31 Jul 2018 16:32:03 +0200 Subject: [PATCH] changed sortOrder style + resized splitter sizes --- resources/OpenBoard.qrc | 2 + resources/forms/documents.ui | 100 ++++++++++++++++++++------ resources/images/asc.png | Bin 0 -> 309 bytes resources/images/desc.png | Bin 0 -> 301 bytes src/document/UBDocumentController.cpp | 42 ++++------- src/document/UBDocumentController.h | 5 +- 6 files changed, 96 insertions(+), 53 deletions(-) create mode 100644 resources/images/asc.png create mode 100644 resources/images/desc.png diff --git a/resources/OpenBoard.qrc b/resources/OpenBoard.qrc index d67ff3d5..3e41418a 100644 --- a/resources/OpenBoard.qrc +++ b/resources/OpenBoard.qrc @@ -362,5 +362,7 @@ images/backgroundPalette/resetDefaultGridSize.svg images/collapse-all.png images/expand-all.png + images/asc.png + images/desc.png diff --git a/resources/forms/documents.ui b/resources/forms/documents.ui index a81ddaba..efec7a6a 100644 --- a/resources/forms/documents.ui +++ b/resources/forms/documents.ui @@ -62,34 +62,32 @@ - - - - - 2 - 0 - - - - - Ascending order - - - - - Descending order - - - - + + QLayout::SetMinimumSize + - + 4 0 + + + 200 + 16777215 + + + + + + + QComboBox::AdjustToMinimumContentsLength + + + 0 + Creation date @@ -107,6 +105,62 @@ + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + 0 + 0 + + + + Sort Order + + + QToolButton { border-style:none; border-width: 0px;margin-left:2px;margin-right:2px} + + + + + + + :/images/asc.png + :/images/desc.png:/images/asc.png + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -302,6 +356,8 @@
document/UBDocumentController.h
- + + + diff --git a/resources/images/asc.png b/resources/images/asc.png new file mode 100644 index 0000000000000000000000000000000000000000..1b61cce9920ee565e7162b89574734ad5d241eb7 GIT binary patch literal 309 zcmeAS@N?(olHy`uVBq!ia0vp^hCpn}!3HE>@G^rWI14-?iy0WWg+Q3`(%rg0K*8sp zE{-7?jc;de~PsOwPx}ECE0pi zwfYl9<8$8i$((t^^k9nViP@`n+b?<})8yjEka5_6_0gQD{}aQTG9 zy#BlV8%-AOdwylkWZP{sO&MmrI8;>f?%uyyzV=*TGZGwybZ!*z)vkzC+S6G(Wi8KI nsHH#)>Nmf&2>W}L?E_Q6rt4pGYQvrYz0Bb0>gTe~DWM4fmKS-# literal 0 HcmV?d00001 diff --git a/resources/images/desc.png b/resources/images/desc.png new file mode 100644 index 0000000000000000000000000000000000000000..622f2f89f5e2a52924f8ae9503cea1f9634d12f8 GIT binary patch literal 301 zcmeAS@N?(olHy`uVBq!ia0vp^hCpn}!3HE>@G^rWI14-?iy0WWg+Q3`(%rg0K*9T- zE{-7?jc;dcsetSourceModel(model); + // sort documents according to preferences int sortKind = UBSettings::settings()->documentSortKind->get().toInt(); - int sortOrder = UBSettings::settings()->documentSortOrder->get().toInt(); - mUserHasChangedSortOrder = true; + int sortOrder = UBSettings::settings()->documentSortOrder->get().toInt(); + sortDocuments(sortKind, sortOrder); + // update icon and button mDocumentUI->sortKind->setCurrentIndex(sortKind); - mDocumentUI->sortOrder->setCurrentIndex(sortOrder); + if (sortOrder == UBDocumentController::DESC) + mDocumentUI->sortOrder->setChecked(true); mDocumentUI->documentTreeView->setModel(mSortFilterProxyModel); @@ -2002,15 +2003,15 @@ void UBDocumentController::setupViews() //set sizes (left and right sides of the splitter) for the splitter here because it cannot be done in the form editor. const int leftSplitterSize = 100; - const int rightSplitterSize = 900; + const int rightSplitterSize = 1200; QList splitterSizes = { leftSplitterSize, rightSplitterSize }; mDocumentUI->splitter->setSizes(splitterSizes); - mDocumentUI->documentTreeView->hideColumn(1); + //mDocumentUI->documentTreeView->hideColumn(1); mDocumentUI->documentTreeView->hideColumn(2); connect(mDocumentUI->sortKind, SIGNAL(activated(int)), this, SLOT(onSortKindChanged(int))); - connect(mDocumentUI->sortOrder, SIGNAL(activated(int)), this, SLOT(onSortOrderChanged(int))); + connect(mDocumentUI->sortOrder, SIGNAL(toggled(bool)), this, SLOT(onSortOrderChanged(bool))); connect(mDocumentUI->documentTreeView->itemDelegate(), SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint) ), mDocumentUI->documentTreeView, SLOT(adjustSize())); connect(mDocumentUI->documentTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(TreeViewSelectionChanged(QItemSelection,QItemSelection))); @@ -2046,20 +2047,8 @@ void UBDocumentController::setupViews() void UBDocumentController::sortDocuments(int kind, int order) { Qt::SortOrder sortOrder = Qt::AscendingOrder; - - //if the user hasn't change the sort - //set order to its default value according to - //the kind of sort - if(!mUserHasChangedSortOrder){ - if(kind == UBDocumentController::CreationDate || kind == UBDocumentController::UpdateDate){ - sortOrder = Qt::DescendingOrder; - mDocumentUI->sortOrder->setCurrentIndex(1); - }else{ - mDocumentUI->sortOrder->setCurrentIndex(0); - } - }else if(order == UBDocumentController::DESC){ + if(order == UBDocumentController::DESC) sortOrder = Qt::DescendingOrder; - } if(kind == UBDocumentController::CreationDate){ mSortFilterProxyModel->setSortRole(UBDocumentTreeModel::CreationDate); @@ -2073,22 +2062,21 @@ void UBDocumentController::sortDocuments(int kind, int order) } } -void UBDocumentController::onSortOrderChanged(int index) + +void UBDocumentController::onSortOrderChanged(bool order) { int kindIndex = mDocumentUI->sortKind->currentIndex(); + int orderIndex = order ? UBDocumentController::DESC : UBDocumentController::ASC; - mUserHasChangedSortOrder = true; - - sortDocuments(kindIndex, index); + sortDocuments(kindIndex, orderIndex); } void UBDocumentController::onSortKindChanged(int index) { - int orderIndex = mDocumentUI->sortOrder->currentIndex(); + int orderIndex = mDocumentUI->sortOrder->isChecked() ? UBDocumentController::DESC : UBDocumentController::ASC; sortDocuments(index, orderIndex); } -//N/C - NNE - 20140403 : END QWidget* UBDocumentController::controlView() { diff --git a/src/document/UBDocumentController.h b/src/document/UBDocumentController.h index dea703bc..4ac86c0e 100644 --- a/src/document/UBDocumentController.h +++ b/src/document/UBDocumentController.h @@ -445,7 +445,7 @@ class UBDocumentController : public UBDocumentContainer //N/C - NNE - 20140403 void onSortKindChanged(int index); - void onSortOrderChanged(int index); + void onSortOrderChanged(bool order); void collapseAll(); void expandAll(); @@ -488,9 +488,6 @@ protected: UBSortFilterProxyModel *mSortFilterProxyModel; - //N/C - NNE - 20140407 - bool mUserHasChangedSortOrder; - public slots: void TreeViewSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous); void TreeViewSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);