1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-23 06:30:38 +00:00
transmission/qt/RelocateDialog.cc
Charles Kerr c2fb393390
chore: fix clang-tidy-11 warnings (#1436)
* refactor: mark subclass' destructors as override.

* refactor: use QUrl to parse announce URL strings.

The prompt for this was to work around a clang-tidy issue where
"char* host = nullptr;" triggers a "don't use varargs" warning,
but on the other hand it's also terser / cleaner.

* refactor: make the TorrentDelegate brushes const.

* refactor: s/auto/auto const*/ where appropriate

* chore: add some nonconst global warning exemptions

* chore: turn off warnings in GTest

* refactor: just disable the clang-tidy warning.

Apparently a std::array<T>::iterator is a T* on clang, since clang-tidy's
readability warning says we should use 'auto*' instead of 'auto'. However
adding that annotation fails on MSVC, where the is apparently _not_ a raw
pointer.

Since there's not a way to satisfy both of them at the same time, disable
the warning.
2020-09-09 09:24:39 -05:00

97 lines
2.4 KiB
C++

/*
* This file Copyright (C) 2009-2015 Mnemosyne LLC
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
*
*/
#include <QDir>
#include "RelocateDialog.h"
#include "Session.h"
#include "Torrent.h"
#include "TorrentModel.h"
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
bool RelocateDialog::move_flag = true;
void RelocateDialog::onSetLocation()
{
session_.torrentSetLocation(ids_, newLocation(), move_flag);
close();
}
void RelocateDialog::onMoveToggled(bool b)
{
move_flag = b;
}
RelocateDialog::RelocateDialog(Session& session, TorrentModel const& model, torrent_ids_t ids, QWidget* parent) :
BaseDialog(parent),
session_(session),
ids_(std::move(ids))
{
ui_.setupUi(this);
QString path;
for (int const id : ids_)
{
Torrent const* tor = model.getTorrentFromId(id);
if (path.isEmpty())
{
path = tor->getPath();
}
else if (path != tor->getPath())
{
if (session_.isServer())
{
path = QDir::homePath();
}
else
{
path = QDir::rootPath();
}
break;
}
}
if (session_.isServer())
{
ui_.newLocationStack->setCurrentWidget(ui_.newLocationButton);
ui_.newLocationButton->setMode(PathButton::DirectoryMode);
ui_.newLocationButton->setTitle(tr("Select Location"));
ui_.newLocationButton->setPath(path);
}
else
{
ui_.newLocationStack->setCurrentWidget(ui_.newLocationEdit);
ui_.newLocationEdit->setText(path);
ui_.newLocationEdit->selectAll();
}
ui_.newLocationStack->setFixedHeight(ui_.newLocationStack->currentWidget()->sizeHint().height());
ui_.newLocationLabel->setBuddy(ui_.newLocationStack->currentWidget());
if (move_flag)
{
ui_.moveDataRadio->setChecked(true);
}
else
{
ui_.findDataRadio->setChecked(true);
}
connect(ui_.moveDataRadio, SIGNAL(toggled(bool)), this, SLOT(onMoveToggled(bool)));
connect(ui_.dialogButtons, SIGNAL(rejected()), this, SLOT(close()));
connect(ui_.dialogButtons, SIGNAL(accepted()), this, SLOT(onSetLocation()));
}
QString RelocateDialog::newLocation() const
{
return ui_.newLocationStack->currentWidget() == ui_.newLocationButton ? ui_.newLocationButton->path() :
ui_.newLocationEdit->text();
}