projectview implements project parser that is controlled by simple regular expression rules. This allows you to build a dynamic hierarchy of your software project for whatever language or application you desire, and provides a colorful, themeable tree widget for displaying it.
Here, projectview is showing a Spin language project.
projectview notifies the user when there is a circular dependency in inclusion.
It will also tell you when a file was not found.
projectview can be searched.
Parser parser; parser.setCaseInsensitive(true);
To use projectview, you need to provide a filename and additional search paths for locating local dependencies.
parser.setFile("../../Pikemanz/00_Pikemanz.spin"); parser.setLibraryPaths(QStringList() << "../../../");
To use projectview, you must build a description of the
language elements you’d like to to display. This is done using the
A special Rule is defined for declaring file dependencies:
Using this variable will result in projectview looking in the file system
for the string you extract from the source file.
Each rule can hold multiple patterns for languages that support multiple variations of a syntax with the same meaning.
Rules are created by passing a list of patterns to the
so let’s create a list of patterns.
Then, we create a Pattern.
Pattern contains a regular expression and a list
of values that describe how to extract the string.
To extract any data at all, your regular expression must contain unnamed pattern groups to extract.
pattern.regex = "^[ \t]*([a-zA-Z_]+[a-zA-Z0-9_]*)[ \t]*=[ \t]*(.+?)('.*?)?[ \t]*$";
capture is a
QList<QVariant object that can hold either
QString. If an int, it will capture a group from the regular expression. If
a QString, the string will be added to the result.
pattern.capture << 1 << " returns " << 2;
Now add the pattern to the list.
Provide a name, icon, and color for display.
parser.addRule("constants",patterns, QIcon(":/icons/projectview/block-pub.png"), QColor("#0000FF"));
Now use the
getModel() function to display your project with a
QTreeView *tree= new QTreeView(); tree->setModel(parser.getModel()); tree->show();