Changeset View
Changeset View
Standalone View
Standalone View
sublime/container.cpp
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Line(s) | 143 | { | |||
---|---|---|---|---|---|
150 | views.reserve(viewForWidget.size()); | 150 | views.reserve(viewForWidget.size()); | ||
151 | 151 | | |||
152 | foreach(View* view, viewForWidget){ | 152 | foreach(View* view, viewForWidget){ | ||
153 | views << view; | 153 | views << view; | ||
154 | } | 154 | } | ||
155 | 155 | | |||
156 | std::sort(views.begin(), views.end(), sortViews); | 156 | std::sort(views.begin(), views.end(), sortViews); | ||
157 | 157 | | |||
158 | foreach(View* view, views) { | 158 | for (int i = 0; i < views.size(); ++i) { | ||
159 | QAction* action = documentListMenu->addAction(view->document()->title()); | 159 | View *view = views.at(i); | ||
160 | QString visibleEntryTitle; | ||||
161 | // if filename is not unique, prepend containing directory | ||||
162 | if ((i < views.size() - 1 && view->document()->title() == views.at(i + 1)->document()->title()) | ||||
163 | || (i > 0 && view->document()->title() == views.at(i - 1)->document()->title()) | ||||
164 | ) { | ||||
165 | auto urlDoc = qobject_cast<Sublime::UrlDocument*>(view->document()); | ||||
brauch: add a null check here | |||||
166 | if (!urlDoc) { | ||||
167 | visibleEntryTitle = view->document()->title(); | ||||
168 | continue; | ||||
169 | } | ||||
170 | auto url = urlDoc->url().toString(); | ||||
171 | int secondOffset = url.lastIndexOf('/'); | ||||
172 | secondOffset = url.lastIndexOf('/', secondOffset - 1); | ||||
173 | visibleEntryTitle = url.right(url.length() - url.lastIndexOf('/', secondOffset) - 1); | ||||
174 | } else { | ||||
175 | visibleEntryTitle = view->document()->title(); | ||||
176 | } | ||||
177 | QAction* action = documentListMenu->addAction(visibleEntryTitle); | ||||
160 | action->setData(QVariant::fromValue(view)); | 178 | action->setData(QVariant::fromValue(view)); | ||
161 | documentListActionForView[view] = action; | 179 | documentListActionForView[view] = action; | ||
162 | action->setIcon(view->document()->icon()); | 180 | action->setIcon(view->document()->icon()); | ||
163 | ///FIXME: push this code somehow into shell, such that we can access the project model for | 181 | ///FIXME: push this code somehow into shell, such that we can access the project model for | ||
164 | /// icons and also get a neat, short path like the document switcher. | 182 | /// icons and also get a neat, short path like the document switcher. | ||
165 | } | 183 | } | ||
166 | } | 184 | } | ||
167 | }; | 185 | }; | ||
▲ Show 20 Lines • Show All 226 Lines • ▼ Show 20 Line(s) | 411 | while (it.hasNext()) { | |||
394 | Sublime::View* view = it.next().value(); | 412 | Sublime::View* view = it.next().value(); | ||
395 | if (view->document() == doc) { | 413 | if (view->document() == doc) { | ||
396 | if (currentView() == view) { | 414 | if (currentView() == view) { | ||
397 | d->fileNameCorner->setText( doc->title(Document::Extended) + i18n(" <i><small>(Press Ctrl+Tab to switch)</small></i>") ); | 415 | d->fileNameCorner->setText( doc->title(Document::Extended) + i18n(" <i><small>(Press Ctrl+Tab to switch)</small></i>") ); | ||
398 | } | 416 | } | ||
399 | int tabIndex = d->stack->indexOf(it.key()); | 417 | int tabIndex = d->stack->indexOf(it.key()); | ||
400 | if (tabIndex != -1) { | 418 | if (tabIndex != -1) { | ||
401 | d->tabBar->setTabText(tabIndex, doc->title()); | 419 | d->tabBar->setTabText(tabIndex, doc->title()); | ||
402 | } | 420 | } | ||
403 | | ||||
404 | // Update document list popup title | | |||
405 | Q_ASSERT(d->documentListActionForView.contains(view)); | | |||
406 | d->documentListActionForView[view]->setText(doc->title()); | | |||
407 | break; | 421 | break; | ||
brauch: But what it if it really changed, e.g. "save as", does that work? | |||||
408 | } | 422 | } | ||
409 | } | 423 | } | ||
424 | // Update document list popup title | ||||
425 | d->updateDocumentListPopupMenu(); | ||||
410 | } | 426 | } | ||
411 | 427 | | |||
412 | int Container::count() const | 428 | int Container::count() const | ||
413 | { | 429 | { | ||
414 | return d->stack->count(); | 430 | return d->stack->count(); | ||
415 | } | 431 | } | ||
416 | 432 | | |||
417 | QWidget* Container::currentWidget() const | 433 | QWidget* Container::currentWidget() const | ||
▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines |
add a null check here