Fixed clang-format with proper definition file

This commit is contained in:
Gaute Lindkvist 2019-08-26 12:33:38 +02:00
parent d93b43afbe
commit 245d3ad287
2 changed files with 92 additions and 87 deletions

View File

@ -3,8 +3,8 @@
// Custom Visualization Core library // Custom Visualization Core library
// Copyright (C) 2017 Ceetron Solutions AS // Copyright (C) 2017 Ceetron Solutions AS
// //
// This library may be used under the terms of either the GNU General Public // This library may be used under the terms of either the GNU General Public License or
// License or the GNU Lesser General Public License as follows: // the GNU Lesser General Public License as follows:
// //
// GNU General Public License Usage // GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify // This library is free software: you can redistribute it and/or modify
@ -12,12 +12,12 @@
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This library is distributed in the hope that it will be useful, but WITHOUT // This library is distributed in the hope that it will be useful, but WITHOUT ANY
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at // See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// <<http://www.gnu.org/licenses/gpl.html>> for more details. // for more details.
// //
// GNU Lesser General Public License Usage // GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify // This library is free software; you can redistribute it and/or modify
@ -25,17 +25,26 @@
// the Free Software Foundation; either version 2.1 of the License, or // the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This library is distributed in the hope that it will be useful, but WITHOUT // This library is distributed in the hope that it will be useful, but WITHOUT ANY
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU Lesser General Public License at // See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// <<http://www.gnu.org/licenses/lgpl-2.1.html>> for more details. // for more details.
// //
//################################################################################################## //##################################################################################################
#include "cafPdmUiTimeEditor.h" #include "cafPdmUiTimeEditor.h"
#include "cafFactory.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiOrdering.h"
#include "cafQShortenedLabel.h"
#include "cafSelectionManager.h"
#include <QApplication> #include <QApplication>
#include <QGridLayout> #include <QGridLayout>
#include <QIntValidator> #include <QIntValidator>
@ -47,75 +56,69 @@
#include <QStatusBar> #include <QStatusBar>
#include <QString> #include <QString>
#include "cafFactory.h" namespace caf
#include "cafPdmField.h" {
#include "cafPdmObject.h"
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiOrdering.h"
#include "cafQShortenedLabel.h"
#include "cafSelectionManager.h"
namespace caf {
CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(PdmUiTimeEditor); CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(PdmUiTimeEditor);
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void PdmUiTimeEditor::configureAndUpdateUi(const QString& uiConfigName) { void PdmUiTimeEditor::configureAndUpdateUi(const QString& uiConfigName)
CAF_ASSERT(!m_timeEdit.isNull()); {
CAF_ASSERT(!m_timeEdit.isNull());
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName); PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
m_timeEdit->setEnabled(!uiField()->isUiReadOnly(uiConfigName)); m_timeEdit->setEnabled(!uiField()->isUiReadOnly(uiConfigName));
caf::PdmUiObjectHandle* uiObject = caf::PdmUiObjectHandle* uiObject = uiObj(uiField()->fieldHandle()->ownerObject());
uiObj(uiField()->fieldHandle()->ownerObject()); if (uiObject)
if (uiObject) { {
uiObject->editorAttribute(uiField()->fieldHandle(), uiConfigName, uiObject->editorAttribute(uiField()->fieldHandle(), uiConfigName, &m_attributes);
&m_attributes); }
}
if (!m_attributes.timeFormat.isEmpty()) { if (!m_attributes.timeFormat.isEmpty())
m_timeEdit->setDisplayFormat(m_attributes.timeFormat); {
} m_timeEdit->setDisplayFormat(m_attributes.timeFormat);
}
m_timeEdit->setTime(uiField()->uiValue().toTime()); m_timeEdit->setTime(uiField()->uiValue().toTime());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QWidget* PdmUiTimeEditor::createEditorWidget(QWidget* parent) { QWidget* PdmUiTimeEditor::createEditorWidget(QWidget* parent)
m_timeEdit = new QTimeEdit(parent); {
connect(m_timeEdit, SIGNAL(editingFinished()), this, m_timeEdit = new QTimeEdit(parent);
SLOT(slotEditingFinished())); connect(m_timeEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
connect(m_timeEdit, SIGNAL(timeChanged(QTime)), this, connect(m_timeEdit, SIGNAL(timeChanged(QTime)), this, SLOT(slotTimeChanged(QTime)));
SLOT(slotTimeChanged(QTime))); return m_timeEdit;
return m_timeEdit;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QWidget* PdmUiTimeEditor::createLabelWidget(QWidget* parent) { QWidget* PdmUiTimeEditor::createLabelWidget(QWidget* parent)
m_label = new QShortenedLabel(parent); {
return m_label; m_label = new QShortenedLabel(parent);
return m_label;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void PdmUiTimeEditor::slotEditingFinished() { void PdmUiTimeEditor::slotEditingFinished()
this->setValueToField(m_timeEdit->time()); {
this->setValueToField(m_timeEdit->time());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void PdmUiTimeEditor::slotTimeChanged(const QTime& time) { void PdmUiTimeEditor::slotTimeChanged(const QTime& time)
this->setValueToField(m_timeEdit->time()); {
this->setValueToField(m_timeEdit->time());
} }
} // end namespace caf } // end namespace caf

View File

@ -3,8 +3,8 @@
// Custom Visualization Core library // Custom Visualization Core library
// Copyright (C) 2019- Ceetron Solutions AS // Copyright (C) 2019- Ceetron Solutions AS
// //
// This library may be used under the terms of either the GNU General Public // This library may be used under the terms of either the GNU General Public License or
// License or the GNU Lesser General Public License as follows: // the GNU Lesser General Public License as follows:
// //
// GNU General Public License Usage // GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify // This library is free software: you can redistribute it and/or modify
@ -12,12 +12,12 @@
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This library is distributed in the hope that it will be useful, but WITHOUT // This library is distributed in the hope that it will be useful, but WITHOUT ANY
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at // See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// <<http://www.gnu.org/licenses/gpl.html>> for more details. // for more details.
// //
// GNU Lesser General Public License Usage // GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify // This library is free software; you can redistribute it and/or modify
@ -25,63 +25,65 @@
// the Free Software Foundation; either version 2.1 of the License, or // the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This library is distributed in the hope that it will be useful, but WITHOUT // This library is distributed in the hope that it will be useful, but WITHOUT ANY
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU Lesser General Public License at // See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// <<http://www.gnu.org/licenses/lgpl-2.1.html>> for more details. // for more details.
// //
//################################################################################################## //##################################################################################################
#pragma once #pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include <QLabel> #include <QLabel>
#include <QPointer> #include <QPointer>
#include <QString> #include <QString>
#include <QTimeEdit> #include <QTimeEdit>
#include <QWidget> #include <QWidget>
#include "cafPdmUiFieldEditorHandle.h" namespace caf
{
namespace caf {
//================================================================================================== //==================================================================================================
/// ///
//================================================================================================== //==================================================================================================
class PdmUiTimeEditorAttribute : public PdmUiEditorAttribute { class PdmUiTimeEditorAttribute : public PdmUiEditorAttribute
public: {
QString timeFormat; public:
QString timeFormat;
public: public:
PdmUiTimeEditorAttribute() {} PdmUiTimeEditorAttribute() {}
}; };
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
class PdmUiTimeEditor : public PdmUiFieldEditorHandle { class PdmUiTimeEditor : public PdmUiFieldEditorHandle
Q_OBJECT {
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT; Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
public: public:
PdmUiTimeEditor() {} PdmUiTimeEditor() {}
~PdmUiTimeEditor() override {} ~PdmUiTimeEditor() override {}
protected: protected:
QWidget* createEditorWidget(QWidget* parent) override; QWidget* createEditorWidget(QWidget* parent) override;
QWidget* createLabelWidget(QWidget* parent) override; QWidget* createLabelWidget(QWidget* parent) override;
void configureAndUpdateUi(const QString& uiConfigName) override; void configureAndUpdateUi(const QString& uiConfigName) override;
protected slots: protected slots:
void slotEditingFinished(); void slotEditingFinished();
void slotTimeChanged(const QTime& time); void slotTimeChanged(const QTime& time);
private: private:
QPointer<QTimeEdit> m_timeEdit; QPointer<QTimeEdit> m_timeEdit;
QPointer<QShortenedLabel> m_label; QPointer<QShortenedLabel> m_label;
PdmUiTimeEditorAttribute m_attributes; PdmUiTimeEditorAttribute m_attributes;
}; };
} // end namespace caf } // end namespace caf