File indexing completed on 2024-05-19 05:51:03

0001 /* Atelier KDE Printer Host for 3D Printing
0002     Copyright (C) <2016>
0003     Author: Lays Rodrigues - lays.rodrigues@kde.org
0004             Chris Rizzitello - rizzitello@kde.org
0005 
0006     This program is free software: you can redistribute it and/or modify
0007     it under the terms of the GNU General Public License as published by
0008     the Free Software Foundation, either version 3 of the License, or
0009     (at your option) any later version.
0010 
0011     This program is distributed in the hope that it will be useful,
0012     but WITHOUT ANY WARRANTY; without even the implied warranty of
0013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014     GNU General Public License for more details.
0015 
0016     You should have received a copy of the GNU General Public License
0017     along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 #pragma once
0020 
0021 #include <KTextEditor/ConfigInterface>
0022 #include <KTextEditor/Document>
0023 #include <KTextEditor/Editor>
0024 #include <KTextEditor/View>
0025 #include <QTabWidget>
0026 #include <QWidget>
0027 
0028 class GCodeEditorWidget : public QWidget
0029 {
0030     Q_OBJECT
0031 public:
0032     explicit GCodeEditorWidget(QWidget *parent = nullptr);
0033     ~GCodeEditorWidget() = default;
0034     void loadFile(const QUrl &file);
0035     QVector<QUrl> modifiedFiles();
0036     bool saveFile(const QUrl &url);
0037 
0038 private:
0039     QMap<QUrl, KTextEditor::Document *> urlDoc;
0040     QMap<QUrl, QWidget *> urlTab;
0041     KTextEditor::ConfigInterface *m_interface = nullptr;
0042     KTextEditor::Document *newDoc(const QUrl &file);
0043     KTextEditor::Editor *m_editor;
0044     KTextEditor::View *newView(KTextEditor::Document *doc);
0045     QTabWidget *m_tabwidget;
0046     void closeTab(int index);
0047     void currentIndexChanged(int index);
0048     void setupInterface(const KTextEditor::View *view);
0049     void setupTabWidget();
0050 
0051 signals:
0052     void currentFileChanged(const QUrl &file);
0053     void updateClientFactory(KTextEditor::View *view);
0054     void fileClosed(const QUrl &file);
0055     void droppedUrls(QList<QUrl> fileList);
0056 
0057 private slots:
0058     void dropCatch(QDropEvent *event);
0059 };