~ubuntu-branches/ubuntu/saucy/kopete/saucy-proposed

« back to all changes in this revision

Viewing changes to libkopete/kopeteinfoeventmanager.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-06-21 02:22:39 UTC
  • Revision ID: package-import@ubuntu.com-20130621022239-63l3zc8p0nf26pt6
Tags: upstream-4.10.80
ImportĀ upstreamĀ versionĀ 4.10.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    kopeteinfoeventmanager.cpp - Kopete Info Event Manager
 
3
 
 
4
    Copyright (c) 2008      by Roman Jarosz          <kedgedev@centrum.cz>
 
5
    Kopete    (c) 2008      by the Kopete developers <kopete-devel@kde.org>
 
6
 
 
7
    *************************************************************************
 
8
    *                                                                       *
 
9
    * This library is free software; you can redistribute it and/or         *
 
10
    * modify it under the terms of the GNU Lesser General Public            *
 
11
    * License as published by the Free Software Foundation; either          *
 
12
    * version 2 of the License, or (at your option) any later version.      *
 
13
    *                                                                       *
 
14
    *************************************************************************
 
15
*/
 
16
#include "kopeteinfoeventmanager.h"
 
17
#include "kopeteinfoevent.h"
 
18
 
 
19
#include <QApplication>
 
20
#include <QStringList>
 
21
 
 
22
namespace Kopete {
 
23
 
 
24
class InfoEventManager::Private
 
25
{
 
26
public:
 
27
        QList<InfoEvent*> eventList;
 
28
};
 
29
 
 
30
InfoEventManager *InfoEventManager::instance = 0L;
 
31
 
 
32
InfoEventManager::InfoEventManager()
 
33
 : QObject( qApp ), d( new Private )
 
34
{
 
35
}
 
36
 
 
37
 
 
38
InfoEventManager::~InfoEventManager()
 
39
{
 
40
        instance = 0L;
 
41
        delete d;
 
42
}
 
43
 
 
44
InfoEventManager *InfoEventManager::self()
 
45
{
 
46
        if ( !instance )
 
47
                instance = new InfoEventManager;
 
48
        
 
49
        return instance;
 
50
}
 
51
 
 
52
void InfoEventManager::addEvent( Kopete::InfoEvent* event )
 
53
{
 
54
        emit eventAboutToBeAdded( event );
 
55
 
 
56
        if ( !event->isClosed() )
 
57
        {
 
58
                connect( event, SIGNAL(eventClosed(Kopete::InfoEvent*)),
 
59
                         this, SLOT(eventClosed(Kopete::InfoEvent*)) );
 
60
 
 
61
                d->eventList.append( event );
 
62
                emit eventAdded( event );
 
63
                emit changed();
 
64
        }
 
65
}
 
66
 
 
67
QList<InfoEvent*> InfoEventManager::events() const
 
68
{
 
69
        return d->eventList;
 
70
}
 
71
 
 
72
int InfoEventManager::eventCount() const
 
73
{
 
74
        return d->eventList.count();
 
75
}
 
76
 
 
77
Kopete::InfoEvent* InfoEventManager::event( int i ) const
 
78
{
 
79
        return d->eventList.at( i );
 
80
}
 
81
 
 
82
void InfoEventManager::eventClosed( Kopete::InfoEvent* event )
 
83
{
 
84
        d->eventList.removeAll( event );
 
85
        emit changed();
 
86
}
 
87
 
 
88
}
 
89
 
 
90
#include "kopeteinfoeventmanager.moc"