1 // -*- indent-tabs-mode:nil -*-
2 // vim: set ts=4 sts=4 sw=4 et:
3 /* This file is part of the KDE project
4 Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License version 2 or at your option version 3 as published by
9 the Free Software Foundation.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
24 #include "bookmarkiterator.h"
28 #include "bookmarkmodel.h"
32 #include <kapplication.h>
34 FavIconsItrHolder
*FavIconsItrHolder::s_self
= 0;
36 FavIconsItrHolder::FavIconsItrHolder()
37 : BookmarkIteratorHolder() {
41 void FavIconsItrHolder::doItrListChanged() {
42 kDebug()<<"FavIconsItrHolder::doItrListChanged() "<<count()<<" iterators";
43 KEBApp::self()->setCancelFavIconUpdatesEnabled(count() > 0);
46 kDebug()<<"Notifing managers "<<m_affectedBookmark
;
47 CurrentMgr::self()->notifyManagers(CurrentMgr::bookmarkAt(m_affectedBookmark
).toGroup());
48 m_affectedBookmark
.clear();
52 void FavIconsItrHolder::addAffectedBookmark( const QString
& address
)
54 kDebug()<<"addAffectedBookmark "<<address
;
55 if(m_affectedBookmark
.isNull())
56 m_affectedBookmark
= address
;
58 m_affectedBookmark
= KBookmark::commonParent(m_affectedBookmark
, address
);
59 kDebug()<<" m_affectedBookmark is now "<<m_affectedBookmark
;
62 /* -------------------------- */
64 FavIconsItr::FavIconsItr(QList
<KBookmark
> bks
)
65 : BookmarkIterator(bks
) {
69 FavIconsItr::~FavIconsItr() {
70 setStatus(m_oldStatus
);
74 void FavIconsItr::setStatus(const QString
& status
)
76 EditCommand::setNodeText(curBk(), QStringList()<< "info" << "metadata" << "favstate", status
);
77 CurrentMgr::self()->model()->emitDataChanged(curBk());
80 void FavIconsItr::slotDone(bool succeeded
) {
81 // kDebug() << "FavIconsItr::slotDone()";
82 setStatus(succeeded
? i18n("OK") : i18n("No favicon found"));
83 holder()->addAffectedBookmark(KBookmark::parentAddress(curBk().address()));
87 bool FavIconsItr::isApplicable(const KBookmark
&bk
) const {
88 return (!bk
.isGroup() && !bk
.isSeparator());
91 void FavIconsItr::doAction() {
92 // kDebug() << "FavIconsItr::doAction()";
93 //FIXME ensure that this gets overwritten
94 setStatus(i18n("Updating favicon..."));
96 m_updater
= new FavIconUpdater(kapp
);
97 connect(m_updater
, SIGNAL( done(bool) ),
98 this, SLOT( slotDone(bool) ) );
100 if (curBk().url().protocol().startsWith("http")) {
101 m_updater
->downloadIcon(curBk());
103 setStatus(i18n("Local file"));
104 delayedEmitNextOne();
108 #include "favicons.moc"