• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KTextEditor

  • interfaces
  • ktexteditor
messageinterface.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 *
3 * Copyright (C) 2012-2013 Dominik Haumann <dhaumann@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library 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.
9 *
10 * This library 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 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include "messageinterface.h"
22
23namespace KTextEditor {
24
25class MessagePrivate
26{
27 public:
28 QList<QAction*> actions;
29 Message::MessageType messageType;
30 Message::MessagePosition position;
31 QString text;
32 QIcon icon;
33 bool wordWrap;
34 int autoHide;
35 KTextEditor::Message::AutoHideMode autoHideMode;
36 int priority;
37 KTextEditor::View* view;
38 KTextEditor::Document* document;
39};
40
41Message::Message(const QString& richtext, MessageType type)
42 : d(new MessagePrivate())
43{
44 d->messageType = type;
45 d->position = Message::AboveView;
46 d->text = richtext;
47 d->wordWrap = false;
48 d->autoHide = -1;
49 d->autoHideMode = KTextEditor::Message::AfterUserInteraction;
50 d->priority = 0;
51 d->view = 0;
52 d->document = 0;
53}
54
55Message::~Message()
56{
57 emit closed(this);
58
59 delete d;
60}
61
62QString Message::text() const
63{
64 return d->text;
65}
66
67void Message::setText(const QString& text)
68{
69 if (d->text != text) {
70 d->text = text;
71 emit textChanged(text);
72 }
73}
74
75void Message::setIcon(const QIcon& newIcon)
76{
77 d->icon = newIcon;
78 emit iconChanged(d->icon);
79}
80
81QIcon Message::icon() const
82{
83 return d->icon;
84}
85
86Message::MessageType Message::messageType() const
87{
88 return d->messageType;
89}
90
91void Message::addAction(QAction* action, bool closeOnTrigger)
92{
93 // make sure this is the parent, so all actions are deleted in the destructor
94 action->setParent(this);
95 d->actions.append(action);
96
97 // call close if wanted
98 if (closeOnTrigger)
99 connect(action, SIGNAL(triggered()), SLOT(deleteLater()));
100}
101
102QList<QAction*> Message::actions() const
103{
104 return d->actions;
105}
106
107void Message::setAutoHide(int autoHideTimer)
108{
109 d->autoHide = autoHideTimer;
110}
111
112int Message::autoHide() const
113{
114 return d->autoHide;
115}
116
117void Message::setAutoHideMode(KTextEditor::Message::AutoHideMode mode)
118{
119 d->autoHideMode = mode;
120}
121
122KTextEditor::Message::AutoHideMode Message::autoHideMode() const
123{
124 return d->autoHideMode;
125}
126
127void Message::setWordWrap(bool wordWrap)
128{
129 d->wordWrap = wordWrap;
130}
131
132bool Message::wordWrap() const
133{
134 return d->wordWrap;
135}
136
137void Message::setPriority(int priority)
138{
139 d->priority = priority;
140}
141
142int Message::priority() const
143{
144 return d->priority;
145}
146
147void Message::setView(KTextEditor::View* view)
148{
149 d->view = view;
150}
151
152KTextEditor::View* Message::view() const
153{
154 return d->view;
155}
156
157void Message::setDocument(KTextEditor::Document* document)
158{
159 d->document = document;
160}
161
162KTextEditor::Document* Message::document() const
163{
164 return d->document;
165}
166
167void Message::setPosition(Message::MessagePosition position)
168{
169 d->position = position;
170}
171
172Message::MessagePosition Message::position() const
173{
174 return d->position;
175}
176
177
178
179MessageInterface::MessageInterface()
180 : d (0)
181{
182}
183
184MessageInterface::~MessageInterface()
185{
186}
187
188}
189
190// kate: space-indent on; indent-width 2; replace-tabs on;
KTextEditor::Document
A KParts derived class representing a text document.
Definition: document.h:112
KTextEditor::MessageInterface::MessageInterface
MessageInterface()
Default constructor, for internal use.
Definition: messageinterface.cpp:179
KTextEditor::MessageInterface::~MessageInterface
virtual ~MessageInterface()
Destructor, for internal use.
Definition: messageinterface.cpp:184
KTextEditor::Message::setWordWrap
void setWordWrap(bool wordWrap)
Enabled word wrap according to wordWrap.
Definition: messageinterface.cpp:127
KTextEditor::Message::MessagePosition
MessagePosition
Message position used to place the message either above or below of the KTextEditor::View.
Definition: messageinterface.h:115
KTextEditor::Message::AboveView
@ AboveView
show message above view
Definition: messageinterface.h:116
KTextEditor::Message::view
KTextEditor::View * view() const
This function returns the view you set by setView().
Definition: messageinterface.cpp:152
KTextEditor::Message::~Message
virtual ~Message()
Destructor.
Definition: messageinterface.cpp:55
KTextEditor::Message::autoHide
int autoHide() const
Returns the auto hide time in milliseconds.
Definition: messageinterface.cpp:112
KTextEditor::Message::setAutoHideMode
void setAutoHideMode(KTextEditor::Message::AutoHideMode mode)
Sets the autoHide mode to mode.
Definition: messageinterface.cpp:117
KTextEditor::Message::setAutoHide
void setAutoHide(int autoHideTimer=0)
Set the auto hide timer to autoHideTimer milliseconds.
Definition: messageinterface.cpp:107
KTextEditor::Message::wordWrap
bool wordWrap() const
Check, whether word wrap is enabled or not.
Definition: messageinterface.cpp:132
KTextEditor::Message::addAction
void addAction(QAction *action, bool closeOnTrigger=true)
Adds an action to the message.
Definition: messageinterface.cpp:91
KTextEditor::Message::text
QString text() const
Returns the text set in the constructor.
Definition: messageinterface.cpp:62
KTextEditor::Message::closed
void closed(KTextEditor::Message *message)
This signal is emitted before the message is deleted.
KTextEditor::Message::autoHideMode
KTextEditor::Message::AutoHideMode autoHideMode() const
Get the Message's autoHide mode.
Definition: messageinterface.cpp:122
KTextEditor::Message::messageType
MessageType messageType() const
Returns the message type set in the constructor.
Definition: messageinterface.cpp:86
KTextEditor::Message::textChanged
void textChanged(const QString &text)
This signal is emitted whenever setText() is called.
KTextEditor::Message::position
MessagePosition position() const
Returns the desired message position of this message.
Definition: messageinterface.cpp:172
KTextEditor::Message::MessageType
MessageType
Message types used as visual indicator.
Definition: messageinterface.h:104
KTextEditor::Message::icon
QIcon icon() const
Returns the icon of this message.
Definition: messageinterface.cpp:81
KTextEditor::Message::setIcon
void setIcon(const QIcon &icon)
Optionally set an icon for this notification.
Definition: messageinterface.cpp:75
KTextEditor::Message::priority
int priority() const
Returns the priority of the message.
Definition: messageinterface.cpp:142
KTextEditor::Message::setDocument
void setDocument(KTextEditor::Document *document)
Set the document pointer to document.
Definition: messageinterface.cpp:157
KTextEditor::Message::AutoHideMode
AutoHideMode
The AutoHideMode determines when to trigger the autoHide timer.
Definition: messageinterface.h:126
KTextEditor::Message::AfterUserInteraction
@ AfterUserInteraction
auto-hide is triggered only after the user interacted with the view
Definition: messageinterface.h:128
KTextEditor::Message::Message
Message(const QString &richtext, MessageType type=Message::Information)
Constructor for new messages.
Definition: messageinterface.cpp:41
KTextEditor::Message::setPriority
void setPriority(int priority)
Set the priority of this message to priority.
Definition: messageinterface.cpp:137
KTextEditor::Message::setView
void setView(KTextEditor::View *view)
Set the associated view of the message.
Definition: messageinterface.cpp:147
KTextEditor::Message::setPosition
void setPosition(MessagePosition position)
Sets the position either to AboveView or BelowView.
Definition: messageinterface.cpp:167
KTextEditor::Message::setText
void setText(const QString &richtext)
Sets the notification contents to text.
Definition: messageinterface.cpp:67
KTextEditor::Message::iconChanged
void iconChanged(const QIcon &icon)
This signal is emitted whenever setIcon() is called.
KTextEditor::Message::actions
QList< QAction * > actions() const
Accessor to all actions, mainly used in the internal implementation to add the actions into the gui.
Definition: messageinterface.cpp:102
KTextEditor::Message::document
KTextEditor::Document * document() const
Returns the document pointer this message was posted in.
Definition: messageinterface.cpp:162
KTextEditor::View
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:146
QAction
QList
messageinterface.h
KTextEditor
Namespace for the KDE Text Editor Interfaces.
Definition: annotationinterface.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KTextEditor

Skip menu "KTextEditor"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal