annotate base/Selection.h @ 77:2beca8ddcdc3

* Add BZipFileDevice to handle bzip2 compress/uncompress without all that ugly code in MainWindow.cpp * Remove all that ugly code in MainWindow.cpp and replace with uses of BZipFileDevice * Fix layer import/export for SV XML layers * and a few other minor fixes
author Chris Cannam
date Wed, 12 Apr 2006 09:59:40 +0000
parents d397ea0a79f5
children 5877d68815c7
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@8 2
Chris@8 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@8 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@8 14 */
Chris@8 15
Chris@8 16 #ifndef _SELECTION_H_
Chris@8 17 #define _SELECTION_H_
Chris@8 18
Chris@8 19 #include <cstddef>
Chris@24 20 #include <set>
Chris@8 21
Chris@46 22 #include "XmlExportable.h"
Chris@46 23
Chris@8 24 class Selection
Chris@8 25 {
Chris@8 26 public:
Chris@8 27 Selection();
Chris@8 28 Selection(size_t startFrame, size_t endFrame);
Chris@8 29 Selection(const Selection &);
Chris@8 30 Selection &operator=(const Selection &);
Chris@8 31 virtual ~Selection();
Chris@8 32
Chris@8 33 bool isEmpty() const;
Chris@8 34 size_t getStartFrame() const;
Chris@8 35 size_t getEndFrame() const;
Chris@9 36 bool contains(size_t frame) const;
Chris@8 37
Chris@8 38 bool operator<(const Selection &) const;
Chris@8 39 bool operator==(const Selection &) const;
Chris@8 40
Chris@8 41 protected:
Chris@8 42 size_t m_startFrame;
Chris@8 43 size_t m_endFrame;
Chris@8 44 };
Chris@8 45
Chris@46 46 class MultiSelection : public XmlExportable
Chris@24 47 {
Chris@24 48 public:
Chris@24 49 MultiSelection();
Chris@24 50 virtual ~MultiSelection();
Chris@24 51
Chris@24 52 typedef std::set<Selection> SelectionList;
Chris@24 53
Chris@24 54 const SelectionList &getSelections() const;
Chris@24 55 void setSelection(const Selection &selection);
Chris@24 56 void addSelection(const Selection &selection);
Chris@24 57 void removeSelection(const Selection &selection);
Chris@24 58 void clearSelections();
Chris@24 59
Chris@24 60 /**
Chris@24 61 * Return the selection that contains a given frame.
Chris@24 62 * If defaultToFollowing is true, and if the frame is not in a
Chris@24 63 * selected area, return the next selection after the given frame.
Chris@24 64 * Return the empty selection if no appropriate selection is found.
Chris@24 65 */
Chris@36 66 Selection getContainingSelection(size_t frame, bool defaultToFollowing) const;
Chris@24 67
Chris@46 68 virtual QString toXmlString(QString indent = "",
Chris@46 69 QString extraAttributes = "") const;
Chris@46 70
Chris@24 71 protected:
Chris@24 72 SelectionList m_selections;
Chris@24 73 };
Chris@24 74
Chris@24 75
Chris@8 76 #endif