summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index c0008cba..62f82e58 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1089,18 +1089,33 @@ void MainWindow::slotOpenActionUrl(QAction *action)
void MainWindow::addFavoriteLink()
{
QString name = currentTab()->title();
- QString url = currentTab()->url().pathOrUrl();
+ QString url = currentTab()->url().prettyUrl(KUrl::RemoveTrailingSlash);
QStringList names = ReKonfig::previewNames();
QStringList urls = ReKonfig::previewUrls();
- names.prepend(name);
- if(names.count() > 8)
- names.removeLast();
- urls.prepend(url);
- if(urls.count() > 8)
- urls.removeLast();
+ for (int i = 0; i < 8 && i < urls.size() ; ++i)
+ {
+ if(urls.at(i).isEmpty() || urls.at(i) == url)
+ {
+ names.replace(i, name);
+ urls.replace(i, url);
+ break;
+ }
+ if(i == 7)
+ {
+ names.prepend(name);
+ if(names.count() > 8)
+ names.removeLast();
+
+ urls.prepend(url);
+ if(urls.count() > 8)
+ urls.removeLast();
+
+ break;
+ }
+ }
ReKonfig::setPreviewNames(names);
ReKonfig::setPreviewUrls(urls);