OSDN Git Service

80a115a28d6b398a1d0839bd27d8a33c04738242
[kita/kita.git] / kita / src / threadlistviewitem.cpp
1 /***************************************************************************
2 *   Copyright (C) 2004 by Kita Developers                                 *
3 *   ikemo@users.sourceforge.jp                                            *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 ***************************************************************************/
10
11 #include "threadlistviewitem.h"
12
13 using namespace Kita;
14
15 ThreadListViewItem::ThreadListViewItem(int column)
16     : QTableWidgetItem(Qt::ItemIsSelectable), m_column(column)
17 {}
18
19 /* public */ /* virtual */
20 bool ThreadListViewItem::operator<(const QTableWidgetItem& other) const
21 {
22     QString thisText = text();
23     QString otherText = other.text();
24     switch (m_column) {
25     case ColumnResNum:
26     case ColumnReadNum:
27     case ColumnUnread:
28         return thisText.toInt() > otherText.toInt();
29     case ColumnId:
30         return thisText.toInt() > otherText.toInt();
31     case ColumnMark:
32         return data(Qt::UserRole).toInt() > other.data(Qt::UserRole).toInt();
33     case ColumnSince:
34         return QString::localeAwareCompare(thisText, otherText) > 0;
35     case ColumnSpeed:
36         return thisText.toDouble() * 1000 > otherText.toDouble() * 1000;
37     default:
38         return QString::localeAwareCompare(thisText, otherText) > 0;
39     }
40 }