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: 2015 Andrea Scarpino <scarpino@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0007 */
0008 
0009 #include "gnusocialapidmessagedialog.h"
0010 
0011 #include <QStringList>
0012 
0013 #include "twitterapiaccount.h"
0014 
0015 #include "gnusocialapimicroblog.h"
0016 
0017 GNUSocialApiDMessageDialog::GNUSocialApiDMessageDialog(TwitterApiAccount *theAccount, QWidget *parent, Qt::WindowFlags flags)
0018     : TwitterApiDMessageDialog(theAccount, parent, flags)
0019 {
0020     const QStringList list = theAccount->friendsList();
0021 
0022     if (list.isEmpty()) {
0023         reloadFriendslist();
0024     } else {
0025         QStringList sameHost;
0026 
0027         for (const QString &user: list) {
0028             // QUrl::host() is needed to skip scheme check
0029             if (GNUSocialApiMicroBlog::hostFromProfileUrl(user).compare(QUrl(theAccount->host()).host()) == 0) {
0030                 sameHost.append(GNUSocialApiMicroBlog::usernameFromProfileUrl(user));
0031             }
0032         }
0033 
0034         sameHost.sort(Qt::CaseInsensitive);
0035         setFriends(sameHost);
0036     }
0037 }
0038 
0039 GNUSocialApiDMessageDialog::~GNUSocialApiDMessageDialog()
0040 {
0041 }
0042 
0043 #include "moc_gnusocialapidmessagedialog.cpp"