File indexing completed on 2024-04-28 16:24:35

0001 /* This file is part of the KDE project
0002    Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This library 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 GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 // clazy:excludeall=qstring-arg
0021 #include "kptfactory.h"
0022 #include "kptmaindocument.h"
0023 #include "kptpart.h"
0024 #include "kptaboutdata.h"
0025 
0026 #include <KoResourcePaths.h>
0027 #include <KoDockRegistry.h>
0028 #include <KoComponentData.h>
0029 
0030 #include <kiconloader.h>
0031 
0032 #include <QTimer>
0033 
0034 namespace KPlato
0035 {
0036 
0037 KoComponentData* Factory::s_global = 0L;
0038 KAboutData* Factory::s_aboutData = 0L;
0039 
0040 Factory::Factory()
0041     : KPluginFactory()
0042 {
0043     global();
0044 }
0045 
0046 Factory::~Factory()
0047 {
0048     delete s_aboutData;
0049     s_aboutData = 0L;
0050     delete s_global;
0051     s_global = 0L;
0052 }
0053 
0054 QObject* Factory::create(const char* /*iface*/, QWidget* /*parentWidget*/, QObject *parent,
0055                              const QVariantList& args, const QString& keyword)
0056 {
0057     Q_UNUSED(args);
0058     Q_UNUSED(keyword);
0059 
0060     Part *part = new Part(parent);
0061     MainDocument *doc = new MainDocument(part);
0062     part->setDocument(doc);
0063 
0064     // start checking for workpackages
0065     QTimer *timer = new QTimer(doc);
0066     connect(timer, &QTimer::timeout, doc, &MainDocument::autoCheckForWorkPackages);
0067     timer->start(5000);
0068 
0069     return part;
0070 }
0071 
0072 KAboutData* Factory::aboutData()
0073 {
0074     if (!s_aboutData)
0075         s_aboutData = newAboutData();
0076     return s_aboutData;
0077 }
0078 
0079 const KoComponentData &Factory::global()
0080 {
0081     if (!s_global)
0082     {
0083         debugPlan;
0084         s_global = new KoComponentData(*aboutData());
0085 
0086         // Add any application-specific resource directories here
0087         KoResourcePaths::addResourceType("calligraplan_taskmodules", "data", "calligraplan/taskmodules/");
0088 
0089         // Tell the iconloader about share/apps/calligra/icons
0090 //        KIconLoader::global()->addAppDir("calligra");
0091 
0092 //        KoDockRegistry *dockRegistry = KoDockRegistry::instance();
0093 //        dockRegistry->remove("StencilBox"); //don't want this in plan
0094     }
0095     return *s_global;
0096 }
0097 
0098 } // KPlato namespace