- // create Url navigator buttons
- int idx = slashCount;
- bool hasNext = true;
- do {
- dir_name = path.section('/', idx, idx);
- const bool isFirstButton = (idx == slashCount);
- hasNext = isFirstButton || !dir_name.isEmpty();
- if (hasNext) {
- UrlNavigatorButton* button = new UrlNavigatorButton(idx, this);
- if (isFirstButton) {
- // the first Url navigator button should get the name of the
- // bookmark instead of the directory name
- QString text = bookmark.text();
- if (text.isEmpty()) {
- if (url().isLocalFile())
- {
- text = i18n("Custom Path");
- }
- else
- {
- delete button;
- ++idx;
- continue;
- }
+ updateButtons(path, slashCount);
+ }
+}
+
+void UrlNavigator::updateButtons(const QString& path, int startIndex)
+{
+ QLinkedList<UrlNavigatorButton*>::iterator it = m_navButtons.begin();
+ const QLinkedList<UrlNavigatorButton*>::const_iterator itEnd = m_navButtons.end();
+ bool createButton = false;
+
+ int idx = startIndex;
+ bool hasNext = true;
+ do {
+ createButton = (it == itEnd);
+
+ const QString dirName = path.section('/', idx, idx);
+ const bool isFirstButton = (idx == startIndex);
+ hasNext = isFirstButton || !dirName.isEmpty();
+ if (hasNext) {
+ QString text;
+ if (isFirstButton) {
+ // the first URL navigator button should get the name of the
+ // bookmark instead of the directory name
+ const KBookmark bookmark = m_bookmarkSelector->selectedBookmark();
+ text = bookmark.text();
+ if (text.isEmpty()) {
+ if (url().isLocalFile()) {
+ text = i18n("Custom Path");
+ }
+ else {
+ ++idx;
+ continue;