diff options
| author | Mason Reed <mason@vector35.com> | 2026-03-13 12:24:18 -0700 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2026-03-24 18:46:48 -0700 |
| commit | 3c88b11e5df33116580ac008e36092775df66135 (patch) | |
| tree | cd64fbe149f05683ddabcccd0db7b87356f1f8cf /plugins/warp/ui/shared/file.cpp | |
| parent | f325aa7b6026a1daef84931baeb1f50d7da10c10 (diff) | |
[WARP] Improved UX and API
- Exposes WARP type objects directly
- Adds processor API (for generating warp files directly)
- Adds file and chunk API
- Misc cleanup
- Simplified the amount of commands
- Replaced the "Create" commands with a purpose built processor dialog
- Added a native QT viewer for WARP files
- Simplified committing to a remote with a purpose built commit dialog
Diffstat (limited to 'plugins/warp/ui/shared/file.cpp')
| -rw-r--r-- | plugins/warp/ui/shared/file.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/plugins/warp/ui/shared/file.cpp b/plugins/warp/ui/shared/file.cpp new file mode 100644 index 00000000..70a169fe --- /dev/null +++ b/plugins/warp/ui/shared/file.cpp @@ -0,0 +1,71 @@ +#include "file.h" + +#include <QVBoxLayout> + +FileWidget::FileWidget(QWidget* parent) : QWidget(parent) +{ + auto* layout = new QVBoxLayout(this); + layout->setContentsMargins(0, 0, 0, 0); + + auto* splitter = new QSplitter(Qt::Horizontal, this); + + // Left side: List of chunks + m_list = new QListWidget(this); + m_list->setSelectionMode(QAbstractItemView::SingleSelection); + m_list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_list->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); + m_list->setUniformItemSizes(true); + connect(m_list, &QListWidget::itemSelectionChanged, this, &FileWidget::onListSelectionChanged); + splitter->addWidget(m_list); + + // Right side: Chunk Widget + m_chunkWidget = new ChunkWidget(this); + splitter->addWidget(m_chunkWidget); + + splitter->setSizes({100, 900}); + layout->addWidget(splitter); +} + +void FileWidget::setFile(Warp::Ref<Warp::File> file) +{ + m_file = file; + m_list->clear(); + m_chunkWidget->setChunk(nullptr); + m_currentChunks.clear(); + + if (!m_file) + return; + + m_currentChunks = m_file->GetChunks(); + for (size_t i = 0; i < m_currentChunks.size(); ++i) + { + auto* listItem = new QListWidgetItem(m_list); + listItem->setText(QString("Chunk #%1").arg(i + 1)); + // Store the chunk index in the item's data for easy retrieval + listItem->setData(Qt::UserRole, QVariant::fromValue(static_cast<qulonglong>(i))); + } + + if (m_list->count() > 0) + m_list->setCurrentRow(0); +} + +void FileWidget::onListSelectionChanged() +{ + auto selectedItems = m_list->selectedItems(); + if (selectedItems.isEmpty()) + { + m_chunkWidget->setChunk(nullptr); + return; + } + + auto* item = selectedItems.first(); + QVariant data = item->data(Qt::UserRole); + if (data.isValid()) + { + size_t index = data.value<qulonglong>(); + if (index < m_currentChunks.size()) + { + m_chunkWidget->setChunk(m_currentChunks[index]); + } + } +}
\ No newline at end of file |
