#include "mainwindow.h"


//-------------------------------------------
MainWindow::MainWindow (QWidget *parent) :
    QMainWindow (parent)
//-------------------------------------------
{
    setupUi(this);

    GetHeapSumInfo (&StartHeapInfo);

    curFontSize = minFontSize = 10;
    maxFontSize = 20;

    connect (&sizeUpdateTimer, SIGNAL(timeout()),
             this, SLOT(sizeUpdateTimerTrigger()));

    sizeUpdateTimer.start (20);

} // ~MainWindow::MainWindow



//------------------------------------------
void MainWindow::sizeUpdateTimerTrigger()
//------------------------------------------
{
    if (++curFontSize > maxFontSize)
        curFontSize = minFontSize;

    setStyleSheet("font: " + QString::number(curFontSize) +"px;");

    updateHeapInfo ();

} // ~MainWindow::updateTimerTrigger



//-----------------------------------
void MainWindow::updateHeapInfo ()
//-----------------------------------
{
    THeapSumInfo CurHeapInfo;
    THeapSumInfoDifference HeapInfoDiff;

    GetHeapSumInfo (&CurHeapInfo);

    GetHeapSumInfoDifference (
        &StartHeapInfo,
        &CurHeapInfo,
        &HeapInfoDiff);

    char Buffer[512];
    static THeapSumInfoFieldPresenceFlag PF = {1,1,0,0,0,0,1,1};

    THeapSumInfoDifference_to_cstring (
         &HeapInfoDiff, Buffer, 0, "     ", 0, &PF);

    MemInfoLabel->setText (Buffer);

} // ~MainWindow::updateHeapInfo
