Krita Source Code Documentation
Loading...
Searching...
No Matches
RecorderSnapshotsScanner Class Reference

#include <recorder_snapshots_scanner.h>

+ Inheritance diagram for RecorderSnapshotsScanner:

Signals

void scanningFinished (SnapshotDirInfoList snapshots)
 

Public Member Functions

 RecorderSnapshotsScanner ()
 
void setup (const QString &snapshotDirectory)
 
void stop ()
 
 ~RecorderSnapshotsScanner ()
 

Protected Member Functions

void run () override
 

Private Member Functions

SnapshotDirInfo readSnapshotDirInfo (const QString &path) const
 

Private Attributes

QString snapshotDirectory
 

Detailed Description

Definition at line 24 of file recorder_snapshots_scanner.h.

Constructor & Destructor Documentation

◆ RecorderSnapshotsScanner()

RecorderSnapshotsScanner::RecorderSnapshotsScanner ( )

Definition at line 21 of file recorder_snapshots_scanner.cpp.

22{
23 moveToThread(this);
24}

◆ ~RecorderSnapshotsScanner()

RecorderSnapshotsScanner::~RecorderSnapshotsScanner ( )

Definition at line 26 of file recorder_snapshots_scanner.cpp.

References stop().

Member Function Documentation

◆ readSnapshotDirInfo()

SnapshotDirInfo RecorderSnapshotsScanner::readSnapshotDirInfo ( const QString & path) const
private

Definition at line 72 of file recorder_snapshots_scanner.cpp.

73{
74 SnapshotDirInfo result;
75 QFileInfo fileInfo(path);
76 result.path = path;
77 result.name = fileInfo.fileName();
78
79 int recordIndex = -1;
80 QDirIterator dirIterator(path, QDir::Files | QDir::NoDotAndDotDot);
81 const QRegularExpression &snapshotFilePattern = RecorderConst::snapshotFilePatternFor(".*");
82
83 while (dirIterator.hasNext()) {
84 dirIterator.next();
85
86 if (isInterruptionRequested()) {
87 return {};
88 }
89
90 const QRegularExpressionMatch &match = snapshotFilePattern.match(dirIterator.fileName());
91 if (!match.hasMatch())
92 continue;
93
94 const QString &filePath = dirIterator.filePath();
95
96 fileInfo.setFile(filePath);
97 result.size += fileInfo.size();
98
99 int index = match.captured(1).toInt();
100 if (recordIndex < index) {
101 recordIndex = index;
102 result.thumbnail = filePath;
103 result.dateTime = fileInfo.lastModified();
104 }
105 }
106
107 return result;
108}
QRegularExpression snapshotFilePatternFor(const QString &extension)

References SnapshotDirInfo::dateTime, SnapshotDirInfo::name, SnapshotDirInfo::path, SnapshotDirInfo::size, RecorderConst::snapshotFilePatternFor(), and SnapshotDirInfo::thumbnail.

◆ run()

void RecorderSnapshotsScanner::run ( )
overrideprotected

Definition at line 50 of file recorder_snapshots_scanner.cpp.

51{
53
54 QDirIterator dirIterator(snapshotDirectory, QDir::Dirs | QDir::NoDotAndDotDot);
55
56 while (dirIterator.hasNext()) {
57 dirIterator.next();
58
59 const SnapshotDirInfo &info = readSnapshotDirInfo(dirIterator.filePath());
60 if (isInterruptionRequested()) {
61 return;
62 }
63 if (info.size > 0) {
64 result.append(info);
65 }
66 }
67
68 Q_EMIT scanningFinished(result);
69}
void scanningFinished(SnapshotDirInfoList snapshots)
SnapshotDirInfo readSnapshotDirInfo(const QString &path) const

References readSnapshotDirInfo(), scanningFinished(), SnapshotDirInfo::size, and snapshotDirectory.

◆ scanningFinished

void RecorderSnapshotsScanner::scanningFinished ( SnapshotDirInfoList snapshots)
signal

◆ setup()

void RecorderSnapshotsScanner::setup ( const QString & snapshotDirectory)

Definition at line 31 of file recorder_snapshots_scanner.cpp.

32{
33 this->snapshotDirectory = snapshotDirectory;
34}

References snapshotDirectory.

◆ stop()

void RecorderSnapshotsScanner::stop ( )

Definition at line 36 of file recorder_snapshots_scanner.cpp.

37{
38 if (!isRunning())
39 return;
40
41 requestInterruption();
43 terminate();
45 qCritical() << "Unable to stop RecorderSnapshotsScanner";
46 }
47 }
48}
constexpr int waitThreadTimeoutMs

References RecorderConst::waitThreadTimeoutMs.

Member Data Documentation

◆ snapshotDirectory

QString RecorderSnapshotsScanner::snapshotDirectory
private

Definition at line 44 of file recorder_snapshots_scanner.h.


The documentation for this class was generated from the following files: