Animate show and replace widget.

this feature is totally useless and by consequent indispensable.
This commit is contained in:
Claveau Joshua
2020-04-23 19:52:56 +02:00
parent f4cbf21075
commit 9525278be7
8 changed files with 606 additions and 238 deletions

View File

@@ -44,6 +44,13 @@ SearchAndReplaceWidget::SearchAndReplaceWidget(QWidget *parent) :
ui(new Ui::SearchAndReplaceWidget)
{
ui->setupUi(this);
m_horizontal_animation = new QWidgetAnimation(ui->m_advanced_button_widget, Qt::Horizontal, QWidgetAnimation::minimumSizeHint, 250);
m_vertical_animation = new QWidgetAnimation(ui->m_advanced_widget, Qt::Vertical, QWidgetAnimation::availableSpace, 250);
QVector<QWidget *> v;
v << ui->m_header_widget;
m_vertical_animation->widgetToSubtract(v);
setHideAdvanced(true);
setUpTreeItems();
@@ -70,7 +77,6 @@ bool SearchAndReplaceWidget::event(QEvent *event)
if (event->type() == QEvent::Hide)
{
clear();
setHideAdvanced(true);
if (m_highlighted_element)
{
m_highlighted_element.data()->setHighlighted(false);
@@ -204,20 +210,10 @@ void SearchAndReplaceWidget::setUpTreeItems()
* Hide advanced widgets
* @param hide
*/
void SearchAndReplaceWidget::setHideAdvanced(bool hide) const
void SearchAndReplaceWidget::setHideAdvanced(bool hide)
{
ui->m_advanced_pb ->setChecked(!hide);
ui->m_replace ->setHidden(hide);
ui->m_replace_le ->setHidden(hide);
ui->m_folio_pb ->setHidden(hide);
ui->m_element_pb ->setHidden(hide);
ui->m_conductor_pb ->setHidden(hide);
ui->m_tree_widget ->setHidden(hide);
ui->m_replace_pb ->setHidden(hide);
ui->m_replace_all_pb ->setHidden(hide);
ui->m_mode_cb ->setHidden(hide);
ui->m_case_sensitive_cb->setHidden(hide);
ui->m_advanced_replace_pb->setHidden(hide);
m_vertical_animation->setHidden(hide);
m_horizontal_animation->setHidden(hide);
}
/**

View File

@@ -24,6 +24,7 @@
#include "element.h"
#include "independenttextitem.h"
#include "searchandreplaceworker.h"
#include "QWidgetAnimation/qwidgetanimation.h"
class QTreeWidgetItem;
@@ -39,7 +40,7 @@ class SearchAndReplaceWidget : public QWidget
public:
explicit SearchAndReplaceWidget(QWidget *parent = nullptr);
~SearchAndReplaceWidget();
~SearchAndReplaceWidget() override;
bool event(QEvent *event) override;
void clear();
@@ -47,7 +48,7 @@ class SearchAndReplaceWidget : public QWidget
private:
void setUpTreeItems();
void setHideAdvanced(bool hide) const;
void setHideAdvanced(bool hide);
void fillItemsList();
void addElement(Element *element);
void search();
@@ -109,6 +110,8 @@ class SearchAndReplaceWidget : public QWidget
QPointer<QGraphicsObject> m_last_selected;
QHash<QTreeWidgetItem *, QPointer <Diagram>> m_diagram_hash;
SearchAndReplaceWorker m_worker;
QWidgetAnimation *m_vertical_animation;
QWidgetAnimation *m_horizontal_animation;
};
#endif // SEARCHANDREPLACEWIDGET_H

View File

@@ -6,22 +6,331 @@
<rect>
<x>0</x>
<y>0</y>
<width>970</width>
<height>436</height>
<width>989</width>
<height>661</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,1" columnstretch="0,0,1,0,0,0,0,0,0,0,0,0,0">
<item row="0" column="1">
<widget class="QLabel" name="m_search">
<property name="text">
<string>Chercher :</string>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0" columnstretch="0,0">
<property name="leftMargin">
<number>9</number>
</property>
<item row="1" column="1">
<widget class="QWidget" name="m_header_widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="m_search">
<property name="text">
<string>Chercher :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="m_search_le">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="m_advanced_button_widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="m_mode_cb">
<property name="toolTip">
<string>Mode</string>
</property>
<property name="frame">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>Texte brut</string>
</property>
</item>
<item>
<property name="text">
<string>Mots entiers</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="m_case_sensitive_cb">
<property name="text">
<string>Sensible à la casse</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_next_pb">
<property name="toolTip">
<string>Aller à la correspondance suivante</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/go-bottom.png</normaloff>:/ico/16x16/go-bottom.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_previous_pb">
<property name="toolTip">
<string>Aller à la correspondance précédente</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/go-top.png</normaloff>:/ico/16x16/go-top.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_reload_pb">
<property name="toolTip">
<string>Actualiser</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/view-refresh.png</normaloff>:/ico/16x16/view-refresh.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_advanced_pb">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Afficher les options avancées&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/configure-toolbars.png</normaloff>:/ico/16x16/configure-toolbars.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<item row="2" column="1">
<widget class="QWidget" name="m_advanced_widget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<item row="0" column="3">
<widget class="QPushButton" name="m_element_pb">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Définir les propriétés à remplacer dans les éléments&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Élément</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="m_conductor_pb">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Définir les propriétés à remplacer dans les conducteurs&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Conducteur</string>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QPushButton" name="m_replace_all_pb">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Remplacer les correspondances cochées&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Tout remplacer</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="m_advanced_replace_pb">
<property name="text">
<string>avancé</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="m_replace">
<property name="text">
<string>Remplacer :</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="m_folio_pb">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Définir les propriétés à remplacer dans les folios&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Folio</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="m_replace_le">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="placeholderText">
<string>Champ texte de folio</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QPushButton" name="m_replace_pb">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Remplacer la correspondance sélectionnée&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Remplacer</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="9">
<widget class="QTreeWidget" name="m_tree_widget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="animated">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="0" column="6">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="m_quit_button">
<property name="toolTip">
<string>Quitter</string>
@@ -38,217 +347,18 @@
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QComboBox" name="m_mode_cb">
<property name="toolTip">
<string>Mode</string>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="frame">
<bool>true</bool>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
<item>
<property name="text">
<string>Texte brut</string>
</property>
</item>
<item>
<property name="text">
<string>Mots entiers</string>
</property>
</item>
</widget>
</item>
<item row="0" column="8">
<widget class="QCheckBox" name="m_case_sensitive_cb">
<property name="text">
<string>Sensible à la casse</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="m_replace">
<property name="text">
<string>Remplacer :</string>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QPushButton" name="m_next_pb">
<property name="toolTip">
<string>Aller à la correspondance suivante</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/go-bottom.png</normaloff>:/ico/16x16/go-bottom.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="10">
<widget class="QPushButton" name="m_previous_pb">
<property name="toolTip">
<string>Aller à la correspondance précédente</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/go-top.png</normaloff>:/ico/16x16/go-top.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="12">
<widget class="QPushButton" name="m_advanced_pb">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Afficher les options avancées&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/configure-toolbars.png</normaloff>:/ico/16x16/configure-toolbars.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="11">
<widget class="QPushButton" name="m_reload_pb">
<property name="toolTip">
<string>Actualiser</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/view-refresh.png</normaloff>:/ico/16x16/view-refresh.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="m_replace_le">
<property name="placeholderText">
<string>Champ texte de folio</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="m_folio_pb">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Définir les propriétés à remplacer dans les folios&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Folio</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="m_element_pb">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Définir les propriétés à remplacer dans les éléments&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Élément</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QPushButton" name="m_conductor_pb">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Définir les propriétés à remplacer dans les conducteurs&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Conducteur</string>
</property>
</widget>
</item>
<item row="1" column="9" colspan="2">
<widget class="QPushButton" name="m_replace_pb">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Remplacer la correspondance sélectionnée&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Remplacer</string>
</property>
</widget>
</item>
<item row="1" column="11" colspan="2">
<widget class="QPushButton" name="m_replace_all_pb">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Remplacer les correspondances cochées&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Tout remplacer</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="13">
<widget class="QTreeWidget" name="m_tree_widget">
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="animated">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="1" column="6">
<widget class="QPushButton" name="m_advanced_replace_pb">
<property name="text">
<string>avancé</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="5">
<widget class="QLineEdit" name="m_search_le">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</spacer>
</item>
</layout>
</widget>