summaryrefslogtreecommitdiffstats
path: root/konversation/src/servergroupsettings.h
blob: 3a7cc2d853c2c0559fd0ce31199c279821ddd489 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
*/

/*
  Copyright (C) 2004, 2007 Peter Simonsson <psn@linux.se>
  Copyright (C) 2006-2008 Eike Hein <hein@kde.org>
*/

#ifndef KONVERSATIONSERVERGROUPSETTINGS_H
#define KONVERSATIONSERVERGROUPSETTINGS_H

#include "serversettings.h"
#include "identity.h"

#include <tqvaluelist.h>
#include <tqstringlist.h>

#include <ksharedptr.h>


namespace Konversation
{

    class ChannelSettings
    {
        public:
            ChannelSettings();
            ChannelSettings(const ChannelSettings& settings);
            explicit ChannelSettings(const TQString& name);
            ChannelSettings(const TQString& name, const TQString& password);
            ChannelSettings(const TQString& name, const TQString& password, bool enableNotifications);
            ~ChannelSettings();

            void setName(const TQString& name) { m_name = name; }
            TQString name() const { return m_name; }

            void setPassword(const TQString& password) { m_password = password; }
            TQString password() const { return m_password; }

            void setNotificationsEnabled(bool enable) { m_enableNotifications = enable; }
            bool enableNotifications() const { return m_enableNotifications; }

            bool operator==(const ChannelSettings& channel) const;

        private:
            TQString m_name;
            TQString m_password;

            bool m_enableNotifications;
    };

    class ServerGroupSettings;
    typedef KSharedPtr<ServerGroupSettings> ServerGroupSettingsPtr;
    typedef TQValueList<ServerGroupSettingsPtr> ServerGroupList;
    typedef TQValueList<ServerSettings> ServerList;
    typedef TQValueList<ChannelSettings> ChannelList;

    class ServerGroupSettings : public KShared
    {
        public:
            ServerGroupSettings();
            ServerGroupSettings(int id);
            ServerGroupSettings(const ServerGroupSettings& settings);
            ServerGroupSettings(const TQString& name);
            ~ServerGroupSettings();

            void setName(const TQString& name) { m_name = name; }
            TQString name() const { return m_name; }

            void setServerList(const ServerList& list);
            void addServer(const ServerSettings& settings) { m_serverList.append(settings); }
            void removeServer(const ServerSettings settings);
            ServerList serverList() const { return m_serverList; }
            ServerSettings serverByIndex(unsigned int index) const;


            void setIdentityId(int identityId) { m_identityId = identityId; }
            int identityId() const { return m_identityId; }
            IdentityPtr identity() const;

            void setChannelList(const ChannelList& list);
            void addChannel(const ChannelSettings& channel) { m_channelList.append(channel); }
            void addChannel(const ChannelSettings& channel, const ChannelSettings& before);
            void removeChannel(const ChannelSettings& channel);
            ChannelList channelList() const { return m_channelList; }
            ChannelSettings channelByIndex(unsigned int index) const;

            void setConnectCommands(const TQString& commands) { m_connectCommands = commands; }
            TQString connectCommands() const { return m_connectCommands; }

            void setAutoConnectEnabled(bool enabled) { m_autoConnect = enabled; }
            bool autoConnectEnabled() const { return m_autoConnect; }

            int id() const { return m_id; }

            void setSortIndex(int sortIndex) { m_sortIndex = sortIndex; }
            int sortIndex() const { return m_sortIndex; }

            void setChannelHistory(const ChannelList& list) { m_channelHistory = list; }
            void appendChannelHistory(const ChannelSettings& channel);
            ChannelList channelHistory() const { return m_channelHistory; }
            ChannelSettings channelByNameFromHistory(const TQString& channelName);

            void setNotificationsEnabled(bool enable) { m_enableNotifications = enable; }
            bool enableNotifications() const { return m_enableNotifications; }

            void setExpanded(bool enable) { m_expanded = enable; }
            bool expanded() const { return m_expanded; }

        private:
            static int s_availableId;
            int m_sortIndex;
            TQString m_name;
            ServerList m_serverList;
            int m_identityId;
            ChannelList m_channelList;
            ChannelList m_channelHistory;
            TQString m_connectCommands;
            bool m_autoConnect;
            TQString m_group;
            int m_id;
            bool m_enableNotifications;
            bool m_expanded;
    };

}
#endif