diff --git a/microblogs/pumpio/pumpiopostwidget.cpp b/microblogs/pumpio/pumpiopostwidget.cpp index e37ac8fd..5bf741da 100644 --- a/microblogs/pumpio/pumpiopostwidget.cpp +++ b/microblogs/pumpio/pumpiopostwidget.cpp @@ -1,138 +1,137 @@ /* 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" 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) { - connect(this, SIGNAL(resendPost(QString)), this, SLOT(sharePost())); } PumpIOPostWidget::~PumpIOPostWidget() { delete d->btnFav; delete d; } QString PumpIOPostWidget::generateSign() { QString ss; ss = "author.description + "\">" + currentPost()->author.userName + " - "; ss += "link + "\" title=\"" + currentPost()->creationDateTime.toString(Qt::DefaultLocaleLongDate) + "\">%1"; if( !currentPost()->source.isEmpty() ) ss += " - " + currentPost()->source; if (!currentPost()->replyToPostId.isEmpty()) { const QString link = currentAccount()->microblog()->postUrl(currentAccount(), currentPost()->replyToUserName, currentPost()->replyToPostId); ss += " - "; ss += i18n("in reply to @%3", link, currentAccount()->microblog()->profileUrl(currentAccount(), currentPost()->replyToUserId), currentPost()->replyToUserName); } 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::sharePost() +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); } } diff --git a/microblogs/pumpio/pumpiopostwidget.h b/microblogs/pumpio/pumpiopostwidget.h index c7bc7ce4..b7e094d4 100644 --- a/microblogs/pumpio/pumpiopostwidget.h +++ b/microblogs/pumpio/pumpiopostwidget.h @@ -1,58 +1,61 @@ /* 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/ */ #ifndef PUMPIOPOSTWIDGET_H #define PUMPIOPOSTWIDGET_H #include "postwidget.h" class PumpIOPostWidget : public Choqok::UI::PostWidget { Q_OBJECT public: explicit PumpIOPostWidget(Choqok::Account* account, Choqok::Post* post, QWidget* parent = 0); virtual ~PumpIOPostWidget(); virtual QString generateSign(); + virtual void initUi(); protected Q_SLOTS: virtual void slotPostError(Choqok::Account* theAccount, Choqok::Post* post, Choqok::MicroBlog::ErrorType error, const QString& errorMessage); + virtual void toggleFavorite(); - virtual void slotToggleFavorite(Choqok::Account*, Choqok::Post*); - void sharePost(); + virtual void slotResendPost(); + + virtual void slotToggleFavorite(Choqok::Account*, Choqok::Post*); protected: static const KIcon unFavIcon; private: void updateFavStat(); class Private; Private * const d; }; #endif // PUMPIOPOSTWIDGET_H \ No newline at end of file