~ubuntu-branches/ubuntu/quantal/kdevplatform/quantal-proposed

« back to all changes in this revision

Viewing changes to plugins/projectmanagerview/projectmanagerview.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-09-03 19:38:03 UTC
  • mfrom: (0.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100903193803-5hovukzkuu36ul4f
Tags: 1.0.2-0ubuntu1
* New upstream release
  - Don't ship kdevplatform-l10n-de, German translation is missing from
    upstream, German dropped below the threshold of translated strings

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
    // We should _never_ get a null pointer for the document, as
169
169
    // the action is only enabled when there is an active document.
170
170
    Q_ASSERT(doc); 
171
 
   
 
171
 
 
172
    QModelIndex bestMatch;
172
173
    foreach (IProject* proj, ICore::self()->projectController()->projects()) {
173
174
        foreach (KDevelop::ProjectFileItem* item, proj->filesForUrl(doc->url())) {
174
175
            QModelIndex index = m_modelFilter->proxyIndexFromItem(item);
175
176
            if (index.isValid()) {
176
 
                m_ui->projectTreeView->setCurrentIndex(index);
177
 
                m_ui->projectTreeView->expand(index);
178
 
                m_ui->projectTreeView->scrollTo(index);
179
 
                return;
 
177
                if (!bestMatch.isValid()) {
 
178
                    bestMatch = index;
 
179
                } else if (KDevelop::ProjectFolderItem* folder = dynamic_cast<KDevelop::ProjectFolderItem*>(item->parent())) {
 
180
                    // prefer files in their real folders over the 'copies' in the target folders
 
181
                    if (!folder->target()) {
 
182
                        bestMatch = index;
 
183
                        break;
 
184
                    }
 
185
                }
180
186
            }
181
187
        }
182
188
    }
 
189
    if (bestMatch.isValid()) {
 
190
        m_ui->projectTreeView->clearSelection();
 
191
        m_ui->projectTreeView->setCurrentIndex(bestMatch);
 
192
        m_ui->projectTreeView->expand(bestMatch);
 
193
        m_ui->projectTreeView->scrollTo(bestMatch);
 
194
    }
183
195
}
184
196
 
185
197
void ProjectManagerView::openUrl( const KUrl& url )