Seamly2D
Code documentation
group_tablewidgetitem.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file group_tablewidgetitem.cpp
3  ** @author Douglas S Caskey
4  ** @date 11 Jun, 2023
5  **
6  ** @brief
7  ** @copyright
8  ** This source code is part of the Seamly2D project, a pattern making
9  ** program to create and model patterns of clothing.
10  ** Copyright (C) 2017-2023 Seamly2D project
11  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
12  **
13  ** Seamly2D is free software: you can redistribute it and/or modify
14  ** it under the terms of the GNU General Public License as published by
15  ** the Free Software Foundation, either version 3 of the License, or
16  ** (at your option) any later version.
17  **
18  ** Seamly2D is distributed in the hope that it will be useful,
19  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  ** GNU General Public License for more details.
22  **
23  ** You should have received a copy of the GNU General Public License
24  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
25  **
26  *************************************************************************/
27 
28 #include "group_tablewidgetitem.h"
29 
30 #include "../ifc/xml/vabstractpattern.h"
31 
33  : QTableWidgetItem()
34  , m_doc(doc)
35  {}
36 
37 //---------------------------------------------------------------------------------------------------------------------
38 bool GroupTableWidgetItem::operator<(const QTableWidgetItem &other) const
39 {
40  if (other.column() == 0)
41  {
42  bool thisVisible = m_doc->getGroupVisibility(this->data(Qt::UserRole).toUInt());
43  bool otherVisible = m_doc->getGroupVisibility(other.data(Qt::UserRole).toUInt());
44  return int(thisVisible) < int(otherVisible);
45  }
46  else if (other.column() == 1)
47  {
48  bool thisLocked = m_doc->getGroupLock(this->data(Qt::UserRole).toUInt());
49  bool otherLocked = m_doc->getGroupLock(other.data(Qt::UserRole).toUInt());
50  return int(thisLocked) < int(otherLocked);
51  }
52  else if (other.column() == 2)
53  {
54  bool thisEmpty = m_doc->isGroupEmpty(this->data(Qt::UserRole).toUInt());
55  bool otherEmpty = m_doc->isGroupEmpty(other.data(Qt::UserRole).toUInt());
56  return int(!thisEmpty) < int(!otherEmpty);
57  }
58  else if (other.column() == 3)
59  {
60  return this->data(Qt::UserRole).toString() < other.data(Qt::UserRole).toString();
61  }
62 
63  return false;
64 }
VAbstractPattern * m_doc
virtual bool operator<(const QTableWidgetItem &other) const Q_DECL_OVERRIDE
GroupTableWidgetItem(VAbstractPattern *doc)
bool getGroupLock(quint32 id)
bool isGroupEmpty(quint32 id)
Returns true if the given group is empty.
bool getGroupVisibility(quint32 id)