<commit_before>#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <KFileItem>
#include <KFileItemList>
#include <KIO/PreviewJob>

#include <TelepathyQt4/AccountManager>
#include <TelepathyQt4/PendingReady>


#include "accounts-model.h"
#include "flat-model-proxy.h"
#include "account-filter-model.h"


MainWindow::MainWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MainWindow)
{
    Tp::registerTypes();

    ui->setupUi(this);

    KFileItem file(KUrl("/home/david/a.png"), "image/png", KFileItem::Unknown);

    KIO::PreviewJob* job = KIO::filePreview(KFileItemList() << file, ui->filePreviewLabel->size());

    ui->fileNameLabel->setText(file.name());
    ui->filePreviewLabel->setText(QString());

    connect(job, SIGNAL(gotPreview(KFileItem, QPixmap)),
            this, SLOT(showPreview(KFileItem, QPixmap)));
    connect(job, SIGNAL(failed(KFileItem)),
            this, SLOT(showIcon(KFileItem)));


    Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
                                                                       Tp::Features() << Tp::Account::FeatureCore
                                                                       << Tp::Account::FeatureAvatar
                                                                       << Tp::Account::FeatureProtocolInfo
                                                                       << Tp::Account::FeatureProfile);

    Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus(),
                                                                               Tp::Features() << Tp::Connection::FeatureCore
                                                                               << Tp::Connection::FeatureRosterGroups
                                                                               << Tp::Connection::FeatureRoster
                                                                               << Tp::Connection::FeatureSelfContact);

    Tp::ContactFactoryPtr contactFactory = Tp::ContactFactory::create(Tp::Features()  << Tp::Contact::FeatureAlias
                                                                      << Tp::Contact::FeatureAvatarData
                                                                      << Tp::Contact::FeatureSimplePresence
                                                                      << Tp::Contact::FeatureCapabilities);

    Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());

    m_accountManager = Tp::AccountManager::create(QDBusConnection::sessionBus(),
                                                  accountFactory,
                                                  connectionFactory,
                                                  channelFactory,
                                                  contactFactory);


    connect(m_accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onAccountManagerReady()));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::showPreview(const KFileItem &file, const QPixmap &pixmap)
{
    ui->filePreviewLabel->setMinimumSize(pixmap.size());
    ui->filePreviewLabel->setPixmap(pixmap);
}

void MainWindow::showIcon(const KFileItem &file)
{
    //icon is     file.iconName();

}

void MainWindow::onAccountManagerReady()
{
    AccountsModel *model = new AccountsModel(m_accountManager, this);
    FlatModelProxy *flatProxyModel = new FlatModelProxy(model);
    AccountFilterModel *filterModel = new AccountFilterModel(this);
    filterModel->setSourceModel(flatProxyModel);
    filterModel->filterOfflineUsers(true);
    ui->listView->setModel(filterModel);
}<commit_msg>Fix the models by switching round the use of the flat model proxy and the filter proxy.<commit_after>#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <KFileItem>
#include <KFileItemList>
#include <KIO/PreviewJob>

#include <TelepathyQt4/AccountManager>
#include <TelepathyQt4/PendingReady>


#include "accounts-model.h"
#include "flat-model-proxy.h"
#include "account-filter-model.h"


MainWindow::MainWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MainWindow)
{
    Tp::registerTypes();

    ui->setupUi(this);

    KFileItem file(KUrl("/home/david/a.png"), "image/png", KFileItem::Unknown);

    KIO::PreviewJob* job = KIO::filePreview(KFileItemList() << file, ui->filePreviewLabel->size());

    ui->fileNameLabel->setText(file.name());
    ui->filePreviewLabel->setText(QString());

    connect(job, SIGNAL(gotPreview(KFileItem, QPixmap)),
            this, SLOT(showPreview(KFileItem, QPixmap)));
    connect(job, SIGNAL(failed(KFileItem)),
            this, SLOT(showIcon(KFileItem)));


    Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
                                                                       Tp::Features() << Tp::Account::FeatureCore
                                                                       << Tp::Account::FeatureAvatar
                                                                       << Tp::Account::FeatureProtocolInfo
                                                                       << Tp::Account::FeatureProfile);

    Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus(),
                                                                               Tp::Features() << Tp::Connection::FeatureCore
                                                                               << Tp::Connection::FeatureRosterGroups
                                                                               << Tp::Connection::FeatureRoster
                                                                               << Tp::Connection::FeatureSelfContact);

    Tp::ContactFactoryPtr contactFactory = Tp::ContactFactory::create(Tp::Features()  << Tp::Contact::FeatureAlias
                                                                      << Tp::Contact::FeatureAvatarData
                                                                      << Tp::Contact::FeatureSimplePresence
                                                                      << Tp::Contact::FeatureCapabilities);

    Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());

    m_accountManager = Tp::AccountManager::create(QDBusConnection::sessionBus(),
                                                  accountFactory,
                                                  connectionFactory,
                                                  channelFactory,
                                                  contactFactory);


    connect(m_accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onAccountManagerReady()));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::showPreview(const KFileItem &file, const QPixmap &pixmap)
{
    ui->filePreviewLabel->setMinimumSize(pixmap.size());
    ui->filePreviewLabel->setPixmap(pixmap);
}

void MainWindow::showIcon(const KFileItem &file)
{
    //icon is     file.iconName();

}

void MainWindow::onAccountManagerReady()
{
    AccountsModel *model = new AccountsModel(m_accountManager, this);
    AccountFilterModel *filterModel = new AccountFilterModel(this);
    filterModel->setSourceModel(model);
    filterModel->filterOfflineUsers(true);
    FlatModelProxy *flatProxyModel = new FlatModelProxy(filterModel);

    ui->listView->setModel(flatProxyModel);
}
{'fraction_non_alphanumeric': 0.1099435176671483, 'fraction_numerical': 0.0005254170497832654, 'mean_word_length': 1.7818779685787358, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 82, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '567361', 'n_tokens_mistral': 1766, 'n_tokens_neox': 1709, 'n_words': 256}