Exemple #1
0
void TreeView::on_currentItemChanged(QTreeWidgetItem* item, QTreeWidgetItem*)
{
    if (item) {
        SCRef fn = ((FileItem*)item)->fullName();
        if (!ignoreCurrentChanged && fn != st->fileName()) {
            st->setFileName(fn);
            st->setSelectItem(true);
            UPDATE_DOMAIN(d);
        }
    }
}
Exemple #2
0
void FileList::on_currentItemChanged(QListWidgetItem* current, QListWidgetItem*) {

	if (!current)
		return;

	if (st->isMerge() && row(current) == 0) { // header clicked

		// In a listbox without current item, as soon as the box
		// gains focus the first item becomes the current item
		// and a spurious currentChanged() signal is sent.
		// In case of a merge the signal arrives here and fakes
		// the user clicking on the header.
		//
		// The problem arise when user clicks on a merge header,
		// then list box gains focus and current item becomes null
		// because the content of the list is cleared and updated.
		//
		// If now tab is changed list box loose the focus and,
		// upon changing back again the tab the signal triggers
		// because Qt gives back the focus to the listbox.
		//
		// The workaround here is to give the focus away as soon
		// as the user clicks on the merge header. Note that a
		// lb->clearFocus() is not enough, we really need to
		// reassign the focus to someone else.
		d->tabPage()->setFocus();
		st->setAllMergeFiles(!st->allMergeFiles());

	} else {
		QString fileName(currentText());
		git->removeExtraFileInfo(&fileName);
		// if we are called by updateFileList() fileName is already updated
		if (st->fileName() == fileName) // avoid loops
			return;

		st->setFileName(fileName);
	}
	st->setSelectItem(true);
	UPDATE_DOMAIN(d);
}