XPlor/app/mainwindow.h
njohnson 57c7ee7de5 Enhance app UI with export integration and tab management
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>
2026-01-12 20:55:41 -05:00

117 lines
3.0 KiB
C++

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QFrame>
#include "typeregistry.h"
#include "treebuilder.h"
#include "settings.h"
struct DefinitionLoadResult {
QString filePath;
QString fileName;
bool success;
QString errorMessage;
};
class XTreeWidget;
class XTreeWidgetItem;
class QPlainTextEdit;
class QProgressBar;
class QUndoStack;
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void LoadDefinitions(); // For reparse
void setTypeRegistry(TypeRegistry&& registry, const QVector<DefinitionLoadResult>& results);
void LoadTreeCategories();
void Reset();
bool openFile(const QString& filePath); // Open and parse a file
const QVector<DefinitionLoadResult>& definitionResults() const { return mDefinitionResults; }
const TypeRegistry& typeRegistry() const { return mTypeRegistry; }
TreeBuilder& treeBuilder() { return mTreeBuilder; }
// Undo/Redo support
QUndoStack* undoStack() const { return mUndoStack; }
void pushFieldEdit(int journalId, const QString& fieldName,
const QVariant& oldValue, const QVariant& newValue);
private slots:
void HandleLogEntry(const QString &entry);
void HandleStatusUpdate(const QString &message, int timeout);
void HandleProgressUpdate(const QString &message, int progress, int max);
void applyTheme(const Theme &theme);
public:
// Save functionality for write-back
bool saveTab(QWidget* tab);
bool saveTabAs(QWidget* tab);
protected:
void dragEnterEvent(QDragEnterEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dropEvent(QDropEvent *event) override;
private:
Ui::MainWindow *ui;
XTreeWidget *mTreeWidget;
QPlainTextEdit *mLogWidget;
QProgressBar *mProgressBar;
QFrame *mRibbon;
TypeRegistry mTypeRegistry;
TreeBuilder mTreeBuilder;
QStringList mOpenedFilePaths; // Track opened files for reparsing
QVector<DefinitionLoadResult> mDefinitionResults;
// Undo/Redo support
QUndoStack *mUndoStack;
// Actions - File menu
QAction *actionNew;
QAction *actionOpen;
QAction *actionOpenFolder;
QAction *actionSave;
QAction *actionSaveAs;
// Actions - Edit menu
QAction *actionUndo;
QAction *actionRedo;
QAction *actionCut;
QAction *actionCopy;
QAction *actionPaste;
QAction *actionRename;
QAction *actionDelete;
QAction *actionFind;
QAction *actionClearUndoHistory;
QAction *actionPreferences;
// Actions - Tools menu
QAction *actionRunTests;
QAction *actionViewDefinitions;
// Actions - Help menu
QAction *actionAbout;
QAction *actionCheckForUpdates;
QAction *actionReportIssue;
// Actions - Toolbar
QAction *actionReparse;
};
#endif // MAINWINDOW_H