phonebookui/pbkcommonui/src/cntfetchmarkall.cpp
author hgs
Thu, 05 Aug 2010 14:31:09 +0300
changeset 54 47627ab5d7a4
parent 53 e6aff7b69165
child 61 d30183af6ca6
permissions -rw-r--r--
201031
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include "cntfetchmarkall.h"
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include <QGraphicsLinearLayout>
hgs
parents:
diff changeset
    21
#include <hbcheckbox.h>
hgs
parents:
diff changeset
    22
#include <hbtextitem.h>
hgs
parents:
diff changeset
    23
#include <hbframeitem.h>
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
CntFetchMarkAll::CntFetchMarkAll(QGraphicsItem *aParent)
hgs
parents:
diff changeset
    26
: HbWidget(aParent),
hgs
parents:
diff changeset
    27
  mCheckBox(NULL),
hgs
parents:
diff changeset
    28
  mCounterLabel(NULL),
hgs
parents:
diff changeset
    29
  mContactCount( 0 ),
hgs
parents:
diff changeset
    30
  mSelectionCount( 0 )
hgs
parents:
diff changeset
    31
{
hgs
parents:
diff changeset
    32
    setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
hgs
parents:
diff changeset
    33
    
hgs
parents:
diff changeset
    34
    mCheckBox = new HbCheckBox(this);
hgs
parents:
diff changeset
    35
    mCheckBox->setText(hbTrId("txt_common_list_mark_all_items"));
hgs
parents:
diff changeset
    36
    mCheckBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
hgs
parents:
diff changeset
    37
    
hgs
parents:
diff changeset
    38
    connect(mCheckBox, SIGNAL(stateChanged(int)), this, SIGNAL(markAll(int)) );
hgs
parents:
diff changeset
    39
    
hgs
parents:
diff changeset
    40
    mCounterLabel = new HbTextItem( this );
hgs
parents:
diff changeset
    41
    
hgs
parents:
diff changeset
    42
    mFrame = new HbFrameItem(this);
hgs
parents:
diff changeset
    43
    mFrame->frameDrawer().setFrameGraphicsName("qtg_fr_groupbox_normal");
hgs
parents:
diff changeset
    44
    mFrame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
hgs
parents:
diff changeset
    45
    mFrame->setZValue(-2);
hgs
parents:
diff changeset
    46
    style()->setItemName(mFrame, "background");
hgs
parents:
diff changeset
    47
           
hgs
parents:
diff changeset
    48
    HbStyle::setItemName(mCheckBox,"checkbox");
hgs
parents:
diff changeset
    49
    HbStyle::setItemName(mCounterLabel,"counter");
hgs
parents:
diff changeset
    50
}
hgs
parents:
diff changeset
    51
hgs
parents:
diff changeset
    52
void CntFetchMarkAll::setMaxContactCount( int aContactCount )
hgs
parents:
diff changeset
    53
{
hgs
parents:
diff changeset
    54
    mContactCount = aContactCount;
hgs
parents:
diff changeset
    55
    mCounterLabel->setText( QString("%1/%2").arg(mSelectionCount).arg(mContactCount) );
hgs
parents:
diff changeset
    56
}
hgs
parents:
diff changeset
    57
hgs
parents:
diff changeset
    58
void CntFetchMarkAll::setSelectedContactCount( int aSelectedCount )
hgs
parents:
diff changeset
    59
{
hgs
parents:
diff changeset
    60
    mSelectionCount = aSelectedCount;
hgs
parents:
diff changeset
    61
    mCounterLabel->setText( QString("%1/%2").arg(mSelectionCount).arg(mContactCount) );
54
hgs
parents: 53
diff changeset
    62
    
hgs
parents: 53
diff changeset
    63
    if ( mSelectionCount < mContactCount )
hgs
parents: 53
diff changeset
    64
    {
hgs
parents: 53
diff changeset
    65
        blockSignals( true );
hgs
parents: 53
diff changeset
    66
        mCheckBox->setCheckState( Qt::Unchecked );
hgs
parents: 53
diff changeset
    67
        blockSignals( false );
hgs
parents: 53
diff changeset
    68
    }
53
hgs
parents:
diff changeset
    69
}
hgs
parents:
diff changeset
    70
hgs
parents:
diff changeset
    71
CntFetchMarkAll::~CntFetchMarkAll()
hgs
parents:
diff changeset
    72
{
54
hgs
parents: 53
diff changeset
    73
    delete mCheckBox;
hgs
parents: 53
diff changeset
    74
    mCheckBox = NULL;
hgs
parents: 53
diff changeset
    75
    delete mCounterLabel;
hgs
parents: 53
diff changeset
    76
    mCounterLabel = NULL;
hgs
parents: 53
diff changeset
    77
    delete mFrame;
hgs
parents: 53
diff changeset
    78
    mFrame = NULL;
53
hgs
parents:
diff changeset
    79
}
hgs
parents:
diff changeset
    80
hgs
parents:
diff changeset
    81
// EOF