EFileOps is a Qt/QML-based batch file renaming tool that adopts the classic MVC architecture pattern. Here, MVC doesn't refer to class inheritance relationships, but emphasizes the clear separation of responsibility boundaries.
Model ←→ View ←→ Controller
Core Components:
- Model:
FileListModel,FileService,RuleEngine,FileItem,RuleBase - View: QML UI Layer
- Controller:
MainController
Call Flow:
[ QML UI ]
↓ User Interaction
[ MainController ]
↓ Business Coordination
[ RuleEngine ] ← Rule Management & Execution
[ FileService ] ← File Data + History Management + Rename Execution
↓ Operation Objects
[ FileItem / RuleBase ] ← Domain Models
Responsibility: Acts as a bridge between UI and business layer, coordinating the work of various service modules.
Key Features:
- Exposes
Q_INVOKABLEmethods for QML calls (e.g.,addFiles,executeRename) - Manages the lifecycle of
FileServiceandRuleEngine - Handles session persistence (auto-save/restore working state)
- Import/export rule configurations (JSON format)
Responsibility: Manages file list, executes rename operations, maintains history records.
Core Capabilities:
- File Management: Add, delete, sort files
- Preview Generation: Calls RuleEngine to generate rename previews
- Atomic Execution: Batch renaming adopts
all-or-nothingstrategy, rollback all if any file fails - History Management: Records rename history, supports undo operations
Responsibility: Manages rule chain, executes rule sequences, generates rename results.
Rule Types:
- Replace: Find and replace
- Remove: Remove files containing keywords
- AddPrefix/AddSuffix: Add prefix/suffix
- CaseTransform: Case transformation
- Numbering: Number sequencing
Execution Model: Rules are applied sequentially, with each rule's output serving as input for the next rule (pipeline pattern).
Configuration Persistence: Rule configurations can be saved as JSON files, supporting import/export for reusing common rule combinations.
Responsibility: Serves as the data source for QML ListView, reactively synchronizing file list state.
Features:
- Implements
QAbstractListModelinterface - Lstens to FileService changes (add, delete, rename), updating UI in real-time
- Provides fields like index, original name, preview name, status for UI binding
1. User clicks "Execute" → MainController::executeRename()
2. FileService performs pre-checks (file existence, permission validation, target path conflict check)
3. Execute rename operations sequentially (using QDir::rename)
4. Record each successful operation for potential rollback
5. If any file fails → immediately rollback all successful operations
6. Update execution status, sort by failed/rollback/success, emit completion signal
1. User adds rule in right panel → QML calls MainController::addRule()
2. MainController uses RuleEngine::createRule() factory method to create rule instance
3. Rule is added to RuleEngine, triggering ruleCountChanged signal
4. MainController::addRule() automatically calls updatePreview()
5. RuleEngine applies rule chain to each file sequentially (pipeline pattern), generating new names
6. FileService::updatePreview() updates file's new name
7. FileListModel listens to changes, UI displays preview results in real-time
Auto-save: Automatically saves current file list and rule configuration to local JSON file when application exits.
Auto-restore: Checks settings on application startup, and loads last working state if auto-restore is enabled.
Configuration Path: Uses QStandardPaths::AppLocalDataLocation.