MCPcopy Create free account
hub / github.com/baldurk/renderdoc / location_keyPress

Method location_keyPress

qrenderdoc/Windows/EventBrowser.cpp:5898–6028  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5896}
5897
5898void EventBrowser::location_keyPress(QKeyEvent *e)
5899{
5900 if(e->key() == Qt::Key_Escape)
5901 {
5902 return location_leave();
5903 }
5904 if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter)
5905 {
5906 // if the text hasn't changed (ignoring any whitespace added) don't move
5907 if(m_BreadcrumbLocationText->text().trimmed() == m_InitialBreadcrumbLocation)
5908 return location_leave();
5909
5910 QString locationText = m_BreadcrumbLocationText->text();
5911
5912 // split naively by /
5913 QStringList elements = locationText.split(QLatin1Char('/'));
5914
5915 // for each split string, combine any that end with a \ because that means it was an escaped
5916 // slash like foo\/bar
5917 for(int i = 0; i < elements.count(); i++)
5918 {
5919 if(elements[i][elements[i].count() - 1] == QLatin1Char('\\'))
5920 {
5921 elements[i] += elements[i + 1];
5922 elements.removeAt(i + 1);
5923 continue;
5924 }
5925 }
5926
5927 // unescape
5928 for(QString &el : elements)
5929 {
5930 el.replace(lit("\\/"), lit("/"));
5931 el.replace(lit("\\\\"), lit("\\"));
5932 }
5933
5934 const ActionDescription *curAction = NULL;
5935 const rdcarray<ActionDescription> *actions = &m_Ctx.CurRootActions();
5936
5937 while(!elements.isEmpty())
5938 {
5939 QString el = elements.front().trimmed();
5940 elements.pop_front();
5941
5942 // ignore empty elements (so foo//bar is equivalent to foo/bar is equivalent to /foo/bar)
5943 if(el.isEmpty())
5944 continue;
5945
5946 // try finding an exact name match first
5947 bool found = false;
5948 for(size_t i = 0; i < actions->size(); i++)
5949 {
5950 QString name = actions->at(i).GetName(m_Ctx.GetStructuredFile());
5951 if(name == el)
5952 {
5953 found = true;
5954 curAction = &actions->at(i);
5955 actions = &curAction->children;

Callers

nothing calls this directly

Calls 15

QLatin1CharClass · 0.85
criticalFunction · 0.85
GetSelectedEIDFunction · 0.85
GetEffectiveEIDFunction · 0.85
trimmedMethod · 0.80
setFocusMethod · 0.80
selectAllMethod · 0.80
GetIndexForEIDMethod · 0.80
trFunction · 0.50
keyMethod · 0.45
textMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected