GlobalReplaceDialog

class GlobalReplaceDialog : public QDialog

This class is used to handle the gui functionality of global replace dialog box Whenever user saves the page and makes changes to words, this dialog box will appear and show the words which can be globally replaced by the user.

Public Functions

explicit GlobalReplaceDialog(QVector<QString> replacedWords, QWidget *parent = nullptr)

In this constructor function we initialize the UI and setup the layout, margins, alignment,etc.

Parameters:

replacedWords, parent

QVector<int> getStatesOfCheckboxes()

This gets the state of checkboxes at the right hand side of the pane and returns the vector.

Returns:

States of checkboxes

bool clicked_applyButton()

Returns if apply button is clicked.

If apply button was clicked or not

~GlobalReplaceDialog()

Destructor.

Public Slots

void highlightChecked(QListWidgetItem *item)

We change the color of list to lightblue when it is checked and when it is unchecked.

This is done to make the GUI elegant.

Parameters:

ListItem

QMap<QString, QString> getFilteredGlobalReplacementMap()

Returns the processed globalreplacement map which contain the key value pairs of word before replacement and after it is replaced.

Returns:

Filtered global replacement map

QMap<QString, QString> uncheckedItemsList()

This function returns the map of unchecked items list.

Parameters:

item

Returns:

UncheckedItemMap

void disableCheckboxes(int, QMap<QPair<QString, QString>, QString> *changesCheckedInPreviewMap)

This function disables the interaction of user with any of the checkboxes in the Global-Replace dialog window if any of the checkboxes in the preview are checked.

Parameters:
  • flag

  • changesCheckedInPreviewMap1

Private Slots

void on_applyButton_clicked()

Defines what happens when user clicks on apply to global replace.

It puts the words in the global replace map and applies global replace.

void displayOriginalList(QVector<QString> replacedWords)

This function is used to show the checkboxes for words that can be globally replaced in list format.

Parameters:

ReplacedWords

void leftCheckBoxStateChanged(QListWidgetItem*)

This function is a SLOT which receives signal from listWidget when an item is selected.

This function is called by QT whenever user checks or unchecks the left hand side checkbox in the global replace window. If user clicks on lecft checkbox, then right hand side checkbox gets visible.

Parameters:

item – Address of QListWidgetItem is passed

void rightCheckBoxStateChanged()

This function handles what happens when states of right side Checkboxes are changed.

void on_previewButton_clicked()

Defines what happens when preview button is clicked.

Gets the checkboxes are clicked and emits a signal which causes preview dialog to show up.

void on_pushButton_clicked()

This opens the global replace information dialog box.

Whenever users click on the 𝒊 symbol they can see what each button does in global replace, thus better equipped to use the feature.

void on_checkBox_clicked()

This function is triggered by “Select All” button(on left side) which checks all the checkboxes on the left.

void on_checkBox_2_clicked()

This function is triggered by the “Select All” button(on right side) which checks all enabled checkboxes on the right .

void on_pushButton_2_clicked()

This button clears all the checkboxes’ states which were checked in preview dialog of global-replace.