summaryrefslogtreecommitdiffstats
path: root/torrentwidget.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-02-03 02:57:04 +0100
committerArno <arno@disconnect.de>2018-02-03 02:57:04 +0100
commit2e7a708e036b80eeba946a31e6ca3ec462ee5a92 (patch)
tree5d03fc28bd28ff0b4323c8024f11282521954871 /torrentwidget.cpp
parent112d450df193425c6d78f1f8a01f58b4e6ee0ebc (diff)
downloadShemovCleaner-2e7a708e036b80eeba946a31e6ca3ec462ee5a92.tar.gz
ShemovCleaner-2e7a708e036b80eeba946a31e6ca3ec462ee5a92.tar.bz2
ShemovCleaner-2e7a708e036b80eeba946a31e6ca3ec462ee5a92.zip
Clean up TorrentWidget
Get rid of Q_FOREARCH, use type safe connect syntax, remove members that don't have to be members, the usual.
Diffstat (limited to 'torrentwidget.cpp')
-rw-r--r--torrentwidget.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/torrentwidget.cpp b/torrentwidget.cpp
index 66bc663..bb3bf54 100644
--- a/torrentwidget.cpp
+++ b/torrentwidget.cpp
@@ -44,25 +44,25 @@ void TorrentWidget::setupGui(){
QCompleter *torDirCompl = new QCompleter(this);
torDirCompl->setModel(new QDirModel(torDirCompl));
mDir->setCompleter(torDirCompl);
- connect(mDir, SIGNAL(returnPressed()), this, SLOT(setDir()));
+ connect(mDir, &QLineEdit::returnPressed, this, &TorrentWidget::setDir);
- mSelDir = new QPushButton(tr("Browse..."));
- connect(mSelDir, SIGNAL(clicked()), this, SLOT(selectDir()));
+ QPushButton *selDirB = new QPushButton(tr("Browse..."));
+ connect(selDirB, &QPushButton::clicked, this, &TorrentWidget::selectDir);
mSearchTorrents = new QLineEdit;
- connect(mSearchTorrents, SIGNAL(returnPressed()), this, SLOT(searchFile()));
- mDoSearchTorrents = new QPushButton(tr("Search"));
- connect(mDoSearchTorrents, SIGNAL(clicked()), this, SLOT(searchFile()));
+ connect(mSearchTorrents, &QLineEdit::returnPressed, this, &TorrentWidget::searchFile);
+ QPushButton *doSearchTorrentsB = new QPushButton(tr("Search"));
+ connect(doSearchTorrentsB, &QPushButton::clicked, this, &TorrentWidget::searchFile);
QLabel *searchL = new QLabel(tr("&Search"));
searchL->setBuddy(mSearchTorrents);
QGridLayout *buttonL = new QGridLayout;
buttonL->addWidget(new QLabel(tr("Directory")), 0, 0);
buttonL->addWidget(mDir, 0, 1);
- buttonL->addWidget(mSelDir, 0, 2);
+ buttonL->addWidget(selDirB, 0, 2);
buttonL->addWidget(searchL, 1, 0);
buttonL->addWidget(mSearchTorrents, 1, 1);
- buttonL->addWidget(mDoSearchTorrents, 1, 2);
+ buttonL->addWidget(doSearchTorrentsB, 1, 2);
mFileView = new QTreeView;
mFileView->setSortingEnabled(true);
@@ -90,33 +90,33 @@ void TorrentWidget::setupGui(){
setLayout(mainLayout);
mTorrentDisplay = new TorrentDisplay(this);
- connect(mFileView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(fileSelectionChanged(QItemSelection,QItemSelection)));
+ connect(mFileView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &TorrentWidget::fileSelectionChanged);
createActions();
- connect(mFileView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(torrentInfo()));
+ connect(mFileView, &QTreeView::doubleClicked, this, &TorrentWidget::torrentInfo);
}
void TorrentWidget::createActions(){
mRefreshA = new QAction(QIcon(":/refresh.png"), tr("Refresh"), this);
mRefreshA->setShortcut(tr("CTRL+R"));
- connect(mRefreshA, SIGNAL(triggered()), this, SLOT(gatherData()));
+ connect(mRefreshA, &QAction::triggered, this, &TorrentWidget::gatherData);
mDeleteA = new QAction(QIcon(":/delete.png"), tr("Delete..."), this);
mDeleteA->setShortcut(Qt::Key_Delete);
- connect(mDeleteA, SIGNAL(triggered()), this, SLOT(deleteFiles()));
+ connect(mDeleteA, &QAction::triggered, this, &TorrentWidget::deleteFiles);
mMoveA = new QAction(QIcon(":/diaper.png"), tr("Move..."), this);
mMoveA->setShortcut(tr("CTRL+M"));
- connect(mMoveA, SIGNAL(triggered()), this, SLOT(moveFiles()));
+ connect(mMoveA, &QAction::triggered, this, &TorrentWidget::moveFiles);
mTorrentInfoA = new QAction(QIcon(":/huge_bra.png"), tr("Torrent Info..."), this);
mTorrentInfoA->setShortcut(Qt::CTRL + Qt::Key_Return);
- connect(mTorrentInfoA, SIGNAL(triggered()), this, SLOT(torrentInfo()));
+ connect(mTorrentInfoA, &QAction::triggered, this, &TorrentWidget::torrentInfo);
mSelDirA = new QAction(QIcon(":/folder.png"), tr("Select folder..."), this);
mSelDirA->setShortcut(tr("CTRL+O"));
- connect(mSelDirA, SIGNAL(triggered()), this, SLOT(selectDir()));
+ connect(mSelDirA, &QAction::triggered, this, &TorrentWidget::selectDir);
mCopyFnToClipA = new QAction(QIcon(":/edit-copy.png"), tr("Filename to Clip"), this);
mCopyFnToClipA->setShortcut(tr("CTRL+C"));
- connect(mCopyFnToClipA, SIGNAL(triggered()), this, SLOT(copyToClipboard()));
+ connect(mCopyFnToClipA, &QAction::triggered, this, &TorrentWidget::copyToClipboard);
mGuessSubtitleA = new QAction(QIcon(":/hourglass_figure.png"), tr("Guess subtitle"), this);
mGuessSubtitleA->setShortcut(tr("CTRL+SHIFT+C"));
- connect(mGuessSubtitleA, SIGNAL(triggered()), this, SLOT(guessSubtitle()));
+ connect(mGuessSubtitleA, &QAction::triggered, this, &TorrentWidget::guessSubtitle);
QMenu *fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(mSelDirA);
@@ -182,7 +182,7 @@ void TorrentWidget::gatherData(){
mModel->setHorizontalHeaderLabels(QStringList() << QChar(0x26A7) << tr("Name") << tr("Created"));
QBrush redBrush(Qt::red);
QBrush greenBrush(Qt::darkGreen);
- foreach(QFileInfo fi, fl){
+ for(QFileInfo fi : fl){
QList<QStandardItem*> fData;
for(int i = 0; i < ColumnCount; ++i){
QStandardItem *item = new QStandardItem;
@@ -321,7 +321,7 @@ void TorrentWidget::searchFile(){
emit statusMessage(QString(tr("parsing %1").arg(fn)));
QList<QVariant> torrentData = p.parse();
QStringList files = p.files(torrentData);
- foreach(QString f, files){
+ for(QString f : files){
QRegularExpressionMatch m = regex.match(f);
if(m.hasMatch()){
++success;
@@ -444,17 +444,17 @@ void TorrentWidget::writeSettings(){
void TorrentWidget::rememberSelection(){
QModelIndexList sel = mFileView->selectionModel()->selectedRows(NameColumn);
mSelection.clear();
- foreach(QModelIndex idx, sel){
+ for(QModelIndex idx : sel){
mSelection << idx.data().toString();
}
}
void TorrentWidget::restoreSelection(){
QList<QStandardItem*> modelItems;
- foreach(QString sel, mSelection){
+ for(QString sel : mSelection){
modelItems << mModel->findItems(sel, Qt::MatchExactly, NameColumn);
}
- foreach(QStandardItem *i, modelItems){
+ for(QStandardItem *i : modelItems){
QModelIndex srcIdx = mModel->indexFromItem(i);
QModelIndex idx = mProxy->mapFromSource(srcIdx);
mFileView->selectionModel()->select(idx, QItemSelectionModel::Select | QItemSelectionModel::Rows);