Commit c65e9f64 authored by Andrius Štikonas's avatar Andrius Štikonas

Use nullptr in bittorrent plugin.

parent 70ec1b38
......@@ -73,7 +73,7 @@ void BTAdvancedDetailsWidget::init()
webseeds_tab = new WebSeedsTab(this);
webseeds_tab->changeTC(tc);
tabWidget->insertTab(2, webseeds_tab, QIcon::fromTheme("network-server"), i18n("Webseeds"));
monitor = new Monitor(tc, 0, 0, file_view);
monitor = new Monitor(tc, nullptr, nullptr, file_view);
}
void BTAdvancedDetailsWidget::hideEvent(QHideEvent * event)
......
......@@ -86,7 +86,7 @@ namespace kt
/////////////////////////////////////////////////////////////
ChunkDownloadModel::ChunkDownloadModel ( QObject* parent )
: QAbstractTableModel(parent),tc(0)
: QAbstractTableModel(parent),tc(nullptr)
{
sort_column = 0;
sort_order = Qt::AscendingOrder;
......
......@@ -37,7 +37,7 @@ namespace kt
{
ChunkDownloadView::ChunkDownloadView(QWidget* parent) : QWidget(parent),curr_tc(0)
ChunkDownloadView::ChunkDownloadView(QWidget* parent) : QWidget(parent),curr_tc(nullptr)
{
setupUi(this);
model = new ChunkDownloadModel(this);
......
......@@ -104,9 +104,9 @@ namespace kt
}
proxy_model->setSourceModel(0);
delete model;
model = 0;
model = nullptr;
curr_tc = tc;
setEnabled(tc != 0);
setEnabled(tc != nullptr);
if (tc)
{
connect(tc,SIGNAL(missingFilesMarkedDND(bt::TorrentInterface*)),
......@@ -129,7 +129,7 @@ namespace kt
else
{
proxy_model->setSourceModel(0);
model = 0;
model = nullptr;
}
}
......@@ -266,7 +266,7 @@ namespace kt
QString msg = i18np("You will lose all data in this file, are you sure you want to do this?",
"You will lose all data in these files, are you sure you want to do this?", n);
if (KMessageBox::warningYesNo(0,msg) == KMessageBox::Yes)
if (KMessageBox::warningYesNo(nullptr, msg) == KMessageBox::Yes)
changePriority(EXCLUDED);
}
......@@ -419,7 +419,7 @@ namespace kt
proxy_model->setSourceModel(0);
delete model;
model = 0;
model = nullptr;
if (show_list_of_files)
model = new IWFileListModel(curr_tc,this);
......
......@@ -91,7 +91,7 @@ namespace kt
QVariant IWFileTreeModel::data(const QModelIndex & index, int role) const
{
Node* n = 0;
Node* n = nullptr;
if (index.column() < 2 && role != Qt::ForegroundRole)
return TorrentFileTreeModel::data(index,role);
......
......@@ -85,7 +85,7 @@ namespace kt
pv->removeAll();
if (cdv)
cdv->removeAll();
tc = 0;
tc = nullptr;
}
void Monitor::filePercentageChanged(bt::TorrentFileInterface* file,float percentage)
......
......@@ -46,7 +46,7 @@ namespace kt
}
TorrentFileTreeModel::Node::Node(Node* parent,const QString & name, const bt::Uint32 total_chunks)
: parent(parent),file(0),name(name),size(0),chunks(total_chunks),chunks_set(false),percentage(0.0f)
: parent(parent),file(nullptr),name(name),size(0),chunks(total_chunks),chunks_set(false),percentage(0.0f)
{
chunks.setAll(false);
}
......@@ -310,12 +310,12 @@ namespace kt
}
TorrentFileTreeModel::TorrentFileTreeModel(bt::TorrentInterface* tc,DeselectMode mode,QObject* parent)
: TorrentFileModel(tc,mode,parent),root(0),emit_check_state_change(true)
: TorrentFileModel(tc,mode,parent),root(nullptr),emit_check_state_change(true)
{
if (tc->getStats().multi_file_torrent)
constructTree();
else
root = new Node(0,tc->getStats().torrent_name,tc->getStats().total_chunks);
root = new Node(nullptr,tc->getStats().torrent_name,tc->getStats().total_chunks);
}
......@@ -328,7 +328,7 @@ namespace kt
{
bt::Uint32 num_chunks = tc->getStats().total_chunks;
if (!root)
root = new Node(0,tc->getUserModifiedFileName(),num_chunks);
root = new Node(nullptr,tc->getUserModifiedFileName(),num_chunks);
for (Uint32 i = 0;i < tc->getNumFiles();++i)
{
......@@ -340,7 +340,7 @@ namespace kt
void TorrentFileTreeModel::onCodecChange()
{
delete root;
root = 0;
root = nullptr;
constructTree();
reset();
}
......@@ -454,7 +454,7 @@ namespace kt
if (!hasIndex(row, column, parent))
return QModelIndex();
Node* p = 0;
Node* p = nullptr;
if (!parent.isValid())
return createIndex(row,column,root);
......
......@@ -28,7 +28,7 @@ namespace kt
{
TrackerModel::TrackerModel(QObject* parent)
: QAbstractTableModel(parent),tc(0)
: QAbstractTableModel(parent),tc(nullptr)
{
running = false;
}
......
......@@ -43,7 +43,7 @@ namespace kt
TrackerView::TrackerView(QWidget *parent)
: QWidget(parent), tc(0)
: QWidget(parent), tc(nullptr)
{
setupUi(this);
model = new TrackerModel(this);
......@@ -69,7 +69,7 @@ namespace kt
m_change_tracker->setIcon(QIcon::fromTheme("kt-change-tracker"));
setEnabled(false);
torrentChanged(0);
torrentChanged(nullptr);
}
TrackerView::~TrackerView()
......@@ -92,14 +92,14 @@ namespace kt
KUrl url(text);
if (!url.isValid())
{
KMessageBox::error(0, i18n("Malformed URL."));
KMessageBox::error(nullptr, i18n("Malformed URL."));
return;
}
// check for dupes
if (!tc->getTrackersList()->addTracker(url,true))
{
KMessageBox::sorry(0,i18n("There already is a tracker named <b>%1</b>.",text));
KMessageBox::sorry(nullptr,i18n("There already is a tracker named <b>%1</b>.",text));
}
else
{
......@@ -156,7 +156,7 @@ namespace kt
if (tc == ti)
return;
setEnabled(ti != 0);
setEnabled(ti != nullptr);
torrentChanged(ti);
update();
}
......@@ -177,7 +177,7 @@ namespace kt
m_restore_defaults->setEnabled(false);
m_change_tracker->setEnabled(false);
m_scrape->setEnabled(false);
model->changeTC(0);
model->changeTC(nullptr);
}
else
{
......
......@@ -30,7 +30,7 @@ namespace kt
{
WebSeedsModel::WebSeedsModel(QObject* parent)
: QAbstractTableModel(parent),curr_tc(0)
: QAbstractTableModel(parent),curr_tc(nullptr)
{
}
......
......@@ -32,7 +32,7 @@ namespace kt
{
WebSeedsTab::WebSeedsTab(QWidget* parent)
: QWidget(parent),curr_tc(0)
: QWidget(parent),curr_tc(nullptr)
{
setupUi(this);
connect(m_add,SIGNAL(clicked()),this,SLOT(addWebSeed()));
......@@ -64,10 +64,10 @@ namespace kt
{
curr_tc = tc;
model->changeTC(tc);
m_add->setEnabled(curr_tc != 0);
m_remove->setEnabled(curr_tc != 0);
m_webseed_list->setEnabled(curr_tc != 0);
m_webseed->setEnabled(curr_tc != 0);
m_add->setEnabled(curr_tc != nullptr);
m_remove->setEnabled(curr_tc != nullptr);
m_webseed_list->setEnabled(curr_tc != nullptr);
m_webseed->setEnabled(curr_tc != nullptr);
onWebSeedTextChanged(m_webseed->text());
// see if we need to enable or disable the remove button
......@@ -141,7 +141,7 @@ namespace kt
void WebSeedsTab::onWebSeedTextChanged(const QString & ws)
{
QUrl url(ws);
m_add->setEnabled(curr_tc != 0 && url.isValid() && url.scheme() == "http");
m_add->setEnabled(curr_tc != nullptr && url.isValid() && url.scheme() == "http");
}
void WebSeedsTab::update()
......
......@@ -18,7 +18,7 @@ using namespace bt;
//TODO: Support buffered mode?
BTCache::BTCache(Torrent & tor,const QString & tmpdir,const QString & datadir)
: Cache(tor, tmpdir, datadir),
QObject(0)
QObject(nullptr)
{
}
......
......@@ -53,12 +53,12 @@ BTTransfer::BTTransfer(TransferGroup* parent, TransferFactory* factory,
Scheduler* scheduler, const QUrl &src, const QUrl& dest,
const QDomElement * e)
: Transfer(parent, factory, scheduler, src, dest, e),
torrent(0),
torrent(nullptr),
m_tmp(KStandardDirs::locateLocal("appdata", "tmp/")),
m_ready(false),
m_downloadFinished(false),
m_movingFile(false),
m_fileModel(0),
m_fileModel(nullptr),
m_updateCounter(0)
{
m_directory = KIO::upUrl(m_dest);//FIXME test
......@@ -69,7 +69,7 @@ BTTransfer::BTTransfer(TransferGroup* parent, TransferFactory* factory,
BTTransfer::~BTTransfer()
{
if (torrent && m_ready)
torrent->setMonitor(0);
torrent->setMonitor(nullptr);
delete torrent;
}
......@@ -251,12 +251,12 @@ void BTTransfer::addTracker(const QString &url)
{
qCDebug(KGET_DEBUG);
if(torrent->getStats().priv_torrent) {
KMessageBox::sorry(0, i18n("Cannot add a tracker to a private torrent."));
KMessageBox::sorry(nullptr, i18n("Cannot add a tracker to a private torrent."));
return;
}
if(!QUrl(url).isValid()) {
KMessageBox::error(0, i18n("Malformed URL."));
KMessageBox::error(nullptr, i18n("Malformed URL."));
return;
}
......@@ -288,7 +288,7 @@ void BTTransfer::startTorrent()
void BTTransfer::stopTorrent()
{
torrent->stop();
torrent->setMonitor(0);
torrent->setMonitor(nullptr);
m_downloadSpeed = 0;
timer.stop();
......@@ -456,7 +456,7 @@ void BTTransfer::btTransferInit(const QUrl &src, const QByteArray &data)
kDebug() << "Source:" << m_source.path() << "Destination:" << m_dest.path();
m_dest = m_dest.adjusted(QUrl::StripTrailingSlash);
torrent->init(0, file.readAll(), m_tmp + m_source.fileName().remove(".torrent"), QUrl::fromLocalFile(m_dest.adjusted(QUrl::RemoveFilename).path()).toLocalFile());
torrent->init(nullptr, file.readAll(), m_tmp + m_source.fileName().remove(".torrent"), QUrl::fromLocalFile(m_dest.adjusted(QUrl::RemoveFilename).path()).toLocalFile());
m_dest = torrent->getStats().output_path;
if (!torrent->getStats().multi_file_torrent && (m_dest.fileName() != torrent->getStats().torrent_name))//TODO check if this is needed, so if that case is true at some point
......@@ -477,7 +477,7 @@ void BTTransfer::btTransferInit(const QUrl &src, const QByteArray &data)
{
m_ready = false;
torrent->deleteLater();
torrent = 0;
torrent = nullptr;
setError(err.toString(), SmallIcon("dialog-cancel"), Job::NotSolveable);
setTransferChange(Tc_Status);
return;
......
......@@ -31,7 +31,7 @@ BTTransferFactory::BTTransferFactory(QObject *parent, const QVariantList &args)
if (!bt::InitLibKTorrent())
{
qCCritical(KGET_DEBUG) << "Failed to initialize libktorrent";
KGet::showNotification(0, "error", i18n("Cannot initialize libktorrent. Torrent support might not work."));
KGet::showNotification(nullptr, "error", i18n("Cannot initialize libktorrent. Torrent support might not work."));
}
}
......
......@@ -24,8 +24,8 @@ BTTransferHandler::BTTransferHandler(BTTransfer * transfer, Scheduler * schedule
: TransferHandler(transfer, scheduler),
m_transfer(transfer)
{
advancedDetails = 0;
scanDlg = 0;
advancedDetails = nullptr;
scanDlg = nullptr;
}
BTTransferHandler::~BTTransferHandler()
......@@ -48,7 +48,7 @@ void BTTransferHandler::createAdvancedDetails()
connect(advancedDetails, SIGNAL(aboutToClose()), SLOT(removeAdvancedDetails()));
if (m_transfer->torrentControl())
{
m_transfer->torrentControl()->setMonitor(0);
m_transfer->torrentControl()->setMonitor(nullptr);
m_transfer->torrentControl()->setMonitor(m_transfer);
}
}
......@@ -57,7 +57,7 @@ void BTTransferHandler::createAdvancedDetails()
void BTTransferHandler::removeAdvancedDetails()
{
advancedDetails->close();
advancedDetails = 0;
advancedDetails = nullptr;
}
kt::Monitor* BTTransferHandler::torrentMonitor() const
......@@ -73,6 +73,6 @@ void BTTransferHandler::createScanDlg()
if (!torrentControl())
return;
scanDlg = new kt::ScanDlg(m_transfer->torrentControl()->startDataCheck(false, 0, m_transfer->chunksTotal()), 0);//TODO: Maybe start/stop it
scanDlg = new kt::ScanDlg(m_transfer->torrentControl()->startDataCheck(false, 0, m_transfer->chunksTotal()), nullptr);//TODO: Maybe start/stop it
scanDlg->exec();
}
......@@ -64,7 +64,7 @@ namespace kt
{
if (m_job) {
m_job->kill(false);
m_job = 0;
m_job = nullptr;
}
else
accept();
......@@ -74,7 +74,7 @@ namespace kt
{
if (m_job) {
m_job->kill(false);
m_job = 0;
m_job = nullptr;
}
KDialog::reject();
deleteLater();
......@@ -97,9 +97,9 @@ namespace kt
void ScanDlg::result(KJob *job)
{
if (job->error() && job->error() != KIO::ERR_USER_CANCELED) {
KMessageBox::error(0,i18n("Error scanning data: %1",job->errorString()));
KMessageBox::error(nullptr,i18n("Error scanning data: %1",job->errorString()));
}
m_job = 0;
m_job = nullptr;
m_progress->setValue(100);
disconnect(m_cancel,SIGNAL(clicked()),this,SLOT(reject()));
connect(m_cancel,SIGNAL(clicked()),this,SLOT(accept()));
......
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