File indexing completed on 2019-07-28 10:35:11

0001 /*
0002 This file is part of Choqok, the KDE micro-blogging client
0003 
0004 Copyright (C) 2008-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com>
0005 
0006 This program is free software; you can redistribute it and/or
0007 modify it under the terms of the GNU General Public License as
0008 published by the Free Software Foundation; either version 2 of
0009 the License or (at your option) version 3 or any later version
0010 accepted by the membership of KDE e.V. (or its successor approved
0011 by the membership of KDE e.V.), which shall act as a proxy
0012 defined in Section 14 of version 3 of the license.
0013 
0014 This program is distributed in the hope that it will be useful,
0015 but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0017 GNU General Public License for more details.
0018 
0019 You should have received a copy of the GNU General Public License
0020 along with this program; if not, see http://www.gnu.org/licenses/
0021 */
0022 #ifndef TIMELINEWIDGET_H
0023 #define TIMELINEWIDGET_H
0024 
0025 #include <QIcon>
0026 #include <QMap>
0027 #include <QWidget>
0028 
0029 #include "choqoktypes.h"
0030 #include "choqok_export.h"
0031 
0032 class QLabel;
0033 class QHBoxLayout;
0034 class QVBoxLayout;
0035 
0036 namespace Choqok
0037 {
0038 class Account;
0039 
0040 namespace UI
0041 {
0042 
0043 class PostWidget;
0044 /**
0045 @brief Choqok base Timeline Widget
0046 
0047 @author Mehrdad Momeny \<mehrdad.momeny@gmail.com\>
0048 */
0049 class CHOQOK_EXPORT TimelineWidget : public QWidget
0050 {
0051     Q_OBJECT
0052 public:
0053     TimelineWidget(Account *account, const QString &timelineName, QWidget *parent = nullptr);
0054     virtual ~TimelineWidget();
0055     void setTimelineName(const QString &type);
0056 
0057     /**
0058     @brief Return Timeline name
0059     Related to whatever sets previouslly by @ref setTimelineName()
0060     */
0061     QString timelineName();
0062 
0063     /**
0064     @brief Return Timeline name for UI
0065     */
0066     QString timelineInfoName();
0067 
0068     /**
0069     @brief Return Timeline icon name
0070     */
0071     QString timelineIconName();
0072 
0073     /**
0074     @brief Return Timeline icon
0075     If timelineIconName() is empty this can be useful
0076      */
0077     QIcon &timelineIcon() const;
0078     void setTimelineIcon(const QIcon &icon);
0079 
0080     /**
0081      @brief Add new posts to UI.
0082     */
0083     virtual void addNewPosts(QList< Choqok::Post * > &postList);
0084 
0085     /**
0086      @brief Adds a message in place of an empty timeline. Placeholder is removed when a post gets added.
0087     */
0088     virtual void addPlaceholderMessage(const QString &message);
0089 
0090     /**
0091     @brief Return count of unread posts on this timeline.
0092     */
0093     int unreadCount() const;
0094 
0095     /**
0096     @brief remove old posts, about to user selected count of posts on timelines
0097     */
0098     void removeOldPosts();
0099 
0100     /**
0101     @return list of all widgets available on this timeline
0102     */
0103     QList<PostWidget *> postWidgets();
0104 
0105     /**
0106      * @return true if this timeline is closable!
0107      */
0108     bool isClosable() const;
0109 
0110     void setClosable(bool isClosable = true);
0111 
0112 public Q_SLOTS:
0113     /**
0114     @brief Mark all posts as read
0115     */
0116     virtual void markAllAsRead();
0117     /**
0118     @brief Manage changed settings on this timeline and forward it to all posts.
0119     */
0120     virtual void settingsChanged();
0121     /**
0122     @brief Scroll to the bottom of the timeline
0123     */
0124     virtual void scrollToBottom();
0125 
0126 Q_SIGNALS:
0127     void forwardResendPost(const QString &post);
0128     void forwardReply(const QString &txt, const QString &replyToId, const QString &replyToUsername);
0129     /**
0130     @brief Emit to inform MicroBlogWidget about changes on count of unread posts
0131 
0132     @param change changes of unread Count, can be positive or negative.
0133         positive means addition, and negative means subtraction
0134     */
0135     void updateUnreadCount(int change);
0136 
0137 protected Q_SLOTS:
0138     void slotOnePostReaded();
0139     virtual void saveTimeline();
0140     virtual void loadTimeline();
0141     void postWidgetClosed(const QString &postId, PostWidget *widget);
0142 
0143 protected:
0144     /**
0145     Add a PostWidget to UI
0146     @Note This will call @ref PostWidget::initUi()
0147     */
0148     virtual void addPostWidgetToUi(PostWidget *widget);
0149     Account *currentAccount();
0150     QMap<QString, PostWidget *> &posts() const;
0151     QMultiMap<QDateTime, PostWidget *> &sortedPostsList() const;
0152 
0153     QVBoxLayout *mainLayout();
0154     QHBoxLayout *titleBarLayout();
0155     QLabel *timelineDescription();
0156     virtual void setUnreadCount(int unread);
0157     virtual void showMarkAllAsReadButton();
0158 
0159 private:
0160     void setupUi();
0161     class Private;
0162     Private *const d;
0163 };
0164 }
0165 }
0166 #endif // TIMELINEWIDGET_H