[qet] [1772] Title block template editor: added tooltips to helper cells to ensure their content remains readable even when their size is reduced .

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 1772
Author:   xavier
Date:     2012-05-09 04:31:41 +0200 (Wed, 09 May 2012)
Log Message:
-----------
Title block template editor: added tooltips to helper cells to ensure their content remains readable even when their size is reduced.

Modified Paths:
--------------
    trunk/sources/titleblock/helpercell.cpp
    trunk/sources/titleblock/helpercell.h
    trunk/sources/titleblock/splittedhelpercell.cpp
    trunk/sources/titleblock/templateview.cpp

Modified: trunk/sources/titleblock/helpercell.cpp
===================================================================
--- trunk/sources/titleblock/helpercell.cpp	2012-05-09 02:31:40 UTC (rev 1771)
+++ trunk/sources/titleblock/helpercell.cpp	2012-05-09 02:31:41 UTC (rev 1772)
@@ -119,6 +119,17 @@
 }
 
 /**
+	@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.
 	@param event Context menu event.
 */

Modified: trunk/sources/titleblock/helpercell.h
===================================================================
--- trunk/sources/titleblock/helpercell.h	2012-05-09 02:31:40 UTC (rev 1771)
+++ trunk/sources/titleblock/helpercell.h	2012-05-09 02:31:41 UTC (rev 1772)
@@ -52,6 +52,7 @@
 	virtual void setType(QET::TitleBlockColumnLength);
 	virtual void setActions(const QList<QAction *> &);
 	virtual QList<QAction *> actions() const;
+	virtual void setLabel(const QString &text, bool = true);
 	
 	protected:
 	void contextMenuEvent(QGraphicsSceneContextMenuEvent *);

Modified: trunk/sources/titleblock/splittedhelpercell.cpp
===================================================================
--- trunk/sources/titleblock/splittedhelpercell.cpp	2012-05-09 02:31:40 UTC (rev 1771)
+++ trunk/sources/titleblock/splittedhelpercell.cpp	2012-05-09 02:31:41 UTC (rev 1772)
@@ -48,7 +48,6 @@
 	}
 	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()));
-	qDebug() << first_drawing_rectangle << second_drawing_rectangle;
 	
 	painter -> setPen(Qt::black);
 	painter -> setBrush(background_color);

Modified: trunk/sources/titleblock/templateview.cpp
===================================================================
--- trunk/sources/titleblock/templateview.cpp	2012-05-09 02:31:40 UTC (rev 1771)
+++ trunk/sources/titleblock/templateview.cpp	2012-05-09 02:31:41 UTC (rev 1772)
@@ -603,9 +603,11 @@
 		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_ -> setColumnFixedWidth(COL_OFFSET + widths.count(), preview_width_ - total_applied_width);
-		extra_cells_width_helper_cell_ -> label = QString(
-			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);
+		extra_cells_width_helper_cell_ -> setLabel(
+			QString(
+				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_) {
 		// preview width is smaller than the sum of cells widths
 		// we draw an extra header within th "preview width" cell.
@@ -666,7 +668,7 @@
 		HelperCell *current_row_cell = static_cast<HelperCell *>(tbgrid_ -> itemAt(ROW_OFFSET + i, 0));
 		if (current_row_cell) {
 			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 @@
 		HelperCell *current_col_cell = static_cast<HelperCell *>(tbgrid_ -> itemAt(1, COL_OFFSET + i));
 		if (current_col_cell) {
 			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 @@
 		TitleBlockDimension current_col_dim = tbtemplate_ -> columnDimension(i);
 		HelperCell *current_col_cell = new HelperCell();
 		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 -> orientation = Qt::Horizontal;
 		current_col_cell -> index = i;
@@ -728,7 +730,7 @@
 	for (int i = 0 ; i < row_count ; ++ i) {
 		HelperCell *current_row_cell = new HelperCell();
 		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 -> index = i;
 		current_row_cell -> setActions(rowsActions());
@@ -942,6 +944,12 @@
 		).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));
 }
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/