Skip to content

Commit 2fddef9

Browse files
committedDec 6, 2011
reindent main.cpp
1 parent 7c393cc commit 2fddef9

File tree

1 file changed

+137
-141
lines changed

1 file changed

+137
-141
lines changed
 

‎src/app/main.cpp

Lines changed: 137 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void myMessageOutput( QtMsgType type, const char *msg )
181181

182182
int main( int argc, char *argv[] )
183183
{
184-
QgsDebugMsg( QString( "Starting qgis main" ) );
184+
QgsDebugMsg( QString( "Starting qgis main" ) );
185185
#ifdef WIN32 // Windows
186186
#ifdef _MSC_VER
187187
_set_fmode( _O_BINARY );
@@ -190,11 +190,9 @@ QgsDebugMsg( QString( "Starting qgis main" ) );
190190
#endif // _MSC_VER
191191
#endif // WIN32
192192

193-
#ifndef ANDROID
194-
#ifndef _MSC_VER
195-
// Set up the custom qWarning/qDebug custom handler
196-
qInstallMsgHandler( myMessageOutput );
197-
#endif
193+
#if !defined(ANDROID) && !defined(_MSC_VER)
194+
// Set up the custom qWarning/qDebug custom handler
195+
qInstallMsgHandler( myMessageOutput );
198196
#endif
199197

200198
/////////////////////////////////////////////////////////////////
@@ -233,134 +231,11 @@ QgsDebugMsg( QString( "Starting qgis main" ) );
233231
// user settings (~/.qgis) and it will be used for QSettings INI file
234232
QString configpath;
235233

236-
#ifndef ANDROID
237-
#ifndef WIN32
238-
if ( !bundleclicked( argc, argv ) )
239-
{
240-
241-
////////////////////////////////////////////////////////////////
242-
// USe the GNU Getopts utility to parse cli arguments
243-
// Invokes ctor `GetOpt (int argc, char **argv, char *optstring);'
244-
///////////////////////////////////////////////////////////////
245-
int optionChar;
246-
while ( 1 )
247-
{
248-
static struct option long_options[] =
249-
{
250-
/* These options set a flag. */
251-
{"help", no_argument, 0, '?'},
252-
{"nologo", no_argument, 0, 'n'},
253-
{"noplugins", no_argument, 0, 'P'},
254-
{"nocustomization", no_argument, 0, 'C'},
255-
/* These options don't set a flag.
256-
* We distinguish them by their indices. */
257-
{"snapshot", required_argument, 0, 's'},
258-
{"width", required_argument, 0, 'w'},
259-
{"height", required_argument, 0, 'h'},
260-
{"lang", required_argument, 0, 'l'},
261-
{"project", required_argument, 0, 'p'},
262-
{"extent", required_argument, 0, 'e'},
263-
{"optionspath", required_argument, 0, 'o'},
264-
{"configpath", required_argument, 0, 'c'},
265-
{"android", required_argument, 0, 'a'},
266-
{0, 0, 0, 0}
267-
};
268-
269-
/* getopt_long stores the option index here. */
270-
int option_index = 0;
271-
272-
optionChar = getopt_long( argc, argv, "swhlpeoc",
273-
long_options, &option_index );
274-
QgsDebugMsg( QString( "Qgis main Debug" ) + optionChar );
275-
/* Detect the end of the options. */
276-
if ( optionChar == -1 )
277-
break;
278-
279-
switch ( optionChar )
280-
{
281-
case 0:
282-
/* If this option set a flag, do nothing else now. */
283-
if ( long_options[option_index].flag != 0 )
284-
break;
285-
printf( "option %s", long_options[option_index].name );
286-
if ( optarg )
287-
printf( " with arg %s", optarg );
288-
printf( "\n" );
289-
break;
290-
291-
case 's':
292-
mySnapshotFileName = QDir::convertSeparators( QFileInfo( QFile::decodeName( optarg ) ).absoluteFilePath() );
293-
break;
294-
295-
case 'w':
296-
mySnapshotWidth = QString( optarg ).toInt();
297-
break;
298-
299-
case 'h':
300-
mySnapshotHeight = QString( optarg ).toInt();
301-
break;
302-
303-
case 'n':
304-
myHideSplash = true;
305-
break;
306-
307-
case 'l':
308-
myTranslationCode = optarg;
309-
break;
310-
311-
case 'p':
312-
myProjectFileName = QDir::convertSeparators( QFileInfo( QFile::decodeName( optarg ) ).absoluteFilePath() );
313-
break;
314-
315-
case 'P':
316-
myRestorePlugins = false;
317-
break;
318-
319-
case 'C':
320-
myCustomization = false;
321-
break;
322-
323-
case 'e':
324-
myInitialExtent = optarg;
325-
break;
326-
327-
case 'o':
328-
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, optarg );
329-
break;
330-
331-
case 'c':
332-
configpath = optarg;
333-
break;
334-
335-
case '?':
336-
usage( argv[0] );
337-
return 2; // XXX need standard exit codes
338-
break;
339-
340-
default:
341-
QgsDebugMsg( QString( "%1: getopt returned character code %2" ).arg( argv[0] ).arg( optionChar ) );
342-
return 1; // XXX need standard exit codes
343-
}
344-
}
345-
346-
// Add any remaining args to the file list - we will attempt to load them
347-
// as layers in the map view further down....
348-
QgsDebugMsg( QString( "Files specified on command line: %1" ).arg( optind ) );
349-
if ( optind < argc )
350-
{
351-
while ( optind < argc )
352-
{
353-
#ifdef QGISDEBUG
354-
int idx = optind;
355-
QgsDebugMsg( QString( "%1: %2" ).arg( idx ).arg( argv[idx] ) );
356-
#endif
357-
myFileList.append( QDir::convertSeparators( QFileInfo( QFile::decodeName( argv[optind++] ) ).absoluteFilePath() ) );
358-
}
359-
}
360-
}
361-
#else
362-
for ( int i = 1; i < argc; i++ )
363-
{
234+
#if defined(ANDROID)
235+
QgsDebugMsg( QString( "Android: All params stripped" ) );// Param %1" ).arg( argv[0] ) );
236+
#elif defined(Q_WS_WIN)
237+
for ( int i = 1; i < argc; i++ )
238+
{
364239
QString arg = argv[i];
365240

366241
if ( arg == "--help" || arg == "-?" )
@@ -417,11 +292,132 @@ QgsDebugMsg( QString( "Starting qgis main" ) );
417292
{
418293
myFileList.append( QDir::convertSeparators( QFileInfo( QFile::decodeName( argv[i] ) ).absoluteFilePath() ) );
419294
}
295+
}
296+
#else
297+
if ( !bundleclicked( argc, argv ) )
298+
{
299+
300+
////////////////////////////////////////////////////////////////
301+
// Use the GNU Getopts utility to parse cli arguments
302+
// Invokes ctor `GetOpt (int argc, char **argv, char *optstring);'
303+
///////////////////////////////////////////////////////////////
304+
int optionChar;
305+
while ( 1 )
306+
{
307+
static struct option long_options[] =
308+
{
309+
/* These options set a flag. */
310+
{"help", no_argument, 0, '?'},
311+
{"nologo", no_argument, 0, 'n'},
312+
{"noplugins", no_argument, 0, 'P'},
313+
{"nocustomization", no_argument, 0, 'C'},
314+
/* These options don't set a flag.
315+
* We distinguish them by their indices. */
316+
{"snapshot", required_argument, 0, 's'},
317+
{"width", required_argument, 0, 'w'},
318+
{"height", required_argument, 0, 'h'},
319+
{"lang", required_argument, 0, 'l'},
320+
{"project", required_argument, 0, 'p'},
321+
{"extent", required_argument, 0, 'e'},
322+
{"optionspath", required_argument, 0, 'o'},
323+
{"configpath", required_argument, 0, 'c'},
324+
{"android", required_argument, 0, 'a'},
325+
{0, 0, 0, 0}
326+
};
327+
328+
/* getopt_long stores the option index here. */
329+
int option_index = 0;
330+
331+
optionChar = getopt_long( argc, argv, "swhlpeoc",
332+
long_options, &option_index );
333+
QgsDebugMsg( QString( "Qgis main Debug" ) + optionChar );
334+
/* Detect the end of the options. */
335+
if ( optionChar == -1 )
336+
break;
337+
338+
switch ( optionChar )
339+
{
340+
case 0:
341+
/* If this option set a flag, do nothing else now. */
342+
if ( long_options[option_index].flag != 0 )
343+
break;
344+
printf( "option %s", long_options[option_index].name );
345+
if ( optarg )
346+
printf( " with arg %s", optarg );
347+
printf( "\n" );
348+
break;
349+
350+
case 's':
351+
mySnapshotFileName = QDir::convertSeparators( QFileInfo( QFile::decodeName( optarg ) ).absoluteFilePath() );
352+
break;
353+
354+
case 'w':
355+
mySnapshotWidth = QString( optarg ).toInt();
356+
break;
357+
358+
case 'h':
359+
mySnapshotHeight = QString( optarg ).toInt();
360+
break;
361+
362+
case 'n':
363+
myHideSplash = true;
364+
break;
365+
366+
case 'l':
367+
myTranslationCode = optarg;
368+
break;
369+
370+
case 'p':
371+
myProjectFileName = QDir::convertSeparators( QFileInfo( QFile::decodeName( optarg ) ).absoluteFilePath() );
372+
break;
373+
374+
case 'P':
375+
myRestorePlugins = false;
376+
break;
377+
378+
case 'C':
379+
myCustomization = false;
380+
break;
381+
382+
case 'e':
383+
myInitialExtent = optarg;
384+
break;
385+
386+
case 'o':
387+
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, optarg );
388+
break;
389+
390+
case 'c':
391+
configpath = optarg;
392+
break;
393+
394+
case '?':
395+
usage( argv[0] );
396+
return 2; // XXX need standard exit codes
397+
break;
398+
399+
default:
400+
QgsDebugMsg( QString( "%1: getopt returned character code %2" ).arg( argv[0] ).arg( optionChar ) );
401+
return 1; // XXX need standard exit codes
402+
}
420403
}
421-
#endif //WIN32
422-
#else //ANDROID
423-
QgsDebugMsg( QString( "Android: All params stripped"));// Param %1" ).arg( argv[0] ) );
424-
#endif //ANDROID
404+
405+
// Add any remaining args to the file list - we will attempt to load them
406+
// as layers in the map view further down....
407+
QgsDebugMsg( QString( "Files specified on command line: %1" ).arg( optind ) );
408+
if ( optind < argc )
409+
{
410+
while ( optind < argc )
411+
{
412+
#ifdef QGISDEBUG
413+
int idx = optind;
414+
QgsDebugMsg( QString( "%1: %2" ).arg( idx ).arg( argv[idx] ) );
415+
#endif
416+
myFileList.append( QDir::convertSeparators( QFileInfo( QFile::decodeName( argv[optind++] ) ).absoluteFilePath() ) );
417+
}
418+
}
419+
}
420+
#endif
425421

426422

427423
/////////////////////////////////////////////////////////////////////
@@ -487,12 +483,12 @@ QgsDebugMsg( QString( "Starting qgis main" ) );
487483

488484
// Set the application style. If it's not set QT will use the platform style except on Windows
489485
// as it looks really ugly so we use QPlastiqueStyle.
490-
QString style = mySettings.value("/qgis/style").toString();
486+
QString style = mySettings.value( "/qgis/style" ).toString();
491487
if ( !style.isNull() )
492-
QApplication::setStyle( style );
488+
QApplication::setStyle( style );
493489
#ifdef Q_WS_WIN
494490
else
495-
QApplication::setStyle( new QPlastiqueStyle );
491+
QApplication::setStyle( new QPlastiqueStyle );
496492
#endif
497493

498494
/* Translation file for QGIS.

0 commit comments

Comments
 (0)
Please sign in to comment.