]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
final updates to ui/skip
authorgg <chown_tee@proton.me>
Mon, 19 Jan 2026 18:38:33 +0000 (13:38 -0500)
committergg <chown_tee@proton.me>
Mon, 19 Jan 2026 18:38:33 +0000 (13:38 -0500)
src/dialog/SyncRangeDialog.cpp
src/dialog/SyncRangeDialog.h
src/libwalletqt/Wallet.cpp
src/libwalletqt/Wallet.h

index 4e0edb9cb84fbccf42de1db4444d8ea082862b7e..cb4b5d8619531aacb6b1bf1a134adc5835b687be 100644 (file)
@@ -10,6 +10,7 @@
 #include <QSpinBox>
 #include <QDateEdit>
 #include <QLabel>
+#include <QTabWidget>
 #include <QDialogButtonBox>
 
 #include "utils/Utils.h"
@@ -25,7 +26,11 @@ SyncRangeDialog::SyncRangeDialog(QWidget *parent, Wallet *wallet)
     setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
 
     auto *layout = new QVBoxLayout(this);
-    auto *formLayout = new QFormLayout;
+    m_tabWidget = new QTabWidget(this);
+
+    // --- Date Tab ---
+    m_dateTab = new QWidget;
+    auto *formLayout = new QFormLayout(m_dateTab);
     formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
 
     m_toDateEdit = new QDateEdit(QDate::currentDate());
@@ -61,17 +66,44 @@ SyncRangeDialog::SyncRangeDialog(QWidget *parent, Wallet *wallet)
     m_fromDateEdit->setDisplayFormat("yyyy-MM-dd");
     m_fromDateEdit->setToolTip(tr("Calculated from 'End date' and day span."));
 
-    m_infoLabel = new QLabel;
-    m_infoLabel->setWordWrap(true);
-    m_infoLabel->setStyleSheet("QLabel { color: #888; font-size: 11px; }");
-
     formLayout->addRow(tr("Day span:"), daysLayout);
     formLayout->addRow(tr("Start date:"), m_fromDateEdit);
     formLayout->addRow(tr("End date:"), m_toDateEdit);
 
-    layout->addLayout(formLayout);
+    m_tabWidget->addTab(m_dateTab, tr("Date Range"));
+
+    // --- Block Tab ---
+    m_blockTab = new QWidget;
+    auto *blockLayout = new QFormLayout(m_blockTab);
+
+    quint64 currentHeight = m_wallet->blockChainHeight();
+    quint64 daemonHeight = m_wallet->daemonBlockChainHeight();
+    quint64 targetHeight = (daemonHeight > 0) ? daemonHeight : currentHeight;
+
+    m_startHeightSpin = new QSpinBox;
+    m_startHeightSpin->setRange(0, 9999999);
+    m_startHeightSpin->setValue(std::max((quint64)0, targetHeight - 5040)); // Approx 7 days
+
+    m_endHeightSpin = new QSpinBox;
+    m_endHeightSpin->setRange(0, 9999999);
+    m_endHeightSpin->setValue(targetHeight);
+
+    blockLayout->addRow(tr("Start Height:"), m_startHeightSpin);
+    blockLayout->addRow(tr("End Height:"), m_endHeightSpin);
+
+    m_tabWidget->addTab(m_blockTab, tr("Block Height"));
+
+    m_infoLabel = new QLabel;
+    m_infoLabel->setWordWrap(true);
+    m_infoLabel->setStyleSheet("QLabel { color: #888; font-size: 11px; }");
+
+    layout->addWidget(m_tabWidget);
     layout->addWidget(m_infoLabel);
 
+    connect(m_tabWidget, &QTabWidget::currentChanged, this, &SyncRangeDialog::updateInfo);
+    connect(m_startHeightSpin, QOverload<int>::of(&QSpinBox::valueChanged), this, &SyncRangeDialog::updateInfo);
+    connect(m_endHeightSpin, QOverload<int>::of(&QSpinBox::valueChanged), this, &SyncRangeDialog::updateInfo);
+
     connect(m_fromDateEdit, &QDateEdit::dateChanged, this, &SyncRangeDialog::updateToDate);
     connect(m_toDateEdit, &QDateEdit::dateChanged, this, &SyncRangeDialog::updateFromDate);
     connect(m_daysSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &SyncRangeDialog::updateFromDate);
@@ -116,26 +148,48 @@ quint64 SyncRangeDialog::estimatedSize() const {
     return m_estimatedSize;
 }
 
+quint64 SyncRangeDialog::startHeight() const {
+    return m_startHeightSpin->value();
+}
+
+quint64 SyncRangeDialog::endHeight() const {
+    return m_endHeightSpin->value();
+}
+
+SyncRangeDialog::Mode SyncRangeDialog::mode() const {
+    if (m_tabWidget->currentIndex() == 1) return Mode_Block;
+    return Mode_Date;
+}
+
 void SyncRangeDialog::updateInfo() {
-    NetworkType::Type nettype = m_wallet->nettype();
-    QString filename = Utils::getRestoreHeightFilename(nettype);
-    std::unique_ptr<RestoreHeightLookup> lookup(RestoreHeightLookup::fromFile(filename, nettype));
-    if (!lookup || lookup->data.isEmpty()) {
-        m_infoLabel->setText(tr("Unable to estimate - restore height data unavailable"));
-        m_estimatedBlocks = 0;
-        m_estimatedSize = 0;
-        return;
-    }
+    if (this->mode() == Mode_Block) {
+        quint64 start = m_startHeightSpin->value();
+        quint64 end = m_endHeightSpin->value();
+
+        m_estimatedBlocks = (end > start) ? (end - start) : 0;
+        m_estimatedSize = Utils::estimateSyncDataSize(m_estimatedBlocks);
+    } 
+    else {
+        NetworkType::Type nettype = m_wallet->nettype();
+        QString filename = Utils::getRestoreHeightFilename(nettype);
+        std::unique_ptr<RestoreHeightLookup> lookup(RestoreHeightLookup::fromFile(filename, nettype));
+        if (!lookup || lookup->data.isEmpty()) {
+            m_infoLabel->setText(tr("Unable to estimate - restore height data unavailable"));
+            m_estimatedBlocks = 0;
+            m_estimatedSize = 0;
+            return;
+        }
 
-    QDate start = m_fromDateEdit->date();
-    QDate end = m_toDateEdit->date();
+        QDate start = m_fromDateEdit->date();
+        QDate end = m_toDateEdit->date();
 
-    uint64_t startHeight = lookup->dateToHeight(start.startOfDay().toSecsSinceEpoch());
-    uint64_t endHeight = lookup->dateToHeight(end.endOfDay().toSecsSinceEpoch());
+        uint64_t startHeight = lookup->dateToHeight(start.startOfDay().toSecsSinceEpoch());
+        uint64_t endHeight = lookup->dateToHeight(end.endOfDay().toSecsSinceEpoch());
 
-    if (endHeight < startHeight) endHeight = startHeight;
-    m_estimatedBlocks = endHeight - startHeight;
-    m_estimatedSize = Utils::estimateSyncDataSize(m_estimatedBlocks);
+        if (endHeight < startHeight) endHeight = startHeight;
+        m_estimatedBlocks = endHeight - startHeight;
+        m_estimatedSize = Utils::estimateSyncDataSize(m_estimatedBlocks);
+    }
 
     m_infoLabel->setText(tr("Scanning ~%1 blocks\nEst. download size: %2")
                            .arg(m_estimatedBlocks)
index fc8801fcebfb11a41a4ca445ece112790ca6c976..26194306832e8e172312d91e8904cf717e68eeb0 100644 (file)
@@ -13,6 +13,7 @@ class QComboBox;
 class QSpinBox;
 class QDateEdit;
 class QLabel;
+class QTabWidget;
 
 class SyncRangeDialog : public QDialog
 {
@@ -22,10 +23,18 @@ public:
     explicit SyncRangeDialog(QWidget *parent, Wallet *wallet);
     ~SyncRangeDialog() override = default;
 
+    enum Mode {
+        Mode_Date,
+        Mode_Block
+    };
+
     QDate fromDate() const;
     QDate toDate() const;
+    quint64 startHeight() const;
+    quint64 endHeight() const;
     quint64 estimatedBlocks() const;
     quint64 estimatedSize() const;
+    Mode mode() const;
 
 private:
     void updateInfo();
@@ -33,10 +42,20 @@ private:
     void updateToDate();
 
     Wallet *m_wallet;
+    QTabWidget *m_tabWidget;
+    QWidget *m_dateTab;
+    QWidget *m_blockTab;
+
+    // Date/Time
     QComboBox *m_presetCombo;
     QSpinBox *m_daysSpinBox;
     QDateEdit *m_fromDateEdit;
     QDateEdit *m_toDateEdit;
+
+    // Blocks
+    QSpinBox *m_startHeightSpin;
+    QSpinBox *m_endHeightSpin;
+
     QLabel *m_infoLabel;
 
     quint64 m_estimatedBlocks = 0;
index 543c2301c45beb57f8438543e44210916fa5b046..5f2a2bc1473989774bd732cf02d23c6877259e05 100644 (file)
@@ -706,7 +706,8 @@ void Wallet::skipToTip() {
     m_wallet2->set_refresh_from_block_height(target);
     m_lastSyncTime = QDateTime::currentDateTime();
 
-    pauseRefresh();
+    setConnectionStatus(ConnectionStatus_Synchronized);
+    startRefresh();
     emit syncStatus(target, target, true);
 }
 
@@ -731,7 +732,24 @@ void Wallet::syncDateRange(const QDate &start, const QDate &end) {
         m_rangeSyncActive = true;
         m_wallet2->set_refresh_from_block_height(startHeight);
     }
-    pauseRefresh();
+    setConnectionStatus(ConnectionStatus_Synchronizing);
+    startRefresh();
+}
+
+void Wallet::scanBlockRange(quint64 start, quint64 end) {
+    if (!m_wallet2) return;
+
+    // Minimal sanity checks
+    if (start >= end) return;
+
+    {
+        QMutexLocker locker(&m_asyncMutex);
+        m_stopHeight = end;
+        m_rangeSyncActive = true;
+        m_wallet2->set_refresh_from_block_height(start);
+    }
+
+    setConnectionStatus(ConnectionStatus_Synchronizing);
     startRefresh();
 }
 
@@ -760,7 +778,7 @@ void Wallet::fullSync() {
         m_wallet2->set_refresh_from_block_height(originalHeight);
     }
     // Trigger rescan
-    pauseRefresh();
+    setConnectionStatus(ConnectionStatus_Synchronizing);
     startRefresh();
 
     qInfo() << "Full Sync triggered. Rescanning from original restore height:" << originalHeight;
index 7a4a80e6dfb5c2d000ae29482d6a8146a42fd29a..c22072942af4066367796df9b049273aecf88227 100644 (file)
@@ -239,6 +239,7 @@ public:
     void setSyncPaused(bool paused);
     Q_INVOKABLE void skipToTip();
     Q_INVOKABLE void syncDateRange(const QDate &start, const QDate &end);
+    Q_INVOKABLE void scanBlockRange(quint64 start, quint64 end);
     void fullSync(); // Rescans from wallet creation height, not genesis block
 
     bool importTransaction(const QString &txid);