• Skip to content
  • Skip to link menu
  • KDE API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • KTp
  • Declarative
conversation-queue-manager.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 Lasath Fernando <kde@lasath.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 
20 #include "conversation-queue-manager.h"
21 #include <KDebug>
22 
23 class ConversationQueueManager::ConversationQueManagerPrivate
24 {
25  public:
26  QList<Queueable*> queue;
27  KAction *gloablAction;
28 };
29 
30 void Queueable::enqueueSelf()
31 {
32  m_queueManager->enqueue(this);
33 }
34 
35 void Queueable::removeSelfFromQueue()
36 {
37  m_queueManager->remove(this);
38 }
39 
40 Queueable::~Queueable()
41 {
42 }
43 
44 Queueable::Queueable(ConversationQueueManager *queue)
45  : m_queueManager(queue)
46 {
47  if(!queue) {
48  m_queueManager = ConversationQueueManager::instance();
49  }
50 }
51 
52 ConversationQueueManager *ConversationQueueManager::instance()
53 {
54  static ConversationQueueManager *m_instance = 0;
55 
56  if(!m_instance) {
57  m_instance = new ConversationQueueManager();
58  }
59 
60  return m_instance;
61 }
62 
63 ConversationQueueManager::ConversationQueueManager(QObject *parent):
64  QObject(parent),
65  d(new ConversationQueManagerPrivate)
66 {
67  kDebug();
68 
69  //FIXME: think of a good name for this. What did Kopete call it?
70  d->gloablAction = new KAction(this);
71  d->gloablAction->setObjectName(QLatin1String("next-unread-conversation"));
72  d->gloablAction->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_I)/*, KAction::ActiveShortcut | KAction::DefaultShortcut, KAction::NoAutoloading*/);
73 
74  connect(d->gloablAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), SLOT(dequeueNext()));
75 }
76 
77 void ConversationQueueManager::dequeueNext()
78 {
79  kDebug();
80 
81  if(!d->queue.isEmpty()) {
82  d->queue.takeLast()->selfDequeued();
83  }
84 }
85 
86 void ConversationQueueManager::enqueue(Queueable *item)
87 {
88  if(!d->queue.contains(item)) {
89  d->queue.append(item);
90  }
91 }
92 
93 void ConversationQueueManager::remove(Queueable *item)
94 {
95  if(d->queue.contains(item)) {
96  d->queue.removeAll(item);
97  }
98 }
99 
100 ConversationQueueManager::~ConversationQueueManager()
101 {
102  delete d;
103 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Fri Mar 22 2013 10:58:52 by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ktp-common-internals API Reference

Skip menu "ktp-common-internals API Reference"
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal