Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kurlnavigatorplacesselector.cpp
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 80 | for (int i = 0; i < rowCount; ++i) { | |||
---|---|---|---|---|---|
116 | } | 116 | } | ||
117 | } | 117 | } | ||
118 | 118 | | |||
119 | updateTeardownAction(); | 119 | updateTeardownAction(); | ||
120 | } | 120 | } | ||
121 | 121 | | |||
122 | void KUrlNavigatorPlacesSelector::updateTeardownAction() | 122 | void KUrlNavigatorPlacesSelector::updateTeardownAction() | ||
123 | { | 123 | { | ||
124 | const int rowCount = m_placesModel->rowCount(); | 124 | const QString teardownActionId = QStringLiteral("teardownAction"); | ||
125 | if (m_placesMenu->actions().size() == rowCount + 2) { | 125 | | ||
126 | // remove teardown action | 126 | if (!m_placesMenu->isEmpty()) { | ||
127 | QAction *action = m_placesMenu->actions().at(rowCount + 1); | 127 | QAction *teardown = m_placesMenu->actions().last(); | ||
128 | m_placesMenu->removeAction(action); | 128 | if (teardown && teardown->data() == teardownActionId) { | ||
129 | delete action; | 129 | m_placesMenu->removeAction(teardown); | ||
130 | 130 | delete teardown; | |||
131 | // remove separator | 131 | | ||
132 | action = m_placesMenu->actions().at(rowCount); | 132 | // remove separator as well | ||
133 | m_placesMenu->removeAction(action); | 133 | delete m_placesMenu->actions().last(); | ||
134 | delete action; | 134 | } | ||
135 | } | 135 | } | ||
136 | 136 | | |||
137 | const QModelIndex index = m_placesModel->index(m_selectedItem, 0); | 137 | const QModelIndex index = m_placesModel->index(m_selectedItem, 0); | ||
138 | QAction *teardown = m_placesModel->teardownActionForIndex(index); | 138 | QAction *teardown = m_placesModel->teardownActionForIndex(index); | ||
139 | if (teardown != nullptr) { | 139 | if (teardown) { | ||
140 | teardown->setParent(m_placesMenu); | 140 | teardown->setParent(m_placesMenu); | ||
141 | teardown->setData(QStringLiteral("teardownAction")); | 141 | teardown->setData(teardownActionId); | ||
142 | 142 | | |||
143 | m_placesMenu->addSeparator(); | 143 | m_placesMenu->addSeparator(); | ||
144 | m_placesMenu->addAction(teardown); | 144 | m_placesMenu->addAction(teardown); | ||
145 | } | 145 | } | ||
146 | } | 146 | } | ||
147 | 147 | | |||
148 | void KUrlNavigatorPlacesSelector::updateSelection(const QUrl &url) | 148 | void KUrlNavigatorPlacesSelector::updateSelection(const QUrl &url) | ||
149 | { | 149 | { | ||
▲ Show 20 Lines • Show All 152 Lines • Show Last 20 Lines |