bool HistoryView::filterRightButtonPressed(QMouseEvent* e) { QModelIndex index = indexAt(e->pos()); SCRef selSha = sha(index.row()); if (selSha.isEmpty()) return false; if (e->modifiers() == Qt::ControlModifier) { // check for 'diff to' function if (selSha != ZERO_SHA && st->sha() != ZERO_SHA) { if (selSha != st->diffToSha()) st->setDiffToSha(selSha); else st->setDiffToSha(""); // restore std view filterNextContextMenuRequest = true; UPDATE_DOMAIN(d); return true; // filter event out } } // check for 'children & parents' function, i.e. if mouse is on the graph if (index.column() == GRAPH_COL) { filterNextContextMenuRequest = true; QStringList parents, children; if (getLaneParentsChilds(selSha, e->pos().x(), parents, children)) emit lanesContextMenuRequested(parents, children); return true; // filter event out } return false; }
int Git::findFileIndex(const RevFile& rf, SCRef name) { if (name.isEmpty()) return -1; int idx = name.lastIndexOf('/') + 1; SCRef dr = name.left(idx); SCRef nm = name.mid(idx); for (uint i = 0, cnt = rf.count(); i < cnt; ++i) { if (fileNamesVec[rf.nameAt(i)] == nm && dirNamesVec[rf.dirAt(i)] == dr) return i; } return -1; }
const QString Git::getWorkDirDiff(SCRef fileName) { QString runCmd("git diff-index --no-color -r -z -m -p --full-index --no-commit-id HEAD"), runOutput; if (!fileName.isEmpty()) runCmd.append(" -- " + quote(fileName)); if (!run(runCmd, &runOutput)) return ""; /* For unknown reasons file sha of index is not ZERO_SHA but a value of unknown origin. Replace that with ZERO_SHA so to not fool annotate */ int idx = runOutput.indexOf(".."); if (idx != -1) runOutput.replace(idx + 2, 40, ZERO_SHA); return runOutput; }
const QString Git::getRevInfo(SCRef sha) { if (sha.isEmpty()) return ""; uint type = checkRef(sha); if (type == 0) return ""; QString refsInfo; if (type & BRANCH) { const QString cap(type & CUR_BRANCH ? "HEAD: " : "Branch: "); refsInfo = cap + getRefName(sha, BRANCH).join(" "); } if (type & RMT_BRANCH) refsInfo.append(" Remote branch: " + getRefName(sha, RMT_BRANCH).join(" ")); if (type & TAG) refsInfo.append(" Tag: " + getRefName(sha, TAG).join(" ")); if (type & REF) refsInfo.append(" Ref: " + getRefName(sha, REF).join(" ")); if (type & APPLIED) refsInfo.append(" Patch: " + getRefName(sha, APPLIED).join(" ")); if (type & UN_APPLIED) refsInfo.append(" Patch: " + getRefName(sha, UN_APPLIED).join(" ")); if (type & TAG) { SCRef msg(getTagMsg(sha)); if (!msg.isEmpty()) refsInfo.append(" [" + msg + "]"); } return refsInfo.trimmed(); }