AstRawDark
Manage your astrophoto dark frames
 All Classes Functions Variables Enumerations Enumerator Pages
scanDarkSourceCommand.cpp
1 /*
2  * AstRawDark
3  *
4  * Copyright (C) 2015 - Frédéric CORNU
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "scanDarkSourceCommand.h"
21 #include "signalDispatcher.h"
22 
23 #include <QStringList>
24 #include <QFileInfoList>
25 #include <QDir>
26 
27 #ifndef QT_NO_DEBUG
28 #include <QDebug>
29 #endif
30 
33 {
34  _description = QString(tr("Dark library scan"));
35 
36  connect(this,
40 
41  connect(this,
45 }
46 
47 void ScanDarkSourceCommand::checkForErrors()
48 {
49  /*
50  * If dark sources were missing, update error message
51  */
52  if ( ! _missingDirsPaths.isEmpty() ) {
53 
54  _warning = true;
55 
56  QString msg = tr("WARNING - Ignored %1 missing dark source folder")
57  .arg(_missingDirsPaths.count());
58 
59  _reportMessages << msg;
60 
61  _commandReport.addSection(msg, _missingDirsPaths);
62  }
63 
65 }
66 
68 {
69  emit scanStarted();
70 
71  if ( ! _sources.isEmpty() ) {
72 
73  foreach (QString path, _sources) {
74 
75  /*
76  * If current dark source folder is missing,
77  * we skip it and store its path for error display
78  */
79  if ( ! QDir(path).exists() ) {
80 
81  _missingDirsPaths << path;
82  continue;
83  }
84 
86  }
87 
89 
90  /*
91  * If we saw short frames, update warnings & errors
92  */
93  checkForErrors();
94 
95  // tell the world we're done
96  emit scanDone(_imageInfos);
97  }
98 }
99