KNewStuff

question.cpp
1 /*
2  This file is part of KNewStuffCore.
3 
4  Copyright (c) 2016 Dan Leinir Turthra Jensen <[email protected]>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "question.h"
21 
22 #include "questionmanager.h"
23 
24 #include <QCoreApplication>
25 
26 using namespace KNSCore;
27 
28 class Question::Private {
29 public:
30  Private()
31  : questionActive(false)
32  , questionType(YesNoQuestion)
33  , response(InvalidResponse)
34  {}
35  QString question;
36  QString title;
38 
39  bool questionActive;
40  Question::QuestionType questionType;
41  Question::Response response;
42  QString textResponse;
43 };
44 
45 Question::Question(QuestionType questionType, QObject *parent)
46  : QObject(parent)
47  , d(new Private)
48 {
49  d->questionType = questionType;
50 }
51 
52 Question::~Question()
53 {
54  delete d;
55 }
56 
57 Question::Response Question::ask()
58 {
59  d->questionActive = true;
60 
61  emit QuestionManager::instance()->askQuestion(this);
62  while(d->questionActive)
63  {
64  qApp->processEvents();
65  }
66 
67  return d->response;
68 }
69 
70 Question::QuestionType Question::questionType() const
71 {
72  return d->questionType;
73 }
74 
75 void Question::setQuestionType(Question::QuestionType newType)
76 {
77  d->questionType = newType;
78 }
79 
80 void Question::setQuestion(const QString &newQuestion)
81 {
82  d->question = newQuestion;
83 }
84 
85 QString Question::question() const
86 {
87  return d->question;
88 }
89 
90 void Question::setTitle(const QString &newTitle)
91 {
92  d->title = newTitle;
93 }
94 
95 QString Question::title() const
96 {
97  return d->title;
98 }
99 
100 void Question::setList(const QStringList &newList)
101 {
102  d->list = newList;
103 }
104 
105 QStringList Question::list() const
106 {
107  return d->list;
108 }
109 
110 void Question::setResponse(Response response)
111 {
112  d->response = response;
113  d->questionActive = false;
114 }
115 
116 void Question::setResponse(const QString &response)
117 {
118  d->textResponse = response;
119 }
120 
121 QString Question::response() const
122 {
123  return d->textResponse;
124 }
void setResponse(Response response)
When the user makes a choice on a question, that is a response.
Definition: question.cpp:110
Contains the core functionality for handling interaction with NewStuff providers. ...
QObject * parent() const const
KIOFILEWIDGETS_EXPORT QStringList list(const QString &fileClass)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Aug 9 2020 22:43:40 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.