Subversion Repositories svn1-original

Rev

Rev 328 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 328 Rev 372
Line 1... Line 1...
1
#include "qmTableWidgetItem.h"
1
#include "qmTableWidgetItem.h"
-
 
2
#include <QHeaderView>
2
 
3
 
3
/*----------------------------------------------------------------------------
4
/*----------------------------------------------------------------------------
4
** FUNCTION           : qmTwi...
5
** FUNCTION           : qmTwi...
5
**
6
**
6
** DESCRIPTION        : A collection of helper classes to help display team
7
** DESCRIPTION        : A collection of helper classes to help display team
Line 26... Line 27...
26
    sort = usort;
27
    sort = usort;
27
}
28
}
28
 
29
 
29
bool qmTwiString::operator< ( const QTableWidgetItem & other ) const
30
bool qmTwiString::operator< ( const QTableWidgetItem & other ) const
30
{
31
{
31
    if (sort)
32
    if (sort) {
-
 
33
        Qt::SortOrder sortOrder = tableWidget()->horizontalHeader()->sortIndicatorOrder();
32
        return true;
34
        return sortOrder == Qt::DescendingOrder;
-
 
35
    }
33
 
36
 
34
    const qmTwiString *other_widget = dynamic_cast<const qmTwiString *>(&other); 
37
    const qmTwiString *other_widget = dynamic_cast<const qmTwiString *>(&other); 
35
    if (other_widget)
38
    if (other_widget)
36
    {
39
    {
37
        return data(Qt::DisplayRole).toString().toLower() < other_widget->data(Qt::DisplayRole).toString().toLower(); 
40
        return data(Qt::DisplayRole).toString().toLower() < other_widget->data(Qt::DisplayRole).toString().toLower(); 
38
    }
41
    }
39
    return false;
42
    return false;
40
}
43
}
41
 
44
 
42
/*----------------------------------------------------------------------------
45
/*----------------------------------------------------------------------------
-
 
46
** FUNCTION           :
-
 
47
**
-
 
48
** DESCRIPTION        :
-
 
49
----------------------------------------------------------------------------*/
-
 
50
 
-
 
51
qmTwiEditString::qmTwiEditString ( QString value, int usort  ) :  QTableWidgetItem(0)
-
 
52
{
-
 
53
    setData(Qt::DisplayRole,value);
-
 
54
    setFlags(flags() | Qt::ItemIsEditable);
-
 
55
    sort = usort;
-
 
56
}
-
 
57
 
-
 
58
bool qmTwiEditString::operator< ( const QTableWidgetItem & other ) const
-
 
59
{
-
 
60
    if (sort) {
-
 
61
        Qt::SortOrder sortOrder = tableWidget()->horizontalHeader()->sortIndicatorOrder();
-
 
62
        return sortOrder == Qt::DescendingOrder;
-
 
63
    }
-
 
64
 
-
 
65
 
-
 
66
    const qmTwiEditString *other_widget = dynamic_cast<const qmTwiEditString *>(&other);
-
 
67
    if (other_widget)
-
 
68
    {
-
 
69
        return data(Qt::DisplayRole).toString().toLower() < other_widget->data(Qt::DisplayRole).toString().toLower();
-
 
70
    }
-
 
71
    return false;
-
 
72
}
-
 
73
 
-
 
74
/*----------------------------------------------------------------------------
43
** FUNCTION           : 
75
** FUNCTION           : 
44
**
76
**
45
** DESCRIPTION        :
77
** DESCRIPTION        :
46
----------------------------------------------------------------------------*/
78
----------------------------------------------------------------------------*/
47
 
79
 
Line 52... Line 84...
52
    setData(0,value);
84
    setData(0,value);
53
    setFlags(flags() & ~Qt::ItemIsEditable);
85
    setFlags(flags() & ~Qt::ItemIsEditable);
54
}
86
}
55
 
87
 
56
 
88
 
57
bool qmTwiNumber::operator< ( const QTableWidgetItem & other ) const
89
bool qmTwiNumber::operator< ( const QTableWidgetItem& other ) const
58
{
90
{
-
 
91
    //if (sort == 2) {
-
 
92
    //    qDebug() << "<N:" << number << " S:" << sort << " O:" << tableWidget()->horizontalHeader()->sortIndicatorOrder();
-
 
93
    //}
-
 
94
 
59
    if (sort)
95
    if (sort) {
-
 
96
        Qt::SortOrder sortOrder = tableWidget()->horizontalHeader()->sortIndicatorOrder();
60
        return true;
97
        return sortOrder == Qt::DescendingOrder;
-
 
98
    }
-
 
99
 
61
 
100
 
62
    const qmTwiNumber *other_widget = dynamic_cast<const qmTwiNumber *>(&other);
101
    const qmTwiNumber *other_widget = dynamic_cast<const qmTwiNumber *>(&other);
63
    if (other_widget)
102
    if (other_widget)
64
    {
103
    {
65
        return number < other_widget->number;
104
        return number < other_widget->number;
Line 79... Line 118...
79
    sort = usort;
118
    sort = usort;
80
}
119
}
81
 
120
 
82
bool qmTwiEditNumber::operator< ( const QTableWidgetItem & other ) const
121
bool qmTwiEditNumber::operator< ( const QTableWidgetItem & other ) const
83
{
122
{
84
    if (sort)
123
    if (sort) {
-
 
124
        Qt::SortOrder sortOrder = tableWidget()->horizontalHeader()->sortIndicatorOrder();
85
        return true;
125
        return sortOrder == Qt::DescendingOrder;
-
 
126
    }
-
 
127
 
86
 
128
 
87
    const qmTwiEditNumber * other_widget = dynamic_cast<const qmTwiEditNumber*>(&other);
129
    const qmTwiEditNumber * other_widget = dynamic_cast<const qmTwiEditNumber*>(&other);
88
    if (other_widget)
130
    if (other_widget)
89
    {
131
    {
90
        return data(Qt::EditRole).toInt() < other_widget->data(Qt::EditRole).toInt(); 
132
        return data(Qt::EditRole).toInt() < other_widget->data(Qt::EditRole).toInt(); 
Line 135... Line 177...
135
    setFlags(flags() & ~(Qt::ItemIsEditable | Qt::ItemIsUserCheckable));
177
    setFlags(flags() & ~(Qt::ItemIsEditable | Qt::ItemIsUserCheckable));
136
}
178
}
137
 
179
 
138
bool qmTwiFlag::operator< ( const QTableWidgetItem & other ) const
180
bool qmTwiFlag::operator< ( const QTableWidgetItem & other ) const
139
{
181
{
140
    if (sort)
182
    if (sort) {
-
 
183
        Qt::SortOrder sortOrder = tableWidget()->horizontalHeader()->sortIndicatorOrder();
141
        return true;
184
        return sortOrder == Qt::DescendingOrder;
-
 
185
    }
-
 
186
 
142
 
187
 
143
    const qmTwiFlag * other_widget = dynamic_cast<const qmTwiFlag*>(&other);
188
    const qmTwiFlag * other_widget = dynamic_cast<const qmTwiFlag*>(&other);
144
    if (other_widget)
189
    if (other_widget)
145
    {
190
    {
146
        return (other_widget->checkState() < checkState()); 
191
        return (other_widget->checkState() < checkState()); 
Line 164... Line 209...
164
    setFlags(flags() | (Qt::ItemIsEditable | Qt::ItemIsUserCheckable));
209
    setFlags(flags() | (Qt::ItemIsEditable | Qt::ItemIsUserCheckable));
165
}
210
}
166
 
211
 
167
bool qmTwiEditFlag::operator< ( const QTableWidgetItem & other ) const
212
bool qmTwiEditFlag::operator< ( const QTableWidgetItem & other ) const
168
{
213
{
169
    if (sort)
214
    if (sort) {
-
 
215
        Qt::SortOrder sortOrder = tableWidget()->horizontalHeader()->sortIndicatorOrder();
170
        return true;
216
        return sortOrder == Qt::DescendingOrder;
-
 
217
    }
-
 
218
 
171
 
219
 
172
    const qmTwiEditFlag * other_widget = dynamic_cast<const qmTwiEditFlag*>(&other);
220
    const qmTwiEditFlag * other_widget = dynamic_cast<const qmTwiEditFlag*>(&other);
173
    if (other_widget)
221
    if (other_widget)
174
    {
222
    {
175
        return (other_widget->checkState() < checkState()); 
223
        return (other_widget->checkState() < checkState());