File indexing completed on 2024-12-08 03:36:49
0001 /* 0002 SPDX-FileCopyrightText: 2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 #include "vocabularyheaderview.h" 0006 0007 using namespace Editor; 0008 0009 VocabularyHeaderView::VocabularyHeaderView(Qt::Orientation orientation, QWidget *parent) 0010 : QHeaderView(orientation, parent) 0011 { 0012 setSectionsClickable(true); 0013 connect(this, &VocabularyHeaderView::sectionClicked, this, &VocabularyHeaderView::updateSorting); 0014 } 0015 0016 void VocabularyHeaderView::updateSorting(int index) 0017 { 0018 if (m_sortSection != index) { 0019 setSortIndicatorShown(true); 0020 setSortIndicator(index, Qt::AscendingOrder); 0021 m_sortSection = index; 0022 return; 0023 } 0024 0025 if (sortIndicatorOrder() == Qt::DescendingOrder) { 0026 setSortIndicatorShown(true); 0027 setSortIndicator(index, Qt::DescendingOrder); 0028 return; 0029 } 0030 0031 if (!isSortIndicatorShown()) { 0032 setSortIndicatorShown(true); 0033 setSortIndicator(index, Qt::AscendingOrder); 0034 return; 0035 } 0036 0037 setSortIndicatorShown(false); 0038 m_sortSection = -1; 0039 model()->sort(-1); 0040 } 0041 0042 #include "moc_vocabularyheaderview.cpp"