Seamly2D
Code documentation
piece_tablewidgetitem.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file piece_tablewidgetitem.cpp
3  ** @author Douglas S Caskey
4  ** @date Jan 7, 2023
5  **
6  ** @copyright
7  ** Copyright (C) 2017 - 2023 Seamly, LLC
8  ** https://github.com/fashionfreedom/seamly2d
9  **
10  ** @brief
11  ** Seamly2D is free software: you can redistribute it and/or modify
12  ** it under the terms of the GNU General Public License as published by
13  ** the Free Software Foundation, either version 3 of the License, or
14  ** (at your option) any later version.
15  **
16  ** Seamly2D is distributed in the hope that it will be useful,
17  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  ** GNU General Public License for more details.
20  **
21  ** You should have received a copy of the GNU General Public License
22  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
23  **************************************************************************/
24 
25 #include "piece_tablewidgetitem.h"
26 
27 #include "../vpatterndb/vcontainer.h"
28 #include "../vpatterndb/vpiece.h"
29 
31  : QTableWidgetItem()
32  , m_data(data)
33  {}
34 
35 //---------------------------------------------------------------------------------------------------------------------
36 bool PieceTableWidgetItem::operator<(const QTableWidgetItem &other) const
37 {
38  if (other.column() == 0)
39  {
40  VPiece thisPiece = m_data->GetPiece(this->data(Qt::UserRole).toUInt());
41  VPiece otherPiece = m_data->GetPiece(other.data(Qt::UserRole).toUInt());
42 
43  return int(thisPiece.isInLayout()) < int(otherPiece.isInLayout());
44  }
45  else if (other.column() == 1)
46  {
47  VPiece thisPiece = m_data->GetPiece(this->data(Qt::UserRole).toUInt());
48  VPiece otherPiece = m_data->GetPiece(other.data(Qt::UserRole).toUInt());
49 
50  return int(thisPiece.isLocked()) < int(otherPiece.isLocked());
51  }
52  else if (other.column() == 2)
53  {
54  return this->background().color().name() < other.background().color().name();
55  }
56  return false;
57 }
PieceTableWidgetItem(VContainer *data)
virtual bool operator<(const QTableWidgetItem &other) const Q_DECL_OVERRIDE
The VContainer class container of all variables.
Definition: vcontainer.h:141
VPiece GetPiece(quint32 id) const
Definition: vcontainer.cpp:185
Definition: vpiece.h:88
bool isInLayout() const
Definition: vpiece.cpp:376
bool isLocked() const
Definition: vpiece.cpp:388