QElectroTech  0.70
templateview.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef TITLEBLOCK_SLASH_TEMPLATE_VIEW_H
19 #define TITLEBLOCK_SLASH_TEMPLATE_VIEW_H
20 #include <QGraphicsView>
21 #include "titleblocktemplate.h"
22 class HelperCell;
23 class SplittedHelperCell;
26 
32 class TitleBlockTemplateView : public QGraphicsView {
33  Q_OBJECT
34 
35  // constructors, destructor
36  public:
37  TitleBlockTemplateView(QWidget * = nullptr);
38  TitleBlockTemplateView(QGraphicsScene *, QWidget * = nullptr);
39  ~TitleBlockTemplateView() override;
40  private:
42 
43  // methods and slots
44  public:
46  virtual QList<TitleBlockCell *> selectedCells() const;
48  virtual TitleBlockTemplateCellsSet cells(const QRectF &) const;
49  virtual void analyzeSelectedCells(bool *, bool *, int *);
50  virtual QSizeF templateSize() const;
51  virtual qreal templateWidth() const;
52  virtual qreal templateHeight() const;
53 
54  public slots:
56  void selectionChanged();
57  void zoomIn();
58  void zoomOut();
59  void zoomFit();
60  void zoomReset();
61  QList<TitleBlockCell *> cut();
62  QList<TitleBlockCell *> copy();
63  bool mayPaste();
64  QList<TitleBlockCell> pastedCells();
65  void paste();
66  void addColumnAtEnd();
67  void addRowAtEnd();
68  void addColumnBefore();
69  void addRowBefore();
70  void addColumnAfter();
71  void addRowAfter();
72  void editColumn(HelperCell * = nullptr);
73  void editRow(HelperCell * = nullptr);
74  void deleteColumn();
75  void deleteRow();
76  void mergeSelectedCells();
77  void splitSelectedCell();
78  void refresh();
79  void changePreviewWidth();
80  void setPreviewWidth(int);
81  void updateLayout();
82  void rowsDimensionsChanged();
85  void setReadOnly(bool);
86 
87  protected slots:
88  virtual void applyColumnsWidths(bool = true);
89  virtual void applyRowsHeights(bool = true);
90  virtual void updateRowsHelperCells();
91  virtual void updateColumnsHelperCells();
92 
93  protected:
94  void drawBackground(QPainter *, const QRectF &) override;
95  virtual void addCells();
96  virtual void loadTemplate(TitleBlockTemplate *);
97  virtual void init();
98  void wheelEvent(QWheelEvent *) override;
99  virtual qreal zoomFactor() const;
100  virtual void fillWithEmptyCells();
101  bool event(QEvent *) override;
102  virtual void normalizeCells(QList<TitleBlockCell> &, int x = 0, int y = 0) const;
103 
104  signals:
105  void selectedCellsChanged(QList<TitleBlockCell *>);
107  void previewWidthChanged(int, int);
108 
109  private:
110  QList<QAction *> rowsActions() const;
111  QList<QAction *> columnsActions() const;
112  void updateTotalWidthLabel();
114  int lastContextMenuCellIndex() const;
115  int indexOf(QGraphicsLayoutItem *);
116  void removeItem(QGraphicsLayoutItem *);
117  TitleBlockTemplateCellsSet makeCellsSetFromGraphicsItems(const QList<QGraphicsItem *> &) const;
118  QString makePrettyToolTip(const QString &);
119 
120  private slots:
122  void adjustSceneRect();
123 
124  // attributes
125  private:
127  QGraphicsGridLayout *tbgrid_;
128  QGraphicsWidget *form_;
141  bool read_only_;
142 };
143 #endif
virtual qreal templateHeight() const
void updateLastContextMenuCell(HelperCell *)
~TitleBlockTemplateView() override
virtual qreal templateWidth() const
virtual void normalizeCells(QList< TitleBlockCell > &, int x=0, int y=0) const
bool read_only_
Boolean stating whether this view allows template edition.
Definition: templateview.h:141
int indexOf(QGraphicsLayoutItem *)
QString makePrettyToolTip(const QString &)
HelperCell * last_context_menu_cell_
Definition: templateview.h:137
virtual TitleBlockTemplateCellsSet cells(const QRectF &) const
virtual void fillWithEmptyCells()
void selectedCellsChanged(QList< TitleBlockCell *>)
QAction * add_column_before_
Definition: templateview.h:132
HelperCell * extra_cells_width_helper_cell_
Definition: templateview.h:131
TitleBlockTemplate * tbtemplate_
Definition: templateview.h:126
SplittedHelperCell * total_width_helper_cell_
Definition: templateview.h:130
void previewWidthChanged(int, int)
TitleBlockTemplateView(QWidget *=nullptr)
virtual void updateRowsHelperCells()
void setTitleBlockTemplate(TitleBlockTemplate *)
virtual void applyRowsHeights(bool=true)
virtual void analyzeSelectedCells(bool *, bool *, int *)
virtual void updateColumnsHelperCells()
virtual void applyColumnsWidths(bool=true)
TitleBlockTemplateCellsSet makeCellsSetFromGraphicsItems(const QList< QGraphicsItem *> &) const
void drawBackground(QPainter *, const QRectF &) override
void wheelEvent(QWheelEvent *) override
int lastContextMenuCellIndex() const
void gridModificationRequested(TitleBlockTemplateCommand *)
TitleBlockTemplate * titleBlockTemplate() const
void removeItem(QGraphicsLayoutItem *)
QList< TitleBlockCell * > cut()
QAction * change_preview_width_
Definition: templateview.h:136
virtual qreal zoomFactor() const
QGraphicsGridLayout * tbgrid_
Definition: templateview.h:127
void editColumn(HelperCell *=nullptr)
QList< QAction * > columnsActions() const
QList< TitleBlockCell * > copy()
virtual void loadTemplate(TitleBlockTemplate *)
virtual TitleBlockTemplateCellsSet selectedCellsSet() const
QGraphicsWidget * form_
Definition: templateview.h:128
virtual QList< TitleBlockCell * > selectedCells() const
bool first_activation_
Boolean used to detect the first display of this widget.
Definition: templateview.h:140
void editRow(HelperCell *=nullptr)
virtual QSizeF templateSize() const
QList< QAction * > rowsActions() const
void requestGridModification(TitleBlockTemplateCommand *)
bool event(QEvent *) override
QList< TitleBlockCell > pastedCells()
virtual void addCells()