No longer honours following status in JSON, instead relies solely on following list.
[larjonas-pumpa.git] / src / messageedit.h
blobe6fe114091e36793524b1d64c14bb5d59fd54254
1 /*
2 Copyright 2013-2015 Mats Sjöberg
4 This file is part of the Pumpa programme.
6 Pumpa is free software: you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Pumpa is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Pumpa. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef MESSAGE_EDIT_H
21 #define MESSAGE_EDIT_H
23 #include <QTextEdit>
24 #include <QKeyEvent>
25 #include <QCompleter>
26 #include <QStringListModel>
28 #include "qasactor.h"
29 #include "qaspell.h"
30 #include "fancyhighlighter.h"
31 #include "pumpasettings.h"
33 //------------------------------------------------------------------------------
35 class MessageEdit : public QTextEdit {
36 Q_OBJECT
37 public:
38 MessageEdit(const PumpaSettings* s, QWidget* parent=0);
40 typedef QMap<QString, QASActor*> completion_t;
41 void setCompletions(const completion_t* completions);
42 void hideCompletion();
43 const completion_t* getCompletions() { return m_completions; }
45 signals:
46 void ready();
47 void addRecipient(QASActor*);
49 protected slots:
50 void insertCompletion(QString);
51 void replaceSuggestion(const QString& word);
53 protected:
54 virtual void focusInEvent(QFocusEvent *event);
55 virtual void keyPressEvent(QKeyEvent* event);
56 virtual void contextMenuEvent(QContextMenuEvent* event);
57 QString wordAtCursor() const;
59 FancyHighlighter* m_highlighter;
60 QCompleter* m_completer;
61 QStringListModel* m_model;
62 const completion_t* m_completions;
64 QSignalMapper* m_sMapper;
65 QASpell* m_checker;
66 QTextCursor m_contextCursor;
68 const PumpaSettings* m_s;
71 #endif