• 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
  • mobile
  • program
mobile/program/program.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Mobile program, made within the KDE community.
3 
4  Copyright 2010 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 // Kasten gui
36 #include <dialoghandler.h>
37 #include <viewmanager.h>
38 // #include <modelcodecviewmanager.h>
39 // Kasten core
40 #include <documentmanager.h>
41 #include <documentcreatemanager.h>
42 #include <documentsyncmanager.h>
43 #include <modelcodecmanager.h>
44 // KDE
45 #include <KLocale>
46 #include <KUrl>
47 #include <KCmdLineArgs>
48 #include <KApplication>
49 // Qt
50 #include <QtCore/QList>
51 
52 
53 namespace Kasten2
54 {
55 
56 // static const char OffsetOptionId[] = "offset";
57 // static const char OffsetOptionShortId[] = "o";
58 
59 
60 OktetaProgram::OktetaProgram( int argc, char *argv[] )
61  : mDocumentManager( new DocumentManager() ),
62  mViewManager( new ViewManager() ),
63  mUnusedMainWindow( 0 ),
64  mDialogHandler( new DialogHandler() )
65 {
66  KCmdLineOptions programOptions;
67 // programOptions.add( OffsetOptionShortId );
68 // programOptions.add( OffsetOptionId, ki18n("Offset to set the cursor to"), 0 );
69  programOptions.add( "+[URL(s)]", ki18n("File(s) to load"), 0 );
70 
71  KCmdLineArgs::init( argc, argv, &mAboutData );
72  KCmdLineArgs::addCmdLineOptions( programOptions );
73 }
74 
75 
76 int OktetaProgram::execute()
77 {
78  KApplication programCore;
79 
80  connect( mDocumentManager, SIGNAL(added(QList<Kasten2::AbstractDocument*>)),
81  mViewManager, SLOT(createViewsFor(QList<Kasten2::AbstractDocument*>)) );
82  connect( mDocumentManager, SIGNAL(closing(QList<Kasten2::AbstractDocument*>)),
83  mViewManager, SLOT(removeViewsFor(QList<Kasten2::AbstractDocument*>)) );
84  connect( mViewManager, SIGNAL(opened(QList<Kasten2::AbstractView*>)),
85  SLOT(onViewsOpened(QList<Kasten2::AbstractView*>)) );
86  connect( mViewManager, SIGNAL(closing(QList<Kasten2::AbstractView*>)),
87  SLOT(onViewsClosing(QList<Kasten2::AbstractView*>)) );
88 
89 // const QList<AbstractModelStreamEncoder*> encoderList =
90 // ByteArrayStreamEncoderFactory::createStreamEncoders();
91 
92 // const QList<AbstractModelDataGenerator*> generatorList =
93 // ByteArrayDataGeneratorFactory::createDataGenerators();
94 
95 // const QList<AbstractModelStreamEncoderConfigEditorFactory*> encoderConfigEditorFactoryList =
96 // ByteArrayStreamEncoderConfigEditorFactoryFactory::createFactorys();
97 
98 // const QList<AbstractModelDataGeneratorConfigEditorFactory*> generatorConfigEditorFactoryList =
99 // ByteArrayDataGeneratorConfigEditorFactoryFactory::createFactorys();
100 
101 // mDocumentManager->codecManager()->setEncoders( encoderList );
102 // mDocumentManager->codecManager()->setGenerators( generatorList );
103 // mDocumentManager->codecManager()->setOverwriteDialog( mDialogHandler );
104  mDocumentManager->createManager()->setDocumentFactory( new ByteArrayDocumentFactory() );
105  mDocumentManager->syncManager()->setDocumentSynchronizerFactory( new ByteArrayRawFileSynchronizerFactory() );
106  mDocumentManager->syncManager()->setOverwriteDialog( mDialogHandler );
107  mDocumentManager->syncManager()->setSaveDiscardDialog( mDialogHandler );
108 
109  mViewManager->setViewFactory( new ByteArrayViewFactory() );
110 // mViewManager->codecViewManager()->setEncoderConfigEditorFactories( encoderConfigEditorFactoryList );
111 // mViewManager->codecViewManager()->setGeneratorConfigEditorFactories( generatorConfigEditorFactoryList );
112 
113  // started by session management?
114  if( false ) //programCore.isSessionRestored() )
115  {
116 // RESTORE( OktetaMainWindow(this) );
117  }
118  else
119  {
120  // no session.. just start up normally
121  OktetaMainWindow* mainWindow = new OktetaMainWindow( this );
122  mUnusedMainWindow = mainWindow;
123 
124  KCmdLineArgs* arguments = KCmdLineArgs::parsedArgs();
125 
126  // take arguments
127  if( arguments->count() > 0 )
128  {
129 // int offset = -1;
130 // if( arguments->isSet(OffsetOptionId) )
131 // {
132 // const QString offsetOptionArgument = arguments->getOption( OffsetOptionId );
133 // offset = readOut( offsetOptionArgument );
134 // }
135 
136  DocumentSyncManager* syncManager = mDocumentManager->syncManager();
137  for( int i=0; i<arguments->count(); ++i )
138  {
139  syncManager->load( arguments->url(i) );
140  // TODO: set view to offset
141  // if( offset != -1 )
142  }
143  }
144 
145  // TODO: what to do with multiple mainWindows?
146  mDialogHandler->setWidget( mainWindow );
147  mainWindow->show();
148 
149  arguments->clear();
150  }
151 
152  return programCore.exec();
153 }
154 
155 
156 
157 void OktetaProgram::quit()
158 {
159  kapp->quit();
160 }
161 
162 void OktetaProgram::onViewsOpened( const QList<Kasten2::AbstractView*>& views )
163 {
164  foreach( AbstractView* view, views )
165  {
166  if( mUnusedMainWindow ) {
167  mUnusedMainWindow->setView( view );
168  mUnusedMainWindow = 0;
169  }
170  else
171  {
172  OktetaMainWindow* mainWindow = new OktetaMainWindow( this );
173  mainWindow->setView( view );
174  mainWindow->show();
175  }
176  }
177 
178 }
179 
180 
181 OktetaProgram::~OktetaProgram()
182 {
183  delete mDocumentManager;
184  delete mViewManager;
185  delete mDialogHandler;
186 }
187 
188 }
Kasten2::AbstractView
Definition: abstractview.h:38
Kasten2::ByteArrayViewFactory
Definition: bytearrayviewfactory.h:37
documentsyncmanager.h
Kasten2::ByteArrayRawFileSynchronizerFactory
Definition: bytearrayrawfilesynchronizerfactory.h:35
Kasten2::DocumentSyncManager::load
void load(const KUrl &url)
Definition: documentsyncmanager.cpp:90
modelcodecmanager.h
documentmanager.h
Kasten2::OktetaProgram::quit
void quit()
Definition: mobile/program/program.cpp:157
Kasten2::ViewManager::setViewFactory
void setViewFactory(AbstractViewFactory *factory)
Definition: viewmanager.cpp:45
dialoghandler.h
Kasten2::DocumentSyncManager::setOverwriteDialog
void setOverwriteDialog(AbstractOverwriteDialog *overwriteDialog)
Definition: documentsyncmanager.cpp:61
Kasten2::OktetaProgram::mDialogHandler
DialogHandler * mDialogHandler
Definition: mobile/program/program.h:68
Kasten2::ViewManager
Definition: viewmanager.h:40
program.h
Kasten2::DocumentCreateManager::setDocumentFactory
void setDocumentFactory(AbstractDocumentFactory *factory)
Definition: documentcreatemanager.cpp:47
bytearraydocumentfactory.h
Kasten2::DialogHandler::setWidget
void setWidget(QWidget *widget)
Definition: dialoghandler.cpp:39
Kasten2::OktetaProgram::mAboutData
OktetaAboutData mAboutData
Definition: mobile/program/program.h:61
Kasten2::OktetaProgram::mViewManager
ViewManager * mViewManager
Definition: mobile/program/program.h:64
Kasten2::DialogHandler
Definition: dialoghandler.h:38
mainwindow.h
Kasten2::OktetaMainWindow
Definition: mobile/program/mainwindow.h:36
bytearrayviewfactory.h
Kasten2::OktetaProgram::onViewsOpened
void onViewsOpened(const QList< Kasten2::AbstractView * > &views)
Definition: mobile/program/program.cpp:162
Kasten2::OktetaProgram::execute
int execute()
Definition: mobile/program/program.cpp:76
Kasten2::OktetaProgram::mDocumentManager
DocumentManager * mDocumentManager
Definition: mobile/program/program.h:63
Kasten2::OktetaProgram::mUnusedMainWindow
OktetaMainWindow * mUnusedMainWindow
Definition: mobile/program/program.h:66
Kasten2::DocumentSyncManager::setSaveDiscardDialog
void setSaveDiscardDialog(AbstractSaveDiscardDialog *saveDiscardDialog)
Definition: documentsyncmanager.cpp:56
documentcreatemanager.h
bytearrayrawfilesynchronizerfactory.h
Kasten2::ByteArrayDocumentFactory
Definition: bytearraydocumentfactory.h:35
Kasten2::OktetaProgram::OktetaProgram
OktetaProgram(int argc, char *argv[])
Definition: mobile/program/program.cpp:60
Kasten2::DocumentManager::syncManager
DocumentSyncManager * syncManager()
Definition: documentmanager.h:108
viewmanager.h
Kasten2::DocumentSyncManager
Definition: documentsyncmanager.h:45
Kasten2::DocumentManager::createManager
DocumentCreateManager * createManager()
Definition: documentmanager.h:107
Kasten2::DocumentSyncManager::setDocumentSynchronizerFactory
void setDocumentSynchronizerFactory(AbstractModelSynchronizerFactory *synchronizerFactory)
Definition: documentsyncmanager.cpp:85
Kasten2::DocumentManager
Definition: documentmanager.h:44
Kasten2::OktetaProgram::~OktetaProgram
virtual ~OktetaProgram()
Definition: mobile/program/program.cpp:181
Kasten2::MobileShellWindow::setView
void setView(AbstractView *view)
Definition: mobileshellwindow.cpp:45
QList< Kasten2::AbstractDocument * >
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