summaryrefslogtreecommitdiffstats
path: root/konversation/src/channeloptionsdialog.h
blob: b947fee6d2f12675f744449f7a943b9cc67cab47 (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
/*
  This program is free software; you can redistribute it and/or modifydvancedModes
  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 by Peter Simonsson
  email:     psn@linux.se
*/
#ifndef KONVERSATIONCHANNELOPTIONSDIALOG_H
#define KONVERSATIONCHANNELOPTIONSDIALOG_H

#include "channel.h"

#include <qstringlist.h>

#include <kdialogbase.h>
#include <klistview.h>


namespace Konversation
{
    class ChannelOptionsUI;

    class ChannelOptionsDialog : public KDialogBase
    {
        Q_OBJECT
            public:
            explicit ChannelOptionsDialog(Channel *channel);
            ~ChannelOptionsDialog();

            QString topic();
            QStringList modes();


        public slots:
            void refreshTopicHistory();
            void refreshAllowedChannelModes();
            void refreshModes();
            void refreshEnableModes();
            void toggleAdvancedModes();

            void refreshBanList();
            void addBan(const QString& newban);
            void addBanClicked();
            void removeBan(const QString& ban);
            void removeBanClicked();
            void banEdited(QListViewItem *edited);

            void changeOptions();


        protected slots:
            void topicHistoryItemClicked(QListViewItem* item);
            void topicBeingEdited(bool state);

            void cancelClicked();
            void okClicked();


        protected:
            bool m_editingTopic;
            QListViewItem *m_NewBan;


        private:
            ChannelOptionsUI* m_widget;
            Channel *m_channel;
    };


    // This is needed to overcome two deficiencies in KListViewItem
    // First there is no signal emitted when a rename is canceled
    // Second there is no way to get the old value of an item after a rename
    class BanListViewItem : public KListViewItem
    {
        public:
            explicit BanListViewItem( QListView *parent );
            BanListViewItem(QListView *parent, bool isNew);
            BanListViewItem(QListView *parent, const QString& label1, const QString& label2 = QString(), uint timestamp = 0);
            BanListViewItem (QListView *parent, bool isNew, const QString& label1, const QString& label2 = QString(), uint timestamp = 0);

            QString getOldValue() { return m_oldValue; }
            QDateTime timestamp() { return m_timestamp; }

            virtual QString text(int column) const;
            virtual int compare(QListViewItem *i, int col, bool ascending) const;
            virtual void startRename(int col);


        protected:
            virtual void cancelRename(int col);

            QString m_oldValue;
            bool m_isNewBan;
            QDateTime m_timestamp;
    };

}
#endif