Browse Source

Use Qt5 connect() style in CategoryFilterWidget

adaptive-webui-19844
Vladimir Golovnev (Glassez) 7 years ago
parent
commit
8c58a69be6
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7
  1. 29
      src/gui/categoryfilterwidget.cpp
  2. 1
      src/gui/categoryfilterwidget.h

29
src/gui/categoryfilterwidget.cpp

@ -81,12 +81,12 @@ CategoryFilterWidget::CategoryFilterWidget(QWidget *parent) @@ -81,12 +81,12 @@ CategoryFilterWidget::CategoryFilterWidget(QWidget *parent)
sortByColumn(0, Qt::AscendingOrder);
setCurrentIndex(model()->index(0, 0));
connect(this, SIGNAL(collapsed(QModelIndex)), SLOT(callUpdateGeometry()));
connect(this, SIGNAL(expanded(QModelIndex)), SLOT(callUpdateGeometry()));
connect(this, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showMenu(QPoint)));
connect(selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex))
, SLOT(onCurrentRowChanged(QModelIndex,QModelIndex)));
connect(model(), SIGNAL(modelReset()), SLOT(callUpdateGeometry()));
connect(this, &QTreeView::collapsed, this, &CategoryFilterWidget::callUpdateGeometry);
connect(this, &QTreeView::expanded, this, &CategoryFilterWidget::callUpdateGeometry);
connect(this, &QWidget::customContextMenuRequested, this, &CategoryFilterWidget::showMenu);
connect(selectionModel(), &QItemSelectionModel::currentRowChanged
, this, &CategoryFilterWidget::onCurrentRowChanged);
connect(model(), &QAbstractItemModel::modelReset, this, &CategoryFilterWidget::callUpdateGeometry);
}
QString CategoryFilterWidget::currentCategory() const
@ -113,7 +113,7 @@ void CategoryFilterWidget::showMenu(QPoint) @@ -113,7 +113,7 @@ void CategoryFilterWidget::showMenu(QPoint)
QAction *addAct = menu.addAction(
GuiIconProvider::instance()->getIcon("list-add")
, tr("Add category..."));
connect(addAct, SIGNAL(triggered()), SLOT(addCategory()));
connect(addAct, &QAction::triggered, this, &CategoryFilterWidget::addCategory);
auto selectedRows = selectionModel()->selectedRows();
if (!selectedRows.empty() && !CategoryFilterModel::isSpecialItem(selectedRows.first())) {
@ -121,36 +121,36 @@ void CategoryFilterWidget::showMenu(QPoint) @@ -121,36 +121,36 @@ void CategoryFilterWidget::showMenu(QPoint)
QAction *addSubAct = menu.addAction(
GuiIconProvider::instance()->getIcon("list-add")
, tr("Add subcategory..."));
connect(addSubAct, SIGNAL(triggered()), SLOT(addSubcategory()));
connect(addSubAct, &QAction::triggered, this, &CategoryFilterWidget::addSubcategory);
}
QAction *removeAct = menu.addAction(
GuiIconProvider::instance()->getIcon("list-remove")
, tr("Remove category"));
connect(removeAct, SIGNAL(triggered()), SLOT(removeCategory()));
connect(removeAct, &QAction::triggered, this, &CategoryFilterWidget::removeCategory);
}
QAction *removeUnusedAct = menu.addAction(
GuiIconProvider::instance()->getIcon("list-remove")
, tr("Remove unused categories"));
connect(removeUnusedAct, SIGNAL(triggered()), SLOT(removeUnusedCategories()));
connect(removeUnusedAct, &QAction::triggered, this, &CategoryFilterWidget::removeUnusedCategories);
menu.addSeparator();
QAction *startAct = menu.addAction(
GuiIconProvider::instance()->getIcon("media-playback-start")
, tr("Resume torrents"));
connect(startAct, SIGNAL(triggered()), SIGNAL(actionResumeTorrentsTriggered()));
connect(startAct, &QAction::triggered, this, &CategoryFilterWidget::actionResumeTorrentsTriggered);
QAction *pauseAct = menu.addAction(
GuiIconProvider::instance()->getIcon("media-playback-pause")
, tr("Pause torrents"));
connect(pauseAct, SIGNAL(triggered()), SIGNAL(actionPauseTorrentsTriggered()));
connect(pauseAct, &QAction::triggered, this, &CategoryFilterWidget::actionPauseTorrentsTriggered);
QAction *deleteTorrentsAct = menu.addAction(
GuiIconProvider::instance()->getIcon("edit-delete")
, tr("Delete torrents"));
connect(deleteTorrentsAct, SIGNAL(triggered()), SIGNAL(actionDeleteTorrentsTriggered()));
connect(deleteTorrentsAct, &QAction::triggered, this, &CategoryFilterWidget::actionDeleteTorrentsTriggered);
menu.exec(QCursor::pos());
}
@ -167,6 +167,9 @@ void CategoryFilterWidget::callUpdateGeometry() @@ -167,6 +167,9 @@ void CategoryFilterWidget::callUpdateGeometry()
QSize CategoryFilterWidget::sizeHint() const
{
// The sizeHint must depend on viewportSizeHint,
// otherwise widget will not correctly adjust the
// size when subcategories are used.
const QSize viewportSize {viewportSizeHint()};
return {
viewportSize.width(),

1
src/gui/categoryfilterwidget.h

@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
class CategoryFilterWidget: public QTreeView
{
Q_OBJECT
Q_DISABLE_COPY(CategoryFilterWidget)
public:
explicit CategoryFilterWidget(QWidget *parent = nullptr);

Loading…
Cancel
Save