1 /* 2 SPDX-FileCopyrightText: 2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net> 3 SPDX-License-Identifier: GPL-2.0-or-later 4 */ 5 #include "vocabularyheaderview.h" 6 7 using namespace Editor; 8 VocabularyHeaderView(Qt::Orientation orientation,QWidget * parent)9VocabularyHeaderView::VocabularyHeaderView(Qt::Orientation orientation, QWidget *parent) 10 : QHeaderView(orientation, parent) 11 { 12 setSectionsClickable(true); 13 connect(this, &VocabularyHeaderView::sectionClicked, this, &VocabularyHeaderView::updateSorting); 14 } 15 updateSorting(int index)16void VocabularyHeaderView::updateSorting(int index) 17 { 18 if (m_sortSection != index) { 19 setSortIndicatorShown(true); 20 setSortIndicator(index, Qt::AscendingOrder); 21 m_sortSection = index; 22 return; 23 } 24 25 if (sortIndicatorOrder() == Qt::DescendingOrder) { 26 setSortIndicatorShown(true); 27 setSortIndicator(index, Qt::DescendingOrder); 28 return; 29 } 30 31 if (!isSortIndicatorShown()) { 32 setSortIndicatorShown(true); 33 setSortIndicator(index, Qt::AscendingOrder); 34 return; 35 } 36 37 setSortIndicatorShown(false); 38 m_sortSection = -1; 39 model()->sort(-1); 40 } 41