Warning, file /graphics/tikzkit/src/app/TikzKit.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the TikZKit project 0002 * 0003 * Copyright (C) 2013 Dominik Haumann <dhaumann@kde.org> 0004 * 0005 * This program is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 2 or the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program; If not, see <http://www.gnu.org/licenses/>. 0017 */ 0018 #include "TikzKit.h" 0019 0020 #include "DocumentManager.h" 0021 #include "MainWindow.h" 0022 0023 #include <tikz/ui/Editor.h> 0024 #include <tikz/ui/Application.h> 0025 #include <tikz/ui/MainWindow.h> 0026 #include <tikz/ui/Document.h> 0027 #include <tikz/ui/View.h> 0028 0029 #include <QDebug> 0030 0031 namespace { 0032 TikzKit * s_appSelf = nullptr; 0033 } 0034 0035 TikzKit * TikzKit::self() 0036 { 0037 return s_appSelf; 0038 } 0039 0040 TikzKit::TikzKit() 0041 : QObject() 0042 , m_wrapper(new tikz::ui::Application(this)) 0043 { 0044 s_appSelf = this; 0045 0046 // document manager 0047 m_docManager = new DocumentManager(this); 0048 0049 // set our application wrapper 0050 tikz::ui::Editor::instance()->setApplication(m_wrapper); 0051 0052 // forward signal connections 0053 connect(this, SIGNAL(documentCreated(tikz::ui::Document *)), 0054 m_wrapper, SIGNAL(documentCreated(tikz::ui::Document *))); 0055 connect(this, SIGNAL(aboutToDeleteDocument(tikz::ui::Document *)), 0056 m_wrapper, SIGNAL(aboutToDeleteDocument(tikz::ui::Document *))); 0057 connect(this, SIGNAL(documentDeleted(tikz::ui::Document *)), 0058 m_wrapper, SIGNAL(documentDeleted(tikz::ui::Document *))); 0059 0060 // create a main window 0061 createMainWindow(); 0062 } 0063 0064 TikzKit::~TikzKit() 0065 { 0066 // delete now 0067 delete m_docManager; 0068 } 0069 0070 DocumentManager * TikzKit::documentManager() 0071 { 0072 return m_docManager; 0073 } 0074 0075 MainWindow * TikzKit::createMainWindow() 0076 { 0077 auto mainWindow = new MainWindow(); 0078 mainWindow->show(); 0079 0080 return mainWindow; 0081 } 0082 0083 void TikzKit::registerMainWindow(MainWindow * mainWin) 0084 { 0085 Q_ASSERT(! m_mainWindows.contains(mainWin)); 0086 m_mainWindows.append(mainWin); 0087 } 0088 0089 void TikzKit::unregisterMainWindow(MainWindow * mainWin) 0090 { 0091 Q_ASSERT(m_mainWindows.contains(mainWin)); 0092 m_mainWindows.remove(m_mainWindows.indexOf(mainWin)); 0093 } 0094 0095 QList<tikz::ui::MainWindow *> TikzKit::mainWindows() 0096 { 0097 // assemble right list 0098 QList<tikz::ui::MainWindow *> windows; 0099 for (auto window : qAsConst(m_mainWindows)) { 0100 windows.append(window->wrapper()); 0101 } 0102 return windows; 0103 } 0104 0105 tikz::ui::MainWindow * TikzKit::activeMainWindow() 0106 { 0107 return nullptr; 0108 } 0109 0110 QVector<tikz::ui::Document *> TikzKit::documents() 0111 { 0112 return documentManager()->documentList(); 0113 } 0114 0115 tikz::ui::Document * TikzKit::findUrl(const QUrl &url) 0116 { 0117 return nullptr; 0118 } 0119 0120 tikz::ui::Document * TikzKit::openUrl(const QUrl &url) 0121 { 0122 return nullptr; 0123 } 0124 0125 bool TikzKit::closeDocument(tikz::ui::Document *document) 0126 { 0127 return false; 0128 } 0129 0130 // kate: indent-width 4; replace-tabs on;