Remove some unused or obsolete code.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4926 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2017-03-05 12:24:33 +00:00
parent f4acaff7be
commit 878e3d5bf0
4 changed files with 63 additions and 102 deletions

View File

@@ -958,21 +958,15 @@ void Diagram::write(const QDomElement &element) {
emit(written()); emit(written());
} }
/**
@return true si la fonction write a deja ete appele (pour etre plus exact :
si le document XML utilise en interne n'est pas vide), false sinon
*/
bool Diagram::wasWritten() const {
return(!xml_document_.isNull());
}
/** /**
@return le schema en XML tel qu'il doit etre enregistre dans le fichier projet @return le schema en XML tel qu'il doit etre enregistre dans le fichier projet
@param xml_doc document XML a utiliser pour creer l'element @param xml_doc document XML a utiliser pour creer l'element
*/ */
QDomElement Diagram::writeXml(QDomDocument &xml_doc) const { QDomElement Diagram::writeXml(QDomDocument &xml_doc) const
// si le schema n'a pas ete enregistre explicitement, on n'ecrit rien {
if (!wasWritten()) return(QDomElement()); //If diagram was not explicitely saved, we write nothing.
if (xml_document_.isNull())
return(QDomElement());
QDomElement diagram_elmt = xml_document_.documentElement(); QDomElement diagram_elmt = xml_document_.documentElement();
QDomNode new_node = xml_doc.importNode(diagram_elmt, true); QDomNode new_node = xml_doc.importNode(diagram_elmt, true);

View File

@@ -157,7 +157,6 @@ class Diagram : public QGraphicsScene
bool fromXml(QDomElement &, QPointF = QPointF(), bool = true, DiagramContent * = 0); bool fromXml(QDomElement &, QPointF = QPointF(), bool = true, DiagramContent * = 0);
void write(); void write();
void write(const QDomElement &); void write(const QDomElement &);
bool wasWritten() const;
QDomElement writeXml(QDomDocument &) const; QDomElement writeXml(QDomDocument &) const;
void folioSequentialsToXml(QHash<QString, QStringList>*, QDomElement *, QString, QString, QDomDocument *); void folioSequentialsToXml(QHash<QString, QStringList>*, QDomElement *, QString, QString, QDomDocument *);
void folioSequentialsFromXml(const QDomElement&, QHash<QString, QStringList>*, QString, QString, QString, QString); void folioSequentialsFromXml(const QDomElement&, QHash<QString, QStringList>*, QString, QString, QString, QString);

View File

@@ -93,29 +93,6 @@ QList<DiagramView *> ProjectView::diagram_views() const {
return(m_diagram_view_list); return(m_diagram_view_list);
} }
/**
@return A list containing child diagrams matching provided \a options.
*/
QList<Diagram *> ProjectView::getDiagrams(ProjectSaveOptions options) {
QList<Diagram *> selection;
if ((options & AllDiagrams) == AllDiagrams) {
selection << m_project -> diagrams();
} else {
Diagram *current = 0;
if (DiagramView *view = currentDiagram()) {
current = view -> diagram();
}
if (options & CurrentDiagram) {
if (current) selection << current;
} else if (options & AllDiagramsButCurrent) {
selection = m_project -> diagrams();
selection.removeOne(current);
}
}
return(selection);
}
/** /**
* @brief ProjectView::currentDiagram * @brief ProjectView::currentDiagram
* @return The current active diagram view or nullptr if there isn't diagramView in this project view. * @return The current active diagram view or nullptr if there isn't diagramView in this project view.
@@ -696,7 +673,7 @@ void ProjectView::exportProject() {
@return a QETResult object reflecting the situation @return a QETResult object reflecting the situation
*/ */
QETResult ProjectView::save() { QETResult ProjectView::save() {
return(doSave(AllDiagrams)); return(doSave());
} }
/** /**
@@ -706,38 +683,38 @@ QETResult ProjectView::save() {
@return a QETResult object reflecting the situation; note that a valid @return a QETResult object reflecting the situation; note that a valid
QETResult object is returned if the operation was cancelled. QETResult object is returned if the operation was cancelled.
*/ */
QETResult ProjectView::saveAs(ProjectSaveOptions options) { QETResult ProjectView::saveAs()
{
if (!m_project) return(noProjectResult()); if (!m_project) return(noProjectResult());
QString filepath = askUserForFilePath(); QString filepath = askUserForFilePath();
if (filepath.isEmpty()) return(QETResult()); if (filepath.isEmpty()) return(QETResult());
return(doSave(options)); return(doSave());
} }
/** /**
Save project content according to \a options, then write the project file. May Save project content, then write the project file. May
call saveAs if no filepath was provided before. call saveAs if no filepath was provided before.
@param options May be used to specify what should be saved (e.g. modified
diagrams only).
@return a QETResult object reflecting the situation; note that a valid @return a QETResult object reflecting the situation; note that a valid
QETResult object is returned if the operation was cancelled. QETResult object is returned if the operation was cancelled.
*/ */
QETResult ProjectView::doSave(ProjectSaveOptions options) { QETResult ProjectView::doSave()
{
if (!m_project) return(noProjectResult()); if (!m_project) return(noProjectResult());
if (m_project -> filePath().isEmpty()) { if (m_project -> filePath().isEmpty()) {
// The project has not been saved to a file yet, // The project has not been saved to a file yet,
// so save() actually means saveAs(). // so save() actually means saveAs().
return(saveAs(options)); return(saveAs());
} }
// look for diagrams matching the required save options // look for diagrams matching the required save options
saveDiagrams(getDiagrams(options)); saveDiagrams(m_project->diagrams());
// write to file // write to file
QETResult result = m_project -> write(); QETResult result = m_project -> write();
updateWindowTitle(); updateWindowTitle();
if (options == AllDiagrams) project()->undoStack()->clear(); project()->undoStack()->clear();
return(result); return(result);
} }

View File

@@ -35,37 +35,28 @@ class QVBoxLayout;
This class provides a widget displaying the diagrams of a particular This class provides a widget displaying the diagrams of a particular
project using tabs. project using tabs.
*/ */
class ProjectView : public QWidget { class ProjectView : public QWidget
{
Q_OBJECT Q_OBJECT
// constructors, destructor
public: public:
enum ProjectSaveOption { ProjectView(QETProject *, QWidget * = 0);
CurrentDiagram = 2, virtual ~ProjectView();
AllDiagramsButCurrent = 4,
AllDiagrams = 6
};
Q_DECLARE_FLAGS(ProjectSaveOptions, ProjectSaveOption)
// constructors, destructor
public:
ProjectView(QETProject *, QWidget * = 0);
virtual ~ProjectView();
private: private:
ProjectView(const ProjectView &); ProjectView(const ProjectView &);
// methods // methods
public: public:
QETProject *project(); QETProject *project();
void setProject(QETProject *); void setProject(QETProject *);
QList<DiagramView *> diagram_views() const; QList<DiagramView *> diagram_views() const;
QList<Diagram *> getDiagrams(ProjectSaveOptions options); DiagramView *currentDiagram() const;
DiagramView *currentDiagram() const; void closeEvent(QCloseEvent *);
void closeEvent(QCloseEvent *); void changeTabUp();
void changeTabUp(); void changeTabDown();
void changeTabDown(); void changeFirstTab();
void changeFirstTab(); void changeLastTab();
void changeLastTab();
public slots: public slots:
void addNewDiagram(); void addNewDiagram();
@@ -92,8 +83,8 @@ class ProjectView : public QWidget {
void printProject(); void printProject();
void exportProject(); void exportProject();
QETResult save(); QETResult save();
QETResult saveAs(ProjectSaveOptions = ProjectSaveOptions(AllDiagrams)); QETResult saveAs();
QETResult doSave(ProjectSaveOptions); QETResult doSave();
void saveDiagrams(const QList<Diagram *> &); void saveDiagrams(const QList<Diagram *> &);
int cleanProject(); int cleanProject();
void updateWindowTitle(); void updateWindowTitle();
@@ -112,38 +103,38 @@ class ProjectView : public QWidget {
void editElementRequired(const ElementsLocation &); void editElementRequired(const ElementsLocation &);
private: private:
void initActions(); void initActions();
void initWidgets(); void initWidgets();
void initLayout(); void initLayout();
void loadDiagrams(); void loadDiagrams();
DiagramView *findDiagram(Diagram *); DiagramView *findDiagram(Diagram *);
DiagramView *nextDiagram(); DiagramView *nextDiagram();
DiagramView *previousDiagram(); DiagramView *previousDiagram();
DiagramView *firstDiagram(); DiagramView *firstDiagram();
DiagramView *lastDiagram(); DiagramView *lastDiagram();
void rebuildDiagramsMap(); void rebuildDiagramsMap();
bool tryClosing(); bool tryClosing();
bool tryClosingElementEditors(); bool tryClosingElementEditors();
int tryClosingDiagrams(); int tryClosingDiagrams();
QString askUserForFilePath(bool = true); QString askUserForFilePath(bool = true);
QETResult noProjectResult() const; QETResult noProjectResult() const;
private slots: private slots:
void tabChanged(int); void tabChanged(int);
void tabDoubleClicked(int); void tabDoubleClicked(int);
void setDisplayFallbackWidget(bool); void setDisplayFallbackWidget(bool);
void adjustReadOnlyState(); void adjustReadOnlyState();
// attributes // attributes
private: private:
QAction *add_new_diagram_; QAction *add_new_diagram_;
QETProject *m_project; QETProject *m_project;
QVBoxLayout *layout_; QVBoxLayout *layout_;
QWidget *fallback_widget_; QWidget *fallback_widget_;
QLabel *fallback_label_; QLabel *fallback_label_;
QTabWidget *m_tab; QTabWidget *m_tab;
QMap<int, DiagramView *> m_diagram_ids; QMap<int, DiagramView *> m_diagram_ids;
QList<DiagramView *> m_diagram_view_list; QList<DiagramView *> m_diagram_view_list;
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS(ProjectView::ProjectSaveOptions)
#endif #endif