File indexing completed on 2024-05-05 04:57:13
0001 /* 0002 This file is part of Choqok, the KDE micro-blogging client 0003 0004 SPDX-FileCopyrightText: 2011-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0007 */ 0008 0009 #include "gnusocialapiconversationtimelinewidget.h" 0010 0011 #include <QTimer> 0012 0013 #include <KLocalizedString> 0014 0015 #include "choqokappearancesettings.h" 0016 #include "postwidget.h" 0017 0018 #include "gnusocialapimicroblog.h" 0019 0020 GNUSocialApiConversationTimelineWidget::GNUSocialApiConversationTimelineWidget(Choqok::Account *curAccount, 0021 const QString &convId, QWidget *parent) 0022 : TwitterApiTimelineWidget(curAccount, i18n("Conversation %1", convId), parent) 0023 { 0024 setWindowTitle(i18n("Please wait...")); 0025 GNUSocialApiMicroBlog *mBlog = qobject_cast<GNUSocialApiMicroBlog *>(curAccount->microblog()); 0026 resize(choqokMainWindow->width(), 500); 0027 move(choqokMainWindow->pos()); 0028 conversationId = convId; 0029 connect(mBlog, &GNUSocialApiMicroBlog::conversationFetched, 0030 this, &GNUSocialApiConversationTimelineWidget::slotConversationFetched); 0031 mBlog->fetchConversation(curAccount, convId); 0032 } 0033 0034 GNUSocialApiConversationTimelineWidget::~GNUSocialApiConversationTimelineWidget() 0035 { 0036 0037 } 0038 0039 void GNUSocialApiConversationTimelineWidget::saveTimeline() 0040 { 0041 } 0042 0043 void GNUSocialApiConversationTimelineWidget::loadTimeline() 0044 { 0045 } 0046 0047 void GNUSocialApiConversationTimelineWidget::slotConversationFetched(Choqok::Account *theAccount, 0048 const QString &convId, 0049 QList< Choqok::Post * > posts) 0050 { 0051 if (currentAccount() == theAccount && convId == this->conversationId) { 0052 setWindowTitle(i18n("Conversation")); 0053 addNewPosts(posts); 0054 for (Choqok::UI::PostWidget *post: postWidgets()) { 0055 post->setReadWithSignal(); 0056 } 0057 QTimer::singleShot(0, this, SLOT(updateHeight())); 0058 } 0059 } 0060 0061 void GNUSocialApiConversationTimelineWidget::updateHeight() 0062 { 0063 int height = 25; 0064 for (Choqok::UI::PostWidget *wd: postWidgets()) { 0065 height += wd->height() + 5; 0066 } 0067 if (height > choqokMainWindow->height()) { 0068 height = choqokMainWindow->height(); 0069 } 0070 resize(width(), height); 0071 if (!Choqok::AppearanceSettings::useReverseOrder()) { 0072 scrollToBottom(); 0073 } 0074 } 0075 0076 #include "moc_gnusocialapiconversationtimelinewidget.cpp"