1 /***************************************************************************
2 * Copyright (C) 2005-09 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef ABSTRACTBUFFERCONTAINER_H_
22 #define ABSTRACTBUFFERCONTAINER_H_
24 #include "abstractitemview.h"
25 #include "buffermodel.h"
27 class AbstractChatView;
31 class AbstractBufferContainer : public AbstractItemView {
35 AbstractBufferContainer(QWidget *parent);
36 virtual ~AbstractBufferContainer();
38 inline BufferId currentBuffer() const { return _currentBuffer; }
41 void currentChanged(BufferId);
42 void currentChanged(const QModelIndex &);
45 //! Create an AbstractChatView for the given BufferId and add it to the UI if necessary
46 virtual AbstractChatView *createChatView(BufferId) = 0;
48 //! Remove a chat view from the UI and delete it
49 /** This method shall remove the view from the UI (for example, from a QStackedWidget) if appropriate.
50 * It also shall delete the object afterwards.
51 * \param view The chat view to be removed and deleted
53 virtual void removeChatView(BufferId) = 0;
56 virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
57 virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
59 //! Show the given chat view
60 /** This method is called when the given chat view should be displayed. Use this e.g. for
61 * selecting the appropriate page in a QStackedWidget.
62 * \param view The chat view to be displayed. May be 0 if no chat view is selected.
64 virtual void showChatView(BufferId) = 0;
67 void removeBuffer(BufferId bufferId);
68 void setCurrentBuffer(BufferId bufferId);
71 BufferId _currentBuffer;
72 QHash<BufferId, AbstractChatView *> _chatViews;
75 class AbstractChatView {
78 virtual ~AbstractChatView() {};
79 virtual MsgId lastMsgId() const = 0;