1 /*
2  * This file is part of Licq, an instant messaging client for UNIX.
3  * Copyright (C) 2007-2009 Licq developers
4  *
5  * Licq 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  * Licq 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
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Licq; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #ifndef CONTACTBAR_H
21 #define CONTACTBAR_H
22 
23 #include <QString>
24 #include <QVariant>
25 
26 #include "contactitem.h"
27 #include "contactlist.h"
28 
29 
30 namespace LicqQtGui
31 {
32 class ContactGroup;
33 
34 /**
35  * A separator bar in the contact list used to separate online and offline users
36  *
37  * This class is used internally by CContactList and should not be accessed from any other class
38  */
39 class ContactBar : public ContactItem
40 {
41   Q_OBJECT
42 
43 public:
44   /**
45    * Constructor, creates a bar
46    */
47   ContactBar(ContactListModel::SubGroupType subGroup, ContactGroup* group);
48 
49   /**
50    * Destructor
51    */
~ContactBar()52   virtual ~ContactBar() {}
53 
54   /**
55    * Get the group this user instance belongs to
56    */
group()57   ContactGroup* group() const
58   { return myGroup; }
59 
60   /**
61    * Get sub group
62    */
subGroup()63   ContactListModel::SubGroupType subGroup() const
64   { return mySubGroup; }
65 
66   /**
67    * Get current user count
68    */
count()69   int count() const
70   { return myUserCount; }
71 
72   /**
73    * Increase the current number of users in this sub group
74    */
75   void countIncrease();
76 
77   /**
78    * Decrease the current number of users in this sub group
79    */
80   void countDecrease();
81 
82   /**
83    * Update unread event counter for sub group
84    *
85    * @param counter Number to increase or decrease event counter by
86    */
87   void updateNumEvents(int counter);
88 
89   /**
90    * Update visibility counter
91    *
92    * @param increase True if counter should be increased
93    */
94   void updateVisibility(bool increase);
95 
96   /**
97    * Get data for this bar
98    *
99    * @param column A valid column in the contact list
100    * @param role The qt role to get data for
101    * @return Data for this bar
102    */
103   QVariant data(int column, int role) const;
104 
105 private:
106   ContactGroup* myGroup;
107   ContactListModel::SubGroupType mySubGroup;
108   QString myText;
109   int myUserCount;
110   int myEvents;
111   int myVisibleContacts;
112 };
113 
114 } // namespace LicqQtGui
115 
116 #endif
117