Fix TreeMap Crash & Cosmetics

The recent fix for date range selection was not applied to the
TreeMap plot and caused a SEGV on restart (when placed on home
window). This fixes that.

It also fixes a minor cosmetic related to QFrame margins.
This commit is contained in:
Mark Liversedge
2011-02-11 23:08:05 +00:00
parent 2f44100246
commit c144098165
4 changed files with 24 additions and 6 deletions

View File

@@ -38,7 +38,7 @@ bool TreeMapLessThan(const TreeMap *a, const TreeMap *b) {
}
TreeMapPlot::TreeMapPlot(TreeMapWindow *parent, MainWindow *main, QDir home)
: QFrame (parent), parent(parent), main(main), home(home)
: QWidget (parent), parent(parent), main(main), home(home)
{
setInstanceName("TreeMap Plot");
@@ -50,8 +50,8 @@ TreeMapPlot::TreeMapPlot(TreeMapWindow *parent, MainWindow *main, QDir home)
setMouseTracking(true);
installEventFilter(this);
// pretty border
setFrameStyle(QFrame::Box | QFrame::Raised);
// no margins
setContentsMargins(0,0,0,0);
configUpdate(); // set basic colors
connect(main, SIGNAL(configChanged()), this, SLOT(configUpdate()));
@@ -96,7 +96,7 @@ void
TreeMapPlot::resizeEvent(QResizeEvent *)
{
// layout the map
if (root) root->layout(geometry());
if (root) root->layout(QRect(9,9,geometry().width()-18, geometry().height()-18));
}

View File

@@ -234,7 +234,7 @@ class TreeMap
};
class TreeMapPlot : public QFrame
class TreeMapPlot : public QWidget
{
Q_OBJECT
G_OBJECT

View File

@@ -41,7 +41,7 @@ TreeMapWindow::TreeMapWindow(MainWindow *parent, bool useMetricUnits, const QDir
setInstanceName("Treemap Window");
// the plot
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout = new QVBoxLayout;
ltmPlot = new TreeMapPlot(this, main, home);
mainLayout->addWidget(ltmPlot);
mainLayout->setSpacing(0);
@@ -119,6 +119,18 @@ TreeMapWindow::~TreeMapWindow()
delete popup;
}
QString
TreeMapWindow::dateRange() const
{
return ltmTool->_dateRange();
}
void
TreeMapWindow::setDateRange(QString s)
{
ltmTool->setDateRange(s);
}
void
TreeMapWindow::rideSelected()
{

View File

@@ -46,6 +46,7 @@ class TreeMapWindow : public GcWindow
Q_PROPERTY(QString f1 READ f1 WRITE setf1 USER true)
Q_PROPERTY(QString f2 READ f2 WRITE setf2 USER true)
Q_PROPERTY(QString dateRange READ dateRange WRITE setDateRange USER true)
Q_PROPERTY(LTMSettings settings READ getSettings WRITE applySettings USER true)
public:
@@ -71,6 +72,10 @@ class TreeMapWindow : public GcWindow
void pointClicked(QwtPlotCurve*, int);
int groupForDate(QDate, int);
// date ranges set/get the string from the treeWidget
QString dateRange() const;
void setDateRange(QString x);
private:
// passed from MainWindow
QDir home;
@@ -91,6 +96,7 @@ class TreeMapWindow : public GcWindow
QList<SummaryMetrics> measures;
// Widgets
QVBoxLayout *mainLayout;
TreeMapPlot *ltmPlot;
LTMTool *ltmTool;
QLabel *title;