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

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 
0024 #ifndef MICROBLOGWIDGET_H
0025 #define MICROBLOGWIDGET_H
0026 
0027 #include <QMap>
0028 #include <QWidget>
0029 
0030 #include "choqoktabbar.h"
0031 #include "choqoktypes.h"
0032 #include "microblog.h"
0033 #include "choqok_export.h"
0034 
0035 class QLabel;
0036 
0037 namespace Choqok {
0038 class Account;
0039 
0040 namespace UI {
0041 class ComposerWidget;
0042 class TimelineWidget;
0043 
0044 /**
0045  * \brief MicroBlogWidget class.
0046  * Every MicroBlog plugin can use this or a drived class!
0047  *
0048  * @author Mehrdad Momeny \<mehrdad.momeny@gmail.com\>
0049  */
0050 class CHOQOK_EXPORT MicroBlogWidget : public QWidget
0051 {
0052     Q_OBJECT
0053 public:
0054     explicit MicroBlogWidget( Account *account, QWidget* parent = 0);
0055     virtual ~MicroBlogWidget();
0056     virtual void initUi();
0057     /**
0058     Set a @ref Choqok::ComposerWidget on read/write accounts!
0059     */
0060     Account * currentAccount() const;
0061 
0062     /**
0063     @return Current active timeline widget
0064     */
0065     TimelineWidget * currentTimeline();
0066 
0067 public Q_SLOTS:
0068     void removeOldPosts();
0069     /**
0070     @brief Manage changed settings on this timeline and forward it to all posts.
0071     */
0072     virtual void settingsChanged();
0073 
0074     /**
0075     @brief Call markAllAsRead() on all timelines
0076     */
0077     virtual void markAllAsRead();
0078 
0079     /**
0080     Call for @ref MicroBlog::updateTimelines() to update timelines!
0081 
0082     @see newTimelineDataRecieved()
0083     */
0084     virtual void updateTimelines();
0085 
0086     /**
0087     Using to give focus to composer()->editot() on tab change
0088     */
0089     virtual void setFocus();
0090 
0091 Q_SIGNALS:
0092     /**
0093     @brief Emit to tell MainWindow to show this MicroBlog
0094     */
0095     void showMe();
0096     /**
0097     Emit to show a message on MainWindow::StatusBar
0098     */
0099 //     void showStatusMessage( const QString & message, bool isPermanent = false );
0100 
0101     /**
0102     @brief Emit to inform MicroBlogWidget about changes on count of unread posts
0103 
0104     @param change changes of unread Count, can be positive or negative.
0105     positive means addition, and negative means subtraction
0106     @param sum of unread count on this blog
0107     */
0108     void updateUnreadCount( int change, int sum );
0109 
0110     /**
0111     Emitted when all timelines are loaded fine!
0112     @note This will use for splash screen management!
0113     */
0114     void loaded();
0115 
0116 protected Q_SLOTS:
0117     /**
0118     Connected to @ref MicroBlog::timelineDataReceived() to update timelines
0119 
0120     @see updateTimelines()
0121     */
0122     virtual void newTimelineDataRecieved( Choqok::Account *theAccount, const QString& type,
0123                                           QList< Choqok::Post* > data );
0124     void slotUpdateUnreadCount( int change, TimelineWidget * widget = 0 );
0125     void error(Choqok::Account* theAccount, Choqok::MicroBlog::ErrorType errorType,
0126                                 const QString &errorMsg, Choqok::MicroBlog::ErrorLevel level);
0127     void errorPost(Choqok::Account* theAccount, Choqok::Post*, Choqok::MicroBlog::ErrorType errorType,
0128                                     const QString &errorMsg, Choqok::MicroBlog::ErrorLevel level);
0129     void slotAbortAllJobs();
0130 
0131     virtual void keyPressEvent(QKeyEvent* );
0132 
0133     void slotAccountModified(Choqok::Account *theAccount);
0134 protected:
0135     virtual QLayout *createToolbar();
0136     virtual TimelineWidget* addTimelineWidgetToUi( const QString &name);
0137     void initTimelines();
0138 
0139     void setComposerWidget(ComposerWidget* widget);
0140     ComposerWidget *composer();
0141     QMap<QString, TimelineWidget*> &timelines();
0142     Choqok::UI::ChoqokTabBar *timelinesTabWidget();
0143     QLabel *latestUpdate();
0144 
0145 private:
0146     class Private;
0147     Private * const d;
0148 };
0149 }
0150 }
0151 #endif // MICROBLOGWIDGET_H