2005-05-12 12:15:44 +00:00
|
|
|
// -*- indent-tabs-mode:nil -*-
|
2003-10-06 18:31:25 +00:00
|
|
|
// vim: set ts=4 sts=4 sw=4 et:
|
2003-01-21 16:16:53 +00:00
|
|
|
/* This file is part of the KDE project
|
|
|
|
Copyright (C) 2000 David Faure <faure@kde.org>
|
|
|
|
Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public
|
|
|
|
License version 2 as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2003-10-11 13:39:50 +00:00
|
|
|
General Public License for more details.
|
2003-01-21 16:16:53 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; see the file COPYING. If not, write to
|
2005-07-04 19:02:09 +00:00
|
|
|
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
2003-01-21 16:16:53 +00:00
|
|
|
*/
|
|
|
|
|
2003-09-14 18:07:31 +00:00
|
|
|
#include "bookmarkiterator.h"
|
2003-01-21 16:16:53 +00:00
|
|
|
|
|
|
|
#include "toplevel.h"
|
2003-09-14 18:07:31 +00:00
|
|
|
|
|
|
|
#include <kdebug.h>
|
|
|
|
#include <qtimer.h>
|
2005-08-13 20:13:21 +00:00
|
|
|
#include <assert.h>
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2005-09-28 16:16:52 +00:00
|
|
|
BookmarkIterator::BookmarkIterator(QList<KBookmark> bks) : m_bklist(bks) {
|
2003-10-11 13:39:50 +00:00
|
|
|
connect(this, SIGNAL( deleteSelf(BookmarkIterator *) ),
|
|
|
|
SLOT( slotCancelTest(BookmarkIterator *) ));
|
|
|
|
delayedEmitNextOne();
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BookmarkIterator::~BookmarkIterator() {
|
2003-10-11 13:39:50 +00:00
|
|
|
;
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkIterator::delayedEmitNextOne() {
|
2003-10-11 13:39:50 +00:00
|
|
|
QTimer::singleShot(1, this, SLOT( nextOne() ));
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkIterator::slotCancelTest(BookmarkIterator *test) {
|
2003-10-11 13:39:50 +00:00
|
|
|
holder()->removeItr(test);
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-03-08 15:26:42 +00:00
|
|
|
const KBookmark BookmarkIterator::curBk() const {
|
2003-10-19 16:23:37 +00:00
|
|
|
assert(m_bk.hasParent());
|
2003-10-11 13:39:50 +00:00
|
|
|
return m_bk;
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkIterator::nextOne() {
|
2003-10-11 13:39:50 +00:00
|
|
|
// kdDebug() << "BookmarkIterator::nextOne" << endl;
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-10-11 13:39:50 +00:00
|
|
|
if (m_bklist.isEmpty()) {
|
|
|
|
emit deleteSelf(this);
|
|
|
|
return;
|
|
|
|
}
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2005-09-28 16:16:52 +00:00
|
|
|
QList<KBookmark>::iterator head = m_bklist.begin();
|
2003-10-11 13:39:50 +00:00
|
|
|
KBookmark bk = (*head);
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-10-11 13:39:50 +00:00
|
|
|
bool viable = bk.hasParent() && isApplicable(bk);
|
2003-03-22 00:43:39 +00:00
|
|
|
|
2003-10-11 13:39:50 +00:00
|
|
|
if (viable) {
|
|
|
|
m_bk = bk;
|
|
|
|
doAction();
|
|
|
|
}
|
2003-03-22 00:43:39 +00:00
|
|
|
|
2005-08-13 20:13:21 +00:00
|
|
|
m_bklist.erase(head);
|
2003-03-22 00:43:39 +00:00
|
|
|
|
2003-10-19 16:23:37 +00:00
|
|
|
if (!viable)
|
|
|
|
delayedEmitNextOne();
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-03-22 00:43:39 +00:00
|
|
|
/* --------------------------- */
|
2003-02-16 00:05:39 +00:00
|
|
|
|
2005-09-28 16:16:52 +00:00
|
|
|
BookmarkIteratorHolder::BookmarkIteratorHolder()
|
|
|
|
{
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkIteratorHolder::insertItr(BookmarkIterator *itr) {
|
2005-09-28 16:16:52 +00:00
|
|
|
m_itrs.prepend(itr);
|
2003-10-11 13:39:50 +00:00
|
|
|
doItrListChanged();
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BookmarkIteratorHolder::removeItr(BookmarkIterator *itr) {
|
2005-09-28 16:16:52 +00:00
|
|
|
QList<BookmarkIterator *>::iterator it = m_itrs.find(itr);
|
|
|
|
m_itrs.remove(it);
|
|
|
|
delete itr;
|
2003-10-11 13:39:50 +00:00
|
|
|
doItrListChanged();
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2005-09-28 16:16:52 +00:00
|
|
|
void BookmarkIteratorHolder::cancelAllItrs()
|
|
|
|
{
|
|
|
|
qDeleteAll(m_itrs);
|
2005-06-10 01:08:43 +00:00
|
|
|
m_itrs.clear();
|
|
|
|
doItrListChanged();
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "bookmarkiterator.moc"
|