Major UI improvements across the application: MainWindow: - Integrate undo stack for field editing - Dirty state tracking with tab title indicators (*) - Save/SaveAs prompts on tab close with unsaved changes - Export menu integration in tab context menu - Tab management: close all, close left/right of current tab - Connect export system to tree widget signals XTreeWidget: - Add context menus for tree items - Quick export action for immediate saves - Export dialog action for format options - Raw data export for any item - Batch export for containers XTreeWidgetItem: - Add modified state tracking with visual indicator - Support for marking items as dirty ImagePreviewWidget: - Enhanced image display and navigation - Improved zoom and pan controls TreeBuilder: - Better handling of nested data structures - Improved child node generation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
84 lines
2.1 KiB
C++
84 lines
2.1 KiB
C++
#include "xtreewidgetitem.h"
|
|
|
|
XTreeWidgetItem::XTreeWidgetItem(QTreeWidget *parent, bool group)
|
|
: QTreeWidgetItem(parent)
|
|
, isGroup(group) {
|
|
|
|
}
|
|
|
|
XTreeWidgetItem::XTreeWidgetItem(QTreeWidgetItem *parent, bool group)
|
|
: QTreeWidgetItem(parent)
|
|
, isGroup(group) {
|
|
|
|
}
|
|
|
|
bool XTreeWidgetItem::operator<(const QTreeWidgetItem &other) const {
|
|
// Attempt to cast the other item to our custom type.
|
|
const XTreeWidgetItem* otherItem = dynamic_cast<const XTreeWidgetItem*>(&other);
|
|
if (otherItem) {
|
|
bool thisIsGroup = this->childCount() > 0;
|
|
bool otherIsGroup = otherItem->childCount() > 0;
|
|
|
|
if (thisIsGroup != otherIsGroup) {
|
|
return otherIsGroup; // Groups should come before non-groups
|
|
}
|
|
}
|
|
// Fallback to the default string comparison on the current sort column.
|
|
return QTreeWidgetItem::operator<(other);
|
|
}
|
|
|
|
|
|
XTreeWidgetItem& XTreeWidgetItem::operator=(const XTreeWidgetItem &other)
|
|
{
|
|
if (this != &other) {
|
|
// Copy text and icon for each column.
|
|
const int colCount = other.columnCount();
|
|
for (int i = 0; i < colCount; ++i) {
|
|
setText(i, other.text(i));
|
|
setIcon(i, other.icon(i));
|
|
}
|
|
// Copy custom members.
|
|
this->isGroup = other.isGroup;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
bool XTreeWidgetItem::GetIsGroup() const
|
|
{
|
|
return isGroup;
|
|
}
|
|
|
|
void XTreeWidgetItem::SetIsGroup(bool aIsGroup)
|
|
{
|
|
isGroup = aIsGroup;
|
|
}
|
|
|
|
void XTreeWidgetItem::setModified(bool modified)
|
|
{
|
|
if (m_modified == modified) return;
|
|
|
|
if (modified && m_originalText.isEmpty()) {
|
|
// Store original text before adding indicator
|
|
m_originalText = text(0);
|
|
}
|
|
|
|
m_modified = modified;
|
|
|
|
if (modified) {
|
|
// Add asterisk indicator
|
|
if (!text(0).endsWith(" *")) {
|
|
setText(0, m_originalText + " *");
|
|
}
|
|
} else {
|
|
// Remove asterisk indicator
|
|
if (!m_originalText.isEmpty()) {
|
|
setText(0, m_originalText);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool XTreeWidgetItem::isModified() const
|
|
{
|
|
return m_modified;
|
|
}
|