• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

KTextEditor

  • kde-4.14
  • applications
  • kate
  • 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 
23 namespace KTextEditor {
24 
25 class 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 
41 Message::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 
55 Message::~Message()
56 {
57  emit closed(this);
58 
59  delete d;
60 }
61 
62 QString Message::text() const
63 {
64  return d->text;
65 }
66 
67 void Message::setText(const QString& text)
68 {
69  if (d->text != text) {
70  d->text = text;
71  emit textChanged(text);
72  }
73 }
74 
75 void Message::setIcon(const QIcon& newIcon)
76 {
77  d->icon = newIcon;
78  emit iconChanged(d->icon);
79 }
80 
81 QIcon Message::icon() const
82 {
83  return d->icon;
84 }
85 
86 Message::MessageType Message::messageType() const
87 {
88  return d->messageType;
89 }
90 
91 void 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 
102 QList<QAction*> Message::actions() const
103 {
104  return d->actions;
105 }
106 
107 void Message::setAutoHide(int autoHideTimer)
108 {
109  d->autoHide = autoHideTimer;
110 }
111 
112 int Message::autoHide() const
113 {
114  return d->autoHide;
115 }
116 
117 void Message::setAutoHideMode(KTextEditor::Message::AutoHideMode mode)
118 {
119  d->autoHideMode = mode;
120 }
121 
122 KTextEditor::Message::AutoHideMode Message::autoHideMode() const
123 {
124  return d->autoHideMode;
125 }
126 
127 void Message::setWordWrap(bool wordWrap)
128 {
129  d->wordWrap = wordWrap;
130 }
131 
132 bool Message::wordWrap() const
133 {
134  return d->wordWrap;
135 }
136 
137 void Message::setPriority(int priority)
138 {
139  d->priority = priority;
140 }
141 
142 int Message::priority() const
143 {
144  return d->priority;
145 }
146 
147 void Message::setView(KTextEditor::View* view)
148 {
149  d->view = view;
150 }
151 
152 KTextEditor::View* Message::view() const
153 {
154  return d->view;
155 }
156 
157 void Message::setDocument(KTextEditor::Document* document)
158 {
159  d->document = document;
160 }
161 
162 KTextEditor::Document* Message::document() const
163 {
164  return d->document;
165 }
166 
167 void Message::setPosition(Message::MessagePosition position)
168 {
169  d->position = position;
170 }
171 
172 Message::MessagePosition Message::position() const
173 {
174  return d->position;
175 }
176 
177 
178 
179 MessageInterface::MessageInterface()
180  : d (0)
181 {
182 }
183 
184 MessageInterface::~MessageInterface()
185 {
186 }
187 
188 }
189 
190 // kate: space-indent on; indent-width 2; replace-tabs on;
KTextEditor::MessageInterface::~MessageInterface
virtual ~MessageInterface()
Destructor, for internal use.
Definition: messageinterface.cpp:184
KTextEditor::Message::view
KTextEditor::View * view() const
This function returns the view you set by setView().
Definition: messageinterface.cpp:152
KTextEditor::Message::priority
int priority() const
Returns the priority of the message.
Definition: messageinterface.cpp:142
KTextEditor::Message::AfterUserInteraction
auto-hide is triggered only after the user interacted with the view
Definition: messageinterface.h:128
KTextEditor::Message::setDocument
void setDocument(KTextEditor::Document *document)
Set the document pointer to document.
Definition: messageinterface.cpp:157
KTextEditor::Message::setIcon
void setIcon(const QIcon &icon)
Optionally set an icon for this notification.
Definition: messageinterface.cpp:75
KTextEditor::Message::icon
QIcon icon() const
Returns the icon of this message.
Definition: messageinterface.cpp:81
KTextEditor::Message::iconChanged
void iconChanged(const QIcon &icon)
This signal is emitted whenever setIcon() is called.
KTextEditor::Message::setView
void setView(KTextEditor::View *view)
Set the associated view of the message.
Definition: messageinterface.cpp:147
KTextEditor::Message::textChanged
void textChanged(const QString &text)
This signal is emitted whenever setText() is called.
KTextEditor::Message::wordWrap
bool wordWrap() const
Check, whether word wrap is enabled or not.
Definition: messageinterface.cpp:132
KTextEditor::MessageInterface::MessageInterface
MessageInterface()
Default constructor, for internal use.
Definition: messageinterface.cpp:179
KTextEditor::Message::position
MessagePosition position() const
Returns the desired message position of this message.
Definition: messageinterface.cpp:172
KTextEditor::Message::setAutoHide
void setAutoHide(int autoHideTimer=0)
Set the auto hide timer to autoHideTimer milliseconds.
Definition: messageinterface.cpp:107
messageinterface.h
KTextEditor::Document
A KParts derived class representing a text document.
Definition: document.h:111
KTextEditor::Message::document
KTextEditor::Document * document() const
Returns the document pointer this message was posted in.
Definition: messageinterface.cpp:162
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::AboveView
show message above view
Definition: messageinterface.h:116
QObject::deleteLater
void deleteLater()
QString
QList< QAction * >
KTextEditor::Message::setPosition
void setPosition(MessagePosition position)
Sets the position either to AboveView or BelowView.
Definition: messageinterface.cpp:167
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::text
QString text() const
Returns the text set in the constructor.
Definition: messageinterface.cpp:62
QObject::setParent
void setParent(QObject *parent)
KTextEditor::Message::setAutoHideMode
void setAutoHideMode(KTextEditor::Message::AutoHideMode mode)
Sets the autoHide mode to mode.
Definition: messageinterface.cpp:117
KTextEditor::Message::~Message
virtual ~Message()
Destructor.
Definition: messageinterface.cpp:55
KTextEditor::Message::autoHideMode
KTextEditor::Message::AutoHideMode autoHideMode() const
Get the Message's autoHide mode.
Definition: messageinterface.cpp:122
KTextEditor::Message::Message
Message(const QString &richtext, MessageType type=Message::Information)
Constructor for new messages.
Definition: messageinterface.cpp:41
KTextEditor::Message::autoHide
int autoHide() const
Returns the auto hide time in milliseconds.
Definition: messageinterface.cpp:112
KTextEditor::Message::MessageType
MessageType
Message types used as visual indicator.
Definition: messageinterface.h:104
KTextEditor::Message::setWordWrap
void setWordWrap(bool wordWrap)
Enabled word wrap according to wordWrap.
Definition: messageinterface.cpp:127
QAction
KTextEditor::Message::messageType
MessageType messageType() const
Returns the message type set in the constructor.
Definition: messageinterface.cpp:86
KTextEditor::Message::AutoHideMode
AutoHideMode
The AutoHideMode determines when to trigger the autoHide timer.
Definition: messageinterface.h:126
KTextEditor::View
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:145
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KTextEditor::Message::setPriority
void setPriority(int priority)
Set the priority of this message to priority.
Definition: messageinterface.cpp:137
KTextEditor::Message::closed
void closed(KTextEditor::Message *message)
This signal is emitted before the message is deleted.
QIcon
KTextEditor::Message::setText
void setText(const QString &richtext)
Sets the notification contents to text.
Definition: messageinterface.cpp:67
KTextEditor::Message::addAction
void addAction(QAction *action, bool closeOnTrigger=true)
Adds an action to the message.
Definition: messageinterface.cpp:91
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:48 by doxygen 1.8.7 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

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



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