File indexing completed on 2024-04-21 14:43:53

0001 /*************************************************************************************
0002  *  Copyright (C) 2010-2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com> *
0003  *                                                                                   *
0004  *  This program is free software; you can redistribute it and/or                    *
0005  *  modify it under the terms of the GNU General Public License                      *
0006  *  as published by the Free Software Foundation; either version 2                   *
0007  *  of the License, or (at your option) any later version.                           *
0008  *                                                                                   *
0009  *  This program is distributed in the hope that it will be useful,                  *
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
0012  *  GNU General Public License for more details.                                     *
0013  *                                                                                   *
0014  *  You should have received a copy of the GNU General Public License                *
0015  *  along with this program; if not, write to the Free Software                      *
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
0017  *************************************************************************************/
0018 
0019 #ifndef GPLACS_MAINWINDOW_H
0020 #define GPLACS_MAINWINDOW_H
0021 
0022 //Analitza includes
0023 #include <analitzaplot/plotitem.h>
0024 
0025 //Qt includes
0026 #include <QAction>
0027 #include <QModelIndex>
0028 
0029 //KDE includes
0030 #include <KXmlGuiWindow>
0031 #include <KRecentFilesAction>
0032 
0033 class DictionaryCollection;
0034 class Filter;
0035 class SpaceOptions;
0036 class SpaceInformation;
0037 class PlotsBuilder;
0038 class DataStore;
0039 class SpacePlotsFilterProxyModel;
0040 class PlotsEditor;
0041 class KToggleAction;
0042 
0043 class FunctionsModel;
0044 class SpacesModel;
0045 
0046 class Dashboard;
0047 
0048 class MainWindow : public KXmlGuiWindow
0049 {
0050     Q_OBJECT
0051 
0052 public:
0053     explicit MainWindow(QWidget *parent = nullptr);
0054     ~MainWindow() override;
0055 
0056     DataStore* getDocument() { return m_document; }
0057 
0058     //used for checking the default autosave file (.khipu.autosave)
0059     void checkforAutoSavedFile();
0060 
0061 signals:
0062     //used to know the type of the dictionary to be shown in the dictionarydock
0063     void Spaceinserted(Analitza::Dimension dim);
0064 
0065 public slots:
0066 
0067     //New file slot
0068     void newFile();
0069 
0070     //open file slot
0071     bool openFileClicked();
0072 
0073     //opening a file spcified by the url
0074     bool openFile(const QUrl &url);
0075 
0076     //recent file list
0077     void openRecentClicked(const QUrl&  name);
0078     void saveClicked();
0079     bool saveAsClicked();
0080     bool saveFile(const QUrl &url);
0081     void activateSpace(int);
0082 
0083     //create the plots for the appropriate space which are clicked by the user
0084     void createPlot(const QModelIndex &ind);
0085 
0086     //saves the plot
0087     void savePlot();
0088 
0089     //set the current space's title and description
0090     void setCurrentSpaceTitle(const QString& str);
0091     void setCurrentSpaceDesc(const QString& desc);
0092 
0093 private slots:
0094     //helpers - space
0095     void activateDashboardUi();
0096     void activateSpaceUi();
0097     void copySnapshot();
0098     bool closeClicked();
0099     void autoSaveFile();
0100 
0101     //used to set visible/invisible dictionary-view
0102     void setVisibleDictionary();
0103 
0104     //slots for addSpace2D/3D buttons
0105     void addSpace2D();
0106     void addSpace3D();
0107 
0108     //removes the current space
0109     void removeCurrentSpace();
0110 
0111     void goHome();
0112     void fullScreenView (bool isFull);
0113     void setMenuBarVisibility (bool isShow);
0114     void clearRecentFileList();
0115 
0116     //Actions related to space's navigation
0117     void firstPageActClicked();
0118     void priorActClicked();
0119     void nextActClicked();
0120     void lastPageActClicked();
0121 
0122     //builder dock actions: shortcuts ... first add the space then show the editor
0123     void buildCartesianGraphCurve();
0124     void buildCartesianImplicitCurve();
0125     void buildCartesianParametricCurve2D();
0126     void buildPolarGraphCurve();
0127 
0128     //3D
0129     void buildCartesianParametricCurve3D();
0130     void buildCartesianGraphSurface();
0131     void buildCartesianImplicitSurface();
0132     void buildCartesianParametricSurface();
0133     void buildCylindricalGraphSurface();
0134     void buildSphericalGraphSurface();
0135 
0136 private:
0137     QAction *createAction(const char *name, const QString &text, const QString &iconName, const QKeySequence & shortcut, const QObject *recvr, const char *slot, bool isCheckable = false, bool checked = true);
0138 
0139     //setting up the dock-widgets
0140     void setupDocks();
0141     void setupActions();
0142 
0143     //changes the title bar when file-name is available
0144     void changeTitleBar(const QString& path);
0145 
0146     //current opened file's name (i.e. path)
0147     void setCurrentFile(const QString &fileName);
0148     void updateRecentFileList();
0149 
0150     // used for parsing file path from the url provided by openrecent
0151     QString pathFromUrl(const QUrl &url);
0152 
0153     //converts a thubnail from bytearray to pixmap and vice-versa
0154     QPixmap toPixmap(const QByteArray &bytearray);
0155     QByteArray thumbnailtoByteArray(const QPixmap &thumbnail);
0156 
0157     void closeEvent(QCloseEvent * event) override;
0158     void updateThumbnail();
0159 
0160     //returns the current autosave file's path (i.e.currentdirecotrypath/.filename.khipu.autosave)
0161     QString getCurrentAutoSavepath(const QString& path);
0162 
0163     //returns the default autosave file's path (i.e.homedirectotypath/.khipu.autosave)
0164     QUrl getDefaultAutoSavepath() const;
0165 
0166 private:
0167     DataStore *m_document;
0168     Dashboard *m_dashboard;
0169     Filter *m_filter;
0170 
0171     QDockWidget *m_plotsBuilderDock;
0172     PlotsEditor *m_spacePlotsDock;
0173     SpaceInformation *m_spaceInfoDock;
0174     SpaceOptions *m_spaceOptionsDock;
0175     DictionaryCollection *m_dictionaryDock;
0176     QVariantList m_parsedSpaceDetails;
0177     QString m_fileLocation; // location of the current running file which is saved by the user.
0178     KRecentFilesAction * m_openrecent;
0179     QAction *m_priorAct;
0180     QAction *m_nextAct;
0181     QAction *m_importdictionaryAct;
0182     QAction *m_getdictionaryAct;
0183     QUrl m_currentFileUrl;
0184     
0185 private: // consts
0186     static const unsigned short MaxRecentFiles = 7;
0187     
0188     // time interval to show the message on statusbar in milliseconds
0189     static const unsigned short MessageDuration = 3000;
0190 };
0191 
0192 #endif