comparison view/Pane.cpp @ 294:919740b20cc9

* Better abbreviation modes for layer names in pane (and input model combo of plugin parameter dialog) * Avoid crash when loading SV file containing model derived from nonexistent model (shouldn't happen of course, but see bug #1771769) * Remember last-used input model in plugin parameter dialog * Don't override a layer colour loaded from a session file with the generated default colour when attaching it to a view
author Chris Cannam
date Fri, 10 Aug 2007 16:36:50 +0000
parents 3101c68a00c1
children 5c59c433b358
comparison
equal deleted inserted replaced
293:15b8a4bfe855 294:919740b20cc9
19 #include "base/ZoomConstraint.h" 19 #include "base/ZoomConstraint.h"
20 #include "base/RealTime.h" 20 #include "base/RealTime.h"
21 #include "base/Profiler.h" 21 #include "base/Profiler.h"
22 #include "ViewManager.h" 22 #include "ViewManager.h"
23 #include "base/CommandHistory.h" 23 #include "base/CommandHistory.h"
24 #include "base/TextAbbrev.h"
24 #include "layer/WaveformLayer.h" 25 #include "layer/WaveformLayer.h"
25 26
26 #include <QPaintEvent> 27 #include <QPaintEvent>
27 #include <QPainter> 28 #include <QPainter>
28 #include <QBitmap> 29 #include <QBitmap>
712 713
713 if (r.y() + r.height() < height() - int(m_layers.size()) * fontHeight - 6) { 714 if (r.y() + r.height() < height() - int(m_layers.size()) * fontHeight - 6) {
714 return; 715 return;
715 } 716 }
716 717
717 std::vector<QString> texts; 718 QStringList texts;
718 int maxTextWidth = 0;
719
720 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { 719 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
721 720 texts.push_back((*i)->getLayerPresentationName());
722 QString text = (*i)->getLayerPresentationName(); 721 }
723 int tw = paint.fontMetrics().width(text); 722
724 bool reduced = false; 723 int maxTextWidth = width() / 3;
725 while (tw > width() / 3 && text.length() > 4) { 724 texts = TextAbbrev::abbreviate(texts, paint.fontMetrics(), maxTextWidth);
726 if (!reduced && text.length() > 8) { 725
727 text = text.left(text.length() - 4);
728 } else {
729 text = text.left(text.length() - 2);
730 }
731 reduced = true;
732 tw = paint.fontMetrics().width(text + "...");
733 }
734 if (reduced) {
735 texts.push_back(text + "...");
736 } else {
737 texts.push_back(text);
738 }
739 if (tw > maxTextWidth) maxTextWidth = tw;
740 }
741
742 int lly = height() - 6; 726 int lly = height() - 6;
743 int llx = width() - maxTextWidth - 5; 727 int llx = width() - maxTextWidth - 5;
744 728
745 if (m_manager->getZoomWheelsEnabled()) { 729 if (m_manager->getZoomWheelsEnabled()) {
746 lly -= 20; 730 lly -= 20;