mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Title block template editor: added tooltips to helper cells to ensure their content remains readable even when their size is reduced.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@1772 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
f54e3bb90b
commit
dd237b148e
@ -118,6 +118,17 @@ QList<QAction *> HelperCell::actions() const {
|
|||||||
return actions_;
|
return actions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param text New label displayed by this helper cell
|
||||||
|
@param set_as_tooltip If true, the text is also used as tooltip.
|
||||||
|
*/
|
||||||
|
void HelperCell::setLabel(const QString &text, bool set_as_tooltip) {
|
||||||
|
label = text;
|
||||||
|
if (set_as_tooltip) {
|
||||||
|
setToolTip(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handle context menu events.
|
Handle context menu events.
|
||||||
@param event Context menu event.
|
@param event Context menu event.
|
||||||
|
@ -52,6 +52,7 @@ class HelperCell : public QGraphicsObject, public QGraphicsLayoutItem {
|
|||||||
virtual void setType(QET::TitleBlockColumnLength);
|
virtual void setType(QET::TitleBlockColumnLength);
|
||||||
virtual void setActions(const QList<QAction *> &);
|
virtual void setActions(const QList<QAction *> &);
|
||||||
virtual QList<QAction *> actions() const;
|
virtual QList<QAction *> actions() const;
|
||||||
|
virtual void setLabel(const QString &text, bool = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *);
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *);
|
||||||
|
@ -48,7 +48,6 @@ void SplittedHelperCell::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||||||
}
|
}
|
||||||
QRectF first_drawing_rectangle(QPointF(0, 0), geometry().adjusted(0, 0, -split_size, 0).size());
|
QRectF first_drawing_rectangle(QPointF(0, 0), geometry().adjusted(0, 0, -split_size, 0).size());
|
||||||
QRectF second_drawing_rectangle(first_drawing_rectangle.topRight(), QSize(split_size, first_drawing_rectangle.height()));
|
QRectF second_drawing_rectangle(first_drawing_rectangle.topRight(), QSize(split_size, first_drawing_rectangle.height()));
|
||||||
qDebug() << first_drawing_rectangle << second_drawing_rectangle;
|
|
||||||
|
|
||||||
painter -> setPen(Qt::black);
|
painter -> setPen(Qt::black);
|
||||||
painter -> setBrush(background_color);
|
painter -> setBrush(background_color);
|
||||||
|
@ -603,9 +603,11 @@ void TitleBlockTemplateView::applyColumnsWidths(bool animate) {
|
|||||||
tbgrid_ -> addItem(extra_cells_width_helper_cell_, ROW_OFFSET - 1, COL_OFFSET + widths.count(), tbtemplate_ -> rowsCount() + 1, 1);
|
tbgrid_ -> addItem(extra_cells_width_helper_cell_, ROW_OFFSET - 1, COL_OFFSET + widths.count(), tbtemplate_ -> rowsCount() + 1, 1);
|
||||||
tbgrid_ -> addItem(total_width_helper_cell_, 0, COL_OFFSET, 1, widths.count() + 1);
|
tbgrid_ -> addItem(total_width_helper_cell_, 0, COL_OFFSET, 1, widths.count() + 1);
|
||||||
tbgrid_ -> setColumnFixedWidth(COL_OFFSET + widths.count(), preview_width_ - total_applied_width);
|
tbgrid_ -> setColumnFixedWidth(COL_OFFSET + widths.count(), preview_width_ - total_applied_width);
|
||||||
extra_cells_width_helper_cell_ -> label = QString(
|
extra_cells_width_helper_cell_ -> setLabel(
|
||||||
tr("[%1px]","content of the extra cell added when the total width of cells is less than the preview width")
|
QString(
|
||||||
).arg(preview_width_ - total_applied_width);
|
tr("[%1px]","content of the extra cell added when the total width of cells is less than the preview width")
|
||||||
|
).arg(preview_width_ - total_applied_width)
|
||||||
|
);
|
||||||
} else if (total_applied_width > preview_width_) {
|
} else if (total_applied_width > preview_width_) {
|
||||||
// preview width is smaller than the sum of cells widths
|
// preview width is smaller than the sum of cells widths
|
||||||
// we draw an extra header within th "preview width" cell.
|
// we draw an extra header within th "preview width" cell.
|
||||||
@ -666,7 +668,7 @@ void TitleBlockTemplateView::updateRowsHelperCells() {
|
|||||||
HelperCell *current_row_cell = static_cast<HelperCell *>(tbgrid_ -> itemAt(ROW_OFFSET + i, 0));
|
HelperCell *current_row_cell = static_cast<HelperCell *>(tbgrid_ -> itemAt(ROW_OFFSET + i, 0));
|
||||||
if (current_row_cell) {
|
if (current_row_cell) {
|
||||||
current_row_cell -> setType(QET::Absolute); // rows always have absolute heights
|
current_row_cell -> setType(QET::Absolute); // rows always have absolute heights
|
||||||
current_row_cell -> label = QString(tr("%1px", "format displayed in rows helper cells")).arg(heights.at(i));
|
current_row_cell -> setLabel(QString(tr("%1px", "format displayed in rows helper cells")).arg(heights.at(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -681,7 +683,7 @@ void TitleBlockTemplateView::updateColumnsHelperCells() {
|
|||||||
HelperCell *current_col_cell = static_cast<HelperCell *>(tbgrid_ -> itemAt(1, COL_OFFSET + i));
|
HelperCell *current_col_cell = static_cast<HelperCell *>(tbgrid_ -> itemAt(1, COL_OFFSET + i));
|
||||||
if (current_col_cell) {
|
if (current_col_cell) {
|
||||||
current_col_cell -> setType(current_col_dim.type);
|
current_col_cell -> setType(current_col_dim.type);
|
||||||
current_col_cell -> label = current_col_dim.toString();
|
current_col_cell -> setLabel(current_col_dim.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -714,7 +716,7 @@ void TitleBlockTemplateView::addCells() {
|
|||||||
TitleBlockDimension current_col_dim = tbtemplate_ -> columnDimension(i);
|
TitleBlockDimension current_col_dim = tbtemplate_ -> columnDimension(i);
|
||||||
HelperCell *current_col_cell = new HelperCell();
|
HelperCell *current_col_cell = new HelperCell();
|
||||||
current_col_cell -> setType(current_col_dim.type);
|
current_col_cell -> setType(current_col_dim.type);
|
||||||
current_col_cell -> label = current_col_dim.toString();
|
current_col_cell -> setLabel(current_col_dim.toString());
|
||||||
current_col_cell -> setActions(columnsActions());
|
current_col_cell -> setActions(columnsActions());
|
||||||
current_col_cell -> orientation = Qt::Horizontal;
|
current_col_cell -> orientation = Qt::Horizontal;
|
||||||
current_col_cell -> index = i;
|
current_col_cell -> index = i;
|
||||||
@ -728,7 +730,7 @@ void TitleBlockTemplateView::addCells() {
|
|||||||
for (int i = 0 ; i < row_count ; ++ i) {
|
for (int i = 0 ; i < row_count ; ++ i) {
|
||||||
HelperCell *current_row_cell = new HelperCell();
|
HelperCell *current_row_cell = new HelperCell();
|
||||||
current_row_cell -> setType(QET::Absolute); // rows always have absolute heights
|
current_row_cell -> setType(QET::Absolute); // rows always have absolute heights
|
||||||
current_row_cell -> label = QString(tr("%1px")).arg(heights.at(i));
|
current_row_cell -> setLabel(QString(tr("%1px")).arg(heights.at(i)));
|
||||||
current_row_cell -> orientation = Qt::Vertical;
|
current_row_cell -> orientation = Qt::Vertical;
|
||||||
current_row_cell -> index = i;
|
current_row_cell -> index = i;
|
||||||
current_row_cell -> setActions(rowsActions());
|
current_row_cell -> setActions(rowsActions());
|
||||||
@ -942,6 +944,12 @@ void TitleBlockTemplateView::updateDisplayedMinMaxWidth() {
|
|||||||
).arg(min_width);
|
).arg(min_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the tooltip may also display the split label for readability purpose
|
||||||
|
if (total_width_helper_cell_ -> split_size) {
|
||||||
|
min_max_width_sentence += "---\n";
|
||||||
|
min_max_width_sentence += total_width_helper_cell_ -> split_label;
|
||||||
|
}
|
||||||
|
|
||||||
total_width_helper_cell_ -> setToolTip(makePrettyToolTip(min_max_width_sentence));
|
total_width_helper_cell_ -> setToolTip(makePrettyToolTip(min_max_width_sentence));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user