void TwitterApiPostWidget::initUi() { Choqok::UI::PostWidget::initUi(); KPushButton *btnRe = addButton( "btnReply",i18nc( "@info:tooltip", "Reply" ), "edit-undo" ); QMenu *menu = new QMenu(btnRe); KAction *actRep = new KAction(KIcon("edit-undo"), i18n("Reply to %1", currentPost().author.userName), menu); menu->addAction(actRep); connect( actRep, SIGNAL(triggered(bool)), SLOT(slotReply()) ); connect( btnRe, SIGNAL(clicked(bool)), SLOT(slotReply()) ); KAction *actWrite = new KAction( KIcon("document-edit"), i18n("Write to %1", currentPost().author.userName), menu ); menu->addAction(actWrite); connect( actWrite, SIGNAL(triggered(bool)), SLOT(slotWriteTo()) ); if( !currentPost().isPrivate ) { KAction *actReplytoAll = new KAction(i18n("Reply to all"), menu); menu->addAction(actReplytoAll); connect( actReplytoAll, SIGNAL(triggered(bool)), SLOT(slotReplyToAll()) ); } menu->setDefaultAction(actRep); btnRe->setDelayedMenu(menu); if( !currentPost().isPrivate ) { d->btnFav = addButton( "btnFavorite",i18nc( "@info:tooltip", "Favorite" ), "rating" ); d->btnFav->setCheckable(true); connect( d->btnFav, SIGNAL(clicked(bool)), SLOT(setFavorite()) ); updateFavStat(); }
void PostEntry::saveLocally() { if (currentPost()->content().isEmpty()) { if (KMessageBox::warningYesNo(this, i18n("The current post content is empty, are you sure you want to save an empty post?")) == KMessageBox::No) { return; } } const int resId = DBMan::self()->saveLocalEntry(*currentPost(), d->mCurrentPostBlogId); if (resId == -1) { KMessageBox::detailedSorry(this, i18n("Saving post locally failed."), DBMan::self()->lastErrorText()); return; } d->mCurrentPost.setLocalId(resId); Q_EMIT postSavedLocally(); Q_EMIT showStatusMessage(i18n("Post saved locally."), false); qCDebug(BLOGILO_LOG) << "Locally saved"; }
void TwitterPostWidget::slotReplyToAll() { QStringList nicks; nicks.append(currentPost().author.userName); QString txt = QString("@%1 ").arg(currentPost().author.userName); int pos = 0; while ((pos = mTwitterUserRegExp.indexIn(currentPost().content, pos)) != -1) { if (mTwitterUserRegExp.cap(2).toLower() != currentAccount()->username() && mTwitterUserRegExp.cap(2).toLower() != currentPost().author.userName && !nicks.contains(mTwitterUserRegExp.cap(2).toLower())){ nicks.append(mTwitterUserRegExp.cap(2)); txt += QString("@%1 ").arg(mTwitterUserRegExp.cap(2)); } pos += mTwitterUserRegExp.matchedLength(); } txt.chop(1); emit reply(txt, currentPost().postId); }
void PostEntry::saveTemporary() { if (d->isPostContentModified) { const int res = DBMan::self()->saveTempEntry(*currentPost(), d->mCurrentPostBlogId); if (res != -1) { d->mCurrentPost.setLocalId(res); Q_EMIT postSavedTemporary(); qCDebug(BLOGILO_LOG) << "Temporary saved"; } else { qCDebug(BLOGILO_LOG) << "Saving temporary failed: " << DBMan::self()->lastErrorText(); } } }
void TwitterPostWidget::initUi() { TwitterApiPostWidget::initUi(); KPushButton *btn = buttons().value("btnResend"); if(btn){ QMenu *menu = new QMenu(btn); QAction *resend = new QAction(i18n("Manual ReSend"), menu); connect( resend, SIGNAL(triggered(bool)), SLOT(slotResendPost()) ); QAction *repeat = new QAction(i18n("Retweet"), menu); repeat->setToolTip(i18n("Retweet post using API")); connect( repeat, SIGNAL(triggered(bool)), SLOT(repeatPost()) ); // If person protects their acc, we will use simple adding RT before message if (!currentPost().author.isProtected) menu->addAction(repeat); menu->addAction(resend); btn->setMenu(menu); } }
QString FacebookPostWidget::prepareStatus( const QString &txt ) { FacebookPost* post = static_cast<FacebookPost*>(currentPost()); kDebug()<<"content: " << post->content; kDebug()<<"title: " << post->title; kDebug()<<"caption: " << post->caption; kDebug()<<"description: " << post->description; kDebug()<<"story: " << post->story; kDebug()<<"link: " << post->link; QString content = Choqok::UI::PostWidget::prepareStatus(post->content); QString title = /*Choqok::UI::PostWidget::prepareStatus*/(post->title); QString caption = /*Choqok::UI::PostWidget::prepareStatus*/(post->caption); QString description = Choqok::UI::PostWidget::prepareStatus(post->description); QString story = Choqok::UI::PostWidget::prepareStatus(post->story); QString link = /*Choqok::UI::PostWidget::prepareStatus*/(post->link); QString status; if( !story.isEmpty() ) status += story + " <br/> "; if( !link.isEmpty() ) status += prepareLink(link, title, caption, description) + "<br/>"; if( !content.isEmpty() ) status += content; /* You cannot show an image this way in a QTextBrowser * You need to download it first, via Choqok::MediaManager and then add it as a resource * just like what we did in Image preview plugin. * I put the false in if, to prevent it to show for now*/ if (false && !post->iconUrl.isEmpty()) status += QString("<a href = \"%1\"> <img src = \"%2\"/> </a>").arg(link).arg(post->iconUrl); //QString status = Choqok::UI::PostWidget::prepareStatus(txt); kDebug()<< status; return status; }
QString FacebookPostWidget::generateSign () { FacebookPost* post = static_cast<FacebookPost*>(currentPost()); QString ss = ""; ss = "<i><a href='"+ currentAccount()->microblog()->profileUrl( currentAccount(), post->author.userId ) + +"' title=\"" + post->author.realName + "\">" ; if (post->author.realName.isEmpty()) ss += "Anonymous"; else ss += post->author.realName; ss += "</a> - </i> via"; //QStringList list = currentPost()->postId.split("_"); /*ss += "<a href=\"http://www.facebook.com/" + list[0] + "/posts/" + list[1] + "\" title=\"" + currentPost().creationDateTime.toString(Qt::DefaultLocaleLongDate) + "\">%1</a>";*/ if( !post->appId.isEmpty()) ss += " <a href=\"http://www.facebook.com/apps/application.php?id=" + post->appId.toString() + "\">" + post->appName + "</a>"; else ss += " web"; ss += " <a href='" + currentAccount()->microblog()->postUrl(currentAccount(), post->author.userName, post->postId) + "'>" + "<b>" + post->creationDateTime.toString(Qt::DefaultLocaleLongDate) + "</b></a>"; return ss; }
void TwitterPostWidget::checkAnchor(const QUrl& url) { QString scheme = url.scheme(); TwitterApiMicroBlog* blog = qobject_cast<TwitterApiMicroBlog*>(currentAccount()->microblog()); TwitterApiAccount *account = qobject_cast<TwitterApiAccount*>(currentAccount()); if( scheme == "tag" ) { blog->searchBackend()->requestSearchResults(currentAccount(), KUrl::fromPunycode(url.host().toUtf8()), (int)TwitterSearch::ReferenceHashtag); } else if(scheme == "user") { KMenu menu; KAction * info = new KAction( KIcon("user-identity"), i18nc("Who is user", "Who is %1", url.host()), &menu ); KAction * from = new KAction(KIcon("edit-find-user"), i18nc("Posts from user", "Posts from %1",url.host()), &menu); KAction * to = new KAction(KIcon("meeting-attending"), i18nc("Replies to user", "Replies to %1", url.host()), &menu); KAction *cont = new KAction(KIcon("user-properties"),i18nc("Including user name", "Including %1", url.host()), &menu); KAction * openInBrowser = new KAction(KIcon("applications-internet"), i18nc("Open profile page in browser", "Open profile in browser"), &menu); from->setData(TwitterSearch::FromUser); to->setData(TwitterSearch::ToUser); cont->setData(TwitterSearch::ReferenceUser); menu.addAction(info); menu.addAction(from); menu.addAction(to); menu.addAction(cont); menu.addAction(openInBrowser); //Subscribe/UnSubscribe/Block bool isSubscribe = false; QString accountUsername = currentAccount()->username().toLower(); QString postUsername = url.host().toLower(); KAction *subscribe = 0, *block = 0, *replyTo = 0, *dMessage = 0; if(accountUsername != postUsername){ menu.addSeparator(); QMenu *actionsMenu = menu.addMenu(KIcon("applications-system"), i18n("Actions")); replyTo = new KAction(KIcon("edit-undo"), i18nc("Write a message to user attention", "Write to %1", url.host()), actionsMenu); actionsMenu->addAction(replyTo); if( account->friendsList().contains( url.host(), Qt::CaseInsensitive ) ){ dMessage = new KAction(KIcon("mail-message-new"), i18nc("Send direct message to user", "Send private message to %1", url.host()), actionsMenu); actionsMenu->addAction(dMessage); isSubscribe = false;//It's UnSubscribe subscribe = new KAction( KIcon("list-remove-user"), i18nc("Unfollow user", "Unfollow %1", url.host()), actionsMenu); } else { isSubscribe = true; subscribe = new KAction( KIcon("list-add-user"), i18nc("Follow user", "Follow %1", url.host()), actionsMenu); } block = new KAction( KIcon("dialog-cancel"), i18nc("Block user", "Block %1", url.host()), actionsMenu); actionsMenu->addAction(subscribe); actionsMenu->addAction(block); } QAction * ret = menu.exec(QCursor::pos()); if(ret == 0) return; if(ret == info) { TwitterApiWhoisWidget *wd = new TwitterApiWhoisWidget(account, url.host(), currentPost(), this); wd->show(QCursor::pos()); return; } else if(ret == subscribe){ if(isSubscribe) { blog->createFriendship(currentAccount(), url.host()); } else { blog->destroyFriendship(currentAccount(), url.host()); } return; }else if(ret == block){ blog->blockUser(currentAccount(), url.host()); return; } else if(ret == openInBrowser){ Choqok::openUrl( QUrl( currentAccount()->microblog()->profileUrl(currentAccount(), url.host()) ) ); return; } else if(ret == replyTo){ emit reply( QString("@%1").arg(url.host()), QString() ); return; } else if(ret == dMessage){ blog->showDirectMessageDialog(account,url.host()); return; } int type = ret->data().toInt(); blog->searchBackend()->requestSearchResults(currentAccount(), url.host(), type); } else TwitterApiPostWidget::checkAnchor(url); }