serverlistcolumn.h
1 //------------------------------------------------------------------------------
2 // serverlistcolumn.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __SERVER_LIST_COLUMN_H_
24 #define __SERVER_LIST_COLUMN_H_
25 
26 #include <QObject>
27 #include <QtContainerFwd>
28 
29 class QStandardItem;
30 
32 {
33  const int columnId;
34  const int width;
35  const bool bResizable;
36  const Qt::SortOrder defaultSortOrder;
37 };
38 
39 namespace ServerListColumnId
40 {
41 enum ColumnId
42 {
43  IDPort,
44  IDPlayers,
45  IDPing,
46  IDServerName,
47  IDAddress,
48  IDIwad,
49  IDMap,
50  IDWads,
51  IDGametype,
52 
53  NUM_SERVERLIST_COLUMNS
54 };
55 
56 const ColumnId COL_META = IDPort;
57 }
58 
59 class ServerListColumns : public QObject
60 {
61  Q_OBJECT
62 
63 public:
64  static const ServerListColumn columns[];
65 
66  static QString columnLabel(int columnId);
67  static QStringList generateColumnHeaderLabels();
68  static QList<QStandardItem *> generateListOfCells();
69 
70  static bool isColumnVital(int columnId);
71 
72  inline static bool isPictureColumn(int columnId)
73  {
74  return columnId == ServerListColumnId::IDPort ||
75  columnId == ServerListColumnId::IDPlayers;
76  }
77 
79 };
80 
81 #endif