Debian Codegraph @

src/Base/FutureWatcherProgress.cpp

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2
3 /***************************************************************************
4 * Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
5 * *
6 * This file is part of the FreeCAD CAx development system. *
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Library General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Library General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Library General Public *
19 * License along with this library; see the file COPYING.LIB. If not, *
20 * write to the Free Software Foundation, Inc., 59 Temple Place, *
21 * Suite 330, Boston, MA 02111-1307, USA *
22 * *
23 ***************************************************************************/
24
25
26 #include "FutureWatcherProgress.h"
27
28 using namespace Base;
29
30 FutureWatcherProgress::FutureWatcherProgress(const char* text, unsigned int steps)
31 : seq(text, 100)
32 , steps(steps)
33 {}
34
35 FutureWatcherProgress::~FutureWatcherProgress() = default;
36
37 void FutureWatcherProgress::progressValueChanged(int value)
38 {
39 if (steps == 0) {
40 return;
41 }
42 unsigned int step = (100 * static_cast<unsigned int>(value)) / steps;
43 if (step > current) {
44 current = step;
45 seq.next();
46 }
47 }
48
49 #include "moc_FutureWatcherProgress.cpp"