From 47d455dd55be855e4cc691c32f687f723d9247ee Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kviewshell/bookmark.h | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 kviewshell/bookmark.h (limited to 'kviewshell/bookmark.h') diff --git a/kviewshell/bookmark.h b/kviewshell/bookmark.h new file mode 100644 index 00000000..1df245fb --- /dev/null +++ b/kviewshell/bookmark.h @@ -0,0 +1,107 @@ +// -*- C++ -*- +/*************************************************************************** + * Copyright (C) 2005 by Stefan Kebekus * + * kebekus@kde.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef _bookmarks_h_ +#define _bookmarks_h_ + +#include "anchor.h" + +#include +#include + + +/** \brief Bookmark + +This class represents a bookmark. It contains the bookmark text, an +anchor that represents the target of the bookmark, and a list of +subordinate bookmarks. + +@warning The list of subordinate bookmarks owns its entries, +i.e. autoDelete() is set to true. Thus, extra care must be taken when +copying bookmarks. Otherwise, a segfault could result. +*/ + +class Bookmark { + public: + /** Default constructor. + + Constructs an invalid bookmark with an empty bookMarkText and an + invalid position + */ + Bookmark() {subordinateBookmarks.setAutoDelete(true);} + + /** Constructs a bookmark with given a text and anchor + + @param text name of the bookmark, as it appears in the GUI + + @param pos an Anchor that specifies the position of the bookmark + */ + Bookmark(const QString &text, const Anchor &pos) { + Bookmark(); + bookmarkText = text; + position = pos; + } + + /** Convenience funtion, behaves as Bookmark(const QString &text, const Anchor &pos) + + @param text name of the bookmark, as it appears in the GUI + + @param page number of the where the bookmark lives. Recall the + convention that '0' is an invalid page, the first page is '1' + + @param distance_from_top position on the page, distance from + top of the page + */ + Bookmark(const QString& text, const PageNumber& page, const Length& distance_from_top) { + Bookmark(); + bookmarkText = text; + position.page = page; + position.distance_from_top = distance_from_top; + } + + /** Label of the bookmark as it will appear in the GUI to the user, + such as "Section 1", "Theorem 12", etc. */ + QString bookmarkText; + + /** The anchor that specifies the position of the bookmark */ + Anchor position; + + /** List of subordinate bookmarks + + Bookmarks generally come in trees, and some bookmarks can have + subordinate bookmarks. For instance, the bookmark that + respresents a chapter heading would have headings of subsections + as subordinate bookmarks. These are contained in this list. + + @warning This list owns its entries, e.g. autoDelete() is set to + true. Thus, extra care must be taken when copying this + list. Otherwise, a segfault could result. + */ + QPtrList subordinateBookmarks; + + // Returns true if the bookmark is valid, false otherwise. A + // bookmark is valid if the text is not empty and the anchor is + // valid. + bool isValid() const {return (!bookmarkText.isEmpty()) && position.isValid();} +}; + + +#endif -- cgit v1.2.1