[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kfile
From: Peter Penz <peter.penz () gmx ! at>
Date: 2010-05-14 17:43:55
Message-ID: 20100514174355.B6113AC8B5 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1126714 by ppenz:
Move the text detection for the first button into a custom method
M +32 -18 kurlnavigator.cpp
--- trunk/KDE/kdelibs/kfile/kurlnavigator.cpp #1126713:1126714
@@ -119,6 +119,11 @@
void updateButtonVisibility();
/**
+ * @return Text for the first button of the URL navigator.
+ */
+ QString firstButtonText() const;
+
+ /**
* Returns the URL that should be applied for the button with the index \a index.
*/
KUrl buttonUrl(int index) const;
@@ -543,23 +548,6 @@
const QString dirName = path.section(QLatin1Char('/'), idx, idx);
hasNext = isFirstButton || !dirName.isEmpty();
if (hasNext) {
- QString text;
- if (isFirstButton) {
- // the first URL navigator button should get the name of the
- // place instead of the directory name
- if ((m_placesSelector != 0) && !m_showFullPath) {
- const KUrl placeUrl = m_placesSelector->selectedPlaceUrl();
- text = m_placesSelector->selectedPlaceText();
- }
- if (text.isEmpty()) {
- if (currentUrl.isLocalFile()) {
- text = m_showFullPath ? QLatin1String("/") : i18n("Custom Path");
- } else {
- text = currentUrl.protocol() + QLatin1String(": ") + currentUrl.host();
- }
- }
- }
-
KUrlNavigatorButton* button = 0;
if (createButton) {
button = new KUrlNavigatorButton(buttonUrl(idx), q);
@@ -577,7 +565,7 @@
}
if (isFirstButton) {
- button->setText(text);
+ button->setText(firstButtonText());
}
button->setActive(q->isActive());
@@ -686,6 +674,32 @@
}
}
+QString KUrlNavigator::Private::firstButtonText() const
+{
+ QString text;
+
+ // The first URL navigator button should get the name of the
+ // place instead of the directory name
+ if ((m_placesSelector != 0) && !m_showFullPath) {
+ const KUrl placeUrl = m_placesSelector->selectedPlaceUrl();
+ text = m_placesSelector->selectedPlaceText();
+ }
+
+ if (text.isEmpty()) {
+ const KUrl currentUrl = q->locationUrl();
+ if (currentUrl.isLocalFile()) {
+ text = m_showFullPath ? QLatin1String("/") : i18n("Custom Path");
+ } else {
+ text = currentUrl.protocol() + QLatin1Char(':');
+ if (!currentUrl.host().isEmpty()) {
+ text += QLatin1Char(' ') + currentUrl.host();
+ }
+ }
+ }
+
+ return text;
+}
+
KUrl KUrlNavigator::Private::buttonUrl(int index) const
{
if (index < 0) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic