30 std::vector<std::string> builtins_std;
32 for (
unsigned int i = 0; i < builtins_std.size(); i++)
builtins.push_back(QString(builtins_std[i].c_str()));
67 static QColor variableColor = QColor(100, 200, 250), functionColor = QColor(100, 250, 200),
68 backgroundColor(50, 50, 50);
70 if (!
index.isValid())
return QVariant();
71 int row =
index.row(), column =
index.column();
73 int functions_offset =
builtins.size();
74 int variables_offset = functions_offset +
functions.size();
75 int local_variables_offset = variables_offset +
variables.size();
77 if (role == Qt::BackgroundRole)
return backgroundColor;
79 if (role == Qt::FontRole && column == 0) {
85 if (row < functions_offset) {
87 if (role == Qt::DisplayRole || role == Qt::EditRole) {
92 }
else if (role == Qt::ForegroundRole)
94 }
else if (row < variables_offset) {
95 int index = row - functions_offset;
96 if (role == Qt::DisplayRole || role == Qt::EditRole) {
101 }
else if (role == Qt::ForegroundRole)
102 return functionColor;
103 }
else if (row < local_variables_offset) {
104 int index = row - variables_offset;
105 if (role == Qt::DisplayRole || role == Qt::EditRole) {
108 else if (column == 1)
110 }
else if (role == Qt::ForegroundRole)
111 return variableColor;
112 }
else if (row < local_variables_offset + (
int)
local_variables.size()) {
113 int index = row - local_variables_offset;
114 if (role == Qt::DisplayRole || role == Qt::EditRole) {
117 else if (column == 1)
118 return QVariant(
"Local");
119 }
else if (role == Qt::ForegroundRole)
120 return variableColor;
std::vector< QString > local_variables
static std::vector< QString > builtins
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
std::vector< QString > functions
std::vector< QString > variables
std::vector< QString > functions_comment
QString getFirstLine(const std::string &all) const
QModelIndex index(int row, int column, const QModelIndex &) const
QString getDocString(const QString &s)
ExprCompletionModel(QObject *parent=0)
void syncExtras(const ExprCompletionModel &otherModel)
void addVariable(const QString &str, const QString &comment)
std::vector< QString > variables_comment
void addFunction(const QString &function, const QString &docString)
std::map< QString, int > functionNameToFunction
static std::string getDocString(const char *functionName)
Get doc string for a specific function.
static void getFunctionNames(std::vector< std::string > &names)
Get a list of registered builtin and DSO generated functions.
The result is computed int int< br >< div style="margin-left: 40px;"> Picks values randomly between loRange and hiRange based on supplied index(which is automatically hashed).