[qet] qet/qet: [4918] Project view : prepend the positon number or the folio label ( acording the configuration of qet) in the title of each diagram view tabs. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] qet/qet: [4918] Project view : prepend the positon number or the folio label ( acording the configuration of qet) in the title of each diagram view tabs.
- From: subversion@xxxxxxxxxxxxx
- Date: Sat, 18 Feb 2017 14:30:39 +0100
Revision: 4918
Author: blacksun
Date: 2017-02-18 14:30:38 +0100 (Sat, 18 Feb 2017)
Log Message:
-----------
Project view : prepend the positon number or the folio label (acording the configuration of qet) in the title of each diagram view tabs.
Modified Paths:
--------------
trunk/sources/projectview.cpp
trunk/sources/projectview.h
trunk/sources/qetdiagrameditor.cpp
trunk/sources/qetmainwindow.cpp
Modified: trunk/sources/projectview.cpp
===================================================================
--- trunk/sources/projectview.cpp 2017-02-16 14:10:30 UTC (rev 4917)
+++ trunk/sources/projectview.cpp 2017-02-18 13:30:38 UTC (rev 4918)
@@ -32,6 +32,7 @@
#include "diagramfoliolist.h"
#include "projectpropertiesdialog.h"
#include "xmlelementcollection.h"
+#include "autoNum/assignvariables.h"
/**
Constructeur
@@ -55,8 +56,8 @@
*/
ProjectView::~ProjectView() {
// qDebug() << "Suppression du ProjectView" << ((void *)this);
- foreach(int id, diagram_ids_.keys()) {
- DiagramView *diagram_view = diagram_ids_.take(id);
+ foreach(int id, m_diagram_ids.keys()) {
+ DiagramView *diagram_view = m_diagram_ids.take(id);
delete diagram_view;
}
}
@@ -88,7 +89,7 @@
/**
@return la liste des schemas ouverts dans le projet
*/
-QList<DiagramView *> ProjectView::diagrams() const {
+QList<DiagramView *> ProjectView::diagram_views() const {
return(m_diagram_view_list);
}
@@ -123,7 +124,7 @@
int current_tab_index = m_tab -> currentIndex();
if (current_tab_index == -1)
return nullptr;
- return(diagram_ids_[current_tab_index]);
+ return(m_diagram_ids[current_tab_index]);
}
/**
@@ -157,8 +158,8 @@
DiagramView *ProjectView::nextDiagram() {
int current_tab_index = m_tab -> currentIndex();
int next_tab_index = current_tab_index + 1; //get next tab index
- if (next_tab_index<diagram_ids_.count()) //if next tab index >= greatest tab the last tab is activated so no need to change tab.
- return(diagram_ids_[next_tab_index]);
+ if (next_tab_index<m_diagram_ids.count()) //if next tab index >= greatest tab the last tab is activated so no need to change tab.
+ return(m_diagram_ids[next_tab_index]);
else
return NULL;
}
@@ -181,7 +182,7 @@
int current_tab_index = m_tab -> currentIndex();
int previous_tab_index = current_tab_index - 1; //get previous tab index
if (previous_tab_index>=0) //if previous tab index = 0 then the first tab is activated so no need to change tab.
- return(diagram_ids_[previous_tab_index]);
+ return(m_diagram_ids[previous_tab_index]);
else
return NULL;
}
@@ -198,7 +199,7 @@
@return last folio of current project
*/
DiagramView *ProjectView::lastDiagram(){
- return(diagram_ids_.last());
+ return(m_diagram_ids.last());
}
/**
@@ -213,7 +214,7 @@
@return first folio of current project
*/
DiagramView *ProjectView::firstDiagram(){
- return(diagram_ids_.first());
+ return(m_diagram_ids.first());
}
@@ -393,41 +394,41 @@
DiagramView *new_diagram_view = new DiagramView(d);
addDiagram(new_diagram_view);
showDiagram(new_diagram_view);
- m_tab->tabBar()->moveTab(diagrams().size()-1, i);
+ m_tab->tabBar()->moveTab(diagram_views().size()-1, i);
i++;
}
}
/**
- Ajoute un schema au ProjectView
- @param diagram Schema a ajouter
-*/
-/**
* @brief ProjectView::addDiagram
- * Add new digram to this project view
- * @param diagram added diagram
- * @param front: true add page at front
- * false add page at back
+ * Add diagram view to this project view
+ * @param diagram_view
*/
-void ProjectView::addDiagram(DiagramView *diagram_view) {
- if (!diagram_view) return;
+void ProjectView::addDiagram(DiagramView *diagram_view)
+{
+ if (!diagram_view)
+ return;
- // check diagram isn't present in the project
- if (diagram_ids_.values().contains(diagram_view)) return;
+ //Check if diagram isn't present in the project
+ if (m_diagram_ids.values().contains(diagram_view))
+ return;
- // Add new tab for the diagram
- m_tab -> addTab(diagram_view, QET::Icons::Diagram, diagram_view -> title());
- diagram_view -> setFrameStyle(QFrame::Plain | QFrame::NoFrame);
+ // Add new tab for the diagram
+ m_tab->addTab(diagram_view, QET::Icons::Diagram, diagram_view -> title());
+ diagram_view->setFrameStyle(QFrame::Plain | QFrame::NoFrame);
m_diagram_view_list << diagram_view;
rebuildDiagramsMap();
+ updateTabTitle(diagram_view);
+
connect(diagram_view, SIGNAL(showDiagram(Diagram*)), this, SLOT(showDiagram(Diagram*)));
- connect(diagram_view, SIGNAL(titleChanged(DiagramView *, const QString &)), this, SLOT(updateTabTitle(DiagramView *, const QString &)));
+ connect(diagram_view, SIGNAL(titleChanged(DiagramView *, const QString &)), this, SLOT(updateTabTitle(DiagramView *)));
connect(diagram_view, SIGNAL(findElementRequired(const ElementsLocation &)), this, SIGNAL(findElementRequired(const ElementsLocation &)));
connect(diagram_view, SIGNAL(editElementRequired(const ElementsLocation &)), this, SIGNAL(editElementRequired(const ElementsLocation &)));
+ connect(&diagram_view->diagram()->border_and_titleblock , &BorderTitleBlock::titleBlockFolioChanged, [this, diagram_view]() {this->updateTabTitle(diagram_view);});
- // signal diagram was added
+ // signal diagram view was added
emit(diagramAdded(diagram_view));
}
@@ -440,7 +441,7 @@
if (m_project -> isReadOnly()) return;
// verifie que le schema est bien present dans le projet
- if (!diagram_ids_.values().contains(diagram_view)) return;
+ if (!m_diagram_ids.values().contains(diagram_view)) return;
//Ask confirmation to user.
@@ -456,7 +457,7 @@
}
// enleve le DiagramView des onglets
- int diagram_tab_id = diagram_ids_.key(diagram_view);
+ int diagram_tab_id = m_diagram_ids.key(diagram_view);
m_tab -> removeTab(diagram_tab_id);
m_diagram_view_list.removeAll(diagram_view);
rebuildDiagramsMap();
@@ -543,7 +544,7 @@
void ProjectView::moveDiagramUp(DiagramView *diagram_view) {
if (!diagram_view) return;
- int diagram_view_position = diagram_ids_.key(diagram_view);
+ int diagram_view_position = m_diagram_ids.key(diagram_view);
if (!diagram_view_position) {
// le schema est le premier du projet
return;
@@ -564,8 +565,8 @@
void ProjectView::moveDiagramDown(DiagramView *diagram_view) {
if (!diagram_view) return;
- int diagram_view_position = diagram_ids_.key(diagram_view);
- if (diagram_view_position + 1 == diagram_ids_.count()) {
+ int diagram_view_position = m_diagram_ids.key(diagram_view);
+ if (diagram_view_position + 1 == m_diagram_ids.count()) {
// le schema est le dernier du projet
return;
}
@@ -586,12 +587,12 @@
{
if (!diagram_view) return;
- int diagram_view_position = diagram_ids_.key(diagram_view);
+ int diagram_view_position = m_diagram_ids.key(diagram_view);
if (!diagram_view_position) {
// le schema est le premier du projet
return;
}
- m_tab -> tabBar() -> moveTab(diagram_view_position, (diagrams().size(), 0));
+ m_tab -> tabBar() -> moveTab(diagram_view_position, (diagram_views().size(), 0));
}
/*
@@ -608,7 +609,7 @@
void ProjectView::moveDiagramUpx10(DiagramView *diagram_view) {
if (!diagram_view) return;
- int diagram_view_position = diagram_ids_.key(diagram_view);
+ int diagram_view_position = m_diagram_ids.key(diagram_view);
if (!diagram_view_position) {
// le schema est le premier du projet
return;
@@ -629,8 +630,8 @@
void ProjectView::moveDiagramDownx10(DiagramView *diagram_view) {
if (!diagram_view) return;
- int diagram_view_position = diagram_ids_.key(diagram_view);
- if (diagram_view_position + 1 == diagram_ids_.count()) {
+ int diagram_view_position = m_diagram_ids.key(diagram_view);
+ if (diagram_view_position + 1 == m_diagram_ids.count()) {
// le schema est le dernier du projet
return;
}
@@ -903,7 +904,7 @@
// If project have the folios list, move it at the beginning of the project
if (m_project -> getFolioSheetsQuantity()) {
for (int i = 0; i < m_project->getFolioSheetsQuantity(); i++)
- m_tab -> tabBar() -> moveTab(diagrams().size()-1, + 1);
+ m_tab -> tabBar() -> moveTab(diagram_views().size()-1, + 1);
}
}
@@ -938,32 +939,63 @@
}
/**
- Met a jour le titre d'un onglet
- @param diagram Schema
- @param diagram_title Titre du schema
-*/
-void ProjectView::updateTabTitle(DiagramView *diagram, const QString &diagram_title) {
- int diagram_tab_id = diagram_ids_.key(diagram, -1);
- if (diagram_tab_id != -1) {
- m_tab -> setTabText(diagram_tab_id, diagram_title);
+ * @brief ProjectView::updateTabTitle
+ * Update the title of the tab which display the diagram view @diagram_view.
+ * @param diagram : The diagram view.
+ */
+void ProjectView::updateTabTitle(DiagramView *diagram_view)
+{
+ int diagram_tab_id = m_diagram_ids.key(diagram_view, -1);
+
+ if (diagram_tab_id != -1)
+ {
+ QSettings settings;
+ QString title;
+ Diagram *diagram = diagram_view->diagram();
+
+ if (settings.value("genericpanel/folio", false).toBool())
+ {
+ QString formula = diagram->border_and_titleblock.folio();
+ autonum::sequentialNumbers seq;
+ title = autonum::AssignVariables::formulaToLabel(formula, seq, diagram);
+ }
+ else
+ title = QString::number(diagram->folioIndex() + 1);
+
+ title += " - ";
+ title += diagram->title();
+ m_tab->setTabText(diagram_tab_id ,title);
}
}
/**
+ * @brief ProjectView::updateAllTabsTitle
+ * Update all tabs title
+ */
+void ProjectView::updateAllTabsTitle()
+{
+ for (DiagramView *dv : m_diagram_ids.values())
+ updateTabTitle(dv);
+}
+
+/**
@param from Index de l'onglet avant le deplacement
@param to Index de l'onglet apres le deplacement
*/
-void ProjectView::tabMoved(int from, int to) {
- if (!m_project) return;
-
- // signale au QETProject le changement d'ordre des schemas
- m_project -> diagramOrderChanged(from, to);
-
- // reconstruit la liste associant les index des onglets aux schemas
+void ProjectView::tabMoved(int from, int to)
+{
+ if (!m_project)
+ return;
+
+ m_project->diagramOrderChanged(from, to);
rebuildDiagramsMap();
-
- // emet un signal pour informer le reste du monde que l'ordre des schemas a change
- emit(diagramOrderChanged(this, from, to));
+
+ //Rebuild the title of each diagram in range from - to
+ for (int i= qMin(from,to) ; i< qMax(from,to)+1 ; ++i)
+ {
+ DiagramView *dv = m_diagram_ids.value(i);
+ updateTabTitle(dv);
+ }
}
/**
@@ -972,7 +1004,7 @@
le schema n'est pas trouve
*/
DiagramView *ProjectView::findDiagram(Diagram *diagram) {
- foreach(DiagramView *diagram_view, diagrams()) {
+ foreach(DiagramView *diagram_view, diagram_views()) {
if (diagram_view -> diagram() == diagram) {
return(diagram_view);
}
@@ -985,12 +1017,12 @@
*/
void ProjectView::rebuildDiagramsMap() {
// vide la map
- diagram_ids_.clear();
+ m_diagram_ids.clear();
foreach(DiagramView *diagram_view, m_diagram_view_list) {
int dv_idx = m_tab -> indexOf(diagram_view);
if (dv_idx == -1) continue;
- diagram_ids_.insert(dv_idx, diagram_view);
+ m_diagram_ids.insert(dv_idx, diagram_view);
}
}
@@ -1007,9 +1039,9 @@
else if(m_tab->count() == 1)
setDisplayFallbackWidget(false);
- emit(diagramActivated(diagram_ids_[tab_id]));
- if (diagram_ids_[tab_id] != nullptr)
- diagram_ids_[tab_id]->diagram()->diagramActivated();
+ emit(diagramActivated(m_diagram_ids[tab_id]));
+ if (m_diagram_ids[tab_id] != nullptr)
+ m_diagram_ids[tab_id]->diagram()->diagramActivated();
}
/**
@@ -1018,7 +1050,7 @@
*/
void ProjectView::tabDoubleClicked(int tab_id) {
// repere le schema concerne
- DiagramView *diagram_view = diagram_ids_[tab_id];
+ DiagramView *diagram_view = m_diagram_ids[tab_id];
if (!diagram_view) return;
diagram_view -> editDiagramProperties();
Modified: trunk/sources/projectview.h
===================================================================
--- trunk/sources/projectview.h 2017-02-16 14:10:30 UTC (rev 4917)
+++ trunk/sources/projectview.h 2017-02-18 13:30:38 UTC (rev 4918)
@@ -58,7 +58,7 @@
public:
QETProject *project();
void setProject(QETProject *);
- QList<DiagramView *> diagrams() const;
+ QList<DiagramView *> diagram_views() const;
QList<Diagram *> getDiagrams(ProjectSaveOptions options);
DiagramView *currentDiagram() const;
void closeEvent(QCloseEvent *);
@@ -68,48 +68,48 @@
void changeLastTab();
public slots:
- void addNewDiagram();
- void addNewDiagramFolioList();
- void addDiagram(DiagramView *);
- void removeDiagram(DiagramView *);
- void removeDiagram(Diagram *);
- void showDiagram(DiagramView *);
- void showDiagram(Diagram *);
- void editProjectProperties();
- void editCurrentDiagramProperties();
- void editDiagramProperties(DiagramView *);
- void editDiagramProperties(Diagram *);
- void moveDiagramUp(DiagramView *);
- void moveDiagramUp(Diagram *);
- void moveDiagramDown(DiagramView *);
- void moveDiagramDown(Diagram *);
- void moveDiagramUpTop(DiagramView *);
- void moveDiagramUpTop(Diagram *);
- void moveDiagramUpx10(DiagramView *);
- void moveDiagramUpx10(Diagram *);
- void moveDiagramDownx10(DiagramView *);
- void moveDiagramDownx10(Diagram *);
- void printProject();
- void exportProject();
- QETResult save();
- QETResult saveAs(ProjectSaveOptions = ProjectSaveOptions(AllDiagrams));
- QETResult doSave(ProjectSaveOptions);
- void saveDiagrams(const QList<Diagram *> &);
- int cleanProject();
- void updateWindowTitle();
- void updateTabTitle(DiagramView *, const QString &);
- void tabMoved(int, int);
+ void addNewDiagram();
+ void addNewDiagramFolioList();
+ void addDiagram(DiagramView *);
+ void removeDiagram(DiagramView *);
+ void removeDiagram(Diagram *);
+ void showDiagram(DiagramView *);
+ void showDiagram(Diagram *);
+ void editProjectProperties();
+ void editCurrentDiagramProperties();
+ void editDiagramProperties(DiagramView *);
+ void editDiagramProperties(Diagram *);
+ void moveDiagramUp(DiagramView *);
+ void moveDiagramUp(Diagram *);
+ void moveDiagramDown(DiagramView *);
+ void moveDiagramDown(Diagram *);
+ void moveDiagramUpTop(DiagramView *);
+ void moveDiagramUpTop(Diagram *);
+ void moveDiagramUpx10(DiagramView *);
+ void moveDiagramUpx10(Diagram *);
+ void moveDiagramDownx10(DiagramView *);
+ void moveDiagramDownx10(Diagram *);
+ void printProject();
+ void exportProject();
+ QETResult save();
+ QETResult saveAs(ProjectSaveOptions = ProjectSaveOptions(AllDiagrams));
+ QETResult doSave(ProjectSaveOptions);
+ void saveDiagrams(const QList<Diagram *> &);
+ int cleanProject();
+ void updateWindowTitle();
+ void updateTabTitle(DiagramView *);
+ void updateAllTabsTitle();
+ void tabMoved(int, int);
signals:
- void diagramAdded(DiagramView *);
- void diagramRemoved(DiagramView *);
- void diagramActivated(DiagramView *);
- void diagramOrderChanged(ProjectView *, int, int);
- void projectClosed(ProjectView *);
- void errorEncountered(const QString &);
- // relayed signals
- void findElementRequired(const ElementsLocation &);
- void editElementRequired(const ElementsLocation &);
+ void diagramAdded(DiagramView *);
+ void diagramRemoved(DiagramView *);
+ void diagramActivated(DiagramView *);
+ void projectClosed(ProjectView *);
+ void errorEncountered(const QString &);
+ // relayed signals
+ void findElementRequired(const ElementsLocation &);
+ void editElementRequired(const ElementsLocation &);
private:
void initActions();
@@ -142,7 +142,7 @@
QWidget *fallback_widget_;
QLabel *fallback_label_;
QTabWidget *m_tab;
- QMap<int, DiagramView *> diagram_ids_;
+ QMap<int, DiagramView *> m_diagram_ids;
QList<DiagramView *> m_diagram_view_list;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(ProjectView::ProjectSaveOptions)
Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp 2017-02-16 14:10:30 UTC (rev 4917)
+++ trunk/sources/qetdiagrameditor.cpp 2017-02-18 13:30:38 UTC (rev 4918)
@@ -1055,7 +1055,7 @@
*/
ProjectView *QETDiagramEditor::findProject(DiagramView *diagram_view) const {
foreach(ProjectView *project_view, openedProjects()) {
- if (project_view -> diagrams().contains(diagram_view)) {
+ if (project_view -> diagram_views().contains(diagram_view)) {
return(project_view);
}
}
@@ -1069,7 +1069,7 @@
*/
ProjectView *QETDiagramEditor::findProject(Diagram *diagram) const {
foreach(ProjectView *project_view, openedProjects()) {
- foreach(DiagramView *diagram_view, project_view -> diagrams()) {
+ foreach(DiagramView *diagram_view, project_view -> diagram_views()) {
if (diagram_view -> diagram() == diagram) {
return(project_view);
}
@@ -1284,7 +1284,7 @@
void QETDiagramEditor::slot_setSelectionMode()
{
if (ProjectView *pv = currentProject())
- foreach(DiagramView *dv, pv -> diagrams())
+ foreach(DiagramView *dv, pv -> diagram_views())
dv -> setSelectionMode();
}
@@ -1295,7 +1295,7 @@
void QETDiagramEditor::slot_setVisualisationMode()
{
if (ProjectView *pv = currentProject())
- foreach(DiagramView *dv, pv -> diagrams())
+ foreach(DiagramView *dv, pv -> diagram_views())
dv -> setVisualisationMode();
}
@@ -1506,7 +1506,7 @@
{
if (!project_view) return;
- foreach(DiagramView *dv, project_view -> diagrams())
+ foreach(DiagramView *dv, project_view -> diagram_views())
diagramWasAdded(dv);
//Manage the close event of project
@@ -2035,7 +2035,7 @@
// if the removed diagram was a folio sheet, then delete all the remaining folio sheets also.
if (isFolioList) {
- foreach (DiagramView *diag, current_project -> diagrams()) {
+ foreach (DiagramView *diag, current_project -> diagram_views()) {
if (dynamic_cast<DiagramFolioList *>(diag -> diagram())) {
current_project -> removeDiagram(diag);
}
@@ -2043,8 +2043,8 @@
// else if after diagram removal, the total diagram quantity becomes a factor of 58, then
// remove one (last) folio sheet.
- } else if (current_project -> diagrams().size() % 58 == 0) {
- foreach (DiagramView *diag, current_project -> diagrams()) {
+ } else if (current_project -> diagram_views().size() % 58 == 0) {
+ foreach (DiagramView *diag, current_project -> diagram_views()) {
DiagramFolioList *ptr = dynamic_cast<DiagramFolioList *>(diag -> diagram());
if (ptr && ptr -> getId() == current_project -> project() -> getFolioSheetsQuantity() - 1) {
current_project -> removeDiagram(diag);
Modified: trunk/sources/qetmainwindow.cpp
===================================================================
--- trunk/sources/qetmainwindow.cpp 2017-02-16 14:10:30 UTC (rev 4917)
+++ trunk/sources/qetmainwindow.cpp 2017-02-18 13:30:38 UTC (rev 4918)
@@ -26,6 +26,7 @@
#include "qeticons.h"
#include "qetapp.h"
#include "qetdiagrameditor.h"
+#include "projectview.h"
/**
Constructor
@@ -55,12 +56,19 @@
configure_action_ = new QAction(QET::Icons::Configure, tr("&Configurer QElectroTech"), this);
configure_action_ -> setStatusTip(tr("Permet de régler différents paramètres de QElectroTech", "status bar tip"));
- connect(configure_action_, &QAction::triggered, [qet_app]() {
+ connect(configure_action_, &QAction::triggered, [qet_app]()
+ {
qet_app->configureQET();
- //TODO we use reloadOldElementPanel only to keep up to date the string of the folio in the old element panel.
- //then, if user change the option "Use labels of folio instead of their ID" the string of folio in the old element panel is up to date
- foreach (QETDiagramEditor *qde, qet_app->diagramEditors())
+ //TODO we use reloadOldElementPanel only to keep up to date the string of the folio in the old element panel.
+ //then, if user change the option "Use labels of folio instead of their ID" the string of folio in the old element panel is up to date
+ for (QETDiagramEditor *qde : qet_app->diagramEditors())
+ {
qde->reloadOldElementPanel();
+ for (ProjectView *pv : qde->openedProjects())
+ {
+ pv->updateAllTabsTitle();
+ }
+ }
});
fullscreen_action_ = new QAction(this);