musredit 1.0.0
Loading...
Searching...
No Matches
PReplaceConfirmationDialog Class Reference

Confirmation dialog for interactive find-and-replace operations. More...

#include <PReplaceConfirmationDialog.h>

Inheritance diagram for PReplaceConfirmationDialog:
Collaboration diagram for PReplaceConfirmationDialog:

Public Member Functions

 PReplaceConfirmationDialog (QWidget *parent=nullptr)
 Constructs the replace confirmation dialog.
 
virtual ~PReplaceConfirmationDialog ()
 Virtual destructor.
 

Detailed Description

Confirmation dialog for interactive find-and-replace operations.

This dialog provides user control over individual replacement operations during interactive find-and-replace sessions in musredit. When the user performs a "Replace" (as opposed to "Replace All") operation, this dialog appears for each match, allowing fine-grained control over which instances should be replaced.

Dialog Purpose:
The dialog serves as an interactive confirmation mechanism that prevents unintended replacements by giving users the opportunity to review each match before replacement occurs.
Typical User Actions:
The dialog typically provides several options (exact buttons defined in UI):
  • Replace: Confirm this replacement and move to next match
  • Skip: Leave this match unchanged and move to next match
  • Replace All: Replace this and all remaining matches without further confirmation
  • Cancel/Close: Abort the replace operation entirely
Usage Context:
This dialog is invoked during interactive find-and-replace workflows:
  1. User opens Find/Replace dialog (Edit → Find/Replace)
  2. User enters search term and replacement text
  3. User clicks "Replace" button (not "Replace All")
  4. Editor finds first match and shows context
  5. This confirmation dialog appears
  6. User makes decision (replace/skip/etc.)
  7. Process repeats for next match until completion or cancellation
Dialog Behavior:
  • Modal: Blocks interaction with main editor until decision is made
  • Non-resizable: Fixed size appropriate for decision buttons
  • Centered over parent: Appears centered on the editor window
  • Quick keyboard access: Buttons typically have keyboard shortcuts
Integration:
The dialog integrates with musredit's find-and-replace engine, which:
  • Highlights the current match in the editor
  • Manages the search state across multiple matches
  • Executes the replacement based on user choice
  • Advances to the next match after each decision
Note
The dialog is modal, requiring explicit user action before continuing.
Return values (via exec()) indicate the user's choice for action.
The actual button configuration and return values are defined in the UI file and handled by the calling find-and-replace code.
See also
musredit For the main text editor with find-and-replace functionality
PFindDialog For the primary find/replace dialog interface

Definition at line 110 of file PReplaceConfirmationDialog.h.

Constructor & Destructor Documentation

◆ PReplaceConfirmationDialog()

PReplaceConfirmationDialog::PReplaceConfirmationDialog ( QWidget * parent = nullptr)

Constructs the replace confirmation dialog.

Constructor - Initializes the replace confirmation dialog.

Initializes the dialog with a simple confirmation interface for find-and-replace operations. The dialog is configured as modal to ensure users make an explicit decision before continuing with the replacement process.

The constructor sets up the UI from the Qt Designer UI file and configures basic dialog properties. The actual button configuration, labels, and layout are defined in the UI file.

Parameters
parentPointer to the parent widget (typically the main editor window). If nullptr, the dialog has no parent. The parent-child relationship ensures:
  • Proper dialog centering over the parent window
  • Automatic cleanup when parent is destroyed
  • Consistent styling and theme inheritance
Note
The dialog is created but not shown by the constructor. The caller must invoke exec() to display it modally.
Parent ownership is recommended to ensure proper cleanup and visual integration with the main application.
See also
exec() Qt method to display the dialog and wait for user response
setupUi() Qt Designer generated UI initialization

Sets up a simple, focused dialog for confirming individual replacements during interactive find-and-replace operations. The initialization is minimal, establishing only the essential dialog configuration for user interaction.

Initialization Process:

  1. Base Class Initialization: Calls QDialog constructor with parent widget to establish proper parent-child relationship
  2. UI Setup: Loads the dialog layout, labels, and buttons from the Qt Designer UI file via setupUi(). The UI file defines:
    • Dialog title and dimensions
    • Confirmation message text
    • Action buttons (Replace, Skip, Replace All, Cancel, etc.)
    • Button layout and spacing
    • Keyboard shortcuts for quick access
  3. Modal Configuration: Sets the dialog as modal using setModal(true), ensuring that:
    • The dialog blocks interaction with the main editor
    • User must make an explicit decision
    • No other editor operations can occur until dialog is closed
    • Focus remains on the dialog until user responds

Dialog Workflow:

After construction, the typical usage pattern is:

  1. Caller creates dialog instance (this constructor executes)
  2. Caller updates dialog text to show current match context (optional)
  3. Caller invokes exec() to display dialog and wait for user response
  4. User clicks a button (Replace, Skip, Replace All, Cancel)
  5. Dialog returns with appropriate QDialog result code
  6. Caller interprets result and takes appropriate action
  7. Process repeats for next match or terminates

Button Actions (typical configuration):

  • Replace button: Returns QDialog::Accepted, triggers replacement
  • Skip button: Returns custom code, advances without replacing
  • Replace All: Returns custom code, batch replaces remaining matches
  • Cancel button: Returns QDialog::Rejected, aborts operation

Modal Behavior Benefits:

  • Prevents accidental document edits during confirmation
  • Maintains clear workflow state
  • Ensures user attention on decision
  • Simplifies state management in calling code
Parameters
parentPointer to the parent widget, typically the main musredit editor window. The parent relationship provides:
  • Automatic dialog centering over parent window
  • Consistent visual style and theme
  • Automatic cleanup when parent is destroyed
  • Proper z-order (dialog appears on top of parent)

If nullptr, the dialog has no parent and will not center over any specific window, though it will still be modal with respect to the application.

Note
The dialog is created but not displayed by the constructor. Use exec() or show() to make it visible to the user.
The actual button configuration and return codes are determined by the UI file design and any signal-slot connections established there.
Modal dialogs entered via exec() run their own event loop, blocking the calling code until the dialog closes.
The simple constructor design (no parameters for search/replace text) suggests the dialog may be updated after construction but before display, or that it shows generic confirmation text.
See also
exec() Qt method to display the dialog modally and return user choice
setModal() Qt method that configures modal behavior (called here)
setupUi() Qt Designer generated method that constructs the UI
QDialog For base class documentation on dialog behavior and return codes

Definition at line 123 of file PReplaceConfirmationDialog.cpp.

◆ ~PReplaceConfirmationDialog()

virtual PReplaceConfirmationDialog::~PReplaceConfirmationDialog ( )
inlinevirtual

Virtual destructor.

Default destructor implementation. Qt's parent-child ownership system automatically handles cleanup of UI elements created by setupUi(). No manual resource cleanup is required.

Note
Declared virtual to ensure proper cleanup in inheritance hierarchies, following C++ best practices.

Definition at line 154 of file PReplaceConfirmationDialog.h.


The documentation for this class was generated from the following files: