add more spacing
[personal-kdebase.git] / apps / konqueror / src / konqclosedwindowsmanager.h
blobcf8f42b7d173eb4bd07812d0573fd8a77dffb197
1 /* This file is part of the KDE project
2 Copyright 2007 David Faure <faure@kde.org>
3 Copyright 2007 Eduardo Robles Elvira <edulix@gmail.com>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
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 GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #ifndef KONQCLOSEDWINDOWSMANAGER_H
22 #define KONQCLOSEDWINDOWSMANAGER_H
24 #include "konqprivate_export.h"
25 #include <QList>
26 #include <QObject>
27 class KonqClosedRemoteWindowItem;
28 class KonqUndoManager;
29 class KConfig;
30 class QDBusMessage;
31 class KonqClosedWindowItem;
32 class QString;
33 class KonqClosedWindowsManagerPrivate;
35 /**
36 * Provides a shared singleton for all Konq window instances.
37 * This class is a singleton, use self() to access its only instance.
39 * - it synchronizes the closed window list with other
40 * Konqueror instances via DBUS.
43 class KONQ_TESTS_EXPORT KonqClosedWindowsManager : public QObject
45 Q_OBJECT
46 public:
47 friend class KonqClosedWindowsManagerPrivate;
49 static KonqClosedWindowsManager *self();
51 const QList<KonqClosedWindowItem *>& closedWindowItemList();
53 /**
54 * When a window is closed it's added with this function to
55 * m_closedWindowItemList.
57 void addClosedWindowItem(KonqUndoManager *real_sender, KonqClosedWindowItem
58 *closedWindowItem, bool propagate = true);
60 void removeClosedWindowItem(KonqUndoManager *real_sender, const
62 KonqClosedWindowItem *closedWindowItem, bool propagate = true);
64 KConfig* config();
66 /**
67 * Called by the KonqUndoManager when a local window is being closed.
68 * Saves the closed windows list to disk inside a config file.
70 void saveConfig();
72 bool undoAvailable() const;
74 public Q_SLOTS:
75 void readSettings();
77 /**
78 * Reads the list of closed window from the configuration file if it couldn't
79 * be retrieved from running konqueror windows and if it hasn't been read
80 * already. By default the closeditems_list file is not read, so each
81 * function which needs that file to be read first must call this function
82 * to ensure the closeditems list is filled.
84 void readConfig();
86 Q_SIGNALS:
87 /**
88 * Notifies the addition the closed window list in all the konqueror windows of
89 * this konqueror instance.
91 void addWindowInOtherInstances(KonqUndoManager *real_sender,
92 KonqClosedWindowItem *closedWindowItem);
94 /**
95 * Notifies the removal the closed window list in all the konqueror windows of
96 * this konqueror instance.
98 void removeWindowInOtherInstances(KonqUndoManager *real_sender, const
99 KonqClosedWindowItem *closedWindowItem);
100 private:
101 KonqClosedWindowsManager();
103 virtual ~KonqClosedWindowsManager();
105 KonqClosedRemoteWindowItem* findClosedRemoteWindowItem(const QString& configFileName,
106 const QString& configGroup);
108 KonqClosedWindowItem* findClosedLocalWindowItem(const QString& configFileName,
109 const QString& configGroup);
112 * This function removes all the closed items temporary files.
114 void removeClosedItemsConfigFiles();
115 private:
116 QList<KonqClosedWindowItem *> m_closedWindowItemList;
117 int m_numUndoClosedItems;
118 KConfig *m_konqClosedItemsConfig;
119 int m_maxNumClosedItems;
121 * This bool var is used internally to allow delayed initialization of the
122 * closed items list. When active, this flag prevents addClosedWindowItem()
123 * from emiting addWindowInOtherInstances() as the windows are already
124 * being dealt with inside KonqUndoManager::populate().
126 bool m_blockClosedItems;
127 Q_SIGNALS: // DBUS signals
129 * Every konqueror instance broadcasts new closed windows to other
130 * konqueror instances.
132 void notifyClosedWindowItem( const QString& title, const int& numTabs,
133 const QString& configFileName, const QString& configGroup );
136 * Every konqueror instance broadcasts removed closed windows to other
137 * konqueror instances.
139 void notifyRemove( const QString& configFileName,
140 const QString& configGroup );
142 private Q_SLOTS:// connected to DBUS signals
143 void slotNotifyClosedWindowItem( const QString& title, const int& numTabs,
144 const QString& configFileName, const QString& configGroup,
145 const QString& service );
147 void slotNotifyClosedWindowItem( const QString& title, const int& numTabs,
148 const QString& configFileName, const QString& configGroup,
149 const QDBusMessage& msg );
151 void slotNotifyRemove( const QString& configFileName,
152 const QString& configGroup, const QDBusMessage& msg );
154 private:
155 void emitNotifyClosedWindowItem(const KonqClosedWindowItem *closedWindowItem);
157 void emitNotifyRemove(const KonqClosedWindowItem *closedWindowItem);
160 #endif /* KONQCLOSEDWINDOWSMANAGER_H */