Use c++11 style connects for Part

parent a2a6631b
......@@ -112,18 +112,18 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&)
QAction *action = actionCollection()->addAction(QStringLiteral("configure_filelight"));
action->setText(i18n("Configure Filelight..."));
action->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
connect(action, SIGNAL(triggered()), this, SLOT(configFilelight()));
connect(action, &QAction::triggered, this, &Part::configFilelight);
connect(m_map, SIGNAL(created(const Folder*)), SIGNAL(completed()));
connect(m_map, SIGNAL(created(const Folder*)), SLOT(mapChanged(const Folder*)));
connect(m_map, SIGNAL(activated(QUrl)), SLOT(updateURL(QUrl)));
connect(m_map, &RadialMap::Widget::folderCreated, this, static_cast<void (Part::*)()>(&Part::completed));
connect(m_map, &RadialMap::Widget::folderCreated, this, &Part::mapChanged);
connect(m_map, &RadialMap::Widget::activated, this, &Part::updateURL);
// TODO make better system
connect(m_map, SIGNAL(giveMeTreeFor(QUrl)), SLOT(updateURL(QUrl)));
connect(m_map, SIGNAL(giveMeTreeFor(QUrl)), SLOT(openUrl(QUrl)));
connect(m_map, &RadialMap::Widget::giveMeTreeFor, this, &Part::updateURL);
connect(m_map, &RadialMap::Widget::giveMeTreeFor, this, &Part::openUrl);
connect(m_manager, SIGNAL(completed(Folder*)), SLOT(scanCompleted(Folder*)));
connect(m_manager, SIGNAL(aboutToEmptyCache()), m_map, SLOT(invalidate()));
connect(m_manager, &ScanManager::completed, this, &Part::scanCompleted);
connect(m_manager, &ScanManager::aboutToEmptyCache, m_map, &RadialMap::Widget::invalidate);
QTimer::singleShot(0, this, SLOT(postInit()));
}
......@@ -226,10 +226,10 @@ Part::updateURL(const QUrl &u)
void
Part::configFilelight()
{
QWidget *dialog = new SettingsDialog(widget());
SettingsDialog *dialog = new SettingsDialog(widget());
connect(dialog, SIGNAL(canvasIsDirty(int)), m_map, SLOT(refresh(int)));
connect(dialog, SIGNAL(mapIsInvalid()), m_manager, SLOT(emptyCache()));
connect(dialog, &SettingsDialog::canvasIsDirty, m_map, &RadialMap::Widget::refresh);
connect(dialog, &SettingsDialog::mapIsInvalid, m_manager, &ScanManager::emptyCache);
dialog->show(); //deletes itself
}
......@@ -239,7 +239,7 @@ Part::start(const QUrl &url)
{
if (!m_started) {
connect(m_map, SIGNAL(mouseHover(QString)), statusBar(), SLOT(showMessage(const QString&)));
connect(m_map, SIGNAL(created(const Folder*)), statusBar(), SLOT(clearMessage()));
connect(m_map, &RadialMap::Widget::folderCreated, statusBar(), &QStatusBar::clearMessage);
m_started = true;
}
......@@ -327,7 +327,7 @@ Part::showSummary()
if (m_summary == 0) {
m_summary = new SummaryWidget(widget());
m_summary->setObjectName(QStringLiteral( "summaryWidget" ));
connect(m_summary, SIGNAL(activated(QUrl)), SLOT(openUrl(QUrl)));
connect(m_summary, &SummaryWidget::activated, this, &Part::openUrl);
m_summary->show();
m_layout->addWidget(m_summary);
}
......
......@@ -39,6 +39,7 @@ class Folder;
namespace Filelight
{
class Part;
class SummaryWidget;
class BrowserExtension : public KParts::BrowserExtension
{
......@@ -80,7 +81,7 @@ private:
void showSummary();
QLayout *m_layout;
QWidget *m_summary;
SummaryWidget *m_summary;
BrowserExtension *m_ext;
StatusBarExtension *m_statusbar;
RadialMap::Widget *m_map;
......
......@@ -22,6 +22,7 @@
#include "progressBox.h"
#include "scan.h"
#include "part.h"
#include <KColorScheme>
#include <KIO/Job>
......@@ -36,9 +37,9 @@
#include <math.h>
ProgressBox::ProgressBox(QWidget *parent, QObject *part, Filelight::ScanManager *m)
ProgressBox::ProgressBox(QWidget *parent, Filelight::Part *part, Filelight::ScanManager *scanManager)
: QWidget(parent)
, m_manager(m)
, m_manager(scanManager)
{
hide();
......@@ -51,10 +52,10 @@ ProgressBox::ProgressBox(QWidget *parent, QObject *part, Filelight::ScanManager
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setMinimumSize(200, 200);
connect(&m_timer, SIGNAL(timeout()), SLOT(report()));
connect(part, SIGNAL(started(KIO::Job*)), SLOT(start()));
connect(part, SIGNAL(completed()), SLOT(stop()));
connect(part, SIGNAL(canceled(QString)), SLOT(halt()));
connect(&m_timer, &QTimer::timeout, this, &ProgressBox::report);
connect(part, &Filelight::Part::started, this, &ProgressBox::start);
connect(part, static_cast<void (Filelight::Part::*)()>(&Filelight::Part::completed), this, &ProgressBox::stop);
connect(part, &Filelight::Part::canceled, this, &ProgressBox::halt);
}
void
......
......@@ -27,6 +27,7 @@
namespace Filelight {
class ScanManager;
class Part;
}
class ProgressBox : public QWidget
......@@ -34,7 +35,7 @@ class ProgressBox : public QWidget
Q_OBJECT
public:
ProgressBox(QWidget*, QObject*, Filelight::ScanManager*);
ProgressBox(QWidget *parent, Filelight::Part *part, Filelight::ScanManager *scanManager);
void setText(int);
......
......@@ -48,8 +48,8 @@ RadialMap::Widget::Widget(QWidget *parent, bool isSummary)
setAcceptDrops(true);
setMinimumSize(350, 250);
connect(this, SIGNAL(created(const Folder*)), SLOT(sendFakeMouseEvent()));
connect(this, SIGNAL(created(const Folder*)), SLOT(update()));
connect(this, SIGNAL(folderCreated(const Folder*)), SLOT(sendFakeMouseEvent()));
connect(this, SIGNAL(folderCreated(const Folder*)), SLOT(update()));
connect(&m_timer, SIGNAL(timeout()), SLOT(resizeTimeout()));
}
......@@ -119,7 +119,7 @@ RadialMap::Widget::create(const Folder *tree)
m_tree = tree;
//tell rest of Filelight
emit created(tree);
emit folderCreated(tree);
}
void
......
......@@ -82,7 +82,7 @@ private slots:
signals:
void activated(const QUrl&);
void invalidated(const QUrl&);
void created(const Folder*);
void folderCreated(const Folder*);
void mouseHover(const QString&);
void giveMeTreeFor(const QUrl&);
......
......@@ -89,8 +89,8 @@ RemoteLister::RemoteLister(const QUrl &url, QWidget *parent, ScanManager* manage
setMainWindow(parent);
// Use SIGNAL(result(KIO::Job*)) instead and then use Job::error()
connect(this, SIGNAL(completed()), SLOT(completed()));
connect(this, SIGNAL(canceled()), SLOT(canceled()));
connect(this, &RemoteLister::completed, this, &RemoteLister::completed);
connect(this, &RemoteLister::canceled, this, &RemoteLister::canceled);
}
RemoteLister::~RemoteLister()
......
......@@ -42,7 +42,7 @@ ScanManager::ScanManager(QObject *parent)
, m_cache(new Chain<Folder>)
{
Filelight::LocalLister::readMounts();
connect(this, SIGNAL(branchCacheHit(Folder*)), this, SLOT(foundCached(Folder*)), Qt::QueuedConnection);
connect(this, &ScanManager::branchCacheHit, this, &ScanManager::foundCached, Qt::QueuedConnection);
}
ScanManager::~ScanManager()
......@@ -83,7 +83,7 @@ bool ScanManager::start(const QUrl &url)
QGuiApplication::changeOverrideCursor(QCursor(Qt::BusyCursor));
//will start listing straight away
Filelight::RemoteLister *remoteLister = new Filelight::RemoteLister(url, (QWidget*)parent(), this);
connect(remoteLister, SIGNAL(branchCompleted(Folder*,bool)), this, SLOT(cacheTree(Folder*,bool)), Qt::QueuedConnection);
connect(remoteLister, &Filelight::RemoteLister::branchCompleted, this, &ScanManager::cacheTree, Qt::QueuedConnection);
remoteLister->setParent(this);
remoteLister->setObjectName(QLatin1String( "remote_lister" ));
remoteLister->openUrl(url);
......@@ -159,7 +159,7 @@ bool ScanManager::start(const QUrl &url)
QGuiApplication::changeOverrideCursor(QCursor(Qt::BusyCursor));
//starts listing by itself
m_thread = new Filelight::LocalLister(path, trees, this);
connect(m_thread, SIGNAL(branchCompleted(Folder*,bool)), this, SLOT(cacheTree(Folder*,bool)), Qt::QueuedConnection);
connect(m_thread, &LocalLister::branchCompleted, this, &ScanManager::cacheTree, Qt::QueuedConnection);
m_thread->start();
return true;
......
......@@ -32,6 +32,9 @@ template<class T> class Chain;
namespace Filelight
{
class LocalLister;
class ScanManager : public QObject
{
Q_OBJECT
......@@ -66,7 +69,7 @@ private:
uint m_files;
QMutex m_mutex;
QThread *m_thread;
LocalLister *m_thread;
Chain<Folder> *m_cache;
};
......
......@@ -64,32 +64,29 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
//read in settings before you make all those nasty connections!
reset(); //makes dialog reflect global settings
connect(&m_timer, SIGNAL(timeout()), SIGNAL(mapIsInvalid()));
connect(m_addButton, SIGNAL(clicked()), SLOT(addFolder()));
connect(m_removeButton, SIGNAL(clicked()), SLOT(removeFolder()));
connect(resetButton, SIGNAL(clicked()), SLOT(reset()));
connect(closeButton, SIGNAL(clicked()), SLOT(close()));
connect(m_schemaGroup, SIGNAL(buttonClicked(int)), SLOT(changeScheme(int)));
connect(contrastSlider, SIGNAL(valueChanged(int)), SLOT(changeContrast(int)));
connect(contrastSlider, SIGNAL(sliderReleased()), SLOT(slotSliderReleased()));
connect(scanAcrossMounts, SIGNAL(toggled(bool)), SLOT(startTimer()));
connect(dontScanRemoteMounts, SIGNAL(toggled(bool)), SLOT(startTimer()));
connect(dontScanRemovableMedia, SIGNAL(toggled(bool)), SLOT(startTimer()));
connect(scanAcrossMounts, SIGNAL(toggled(bool)),
SLOT(toggleScanAcrossMounts(bool)));
connect(dontScanRemoteMounts, SIGNAL(toggled(bool)),
SLOT(toggleDontScanRemoteMounts(bool)));
connect(dontScanRemovableMedia, SIGNAL(toggled(bool)),
SLOT(toggleDontScanRemovableMedia(bool)));
connect(useAntialiasing, SIGNAL(toggled(bool)), SLOT(toggleUseAntialiasing(bool)));
connect(varyLabelFontSizes, SIGNAL(toggled(bool)), SLOT(toggleVaryLabelFontSizes(bool)));
connect(showSmallFiles, SIGNAL(toggled(bool)), SLOT(toggleShowSmallFiles(bool)));
connect(minFontPitch, SIGNAL (valueChanged(int)), SLOT(changeMinFontPitch(int)));
connect(&m_timer, &QTimer::timeout, this, &SettingsDialog::mapIsInvalid);
connect(m_addButton, &QPushButton::clicked, this, &SettingsDialog::addFolder);
connect(m_removeButton, &QPushButton::clicked, this, &SettingsDialog::removeFolder);
connect(resetButton, &QPushButton::clicked, this, &SettingsDialog::reset);
connect(closeButton, &QPushButton::clicked, this, &SettingsDialog::close);
connect(m_schemaGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &SettingsDialog::changeScheme);
connect(contrastSlider, &QSlider::valueChanged, this, &SettingsDialog::changeContrast);
connect(contrastSlider, &QSlider::sliderReleased, this, &SettingsDialog::slotSliderReleased);
connect(scanAcrossMounts, &QCheckBox::toggled, this, &SettingsDialog::startTimer);
connect(dontScanRemoteMounts, &QCheckBox::toggled, this, &SettingsDialog::startTimer);
connect(dontScanRemovableMedia, &QCheckBox::toggled, this, &SettingsDialog::startTimer);
connect(scanAcrossMounts, &QCheckBox::toggled, this, &SettingsDialog::toggleScanAcrossMounts);
connect(dontScanRemoteMounts, &QCheckBox::toggled, this, &SettingsDialog::toggleDontScanRemoteMounts);
connect(dontScanRemovableMedia, &QCheckBox::toggled, this, &SettingsDialog::toggleDontScanRemovableMedia);
connect(useAntialiasing, &QCheckBox::toggled, this, &SettingsDialog::toggleUseAntialiasing);
connect(varyLabelFontSizes, &QCheckBox::toggled, this, &SettingsDialog::toggleVaryLabelFontSizes);
connect(showSmallFiles, &QCheckBox::toggled, this, &SettingsDialog::toggleShowSmallFiles);
connect(minFontPitch, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &SettingsDialog::changeMinFontPitch);
m_addButton->setIcon(QIcon::fromTheme(QLatin1String("folder-open")));
m_removeButton->setIcon(QIcon::fromTheme(QLatin1String("list-remove")));
......
......@@ -41,6 +41,9 @@
#include <QMouseEvent>
#include <QLayout>
namespace Filelight
{
struct Disk
{
QString mount;
......@@ -148,7 +151,7 @@ void SummaryWidget::createDiskMaps()
map->create(tree); //must be done when visible
connect(map, SIGNAL(activated(QUrl)), SIGNAL(activated(QUrl)));
connect(map, &RadialMap::Widget::activated, this, &SummaryWidget::activated);
}
}
......@@ -182,3 +185,5 @@ DiskList::DiskList()
*this += disk;
}
}
}
......@@ -26,6 +26,8 @@
#include <QWidget>
namespace Filelight {
class SummaryWidget : public QWidget
{
Q_OBJECT
......@@ -40,4 +42,6 @@ private:
void createDiskMaps();
};
}
#endif
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