conversation.cpp 2.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
    Copyright (C) 2011  Lasath Fernando <kde@lasath.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/


#include "conversation.h"
21
#include "messages-model.h"
22

David Edmundson's avatar
David Edmundson committed
23
#include <TelepathyQt/TextChannel>
Lasath Fernando's avatar
Lasath Fernando committed
24
#include <KDebug>
25
#include "conversation-target.h"
26

Lasath Fernando's avatar
Lasath Fernando committed
27 28
class Conversation::ConversationPrivate
{
29
public:
30 31
    MessagesModel *model;
    ConversationTarget *target;
32
//     Tp::AccountPtr account;
33 34
};

35
Conversation::Conversation(const Tp::TextChannelPtr& channel, const Tp::AccountPtr& account, QObject *parent) :
36
        QObject(parent),
37
        d (new ConversationPrivate)
38
{
Lasath Fernando's avatar
Lasath Fernando committed
39 40
    kDebug();

41
    d->model = new MessagesModel(this);
42
    d->model->setTextChannel(channel);
43

44
    d->target = new ConversationTarget(channel->targetContact(), this);
45

46
//     connect(model(), SIGNAL(unreadCountChanged(int)), SLOT(onUnreadMessagesChanged()));
47
//     d->account = account;
Lasath Fernando's avatar
Lasath Fernando committed
48 49
}

50
Conversation::Conversation(QObject *parent) : QObject(parent)
Lasath Fernando's avatar
Lasath Fernando committed
51
{
52
    kError() << "Conversation should not be created directly. Use ConversationWatcher instead.";
53
    Q_ASSERT(false);
54 55
}

56
MessagesModel *Conversation::model() const
57
{
Lasath Fernando's avatar
Lasath Fernando committed
58
    return d->model;
59 60
}

61
ConversationTarget *Conversation::target() const
62
{
63
    return d->target;
64 65
}

66 67 68 69 70 71 72 73 74
// void Conversation::onUnreadMessagesChanged()
// {
//     enqueSelf();
// }
// 
// void Conversation::selfDequed()
// {
//     Q_EMIT popoutRequested();
// }
75

76 77
Conversation::~Conversation()
{
Lasath Fernando's avatar
Lasath Fernando committed
78
    kDebug();
79
    delete d;
80
}