~ubuntu-branches/ubuntu/karmic/choqok/karmic

« back to all changes in this revision

Viewing changes to choqok/statuswidget.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi, Alessandro Ghersi, Christian Mangold
  • Date: 2009-08-11 22:29:59 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090811222959-7tnr98ptcnyx3pjg
Tags: 0.6.6-0ubuntu1
[Alessandro Ghersi]
* New upstream release
  - Bump Standards-Version to 3.8.2
  - Long description formatted to fit in 80 characters

[Christian Mangold]
* Improve long description
* Update Maintainer, package is in main now
* Add a watch file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This file is part of Choqok, the KDE micro-blogging client
 
3
 
 
4
    Copyright (C) 2008-2009 Mehrdad Momeny <mehrdad.momeny@gmail.com>
 
5
 
 
6
    This program is free software; you can redistribute it and/or
 
7
    modify it under the terms of the GNU General Public License as
 
8
    published by the Free Software Foundation; either version 2 of
 
9
    the License or (at your option) version 3 or any later version
 
10
    accepted by the membership of KDE e.V. (or its successor approved
 
11
    by the membership of KDE e.V.), which shall act as a proxy
 
12
    defined in Section 14 of version 3 of the license.
 
13
 
 
14
 
 
15
    This program is distributed in the hope that it will be useful,
 
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
18
    GNU General Public License for more details.
 
19
 
 
20
    You should have received a copy of the GNU General Public License
 
21
    along with this program; if not, see http://www.gnu.org/licenses/
 
22
 
 
23
*/
 
24
#ifndef STATUSWIDGET_H
 
25
#define STATUSWIDGET_H
 
26
 
 
27
#include <QTimer>
 
28
#include <KTextBrowser>
 
29
#include <KPushButton>
 
30
#include <KUrl>
 
31
 
 
32
#include "datacontainers.h"
 
33
#include "constants.h"
 
34
#include "account.h"
 
35
 
 
36
namespace KIO {
 
37
    class Job;
 
38
}
 
39
 
 
40
/**
 
41
Status Widget
 
42
 
 
43
    @author Mehrdad Momeny <mehrdad.momeny@gmail.com>
 
44
*/
 
45
class StatusWidget : public KTextBrowser
 
46
{
 
47
    Q_OBJECT
 
48
    Q_PROPERTY (bool read READ isRead)
 
49
public:
 
50
    enum Notify { WithNotify = 0, WithoutNotify};
 
51
 
 
52
    explicit StatusWidget( const Account *account, QWidget *parent = 0 );
 
53
 
 
54
    ~StatusWidget();
 
55
 
 
56
    QString formatDateTime( const QDateTime &time );
 
57
 
 
58
    static void setStyle(const QColor & color, const QColor & back, const QColor & read, const QColor & readBack);
 
59
 
 
60
    Status currentStatus() const;
 
61
    void setCurrentStatus( const Status newStatus );
 
62
    void setUnread( Notify notifyType );
 
63
    void setRead(bool read = true);
 
64
    void updateFavoriteUi();
 
65
    bool isRead() const;
 
66
 
 
67
//     static QString getColoredStyle() { return style; };
 
68
public slots:
 
69
    void setUiStyle();
 
70
    void slotFriendAdded(const QString &);
 
71
 
 
72
signals:
 
73
    void sigSearch(int type, const QString & search);
 
74
    void sigReply( const QString &userName, qulonglong statusId, bool dMsg );
 
75
    void sigDestroy( qulonglong statusId );
 
76
    void sigFavorite( qulonglong statusId, bool isFavorite );
 
77
    void sigReTweet( const QString &text );
 
78
 
 
79
protected slots:
 
80
    void setFavorite( bool isFavorite );
 
81
    void requestReply();
 
82
    void requestDestroy();
 
83
    void requestReTweet();
 
84
    void updateSign();
 
85
    void userAvatarFetched( const QString &avatarUrl, const QPixmap & pixmap );
 
86
    void fetchAvatarError( const QString &avatarUrl, const QString &errMsg );
 
87
    void missingStatusReceived( Status status );
 
88
    void setHeight();
 
89
    void checkAnchor(const QUrl & url);
 
90
    void baseStatusReceived( Status status );
 
91
 
 
92
    void twitpicImageFetched( const QString &imageUrl, const QPixmap & pixmap );
 
93
    void twitpicImageFailed( const QString &imageUrl, const QString &errMsg );
 
94
 
 
95
    void showUserInformation(const User& user);
 
96
 
 
97
    void slot301Redirected(KIO::Job *job, const KUrl &fromUrl, const KUrl &toUrl);
 
98
 
 
99
protected:
 
100
    void resizeEvent ( QResizeEvent * event );
 
101
    void enterEvent ( QEvent * event );
 
102
    void leaveEvent ( QEvent * event );
 
103
 
 
104
private:
 
105
    void setupUi();
 
106
 
 
107
    static KPushButton * getButton(const QString & objName, const QString & toolTip, const QString & icon);
 
108
 
 
109
    void setUserImage();
 
110
    QString prepareStatus( const QString &text );
 
111
    void checkForTwitPicImages(const QString &status);
 
112
    void setDirection();
 
113
    QString generateSign();
 
114
    void updateUi();
 
115
 
 
116
    static QString getColorString(const QColor & color);
 
117
 
 
118
    QTimer timer;
 
119
    Status mCurrentStatus;
 
120
    bool mIsRead;
 
121
    const Account *mCurrentAccount;
 
122
 
 
123
    QString mSign;
 
124
    QString mStatus;
 
125
    QString mImage;
 
126
 
 
127
    static const QString baseText;
 
128
    static const QString baseStyle;
 
129
    static QString style;
 
130
 
 
131
    static const QRegExp mUrlRegExp;
 
132
    static const QRegExp mUserRegExp;
 
133
    static const QRegExp mHashtagRegExp;
 
134
    static const QRegExp mGroupRegExp;
 
135
 
 
136
    KPushButton * btnReply,*btnFavorite,*btnRemove, *btnReTweet;
 
137
    bool isBaseStatusShowed;
 
138
    bool isMissingStatusRequested;
 
139
    QString twitpicImageUrl;
 
140
    QString twitpicPageUrl;
 
141
};
 
142
 
 
143
#endif