File indexing completed on 2019-04-16 17:04:19

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