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(
this );
57 pyLexer->setDefaultFont( font );
58 pyLexer->setFont( font, -1 );
59 pyLexer->setColor( Qt::red, QsciLexerPython::Comment );
60 pyLexer->setColor( Qt::darkGreen, QsciLexerPython::Keyword );
61 pyLexer->setColor( Qt::darkBlue, QsciLexerPython::Decorator );
63 QsciAPIs* apis =
new QsciAPIs( pyLexer );
73 apis->loadPrepared( mPapFile );
75 else if ( mAPISFilesList.
length() == 1 && mAPISFilesList[0].right( 3 ) ==
"pap" )
82 mPapFile = mAPISFilesList[0];
83 apis->loadPrepared( mPapFile );
87 for (
int i = 0; i < mAPISFilesList.
size(); i++ )
96 apis->load( mAPISFilesList[i] );
100 pyLexer->setAPIs( apis );
111 mAPISFilesList = filenames;
119 QFile file( script );
120 if ( !file.
open( QIODevice::ReadOnly ) )
bool loadScript(const QString &script)
Load a script file.
A text editor based on QScintilla2.
void setFoldingVisible(bool folding)
Set folding visible state.
const T & at(int i) const
QgsCodeEditorPython(QWidget *parent=nullptr, const QList< QString > &filenames=QList< QString >())
Construct a new Python editor.
void loadAPIs(QList< QString > const &filenames)
Load APIs from one or more files.
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
static QString pkgDataPath()
Returns the common root path of all application data directories.
void setMarginVisible(bool margin)
Set margin visible state.
void setTitle(const QString &title)
Set the widget title.