summaryrefslogtreecommitdiffstats
path: root/konversation/src/query.h
blob: af28087af8b14df8aecc48078c486a1849a3206f (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
/*
  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) 2002 Dario Abatianni <eisfuchs@tigress.com>
  Copyright (C) 2005-2008 Eike Hein <hein@kde.org>
*/

#ifndef QUERY_H
#define QUERY_H

#include "chatwindow.h"
#include "nickinfo.h"

#include <tqstring.h>

/* TODO: Idle counter to close query after XXX minutes of inactivity */
/* TODO: Use /USERHOST to check if queries are still valid */

class TQLineEdit;
class TQCheckBox;
class TQLabel;
class TQSplitter;

class IRCInput;

namespace Konversation {
  class TopicLabel;
}

class Query : public ChatWindow
{
    Q_OBJECT

    public:
        explicit Query(TQWidget* parent, TQString name);
        virtual void setServer(Server* newServer);

        ~Query();

        /** This will always be called soon after this object is created.
         *  @param nickInfo A nickinfo that must exist.
         */
        void setNickInfo(const NickInfoPtr & nickInfo);
        /** It seems that this does _not_ guaranttee to return non null.
         *  The problem is when you open a query to someone, then the go offline.
         *  This should be fixed maybe?  I don't know.
         */
        NickInfoPtr getNickInfo();
        virtual TQString getTextInLine();
        virtual bool closeYourself(bool askForConfirmation=true);
        virtual bool canBeFrontView();
        virtual bool searchView();

        virtual void setChannelEncoding(const TQString& encoding);
        virtual TQString getChannelEncoding();
        virtual TQString getChannelEncodingDefaultDesc();
        virtual void emitUpdateInfo();

        virtual bool isInsertSupported() { return true; }

        /** call this when you see a nick quit from the server.
         *  @param reason The quit reason given by that user.
         */
        void quitNick(const TQString& reason);

    signals:
        void sendFile(const TQString& recipient);
        void updateQueryChrome(ChatWindow*, const TQString&);

    public slots:
        void sendQueryText(const TQString& text);
        void appendInputText(const TQString& s, bool fromCursor);
        virtual void indicateAway(bool show);
        void updateAppearance();
        void setEncryptedOutput(bool);
        void connectionStateChanged(Server*, Konversation::ConnectionState);

    protected slots:
        void queryTextEntered();
        void queryPassthroughCommand();
        void sendFileMenu();
        void filesDropped(const TQStrList& files);
        // connected to IRCInput::textPasted() - used to handle large/multiline pastes
        void textPasted(const TQString& text);
        void popup(int id);
        void nickInfoChanged();
        void closeWithoutAsking();
        virtual void serverOnline(bool online);

    protected:
        void setName(const TQString& newName);
        void showEvent(TQShowEvent* event);
        /** Called from ChatWindow adjustFocus */
        virtual void childAdjustFocus();

        bool awayChanged;
        bool awayState;

        TQString queryName;
        TQString buffer;

        TQSplitter* m_headerSplitter;
        Konversation::TopicLabel* queryHostmask;
        TQLabel* addresseeimage;
        TQLabel* addresseelogoimage;
        TQLabel* awayLabel;
        TQLabel* blowfishLabel;
        IRCInput* queryInput;
        NickInfoPtr m_nickInfo;

        bool m_initialShow;
};
#endif