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 00000000..1b61cce9 Binary files /dev/null and b/resources/images/asc.png differ diff --git a/resources/images/desc.png b/resources/images/desc.png new file mode 100644 index 00000000..622f2f89 Binary files /dev/null and b/resources/images/desc.png differ diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index 72544dac..19088c6b 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -1643,8 +1643,6 @@ UBDocumentController::UBDocumentController(UBMainWindow* mainWindow) setupToolbar(); connect(this, SIGNAL(exportDone()), mMainWindow, SLOT(onExportDone())); connect(this, SIGNAL(documentThumbnailsUpdated(UBDocumentContainer*)), this, SLOT(refreshDocumentThumbnailsView(UBDocumentContainer*))); - - mUserHasChangedSortOrder = false; } UBDocumentController::~UBDocumentController() @@ -1980,13 +1978,16 @@ void UBDocumentController::setupViews() mSortFilterProxyModel->setSourceModel(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);