mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Diagram Folio List : add switch for folio ID or folio label
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4640 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -234,6 +234,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) : ConfigPage
|
||||
bool zoom_out_folio = settings.value("diagrameditor/zoom-out-beyond-of-folio", false).toBool();
|
||||
bool use_trackpad = settings.value("diagramview/gestures", false).toBool();
|
||||
bool save_label_paste = settings.value("diagramcommands/save-label", true).toBool();
|
||||
bool panel_folio = settings.value("genericpanel/folio", true).toBool();
|
||||
bool highlight_integrated_elements = settings.value("diagrameditor/highlight-integrated-elements", true).toBool();
|
||||
QString default_element_informations = settings.value("elementeditor/default-informations", "").toString();
|
||||
|
||||
@@ -244,6 +245,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) : ConfigPage
|
||||
tabbed_mode_ = new QRadioButton(tr("Utiliser des onglets (appliqué au prochain lancement de QElectroTech)"), projects_view_mode_);
|
||||
use_trackpad_ = new QCheckBox(tr("Utiliser les gestes du pavé tactile"), projects_view_mode_);
|
||||
save_label_paste_ = new QCheckBox(tr("Ne pas conserver les labels des éléments lors des copier coller"), projects_view_mode_);
|
||||
folio_panel_ = new QCheckBox(tr("utiliser les labels de folio à la place de leurs ID"), projects_view_mode_);
|
||||
m_zoom_out_beyond_folio = new QCheckBox(tr("Autoriser le dézoom au delà du folio"), this);
|
||||
|
||||
elements_management_ = new QGroupBox(tr("Gestion des éléments"), this);
|
||||
@@ -262,6 +264,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) : ConfigPage
|
||||
|
||||
use_trackpad_ -> setChecked(use_trackpad);
|
||||
save_label_paste_ -> setChecked(save_label_paste);
|
||||
folio_panel_ ->setChecked(panel_folio);
|
||||
|
||||
if (tabbed) {
|
||||
tabbed_mode_ -> setChecked(true);
|
||||
@@ -284,6 +287,8 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) : ConfigPage
|
||||
projects_view_mode_layout -> addWidget(m_zoom_out_beyond_folio);
|
||||
projects_view_mode_layout -> addWidget(use_trackpad_);
|
||||
projects_view_mode_layout -> addWidget(save_label_paste_);
|
||||
projects_view_mode_layout -> addWidget(folio_panel_);
|
||||
|
||||
projects_view_mode_ -> setLayout(projects_view_mode_layout);
|
||||
|
||||
QVBoxLayout *elements_management_layout = new QVBoxLayout();
|
||||
@@ -348,6 +353,7 @@ void GeneralConfigurationPage::applyConf()
|
||||
settings.setValue("diagramview/gestures", use_trackpad_ -> isChecked());
|
||||
settings.setValue("diagramcommands/save-label", save_label_paste_ -> isChecked());
|
||||
settings.setValue("diagrameditor/zoom-out-beyond-of-folio", m_zoom_out_beyond_folio->isChecked());
|
||||
settings.setValue("genericpanel/folio",folio_panel_->isChecked());
|
||||
}
|
||||
|
||||
/// @return l'icone de cette page
|
||||
|
||||
@@ -98,6 +98,7 @@ class GeneralConfigurationPage : public ConfigPage {
|
||||
QCheckBox *use_system_colors_;
|
||||
QCheckBox *use_trackpad_;
|
||||
QCheckBox *save_label_paste_;
|
||||
QCheckBox *folio_panel_;
|
||||
QGroupBox *projects_view_mode_;
|
||||
QRadioButton *windowed_mode_;
|
||||
QRadioButton *tabbed_mode_;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <QPainter>
|
||||
#include "qetapp.h"
|
||||
|
||||
qreal DiagramFolioList::colWidths[8] = {0.05, 0.05, 0.45, 0.10, 0.10, 0.05, 0.10, 0.10};
|
||||
qreal DiagramFolioList::colWidths[7] = {0.05, 0.50, 0.10, 0.10, 0.05, 0.10, 0.10};
|
||||
|
||||
/**
|
||||
* @brief DiagramFolioList::DiagramFolioList
|
||||
@@ -54,7 +54,7 @@ DiagramFolioList::~DiagramFolioList()
|
||||
void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r)
|
||||
{
|
||||
p -> save();
|
||||
|
||||
QSettings settings;
|
||||
// disable all antialiasing, except for the texts
|
||||
p -> setRenderHint(QPainter::Antialiasing, false);
|
||||
p -> setRenderHint(QPainter::TextAntialiasing, true);
|
||||
@@ -89,14 +89,24 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r)
|
||||
for (int i = startDiagram; i < startDiagram+29 && i < diagram_list.size(); ++i) {
|
||||
y0 += rowHeight;
|
||||
QRectF row_rect(x0, y0, list_rectangles_[0] -> width(), rowHeight);
|
||||
if (settings.value("genericpanel/folio", true).toBool()){
|
||||
fillRow(p, row_rect, diagram_list[i] -> border_and_titleblock.author(),
|
||||
diagram_list[i] -> title(),
|
||||
QString::number(diagram_list[i] ->folioIndex()+1),
|
||||
diagram_list[i] -> border_and_titleblock.folio(),
|
||||
diagram_list[i] -> border_and_titleblock.machine(),
|
||||
diagram_list[i] -> border_and_titleblock.locmach(),
|
||||
diagram_list[i] -> border_and_titleblock.indexrev(),
|
||||
diagram_list[i] -> border_and_titleblock.date().toString(Qt::SystemLocaleShortDate));
|
||||
}else{
|
||||
fillRow(p, row_rect, diagram_list[i] -> border_and_titleblock.author(),
|
||||
diagram_list[i] -> title(),
|
||||
QString::number(diagram_list[i] ->folioIndex()+1),
|
||||
diagram_list[i] -> border_and_titleblock.machine(),
|
||||
diagram_list[i] -> border_and_titleblock.locmach(),
|
||||
diagram_list[i] -> border_and_titleblock.indexrev(),
|
||||
diagram_list[i] -> border_and_titleblock.date().toString(Qt::SystemLocaleShortDate));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
border_and_titleblock.draw(p);
|
||||
@@ -110,16 +120,18 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r)
|
||||
* @param row_rect rectangle where we must draw the new row
|
||||
*/
|
||||
void DiagramFolioList::fillRow(QPainter *qp, const QRectF &row_rect, QString author, QString title,
|
||||
QString folio, QString label, QString machine, QString loc, QString indexrev, QString date)
|
||||
QString folio, QString machine, QString loc, QString indexrev, QString date)
|
||||
{
|
||||
qreal x = row_rect.topLeft().x();
|
||||
qreal y = row_rect.topLeft().y();
|
||||
QSettings settings;
|
||||
|
||||
|
||||
QFontMetrics origFontMetrics(QETApp::diagramTextsFont());
|
||||
qreal origFontSize = QETApp::diagramTextsFont().pointSizeF();
|
||||
QFont workingFont(QETApp::diagramTextsFont());
|
||||
|
||||
if (settings.value("genericpanel/folio", true).toBool()){
|
||||
// reduce the font size if the text entry is long
|
||||
if (origFontMetrics.width(folio) > 0.95*colWidths[0]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[0]*row_rect.width() / origFontMetrics.width(folio));
|
||||
@@ -127,75 +139,77 @@ void DiagramFolioList::fillRow(QPainter *qp, const QRectF &row_rect, QString aut
|
||||
workingFont.setPointSizeF(origFontSize);
|
||||
qp -> setFont(workingFont);
|
||||
qp -> drawText(QRectF(x, y, colWidths[0]*row_rect.width(), row_rect.height()), Qt::AlignCenter, folio);
|
||||
|
||||
x += colWidths[0]*row_rect.width();
|
||||
|
||||
if (origFontMetrics.width(label) > 0.95*colWidths[1]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[1]*row_rect.width() / origFontMetrics.width(label));
|
||||
}else{
|
||||
if (origFontMetrics.width(folio) > 0.95*colWidths[0]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[0]*row_rect.width() / origFontMetrics.width(folio));
|
||||
else
|
||||
workingFont.setPointSizeF(origFontSize);
|
||||
qp -> setFont(workingFont);
|
||||
qp -> drawText(QRectF(x, y, colWidths[1]*row_rect.width(), row_rect.height()), Qt::AlignCenter, label);
|
||||
x += colWidths[1]*row_rect.width();
|
||||
qp -> drawText(QRectF(x, y, colWidths[0]*row_rect.width(), row_rect.height()), Qt::AlignCenter, folio);
|
||||
x += colWidths[0]*row_rect.width();
|
||||
}
|
||||
|
||||
|
||||
if (origFontMetrics.width(title) > 0.95*colWidths[2]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[2]*row_rect.width() / origFontMetrics.width(title));
|
||||
if (origFontMetrics.width(title) > 0.95*colWidths[1]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[1]*row_rect.width() / origFontMetrics.width(title));
|
||||
else
|
||||
workingFont.setPointSizeF(origFontSize);
|
||||
qp -> setFont(workingFont);
|
||||
QString heading = tr("Titre");
|
||||
if (title == heading)
|
||||
qp -> drawText(QRectF(x, y, colWidths[2]*row_rect.width(),row_rect.height()), Qt::AlignCenter, title);
|
||||
qp -> drawText(QRectF(x, y, colWidths[1]*row_rect.width(),row_rect.height()), Qt::AlignCenter, title);
|
||||
else
|
||||
qp -> drawText(QRectF(x+0.01*row_rect.width(), y, colWidths[1]*row_rect.width()*10.2,
|
||||
row_rect.height()), Qt::AlignLeft | Qt::AlignVCenter, title);
|
||||
x += colWidths[2]*row_rect.width();
|
||||
x += colWidths[1]*row_rect.width();
|
||||
|
||||
|
||||
if (origFontMetrics.width(machine) > 0.95*colWidths[3]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[3]*row_rect.width() / origFontMetrics.width(machine));
|
||||
if (origFontMetrics.width(machine) > 0.95*colWidths[2]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[2]*row_rect.width() / origFontMetrics.width(machine));
|
||||
else
|
||||
workingFont.setPointSizeF(origFontSize);
|
||||
qp -> setFont(workingFont);
|
||||
qp -> drawText(QRectF(x, y, colWidths[3]*row_rect.width(), row_rect.height()), Qt::AlignCenter, machine);
|
||||
x += colWidths[2]*row_rect.width();
|
||||
|
||||
|
||||
if (origFontMetrics.width(loc) > 0.95*colWidths[3]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[3]*row_rect.width() / origFontMetrics.width(loc));
|
||||
else
|
||||
workingFont.setPointSizeF(origFontSize);
|
||||
qp -> setFont(workingFont);
|
||||
qp -> drawText(QRectF(x, y, colWidths[3]*row_rect.width(), row_rect.height()), Qt::AlignCenter, loc);
|
||||
x += colWidths[3]*row_rect.width();
|
||||
|
||||
|
||||
if (origFontMetrics.width(loc) > 0.95*colWidths[4]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[4]*row_rect.width() / origFontMetrics.width(loc));
|
||||
if (origFontMetrics.width(indexrev) > 0.95*colWidths[4]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[4]*row_rect.width() / origFontMetrics.width(indexrev));
|
||||
else
|
||||
workingFont.setPointSizeF(origFontSize);
|
||||
qp -> setFont(workingFont);
|
||||
qp -> drawText(QRectF(x, y, colWidths[4]*row_rect.width(), row_rect.height()), Qt::AlignCenter, loc);
|
||||
qp -> drawText(QRectF(x, y, colWidths[4]*row_rect.width(), row_rect.height()), Qt::AlignCenter, indexrev);
|
||||
x += colWidths[4]*row_rect.width();
|
||||
|
||||
|
||||
if (origFontMetrics.width(indexrev) > 0.95*colWidths[5]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[5]*row_rect.width() / origFontMetrics.width(indexrev));
|
||||
else
|
||||
workingFont.setPointSizeF(origFontSize);
|
||||
qp -> setFont(workingFont);
|
||||
qp -> drawText(QRectF(x, y, colWidths[5]*row_rect.width(), row_rect.height()), Qt::AlignCenter, indexrev);
|
||||
x += colWidths[5]*row_rect.width();
|
||||
|
||||
|
||||
|
||||
|
||||
if (origFontMetrics.width(author) > 0.95*colWidths[6]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[6]*row_rect.width() / origFontMetrics.width(author));
|
||||
if (origFontMetrics.width(author) > 0.95*colWidths[5]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[5]*row_rect.width() / origFontMetrics.width(author));
|
||||
else
|
||||
workingFont.setPointSizeF(origFontSize);
|
||||
qp -> setFont(workingFont);
|
||||
qp -> drawText(QRectF(x, y, colWidths[6]*row_rect.width(), row_rect.height()), Qt::AlignCenter, author);
|
||||
x += colWidths[6]*row_rect.width();
|
||||
x += colWidths[5]*row_rect.width();
|
||||
|
||||
|
||||
if (origFontMetrics.width(date) > 0.95*colWidths[7]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[7]*row_rect.width() / origFontMetrics.width(date));
|
||||
if (origFontMetrics.width(date) > 0.95*colWidths[6]*row_rect.width())
|
||||
workingFont.setPointSizeF(origFontSize * 0.95*colWidths[6]*row_rect.width() / origFontMetrics.width(date));
|
||||
else
|
||||
workingFont.setPointSizeF(origFontSize);
|
||||
qp -> setFont(workingFont);
|
||||
qp -> drawText(QRectF(x, y, colWidths[7]*row_rect.width(), row_rect.height()), Qt::AlignCenter, date);
|
||||
qp -> drawText(QRectF(x, y, colWidths[6]*row_rect.width(), row_rect.height()), Qt::AlignCenter, date);
|
||||
}
|
||||
|
||||
void DiagramFolioList::buildGrid(QPainter *qp, const QRectF &rect, int rows, int tables, qreal colWidths[])
|
||||
@@ -206,7 +220,7 @@ void DiagramFolioList::buildGrid(QPainter *qp, const QRectF &rect, int rows, int
|
||||
list_rectangles_.clear();
|
||||
|
||||
qreal sum = 0;
|
||||
for (int i = 0; i < 8; i++ )
|
||||
for (int i = 0; i < 7; i++ )
|
||||
sum += colWidths[i];
|
||||
if ( sum < 0.99 || sum > 1.01 ) {
|
||||
qDebug() << "Invalid input: Column widths do not sum to 1";
|
||||
@@ -216,7 +230,7 @@ void DiagramFolioList::buildGrid(QPainter *qp, const QRectF &rect, int rows, int
|
||||
qreal tablesSpacing = rect.height() * 0.02;
|
||||
qreal tableWidth = (rect.width() - tablesSpacing*(tables+1) ) / tables;
|
||||
qreal rowHeight = (rect.height() - 2*tablesSpacing) / rows;
|
||||
int cols = 8;//colWidths.size();
|
||||
int cols = 7;//colWidths.size();
|
||||
|
||||
qreal x0 = tablesSpacing + rect.topLeft().x();
|
||||
qreal y0 = tablesSpacing + rect.topLeft().y();
|
||||
@@ -249,15 +263,14 @@ void DiagramFolioList::buildGrid(QPainter *qp, const QRectF &rect, int rows, int
|
||||
void DiagramFolioList::fillHeader(QPainter *qp, const QRectF &row_RectF) {
|
||||
QString authorTranslatable(QObject::tr("Auteur"));
|
||||
QString titleTranslatable(QObject::tr("Titre"));
|
||||
QString folioTranslatable(QObject::tr("ID"));
|
||||
QString folioTranslatable(QObject::tr("Folio"));
|
||||
QString machineTranslatable(QObject::tr("Installation"));
|
||||
QString locTranslatable(QObject::tr("Localisation"));
|
||||
QString indexrevTranslatable(QObject::tr("Rev"));
|
||||
QString labelTranslatable(QObject::tr("Folio"));
|
||||
QString dateTranslatable(QObject::tr("Date"));
|
||||
|
||||
qp->save();
|
||||
qp->setFont(QETApp::diagramTextsFont(13));
|
||||
fillRow(qp, row_RectF, authorTranslatable, titleTranslatable, folioTranslatable, labelTranslatable, machineTranslatable, locTranslatable, indexrevTranslatable, dateTranslatable);
|
||||
fillRow(qp, row_RectF, authorTranslatable, titleTranslatable, folioTranslatable, machineTranslatable, locTranslatable, indexrevTranslatable, dateTranslatable);
|
||||
qp->restore();
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@ class DiagramFolioList : public Diagram
|
||||
void setId(int i) {id = i;}
|
||||
int getId() const {return id;}
|
||||
|
||||
static qreal colWidths[8];
|
||||
static qreal colWidths[7];
|
||||
|
||||
protected:
|
||||
void drawBackground(QPainter *, const QRectF &);
|
||||
|
||||
private:
|
||||
void fillRow(QPainter *, const QRectF &, QString, QString, QString, QString, QString, QString, QString, QString);
|
||||
void fillRow(QPainter *, const QRectF &, QString, QString, QString, QString, QString, QString, QString);
|
||||
void buildGrid(QPainter *, const QRectF &, int, int, qreal[]);
|
||||
void fillHeader(QPainter *, const QRectF &);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user