Show webfinger if displayName is unknown for an author.
[larjonas-pumpa.git] / src / fullobjectwidget.h
blob07d8b0f9af65ec7ffd5b80fbcc4033c134b0ad14
1 /*
2 Copyright 2013-2015 Mats Sjöberg
4 This file is part of the Pumpa programme.
6 Pumpa is free software: you can redistribute it and/or modify it
7 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.
11 Pumpa is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Pumpa. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _FULLOBJECTWIDGET_H_
21 #define _FULLOBJECTWIDGET_H_
23 #include <QMenu>
24 #include <QAction>
25 #include <QLabel>
26 #include <QWidget>
27 #include <QVBoxLayout>
28 #include <QPushButton>
30 #include "objectwidgetwithsignals.h"
31 #include "qactivitystreams.h"
32 #include "texttoolbutton.h"
33 #include "richtextlabel.h"
34 #include "actorwidget.h"
35 #include "imagelabel.h"
37 //------------------------------------------------------------------------------
39 class FullObjectWidget : public ObjectWidgetWithSignals {
40 Q_OBJECT
42 public:
43 FullObjectWidget(QASObject* obj, QWidget* parent = 0, bool childWidget=false);
44 virtual ~FullObjectWidget();
46 virtual void changeObject(QASAbstractObject* obj);
48 QASObject* object() const { return m_object; }
49 virtual QASAbstractObject* asObject() const { return object(); }
51 virtual void refreshTimeLabels();
52 void disableLessButton();
54 void updateMenu() {
55 if (m_actorWidget)
56 m_actorWidget->updateMenu();
57 updateFollowAuthorButton();
60 void setActivity(QASActivity* a) { m_activity = a; }
62 signals:
63 void lessClicked();
65 private slots:
66 void onChanged();
67 void updateImage();
68 void imageClicked();
69 void onHasMoreClicked();
71 void favourite();
72 void onRepeatClicked();
73 void reply();
74 void onFollow();
75 void onFollowAuthor();
76 void updateFollowAuthorButton(bool wait = false);
77 void updateDeleteEditButtons();
78 void onDeleteClicked();
79 void onEditClicked();
81 #ifdef DEBUG_BUTTONS
82 void onLoadRepliesClicked();
83 void onDumpJsonClicked();
84 #endif
86 private:
87 bool isCommentable() const;
88 QString typeName() const;
89 QString textExcerpt() const;
91 bool hasValidIrtObject();
92 void setText(QString text);
93 void updateInfoText();
95 void updateLikes();
96 void updateShares();
97 void updateTitle();
99 QString recipientsToString(QASObjectList* rec);
100 QString processText(QString old_text, bool getImages=false);
102 void addHasMoreButton(QASObjectList* ol, int li);
103 void updateFavourButton(bool wait = false);
104 void updateShareButton(bool wait = false);
105 void updateFollowButton(bool wait = false);
107 bool isFollowable(QASObject* obj) const;
109 void addObjectList(QASObjectList* ol);
110 void clearObjectList();
112 QString m_imageUrl;
113 QString m_localFile;
115 RichTextLabel* m_textLabel;
116 ImageLabel* m_imageLabel;
117 ActorWidget* m_actorWidget;
118 RichTextLabel* m_streamLabel;
120 RichTextLabel* m_infoLabel;
121 RichTextLabel* m_likesLabel;
122 RichTextLabel* m_sharesLabel;
123 QLabel* m_titleLabel;
124 QPushButton* m_hasMoreButton;
126 TextToolButton* m_favourButton;
127 TextToolButton* m_shareButton;
128 TextToolButton* m_commentButton;
129 TextToolButton* m_followButton;
130 TextToolButton* m_followAuthorButton;
131 TextToolButton* m_deleteButton;
132 TextToolButton* m_editButton;
134 TextToolButton* m_lessButton;
136 #ifdef DEBUG_BUTTONS
137 TextToolButton* m_loadRepliesButton;
138 TextToolButton* m_dumpJsonButton;
139 #endif
141 QVBoxLayout* m_contentLayout;
142 QHBoxLayout* m_buttonLayout;
143 QVBoxLayout* m_commentsLayout;
145 QASObject* m_object;
146 QASActor* m_actor;
147 QASActor* m_author;
149 QList<QASObject*> m_repliesList;
150 QSet<QString> m_repliesMap;
152 QASActivity* m_activity;
154 bool m_childWidget;
155 bool m_commentable;
158 #endif /* _FULLOBJECTWIDGET_H_ */