-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartitionDialog.h
More file actions
110 lines (92 loc) · 3.69 KB
/
PartitionDialog.h
File metadata and controls
110 lines (92 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2026 Reikooters <https://github.com/Reikooters>
#ifndef KERYTHING_PARTITIONDIALOG_H
#define KERYTHING_PARTITIONDIALOG_H
#include <QDialog>
#include <QString>
#include <QTreeWidget>
#include <QLabel>
#include <QPushButton>
#include <QProgressBar>
#include <QVariantMap>
#include <QtDBus/QDBusServiceWatcher>
#include <vector>
#include <optional>
#include "ScannerEngine.h"
#include "ScannerManager.h"
/**
* @brief Represents basic information about a detected disk partition.
*/
struct PartitionInfo {
QString deviceId; // e.g. "partuuid:...." (daemon identity)
QString fsType; // e.g. "ntfs" / "ext4"
QString name; // label or human-friendly string
QString devicePath; // current /dev/... node
QString mountPoint; // primary mount point or "Not Mounted"
};
/**
* @brief A dialog that allows users to select a partition and triggers the scanning process.
*/
class PartitionDialog : public QDialog {
Q_OBJECT
public:
/**
* @brief Constructs the dialog and populates the list with available partitions.
*/
explicit PartitionDialog(QWidget *parent = nullptr);
/**
* @brief Clears the list and re-scans for partitions.
*/
void refreshPartitions();
/**
* @brief Handles the 'Start' button click. Triggers the scanning helper or requests cancellation if already running.
*/
void onStartClicked();
/**
* @brief Transfers ownership of the scanned database out of the dialog.
* @return An optional containing the database if scanning was successful.
*/
std::optional<ScannerEngine::SearchDatabase> takeDatabase();
/**
* @brief Updates the UI state (buttons, labels, list) based on whether a scan is currently active.
*/
void setScanning(bool scanning);
/**
* @brief Manually enables or disables the action button.
*/
void setButtonEnabled(bool enabled) const;
/**
* @brief Returns the PartitionInfo for the currently selected item in the list.
*/
PartitionInfo getSelected();
// /**
// * @brief Retrieves a list of partitions currently selected in the dialog.
// *
// * This method scans the partition list UI for selected items and compiles their
// * details into a list of PartitionInfo objects.
// *
// * @return A list of PartitionInfo objects representing the selected partitions.
// */
// QList<PartitionInfo> getSelectedPartitions();
private slots:
void onDaemonJobProgress(quint64 jobId, quint32 percent, const QVariantMap& props);
void onDaemonJobFinished(quint64 jobId, const QString& status, const QString& message, const QVariantMap& props);
void onDaemonVanished(const QString& serviceName);
private:
void connectDaemonSignals();
std::optional<ScannerEngine::SearchDatabase> m_scannedDb; ///< Storage for the database returned by the helper
std::unique_ptr<ScannerManager> m_manager; ///< Helper process manager
bool m_isHandlingClick = false; ///< Prevents re-entrant clicks
QTreeWidget *treeWidget; ///< Table of detected partitions
QLabel *statusLabel; ///< Label showing instructions or scan status
QPushButton *startBtn; ///< Action button (Start Indexing / Cancel)
QPushButton *refreshBtn; ///< Action button (Refresh)
std::vector<PartitionInfo> partitions; ///< Internal metadata for the list items
QProgressBar *progressBar; ///< Progress bar showing scanner progress
// Daemon job state (Phase 1 verification)
bool m_daemonSignalsConnected = false;
bool m_isDaemonScanActive = false;
quint64 m_activeJobId = 0;
QDBusServiceWatcher* m_daemonWatcher = nullptr;
};
#endif //KERYTHING_PARTITIONDIALOG_H