24 #include <QMessageBox>
25 #include <QTextStream>
26 #include <Qsci/qscilexerpython.h>
30 , mAPISFilesList( filenames )
43 void QgsCodeEditorPython::setSciLexerPython()
48 setEdgeMode( QsciScintilla::EdgeLine );
50 setEdgeColor( QColor(
"#FF0000" ) );
52 setWhitespaceVisibility( QsciScintilla::WsVisibleAfterIndent );
56 QsciLexerPython* pyLexer =
new QsciLexerPython();
57 pyLexer->setDefaultFont( font );
58 pyLexer->setFont( font, 1 );
59 pyLexer->setFont( font, 3 );
60 pyLexer->setFont( font, 4 );
61 pyLexer->setFont( font, 6 );
62 pyLexer->setColor( Qt::red, 1 );
63 pyLexer->setColor( Qt::darkGreen, 5 );
64 pyLexer->setColor( Qt::darkBlue, 15 );
66 QsciAPIs* apis =
new QsciAPIs( pyLexer );
73 if ( mAPISFilesList.isEmpty() )
76 apis->loadPrepared( mPapFile );
78 else if ( mAPISFilesList.length() == 1 && mAPISFilesList[0].right( 3 ) ==
"pap" )
80 if ( !QFileInfo( mAPISFilesList[0] ).exists() )
82 QgsDebugMsg( QString(
"The apis file %1 not found" ).arg( mAPISFilesList[0] ) );
85 mPapFile = mAPISFilesList[0];
86 apis->loadPrepared( mPapFile );
90 for (
int i = 0; i < mAPISFilesList.size(); i++ )
92 if ( !QFileInfo( mAPISFilesList[i] ).exists() )
94 QgsDebugMsg( QString(
"The apis file %1 was not found" ).arg( mAPISFilesList[i] ) );
99 apis->load( mAPISFilesList[i] );
103 pyLexer->setAPIs( apis );
114 mAPISFilesList = filenames;
121 QgsDebugMsg( QString(
"The script file: %1" ).arg( script ) );
122 QFile
file( script );
123 if ( !file.open( QIODevice::ReadOnly ) )
128 QTextStream in( &file );
130 setText( in.readAll() );