File indexing completed on 2024-04-28 07:39:18
0001 /************************************************************************* 0002 * Copyright (C) 2020 by Caio Jordão Carvalho <caiojcarvalho@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 as * 0006 * published by the Free Software Foundation; either version 3 of * 0007 * 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, see <http://www.gnu.org/licenses/>.* 0016 *************************************************************************/ 0017 0018 #ifndef MARK_H 0019 #define MARK_H 0020 0021 #include "core/markedclass.h" 0022 #include "core/serializer.h" 0023 0024 #include <QFileSystemWatcher> 0025 #include <QListWidgetItem> 0026 #include <QScopedPointer> 0027 0028 #include <KXmlGuiWindow> 0029 0030 namespace Ui { 0031 class marK; 0032 } 0033 0034 /** Main class, also represents the main window. */ 0035 class marK : public KXmlGuiWindow 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 explicit marK(QWidget *parent = nullptr); 0041 ~marK() override; 0042 0043 public: 0044 /** Change directory. */ 0045 void changeDirectory(); 0046 0047 /** Navegate through items with the arrows keys up and down. 0048 * @param count - change index based in this number. 0049 */ 0050 void changeIndex(const int count); 0051 0052 /** Update comboBox reloading all MarkedClass's objects. */ 0053 void updateComboBox(); 0054 0055 /** If exists, load annotated data from temporary file. */ 0056 void retrieveTempFile(); 0057 0058 /** Save state into a temporary file. */ 0059 void makeTempFile(); 0060 0061 /** If selected in the Edit options an Serializer::OutputType different than None, auto save annotation. */ 0062 void autoSave(); 0063 0064 public slots: 0065 0066 /** Change working file. 0067 * @param item - item to load. 0068 */ 0069 void changeItem(QListWidgetItem *item); 0070 0071 /** Update the known files in the current working directory. */ 0072 void updateFiles(); 0073 0074 /** Create a new MarkedClass and add it to comboBox. */ 0075 void addNewClass(); 0076 0077 /** Select the class color. */ 0078 void selectClassColor(); 0079 0080 /** Save Annotation in the selected file. 0081 * @param outputType - type of output to save in the file. 0082 */ 0083 void saveObjects(Serializer::OutputType outputType); 0084 0085 /** Import annotation data. */ 0086 void importData(); 0087 0088 /** Toggle autosave to JSON, XML or None. Default is None. */ 0089 void toggleAutoSave(); 0090 0091 private: 0092 /** Setup Actions. */ 0093 void setupActions(); 0094 0095 /** Setup connections. */ 0096 void setupConnections(); 0097 0098 private: 0099 QScopedPointer<Ui::marK> m_ui; 0100 QFileSystemWatcher *m_watcher; 0101 QString m_currentDirectory; 0102 QVector<MarkedClass*> m_objClasses; 0103 QString m_filepath; 0104 Serializer::OutputType m_autoSaveType; 0105 }; 0106 0107 #endif // MARK_H