Skip to content
Snippets Groups Projects
Commit 2081cf9c authored by Vitaly Fanaskov's avatar Vitaly Fanaskov
Browse files

Make code style more Qtish

parent 7d5b13a9
No related branches found
No related tags found
No related merge requests found
......@@ -107,8 +107,9 @@ void ExamplesDataSource::updateOpenedExamples()
for (auto project : ProjectExplorer::SessionManager::projects()) {
if (project) {
auto projectPath = QDir::fromNativeSeparators(project->projectFilePath().toString());
if (auto match = re.match(projectPath); match.hasMatch())
if (auto match = re.match(projectPath); match.hasMatch()) {
m_examplePaths << match.captured(examplePathGroupName());
}
}
}
}
......
......@@ -128,8 +128,9 @@ void ModeUsageTimeSource::onCurrentModeIdChanged(const Core::Id &modeId)
{
auto mode = modeFromString(QString::fromUtf8(modeId.name().toLower().simplified()));
if (m_currentMode == mode)
if (m_currentMode == mode) {
return;
}
if (m_currentTimer.isValid() && m_currentMode < ModesCount) {
m_timeByModes[m_currentMode] += m_currentTimer.elapsed();
......@@ -138,14 +139,16 @@ void ModeUsageTimeSource::onCurrentModeIdChanged(const Core::Id &modeId)
m_currentMode = mode;
if (m_currentMode != ModesCount)
if (m_currentMode != ModesCount) {
m_currentTimer.start();
}
}
void ModeUsageTimeSource::storeCurrentTimerValue()
{
if (m_currentTimer.isValid() && m_currentMode < ModesCount)
if (m_currentTimer.isValid() && m_currentMode < ModesCount) {
m_timeByModes[m_currentMode] += m_currentTimer.restart();
}
}
} // namespace Internal
......
......@@ -63,8 +63,9 @@ QmlDesignerUsageTimeSource::QmlDesignerUsageTimeSource()
QmlDesignerUsageTimeSource::~QmlDesignerUsageTimeSource()
{
// Connections shouldn't outlive this object, because 'this' is captured
for (auto &&connection : m_connections)
for (auto &&connection : m_connections) {
disconnect(connection);
}
}
QString QmlDesignerUsageTimeSource::name() const
......@@ -101,9 +102,9 @@ static bool editingQmlFile()
void QmlDesignerUsageTimeSource::updateTrackingState(const QString &modeName)
{
if (isDesignMode(modeName) && editingQmlFile() && !isTimeTrackingActive()) {
emit start();
Q_EMIT start();
} else {
emit stop();
Q_EMIT stop();
}
}
......
......@@ -48,8 +48,9 @@ TimeUsageSourceBase::TimeUsageSourceBase(const QString &id)
void TimeUsageSourceBase::onStarted()
{
// Restart if required
if (m_timer.isValid())
if (m_timer.isValid()) {
onStopped();
}
++m_startCount;
m_timer.start();
......@@ -57,8 +58,9 @@ void TimeUsageSourceBase::onStarted()
void TimeUsageSourceBase::onStopped()
{
if (m_timer.isValid())
if (m_timer.isValid()) {
m_usageTime += m_timer.elapsed();
}
m_timer.invalidate();
}
......
......@@ -59,7 +59,7 @@ void EncouragementWidget::setProvider(std::shared_ptr<Provider> provider)
{
m_provider = std::move(provider);
emit providerChanged(m_provider);
Q_EMIT providerChanged(m_provider);
}
void EncouragementWidget::showEvent(QShowEvent *event)
......
......@@ -53,10 +53,10 @@ public:
protected: // QWidget interface
void showEvent(QShowEvent *event) override;
signals:
Q_SIGNALS:
void providerChanged(const std::shared_ptr<KUserFeedback::Provider> &);
private slots:
private Q_SLOTS:
void showSettingsDialog();
void updateMessage();
void onProviderChanged(const std::shared_ptr<KUserFeedback::Provider> &p);
......
......@@ -34,9 +34,7 @@
namespace UsageStatistic::Internal {
OutputPane::OutputPane()
{
}
OutputPane::OutputPane() = default;
OutputPane::~OutputPane() = default;
......@@ -117,7 +115,7 @@ std::shared_ptr<KUserFeedback::Provider> OutputPane::provider() const
void OutputPane::setProvider(std::shared_ptr<KUserFeedback::Provider> provider)
{
m_provider = std::move(provider);
emit providerChanged(m_provider);
Q_EMIT providerChanged(m_provider);
}
} // namespace UsageStatistic::Internal
......@@ -79,7 +79,7 @@ public: // IOutputPane interface
std::shared_ptr<KUserFeedback::Provider> provider() const;
void setProvider(std::shared_ptr<KUserFeedback::Provider> provider);
signals:
Q_SIGNALS:
void providerChanged(std::shared_ptr<KUserFeedback::Provider>);
private: // Methods
......
......@@ -56,9 +56,11 @@ static void applyDataSourcesActiveStatuses(const QHash<QString, bool> &statuses,
const KUserFeedback::Provider &provider)
{
for (auto &&ds : provider.dataSources()) {
if (ds)
if (auto it = statuses.find(ds->id()); it != std::end(statuses))
if (ds) {
if (auto it = statuses.find(ds->id()); it != std::end(statuses)) {
ds->setActive(*it);
}
}
}
}
......@@ -69,7 +71,7 @@ void UsageStatisticPage::apply()
m_provider->setTelemetryMode(settings.telemetryMode);
applyDataSourcesActiveStatuses(settings.activeStatusesById, *m_provider);
emit settingsChanged();
Q_EMIT settingsChanged();
}
void UsageStatisticPage::finish()
......
......@@ -53,7 +53,7 @@ public: // IOptionsPage interface
void apply() override;
void finish() override;
signals:
Q_SIGNALS:
void settingsChanged();
private: // Data
......
......@@ -118,8 +118,9 @@ void UsageStatisticWidget::updateDataSources(int modeIndex)
auto item = dataSourceToItem(*ds, m_activeStatusesById).release();
ui->lvDataSources->addItem(item);
if (m_currentItemId == ds->id())
if (m_currentItemId == ds->id()) {
ui->lvDataSources->setCurrentItem(item);
}
}
}
}
......@@ -129,11 +130,13 @@ static QString collectedData(AbstractDataSource &ds)
QByteArray result;
auto variantData = ds.data();
if (variantData.canConvert<QVariantMap>())
if (variantData.canConvert<QVariantMap>()) {
result = QJsonDocument(QJsonObject::fromVariantMap(variantData.toMap())).toJson();
}
if (variantData.canConvert<QVariantList>())
if (variantData.canConvert<QVariantList>()) {
result = QJsonDocument(QJsonArray::fromVariantList(variantData.value<QVariantList>())).toJson();
}
return QString::fromUtf8(result);
}
......
......@@ -45,15 +45,9 @@
namespace UsageStatistic {
namespace Internal {
UsageStatisticPlugin::UsageStatisticPlugin()
{
}
UsageStatisticPlugin::UsageStatisticPlugin() = default;
UsageStatisticPlugin::~UsageStatisticPlugin()
{
// Unregister objects from the plugin manager's object pool
// Delete members
}
UsageStatisticPlugin::~UsageStatisticPlugin() = default;
bool UsageStatisticPlugin::initialize(const QStringList &arguments, QString *errorString)
{
......@@ -150,14 +144,16 @@ void UsageStatisticPlugin::configureOutputPane()
void UsageStatisticPlugin::storeSettings()
{
if (m_provider)
if (m_provider) {
m_provider->store();
}
}
void UsageStatisticPlugin::restoreSettings()
{
if (m_provider)
if (m_provider) {
m_provider->load();
}
}
static constexpr int encouragementTimeSec() { return 1800; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment