diff --git a/microblogs/pumpio/pumpiopostwidget.cpp b/microblogs/pumpio/pumpiopostwidget.cpp index 0076249f..6bdb164f 100644 --- a/microblogs/pumpio/pumpiopostwidget.cpp +++ b/microblogs/pumpio/pumpiopostwidget.cpp @@ -1,176 +1,176 @@ /* This file is part of Choqok, the KDE micro-blogging client Copyright (C) 2013 Andrea Scarpino This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/ */ #include "pumpiopostwidget.h" #include #include #include #include "mediamanager.h" #include "pumpioaccount.h" #include "pumpiomicroblog.h" #include "pumpiopost.h" const KIcon PumpIOPostWidget::unFavIcon(Choqok::MediaManager::convertToGrayScale(KIcon("rating").pixmap(16))); class PumpIOPostWidget::Private { public: KPushButton *btnFav; }; PumpIOPostWidget::PumpIOPostWidget(Choqok::Account* account, Choqok::Post* post, QWidget* parent): PostWidget(account, post, parent), d(new Private) { } PumpIOPostWidget::~PumpIOPostWidget() { delete d->btnFav; delete d; } QString PumpIOPostWidget::generateSign() { QString ss; PumpIOPost *post = dynamic_cast(currentPost()); PumpIOAccount *account = qobject_cast(currentAccount()); PumpIOMicroBlog *microblog = qobject_cast(account->microblog()); if (post) { if (post->author.userName != account->username()) { ss += "author.description + "\">" + post->author.userName + " - "; } ss += "link + "\" title=\"" + post->creationDateTime.toString(Qt::DefaultLocaleLongDate) + "\">%1"; if (!post->source.isEmpty()) { ss += " - " + post->source; } const QRegExp followers("/api/user/\\w+/followers"); if (!post->to.isEmpty()) { ss += " - "; ss += i18n("To: "); Q_FOREACH (const QString& id, post->to) { if (id == "http://activityschema.org/collection/public") { - ss += "Public"; + ss += "Public "; } else if (followers.indexIn(id) != -1) { - ss += "Followers"; + ss += "Followers "; } else if (id == "acct:" + account->webfingerID()) { - //Display nothing + ss += "You "; } else { ss += "profileUrl(account, id) + "\">" + microblog->userNameFromAcct(id) + " "; } } ss = ss.trimmed(); } if (!post->cc.isEmpty()) { ss += " - "; ss += i18n("Cc: "); Q_FOREACH (const QString& id, post->cc) { if (id == "http://activityschema.org/collection/public") { - ss += "Public"; + ss += "Public "; } else if (followers.indexIn(id) != -1) { - ss += "Followers"; + ss += "Followers "; } else if (id == "acct:" + account->webfingerID()) { - //Display nothing + ss += "You "; } else { ss += "profileUrl(account, id) + "\">" + microblog->userNameFromAcct(id) + ""; } } ss = ss.trimmed(); } } else { kDebug() << "post is not a PumpIOPost!"; } return ss; } void PumpIOPostWidget::initUi() { Choqok::UI::PostWidget::initUi(); d->btnFav = addButton("btnFavorite", i18nc("@info:tooltip", "Favorite"), "rating"); d->btnFav->setCheckable(true); connect(d->btnFav, SIGNAL(clicked(bool)), this, SLOT(toggleFavorite())); updateFavStat(); } void PumpIOPostWidget::toggleFavorite() { setReadWithSignal(); PumpIOMicroBlog* microBlog = qobject_cast(currentAccount()->microblog()); connect(microBlog, SIGNAL(favorite(Choqok::Account*, Choqok::Post*)), this, SLOT(slotToggleFavorite(Choqok::Account*, Choqok::Post*))); microBlog->toggleFavorite(currentAccount(), currentPost()); } void PumpIOPostWidget::slotToggleFavorite(Choqok::Account*, Choqok::Post*) { updateFavStat(); } void PumpIOPostWidget::slotPostError(Choqok::Account* theAccount, Choqok::Post* post, Choqok::MicroBlog::ErrorType error, const QString& errorMessage) { Q_UNUSED(error) if (theAccount == currentAccount() && post == currentPost()) { kDebug() << errorMessage; disconnect(currentAccount()->microblog(), SIGNAL(postRemoved(Choqok::Account*,Choqok::Post*)), this, SLOT(slotCurrentPostRemoved(Choqok::Account*,Choqok::Post*)) ); disconnect(currentAccount()->microblog(), SIGNAL(errorPost(Choqok::Account*,Choqok::Post*,Choqok::MicroBlog::ErrorType,QString,Choqok::MicroBlog::ErrorLevel)), this, SLOT(slotPostError(Choqok::Account*,Choqok::Post*,Choqok::MicroBlog::ErrorType,QString))); } } void PumpIOPostWidget::slotResendPost() { setReadWithSignal(); PumpIOMicroBlog* microBlog = qobject_cast(currentAccount()->microblog()); microBlog->share(currentAccount(), currentPost()); } void PumpIOPostWidget::updateFavStat() { d->btnFav->setChecked(currentPost()->isFavorited); if (currentPost()->isFavorited){ d->btnFav->setIcon(KIcon("rating")); } else { d->btnFav->setIcon(unFavIcon); } }