changed sortOrder style + resized splitter sizes

preferencesAboutTextFull
Clément Fauconnier 6 years ago
parent 34d5b3b526
commit 17d8d0957c
  1. 2
      resources/OpenBoard.qrc
  2. 100
      resources/forms/documents.ui
  3. BIN
      resources/images/asc.png
  4. BIN
      resources/images/desc.png
  5. 42
      src/document/UBDocumentController.cpp
  6. 5
      src/document/UBDocumentController.h

@ -362,5 +362,7 @@
<file>images/backgroundPalette/resetDefaultGridSize.svg</file>
<file>images/collapse-all.png</file>
<file>images/expand-all.png</file>
<file>images/asc.png</file>
<file>images/desc.png</file>
</qresource>
</RCC>

@ -62,34 +62,32 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="sortOrder">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Ascending order</string>
</property>
</item>
<item>
<property name="text">
<string>Descending order</string>
</property>
</item>
</widget>
</item>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<widget class="QComboBox" name="sortKind">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
</property>
<property name="minimumContentsLength">
<number>0</number>
</property>
<item>
<property name="text">
<string>Creation date</string>
@ -107,6 +105,62 @@
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="sortOrder">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Sort Order</string>
</property>
<property name="styleSheet">
<string notr="true">QToolButton { border-style:none; border-width: 0px;margin-left:2px;margin-right:2px}</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/asc.png</normaloff>
<normalon>:/images/desc.png</normalon>:/images/asc.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
@ -302,6 +356,8 @@
<header>document/UBDocumentController.h</header>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../OpenBoard.qrc"/>
</resources>
<connections/>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

@ -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<int> 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()
{

@ -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 &current, const QModelIndex &previous);
void TreeViewSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);

Loading…
Cancel
Save