QSapecNG
 All Classes Functions Enumerations Properties
schematiceditor.h
00001 /*
00002     QSapecNG - Qt based SapecNG GUI front-end
00003     Copyright (C) 2009, Michele Caini
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 #ifndef SCHEMATICEDITOR_H
00021 #define SCHEMATICEDITOR_H
00022 
00023 #include "gui/editor/schematicview.h"
00024 #include "gui/editor/schematicscene.h"
00025 #include "gui/editor/metacircuit_thread.hpp"
00026 #include "gui/workplane/workplane.h"
00027 
00028 #include <QtCore/QMutexLocker>
00029 #include <QtGui/QMdiSubWindow>
00030 
00031 
00032 class QFocusEvent;
00033 
00034 
00035 namespace qsapecng
00036 {
00037 
00038 
00039 class SchematicEditor: public QMdiSubWindow
00040 {
00041 
00042   Q_OBJECT
00043 
00044 public:
00045   SchematicEditor(QWidget* parent = 0, Qt::WindowFlags flags = 0);
00046   SchematicEditor(
00047       SchematicScene& scene,
00048       QWidget* parent = 0,
00049       Qt::WindowFlags flags = 0
00050     );
00051 
00052   inline SchematicView& view() const { return *view_; }
00053   inline SchematicScene& scene() const { return *scene_; }
00054 
00055   inline bool isUntitled() const { return isUntitled_; }
00056   QString userFriendlyCurrentFile() const;
00057   QString currentFile() const;
00058 
00059   inline bool isRunning() const { return solver_.isRunning(); }
00060   inline bool isSolved() const { return solved_; }
00061 
00062   bool accept(WorkPlane& workplane);
00063 
00064 public slots:
00065   bool save();
00066   bool saveAs();
00067   bool saveFile(const QString& fileName);
00068   bool loadFile(const QString& fileName);
00069   void solve();
00070 
00071 signals:
00072   void stackEditor(SchematicEditor* editor);
00073   void aboutToCloseEditor();
00074   
00075   void dirtyChanged(bool dirty);
00076   
00077   void fileSaved(const QString& fileName);
00078   void fileLoaded(const QString& fileName);
00079   void solved();
00080 
00081 private slots:
00082   void reset();
00083   void fileNameChanged(const QString& fileName);
00084   void finished();
00085   void stateChanged(Qt::WindowStates oldState, Qt::WindowStates newState);
00086   void showUserDef(SchematicScene& scene);
00087   void cleanChanged(bool clean = false);
00088   void externalCleanChanged();
00089 
00090 protected:
00091   void closeEvent(QCloseEvent* event);
00092 
00093 private:
00094   void setDirty();
00095   void showResult();
00096   void setCurrentFile(const QString& fileName);
00097   QString strippedName(const QString& fullFileName) const;
00098   bool maybeSave();
00099   void init();
00100 
00101 private:
00102   MetaCircuit_Thread solver_;
00103   bool solved_;
00104 
00105   SchematicView* view_;
00106   SchematicScene* scene_;
00107 
00108   QString curFile_;
00109   bool isUntitled_;
00110   bool externalCleanChanged_;
00111 
00112 };
00113 
00114 
00115 }
00116 
00117 
00118 #endif // SCHEMATICEDITOR_H
 All Classes Functions Enumerations Properties