Commit 7264132f authored by Michael Pyne's avatar Michael Pyne

A few more FileRenamer cleanups since I was there.

Includes modernizing signal/slot usage, dead code elimination, some code
readability improvement.
parent 7d681172
Pipeline #3623 passed with stage
in 16 minutes and 23 seconds
......@@ -270,13 +270,20 @@ FileRenamerWidget::FileRenamerWidget(QWidget *parent) :
m_ui->m_category->addItem(category);
}
connect(m_exampleDialog, SIGNAL(signalShown()), SLOT(exampleDialogShown()));
connect(m_exampleDialog, SIGNAL(signalHidden()), SLOT(exampleDialogHidden()));
connect(m_exampleDialog, SIGNAL(dataChanged()), SLOT(dataSelected()));
connect(m_exampleDialog, SIGNAL(fileChanged(QString)),
this, SLOT(fileSelected(QString)));
connect(m_ui->dlgButtonBox, SIGNAL(accepted()), SIGNAL(accepted()));
connect(m_ui->dlgButtonBox, SIGNAL(rejected()), SIGNAL(rejected()));
connect(m_exampleDialog, &ExampleOptionsDialog::signalShown,
this, &FileRenamerWidget::exampleDialogShown);
connect(m_exampleDialog, &ExampleOptionsDialog::signalHidden,
this, &FileRenamerWidget::exampleDialogHidden);
connect(m_exampleDialog, &ExampleOptionsDialog::dataChanged,
this, &FileRenamerWidget::dataSelected);
connect(m_exampleDialog, &ExampleOptionsDialog::fileChanged,
this, &FileRenamerWidget::fileSelected);
connect(m_ui->dlgButtonBox, &QDialogButtonBox::accepted, this, [this]() {
emit accepted();
});
connect(m_ui->dlgButtonBox, &QDialogButtonBox::rejected, this, [this]() {
emit rejected();
});
exampleTextChanged();
}
......@@ -340,8 +347,8 @@ int FileRenamerWidget::addRowCategory(TagType category)
// Find number of categories already of this type.
int categoryCount = 0;
for(int i = 0; i < m_rows.count(); ++i)
if(m_rows[i].category.category == category)
for(const auto &row : m_rows)
if(row.category.category == category)
++categoryCount;
Row row;
......@@ -489,7 +496,7 @@ bool FileRenamerWidget::removeRow(int id)
// We can insert another row now, make sure GUI is updated to match.
m_ui->m_insertCategory->setEnabled(true);
QTimer::singleShot(0, this, SLOT(exampleTextChanged()));
QTimer::singleShot(0, this, &FileRenamerWidget::exampleTextChanged);
return true;
}
......@@ -505,8 +512,7 @@ void FileRenamerWidget::addFolderSeparatorCheckbox()
l->addWidget(cb, 0, Qt::AlignCenter);
cb->setChecked(false);
connect(cb, SIGNAL(toggled(bool)),
SLOT(exampleTextChanged()));
connect(cb, &QCheckBox::toggled, this, &FileRenamerWidget::exampleTextChanged);
temp->show();
}
......@@ -537,9 +543,7 @@ void FileRenamerWidget::createTagRows()
// a row given the identifier, use m_rows[id].position. To find the id of a given
// position, use idOfPosition(position).
QList<int>::ConstIterator it = categoryOrder.constBegin();
for(; it != categoryOrder.constEnd(); ++it) {
for(auto it = categoryOrder.cbegin(); it != categoryOrder.cend(); ++it) {
if(*it < StartTag || *it >= NumTypes) {
qCCritical(JUK_LOG) << "Invalid category encountered in file renamer configuration.\n";
continue;
......@@ -550,17 +554,12 @@ void FileRenamerWidget::createTagRows()
break;
}
TagType i = static_cast<TagType>(*it);
addRowCategory(i);
addRowCategory(static_cast<TagType>(*it));
// Insert the directory separator checkbox if this isn't the last
// item.
QList<int>::ConstIterator dup(it);
// Check for last item
if(++dup != categoryOrder.constEnd())
if((it + 1) != categoryOrder.constEnd())
addFolderSeparatorCheckbox();
}
......@@ -721,7 +720,7 @@ void FileRenamerWidget::moveItem(int id, MovementDirection direction)
layout->insertWidget(2 * pos, w);
layout->invalidate();
QTimer::singleShot(0, this, SLOT(exampleTextChanged()));
QTimer::singleShot(0, this, &FileRenamerWidget::exampleTextChanged);
}
int FileRenamerWidget::idOfPosition(int position) const
......@@ -752,18 +751,6 @@ int FileRenamerWidget::findIdentifier(const CategoryID &category) const
return MAX_CATEGORIES;
}
void FileRenamerWidget::enableAllUpButtons()
{
for(int i = 0; i < m_rows.count(); ++i)
m_rows[i].upButton->setEnabled(true);
}
void FileRenamerWidget::enableAllDownButtons()
{
for(int i = 0; i < m_rows.count(); ++i)
m_rows[i].downButton->setEnabled(true);
}
void FileRenamerWidget::showCategoryOption(int id)
{
TagOptionsDialog *dialog = new TagOptionsDialog(this, m_rows[id].options, m_rows[id].category.categoryNumber);
......
......@@ -43,7 +43,7 @@ enum MovementDirection { MoveUp, MoveDown };
* tag type, including its position, the QFrame holding the information,
* the up, down, and enable buttons, and the user-selected renaming options.
*/
struct Row
struct Row final
{
Row() : widget(0), upButton(0), downButton(0), enableButton(0) {}
......@@ -66,14 +66,6 @@ struct Row
*/
typedef QVector<Row> Rows;
/**
* Holds a list directory separator checkboxes which separate a row. There
* should always be 1 less than the number of rows in the GUI.
*
* Used for ConfigCategoryReader.
*/
typedef QVector<QCheckBox *> DirSeparatorCheckBoxes;
/**
* Associates a CategoryID combination with a set of options.
*
......@@ -89,7 +81,7 @@ typedef QMap<CategoryID, TagRenamerOptions> CategoryOptionsMap;
*
* @author Michael Pyne <mpyne@kde.org>
*/
class ConfigCategoryReader : public CategoryReaderInterface
class ConfigCategoryReader final : public CategoryReaderInterface
{
public:
// ConfigCategoryReader specific members
......@@ -136,7 +128,7 @@ private:
*
* @author Michael Pyne <mpyne@kde.org>
*/
class FileRenamerWidget : public QWidget, public CategoryReaderInterface
class FileRenamerWidget final : public QWidget, public CategoryReaderInterface
{
Q_OBJECT
......@@ -362,16 +354,6 @@ private:
*/
void setCategoryEnabled(int id, bool enable);
/**
* This function enables all of the up buttons.
*/
void enableAllUpButtons();
/**
* This function enables all of the down buttons.
*/
void enableAllDownButtons();
/**
* This function returns the identifier of the row at \p position.
*
......@@ -469,7 +451,7 @@ private:
* This holds an array of checkboxes that allow the user to insert folder
* separators in between categories.
*/
DirSeparatorCheckBoxes m_folderSwitches;
QVector<QCheckBox *> m_folderSwitches;
ExampleOptionsDialog *m_exampleDialog;
......@@ -486,7 +468,7 @@ private:
*
* @author Michael Pyne <mpyne@kde.org>
*/
class FileRenamer
class FileRenamer final
{
public:
FileRenamer();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment