Wrap code for better readability

This commit is contained in:
Simon De Backer
2020-09-07 22:03:40 +02:00
parent 8ee38fab9e
commit 5d92393ee7
202 changed files with 4031 additions and 2153 deletions

View File

@@ -31,7 +31,8 @@ TitleBlockDimension::TitleBlockDimension(int v, QET::TitleBlockColumnLength t) :
/**
@return a string describing this dimension in a human-readable format.
*/
QString TitleBlockDimension::toString() const {
QString TitleBlockDimension::toString() const
{
QString dim_str;
if (type == QET::Absolute) {
dim_str = QObject::tr("%1px", "titleblock: absolute width");
@@ -46,7 +47,8 @@ QString TitleBlockDimension::toString() const {
/**
@return a string describing this dimension in a short format.
*/
QString TitleBlockDimension::toShortString() const {
QString TitleBlockDimension::toShortString() const
{
QString short_string;
if (type == QET::RelativeToTotalLength) {
short_string = "t";

View File

@@ -36,13 +36,15 @@ TitleBlockDimensionWidget::TitleBlockDimensionWidget(bool complete, QWidget *par
/**
Destructor
*/
TitleBlockDimensionWidget::~TitleBlockDimensionWidget() {
TitleBlockDimensionWidget::~TitleBlockDimensionWidget()
{
}
/**
@return true if this dialog shows the optional radio buttons
*/
bool TitleBlockDimensionWidget::isComplete() const {
bool TitleBlockDimensionWidget::isComplete() const
{
return(complete_);
}
@@ -50,7 +52,8 @@ bool TitleBlockDimensionWidget::isComplete() const {
@return a pointer to the label displayed right before the spinbox.
Useful to specify a custom text.
*/
QLabel *TitleBlockDimensionWidget::label() const {
QLabel *TitleBlockDimensionWidget::label() const
{
return(spinbox_label_);
}
@@ -58,14 +61,16 @@ QLabel *TitleBlockDimensionWidget::label() const {
@return a pointer to the spinbox
Useful to specify custom parameters, such as the minimum value
*/
QSpinBox *TitleBlockDimensionWidget::spinbox() const {
QSpinBox *TitleBlockDimensionWidget::spinbox() const
{
return(spinbox_);
}
/**
@return The dimension as currently shown by the dialog
*/
TitleBlockDimension TitleBlockDimensionWidget::value() const {
TitleBlockDimension TitleBlockDimensionWidget::value() const
{
QET::TitleBlockColumnLength type = QET::Absolute;
if (complete_) {
type = static_cast<QET::TitleBlockColumnLength>(dimension_type_ -> checkedId());
@@ -90,7 +95,8 @@ void TitleBlockDimensionWidget::setValue(const TitleBlockDimension &dim) {
@return Whether or not this widget should allow edition of the displayed
dimension.
*/
bool TitleBlockDimensionWidget::isReadOnly() const {
bool TitleBlockDimensionWidget::isReadOnly() const
{
return(read_only_);
}
@@ -113,7 +119,8 @@ void TitleBlockDimensionWidget::setReadOnly(bool read_only) {
/**
Initialize the widgets composing the dialog.
*/
void TitleBlockDimensionWidget::initWidgets() {
void TitleBlockDimensionWidget::initWidgets()
{
// basic widgets: label + spinbox
spinbox_label_ = new QLabel(tr("Largeur :", "default dialog label"));
@@ -122,9 +129,15 @@ void TitleBlockDimensionWidget::initWidgets() {
// extra widgets, for the user to specify whether the value is absolute, relative, etc.
if (complete_) {
absolute_button_ = new QRadioButton(tr("Absolu", "a traditional, absolute measure"));
relative_button_ = new QRadioButton(tr("Relatif au total", "a percentage of the total width"));
remaining_button_ = new QRadioButton(tr("Relatif au restant", "a percentage of what remains from the total width"));
absolute_button_ = new QRadioButton(
tr("Absolu",
"a traditional, absolute measure"));
relative_button_ = new QRadioButton(
tr("Relatif au total",
"a percentage of the total width"));
remaining_button_ = new QRadioButton(
tr("Relatif au restant",
"a percentage of what remains from the total width"));
dimension_type_ = new QButtonGroup(this);
dimension_type_ -> addButton(absolute_button_, QET::Absolute);
dimension_type_ -> addButton(relative_button_, QET::RelativeToTotalLength);
@@ -144,7 +157,8 @@ void TitleBlockDimensionWidget::initWidgets() {
/**
Initialize the layout of the dialog.
*/
void TitleBlockDimensionWidget::initLayouts() {
void TitleBlockDimensionWidget::initLayouts()
{
QHBoxLayout *hlayout0 = new QHBoxLayout();
hlayout0 -> addWidget(spinbox_label_);
hlayout0 -> addWidget(spinbox_);
@@ -162,7 +176,8 @@ void TitleBlockDimensionWidget::initLayouts() {
/**
Ensure the suffix displayed by the spinbox matches the selected kind of length.
*/
void TitleBlockDimensionWidget::updateSpinBoxSuffix() {
void TitleBlockDimensionWidget::updateSpinBoxSuffix()
{
if (complete_ && dimension_type_ -> checkedId() != QET::Absolute) {
spinbox_ -> setSuffix(tr("%", "spinbox suffix when changing the dimension of a row/column"));
spinbox_ -> setMinimum(1);

View File

@@ -31,13 +31,15 @@ GridLayoutAnimation::GridLayoutAnimation(QGraphicsGridLayout *grid, QObject *par
/**
Destructor
*/
GridLayoutAnimation::~GridLayoutAnimation() {
GridLayoutAnimation::~GridLayoutAnimation()
{
}
/**
@return the animated grid
*/
QGraphicsGridLayout *GridLayoutAnimation::grid() {
QGraphicsGridLayout *GridLayoutAnimation::grid()
{
return(grid_);
}
@@ -51,7 +53,8 @@ void GridLayoutAnimation::setGrid(QGraphicsGridLayout *grid) {
/**
@return the index of the row/column to be animated
*/
int GridLayoutAnimation::index() const {
int GridLayoutAnimation::index() const
{
return(index_);
}
@@ -65,7 +68,8 @@ void GridLayoutAnimation::setIndex(int index) {
/**
@return true if this object acts on a row, false if it acts on a column.
*/
bool GridLayoutAnimation::actsOnRows() const {
bool GridLayoutAnimation::actsOnRows() const
{
return(row_);
}

View File

@@ -37,7 +37,8 @@ HelperCell::HelperCell(QGraphicsItem *parent) :
/**
Destructor
*/
HelperCell::~HelperCell() {
HelperCell::~HelperCell()
{
}
/**
@@ -56,7 +57,8 @@ void HelperCell::setGeometry(const QRectF &g) {
@param constraint New value for the size hint
@return the size hint for \a which using the width or height of \a constraint
*/
QSizeF HelperCell::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const {
QSizeF HelperCell::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
Q_UNUSED(which);
return(constraint);
}
@@ -64,7 +66,8 @@ QSizeF HelperCell::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
/**
@return the bounding rect of this helper cell
*/
QRectF HelperCell::boundingRect() const {
QRectF HelperCell::boundingRect() const
{
return QRectF(QPointF(0,0), geometry().size());
}
@@ -114,7 +117,8 @@ void HelperCell::setActions(const QList<QAction *> &actions) {
/**
@return the list of actions displayed by the context menu of this helper cell.
*/
QList<QAction *> HelperCell::actions() const {
QList<QAction *> HelperCell::actions() const
{
return actions_;
}

View File

@@ -33,7 +33,8 @@ IntegrationMoveTitleBlockTemplatesHandler::IntegrationMoveTitleBlockTemplatesHan
/**
Destructor
*/
IntegrationMoveTitleBlockTemplatesHandler::~IntegrationMoveTitleBlockTemplatesHandler() {
IntegrationMoveTitleBlockTemplatesHandler::~IntegrationMoveTitleBlockTemplatesHandler()
{
}
/**
@@ -95,14 +96,16 @@ QET::Action IntegrationMoveTitleBlockTemplatesHandler::errorWithATemplate(const
@return the name to be used when this object returns QET::Rename
@see QET::Action
*/
QString IntegrationMoveTitleBlockTemplatesHandler::nameForRenamingOperation() {
QString IntegrationMoveTitleBlockTemplatesHandler::nameForRenamingOperation()
{
return(rename_);
}
/**
@return the current date with a filename-friendly format
*/
QString IntegrationMoveTitleBlockTemplatesHandler::dateString() const {
QString IntegrationMoveTitleBlockTemplatesHandler::dateString() const
{
return(QDateTime::currentDateTime().toString("yyyyMMddhhmmss"));
}
@@ -142,7 +145,8 @@ QET::Action IntegrationMoveTitleBlockTemplatesHandler::askUser(const TitleBlockT
/**
Initialize the user dialog.
*/
void IntegrationMoveTitleBlockTemplatesHandler::initDialog() {
void IntegrationMoveTitleBlockTemplatesHandler::initDialog()
{
if (integ_dialog_) return;
integ_dialog_ = new QDialog(parent_widget_);
integ_dialog_ -> setWindowTitle(tr("Intégration d'un modèle de cartouche"));
@@ -238,7 +242,8 @@ void IntegrationMoveTitleBlockTemplatesHandler::radioButtonleftMargin(QRadioButt
/**
Ensure the dialog remains consistent.
*/
void IntegrationMoveTitleBlockTemplatesHandler::correctRadioButtons() {
void IntegrationMoveTitleBlockTemplatesHandler::correctRadioButtons()
{
erase_template_ -> setEnabled(integrate_new_template_ -> isChecked());
integrate_both_ -> setEnabled(integrate_new_template_ -> isChecked());
}

View File

@@ -51,13 +51,14 @@ QETTitleBlockTemplateEditor::QETTitleBlockTemplateEditor(QWidget *parent) :
/**
Destructor
*/
QETTitleBlockTemplateEditor::~QETTitleBlockTemplateEditor() {
}
QETTitleBlockTemplateEditor::~QETTitleBlockTemplateEditor()
{}
/**
@return the location of the currently edited template
*/
TitleBlockTemplateLocation QETTitleBlockTemplateEditor::location() const {
TitleBlockTemplateLocation QETTitleBlockTemplateEditor::location() const
{
return(location_);
}
@@ -65,7 +66,8 @@ TitleBlockTemplateLocation QETTitleBlockTemplateEditor::location() const {
@return true if the provided filepath matches the currently edited template.
@param filepath path of a title block template on the filesystem
*/
bool QETTitleBlockTemplateEditor::isEditing(const QString &filepath) {
bool QETTitleBlockTemplateEditor::isEditing(const QString &filepath)
{
QString current_filepath;
if (opened_from_file_) {
current_filepath = filepath_;
@@ -87,7 +89,8 @@ bool QETTitleBlockTemplateEditor::isEditing(const QString &filepath) {
new template name as soon as the window appears in order to duplicate
the edited one.
*/
void QETTitleBlockTemplateEditor::setOpenForDuplication(bool duplicate) {
void QETTitleBlockTemplateEditor::setOpenForDuplication(bool duplicate)
{
duplicate_ = duplicate;
}
@@ -95,7 +98,8 @@ void QETTitleBlockTemplateEditor::setOpenForDuplication(bool duplicate) {
@return true if this editor will prompt the user for a new template
name as soon as the window appears in order to duplicate the edited one.
*/
bool QETTitleBlockTemplateEditor::openForDuplication() const {
bool QETTitleBlockTemplateEditor::openForDuplication() const
{
return(duplicate_);
}
@@ -104,7 +108,8 @@ bool QETTitleBlockTemplateEditor::openForDuplication() const {
closed if it has not been modified. If the template has been modified, this
method asks the user what he wants to do.
*/
bool QETTitleBlockTemplateEditor::canClose() {
bool QETTitleBlockTemplateEditor::canClose()
{
if (undo_stack_ -> isClean()) return(true);
// ask the user whether he wants to save the current template
QMessageBox::StandardButton answer = QET::QetMessageBox::question(
@@ -131,7 +136,8 @@ bool QETTitleBlockTemplateEditor::canClose() {
/**
@param event Object describing the received event.
*/
void QETTitleBlockTemplateEditor::firstActivation(QEvent *event) {
void QETTitleBlockTemplateEditor::firstActivation(QEvent *event)
{
Q_UNUSED(event)
if (duplicate_ && !opened_from_file_ && location_.parentCollection()) {
// this editor is supposed to duplicate its current location
@@ -143,7 +149,8 @@ void QETTitleBlockTemplateEditor::firstActivation(QEvent *event) {
Handle the closing of the main window
@param qce The QCloseEvent event
*/
void QETTitleBlockTemplateEditor::closeEvent(QCloseEvent *qce) {
void QETTitleBlockTemplateEditor::closeEvent(QCloseEvent *qce)
{
if (canClose()) {
writeSettings();
setAttribute(Qt::WA_DeleteOnClose);
@@ -155,13 +162,15 @@ void QETTitleBlockTemplateEditor::closeEvent(QCloseEvent *qce) {
Ask the user for a new template name in order to duplicate the currently
edited template.
*/
void QETTitleBlockTemplateEditor::duplicateCurrentLocation() {
void QETTitleBlockTemplateEditor::duplicateCurrentLocation()
{
// this method does not work for templates edited from the filesystem
if (opened_from_file_) return;
QString proposed_name;
if (location_.name().isEmpty()) {
proposed_name = tr("nouveau_modele", "template name suggestion when duplicating the default one");
proposed_name = tr("nouveau_modele",
"template name suggestion when duplicating the default one");
} else {
proposed_name = QString("%1_copy").arg(location_.name());
}
@@ -170,13 +179,16 @@ void QETTitleBlockTemplateEditor::duplicateCurrentLocation() {
QString new_template_name = QInputDialog::getText(
this,
tr("Dupliquer un modèle de cartouche", "input dialog title"),
tr("Pour dupliquer ce modèle, entrez le nom voulu pour sa copie", "input dialog text"),
tr("Pour dupliquer ce modèle, entrez le nom voulu pour sa copie",
"input dialog text"),
QLineEdit::Normal,
proposed_name,
&accepted
);
if (accepted) {
TitleBlockTemplateLocation new_template_location(new_template_name, location_.parentCollection());
TitleBlockTemplateLocation new_template_location(
new_template_name,
location_.parentCollection());
saveAs(new_template_location);
}
}
@@ -184,7 +196,9 @@ void QETTitleBlockTemplateEditor::duplicateCurrentLocation() {
/**
@param location Location of the tile block template to be edited.
*/
bool QETTitleBlockTemplateEditor::edit(const TitleBlockTemplateLocation &location) {
bool QETTitleBlockTemplateEditor::edit(
const TitleBlockTemplateLocation &location)
{
// the template name may be empty to create a new one
const TitleBlockTemplate *tb_template_orig;
if (location.name().isEmpty()) {
@@ -212,7 +226,8 @@ bool QETTitleBlockTemplateEditor::edit(const TitleBlockTemplateLocation &locatio
@param template_name Name of the template to edit within its parent project.
@return true if this editor was able to edit the given template, false otherwise
*/
bool QETTitleBlockTemplateEditor::edit(QETProject *project, const QString &template_name)
bool QETTitleBlockTemplateEditor::edit(
QETProject *project, const QString &template_name)
{
// we require a project we will rattach templates to
if (!project) return(false);
@@ -246,7 +261,8 @@ bool QETTitleBlockTemplateEditor::edit(QETProject *project, const QString &templ
@param file_path Path of the template file to edit.
@return false if a problem occurred while opening the template, true otherwise.
*/
bool QETTitleBlockTemplateEditor::edit(const QString &file_path) {
bool QETTitleBlockTemplateEditor::edit(const QString &file_path)
{
// get title block template object from the file, edit it
TitleBlockTemplate *tbt = new TitleBlockTemplate();
bool loading = tbt -> loadFromXmlFile(file_path);
@@ -272,7 +288,8 @@ bool QETTitleBlockTemplateEditor::edit(const QString &file_path) {
@param tbt Title block template to be edited
@return false if a problem occurred while opening the template, true otherwise.
*/
bool QETTitleBlockTemplateEditor::editCopyOf(const TitleBlockTemplate *tbt) {
bool QETTitleBlockTemplateEditor::editCopyOf(const TitleBlockTemplate *tbt)
{
if (!tbt) return(false);
return(edit(tbt -> clone()));
}
@@ -281,7 +298,8 @@ bool QETTitleBlockTemplateEditor::editCopyOf(const TitleBlockTemplate *tbt) {
@param tbt Title block template to be directly edited
@return false if a problem occurred while opening the template, true otherwise.
*/
bool QETTitleBlockTemplateEditor::edit(TitleBlockTemplate *tbt) {
bool QETTitleBlockTemplateEditor::edit(TitleBlockTemplate *tbt)
{
if (!tbt) return(false);
tb_template_ = tbt;
template_edition_area_view_ -> setTitleBlockTemplate(tb_template_);
@@ -294,7 +312,8 @@ bool QETTitleBlockTemplateEditor::edit(TitleBlockTemplate *tbt) {
Launches the logo manager widget, which allows the user to manage the
logos embedded within the edited template.
*/
void QETTitleBlockTemplateEditor::editLogos() {
void QETTitleBlockTemplateEditor::editLogos()
{
if (tb_template_) {
if (!logo_manager_) {
initLogoManager();
@@ -321,7 +340,8 @@ void QETTitleBlockTemplateEditor::editLogos() {
/**
Launch a new title block template editor.
*/
void QETTitleBlockTemplateEditor::newTemplate() {
void QETTitleBlockTemplateEditor::newTemplate()
{
QETTitleBlockTemplateEditor *qet_template_editor = new QETTitleBlockTemplateEditor();
qet_template_editor -> edit(TitleBlockTemplateLocation());
qet_template_editor -> show();
@@ -330,7 +350,8 @@ void QETTitleBlockTemplateEditor::newTemplate() {
/**
Initialize the various actions.
*/
void QETTitleBlockTemplateEditor::initActions() {
void QETTitleBlockTemplateEditor::initActions()
{
new_ = new QAction(QET::Icons::DocumentNew, tr("&Nouveau", "menu entry"), this);
open_ = new QAction(QET::Icons::DocumentOpen, tr("&Ouvrir", "menu entry"), this);
open_from_file_ = new QAction(QET::Icons::DocumentOpen, tr("Ouvrir depuis un fichier", "menu entry"), this);
@@ -402,10 +423,11 @@ void QETTitleBlockTemplateEditor::initActions() {
/**
Initialize the various menus.
*/
void QETTitleBlockTemplateEditor::initMenus() {
file_menu_ = new QMenu(tr("&Fichier", "menu title"), this);
edit_menu_ = new QMenu(tr("&Édition", "menu title"), this);
display_menu_ = new QMenu(tr("Afficha&ge", "menu title"), this);
void QETTitleBlockTemplateEditor::initMenus()
{
file_menu_ = new QMenu(tr("&Fichier", "menu title"), this);
edit_menu_ = new QMenu(tr("&Édition", "menu title"), this);
display_menu_ = new QMenu(tr("Afficha&ge", "menu title"), this);
file_menu_ -> addAction(new_);
file_menu_ -> addAction(open_);
@@ -443,7 +465,8 @@ void QETTitleBlockTemplateEditor::initMenus() {
/**
Initalize toolbars.
*/
void QETTitleBlockTemplateEditor::initToolbars() {
void QETTitleBlockTemplateEditor::initToolbars()
{
QToolBar *main_toolbar = new QToolBar(tr("Outils", "toolbar title"), this);
main_toolbar -> setObjectName("tbt_main_toolbar");
main_toolbar -> addAction(new_);
@@ -516,7 +539,8 @@ void QETTitleBlockTemplateEditor::initWidgets()
this,
SLOT(selectedCellsChanged(QList<TitleBlockCell *>))
);
connect(template_cell_editor_widget_, SIGNAL(logoEditionRequested()), this, SLOT(editLogos()));
connect(template_cell_editor_widget_, SIGNAL(logoEditionRequested()),
this, SLOT(editLogos()));
connect(
template_cell_editor_widget_,
SIGNAL(cellModified(ModifyTitleBlockCellCommand *)),
@@ -535,14 +559,17 @@ void QETTitleBlockTemplateEditor::initWidgets()
this,
SLOT(savePreviewWidthToApplicationSettings(int, int))
);
connect(undo_stack_, SIGNAL(cleanChanged(bool)), this, SLOT(updateEditorTitle()));
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(updateActions()));
connect(undo_stack_, SIGNAL(cleanChanged(bool)),
this, SLOT(updateEditorTitle()));
connect(QApplication::clipboard(), SIGNAL(dataChanged()),
this, SLOT(updateActions()));
}
/**
Initialize the logo manager
*/
void QETTitleBlockTemplateEditor::initLogoManager() {
void QETTitleBlockTemplateEditor::initLogoManager()
{
logo_manager_ = new TitleBlockTemplateLogoManager(tb_template_, this);
logo_manager_ -> setReadOnly(read_only_);
connect(
@@ -557,7 +584,8 @@ void QETTitleBlockTemplateEditor::initLogoManager() {
@return a string describing what is being edited, along with [Changed] or
[Read only] tags. Useful to compose the window title.
*/
QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const {
QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const
{
QString titleblock_title;
if (opened_from_file_) {
titleblock_title = filepath_;
@@ -617,7 +645,9 @@ void QETTitleBlockTemplateEditor::writeSettings()
Update various things when user changes the selected cells.
@param selected_cells List of selected cells.
*/
void QETTitleBlockTemplateEditor::selectedCellsChanged(const QList<TitleBlockCell *>& selected_cells) {
void QETTitleBlockTemplateEditor::selectedCellsChanged(
const QList<TitleBlockCell *>& selected_cells)
{
if (selected_cells.count() == 1) {
template_cell_editor_widget_ -> edit(selected_cells.at(0));
template_cell_editor_widget_ -> setVisible(true);
@@ -631,7 +661,9 @@ void QETTitleBlockTemplateEditor::selectedCellsChanged(const QList<TitleBlockCel
Configure an undo Command before adding it to the undo stack.
@param command to be added to the undo stack
*/
void QETTitleBlockTemplateEditor::pushCellUndoCommand(ModifyTitleBlockCellCommand *command) {
void QETTitleBlockTemplateEditor::pushCellUndoCommand(
ModifyTitleBlockCellCommand *command)
{
command -> setView(template_edition_area_view_);
pushUndoCommand(command);
}
@@ -640,7 +672,9 @@ void QETTitleBlockTemplateEditor::pushCellUndoCommand(ModifyTitleBlockCellComman
Add an undo Command to the undo stack.
@param command QUndoCommand to be added to the undo stack
*/
void QETTitleBlockTemplateEditor::pushGridUndoCommand(TitleBlockTemplateCommand *command) {
void QETTitleBlockTemplateEditor::pushGridUndoCommand(
TitleBlockTemplateCommand *command)
{
pushUndoCommand(command);
}
@@ -655,7 +689,8 @@ void QETTitleBlockTemplateEditor::pushUndoCommand(QUndoCommand *command) {
/**
Set the title of this editor.
*/
void QETTitleBlockTemplateEditor::updateEditorTitle() {
void QETTitleBlockTemplateEditor::updateEditorTitle()
{
// base title
QString min_title(
tr(
@@ -686,7 +721,8 @@ void QETTitleBlockTemplateEditor::updateEditorTitle() {
Ensure the user interface remains consistent by enabling or disabling
adequate actions.
*/
void QETTitleBlockTemplateEditor::updateActions() {
void QETTitleBlockTemplateEditor::updateActions()
{
save_ -> setEnabled(!read_only_);
bool can_merge = true;
@@ -748,7 +784,8 @@ bool QETTitleBlockTemplateEditor::saveAs(const QString &filepath) {
Ask the user to choose a title block template from the known collections
then open it for edition.
*/
void QETTitleBlockTemplateEditor::open() {
void QETTitleBlockTemplateEditor::open()
{
TitleBlockTemplateLocation location = getTitleBlockTemplateLocationFromUser(
tr("Ouvrir un modèle", "File > open dialog window title"),
true
@@ -762,9 +799,12 @@ void QETTitleBlockTemplateEditor::open() {
Ask the user to choose a file supposed to contain a title block template,
then open it for edition.
*/
void QETTitleBlockTemplateEditor::openFromFile() {
void QETTitleBlockTemplateEditor::openFromFile()
{
// directory to show
QString initial_dir = filepath_.isEmpty() ? QETApp::customTitleBlockTemplatesDir() : QDir(filepath_).absolutePath();
QString initial_dir = filepath_.isEmpty()
? QETApp::customTitleBlockTemplatesDir()
: QDir(filepath_).absolutePath();
// ask the user to choose a filepath
QString user_filepath = QFileDialog::getOpenFileName(
@@ -775,7 +815,8 @@ void QETTitleBlockTemplateEditor::openFromFile() {
"Modèles de cartouches QElectroTech (*%1);;"
"Fichiers XML (*.xml);;"
"Tous les fichiers (*)",
"filetypes allowed when opening a title block template file - %1 is the .titleblock extension"
"filetypes allowed when opening a title block template file"
" - %1 is the .titleblock extension"
).arg(QString(TITLEBLOCKS_FILE_EXTENSION))
);
@@ -786,7 +827,8 @@ void QETTitleBlockTemplateEditor::openFromFile() {
/**
Save the currently edited title block template back to its parent project.
*/
bool QETTitleBlockTemplateEditor::save() {
bool QETTitleBlockTemplateEditor::save()
{
if (opened_from_file_) {
if (!filepath_.isEmpty()) {
QFileInfo file_path_info(filepath_);
@@ -808,7 +850,8 @@ bool QETTitleBlockTemplateEditor::save() {
/**
Ask the user where he wishes to save the currently edited template.
*/
bool QETTitleBlockTemplateEditor::saveAs() {
bool QETTitleBlockTemplateEditor::saveAs()
{
TitleBlockTemplateLocation location = getTitleBlockTemplateLocationFromUser(
tr("Enregistrer le modèle sous", "dialog window title"),
false
@@ -822,9 +865,12 @@ bool QETTitleBlockTemplateEditor::saveAs() {
/**
Ask the user where on the filesystem he wishes to save the currently edited template.
*/
bool QETTitleBlockTemplateEditor::saveAsFile() {
bool QETTitleBlockTemplateEditor::saveAsFile()
{
// directory to show
QString initial_dir = filepath_.isEmpty() ? QETApp::customTitleBlockTemplatesDir() : QDir(filepath_).absolutePath();
QString initial_dir = filepath_.isEmpty()
? QETApp::customTitleBlockTemplatesDir()
: QDir(filepath_).absolutePath();
// ask the user to choose a target file
QString filepath = QFileDialog::getSaveFileName(
@@ -875,14 +921,17 @@ void QETTitleBlockTemplateEditor::setReadOnly(bool read_only) {
@return The location chosen by the user, or an empty
TitleBlockTemplateLocation if the user cancelled the dialog
*/
TitleBlockTemplateLocation QETTitleBlockTemplateEditor::getTitleBlockTemplateLocationFromUser(const QString &title, bool existing_only) {
TitleBlockTemplateLocation QETTitleBlockTemplateEditor::getTitleBlockTemplateLocationFromUser(
const QString &title, bool existing_only)
{
TitleBlockTemplateLocationChooser *widget;
if (existing_only) {
widget = new TitleBlockTemplateLocationChooser(location());
} else {
widget = new TitleBlockTemplateLocationSaver(location());
}
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QDialogButtonBox *buttons = new QDialogButtonBox(
QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QVBoxLayout *dialog_layout = new QVBoxLayout();
dialog_layout -> addWidget(widget);
@@ -904,7 +953,8 @@ TitleBlockTemplateLocation QETTitleBlockTemplateEditor::getTitleBlockTemplateLoc
/**
Close the current editor.
*/
void QETTitleBlockTemplateEditor::quit() {
void QETTitleBlockTemplateEditor::quit()
{
close();
}
@@ -914,7 +964,8 @@ void QETTitleBlockTemplateEditor::quit() {
@param former_preview_width : former_preview_width Unused, former preview width
@param new_preview_width : new_preview_width New preview width
*/
void QETTitleBlockTemplateEditor::savePreviewWidthToApplicationSettings(int former_preview_width, int new_preview_width)
void QETTitleBlockTemplateEditor::savePreviewWidthToApplicationSettings(
int former_preview_width, int new_preview_width)
{
Q_UNUSED(former_preview_width)
QSettings settings;
@@ -924,7 +975,8 @@ void QETTitleBlockTemplateEditor::savePreviewWidthToApplicationSettings(int form
/**
Edit extra information attached to the template.
*/
void QETTitleBlockTemplateEditor::editTemplateInformation() {
void QETTitleBlockTemplateEditor::editTemplateInformation()
{
if (!tb_template_) return;
QDialog dialog_author(this);
@@ -950,16 +1002,25 @@ void QETTitleBlockTemplateEditor::editTemplateInformation() {
dialog_layout -> addWidget(text_field);
// add two buttons to the dialog
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(read_only_ ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(
read_only_
? QDialogButtonBox::Ok
: QDialogButtonBox::Ok
| QDialogButtonBox::Cancel);
dialog_layout -> addWidget(dialog_buttons);
connect(dialog_buttons, SIGNAL(accepted()), &dialog_author, SLOT(accept()));
connect(dialog_buttons, SIGNAL(rejected()), &dialog_author, SLOT(reject()));
connect(dialog_buttons, SIGNAL(accepted()),
&dialog_author, SLOT(accept()));
connect(dialog_buttons, SIGNAL(rejected()),
&dialog_author, SLOT(reject()));
// run the dialog
if (dialog_author.exec() == QDialog::Accepted && !read_only_) {
QString new_info = text_field -> toPlainText().remove(QChar(13)); // CR-less text
if (new_info != tb_template_ -> information()) {
pushUndoCommand(new ChangeTemplateInformationsCommand(tb_template_, tb_template_ -> information(), new_info));
pushUndoCommand(new ChangeTemplateInformationsCommand(
tb_template_,
tb_template_ -> information(),
new_info));
}
}
}

View File

@@ -32,7 +32,8 @@ SplittedHelperCell::SplittedHelperCell(QGraphicsItem *parent) :
/**
Destructor
*/
SplittedHelperCell::~SplittedHelperCell() {
SplittedHelperCell::~SplittedHelperCell()
{
}
/**

View File

@@ -35,13 +35,15 @@ TitleBlockTemplateCellsSet::TitleBlockTemplateCellsSet(const TitleBlockTemplateV
/**
Destructor
*/
TitleBlockTemplateCellsSet::~TitleBlockTemplateCellsSet() {
TitleBlockTemplateCellsSet::~TitleBlockTemplateCellsSet()
{
}
/**
@return a QPainterPath composed of the rectangles from cells within this set
*/
QPainterPath TitleBlockTemplateCellsSet::painterPath() const {
QPainterPath TitleBlockTemplateCellsSet::painterPath() const
{
QPainterPath cells_path;
foreach (TitleBlockTemplateVisualCell *cell, *this) {
cells_path.addRect(cell -> geometry());
@@ -53,7 +55,8 @@ QPainterPath TitleBlockTemplateCellsSet::painterPath() const {
@return true if the cells within this set are composing a rectangle shape,
false otherwise.
*/
bool TitleBlockTemplateCellsSet::isRectangle() const {
bool TitleBlockTemplateCellsSet::isRectangle() const
{
if (!count()) return(false);
if (count() == 1) return(true);
@@ -66,7 +69,8 @@ bool TitleBlockTemplateCellsSet::isRectangle() const {
/**
@return true if all cells within this set are selected
*/
bool TitleBlockTemplateCellsSet::allCellsAreSelected() const {
bool TitleBlockTemplateCellsSet::allCellsAreSelected() const
{
foreach (TitleBlockTemplateVisualCell *cell, *this) {
if (!cell -> isSelected()) {
return(false);
@@ -79,7 +83,8 @@ bool TitleBlockTemplateCellsSet::allCellsAreSelected() const {
@return true if this set includes at least one cell which is spanned by a
cell not present in this set, false otherwise.
*/
bool TitleBlockTemplateCellsSet::hasExternalSpan() const {
bool TitleBlockTemplateCellsSet::hasExternalSpan() const
{
// fetches all cells concerned by this set
QSet<TitleBlockCell *> all_cells = cells(true);
@@ -95,7 +100,8 @@ bool TitleBlockTemplateCellsSet::hasExternalSpan() const {
/**
@return the top left cell within this set, or 0 if this set is empty
*/
TitleBlockTemplateVisualCell *TitleBlockTemplateCellsSet::topLeftCell() const {
TitleBlockTemplateVisualCell *TitleBlockTemplateCellsSet::topLeftCell() const
{
if (empty()) return(nullptr);
if (count() == 1) return(first());
@@ -126,7 +132,8 @@ TitleBlockTemplateVisualCell *TitleBlockTemplateCellsSet::topLeftCell() const {
/**
@return the bottom right cell within this set, or 0 if this set is empty
*/
TitleBlockTemplateVisualCell *TitleBlockTemplateCellsSet::bottomRightCell() const {
TitleBlockTemplateVisualCell *TitleBlockTemplateCellsSet::bottomRightCell() const
{
if (empty()) return(nullptr);
if (count() == 1) return(first());
@@ -155,7 +162,8 @@ TitleBlockTemplateVisualCell *TitleBlockTemplateCellsSet::bottomRightCell() cons
@return the merge area, i.e. the rectangle delimited by the top left cell
and the bottom right cell within this cells set.
*/
QRectF TitleBlockTemplateCellsSet::mergeAreaRect() const {
QRectF TitleBlockTemplateCellsSet::mergeAreaRect() const
{
QRectF merge_area;
if (!parent_view_) return(merge_area);
@@ -174,7 +182,8 @@ QRectF TitleBlockTemplateCellsSet::mergeAreaRect() const {
provided, this method will use mergeAreaRect().
@return the cells contained in the merge area of this cells set
*/
TitleBlockTemplateCellsSet TitleBlockTemplateCellsSet::mergeArea(const QRectF &rect) const {
TitleBlockTemplateCellsSet TitleBlockTemplateCellsSet::mergeArea(const QRectF &rect) const
{
TitleBlockTemplateCellsSet merge_area(parent_view_);
if (!parent_view_) return(merge_area);
@@ -188,7 +197,8 @@ TitleBlockTemplateCellsSet TitleBlockTemplateCellsSet::mergeArea(const QRectF &r
@return the list of cells rendered by the current selection
@param include_spanned whether to include spanned cells or not
*/
QSet<TitleBlockCell *> TitleBlockTemplateCellsSet::cells(bool include_spanned) const {
QSet<TitleBlockCell *> TitleBlockTemplateCellsSet::cells(bool include_spanned) const
{
QSet<TitleBlockCell *> set;
foreach (TitleBlockTemplateVisualCell *cell_view, *this) {
if (TitleBlockCell *cell = cell_view -> cell()) {

View File

@@ -44,13 +44,15 @@ TitleBlockTemplateCellWidget::TitleBlockTemplateCellWidget(
/**
Destructor
*/
TitleBlockTemplateCellWidget::~TitleBlockTemplateCellWidget() {
TitleBlockTemplateCellWidget::~TitleBlockTemplateCellWidget()
{
}
/**
Initialize layout and widgets.
*/
void TitleBlockTemplateCellWidget::initWidgets() {
void TitleBlockTemplateCellWidget::initWidgets()
{
// type combo box: always displayed
cell_type_label_ = new QLabel(tr("Type de cellule :"));
cell_type_input_ = new QComboBox();
@@ -83,9 +85,9 @@ void TitleBlockTemplateCellWidget::initWidgets() {
align_label_ = new QLabel(tr("Alignement :"));
horiz_align_label_ = new QLabel(tr("horizontal :"));
horiz_align_input_ = new QComboBox();
horiz_align_input_ -> addItem(tr("Gauche"), Qt::AlignLeft);
horiz_align_input_ -> addItem(tr("Centré"), Qt::AlignHCenter);
horiz_align_input_ -> addItem(tr("Droite"), Qt::AlignRight);
horiz_align_input_ -> addItem(tr("Gauche"), Qt::AlignLeft);
horiz_align_input_ -> addItem(tr("Centré"), Qt::AlignHCenter);
horiz_align_input_ -> addItem(tr("Droite"), Qt::AlignRight);
horiz_align_indexes_.insert(Qt::AlignLeft, 0);
horiz_align_indexes_.insert(Qt::AlignHCenter, 1);
horiz_align_indexes_.insert(Qt::AlignRight, 2);
@@ -225,7 +227,8 @@ void TitleBlockTemplateCellWidget::edit(TitleBlockCell *cell) {
Emit a type modification command.
@see ModifyTitleBlockCellCommand
*/
void TitleBlockTemplateCellWidget::editType() {
void TitleBlockTemplateCellWidget::editType()
{
emitModification("type", cell_type_input_ -> itemData(cell_type_input_ -> currentIndex()));
}
@@ -233,7 +236,8 @@ void TitleBlockTemplateCellWidget::editType() {
Emit a name modification command.
@see ModifyTitleBlockCellCommand
*/
void TitleBlockTemplateCellWidget::editName() {
void TitleBlockTemplateCellWidget::editName()
{
emitModification("name", name_input_ -> text());
}
@@ -241,7 +245,8 @@ void TitleBlockTemplateCellWidget::editName() {
Emit a modification command stating whether the label should be displayed or not.
@see ModifyTitleBlockCellCommand
*/
void TitleBlockTemplateCellWidget::editLabelDisplayed() {
void TitleBlockTemplateCellWidget::editLabelDisplayed()
{
emitModification("displaylabel", label_checkbox_ -> isChecked());
}
@@ -249,7 +254,8 @@ void TitleBlockTemplateCellWidget::editLabelDisplayed() {
Emit a label modification command.
@see ModifyTitleBlockCellCommand
*/
void TitleBlockTemplateCellWidget::editLabel() {
void TitleBlockTemplateCellWidget::editLabel()
{
if (!edited_cell_) return;
editTranslatableValue(edited_cell_ -> label, "label", tr("Label de cette cellule"));
label_input_ -> setText(edited_cell_ -> label.name());
@@ -259,7 +265,8 @@ void TitleBlockTemplateCellWidget::editLabel() {
Emit a value modification command.
@see ModifyTitleBlockCellCommand
*/
void TitleBlockTemplateCellWidget::editValue() {
void TitleBlockTemplateCellWidget::editValue()
{
if (!edited_cell_) return;
editTranslatableValue(edited_cell_ -> value, "value", tr("Valeur de cette cellule"));
value_input_ -> setText(edited_cell_ -> value.name());
@@ -269,7 +276,8 @@ void TitleBlockTemplateCellWidget::editValue() {
Emit an alignment modification command.
@see ModifyTitleBlockCellCommand
*/
void TitleBlockTemplateCellWidget::editAlignment() {
void TitleBlockTemplateCellWidget::editAlignment()
{
emitModification("alignment", alignment());
}
@@ -277,7 +285,8 @@ void TitleBlockTemplateCellWidget::editAlignment() {
Emit a font size modification command.
@see ModifyTitleBlockCellCommand
*/
void TitleBlockTemplateCellWidget::editFontSize() {
void TitleBlockTemplateCellWidget::editFontSize()
{
emitModification("fontsize", font_size_input_ -> value());
}
@@ -285,7 +294,8 @@ void TitleBlockTemplateCellWidget::editFontSize() {
Emit a modification command stating whether the text should be adjusted if needed.
@see ModifyTitleBlockCellCommand
*/
void TitleBlockTemplateCellWidget::editAdjust() {
void TitleBlockTemplateCellWidget::editAdjust()
{
emitModification("horizontal_adjust", font_adjust_input_ -> isChecked());
}
@@ -293,7 +303,8 @@ void TitleBlockTemplateCellWidget::editAdjust() {
Emit a logo modification command.
@see ModifyTitleBlockCellCommand
*/
void TitleBlockTemplateCellWidget::editLogo() {
void TitleBlockTemplateCellWidget::editLogo()
{
emitModification("logo", logo_input_ -> currentText());
}
@@ -346,7 +357,8 @@ void TitleBlockTemplateCellWidget::setReadOnly(bool read_only) {
Emit a horizontal alignment modification command.
@see ModifyTitleBlockCellCommand
*/
int TitleBlockTemplateCellWidget::horizontalAlignment() const {
int TitleBlockTemplateCellWidget::horizontalAlignment() const
{
return(horiz_align_indexes_.key(horiz_align_input_ -> currentIndex()));
}
@@ -354,21 +366,24 @@ int TitleBlockTemplateCellWidget::horizontalAlignment() const {
Emit a vertical alignment modification command.
@see ModifyTitleBlockCellCommand
*/
int TitleBlockTemplateCellWidget::verticalAlignment() const {
int TitleBlockTemplateCellWidget::verticalAlignment() const
{
return(vert_align_indexes_.key(vert_align_input_ -> currentIndex()));
}
/**
@return the currently selected alignment.
*/
int TitleBlockTemplateCellWidget::alignment() const {
int TitleBlockTemplateCellWidget::alignment() const
{
return(horizontalAlignment() | verticalAlignment());
}
/**
@return whether this edition widget is read only
*/
bool TitleBlockTemplateCellWidget::isReadOnly() const {
bool TitleBlockTemplateCellWidget::isReadOnly() const
{
return(read_only_);
}
@@ -404,7 +419,8 @@ void TitleBlockTemplateCellWidget::editTranslatableValue(NamesList &names, const
@param attribute Modified cell attribute
@param new_value New value for the modified cell attribute
*/
void TitleBlockTemplateCellWidget::emitModification(const QString &attribute, const QVariant &new_value) const {
void TitleBlockTemplateCellWidget::emitModification(const QString &attribute, const QVariant &new_value) const
{
if (!edited_cell_) return;
// avoid creating a QUndoCommand object when no modification was actually done
@@ -423,7 +439,8 @@ void TitleBlockTemplateCellWidget::emitModification(const QString &attribute, co
@return a string describing the various variables provided by default by
the application.
*/
QString TitleBlockTemplateCellWidget::defaultVariablesString() const {
QString TitleBlockTemplateCellWidget::defaultVariablesString() const
{
QString def_var_string = tr(
"Par défaut, les variables suivantes sont disponibles :"
"<ul>"
@@ -455,7 +472,8 @@ QString TitleBlockTemplateCellWidget::defaultVariablesString() const {
/**
@return a string describing what the user may enter as cell label / value.
*/
QString TitleBlockTemplateCellWidget::labelValueInformationString() const {
QString TitleBlockTemplateCellWidget::labelValueInformationString() const
{
QString lab_val_inf_string = tr(
"Chaque cellule d'un cartouche affiche une valeur, optionnellement "
"précédée d'un label. Tous deux peuvent être traduits en "

View File

@@ -34,8 +34,9 @@ class TitleBlockTemplateCellWidget : public QWidget {
// constructor, destructor
public:
TitleBlockTemplateCellWidget(TitleBlockTemplate * = nullptr,
QWidget * = nullptr);
TitleBlockTemplateCellWidget(
TitleBlockTemplate * = nullptr,
QWidget * = nullptr);
~TitleBlockTemplateCellWidget() override;
private:
TitleBlockTemplateCellWidget(

View File

@@ -38,14 +38,16 @@ ModifyTitleBlockCellCommand::ModifyTitleBlockCellCommand(TitleBlockCell *cell, Q
/**
Destructor
*/
ModifyTitleBlockCellCommand::~ModifyTitleBlockCellCommand() {
ModifyTitleBlockCellCommand::~ModifyTitleBlockCellCommand()
{
}
/**
@see QUndoCommand::id()
@return the ID of this command.
*/
int ModifyTitleBlockCellCommand::id() const {
int ModifyTitleBlockCellCommand::id() const
{
return(MODIFY_TITLE_BLOCK_CELL_COMMAND_ID);
}
@@ -70,7 +72,8 @@ bool ModifyTitleBlockCellCommand::mergeWith(const QUndoCommand *command) {
/**
Undo the change.
*/
void ModifyTitleBlockCellCommand::undo() {
void ModifyTitleBlockCellCommand::undo()
{
if (!modified_cell_) return;
foreach (QString attribute, old_values_.keys()) {
modified_cell_ -> setAttribute(attribute, old_values_[attribute]);
@@ -81,7 +84,8 @@ void ModifyTitleBlockCellCommand::undo() {
/**
Redo the change.
*/
void ModifyTitleBlockCellCommand::redo() {
void ModifyTitleBlockCellCommand::redo()
{
if (!modified_cell_) return;
foreach (QString attribute, new_values_.keys()) {
modified_cell_ -> setAttribute(attribute, new_values_[attribute]);
@@ -92,7 +96,8 @@ void ModifyTitleBlockCellCommand::redo() {
/**
@return the cell modified by this command
*/
TitleBlockCell *ModifyTitleBlockCellCommand::cell() const {
TitleBlockCell *ModifyTitleBlockCellCommand::cell() const
{
return(modified_cell_);
}
@@ -107,7 +112,8 @@ void ModifyTitleBlockCellCommand::setCell(TitleBlockCell *modified_cell) {
/**
@return the view to be updated after the cell modification
*/
TitleBlockTemplateView *ModifyTitleBlockCellCommand::view() const {
TitleBlockTemplateView *ModifyTitleBlockCellCommand::view() const
{
return(view_);
}
@@ -122,7 +128,8 @@ void ModifyTitleBlockCellCommand::setView(TitleBlockTemplateView *view) {
/**
Erase the known old/new values.
*/
void ModifyTitleBlockCellCommand::clear() {
void ModifyTitleBlockCellCommand::clear()
{
old_values_.clear();
new_values_.clear();
}
@@ -166,13 +173,15 @@ TitleBlockTemplateCommand::TitleBlockTemplateCommand(TitleBlockTemplate *tbtempl
/**
Destructor
*/
TitleBlockTemplateCommand::~TitleBlockTemplateCommand() {
TitleBlockTemplateCommand::~TitleBlockTemplateCommand()
{
}
/**
@return the modified title block template.
*/
TitleBlockTemplate *TitleBlockTemplateCommand::titleBlockTemplate() const {
TitleBlockTemplate *TitleBlockTemplateCommand::titleBlockTemplate() const
{
return(tbtemplate_);
}
@@ -187,7 +196,8 @@ void TitleBlockTemplateCommand::setTitleBlockTemplate(TitleBlockTemplate *tbtemp
/**
@return the view to be updated after the template modification
*/
TitleBlockTemplateView *TitleBlockTemplateCommand::view() const {
TitleBlockTemplateView *TitleBlockTemplateCommand::view() const
{
return(view_);
}
@@ -202,7 +212,8 @@ void TitleBlockTemplateCommand::setView(TitleBlockTemplateView *view) {
/**
Refresh the view, if any.
*/
void TitleBlockTemplateCommand::refreshView() {
void TitleBlockTemplateCommand::refreshView()
{
if (!view_) return;
view_ -> refresh();
}
@@ -210,7 +221,8 @@ void TitleBlockTemplateCommand::refreshView() {
/**
Refresh the view, including layout reloading, if any.
*/
void TitleBlockTemplateCommand::refreshLayout() {
void TitleBlockTemplateCommand::refreshLayout()
{
if (!view_) return;
view_ -> updateLayout();
}
@@ -313,13 +325,15 @@ ModifyTemplateGridCommand::ModifyTemplateGridCommand(TitleBlockTemplate *tbtempl
/**
Destructor
*/
ModifyTemplateGridCommand::~ModifyTemplateGridCommand() {
ModifyTemplateGridCommand::~ModifyTemplateGridCommand()
{
}
/**
@return the index of the inserted/deleted row/column
*/
int ModifyTemplateGridCommand::index() const {
int ModifyTemplateGridCommand::index() const
{
return(index_);
}
@@ -334,7 +348,8 @@ void ModifyTemplateGridCommand::setIndex(int index) {
/**
@return a list of pointers to cells composing the inserted/deleted row/column.
*/
QList<TitleBlockCell *> ModifyTemplateGridCommand::cells() const {
QList<TitleBlockCell *> ModifyTemplateGridCommand::cells() const
{
return(cells_);
}
@@ -349,7 +364,8 @@ void ModifyTemplateGridCommand::setCells(const QList<TitleBlockCell *> &cells) {
/**
@return the dimension of the inserted/deleted row/column.
*/
TitleBlockDimension ModifyTemplateGridCommand::dimension() const {
TitleBlockDimension ModifyTemplateGridCommand::dimension() const
{
return dimension_;
}
@@ -364,7 +380,8 @@ void ModifyTemplateGridCommand::setDimension(const TitleBlockDimension &dimensio
/**
@return true if this object is about inserting/deleting a row, false for a column.
*/
int ModifyTemplateGridCommand::type() const {
int ModifyTemplateGridCommand::type() const
{
return(type_);
}
@@ -380,7 +397,8 @@ void ModifyTemplateGridCommand::setType(bool type) {
/**
@return true if the row/column is inserted, false if it is deleted
*/
bool ModifyTemplateGridCommand::isInsertion() const {
bool ModifyTemplateGridCommand::isInsertion() const
{
return(insertion_);
}
@@ -395,21 +413,24 @@ void ModifyTemplateGridCommand::setInsertion(bool insertion) {
/**
Undo the change.
*/
void ModifyTemplateGridCommand::undo() {
void ModifyTemplateGridCommand::undo()
{
apply(true);
}
/**
Redo the change.
*/
void ModifyTemplateGridCommand::redo() {
void ModifyTemplateGridCommand::redo()
{
apply(false);
}
/**
Update the text describing what the command does.
*/
void ModifyTemplateGridCommand::updateText() {
void ModifyTemplateGridCommand::updateText()
{
if (type_) {
if (insertion_) {
setText(QObject::tr("Insertion d'une ligne", "label used in the title block template editor undo list"));
@@ -472,13 +493,15 @@ ModifyTemplateDimension::ModifyTemplateDimension(TitleBlockTemplate *tbtemplate,
/**
Destructor
*/
ModifyTemplateDimension::~ModifyTemplateDimension() {
ModifyTemplateDimension::~ModifyTemplateDimension()
{
}
/**
@return the index of the resized row/column
*/
int ModifyTemplateDimension::index() const {
int ModifyTemplateDimension::index() const
{
return(index_);
}
@@ -493,7 +516,8 @@ void ModifyTemplateDimension::setIndex(int index) {
/**
@return true if this object is about resizing a row, false for a column.
*/
int ModifyTemplateDimension::type() const {
int ModifyTemplateDimension::type() const
{
return type_;
}
@@ -509,7 +533,8 @@ void ModifyTemplateDimension::setType(bool type) {
/**
@return the dimension of the row/column before it is resized
*/
TitleBlockDimension ModifyTemplateDimension::dimensionBefore() const {
TitleBlockDimension ModifyTemplateDimension::dimensionBefore() const
{
return(before_);
}
@@ -523,7 +548,8 @@ void ModifyTemplateDimension::setDimensionBefore(const TitleBlockDimension &dime
/**
@return the dimension of the row/column after it is resized
*/
TitleBlockDimension ModifyTemplateDimension::dimensionAfter() const {
TitleBlockDimension ModifyTemplateDimension::dimensionAfter() const
{
return(after_);
}
@@ -537,21 +563,24 @@ void ModifyTemplateDimension::setDimensionAfter(const TitleBlockDimension &dimen
/**
Restore the previous size of the row/column.
*/
void ModifyTemplateDimension::undo() {
void ModifyTemplateDimension::undo()
{
apply(before_);
}
/**
Resize the row/column.
*/
void ModifyTemplateDimension::redo() {
void ModifyTemplateDimension::redo()
{
apply(after_);
}
/**
Update the text describing what the command does.
*/
void ModifyTemplateDimension::updateText() {
void ModifyTemplateDimension::updateText()
{
if (type_) {
setText(QObject::tr("Modification d'une ligne", "label used in the title block template editor undo list"));
} else {
@@ -631,7 +660,8 @@ MergeCellsCommand::MergeCellsCommand(const TitleBlockTemplateCellsSet &merged_ce
/**
Destructor
*/
MergeCellsCommand::~MergeCellsCommand() {
MergeCellsCommand::~MergeCellsCommand()
{
}
/**
@@ -658,7 +688,8 @@ bool MergeCellsCommand::canMerge(const TitleBlockTemplateCellsSet &merged_cells,
/**
@return true if this command object is valid and usable, false otherwise.
*/
bool MergeCellsCommand::isValid() const {
bool MergeCellsCommand::isValid() const
{
// we consider having a non-zero spanning cell and positive spans makes a MergeCellsCommand valid
return(spanning_cell_ && row_span_after_ != -1 && col_span_after_ != -1);
}
@@ -666,7 +697,8 @@ bool MergeCellsCommand::isValid() const {
/**
Undo the merge operation.
*/
void MergeCellsCommand::undo() {
void MergeCellsCommand::undo()
{
if (!isValid()) return;
// restore the original spanning_cell attribute of all impacted cells
@@ -687,7 +719,8 @@ void MergeCellsCommand::undo() {
/**
Apply the merge operation
*/
void MergeCellsCommand::redo() {
void MergeCellsCommand::redo()
{
if (!isValid()) return;
// set the spanning_cell attributes of spanned cells to the spanning cell
@@ -771,7 +804,8 @@ SplitCellsCommand::SplitCellsCommand(const TitleBlockTemplateCellsSet &splitted_
/**
Destructor
*/
SplitCellsCommand::~SplitCellsCommand() {
SplitCellsCommand::~SplitCellsCommand()
{
}
/**
@@ -798,7 +832,8 @@ bool SplitCellsCommand::canSplit(const TitleBlockTemplateCellsSet &splitted_cell
/**
@return true if this command object is valid and usable, false otherwise.
*/
bool SplitCellsCommand::isValid() const {
bool SplitCellsCommand::isValid() const
{
// we consider having a non-zero spanning cell and at least one spanned cell makes a SplitCellsCommand valid
return(spanning_cell_ && spanned_cells_.count());
}
@@ -806,7 +841,8 @@ bool SplitCellsCommand::isValid() const {
/**
Undo the split operation
*/
void SplitCellsCommand::undo() {
void SplitCellsCommand::undo()
{
if (!isValid()) return;
// the spanned cells are spanned again
@@ -827,7 +863,8 @@ void SplitCellsCommand::undo() {
/**
Apply the split operation
*/
void SplitCellsCommand::redo() {
void SplitCellsCommand::redo()
{
if (!isValid()) return;
// the spanned cells are not spanned anymore
@@ -862,13 +899,15 @@ ChangeTemplateInformationsCommand::ChangeTemplateInformationsCommand(TitleBlockT
/**
Destructor
*/
ChangeTemplateInformationsCommand::~ChangeTemplateInformationsCommand() {
ChangeTemplateInformationsCommand::~ChangeTemplateInformationsCommand()
{
}
/**
Undo the information change
*/
void ChangeTemplateInformationsCommand::undo() {
void ChangeTemplateInformationsCommand::undo()
{
if (!tbtemplate_) return;
tbtemplate_ -> setInformation(old_information_);
}
@@ -876,7 +915,8 @@ void ChangeTemplateInformationsCommand::undo() {
/**
Redo the information change
*/
void ChangeTemplateInformationsCommand::redo() {
void ChangeTemplateInformationsCommand::redo()
{
tbtemplate_ -> setInformation(new_information_);
}
@@ -891,13 +931,15 @@ CutTemplateCellsCommand::CutTemplateCellsCommand(TitleBlockTemplate *tb_template
/**
Destructor
*/
CutTemplateCellsCommand::~CutTemplateCellsCommand() {
CutTemplateCellsCommand::~CutTemplateCellsCommand()
{
}
/**
Undo a cut operation
*/
void CutTemplateCellsCommand::undo() {
void CutTemplateCellsCommand::undo()
{
foreach (TitleBlockCell *cell, cut_cells_.keys()) {
cell -> cell_type = cut_cells_.value(cell);
}
@@ -907,7 +949,8 @@ void CutTemplateCellsCommand::undo() {
/**
Redo a cut operation
*/
void CutTemplateCellsCommand::redo() {
void CutTemplateCellsCommand::redo()
{
foreach (TitleBlockCell *cell, cut_cells_.keys()) {
cell -> cell_type = TitleBlockCell::EmptyCell;
}
@@ -924,7 +967,8 @@ void CutTemplateCellsCommand::setCutCells(const QList<TitleBlockCell *> &cells)
/**
Update the label describing this command
*/
void CutTemplateCellsCommand::updateText() {
void CutTemplateCellsCommand::updateText()
{
setText(QObject::tr("Couper %n cellule(s)", "undo caption", cut_cells_.count()));
}
@@ -942,20 +986,23 @@ PasteTemplateCellsCommand::PasteTemplateCellsCommand(TitleBlockTemplate *tb_temp
/**
Destructor
*/
PasteTemplateCellsCommand::~PasteTemplateCellsCommand() {
PasteTemplateCellsCommand::~PasteTemplateCellsCommand()
{
}
/**
Update the label describing this command
*/
void PasteTemplateCellsCommand::updateText() {
void PasteTemplateCellsCommand::updateText()
{
setText(QObject::tr("Coller %n cellule(s)", "undo caption", erased_cells_.count()));
}
/**
Undo a paste action.
*/
void PasteTemplateCellsCommand::undo() {
void PasteTemplateCellsCommand::undo()
{
bool span_management = erased_cells_.count() > 1;
foreach (TitleBlockCell *cell, erased_cells_.keys()) {
cell -> loadContentFromCell(erased_cells_.value(cell));
@@ -973,7 +1020,8 @@ void PasteTemplateCellsCommand::undo() {
/**
Redo a paste action.
*/
void PasteTemplateCellsCommand::redo() {
void PasteTemplateCellsCommand::redo()
{
// we only play with spans when pasting more than one cell.
bool span_management = erased_cells_.count() > 1;

View File

@@ -32,7 +32,8 @@ TitleBlockTemplateDeleter::TitleBlockTemplateDeleter(const TitleBlockTemplateLoc
/**
Destructor
*/
TitleBlockTemplateDeleter::~TitleBlockTemplateDeleter() {
TitleBlockTemplateDeleter::~TitleBlockTemplateDeleter()
{
}
/**
@@ -41,7 +42,8 @@ TitleBlockTemplateDeleter::~TitleBlockTemplateDeleter() {
actually proceeding to the deletion.
@return true if the deletion succeeded, false otherwise.
*/
bool TitleBlockTemplateDeleter::exec() {
bool TitleBlockTemplateDeleter::exec()
{
if (!template_location_.isValid()) return(false);
QString name = template_location_.name();

View File

@@ -38,7 +38,8 @@ TitleBlockTemplateLocation::TitleBlockTemplateLocation(
/**
Destructor
*/
TitleBlockTemplateLocation::~TitleBlockTemplateLocation() {
TitleBlockTemplateLocation::~TitleBlockTemplateLocation()
{
}
/**
@@ -54,7 +55,8 @@ TitleBlockTemplateLocation TitleBlockTemplateLocation::locationFromString(
/**
@return the parent collection of the template, or 0 if none was defined
*/
TitleBlockTemplatesCollection *TitleBlockTemplateLocation::parentCollection() const {
TitleBlockTemplatesCollection *TitleBlockTemplateLocation::parentCollection() const
{
return(collection_);
}
@@ -70,7 +72,8 @@ void TitleBlockTemplateLocation::setParentCollection(
/**
@return the name of this template within its parent project or collection.
*/
QString TitleBlockTemplateLocation::name() const {
QString TitleBlockTemplateLocation::name() const
{
return(name_);
}
@@ -84,7 +87,8 @@ void TitleBlockTemplateLocation::setName(const QString &name) {
/**
@return true if this location is null, false otherwise
*/
bool TitleBlockTemplateLocation::isValid() const {
bool TitleBlockTemplateLocation::isValid() const
{
return(!name_.isEmpty());
}
@@ -105,7 +109,8 @@ void TitleBlockTemplateLocation::fromString(const QString &loc_str) {
/**
@return A string representation of the location
*/
QString TitleBlockTemplateLocation::toString() const {
QString TitleBlockTemplateLocation::toString() const
{
return(protocol() + QString("://") + name_);
}
@@ -113,7 +118,8 @@ QString TitleBlockTemplateLocation::toString() const {
This is a convenience method equivalent to
parentCollection() -> parentProject().
*/
QETProject *TitleBlockTemplateLocation::parentProject() const {
QETProject *TitleBlockTemplateLocation::parentProject() const
{
if (collection_) {
return(collection_ -> parentProject());
}
@@ -124,7 +130,8 @@ QETProject *TitleBlockTemplateLocation::parentProject() const {
This is a convenience method equivalent to
parentCollection() -> protocol().
*/
QString TitleBlockTemplateLocation::protocol() const {
QString TitleBlockTemplateLocation::protocol() const
{
if (collection_) {
return(collection_ -> protocol());
}
@@ -135,7 +142,8 @@ QString TitleBlockTemplateLocation::protocol() const {
This is a convenience method equivalent to
parentCollection() -> getTemplateXmlDescription
*/
QDomElement TitleBlockTemplateLocation::getTemplateXmlDescription() const {
QDomElement TitleBlockTemplateLocation::getTemplateXmlDescription() const
{
if (!collection_ || name_.isEmpty()) return(QDomElement());
return(collection_ -> getTemplateXmlDescription(name_));
}
@@ -144,7 +152,8 @@ QDomElement TitleBlockTemplateLocation::getTemplateXmlDescription() const {
This is a convenience method equivalent to
parentCollection() -> getTemplate(...).
*/
TitleBlockTemplate *TitleBlockTemplateLocation::getTemplate() const {
TitleBlockTemplate *TitleBlockTemplateLocation::getTemplate() const
{
if (!collection_ || name_.isEmpty()) return(nullptr);
return(collection_ -> getTemplate(name_));
}
@@ -153,7 +162,8 @@ TitleBlockTemplate *TitleBlockTemplateLocation::getTemplate() const {
This is a convenience method equivalent to
parentCollection() -> isReadOnly(name())
*/
bool TitleBlockTemplateLocation::isReadOnly() const {
bool TitleBlockTemplateLocation::isReadOnly() const
{
if (!collection_) return(false);
return(collection_ -> isReadOnly(name_));
}
@@ -163,7 +173,8 @@ bool TitleBlockTemplateLocation::isReadOnly() const {
@return true if locations are equal, false otherwise
*/
bool TitleBlockTemplateLocation::operator==(
const TitleBlockTemplateLocation &location) const {
const TitleBlockTemplateLocation &location) const
{
return(location.collection_ == collection_ && location.name_ == name_);
}

View File

@@ -39,27 +39,31 @@ TitleBlockTemplateLocationChooser::TitleBlockTemplateLocationChooser(
/**
Destructor
*/
TitleBlockTemplateLocationChooser::~TitleBlockTemplateLocationChooser() {
TitleBlockTemplateLocationChooser::~TitleBlockTemplateLocationChooser()
{
}
/**
@return the current location
*/
TitleBlockTemplateLocation TitleBlockTemplateLocationChooser::location() const {
TitleBlockTemplateLocation TitleBlockTemplateLocationChooser::location() const
{
return(TitleBlockTemplateLocation(name(), collection()));
}
/**
@return the currently selected collection
*/
TitleBlockTemplatesCollection *TitleBlockTemplateLocationChooser::collection() const {
TitleBlockTemplatesCollection *TitleBlockTemplateLocationChooser::collection() const
{
return(collections_index_[collections_ -> currentIndex()]);
}
/**
@return the currently selected/entered name
*/
QString TitleBlockTemplateLocationChooser::name() const {
QString TitleBlockTemplateLocationChooser::name() const
{
int template_index = templates_ -> currentIndex();
return(template_index != -1 ? templates_ -> currentText() : QString());
}
@@ -87,7 +91,8 @@ void TitleBlockTemplateLocationChooser::setLocation(
Initialize this widget.
@param location Initial location displayed by the widget
*/
void TitleBlockTemplateLocationChooser::init() {
void TitleBlockTemplateLocationChooser::init()
{
collections_ = new QComboBox();
templates_ = new QComboBox();
@@ -96,10 +101,12 @@ void TitleBlockTemplateLocationChooser::init() {
this, SLOT(updateTemplates()));
form_layout_ = new QFormLayout();
form_layout_ -> addRow(tr("Collection parente","used in save as form"),
collections_);
form_layout_ -> addRow(tr("Modèle existant","used in save as form"),
templates_);
form_layout_ -> addRow(
tr("Collection parente","used in save as form"),
collections_);
form_layout_ -> addRow(
tr("Modèle existant","used in save as form"),
templates_);
setLayout(form_layout_);
}
@@ -111,7 +118,8 @@ void TitleBlockTemplateLocationChooser::init() {
or the index of \a coll
*/
int TitleBlockTemplateLocationChooser::indexForCollection(
TitleBlockTemplatesCollection *coll) const {
TitleBlockTemplatesCollection *coll) const
{
QList<int> indexes = collections_index_.keys(coll);
if (indexes.count()) return(indexes.first());
return(-1);
@@ -120,7 +128,8 @@ int TitleBlockTemplateLocationChooser::indexForCollection(
/**
Update the collections list
*/
void TitleBlockTemplateLocationChooser::updateCollections() {
void TitleBlockTemplateLocationChooser::updateCollections()
{
collections_ -> clear();
collections_index_.clear();
@@ -138,7 +147,8 @@ void TitleBlockTemplateLocationChooser::updateCollections() {
/**
Update the templates list according to the selected collection.
*/
void TitleBlockTemplateLocationChooser::updateTemplates() {
void TitleBlockTemplateLocationChooser::updateTemplates()
{
TitleBlockTemplatesCollection *current_collection = collection();
if (!current_collection) return;

View File

@@ -39,13 +39,15 @@ TitleBlockTemplateLocationSaver::TitleBlockTemplateLocationSaver(
/**
Destructor
*/
TitleBlockTemplateLocationSaver::~TitleBlockTemplateLocationSaver() {
TitleBlockTemplateLocationSaver::~TitleBlockTemplateLocationSaver()
{
}
/**
@return the currently selected/entered name
*/
QString TitleBlockTemplateLocationSaver::name() const {
QString TitleBlockTemplateLocationSaver::name() const
{
int template_index = templates_ -> currentIndex();
return(template_index ? templates_ -> currentText() : new_name_ -> text());
}
@@ -74,17 +76,19 @@ void TitleBlockTemplateLocationSaver::setLocation(const TitleBlockTemplateLocati
Initialize this widget.
@param location Initial location displayed by the widget
*/
void TitleBlockTemplateLocationSaver::init() {
void TitleBlockTemplateLocationSaver::init()
{
new_name_ = new QLineEdit();
connect(templates_, SIGNAL(currentIndexChanged(int)), this, SLOT(updateNewName()));
form_layout_ -> addRow(tr("ou nouveau nom", "used in save as form"), new_name_);
form_layout_ -> addRow(tr("ou nouveau nom", "used in save as form"), new_name_);
updateTemplates();
}
/**
Update the templates list according to the selected collection.
*/
void TitleBlockTemplateLocationSaver::updateTemplates() {
void TitleBlockTemplateLocationSaver::updateTemplates()
{
TitleBlockTemplatesCollection *current_collection = collection();
if (!current_collection) return;
@@ -99,7 +103,8 @@ void TitleBlockTemplateLocationSaver::updateTemplates() {
Enable or diable the "new name" text field depending of the selected
template.
*/
void TitleBlockTemplateLocationSaver::updateNewName() {
void TitleBlockTemplateLocationSaver::updateNewName()
{
int template_index = templates_ -> currentIndex();
new_name_ -> setEnabled(!template_index);
}

View File

@@ -37,14 +37,16 @@ TitleBlockTemplateLogoManager::TitleBlockTemplateLogoManager(TitleBlockTemplate
/**
Destructor
*/
TitleBlockTemplateLogoManager::~TitleBlockTemplateLogoManager() {
TitleBlockTemplateLogoManager::~TitleBlockTemplateLogoManager()
{
}
/**
@return the name of the currently selected logo, or a null QString if none
is selected.
*/
QString TitleBlockTemplateLogoManager::currentLogo() const {
QString TitleBlockTemplateLogoManager::currentLogo() const
{
if (!managed_template_) return QString();
QListWidgetItem *current_item = logos_view_ -> currentItem();
@@ -57,21 +59,24 @@ QString TitleBlockTemplateLogoManager::currentLogo() const {
@return Whether this logo manager should allow logo edition
(renaming, addition, deletion).
*/
bool TitleBlockTemplateLogoManager::isReadOnly() const {
bool TitleBlockTemplateLogoManager::isReadOnly() const
{
return(read_only_);
}
/**
Emit the logosChanged() signal.
*/
void TitleBlockTemplateLogoManager::emitLogosChangedSignal() {
void TitleBlockTemplateLogoManager::emitLogosChangedSignal()
{
emit(logosChanged(const_cast<const TitleBlockTemplate *>(managed_template_)));
}
/**
Initialize widgets composing the Logo manager
*/
void TitleBlockTemplateLogoManager::initWidgets() {
void TitleBlockTemplateLogoManager::initWidgets()
{
open_dialog_dir_.setPath(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
setWindowTitle(tr("Gestionnaire de logos"));
@@ -133,7 +138,8 @@ void TitleBlockTemplateLogoManager::initWidgets() {
/**
Update the logos display.
*/
void TitleBlockTemplateLogoManager::fillView() {
void TitleBlockTemplateLogoManager::fillView()
{
if (!managed_template_) return;
logos_view_ -> clear();
@@ -167,7 +173,8 @@ void TitleBlockTemplateLogoManager::fillView() {
@return the icon size to display the logos embedded within the managed
template.
*/
QSize TitleBlockTemplateLogoManager::iconsize() const {
QSize TitleBlockTemplateLogoManager::iconsize() const
{
return(QSize(80, 80));
}
@@ -261,7 +268,8 @@ void TitleBlockTemplateLogoManager::updateLogoInformations(QListWidgetItem *curr
Ask the user for a filepath, and add it as a new logo in the managed
template.
*/
void TitleBlockTemplateLogoManager::addLogo() {
void TitleBlockTemplateLogoManager::addLogo()
{
if (!managed_template_) return;
QString filepath = QFileDialog::getOpenFileName(
@@ -293,7 +301,8 @@ void TitleBlockTemplateLogoManager::addLogo() {
/**
Export the currently selected logo
*/
void TitleBlockTemplateLogoManager::exportLogo() {
void TitleBlockTemplateLogoManager::exportLogo()
{
QString current_logo = currentLogo();
if (current_logo.isNull()) return;
@@ -316,7 +325,8 @@ void TitleBlockTemplateLogoManager::exportLogo() {
/**
Delete the currently selected logo.
*/
void TitleBlockTemplateLogoManager::removeLogo() {
void TitleBlockTemplateLogoManager::removeLogo()
{
QString current_logo = currentLogo();
if (current_logo.isNull()) return;
@@ -329,7 +339,8 @@ void TitleBlockTemplateLogoManager::removeLogo() {
/**
Rename currently selected logo.
*/
void TitleBlockTemplateLogoManager::renameLogo() {
void TitleBlockTemplateLogoManager::renameLogo()
{
QString current_logo = currentLogo();
if (current_logo.isNull()) return;

View File

@@ -33,13 +33,15 @@ TitleBlockTemplatesCollection::TitleBlockTemplatesCollection(QObject *parent) :
/**
Destructor
*/
TitleBlockTemplatesCollection::~TitleBlockTemplatesCollection() {
TitleBlockTemplatesCollection::~TitleBlockTemplatesCollection()
{
}
/**
@return the title of this collection
*/
QString TitleBlockTemplatesCollection::title() const {
QString TitleBlockTemplatesCollection::title() const
{
return(title_);
}
@@ -55,7 +57,8 @@ void TitleBlockTemplatesCollection::setTitle(const QString &title) {
@return the protocol used by this collection ; examples: commontbt,
customtbt, embedtbt, ...
*/
QString TitleBlockTemplatesCollection::protocol() const {
QString TitleBlockTemplatesCollection::protocol() const
{
return(protocol_);
}
@@ -71,7 +74,8 @@ void TitleBlockTemplatesCollection::setProtocol(const QString &protocol) {
@brief TitleBlockTemplatesCollection::collection
@return the collection where is stored this collection.
*/
QET::QetCollection TitleBlockTemplatesCollection::collection() const {
QET::QetCollection TitleBlockTemplatesCollection::collection() const
{
return m_collection;
}
@@ -88,7 +92,8 @@ void TitleBlockTemplatesCollection::setCollection(QET::QetCollection c) {
@return the project this collection is affiliated to, or 0 if this
collection is not related to any project.
*/
QETProject *TitleBlockTemplatesCollection::parentProject() {
QETProject *TitleBlockTemplatesCollection::parentProject()
{
return(nullptr);
}
@@ -97,7 +102,8 @@ QETProject *TitleBlockTemplatesCollection::parentProject() {
objects.
@see templates()
*/
QList<TitleBlockTemplateLocation> TitleBlockTemplatesCollection::templatesLocations() {
QList<TitleBlockTemplateLocation> TitleBlockTemplatesCollection::templatesLocations()
{
QList<TitleBlockTemplateLocation> locations;
foreach (QString template_name, templates()) {
locations << location(template_name);
@@ -120,13 +126,15 @@ TitleBlockTemplatesProjectCollection::TitleBlockTemplatesProjectCollection(QETPr
/**
Destructor
*/
TitleBlockTemplatesProjectCollection::~TitleBlockTemplatesProjectCollection() {
TitleBlockTemplatesProjectCollection::~TitleBlockTemplatesProjectCollection()
{
}
/**
@return a human readable title for this collection
*/
QString TitleBlockTemplatesProjectCollection::title() const {
QString TitleBlockTemplatesProjectCollection::title() const
{
if (!title_.isEmpty()) return(title_);
// if the title attribute is empty, we generate a suitable one using the
@@ -158,7 +166,8 @@ QString TitleBlockTemplatesProjectCollection::title() const {
/**
@return the protocol used to mention this collection
*/
QString TitleBlockTemplatesProjectCollection::protocol() const {
QString TitleBlockTemplatesProjectCollection::protocol() const
{
if (project_) {
int project_id = QETApp::projectId(project_);
if (project_id != -1) {
@@ -172,14 +181,16 @@ QString TitleBlockTemplatesProjectCollection::protocol() const {
/**
@return the parent project of this project collection
*/
QETProject *TitleBlockTemplatesProjectCollection::parentProject() {
QETProject *TitleBlockTemplatesProjectCollection::parentProject()
{
return(project_);
}
/**
@return the list of title block templates embedded within the project.
*/
QStringList TitleBlockTemplatesProjectCollection::templates() {
QStringList TitleBlockTemplatesProjectCollection::templates()
{
return(titleblock_templates_xml_.keys());
}
@@ -292,7 +303,8 @@ TitleBlockTemplateLocation TitleBlockTemplatesProjectCollection::location(const
@return always false since a project collection is not stored on any
filesystem.
*/
bool TitleBlockTemplatesProjectCollection::hasFilePath() {
bool TitleBlockTemplatesProjectCollection::hasFilePath()
{
return(false);
}
@@ -300,7 +312,8 @@ bool TitleBlockTemplatesProjectCollection::hasFilePath() {
@return always an empty string since a project collection is not stored on
any filesystem.
*/
QString TitleBlockTemplatesProjectCollection::filePath() {
QString TitleBlockTemplatesProjectCollection::filePath()
{
return(QString());
}
@@ -309,7 +322,8 @@ QString TitleBlockTemplatesProjectCollection::filePath() {
itself is read only, or a specific template name.
@return true if the specified template is read only, false otherwise
*/
bool TitleBlockTemplatesProjectCollection::isReadOnly(const QString &template_name) const {
bool TitleBlockTemplatesProjectCollection::isReadOnly(const QString &template_name) const
{
Q_UNUSED(template_name)
if (project_) {
return(project_ -> isReadOnly());
@@ -338,7 +352,8 @@ void TitleBlockTemplatesProjectCollection::fromXml(const QDomElement &xml_elemen
/**
Delete all title block templates not used within the parent project
*/
void TitleBlockTemplatesProjectCollection::deleteUnusedTitleBlocKTemplates() {
void TitleBlockTemplatesProjectCollection::deleteUnusedTitleBlocKTemplates()
{
if (!project_) return;
foreach (QString template_name, templates()) {
@@ -371,13 +386,15 @@ TitleBlockTemplatesFilesCollection::TitleBlockTemplatesFilesCollection(const QSt
/**
Destructor
*/
TitleBlockTemplatesFilesCollection::~TitleBlockTemplatesFilesCollection() {
TitleBlockTemplatesFilesCollection::~TitleBlockTemplatesFilesCollection()
{
}
/**
@return the canonical path of the directory hosting this collection.
*/
QString TitleBlockTemplatesFilesCollection::path(const QString &template_name) const {
QString TitleBlockTemplatesFilesCollection::path(const QString &template_name) const
{
if (template_name.isEmpty()) {
return(dir_.canonicalPath());
} else {
@@ -388,7 +405,8 @@ QString TitleBlockTemplatesFilesCollection::path(const QString &template_name) c
/**
@return the list of templates contained in this collection
*/
QStringList TitleBlockTemplatesFilesCollection::templates() {
QStringList TitleBlockTemplatesFilesCollection::templates()
{
QStringList templates_names;
QRegExp replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
foreach(QString name, dir_.entryList()) {
@@ -492,14 +510,16 @@ TitleBlockTemplateLocation TitleBlockTemplatesFilesCollection::location(const QS
@return always true since a files collection is always stored on a
filesystem.
*/
bool TitleBlockTemplatesFilesCollection::hasFilePath() {
bool TitleBlockTemplatesFilesCollection::hasFilePath()
{
return(true);
}
/**
@return The filesystem path where this files collection is actually stored.
*/
QString TitleBlockTemplatesFilesCollection::filePath() {
QString TitleBlockTemplatesFilesCollection::filePath()
{
return(dir_.canonicalPath());
}
@@ -508,7 +528,8 @@ QString TitleBlockTemplatesFilesCollection::filePath() {
itself is read only, or a specific template name.
@return true if the specified template is read only, false otherwise
*/
bool TitleBlockTemplatesFilesCollection::isReadOnly(const QString &template_name) const {
bool TitleBlockTemplatesFilesCollection::isReadOnly(const QString &template_name) const
{
if (template_name.isEmpty()) {
QFileInfo info(dir_.canonicalPath());
return(!info.isWritable());

View File

@@ -56,8 +56,8 @@ TitleBlockTemplateView::TitleBlockTemplateView(QWidget *parent) :
@param scene
@param parent Parent QWidget.
*/
TitleBlockTemplateView::TitleBlockTemplateView(QGraphicsScene *scene,
QWidget *parent) :
TitleBlockTemplateView::TitleBlockTemplateView(
QGraphicsScene *scene,QWidget *parent) :
QGraphicsView(scene, parent),
tbtemplate_(nullptr),
tbgrid_(nullptr),
@@ -73,7 +73,8 @@ TitleBlockTemplateView::TitleBlockTemplateView(QGraphicsScene *scene,
/**
Destructor
*/
TitleBlockTemplateView::~TitleBlockTemplateView() {
TitleBlockTemplateView::~TitleBlockTemplateView()
{
}
/**
@@ -88,14 +89,16 @@ void TitleBlockTemplateView::setTitleBlockTemplate(TitleBlockTemplate *tbtemplat
/**
@return The title block template object rendered by this view.
*/
TitleBlockTemplate *TitleBlockTemplateView::titleBlockTemplate() const {
TitleBlockTemplate *TitleBlockTemplateView::titleBlockTemplate() const
{
return(tbtemplate_);
}
/**
Emits the selectedCellsChanged() signal with the currently selected cells.
*/
void TitleBlockTemplateView::selectionChanged() {
void TitleBlockTemplateView::selectionChanged()
{
emit(selectedCellsChanged(selectedCells()));
}
@@ -103,7 +106,8 @@ void TitleBlockTemplateView::selectionChanged() {
Zoom in by zoomFactor().
@see zoomFactor()
*/
void TitleBlockTemplateView::zoomIn() {
void TitleBlockTemplateView::zoomIn()
{
scale(zoomFactor(), zoomFactor());
}
@@ -111,7 +115,8 @@ void TitleBlockTemplateView::zoomIn() {
Zoom out by zoomFactor().
@see zoomFactor()
*/
void TitleBlockTemplateView::zoomOut() {
void TitleBlockTemplateView::zoomOut()
{
qreal zoom_factor = 1.0/zoomFactor();
scale(zoom_factor, zoom_factor);
}
@@ -119,7 +124,8 @@ void TitleBlockTemplateView::zoomOut() {
/**
Fit the rendered title block template in this view.
*/
void TitleBlockTemplateView::zoomFit() {
void TitleBlockTemplateView::zoomFit()
{
adjustSceneRect();
fitInView(scene() -> sceneRect(), Qt::KeepAspectRatio);
}
@@ -127,7 +133,8 @@ void TitleBlockTemplateView::zoomFit() {
/**
Reset the zoom level.
*/
void TitleBlockTemplateView::zoomReset() {
void TitleBlockTemplateView::zoomReset()
{
adjustSceneRect();
resetTransform();
}
@@ -137,7 +144,8 @@ void TitleBlockTemplateView::zoomReset() {
empty.
@return the list of cells copied to the clipboard
*/
QList<TitleBlockCell *> TitleBlockTemplateView::cut() {
QList<TitleBlockCell *> TitleBlockTemplateView::cut()
{
if (!tbtemplate_) return(QList<TitleBlockCell *>());
QList<TitleBlockCell *> copied_cells = copy();
@@ -153,7 +161,8 @@ QList<TitleBlockCell *> TitleBlockTemplateView::cut() {
Export currently selected cells to the clipboard.
@return the list of cells copied to the clipboard
*/
QList<TitleBlockCell *> TitleBlockTemplateView::copy() {
QList<TitleBlockCell *> TitleBlockTemplateView::copy()
{
if (!tbtemplate_) return(QList<TitleBlockCell *>());
QList<TitleBlockCell *> copied_cells = selectedCells();
@@ -177,7 +186,8 @@ QList<TitleBlockCell *> TitleBlockTemplateView::copy() {
/**
@return true if the content of the clipboard looks interesting
*/
bool TitleBlockTemplateView::mayPaste() {
bool TitleBlockTemplateView::mayPaste()
{
// retrieve the clipboard content
QClipboard *clipboard = QApplication::clipboard();
return(clipboard -> text().contains("<titleblocktemplate-partial"));
@@ -186,7 +196,8 @@ bool TitleBlockTemplateView::mayPaste() {
/**
@return a list containing the pasted cells
*/
QList<TitleBlockCell> TitleBlockTemplateView::pastedCells() {
QList<TitleBlockCell> TitleBlockTemplateView::pastedCells()
{
QList<TitleBlockCell> pasted_cells;
// retrieve the clipboard content and parse it as XML
@@ -235,7 +246,8 @@ QList<TitleBlockCell> TitleBlockTemplateView::pastedCells() {
/**
Import the cells described in the clipboard.
*/
void TitleBlockTemplateView::paste() {
void TitleBlockTemplateView::paste()
{
if (!tbtemplate_) return;
QList<TitleBlockCell> pasted_cells = pastedCells();
if (!pasted_cells.count()) return;
@@ -262,7 +274,8 @@ void TitleBlockTemplateView::paste() {
/**
Add a column right after the last one.
*/
void TitleBlockTemplateView::addColumnAtEnd() {
void TitleBlockTemplateView::addColumnAtEnd()
{
if (read_only_) return;
requestGridModification(ModifyTemplateGridCommand::addColumn(tbtemplate_, tbtemplate_ -> columnsCount()));
}
@@ -270,7 +283,8 @@ void TitleBlockTemplateView::addColumnAtEnd() {
/**
Add a row right after the last one.
*/
void TitleBlockTemplateView::addRowAtEnd() {
void TitleBlockTemplateView::addRowAtEnd()
{
if (read_only_) return;
requestGridModification(ModifyTemplateGridCommand::addRow(tbtemplate_, tbtemplate_ -> rowsCount()));
}
@@ -279,7 +293,8 @@ void TitleBlockTemplateView::addRowAtEnd() {
Add a column right before the last index selected when calling the context
menu.
*/
void TitleBlockTemplateView::addColumnBefore() {
void TitleBlockTemplateView::addColumnBefore()
{
if (read_only_) return;
int index = lastContextMenuCellIndex();
if (index == -1) return;
@@ -290,7 +305,8 @@ void TitleBlockTemplateView::addColumnBefore() {
Add a row right before the last index selected when calling the context
menu.
*/
void TitleBlockTemplateView::addRowBefore() {
void TitleBlockTemplateView::addRowBefore()
{
if (read_only_) return;
int index = lastContextMenuCellIndex();
if (index == -1) return;
@@ -301,7 +317,8 @@ void TitleBlockTemplateView::addRowBefore() {
Add a column right after the last index selected when calling the context
menu.
*/
void TitleBlockTemplateView::addColumnAfter() {
void TitleBlockTemplateView::addColumnAfter()
{
if (read_only_) return;
int index = lastContextMenuCellIndex();
if (index == -1) return;
@@ -312,7 +329,8 @@ void TitleBlockTemplateView::addColumnAfter() {
Add a row right after the last index selected when calling the context
menu.
*/
void TitleBlockTemplateView::addRowAfter() {
void TitleBlockTemplateView::addRowAfter()
{
if (read_only_) return;
int index = lastContextMenuCellIndex();
if (index == -1) return;
@@ -374,7 +392,8 @@ void TitleBlockTemplateView::editRow(HelperCell *cell) {
/**
Remove the column at the last index selected when calling the context menu.
*/
void TitleBlockTemplateView::deleteColumn() {
void TitleBlockTemplateView::deleteColumn()
{
int index = lastContextMenuCellIndex();
if (index == -1) return;
requestGridModification(ModifyTemplateGridCommand::deleteColumn(tbtemplate_, index));
@@ -383,7 +402,8 @@ void TitleBlockTemplateView::deleteColumn() {
/**
Remove the row at the last index selected when calling the context menu.
*/
void TitleBlockTemplateView::deleteRow() {
void TitleBlockTemplateView::deleteRow()
{
int index = lastContextMenuCellIndex();
if (index == -1) return;
requestGridModification(ModifyTemplateGridCommand::deleteRow(tbtemplate_, index));
@@ -392,7 +412,8 @@ void TitleBlockTemplateView::deleteRow() {
/**
Merge the selected cells.
*/
void TitleBlockTemplateView::mergeSelectedCells() {
void TitleBlockTemplateView::mergeSelectedCells()
{
// retrieve the selected cells
TitleBlockTemplateCellsSet selected_cells = selectedCellsSet();
@@ -403,7 +424,8 @@ void TitleBlockTemplateView::mergeSelectedCells() {
/**
Split the selected cell.
*/
void TitleBlockTemplateView::splitSelectedCell() {
void TitleBlockTemplateView::splitSelectedCell()
{
// retrieve the selected cells
TitleBlockTemplateCellsSet selected_cells = selectedCellsSet();
@@ -423,14 +445,16 @@ void TitleBlockTemplateView::drawBackground(QPainter *painter, const QRectF &rec
/**
@return the selected logical cells, not including the spanned ones.
*/
QList<TitleBlockCell *> TitleBlockTemplateView::selectedCells() const {
QList<TitleBlockCell *> TitleBlockTemplateView::selectedCells() const
{
return(selectedCellsSet().cells(false).values());
}
/**
@return the selected visual cells.
*/
TitleBlockTemplateCellsSet TitleBlockTemplateView::selectedCellsSet() const {
TitleBlockTemplateCellsSet TitleBlockTemplateView::selectedCellsSet() const
{
return(makeCellsSetFromGraphicsItems(scene() -> selectedItems()));
}
@@ -439,7 +463,8 @@ TitleBlockTemplateCellsSet TitleBlockTemplateView::selectedCellsSet() const {
@param rect Rectangle in the coordinates of the QGraphicsWidget
representing the title block template.
*/
TitleBlockTemplateCellsSet TitleBlockTemplateView::cells(const QRectF &rect) const {
TitleBlockTemplateCellsSet TitleBlockTemplateView::cells(const QRectF &rect) const
{
QPolygonF mapped_rect(form_ -> mapToScene(rect));
QList<QGraphicsItem *> items = scene() -> items(mapped_rect, Qt::IntersectsItemShape);
return(makeCellsSetFromGraphicsItems(items));
@@ -482,14 +507,16 @@ void TitleBlockTemplateView::analyzeSelectedCells(bool *can_merge,
/**
@return the current size of the rendered title block template
*/
QSizeF TitleBlockTemplateView::templateSize() const {
QSizeF TitleBlockTemplateView::templateSize() const
{
return(QSizeF(templateWidth(), templateHeight()));
}
/**
@return the current width of the rendered title block template
*/
qreal TitleBlockTemplateView::templateWidth() const {
qreal TitleBlockTemplateView::templateWidth() const
{
if (!tbtemplate_) return(0);
qreal width = DEFAULT_ROWS_HELPER_CELLS_WIDTH;
@@ -502,7 +529,8 @@ qreal TitleBlockTemplateView::templateWidth() const {
/**
@return the current height of the rendered title block template
*/
qreal TitleBlockTemplateView::templateHeight() const {
qreal TitleBlockTemplateView::templateHeight() const
{
if (!tbtemplate_) return(0);
qreal height = DEFAULT_PREVIEW_HELPER_CELL_HEIGHT;
@@ -532,14 +560,16 @@ void TitleBlockTemplateView::wheelEvent(QWheelEvent *e) {
/**
@return the zoom factor used by zoomIn() and zoomOut().
*/
qreal TitleBlockTemplateView::zoomFactor() const {
qreal TitleBlockTemplateView::zoomFactor() const
{
return(1.1);
}
/**
Initialize this view (actions, signals/slots connections, etc.)
*/
void TitleBlockTemplateView::init() {
void TitleBlockTemplateView::init()
{
add_column_before_ = new QAction(QET::Icons::EditTableInsertColumnLeft, tr("Ajouter une colonne (avant)", "context menu"), this);
add_row_before_ = new QAction(QET::Icons::EditTableInsertRowAbove, tr("Ajouter une ligne (avant)", "context menu"), this);
add_column_after_ = new QAction(QET::Icons::EditTableInsertColumnRight, tr("Ajouter une colonne (après)", "context menu"), this);
@@ -669,7 +699,8 @@ void TitleBlockTemplateView::applyRowsHeights(bool animate) {
/**
Update the content (type and value) of rows helper cells.
*/
void TitleBlockTemplateView::updateRowsHelperCells() {
void TitleBlockTemplateView::updateRowsHelperCells()
{
int row_count = tbtemplate_ -> rowsCount();
QList<int> heights = tbtemplate_ -> rowsHeights();
for (int i = 0 ; i < row_count ; ++ i) {
@@ -684,7 +715,8 @@ void TitleBlockTemplateView::updateRowsHelperCells() {
/**
Update the content (type and value) of columns helper cells.
*/
void TitleBlockTemplateView::updateColumnsHelperCells() {
void TitleBlockTemplateView::updateColumnsHelperCells()
{
int col_count = tbtemplate_ -> columnsCount();
for (int i = 0 ; i < col_count ; ++ i) {
TitleBlockDimension current_col_dim = tbtemplate_ -> columnDimension(i);
@@ -700,7 +732,8 @@ void TitleBlockTemplateView::updateColumnsHelperCells() {
Add the cells (both helper cells and regular visual cells) to the scene to
get a visual representation of the edited title block template.
*/
void TitleBlockTemplateView::addCells() {
void TitleBlockTemplateView::addCells()
{
int col_count = tbtemplate_ -> columnsCount();
int row_count = tbtemplate_ -> rowsCount();
@@ -710,8 +743,10 @@ void TitleBlockTemplateView::addCells() {
updateTotalWidthLabel();
total_width_helper_cell_ -> orientation = Qt::Horizontal;
total_width_helper_cell_ -> setActions(QList<QAction *>() << change_preview_width_);
connect(total_width_helper_cell_, SIGNAL(contextMenuTriggered(HelperCell *)), this, SLOT(updateLastContextMenuCell(HelperCell *)));
connect(total_width_helper_cell_, SIGNAL(doubleClicked(HelperCell*)), this, SLOT(changePreviewWidth()));
connect(total_width_helper_cell_, SIGNAL(contextMenuTriggered(HelperCell *)),
this, SLOT(updateLastContextMenuCell(HelperCell *)));
connect(total_width_helper_cell_, SIGNAL(doubleClicked(HelperCell*)),
this, SLOT(changePreviewWidth()));
tbgrid_ -> addItem(total_width_helper_cell_, 0, COL_OFFSET, 1, col_count);
// we also initialize an extra helper cells that shows the preview width is
@@ -728,8 +763,10 @@ void TitleBlockTemplateView::addCells() {
current_col_cell -> setActions(columnsActions());
current_col_cell -> orientation = Qt::Horizontal;
current_col_cell -> index = i;
connect(current_col_cell, SIGNAL(contextMenuTriggered(HelperCell *)), this, SLOT(updateLastContextMenuCell(HelperCell *)));
connect(current_col_cell, SIGNAL(doubleClicked(HelperCell*)), this, SLOT(editColumn(HelperCell *)));
connect(current_col_cell, SIGNAL(contextMenuTriggered(HelperCell *)),
this, SLOT(updateLastContextMenuCell(HelperCell *)));
connect(current_col_cell, SIGNAL(doubleClicked(HelperCell*)),
this, SLOT(editColumn(HelperCell *)));
tbgrid_ -> addItem(current_col_cell, 1, COL_OFFSET + i, 1, 1);
}
@@ -742,8 +779,10 @@ void TitleBlockTemplateView::addCells() {
current_row_cell -> orientation = Qt::Vertical;
current_row_cell -> index = i;
current_row_cell -> setActions(rowsActions());
connect(current_row_cell, SIGNAL(contextMenuTriggered(HelperCell *)), this, SLOT(updateLastContextMenuCell(HelperCell *)));
connect(current_row_cell, SIGNAL(doubleClicked(HelperCell*)), this, SLOT(editRow(HelperCell *)));
connect(current_row_cell, SIGNAL(contextMenuTriggered(HelperCell *)),
this, SLOT(updateLastContextMenuCell(HelperCell *)));
connect(current_row_cell, SIGNAL(doubleClicked(HelperCell*)),
this, SLOT(editRow(HelperCell *)));
tbgrid_ -> addItem(current_row_cell, ROW_OFFSET + i, 0, 1, 1);
}
@@ -768,7 +807,8 @@ void TitleBlockTemplateView::addCells() {
/**
Refresh the regular cells.
*/
void TitleBlockTemplateView::refresh() {
void TitleBlockTemplateView::refresh()
{
int col_count = tbtemplate_ -> columnsCount();
int row_count = tbtemplate_ -> rowsCount();
if (row_count < 1 || col_count < 1) return;
@@ -787,7 +827,8 @@ void TitleBlockTemplateView::refresh() {
/**
Ask the user a new width for the preview
*/
void TitleBlockTemplateView::changePreviewWidth() {
void TitleBlockTemplateView::changePreviewWidth()
{
TitleBlockDimensionWidget dialog(false, this);
dialog.setWindowTitle(tr("Changer la largeur de l'aperçu"));
dialog.label() -> setText(tr("Largeur de l'aperçu :"));
@@ -800,7 +841,8 @@ void TitleBlockTemplateView::changePreviewWidth() {
/**
Fill the layout with empty cells where needed.
*/
void TitleBlockTemplateView::fillWithEmptyCells() {
void TitleBlockTemplateView::fillWithEmptyCells()
{
int col_count = tbtemplate_ -> columnsCount();
int row_count = tbtemplate_ -> rowsCount();
if (row_count < 1 || col_count < 1) return;
@@ -840,7 +882,8 @@ bool TitleBlockTemplateView::event(QEvent *event) {
void TitleBlockTemplateView::normalizeCells(
QList<TitleBlockCell> &cells,
int x,
int y) const {
int y) const
{
if (!cells.count()) return;
int min_row = cells.at(0).num_row;
@@ -896,14 +939,16 @@ void TitleBlockTemplateView::loadTemplate(TitleBlockTemplate *tbt) {
/**
@return the list of rows-specific actions.
*/
QList<QAction *> TitleBlockTemplateView::rowsActions() const {
QList<QAction *> TitleBlockTemplateView::rowsActions() const
{
return QList<QAction *>() << add_row_before_<< edit_row_dim_ << add_row_after_ << delete_row_;
}
/**
@return the list of columns-specific actions.
*/
QList<QAction *> TitleBlockTemplateView::columnsActions() const {
QList<QAction *> TitleBlockTemplateView::columnsActions() const
{
return QList<QAction *>() << add_column_before_ << edit_column_dim_ << add_column_after_ << delete_column_;
}
@@ -912,7 +957,8 @@ QList<QAction *> TitleBlockTemplateView::columnsActions() const {
after the rendered title block template has been "deeply" modified, e.g.
rows/columns have been added/modified or cells were merged/splitted.
*/
void TitleBlockTemplateView::updateLayout() {
void TitleBlockTemplateView::updateLayout()
{
// TODO we should try to update the grid instead of deleting-and-reloading it
loadTemplate(tbtemplate_);
}
@@ -921,7 +967,8 @@ void TitleBlockTemplateView::updateLayout() {
Update the displayed layout. Call this function when the dimensions of
rows changed.
*/
void TitleBlockTemplateView::rowsDimensionsChanged() {
void TitleBlockTemplateView::rowsDimensionsChanged()
{
applyRowsHeights();
}
@@ -929,7 +976,8 @@ void TitleBlockTemplateView::rowsDimensionsChanged() {
Update the displayed layout. Call this function when the dimensions of
columns changed.
*/
void TitleBlockTemplateView::columnsDimensionsChanged() {
void TitleBlockTemplateView::columnsDimensionsChanged()
{
applyColumnsWidths();
}
@@ -937,7 +985,8 @@ void TitleBlockTemplateView::columnsDimensionsChanged() {
Update the tooltip that displays the minimum and/or maximum width of the
template.
*/
void TitleBlockTemplateView::updateDisplayedMinMaxWidth() {
void TitleBlockTemplateView::updateDisplayedMinMaxWidth()
{
if (!tbtemplate_) return;
int min_width = tbtemplate_ -> minimumWidth();
int max_width = tbtemplate_ -> maximumWidth();
@@ -1004,7 +1053,8 @@ void TitleBlockTemplateView::setPreviewWidth(int width) {
/**
Update the label of the helper cell that indicates the preview width.
*/
void TitleBlockTemplateView::updateTotalWidthLabel() {
void TitleBlockTemplateView::updateTotalWidthLabel()
{
if (!total_width_helper_cell_) return;
total_width_helper_cell_ -> label = QString(
tr(
@@ -1030,7 +1080,8 @@ void TitleBlockTemplateView::requestGridModification(TitleBlockTemplateCommand *
@return the last index selected when triggering the context menu.
@see updateLastContextMenuCell
*/
int TitleBlockTemplateView::lastContextMenuCellIndex() const {
int TitleBlockTemplateView::lastContextMenuCellIndex() const
{
if (last_context_menu_cell_) {
return(last_context_menu_cell_ -> index);
}
@@ -1071,7 +1122,8 @@ void TitleBlockTemplateView::removeItem(QGraphicsLayoutItem *item) {
@return the corresponding TitleBlockTemplateCellsSet
*/
TitleBlockTemplateCellsSet TitleBlockTemplateView::makeCellsSetFromGraphicsItems(
const QList<QGraphicsItem *> &items) const {
const QList<QGraphicsItem *> &items) const
{
TitleBlockTemplateCellsSet set(this);
foreach (QGraphicsItem *item, items) {
if (TitleBlockTemplateVisualCell *cell_view = dynamic_cast<TitleBlockTemplateVisualCell *>(item)) {
@@ -1109,7 +1161,8 @@ void TitleBlockTemplateView::updateLastContextMenuCell(HelperCell *last_context_
/**
Adjusts the bounding rect of the scene.
*/
void TitleBlockTemplateView::adjustSceneRect() {
void TitleBlockTemplateView::adjustSceneRect()
{
QRectF old_scene_rect = scene() -> sceneRect();
// rectangle including everything on the scene

View File

@@ -100,9 +100,8 @@ class TitleBlockTemplateView : public QGraphicsView {
virtual qreal zoomFactor() const;
virtual void fillWithEmptyCells();
bool event(QEvent *) override;
virtual void normalizeCells(QList<TitleBlockCell> &,
int x = 0,
int y = 0) const;
virtual void normalizeCells(
QList<TitleBlockCell> &, int x = 0, int y = 0) const;
signals:
void selectedCellsChanged(QList<TitleBlockCell *>);

View File

@@ -37,7 +37,8 @@ TitleBlockTemplateVisualCell::TitleBlockTemplateVisualCell(QGraphicsItem *parent
/**
Destructor
*/
TitleBlockTemplateVisualCell::~TitleBlockTemplateVisualCell() {
TitleBlockTemplateVisualCell::~TitleBlockTemplateVisualCell()
{
}
/**
@@ -56,7 +57,8 @@ void TitleBlockTemplateVisualCell::setGeometry(const QRectF &g) {
@param constraint New value for the size hint
@return the size hint for \a which using the width or height of \a constraint
*/
QSizeF TitleBlockTemplateVisualCell::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const {
QSizeF TitleBlockTemplateVisualCell::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
Q_UNUSED(which);
return constraint;
}
@@ -64,7 +66,8 @@ QSizeF TitleBlockTemplateVisualCell::sizeHint(Qt::SizeHint which, const QSizeF &
/**
@return the bounding rect of this helper cell
*/
QRectF TitleBlockTemplateVisualCell::boundingRect() const {
QRectF TitleBlockTemplateVisualCell::boundingRect() const
{
return QRectF(QPointF(0,0), geometry().size());
}
@@ -74,7 +77,11 @@ QRectF TitleBlockTemplateVisualCell::boundingRect() const {
@param option Rendering options
@param widget QWidget being painted, if any
*/
void TitleBlockTemplateVisualCell::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
void TitleBlockTemplateVisualCell::paint(
QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
@@ -99,7 +106,9 @@ void TitleBlockTemplateVisualCell::paint(QPainter *painter, const QStyleOptionGr
@param tbt Parent title block template of the previewed cell
@param cell Previewed cell
*/
void TitleBlockTemplateVisualCell::setTemplateCell(TitleBlockTemplate *tbt, TitleBlockCell *cell) {
void TitleBlockTemplateVisualCell::setTemplateCell(
TitleBlockTemplate *tbt, TitleBlockCell *cell)
{
template_ = tbt;
cell_ = cell;
}
@@ -107,14 +116,16 @@ void TitleBlockTemplateVisualCell::setTemplateCell(TitleBlockTemplate *tbt, Titl
/**
@return the parent title block template of the previewed cell
*/
TitleBlockTemplate *TitleBlockTemplateVisualCell::titleBlockTemplate() const {
TitleBlockTemplate *TitleBlockTemplateVisualCell::titleBlockTemplate() const
{
return(template_);
}
/**
@return the previewed title block cell
*/
TitleBlockCell *TitleBlockTemplateVisualCell::cell() const {
TitleBlockCell *TitleBlockTemplateVisualCell::cell() const
{
return(cell_);
}
@@ -122,7 +133,8 @@ TitleBlockCell *TitleBlockTemplateVisualCell::cell() const {
@return the title block cell previewed by this object, plus the cells it
spans over, if any
*/
QSet<TitleBlockCell *> TitleBlockTemplateVisualCell::cells() const {
QSet<TitleBlockCell *> TitleBlockTemplateVisualCell::cells() const
{
QSet<TitleBlockCell *> set;
if (cell_) {
if (template_) {