MCPcopy Create free account
hub / github.com/KDE/kdevelop / pathToIndex

Method pathToIndex

kdevplatform/project/projectmodel.cpp:873–906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

871}
872
873QModelIndex ProjectModel::pathToIndex(const QStringList& tofetch_) const
874{
875 if(tofetch_.isEmpty())
876 return QModelIndex();
877 QStringList tofetch(tofetch_);
878 if(tofetch.last().isEmpty())
879 tofetch.removeLast();
880
881 QModelIndex current=index(0,0, QModelIndex());
882
883 QModelIndex ret;
884 for(int a = 0; a < tofetch.size(); ++a)
885 {
886 const QString& currentName = tofetch[a];
887
888 bool matched = false;
889 const QModelIndexList l = match(current, Qt::DisplayRole, currentName, -1, Qt::MatchExactly);
890 for (const QModelIndex& idx : l) {
891 //If this is not the last item, only match folders, as there may be targets and folders with the same name
892 if(a == tofetch.size()-1 || itemFromIndex(idx)->folder()) {
893 ret = idx;
894 current = index(0,0, ret);
895 matched = true;
896 break;
897 }
898 }
899 if(!matched) {
900 ret = QModelIndex();
901 break;
902 }
903 }
904 Q_ASSERT(!ret.isValid() || data(ret).toString()==tofetch.last());
905 return ret;
906}
907
908QStringList ProjectModel::pathFromIndex(const QModelIndex& index) const
909{

Callers 11

findItemMethod · 0.80
validateMethod · 0.80
currentItemMethod · 0.80
testCreateTargetItemsMethod · 0.80
itemForPathFunction · 0.80
indexFromConfigStringMethod · 0.80
itemForPathFunction · 0.80
dependencyJobMethod · 0.80
executableMethod · 0.80
calculateDependenciesMethod · 0.80

Calls 10

folderMethod · 0.80
QModelIndexClass · 0.50
indexFunction · 0.50
matchFunction · 0.50
dataFunction · 0.50
isEmptyMethod · 0.45
lastMethod · 0.45
sizeMethod · 0.45
isValidMethod · 0.45
toStringMethod · 0.45

Tested by 2

testCreateTargetItemsMethod · 0.64