summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-07-11 22:43:56 +0200
committerMontel Laurent <[email protected]>2017-07-11 22:43:56 +0200
commita303beb25c19fe708f7326a8d9ab6c5d31861da2 (patch)
treec3eec34b96d031c90d725c5a0ff43e04dd31adea
parenta389382d3b849e2b0830af401c197a5d062e699c (diff)
Fix duplicate code
-rw-r--r--src/kftabdlg.cpp45
-rw-r--r--src/kftabdlg.h1
2 files changed, 20 insertions, 26 deletions
diff --git a/src/kftabdlg.cpp b/src/kftabdlg.cpp
index fb02ecd..24fb955 100644
--- a/src/kftabdlg.cpp
+++ b/src/kftabdlg.cpp
@@ -457,22 +457,27 @@ void KfindTabWidget::setURL(const QUrl &url)
dirBox->setCurrentIndex(indx);
}
} else {
- QDir m_dir(QStringLiteral("/lib"));
- dirBox->insertItem(0, m_url.toDisplayString());
- dirBox->addItem(QStringLiteral("file:") + QDir::homePath());
- dirBox->addItem(QStringLiteral("file:/"));
- dirBox->addItem(QStringLiteral("file:/usr"));
- if (m_dir.exists()) {
- dirBox->addItem(QStringLiteral("file:/lib"));
- }
- dirBox->addItem(QStringLiteral("file:/home"));
- dirBox->addItem(QStringLiteral("file:/etc"));
- dirBox->addItem(QStringLiteral("file:/var"));
- dirBox->addItem(QStringLiteral("file:/mnt"));
- dirBox->setCurrentIndex(0);
+ fillDirBox();
}
}
+void KfindTabWidget::fillDirBox()
+{
+ QDir m_dir(QStringLiteral("/lib"));
+ dirBox->insertItem(0, m_url.toDisplayString());
+ dirBox->addUrl(QUrl::fromLocalFile(QDir::homePath()));
+ dirBox->addUrl(QUrl::fromLocalFile("/"));
+ dirBox->addUrl(QUrl::fromLocalFile(QStringLiteral("/usr")));
+ if (m_dir.exists()) {
+ dirBox->addUrl(QUrl::fromLocalFile(QStringLiteral("lib")));
+ }
+ dirBox->addUrl(QUrl::fromLocalFile(QStringLiteral("/home")));
+ dirBox->addUrl(QUrl::fromLocalFile(QStringLiteral("/etc")));
+ dirBox->addUrl(QUrl::fromLocalFile(QStringLiteral("/var")));
+ dirBox->addUrl(QUrl::fromLocalFile(QStringLiteral("/mnt")));
+ dirBox->setCurrentIndex(0);
+}
+
void KfindTabWidget::initMimeTypes()
{
KMimeType::List sortedList;
@@ -536,19 +541,7 @@ void KfindTabWidget::loadHistory()
dirBox->setCurrentIndex(indx);
}
} else {
- QDir m_dir(QStringLiteral("/lib"));
- dirBox->insertItem(0, m_url.toDisplayString());
- dirBox->addItem(QStringLiteral("file:") + QDir::homePath());
- dirBox->addItem(QStringLiteral("file:/"));
- dirBox->addItem(QStringLiteral("file:/usr"));
- if (m_dir.exists()) {
- dirBox->addItem(QStringLiteral("file:/lib"));
- }
- dirBox->addItem(QStringLiteral("file:/home"));
- dirBox->addItem(QStringLiteral("file:/etc"));
- dirBox->addItem(QStringLiteral("file:/var"));
- dirBox->addItem(QStringLiteral("file:/mnt"));
- dirBox->setCurrentIndex(0);
+ fillDirBox();
}
}
diff --git a/src/kftabdlg.h b/src/kftabdlg.h
index 4224b94..da38e53 100644
--- a/src/kftabdlg.h
+++ b/src/kftabdlg.h
@@ -99,6 +99,7 @@ public:
private:
bool isDateValid();
+ void fillDirBox();
void updateDateLabels(int type, int value);