KNewStuff

question.cpp
1 /*
2  This file is part of KNewStuffCore.
3  SPDX-FileCopyrightText: 2016 Dan Leinir Turthra Jensen <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7 
8 #include "question.h"
9 
10 #include "questionmanager.h"
11 
12 #include <QCoreApplication>
13 
14 using namespace KNSCore;
15 
16 class Question::Private {
17 public:
18  Private()
19  : questionType(YesNoQuestion)
20  , response(InvalidResponse)
21  {}
22  QString question;
23  QString title;
25 
26  bool questionActive = false;
27  Question::QuestionType questionType;
28  Question::Response response;
29  QString textResponse;
30 };
31 
32 Question::Question(QuestionType questionType, QObject *parent)
33  : QObject(parent)
34  , d(new Private)
35 {
36  d->questionType = questionType;
37 }
38 
39 Question::~Question()
40 {
41  delete d;
42 }
43 
44 Question::Response Question::ask()
45 {
46  d->questionActive = true;
47 
48  Q_EMIT QuestionManager::instance()->askQuestion(this);
49  while(d->questionActive)
50  {
51  qApp->processEvents();
52  }
53 
54  return d->response;
55 }
56 
57 Question::QuestionType Question::questionType() const
58 {
59  return d->questionType;
60 }
61 
62 void Question::setQuestionType(Question::QuestionType newType)
63 {
64  d->questionType = newType;
65 }
66 
67 void Question::setQuestion(const QString &newQuestion)
68 {
69  d->question = newQuestion;
70 }
71 
72 QString Question::question() const
73 {
74  return d->question;
75 }
76 
77 void Question::setTitle(const QString &newTitle)
78 {
79  d->title = newTitle;
80 }
81 
82 QString Question::title() const
83 {
84  return d->title;
85 }
86 
87 void Question::setList(const QStringList &newList)
88 {
89  d->list = newList;
90 }
91 
92 QStringList Question::list() const
93 {
94  return d->list;
95 }
96 
97 void Question::setResponse(Response response)
98 {
99  d->response = response;
100  d->questionActive = false;
101 }
102 
103 void Question::setResponse(const QString &response)
104 {
105  d->textResponse = response;
106 }
107 
108 QString Question::response() const
109 {
110  return d->textResponse;
111 }
Contains the core functionality for handling interaction with NewStuff providers. ...
QObject * parent() const const
Q_EMITQ_EMIT
KIOFILEWIDGETS_EXPORT QStringList list(const QString &fileClass)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 18 2021 22:43:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.