1
/* ****************************************************************************
2
This file is part of KBabel
4
Copyright (C) 2002 by Marco Wegner <mail@marcowegner.de>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
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
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
In addition, as a special exception, the copyright holders give
21
permission to link the code of this program with any edition of
22
the Qt library by Trolltech AS, Norway (or with modified versions
23
of Qt that use the same license as Qt), and distribute linked
24
combinations including the two. You must obey the GNU General
25
Public License in all respects for all of the code used other than
26
Qt. If you modify this file, you may extend this exception to
27
your version of the file, but you are not obligated to do so. If
28
you do not wish to do so, delete this exception statement from
31
**************************************************************************** */
34
#include <qpopupmenu.h>
38
#include "kbbookmarkhandler.h"
41
// implementation of KBabelBookmark
42
KBabelBookmark::KBabelBookmark(int msgindex, QString msgtext)
45
if (msgtext.length() > 32) {
47
msgtext.append("...");
50
// insert one '&' before every consecutive group of ampersands to keep the
51
// first of these from acting either as accelerator or mask in the menu
53
int pos = msgtext.find(rx);
55
msgtext.insert(pos, '&');
56
pos = msgtext.find(rx, pos + rx.matchedLength() + 1);
62
int KBabelBookmark::msgindex() const
67
QString KBabelBookmark::msgtext() const
73
// implementation of KBabelBookmarkHandler
74
KBabelBookmarkHandler::KBabelBookmarkHandler(QPopupMenu* menu)
77
_list.setAutoDelete(true);
80
void KBabelBookmarkHandler::addBookmark(KBabelBookmark* b)
82
// check if a bookmark to the current msgid exists already
83
QPtrListIterator<KBabelBookmark> it(_list);
86
while((temp = it.current()) != 0) {
88
if (temp->msgindex() == b->msgindex()) {
95
// if it's okay then add the bookmark
97
_menu->insertItem(QString("#%1 - %2").arg(b->msgindex()).arg(b->msgtext()),
98
this, SIGNAL(signalBookmarkSelected(int)), 0, b->msgindex());
101
void KBabelBookmarkHandler::addBookmark(int msgindex, QString msgtext)
103
addBookmark(new KBabelBookmark(msgindex, msgtext));
106
void KBabelBookmarkHandler::setBookmarks(QPtrList<KBabelBookmark> list)
108
QPtrListIterator<KBabelBookmark> it(list);
109
KBabelBookmark* temp;
111
while((temp = it.current()) != 0) {
113
addBookmark(temp->msgindex(), temp->msgtext()); // make deep copy
117
QPtrList<KBabelBookmark> KBabelBookmarkHandler::bookmarks() const
122
void KBabelBookmarkHandler::slotClearBookmarks()
124
while (!_list.isEmpty()) {
125
KBabelBookmark* b = _list.first();
126
_menu->removeItem(b->msgindex());
131
#include "kbbookmarkhandler.moc"