Commit 7df64f2b authored by Lasath Fernando's avatar Lasath Fernando Committed by David Edmundson
Browse files

Implemented ConversationQueManager class with Queable interface.

parent e0337c53
/*
<one line to give the library's name and an idea of what it does.>
Copyright (C) 2012 <copyright holder> <email>
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-que-manager.h"
Queable::Queable(ConversationQueManager* que)
{
if(que) {
m_queManager = que;
} else {
m_queManager = ConversationQueManager::instance();
}
}
void Queable::push()
{
if(!m_queManager->que.contains(this)) {
m_queManager->que.append(this);
}
}
ConversationQueManager* ConversationQueManager::instance()
{
static ConversationQueManager* m_instance = 0;
if(!m_instance) {
m_instance = ConversationQueManager();
}
return m_instance;
}
ConversationQueManager::ConversationQueManager(QObject* parent): QObject(parent)
{
//FIXME: think of a good name for this. What did Kopete call it?
m_gloablAction = new KAction("cycle-unread-conversations");
m_gloablAction->setGlobalShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_I);
connect(m_gloablAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), SLOT(popConversation()));
}
void ConversationQueManager::popConversation()
{
if(!que.isEmpty()) {
que.takeLast()->pop();
}
}
\ No newline at end of file
/*
<one line to give the library's name and an idea of what it does.>
Copyright (C) 2012 <copyright holder> <email>
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
*/
#ifndef CONVERSATION_QUE_MANAGER_H
#define CONVERSATION_QUE_MANAGER_H
#include <QtCore/QObject>
#include <KAction>
class Queable {
friend class ConversationQueManager;
public:
explicit Queable(ConversationQueManager* que = 0);
private:
ConversationQueManager* m_queManager;
protected:
void push();
virtual void pop() = 0;
};
class ConversationQueManager : public QObject
{
friend class Queable;
public:
static ConversationQueManager* instance();
private:
QList<Queable*> que;
KAction* m_gloablAction;
explicit ConversationQueManager(QObject* parent = 0);
private Q_SLOTS:
void popConversation();
};
#endif // CONVERSATION_QUE_MANAGER_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment