• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.11.5 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 
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;
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Mon May 5 2014 18:23:40 by doxygen 1.8.3.1 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.11.5 API Reference

Skip menu "kdelibs-4.11.5 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