Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / libkopete / kopetestatusmanager.h
blob476e47b16c80641e9dcdecfa5f90e00c307bde16
1 /*
2 kopetestatusmanager.h - Kopete Status Manager
4 Copyright (c) 2008 by Roman Jarosz <kedgedev@centrum.cz>
5 Kopete (c) 2008 by the Kopete developers <kopete-devel@kde.org>
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 *************************************************************************
16 #ifndef KOPETESTATUSMANAGER_H
17 #define KOPETESTATUSMANAGER_H
19 #include <QtCore/QObject>
21 #include "kopete_export.h"
22 #include "kopetestatusmessage.h"
24 class QDomElement;
26 namespace Kopete {
28 class Account;
30 namespace Status {
31 class StatusGroup;
32 class StatusItem;
35 /**
36 * StatusManager manages status items that are used to build status menu.
37 * It also stores current status message and sets auto away status.
39 * StatusManager is a singleton, you may uses it with @ref StatusManager::self()
41 * @author Roman Jarosz <kedgedev@centrum.cz>
43 class KOPETE_EXPORT StatusManager : public QObject
45 Q_OBJECT
46 public:
47 /**
48 * Get the only instance of StatusManager
49 * @return StatusManager single instance
51 static StatusManager *self();
53 ~StatusManager();
55 /**
56 * Save status data tree into XML file
58 void saveXML();
60 /**
61 * Load status data tree into XML file
63 void loadXML();
65 /**
66 * Set new status data tree
68 void setRootGroup( Status::StatusGroup * rootGroup );
70 /**
71 * Get current status data tree
73 Status::StatusGroup *getRootGroup() const;
75 /**
76 * Copy current status data tree
78 Status::StatusGroup *copyRootGroup() const;
80 /**
81 * Find status item for given uid
83 const Status::StatusItem *itemForUid( const QString &uid ) const;
85 /**
86 * Convert status item to XML structure
88 * @note it's public because it's also used for drag&drop
90 static QDomElement storeStatusItem( const Status::StatusItem *item );
92 /**
93 * Restore status item from XML structure
95 * @note it's public because it's also used for drag&drop
97 static Status::StatusItem *parseStatusItem( QDomElement element );
99 /**
100 * Remember current global status
102 void setGlobalStatus( uint category, const Kopete::StatusMessage &statusMessage = Kopete::StatusMessage() );
105 * Remember current global status message
107 void setGlobalStatusMessage( const Kopete::StatusMessage &statusMessage = Kopete::StatusMessage() );
110 * Get current global status message
112 Kopete::StatusMessage globalStatusMessage() const;
115 * Returns true if auto away status was set
117 bool autoAway();
120 * Returns true if global away status was set
122 bool globalAway();
124 public Q_SLOTS:
126 * Undo auto away
128 void setActive();
131 * Set all online account to auto away status
133 void setAutoAway();
135 Q_SIGNALS:
137 * This signal is emitted when root item of status data tree has changed.
139 void changed();
142 * This signal is emitted when global status has changed.
144 void globalStatusChanged();
146 private Q_SLOTS:
147 void accountUnregistered( const Kopete::Account *account );
148 void loadSettings();
149 void loadBehaviorSettings();
151 private:
152 StatusManager();
153 void updateUidHash( Status::StatusItem *item );
155 Status::StatusGroup *defaultStatuses() const;
157 static StatusManager *instance;
159 class Private;
160 Private * const d;
165 #endif