mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-14 21:49:57 +01:00
folio report: improve GUI and add unlinkcommand
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2720 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <elementprovider.h>
|
||||
#include <qetgraphicsitem/elementtextitem.h>
|
||||
#include <diagramcommands.h>
|
||||
#include "qeticons.h"
|
||||
|
||||
/**
|
||||
* @brief FolioReportProperties::FolioReportProperties : Construcor
|
||||
@@ -18,11 +19,9 @@ FolioReportProperties::FolioReportProperties(Element *elmt, QWidget *parent) :
|
||||
ui(new Ui::FolioReportProperties)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
sm_ = new QSignalMapper(this);
|
||||
connect(sm_, SIGNAL(mapped(int)) , this, SLOT(linkToElement(int)));
|
||||
|
||||
BuildRadioList();
|
||||
unlink = false;
|
||||
if(element_->isFree()) buildRadioList();
|
||||
else buildUnlinkButton();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +35,12 @@ FolioReportProperties::~FolioReportProperties()
|
||||
/**
|
||||
* @brief FolioReportProperties::BuildRadioList : build the radio list for each available folio report
|
||||
*/
|
||||
void FolioReportProperties::BuildRadioList() {
|
||||
void FolioReportProperties::buildRadioList() {
|
||||
sm_ = new QSignalMapper(this);
|
||||
connect(sm_, SIGNAL(mapped(int)), this, SLOT(linkToElement(int)));
|
||||
sm_show_ = new QSignalMapper(this);
|
||||
connect(sm_show_, SIGNAL(mapped(int)), this, SLOT(showDiagram(int)));
|
||||
|
||||
//Research the invert report of @element_
|
||||
int rep = element_->linkType() == Element::NextReport? Element::PreviousReport : Element::NextReport;
|
||||
ElementProvider ep(element_->diagram()->project(), element_->diagram());
|
||||
@@ -53,23 +57,71 @@ void FolioReportProperties::BuildRadioList() {
|
||||
.arg(elmt->diagram() -> convertPosition(elmt -> scenePos()).toString());
|
||||
|
||||
//button himself
|
||||
QHBoxLayout *hl = new QHBoxLayout(this);
|
||||
QRadioButton *rb = new QRadioButton(button_text , this);
|
||||
ui->available_report_layout->addWidget(rb);
|
||||
QPushButton *pb = new QPushButton(QET::Icons::ZoomDraw,"",this);
|
||||
hl->addWidget(rb);
|
||||
hl->addStretch();
|
||||
hl->addWidget(pb);
|
||||
ui->available_report_layout->addLayout(hl);
|
||||
element_list << elmt;
|
||||
//map the radio button signal
|
||||
connect(rb, SIGNAL(clicked()), sm_, SLOT(map()));
|
||||
sm_ -> setMapping(rb, element_list.size()-1);
|
||||
//map the push button show diagram
|
||||
connect(pb, SIGNAL(clicked()), sm_show_, SLOT(map()));
|
||||
sm_show_->setMapping(pb, element_list.size()-1);
|
||||
}
|
||||
}
|
||||
ui->available_report_layout->addStretch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FolioReportProperties::buildUnlinkButton
|
||||
*build button for ask user if want to unlink this element
|
||||
*/
|
||||
void FolioReportProperties::buildUnlinkButton() {
|
||||
unlink_widget = new QWidget(this);
|
||||
QHBoxLayout *unlink_layout = new QHBoxLayout(unlink_widget);
|
||||
QLabel *lb = new QLabel(tr("Ce report est d\351j\340 lier."), unlink_widget);
|
||||
QPushButton *pb = new QPushButton(tr("D\351lier"), unlink_widget);
|
||||
connect(pb, SIGNAL(clicked()), this, SLOT(unlinkClicked()));
|
||||
unlink_layout->addWidget(lb);
|
||||
unlink_layout->addStretch();
|
||||
unlink_layout->addWidget(pb);
|
||||
ui->v_main_layout->insertWidget(0, unlink_widget);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FolioReportProperties::Apply
|
||||
* Apply the new properties for this folio report
|
||||
*/
|
||||
void FolioReportProperties::Apply() {
|
||||
if (element_to_link) {
|
||||
if (unlink && !element_to_link)
|
||||
element_->diagram()->undoStack().push(new unlinkElementsCommand(element_));
|
||||
else if (element_to_link)
|
||||
element_->diagram()->undoStack().push(new LinkElementsCommand(element_, element_to_link));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FolioReportProperties::unlinkClicked
|
||||
*this slot remove unlink_layout and call buildRadioList
|
||||
*/
|
||||
void FolioReportProperties::unlinkClicked() {
|
||||
ui->v_main_layout->removeWidget(unlink_widget);
|
||||
delete unlink_widget;
|
||||
unlink = true;
|
||||
buildRadioList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FolioReportProperties::showDiagram
|
||||
* Show the wanted report element
|
||||
* @param i position of wanted element in element_list
|
||||
*/
|
||||
void FolioReportProperties::showDiagram(const int i) {
|
||||
Element *elmt = element_list.at(i);
|
||||
elmt->diagram()->showMe();
|
||||
foreach (QGraphicsItem *qgi, elmt->diagram()->selectedItems()) qgi->setSelected(false);
|
||||
elmt->setSelected(true);
|
||||
}
|
||||
|
||||
@@ -15,19 +15,22 @@ class FolioReportProperties : public QWidget
|
||||
public:
|
||||
explicit FolioReportProperties(Element *elmt, QWidget *parent = 0);
|
||||
~FolioReportProperties();
|
||||
void BuildRadioList();
|
||||
void buildRadioList();
|
||||
void buildUnlinkButton();
|
||||
void Apply();
|
||||
|
||||
private slots:
|
||||
void linkToElement(const int i) {element_to_link = element_list.at(i);}
|
||||
void unlinkClicked();
|
||||
void showDiagram(const int i);
|
||||
|
||||
private:
|
||||
Element *element_, *element_to_link;
|
||||
QList <Element *> element_list;
|
||||
Ui::FolioReportProperties *ui;
|
||||
QSignalMapper *sm_;
|
||||
|
||||
|
||||
QSignalMapper *sm_, *sm_show_;
|
||||
QWidget *unlink_widget;
|
||||
bool unlink;
|
||||
};
|
||||
|
||||
#endif // FOLIOREPORTPROPERTIES_H
|
||||
|
||||
@@ -14,8 +14,11 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="main_H_layout">
|
||||
<layout class="QVBoxLayout" name="v_main_layout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="Report_gb">
|
||||
<property name="toolTip">
|
||||
@@ -61,6 +64,9 @@
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user