QElectroTech  0.70
genericpanel.cpp
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 #include "genericpanel.h"
19 #include <QTreeWidgetItem>
20 #include "qetproject.h"
21 #include "diagram.h"
24 #include "qeticons.h"
25 #include "qetapp.h"
26 
31 GenericPanel::GenericPanel(QWidget *parent) :
32  QTreeWidget(parent),
33  first_activation_(true)
34 {
35  header() -> hide();
36  setIconSize(QSize(50, 50));
37 }
38 
43 }
44 
49  QTreeWidgetItem *current_qtwi = currentItem();
50  if (!current_qtwi) return(0);
51  return(current_qtwi -> type());
52 }
53 
54 QETProject *GenericPanel::projectForItem(QTreeWidgetItem *item) const {
55  if (item && item -> type() == QET::Project) {
56  return(valueForItem<QETProject *>(item));
57  }
58  return(nullptr);
59 
60 }
61 
65 Diagram *GenericPanel::diagramForItem(QTreeWidgetItem *item) const {
66  if (item && item -> type() == QET::Diagram) {
67  return(valueForItem<Diagram *>(item));
68  }
69  return(nullptr);
70 }
71 
76  if (item && item -> type() & QET::TitleBlockTemplatesCollectionItem) {
77  return(valueForItem<TitleBlockTemplateLocation>(item));
78  }
80 }
81 
86  return(projectForItem(currentItem()));
87 }
88 
93  return(diagramForItem(currentItem()));
94 }
95 
100  return(templateLocationForItem(currentItem()));
101 }
102 
106 QTreeWidgetItem *GenericPanel::addProject(QETProject *project, QTreeWidgetItem *parent_item, PanelOptions options) {
107  if (!project) return(nullptr);
108  bool creation_required;
109 
110  QTreeWidgetItem *project_qtwi = getItemForProject(project, &creation_required);
111  updateProjectItem(project_qtwi, project, options, creation_required);
112  reparent(project_qtwi, parent_item);
113  fillProjectItem(project_qtwi, project, options, creation_required);
114 
115  return(project_qtwi);
116 }
117 
123 QTreeWidgetItem *GenericPanel::itemForProject(QETProject *project) {
124  if (!project) return(nullptr);
125  return(projects_.value(project, nullptr));
126 }
127 
136 QTreeWidgetItem *GenericPanel::getItemForProject(QETProject *project, bool *created) {
137  if (!project) return(nullptr);
138 
139  QTreeWidgetItem *project_qtwi = projects_.value(project, nullptr);
140  if (project_qtwi) {
141  if (created) *created = false;
142  return(project_qtwi);
143  }
144 
145  project_qtwi = makeItem(QET::Project);
146  if (created) *created = true;
147  return(project_qtwi);
148 }
149 
153 QTreeWidgetItem *GenericPanel::updateProjectItem(QTreeWidgetItem *project_qtwi, QETProject *project, PanelOptions options, bool freshly_created) {
154  Q_UNUSED(options)
155  if (!project_qtwi || !project) return(nullptr);
156 
157  if (freshly_created) {
158  project_qtwi -> setData(0, GenericPanel::Item, qVariantFromValue(project));
159  projects_.insert(project, project_qtwi);
160 
161  connect(
162  project, SIGNAL(projectInformationsChanged(QETProject *)),
163  this, SLOT (projectInformationsChanged(QETProject *))
164  );
165  connect(
166  project, SIGNAL(readOnlyChanged(QETProject *, bool)),
167  this, SLOT (projectInformationsChanged(QETProject *))
168  );
169  }
170 
171  // text
172  project_qtwi -> setText(0, project -> pathNameTitle());
173  // tooltip
174  QString final_tooltip = QDir::toNativeSeparators(project -> filePath());
175  if (final_tooltip.isEmpty()) {
176  final_tooltip = tr(
177  "Pas de fichier",
178  "tooltip for a file-less project in the element panel"
179  );
180  }
181  project_qtwi -> setToolTip(0, final_tooltip);
182  QString project_whatsthis = tr("Ceci est un projet QElectroTech, c'est-à-dire un fichier d'extension .qet regroupant plusieurs folios. Il embarque également les éléments et modèles de cartouches utilisés dans ces folios.", "\"What's this\" tip");
183  project_qtwi -> setWhatsThis(0, project_whatsthis);
184  return(updateItem(project_qtwi, options, freshly_created));
185 }
186 
190 QTreeWidgetItem *GenericPanel::fillProjectItem(QTreeWidgetItem *project_qtwi, QETProject *project, PanelOptions options, bool freshly_created) {
191  if (!project_qtwi || !project) return(nullptr);
192 
193 
194  if (options & AddChildDiagrams) {
195  if (freshly_created) {
196  connect(
197  project, SIGNAL(diagramAdded(QETProject *, Diagram *)),
198  this, SLOT (diagramAdded(QETProject *, Diagram *))
199  );
200  connect(
201  project, SIGNAL(diagramRemoved(QETProject *, Diagram *)),
202  this, SLOT (diagramRemoved(QETProject *, Diagram *))
203  );
204  connect(
205  project, SIGNAL(projectDiagramsOrderChanged(QETProject *, int, int)),
206  this, SLOT (projectDiagramsOrderChanged(QETProject *, int, int))
207  );
208  } else {
209  // remove diagrams unknown to the project (presumably removed)
210  removeObsoleteItems(project -> diagrams(), project_qtwi, QET::Diagram, false);
211  }
212  int index = 0;
213  foreach (Diagram *diagram, project -> diagrams()) {
214  QTreeWidgetItem *diagram_qtwi = addDiagram(diagram, nullptr, options);
215  project_qtwi -> insertChild(index, diagram_qtwi);
216  ++ index;
217  }
218  }
219 
220  if (options & AddChildTemplatesCollection) {
221  if (freshly_created) {
222  connect(
223  project, SIGNAL(diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &)),
224  this, SLOT (diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &))
225  );
226  }
228  project -> embeddedTitleBlockTemplatesCollection(),
229  project_qtwi,
230  options
231  );
232  }
233 
234  return(fillItem(project_qtwi, options, freshly_created));
235 }
236 
240 QTreeWidgetItem *GenericPanel::addDiagram(Diagram *diagram, QTreeWidgetItem *parent_item, PanelOptions options) {
241  Q_UNUSED(options)
242  if (!diagram) return(nullptr);
243 
244  bool creation_required;
245 
246  QTreeWidgetItem *diagram_qtwi = getItemForDiagram(diagram, &creation_required);
247  updateDiagramItem(diagram_qtwi, diagram, options, creation_required);
248  reparent(diagram_qtwi, parent_item);
249  fillDiagramItem(diagram_qtwi, diagram, options, creation_required);
250 
251  return(diagram_qtwi);
252 }
253 
257 QTreeWidgetItem *GenericPanel::getItemForDiagram(Diagram *diagram, bool *created) {
258  if (!diagram) return(nullptr);
259 
260  QTreeWidgetItem *diagram_qtwi = diagrams_.value(diagram, nullptr);
261  if (diagram_qtwi) {
262  if (created) *created = false;
263  return(diagram_qtwi);
264  }
265 
266  diagram_qtwi = makeItem(QET::Diagram);
267  if (created) *created = true;
268  return(diagram_qtwi);
269 }
270 
274 QTreeWidgetItem *GenericPanel::updateDiagramItem(QTreeWidgetItem *diagram_qtwi, Diagram *diagram, PanelOptions options, bool freshly_created) {
275  Q_UNUSED(options)
276  if (!diagram || !diagram_qtwi) return(nullptr);
277  QSettings settings;
278 
279  QString displayed_title = diagram -> title();
280  if (displayed_title.isEmpty())
281  {
282  displayed_title = tr("Folio sans titre", "Fallback label when a diagram has no title");
283  }
284 
285  if (settings.value("genericpanel/folio", true).toBool())
286  {
287  QString displayed_label = diagram ->border_and_titleblock.finalfolio();
288  int diagram_folio_idx = diagram -> folioIndex();
289  if (diagram_folio_idx != -1)
290  {
291  displayed_label = QString(
292  tr(
293  "%1 - %2",
294  "label displayed for a diagram in the panel ; %1 is the folio index, %2 is the diagram title"
295  )
296  ).arg(displayed_label).arg(displayed_title);
297  diagram_qtwi -> setText(0, displayed_label);
298  }
299 
300  }
301  else
302  {
303  QString displayed_label;
304  int diagram_folio_idx = diagram -> folioIndex();
305  if (diagram_folio_idx != -1)
306  {
307  displayed_label = QString(
308  tr(
309  "%1 - %2",
310  "label displayed for a diagram in the panel ; %1 is the folio index, %2 is the diagram title"
311  )
312  ).arg(diagram_folio_idx + 1).arg(displayed_title);
313  }
314 
315  diagram_qtwi -> setText(0, displayed_label);
316 
317  }
318  if (freshly_created)
319  {
320  diagram_qtwi -> setData(0, GenericPanel::Item, qVariantFromValue(diagram));
321  diagrams_.insert(diagram, diagram_qtwi);
322 
324  }
325 
326  return(updateItem(diagram_qtwi, options, freshly_created));
327 }
328 
329 
330 
334 QTreeWidgetItem *GenericPanel::fillDiagramItem(QTreeWidgetItem *diagram_qtwi, Diagram *diagram, PanelOptions options, bool freshly_created) {
335  Q_UNUSED(diagram)
336  Q_UNUSED(options)
337  Q_UNUSED(freshly_created)
338  return(fillItem(diagram_qtwi, options, freshly_created));
339 }
340 
344 QTreeWidgetItem *GenericPanel::addTemplatesCollection(TitleBlockTemplatesCollection *tbt_collection, QTreeWidgetItem *parent_item, PanelOptions options) {
345  if (!tbt_collection) return(nullptr);
346  bool creation_required;
347 
348  QTreeWidgetItem *tbt_collection_qtwi = getItemForTemplatesCollection(tbt_collection, &creation_required);
349  updateTemplatesCollectionItem(tbt_collection_qtwi, tbt_collection, options, creation_required);
350  reparent(tbt_collection_qtwi, parent_item);
351  fillTemplatesCollectionItem(tbt_collection_qtwi, tbt_collection, options, creation_required);
352 
353  return(tbt_collection_qtwi);
354 }
355 
360  if (!tbt_collection) return(nullptr);
361  return(tb_templates_.value(tbt_collection -> location(), nullptr));
362 }
363 
367 QTreeWidgetItem *GenericPanel::getItemForTemplatesCollection(TitleBlockTemplatesCollection *tbt_collection, bool *created) {
368  if (!tbt_collection) return(nullptr);
369  QTreeWidgetItem *tbt_collection_item = tb_templates_.value(tbt_collection -> location(), nullptr);
370  if (tbt_collection_item) {
371  if (created) *created = false;
372  return(tbt_collection_item);
373  }
374 
375  tbt_collection_item = makeItem(QET::TitleBlockTemplatesCollection);
376  if (created) *created = true;
377  return(tbt_collection_item);
378 }
379 
383 QTreeWidgetItem *GenericPanel::updateTemplatesCollectionItem(QTreeWidgetItem *tbt_collection_qtwi, TitleBlockTemplatesCollection *tbt_collection, PanelOptions options, bool freshly_created) {
384  Q_UNUSED(options)
385  QString label = tbt_collection -> title();
386  if (label.isEmpty()) label = tr("Modèles de cartouche");
387 
388  tbt_collection_qtwi -> setText(0, label);
389  tbt_collection_qtwi -> setToolTip(0, tbt_collection -> location().toString());
390 
391  if (freshly_created) {
392  tbt_collection_qtwi -> setData(0, GenericPanel::Item, qVariantFromValue(tbt_collection -> location()));
393  tb_templates_.insert(tbt_collection -> location(), tbt_collection_qtwi);
394  }
395 
396  return(updateItem(tbt_collection_qtwi, options, freshly_created));
397 }
398 
402 QTreeWidgetItem *GenericPanel::fillTemplatesCollectionItem(QTreeWidgetItem *tbt_collection_qtwi, TitleBlockTemplatesCollection *tbt_collection, PanelOptions options, bool freshly_created) {
403  if (!tbt_collection_qtwi || !tbt_collection) return(tbt_collection_qtwi);
404 
405  if (options & AddChildTemplates) {
406  if (freshly_created) {
407  connect(
408  tbt_collection, SIGNAL(changed(TitleBlockTemplatesCollection*,QString)),
409  this, SLOT(templatesCollectionChanged(TitleBlockTemplatesCollection*, const QString &))
410  );
411  if (QETProject *project = tbt_collection -> parentProject()) {
412  connect(
413  project, SIGNAL(diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &)),
414  this, SLOT (templatesCollectionChanged(TitleBlockTemplatesCollection *, const QString &))
415  );
416  }
417  } else {
418  // remove templates unknown to the collection (presumably removed)
419  removeObsoleteItems(tbt_collection -> templatesLocations(), tbt_collection_qtwi, QET::TitleBlockTemplate, false);
420  }
421 
422  int index = 0;
423  foreach (QString template_name, tbt_collection -> templates()) {
424  QTreeWidgetItem *template_item = addTemplate(tbt_collection -> location(template_name), nullptr, options);
425  tbt_collection_qtwi -> insertChild(index ++, template_item);
426  }
427  }
428 
429  return(fillItem(tbt_collection_qtwi, options, freshly_created));
430 }
431 
435 QTreeWidgetItem *GenericPanel::addTemplate(const TitleBlockTemplateLocation &tb_template, QTreeWidgetItem *parent_item, PanelOptions options) {
436  if (!tb_template.isValid()) return(nullptr);
437  bool creation_required;
438 
439  QTreeWidgetItem *tb_template_qtwi = getItemForTemplate(tb_template, &creation_required);
440  updateTemplateItem(tb_template_qtwi, tb_template, options, creation_required);
441  reparent(tb_template_qtwi, parent_item);
442  fillTemplateItem(tb_template_qtwi, tb_template, options, creation_required);
443 
444  return(tb_template_qtwi);
445 }
446 
450 QTreeWidgetItem *GenericPanel::getItemForTemplate(const TitleBlockTemplateLocation &tb_template, bool *created) {
451  if (!tb_template.isValid()) return(nullptr);
452 
453  QTreeWidgetItem *tb_template_qtwi = tb_templates_.value(tb_template, nullptr);
454  if (tb_template_qtwi) {
455  if (created) *created = false;
456  return(tb_template_qtwi);
457  }
458 
459  tb_template_qtwi = makeItem(QET::TitleBlockTemplate);
460  if (created) *created = true;
461  return(tb_template_qtwi);
462 }
463 
467 QTreeWidgetItem *GenericPanel::updateTemplateItem(QTreeWidgetItem *tb_template_qtwi, const TitleBlockTemplateLocation &tb_template, PanelOptions options, bool freshly_created) {
468  Q_UNUSED(options)
469  tb_template_qtwi -> setText(0, tr("Modèle \"%1\"", "used to display a title block template").arg(tb_template.name()));
470  QString tbt_whatsthis = tr(
471  "Ceci est un modèle de cartouche, qui peut être appliqué à un folio.",
472  "\"What's this\" tip"
473  );
474  tb_template_qtwi -> setWhatsThis(0, tbt_whatsthis);
475  // note the following lines are technically marking the template as used
476  tb_template_qtwi -> setToolTip(0, tb_template.toString());
477  tb_template_qtwi -> setBackground(0, QBrush());
478 
479  // special action for templates that belong to a project
480  if (QETProject *tbt_project = tb_template.parentProject()) {
481  // display unused templates using a red background
482  if (!tbt_project -> usesTitleBlockTemplate(tb_template)) {
483  markItemAsUnused(tb_template_qtwi);
484  }
485  }
486 
487  if (freshly_created) {
488  tb_template_qtwi -> setData(0, GenericPanel::Item, qVariantFromValue(tb_template));
489  tb_templates_.insert(tb_template, tb_template_qtwi);
490  }
491  return(updateItem(tb_template_qtwi, options, freshly_created));
492 }
493 
497 QTreeWidgetItem *GenericPanel::fillTemplateItem(QTreeWidgetItem *tb_template_qtwi, const TitleBlockTemplateLocation &tb_template, PanelOptions options, bool freshly_created) {
498  Q_UNUSED(tb_template)
499  Q_UNUSED(options)
500  Q_UNUSED(freshly_created)
501  return(fillItem(tb_template_qtwi, options, freshly_created));
502 }
503 
509 QTreeWidgetItem *GenericPanel::updateItem(QTreeWidgetItem *qtwi, PanelOptions options, bool freshly_created) {
510  Q_UNUSED(qtwi);
511  Q_UNUSED(options);
512  Q_UNUSED(freshly_created);
513  QApplication::processEvents();
514  return(qtwi);
515 }
516 
522 QTreeWidgetItem *GenericPanel::fillItem(QTreeWidgetItem *qtwi, PanelOptions options, bool freshly_created) {
523  Q_UNUSED(qtwi);
524  Q_UNUSED(options);
525  Q_UNUSED(freshly_created);
526  return(qtwi);
527 }
528 
533  addProject(project, nullptr, nullptr);
534  emit(panelContentChanged());
535 }
536 
541  Q_UNUSED(diagram)
542  addProject(project, nullptr, GenericPanel::AddChildDiagrams);
543  emit(panelContentChanged());
544 }
545 
550  Q_UNUSED(diagram)
551  addProject(project, nullptr, GenericPanel::AddChildDiagrams);
552  emit(panelContentChanged());
553 }
554 
562 {
563  // get the item representing the provided project
564  QTreeWidgetItem *qtwi_project = itemForProject(project);
565  if (!qtwi_project) return;
566 
567  // get the item representing the moved diagram
568  QTreeWidgetItem *moved_qtwi_diagram = qtwi_project -> child(from);
569  if (!moved_qtwi_diagram) return;
570 
571  // remove the QTWI then insert it back at the adequate location
572  bool was_selected = moved_qtwi_diagram -> isSelected();
573  qtwi_project -> removeChild (moved_qtwi_diagram);
574  qtwi_project -> insertChild (to, moved_qtwi_diagram);
575 
576  // update the QTWI labels because they may display the folio index
577  for (int i = qMin(from, to); i < qMax(from, to) + 1; i++)
578  {
579  QTreeWidgetItem *qtwi_diagram = qtwi_project -> child(i);
580  if (!qtwi_diagram) continue;
581 
582  Diagram *diagram = valueForItem<Diagram *>(qtwi_diagram);
583  if (diagram)
584  updateDiagramItem(qtwi_diagram, diagram);
585  }
586 
587  if (was_selected)
588  setCurrentItem(moved_qtwi_diagram);
589 
590  emit(panelContentChanged());
591 }
592 
596 void GenericPanel::diagramTitleChanged(Diagram *diagram, const QString &title) {
597  Q_UNUSED(title)
598  GenericPanel::addDiagram(diagram);
599  emit(panelContentChanged());
600 }
601 
606 void GenericPanel::templatesCollectionChanged(TitleBlockTemplatesCollection*collection, const QString &template_name) {
607  Q_UNUSED(template_name)
608  addTemplatesCollection(collection);
609  emit(panelContentChanged());
610 }
611 
615 void GenericPanel::diagramUsedTemplate(TitleBlockTemplatesCollection *collection, const QString &name) {
616  Q_UNUSED(collection)
617  Q_UNUSED(name)
618  addTemplatesCollection(collection);
619  emit(panelContentChanged());
620 }
621 
626  switch(type) {
628  case QET::Element: return("element");
630  case QET::ElementsCategory: return("elements category");
631  case QET::ElementsCollection: return("elements collection");
633  case QET::TitleBlockTemplate: return("title block template");
634  case QET::TitleBlockTemplatesCollection: return("title block templates collection");
635  case QET::Diagram: return("diagram");
636  case QET::Project: return("project");
637  default: return(QString());
638  }
639  return(QString());
640 }
641 
647  if (type & QET::ElementsContainer) {
648  return(QET::Icons::Folder);
649  } else if (type & QET::TitleBlockTemplatesCollectionItem) {
650  return(QIcon(QET::Icons::TitleBlock.pixmap(QSize(16, 16))));
651  } else if (type == QET::Diagram) {
652  return(QET::Icons::Diagram);
653  } else if (type == QET::Project) {
654  return(QIcon(QET::Icons::ProjectFileGP.pixmap(QSize(16, 16))));
655  }
656  return(QIcon());
657 }
658 
667 QTreeWidgetItem *GenericPanel::makeItem(QET::ItemType type, QTreeWidgetItem *parent, const QString &label, const QIcon &icon) {
668  QTreeWidgetItem *qtwi = new QTreeWidgetItem(parent, type);
669  qtwi -> setText(0, label.isEmpty() ? defaultText(type) : label);
670  qtwi -> setIcon(0, icon.isNull() ? defaultIcon(type) : icon);
671  return(qtwi);
672 }
673 
680 void GenericPanel::deleteItem(QTreeWidgetItem *item, bool deleted_on_cascade) {
681  Q_UNUSED(deleted_on_cascade)
682  // recursively delete child items first
683  for (int i = item -> childCount() - 1 ; i >= 0 ; -- i) {
684  deleteItem(item -> child(i), true);
685  }
686 
687  // delete the item itself
688  unregisterItem(item);
689  delete item;
690 }
691 
696 void GenericPanel::markItemAsUnused(QTreeWidgetItem *qtwi) {
697  QLinearGradient t(0, 0, 200, 0);
698  t.setColorAt(0, QColor("#ffc0c0"));
699  t.setColorAt(1, QColor("#ffffff"));
700  qtwi -> setBackground(0, QBrush(t));
701  qtwi -> setToolTip(0, QString(tr("%1 [non utilisé dans le projet]")).arg(qtwi -> toolTip(0)));
702 }
703 
707 void GenericPanel::reparent(QTreeWidgetItem *item, QTreeWidgetItem *parent) {
708  if (parent && item -> parent() != parent) {
709  parent -> addChild(item);
710  }
711 }
712 
719 QList<QTreeWidgetItem *> GenericPanel::childItems(QTreeWidgetItem *item, QET::ItemType type, bool recursive) const {
720  QList<QTreeWidgetItem *> items;
721  if (!item) return(items);
722  for (int i = 0 ; i < item -> childCount() ; ++ i) {
723  QTreeWidgetItem *current_item = item -> child(i);
724  if (!current_item) continue;
725  if (current_item -> type() == type) {
726  items << current_item;
727  }
728  if (recursive) {
729  items << childItems(current_item, type, true);
730  }
731  }
732  return(items);
733 }
734 
744 template<typename T>
745 void GenericPanel::removeObsoleteItems(const QList<T> &expected_items, QTreeWidgetItem *item, QET::ItemType type, bool recursive) {
746  // remove items not found in expected_items
747  foreach (QTreeWidgetItem *child_item, childItems(item, type, recursive)) {
748  T child_value = valueForItem<T>(child_item);
749  if (!expected_items.contains(child_value)) {
750  deleteItem(child_item);
751  }
752  }
753 }
754 
758 template<typename T>
759 T GenericPanel::valueForItem(QTreeWidgetItem *item) const {
760  return item -> data(0, GenericPanel::Item).value<T>();
761 }
763 GenericPanel::valueForItem(QTreeWidgetItem *item) const;
764 template ElementsLocation GenericPanel::valueForItem(QTreeWidgetItem*)
765 const;
766 template QETProject* GenericPanel::valueForItem(QTreeWidgetItem*)
767 const;
768 template Diagram* GenericPanel::valueForItem(QTreeWidgetItem*)
769 const;
773 void GenericPanel::unregisterItem(QTreeWidgetItem *item) {
774  if (!item) return;
775 
776  int type = item ->type();
778  tb_templates_.remove(valueForItem<TitleBlockTemplateLocation>(item));
779  } else if (type == QET::Diagram) {
780  diagrams_.remove(valueForItem<Diagram *>(item));
781  } else if (type == QET::Project) {
782  projects_.remove(valueForItem<QETProject *>(item));
783  }
784 }
785 
790 bool GenericPanel::event(QEvent *event) {
791  if (first_activation_) {
792  if (event -> type() == QEvent::WindowActivate || event -> type() == QEvent::Show) {
793  QTimer::singleShot(250, this, SLOT(emitFirstActivated()));
794  first_activation_ = false;
795  }
796  }
797  return(QTreeWidget::event(event));
798 }
799 
804  emit(firstActivated());
805 }
virtual QTreeWidgetItem * fillTemplateItem(QTreeWidgetItem *, const TitleBlockTemplateLocation &, PanelOptions=AddAllChild, bool=false)
virtual void templatesCollectionChanged(TitleBlockTemplatesCollection *, const QString &)
void panelContentChanged()
virtual QTreeWidgetItem * updateProjectItem(QTreeWidgetItem *, QETProject *, PanelOptions=AddAllChild, bool=false)
virtual QTreeWidgetItem * addProject(QETProject *, QTreeWidgetItem *=nullptr, PanelOptions=AddAllChild)
virtual QTreeWidgetItem * itemForProject(QETProject *)
virtual void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &)
virtual void projectInformationsChanged(QETProject *)
GenericPanel(QWidget *=nullptr)
void emitFirstActivated()
virtual int currentItemType()
virtual TitleBlockTemplateLocation templateLocationForItem(QTreeWidgetItem *) const
virtual QTreeWidgetItem * fillProjectItem(QTreeWidgetItem *, QETProject *, PanelOptions=AddAllChild, bool=false)
QIcon Folder
Definition: qeticons.cpp:94
virtual QTreeWidgetItem * updateTemplatesCollectionItem(QTreeWidgetItem *, TitleBlockTemplatesCollection *, PanelOptions=AddAllChild, bool=false)
virtual void deleteItem(QTreeWidgetItem *, bool=false)
virtual QTreeWidgetItem * addTemplate(const TitleBlockTemplateLocation &, QTreeWidgetItem *=nullptr, PanelOptions=AddAllChild)
virtual void diagramAdded(QETProject *, Diagram *)
virtual QTreeWidgetItem * fillDiagramItem(QTreeWidgetItem *, Diagram *, PanelOptions=AddAllChild, bool=false)
QString finalfolio() const
QHash< QETProject *, QTreeWidgetItem * > projects_
Allow quick retrieval of the item representing a given project.
Definition: genericpanel.h:146
~GenericPanel() override
virtual QTreeWidgetItem * getItemForTemplatesCollection(TitleBlockTemplatesCollection *, bool *=nullptr)
virtual QIcon defaultIcon(QET::ItemType)
virtual TitleBlockTemplateLocation selectedTemplateLocation() const
QIcon TitleBlock
Definition: qeticons.cpp:165
virtual QTreeWidgetItem * getItemForProject(QETProject *, bool *=nullptr)
virtual void diagramTitleChanged(Diagram *, const QString &)
bool first_activation_
boolean used to track the first time this widget is activated/shown
Definition: genericpanel.h:145
virtual QTreeWidgetItem * addTemplatesCollection(TitleBlockTemplatesCollection *, QTreeWidgetItem *=nullptr, PanelOptions=AddAllChild)
virtual QString defaultText(QET::ItemType)
bool event(QEvent *) override
virtual QTreeWidgetItem * makeItem(QET::ItemType, QTreeWidgetItem *=nullptr, const QString &=QString(), const QIcon &=QIcon())
virtual QETProject * projectForItem(QTreeWidgetItem *) const
QList< QTreeWidgetItem * > childItems(QTreeWidgetItem *, QET::ItemType, bool=false) const
virtual QTreeWidgetItem * getItemForDiagram(Diagram *, bool *=nullptr)
QIcon tr
Definition: qeticons.cpp:204
virtual Diagram * diagramForItem(QTreeWidgetItem *) const
virtual QTreeWidgetItem * updateTemplateItem(QTreeWidgetItem *, const TitleBlockTemplateLocation &, PanelOptions=AddAllChild, bool=false)
virtual void reparent(QTreeWidgetItem *, QTreeWidgetItem *)
QIcon ProjectFileGP
Definition: qeticons.cpp:148
virtual QTreeWidgetItem * updateDiagramItem(QTreeWidgetItem *, Diagram *, PanelOptions=AddAllChild, bool=false)
virtual QTreeWidgetItem * addDiagram(Diagram *, QTreeWidgetItem *=nullptr, PanelOptions=AddAllChild)
virtual void diagramRemoved(QETProject *, Diagram *)
static int header
QHash< TitleBlockTemplateLocation, QTreeWidgetItem * > tb_templates_
Allow quick retrieval of the item representing a title block template.
Definition: genericpanel.h:148
virtual QTreeWidgetItem * updateItem(QTreeWidgetItem *, PanelOptions=AddAllChild, bool=false)
virtual Diagram * selectedDiagram() const
bool firstActivated()
virtual void projectDiagramsOrderChanged(QETProject *, int, int)
GenericPanel::projectDiagramsOrderChanged.
QETProject * parentProject() const
QHash< Diagram *, QTreeWidgetItem * > diagrams_
Allow quick retrieval of the item representing a given diagram.
Definition: genericpanel.h:147
ItemType
Definition: qet.h:97
virtual QTreeWidgetItem * fillItem(QTreeWidgetItem *, PanelOptions=AddAllChild, bool=false)
void diagramTitleChanged(Diagram *, const QString &)
virtual QTreeWidgetItem * getItemForTemplate(const TitleBlockTemplateLocation &, bool *=nullptr)
virtual QTreeWidgetItem * fillTemplatesCollectionItem(QTreeWidgetItem *, TitleBlockTemplatesCollection *, PanelOptions=AddAllChild, bool=false)
virtual void markItemAsUnused(QTreeWidgetItem *)
T valueForItem(QTreeWidgetItem *) const
BorderTitleBlock border_and_titleblock
Diagram dimensions and title block.
Definition: diagram.h:74
void removeObsoleteItems(const QList< T > &, QTreeWidgetItem *, QET::ItemType, bool)
virtual QTreeWidgetItem * itemForTemplatesCollection(TitleBlockTemplatesCollection *)
QIcon Diagram
Definition: qeticons.cpp:43
void unregisterItem(QTreeWidgetItem *)
virtual QETProject * selectedProject() const