• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • program
program/program.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta program, made within the KDE community.
3 
4  Copyright 2006-2009,2011 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License as
8  published by the Free Software Foundation; either version 2 of
9  the License or (at your option) version 3 or any later version
10  accepted by the membership of KDE e.V. (or its successor approved
11  by the membership of KDE e.V.), which shall act as a proxy
12  defined in Section 14 of version 3 of the license.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #include "program.h"
24 
25 // program
26 #include "mainwindow.h"
27 // Okteta Kasten
28 #include <bytearraydocumentfactory.h>
29 #include <bytearrayviewfactory.h>
30 #include <filesystem/bytearrayrawfilesynchronizerfactory.h>
31 #include <bytearraystreamencoderconfigeditorfactoryfactory.h>
32 #include <bytearraydatageneratorconfigeditorfactoryfactory.h>
33 #include <bytearraystreamencoderfactory.h>
34 #include <bytearraydatageneratorfactory.h>
35 // tmp
36 #include <bytearrayviewprofilemanager.h>
37 // Kasten gui
38 #include <multidocumentstrategy.h>
39 #include <dialoghandler.h>
40 #include <viewmanager.h>
41 #include <modelcodecviewmanager.h>
42 // Kasten core
43 #include <documentmanager.h>
44 #include <documentcreatemanager.h>
45 #include <documentsyncmanager.h>
46 #include <modelcodecmanager.h>
47 // KDE
48 #include <KUrl>
49 #include <KCmdLineArgs>
50 #include <KApplication>
51 // Qt
52 #include <QtCore/QList>
53 
54 
55 namespace Kasten2
56 {
57 
58 // static const char OffsetOptionId[] = "offset";
59 // static const char OffsetOptionShortId[] = "o";
60 
61 #define CmdLineOptionName(STRING) QByteArray::fromRawData( STRING, sizeof(STRING)-1 )
62 
63 OktetaProgram::OktetaProgram( int argc, char* argv[] )
64  : mDocumentManager( new DocumentManager() ),
65  mViewManager( new ViewManager() ),
66  mDocumentStrategy( new MultiDocumentStrategy(mDocumentManager, mViewManager) ),
67  mDialogHandler( new DialogHandler() )
68 {
69  KCmdLineOptions programOptions;
70 // programOptions.add( OffsetOptionShortId );
71 // programOptions.add( OffsetOptionId, ki18n("Offset to set the cursor to"), 0 );
72  programOptions.add( CmdLineOptionName("+[URL(s)]"), ki18n("File(s) to load") );
73 
74  KCmdLineArgs::init( argc, argv, &mAboutData );
75  KCmdLineArgs::addCmdLineOptions( programOptions );
76 }
77 
78 
79 int OktetaProgram::execute()
80 {
81  KApplication programCore;
82 
83  // TODO:
84  mByteArrayViewProfileManager = new ByteArrayViewProfileManager();
85  //mModelManagerManager->addModelManager( byteArrayViewProfileManager );
86 
87  const QList<AbstractModelStreamEncoder*> encoderList =
88  ByteArrayStreamEncoderFactory::createStreamEncoders();
89 
90  const QList<AbstractModelDataGenerator*> generatorList =
91  ByteArrayDataGeneratorFactory::createDataGenerators();
92 
93  const QList<AbstractModelStreamEncoderConfigEditorFactory*> encoderConfigEditorFactoryList =
94  ByteArrayStreamEncoderConfigEditorFactoryFactory::createFactorys();
95 
96  const QList<AbstractModelDataGeneratorConfigEditorFactory*> generatorConfigEditorFactoryList =
97  ByteArrayDataGeneratorConfigEditorFactoryFactory::createFactorys();
98 
99  mDocumentManager->codecManager()->setEncoders( encoderList );
100  mDocumentManager->codecManager()->setGenerators( generatorList );
101  mDocumentManager->codecManager()->setOverwriteDialog( mDialogHandler );
102  mDocumentManager->createManager()->setDocumentFactory( new ByteArrayDocumentFactory() );
103  mDocumentManager->syncManager()->setDocumentSynchronizerFactory( new ByteArrayRawFileSynchronizerFactory() );
104  mDocumentManager->syncManager()->setOverwriteDialog( mDialogHandler );
105  mDocumentManager->syncManager()->setSaveDiscardDialog( mDialogHandler );
106 
107  mViewManager->setViewFactory( new ByteArrayViewFactory(mByteArrayViewProfileManager) );
108  mViewManager->codecViewManager()->setEncoderConfigEditorFactories( encoderConfigEditorFactoryList );
109  mViewManager->codecViewManager()->setGeneratorConfigEditorFactories( generatorConfigEditorFactoryList );
110 
111  OktetaMainWindow* mainWindow = new OktetaMainWindow( this );
112  mDialogHandler->setWidget( mainWindow );
113 
114  // started by session management?
115  if( programCore.isSessionRestored() && KMainWindow::canBeRestored(1) )
116  {
117  mainWindow->restore( 1 );
118  }
119  else
120  {
121  // no session.. just start up normally
122  KCmdLineArgs* arguments = KCmdLineArgs::parsedArgs();
123 
124  // take arguments
125  if( arguments->count() > 0 )
126  {
127  for( int i=0; i<arguments->count(); ++i )
128  mDocumentStrategy->load( arguments->url(i) );
129  }
130 
131  mainWindow->show();
132 
133  arguments->clear();
134  }
135 
136  return programCore.exec();
137 }
138 
139 
140 void OktetaProgram::quit()
141 {
142  kapp->quit();
143 }
144 
145 
146 OktetaProgram::~OktetaProgram()
147 {
148  delete mDocumentStrategy;
149  delete mDocumentManager;
150  delete mViewManager;
151  delete mDialogHandler;
152  delete mByteArrayViewProfileManager;
153 }
154 
155 }
documentsyncmanager.h
modelcodecmanager.h
documentmanager.h
bytearraydatageneratorfactory.h
dialoghandler.h
bytearrayviewprofilemanager.h
bytearraystreamencoderconfigeditorfactoryfactory.h
bytearraydocumentfactory.h
mainwindow.h
multidocumentstrategy.h
bytearraystreamencoderfactory.h
bytearrayviewfactory.h
CmdLineOptionName
#define CmdLineOptionName(STRING)
Definition: program/program.cpp:61
documentcreatemanager.h
bytearrayrawfilesynchronizerfactory.h
bytearraydatageneratorconfigeditorfactoryfactory.h
Kasten2::OktetaProgram::OktetaProgram
OktetaProgram(int argc, char *argv[])
Definition: mobile/program/program.cpp:60
program.h
modelcodecviewmanager.h
viewmanager.h
QList
Definition: bookmarkable.h:29
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal