changeset 1811:796ae7eecced

Add Selection::toString for debug purposes
author Chris Cannam
date Wed, 08 Jan 2020 15:25:43 +0000
parents ee3b248bda25
children 8a06e16948d7
files base/Selection.cpp base/Selection.h
diffstat 2 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/base/Selection.cpp	Fri Nov 22 14:12:16 2019 +0000
+++ b/base/Selection.cpp	Wed Jan 08 15:25:43 2020 +0000
@@ -227,3 +227,15 @@
     stream << indent << "</selections>\n";
 }
 
+QString
+MultiSelection::toString() const
+{
+    QStringList list;
+    for (SelectionList::iterator i = m_selections.begin();
+         i != m_selections.end(); ++i) {
+        list << QString("(%1,%2)")
+            .arg(i->getStartFrame())
+            .arg(i->getEndFrame());
+    }
+    return "(" + list.join(",") + ")";
+}
--- a/base/Selection.h	Fri Nov 22 14:12:16 2019 +0000
+++ b/base/Selection.h	Wed Jan 08 15:25:43 2020 +0000
@@ -75,18 +75,22 @@
     void clearSelections();
 
     void getExtents(sv_frame_t &startFrame, sv_frame_t &endFrame) const;
-
+    
     /**
      * Return the selection that contains a given frame.
      * If defaultToFollowing is true, and if the frame is not in a
      * selected area, return the next selection after the given frame.
      * Return the empty selection if no appropriate selection is found.
      */
-    Selection getContainingSelection(sv_frame_t frame, bool defaultToFollowing) const;
+    Selection getContainingSelection(sv_frame_t frame,
+                                     bool defaultToFollowing) const;
 
     void toXml(QTextStream &stream, QString indent = "",
-                       QString extraAttributes = "") const override;
+               QString extraAttributes = "") const override;
 
+    // Debug only, not interop
+    QString toString() const;
+    
 protected:
     SelectionList m_selections;
 };