title block properties widget: minor improvement

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3210 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-07-13 13:37:43 +00:00
parent 1bb7d0bc02
commit 83583dd94e
4 changed files with 69 additions and 27 deletions

View File

@@ -647,16 +647,14 @@ void DiagramView::editDiagramProperties() {
BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, &popup); BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, &popup);
border_infos -> setReadOnly(diagram_is_read_only); border_infos -> setReadOnly(diagram_is_read_only);
TitleBlockPropertiesWidget *titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, &popup); TitleBlockPropertiesWidget *titleblock_infos;
if (QETProject *parent_project = scene -> project()) { if (QETProject *parent_project = scene -> project()) {
titleblock_infos -> setTitleBlockTemplatesCollection(parent_project -> embeddedTitleBlockTemplatesCollection()); titleblock_infos = new TitleBlockPropertiesWidget(parent_project -> embeddedTitleBlockTemplatesCollection(), titleblock, false, &popup);
titleblock_infos -> setTitleBlockTemplatesVisible(true);
// we have to parse again the TitleBlockProperties object, since the
// first parsing did not know of our templates
titleblock_infos -> setProperties(titleblock);
// relay the signal that requires a title block template edition
connect(titleblock_infos, SIGNAL(editTitleBlockTemplate(QString, bool)), this, SIGNAL(editTitleBlockTemplate(QString, bool))); connect(titleblock_infos, SIGNAL(editTitleBlockTemplate(QString, bool)), this, SIGNAL(editTitleBlockTemplate(QString, bool)));
} }
else
titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, &popup);
titleblock_infos -> setReadOnly(diagram_is_read_only); titleblock_infos -> setReadOnly(diagram_is_read_only);
ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(conductors); ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(conductors);

View File

@@ -39,6 +39,25 @@ TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockPropertie
setProperties(titleblock); setProperties(titleblock);
} }
/**
* @brief TitleBlockPropertiesWidget::TitleBlockPropertiesWidget
* default constructor with tempalte list
* @param tbt_collection template list
* @param titleblock properties to edit
* @param current_date if true, display the radio button "current date"
* @param parent parent widget
*/
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(TitleBlockTemplatesCollection *tbt_collection, const TitleBlockProperties &titleblock, bool current_date, QWidget *parent) :
QWidget(parent),
ui(new Ui::TitleBlockPropertiesWidget),
m_tbt_collection(nullptr)
{
ui->setupUi(this);
initDialog(current_date);
setTitleBlockTemplatesCollection(tbt_collection);
setProperties(titleblock);
}
/** /**
* @brief TitleBlockPropertiesWidget::~TitleBlockPropertiesWidget * @brief TitleBlockPropertiesWidget::~TitleBlockPropertiesWidget
* destructor * destructor
@@ -59,10 +78,11 @@ void TitleBlockPropertiesWidget::setProperties(const TitleBlockProperties &prope
ui -> m_folio_le -> setText (properties.folio); ui -> m_folio_le -> setText (properties.folio);
//About date //About date
on_m_fixed_date_rb_toggled(ui->m_fixed_date_rb->isChecked()); ui -> m_date_now_pb -> setDisabled(true);
ui -> m_date_edit -> setDisabled(true);
ui -> m_date_edit -> setDate(QDate::currentDate()); ui -> m_date_edit -> setDate(QDate::currentDate());
if (ui -> m_current_date_rb -> isVisible()) { if (!ui -> m_current_date_rb -> isHidden()) {
if(properties.useDate == TitleBlockProperties::CurrentDate) if(properties.useDate == TitleBlockProperties::CurrentDate)
ui -> m_current_date_rb -> setChecked(true); ui -> m_current_date_rb -> setChecked(true);
else { else {
@@ -175,6 +195,7 @@ void TitleBlockPropertiesWidget::setCurrentTitleBlockTemplateName (const QString
*/ */
void TitleBlockPropertiesWidget::setTitleBlockTemplatesCollection(TitleBlockTemplatesCollection *tbt_collection) { void TitleBlockPropertiesWidget::setTitleBlockTemplatesCollection(TitleBlockTemplatesCollection *tbt_collection) {
if (!tbt_collection) return; if (!tbt_collection) return;
setTitleBlockTemplatesVisible(true);
if (m_tbt_collection && tbt_collection != m_tbt_collection) { if (m_tbt_collection && tbt_collection != m_tbt_collection) {
// forget any connection with the previous collection // forget any connection with the previous collection
disconnect(m_tbt_collection, 0, this, 0); disconnect(m_tbt_collection, 0, this, 0);
@@ -272,13 +293,3 @@ void TitleBlockPropertiesWidget::changeCurrentTitleBlockTemplate(QString name) {
void TitleBlockPropertiesWidget::on_m_date_now_pb_clicked() { void TitleBlockPropertiesWidget::on_m_date_now_pb_clicked() {
ui -> m_date_edit -> setDate(QDate::currentDate()); ui -> m_date_edit -> setDate(QDate::currentDate());
} }
/**
* @brief TitleBlockPropertiesWidget::on_m_fixed_date_rb_toggled
* Disable widget related to fixed date, if radio button
* current date isn't checked
*/
void TitleBlockPropertiesWidget::on_m_fixed_date_rb_toggled(bool checked) {
ui -> m_date_edit -> setEnabled(checked);
ui -> m_date_now_pb -> setEnabled(checked);
}

View File

@@ -35,6 +35,7 @@ class TitleBlockPropertiesWidget : public QWidget
public: public:
explicit TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QWidget *parent = 0); explicit TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QWidget *parent = 0);
explicit TitleBlockPropertiesWidget(TitleBlockTemplatesCollection *tbt_collection, const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QWidget *parent = 0);
~TitleBlockPropertiesWidget(); ~TitleBlockPropertiesWidget();
void setProperties(const TitleBlockProperties &properties); void setProperties(const TitleBlockProperties &properties);
@@ -56,7 +57,6 @@ class TitleBlockPropertiesWidget : public QWidget
void updateTemplateList(); void updateTemplateList();
void changeCurrentTitleBlockTemplate(QString name); void changeCurrentTitleBlockTemplate(QString name);
void on_m_date_now_pb_clicked(); void on_m_date_now_pb_clicked();
void on_m_fixed_date_rb_toggled(bool checked);
signals: signals:
void editTitleBlockTemplate(const QString &, bool); void editTitleBlockTemplate(const QString &, bool);

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>508</width> <width>449</width>
<height>567</height> <height>387</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@@ -35,7 +35,7 @@
<item> <item>
<widget class="QGroupBox" name="m_tbt_gb"> <widget class="QGroupBox" name="m_tbt_gb">
<property name="title"> <property name="title">
<string>Informations du cartouche</string> <string>Informations des cartouche</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
@@ -78,7 +78,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@@ -280,5 +280,38 @@ associer le nom &quot;volta&quot; et la valeur &quot;1745&quot; remplacera %{vol
<resources> <resources>
<include location="../../qelectrotech.qrc"/> <include location="../../qelectrotech.qrc"/>
</resources> </resources>
<connections/> <connections>
<connection>
<sender>m_fixed_date_rb</sender>
<signal>toggled(bool)</signal>
<receiver>m_date_edit</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>146</x>
<y>199</y>
</hint>
<hint type="destinationlabel">
<x>275</x>
<y>199</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_fixed_date_rb</sender>
<signal>toggled(bool)</signal>
<receiver>m_date_now_pb</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>102</x>
<y>214</y>
</hint>
<hint type="destinationlabel">
<x>401</x>
<y>214</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>