qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
categorywidget.h
Go to the documentation of this file.
1 /*
2  Copyright © 2015-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "genericchatitemwidget.h"
23 #include "src/core/core.h"
24 #include "src/model/status.h"
25 
26 class FriendListLayout;
27 class FriendListWidget;
28 class FriendWidget;
29 class QVBoxLayout;
30 class QHBoxLayout;
31 
33 {
34  Q_OBJECT
35 public:
36  explicit CategoryWidget(bool compact, QWidget* parent = nullptr);
37 
38  bool isExpanded() const;
39  void setExpanded(bool isExpanded, bool save = true);
40  void setName(const QString& name, bool save = true);
41 
44  void updateStatus();
45 
46  bool hasChatrooms() const;
47  bool cycleContacts(bool forward);
48  bool cycleContacts(FriendWidget* activeChatroomWidget, bool forward);
49  void search(const QString& searchString, bool updateAll = false, bool hideOnline = false,
50  bool hideOffline = false);
51 
52 public slots:
53  void onCompactChanged(bool compact);
54  void moveFriendWidgets(FriendListWidget* friendList);
55 
56 protected:
57  void leaveEvent(QEvent* event) final;
58  void mouseReleaseEvent(QMouseEvent* event) final;
59 
60  void editName();
61  void setContainerAttribute(Qt::WidgetAttribute attribute, bool enabled);
62  QLayout* friendOnlineLayout() const;
63  QLayout* friendOfflineLayout() const;
64  void emitChatroomWidget(QLayout* layout, int index);
65 
66 private:
67  virtual void onSetName()
68  {
69  }
70  virtual void onExpand()
71  {
72  }
74  {
75  }
76 
77  QWidget* listWidget;
79  QVBoxLayout* fullLayout;
80  QVBoxLayout* mainLayout = nullptr;
81  QHBoxLayout* topLayout = nullptr;
82  QLabel* statusLabel;
83  QWidget* container;
84  QFrame* lineFrame;
85  bool expanded = false;
86 };
CategoryWidget::statusLabel
QLabel * statusLabel
Definition: categorywidget.h:82
genericchatitemwidget.h
Status::Status
Status
Definition: status.h:28
CategoryWidget::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) final
Definition: categorywidget.cpp:277
GenericChatItemWidget::compact
bool compact
Definition: genericchatitemwidget.h:47
CategoryWidget::leaveEvent
void leaveEvent(QEvent *event) final
Definition: categorywidget.cpp:108
CategoryWidget::expanded
bool expanded
Definition: categorywidget.h:85
CategoryWidget::lineFrame
QFrame * lineFrame
Definition: categorywidget.h:84
CategoryWidget::cycleContacts
bool cycleContacts(bool forward)
Definition: categorywidget.cpp:167
CategoryWidget::container
QWidget * container
Definition: categorywidget.h:83
CategoryWidget::listWidget
QWidget * listWidget
Definition: categorywidget.h:77
CategoryWidget
Definition: categorywidget.h:32
CategoryWidget::onSetName
virtual void onSetName()
Definition: categorywidget.h:67
CategoryWidget::addFriendWidget
void addFriendWidget(FriendWidget *w, Status::Status s)
Definition: categorywidget.cpp:130
CategoryWidget::hasChatrooms
bool hasChatrooms() const
Definition: categorywidget.cpp:152
CategoryWidget::CategoryWidget
CategoryWidget(bool compact, QWidget *parent=nullptr)
Definition: categorywidget.cpp:41
CategoryWidget::topLayout
QHBoxLayout * topLayout
Definition: categorywidget.h:81
GenericChatItemWidget
Definition: genericchatitemwidget.h:27
CategoryWidget::onCompactChanged
void onCompactChanged(bool compact)
Definition: categorywidget.cpp:245
CategoryWidget::search
void search(const QString &searchString, bool updateAll=false, bool hideOnline=false, bool hideOffline=false)
Definition: categorywidget.cpp:157
CategoryWidget::friendOfflineLayout
QLayout * friendOfflineLayout() const
Definition: categorywidget.cpp:289
FriendListLayout
Definition: friendlistlayout.h:30
CategoryWidget::editName
void editName()
Definition: categorywidget.cpp:124
CategoryWidget::onExpand
virtual void onExpand()
Definition: categorywidget.h:70
CategoryWidget::mainLayout
QVBoxLayout * mainLayout
Definition: categorywidget.h:80
FriendListWidget
Definition: friendlistwidget.h:42
CategoryWidget::fullLayout
QVBoxLayout * fullLayout
Definition: categorywidget.h:79
CategoryWidget::emitChatroomWidget
void emitChatroomWidget(QLayout *layout, int index)
Definition: categorywidget.cpp:32
CategoryWidget::setExpanded
void setExpanded(bool isExpanded, bool save=true)
Definition: categorywidget.cpp:83
core.h
CategoryWidget::removeFriendWidget
void removeFriendWidget(FriendWidget *w, Status::Status s)
Definition: categorywidget.cpp:138
CategoryWidget::updateStatus
void updateStatus()
Definition: categorywidget.cpp:144
CategoryWidget::moveFriendWidgets
void moveFriendWidgets(FriendListWidget *friendList)
Definition: categorywidget.cpp:299
CategoryWidget::setContainerAttribute
void setContainerAttribute(Qt::WidgetAttribute attribute, bool enabled)
Definition: categorywidget.cpp:283
CategoryWidget::isExpanded
bool isExpanded() const
Definition: categorywidget.cpp:78
CategoryWidget::setName
void setName(const QString &name, bool save=true)
Definition: categorywidget.cpp:113
CategoryWidget::listLayout
FriendListLayout * listLayout
Definition: categorywidget.h:78
status.h
FriendWidget
Definition: friendwidget.h:33
CategoryWidget::friendOnlineLayout
QLayout * friendOnlineLayout() const
Definition: categorywidget.cpp:294
CategoryWidget::onAddFriendWidget
virtual void onAddFriendWidget(FriendWidget *)
Definition: categorywidget.h:73