DirectPrint/DirectPrintApp/ui/src/directprintmainview.cpp
author Steven Cao <steven.1.cao@nokia.com>
Tue, 11 May 2010 14:10:02 +0800
changeset 15 2275db202402
parent 12 613a5ff70823
permissions -rw-r--r--
Pickup K3's code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     1
/*
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     2
* Copyright (c) 2010 Kanrikogaku Kenkyusho, Ltd.
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     3
* All rights reserved.
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     4
* This component and the accompanying materials are made available
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     6
* which accompanies this distribution, and is available
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     8
*
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     9
* Initial Contributors:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    10
* Kanrikogaku Kenkyusho, Ltd. - Initial contribution
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    11
*
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    12
* Contributors:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    13
*
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    14
* Description:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    15
*
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    16
*/
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    17
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    18
#include <aknviewappui.h>
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    19
#include <akntoolbar.h>
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    20
#include <barsread.h>
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    21
#include <DirectPrintApp.rsg>
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    22
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    23
#include "clog.h"
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    24
#include "directprintapp.hrh"
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    25
#include "directprintmodel.h"
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    26
#include "directprintmainview.h"
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    27
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    28
CDirectPrintMainView::CDirectPrintMainView()
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    29
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    30
	iListBox = NULL;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    31
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    32
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    33
CDirectPrintMainView::~CDirectPrintMainView()
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    34
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    35
	AppUi()->RemoveFromViewStack(*this, iListBox);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    36
	delete iListBox;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    37
	iItemArray->Reset();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    38
	delete iItemArray;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    39
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    40
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    41
CDirectPrintMainView* CDirectPrintMainView::NewL()
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    42
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    43
	CDirectPrintMainView* self = CDirectPrintMainView::NewLC();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    44
	CleanupStack::Pop(self);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    45
	return self;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    46
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    47
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    48
CDirectPrintMainView* CDirectPrintMainView::NewLC()
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    49
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    50
	CDirectPrintMainView* self = new(ELeave) CDirectPrintMainView();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    51
	CleanupStack::PushL(self);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    52
	self->ConstructL();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    53
	return self;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    54
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    55
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    56
void CDirectPrintMainView::ConstructL()
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    57
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    58
	LOG("CDirectPrintMainView::ConstructL BEGIN");
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    59
	BaseConstructL(R_DIRECTPRINT_MAINVIEW);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    60
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    61
	iViewId = TUid::Uid(EDirectPrintMainViewId);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    62
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    63
	iItemArray = new(ELeave) CDesCArrayFlat(3);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    64
	LOG("CDirectPrintMainView::ConstructL END");
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    65
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    66
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    67
void CDirectPrintMainView::HandleCommandL(TInt aCommand)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    68
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    69
	switch (aCommand)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    70
		{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    71
		case EAknSoftkeyBack:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    72
			{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    73
			AppUi()->HandleCommandL(EDirectPrintCmdIdMainViewExit);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    74
			}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    75
			break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    76
		case EDirectPrintCmdIdMainViewPrinterList:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    77
		case EDirectPrintCmdIdMainViewPrint:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    78
		case EDirectPrintCmdIdMainViewPreview:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    79
		case EDirectPrintCmdIdMainViewPropertySetting:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    80
			{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    81
			AppUi()->HandleCommandL(aCommand);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    82
			}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    83
			break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    84
		default:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    85
			{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    86
			AppUi()->HandleCommandL(aCommand);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    87
			}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    88
			break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    89
		}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    90
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    91
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    92
void CDirectPrintMainView::HandleListIndexL(TInt aIndex)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    93
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    94
	switch (aIndex)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    95
		{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    96
		case EItemPrinter:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    97
			{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    98
			AppUi()->HandleCommandL(EDirectPrintCmdIdMainViewPrinterList);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    99
			}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   100
			break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   101
		case EItemBearer:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   102
			{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   103
			CDirectPrintModel& model = GetModel();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   104
			model.SetSelectPrinter(model.CurrentPrinter());
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   105
			AppUi()->HandleCommandL(EDirectPrintCmdIdMainViewPrinterSetting);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   106
			}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   107
			break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   108
		case EItemSetting:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   109
			{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   110
			AppUi()->HandleCommandL(EDirectPrintCmdIdMainViewPropertySetting);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   111
			}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   112
			break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   113
		default:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   114
			break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   115
		}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   116
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   117
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   118
void CDirectPrintMainView::OfferToolbarEventL(TInt aCommand)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   119
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   120
	switch (aCommand)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   121
		{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   122
		case EDirectPrintCmdIdMainViewPrint:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   123
		case EDirectPrintCmdIdMainViewPreview:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   124
		case EDirectPrintCmdIdMainViewPropertySetting:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   125
			{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   126
			AppUi()->HandleCommandL(aCommand);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   127
			}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   128
			break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   129
		default:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   130
			break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   131
		}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   132
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   133
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   134
void CDirectPrintMainView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   135
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   136
	LOG("CDirectPrintMainView::DoActivateL BEGIN");
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   137
	CAknToolbar* toolbar = AppUi()->CurrentFixedToolbar();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   138
	toolbar->SetToolbarObserver(this);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   139
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   140
	iItemArray->Reset();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   141
	LoadListDataL();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   142
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   143
	// Create list box
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   144
	if (!iListBox)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   145
		{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   146
		iListBox = CDirectPrintListBox::NewL(ClientRect(), iItemArray);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   147
		iListBox->SetMopParent(this);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   148
		iListBox->SetListObserver(this);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   149
		}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   150
	AppUi()->AddToStackL(*this, iListBox);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   151
	iListBox->MakeVisible(ETrue);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   152
	iListBox->RedrawListL();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   153
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   154
	// set the title pane
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   155
	SetActiveTitleL(R_DIRECTPRINT_MAINVIEW_TITLE);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   156
	LOG("CDirectPrintMainView::DoActivateL END");
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   157
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   158
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   159
void CDirectPrintMainView::DoDeactivate()
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   160
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   161
	LOG("CDirectPrintMainView::DoDeactivate BEGIN");
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   162
	iListBox->MakeVisible(EFalse);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   163
	AppUi()->RemoveFromViewStack(*this, iListBox);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   164
	LOG("CDirectPrintMainView::DoDeactivate END");
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   165
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   166
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   167
void CDirectPrintMainView::LoadListDataL()
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   168
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   169
	CDirectPrintModel& model = GetModel();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   170
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   171
	if (model.PrinterCount() > 0)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   172
		{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   173
		TBuf<50> buf;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   174
		TBuf<25> itemTitle;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   175
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   176
		TDirectPrintPrinterData printerData;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   177
		model.GetPrinterDataL(0, printerData);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   178
		CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_MAINVIEW_ITEM_PRINTERNAME);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   179
		buf.Format(_L("\t%S\t%S"), &itemTitle, &printerData.iPrinterName);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   180
		iItemArray->AppendL(buf);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   181
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   182
		TDirectPrintBearerData bearerData;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   183
		model.GetCurrentBearerDataL(bearerData);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   184
		CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_MAINVIEW_ITEM_BEARER);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   185
		buf.Format(_L("\t%S\t%S"), &itemTitle, &bearerData.iBearerName);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   186
		iItemArray->AppendL(buf);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   187
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   188
		TBuf<25> property;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   189
		MakePropertyStringL(property);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   190
		CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_MAINVIEW_ITEM_PROPERTYSETTINGS);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   191
		buf.Format(_L("\t%S\t%S"), &itemTitle, &property);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   192
		iItemArray->AppendL(buf);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   193
		}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   194
	else
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   195
		{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   196
		TBuf<50> buf;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   197
		TBuf<30> itemTitle;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   198
		CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_MAINVIEW_ITEM_PRINTERNAME);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   199
		buf.Format(_L("\t%S\t"), &itemTitle);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   200
		iItemArray->AppendL(buf);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   201
		CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_MAINVIEW_ITEM_BEARER);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   202
		buf.Format(_L("\t%S\t"), &itemTitle);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   203
		iItemArray->AppendL(buf);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   204
		CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_MAINVIEW_ITEM_PROPERTYSETTINGS);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   205
		buf.Format(_L("\t%S\t"), &itemTitle);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   206
		iItemArray->AppendL(buf);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   207
		}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   208
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   209
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   210
void CDirectPrintMainView::MakePropertyStringL(TDes& aProperty)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   211
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   212
	CDirectPrintModel& model = GetModel();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   213
	CPrinterProperty* property = model.GetCurrentPrinterPropertyL(TUid::Uid(0));
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   214
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   215
	if (property)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   216
		{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   217
		TInt paperSize(0), orientation(0), copy(0);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   218
		TInt count = property->iPropertyItems.Count();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   219
		for (TInt i=0; i<count; i++)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   220
			{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   221
			if (property->iPropertyItems[i].iItemType == EDirectPrintPageSettingTab)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   222
				{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   223
				switch (property->iPropertyItems[i].iItemId)
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   224
					{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   225
					case EDirectPrintPaperPaperSize:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   226
						{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   227
						paperSize = property->iPropertyItems[i].iItemValue;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   228
						}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   229
						break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   230
					case EDirectPrintPaperOrientation:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   231
						{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   232
						orientation = property->iPropertyItems[i].iItemValue;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   233
						}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   234
						break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   235
					case EDirectPrintPageCopy:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   236
						{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   237
						copy = property->iPropertyItems[i].iItemValue;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   238
						}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   239
						break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   240
					default:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   241
						break;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   242
					}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   243
				}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   244
			}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   245
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   246
		//aProperty.Format(_L("%S/%S/%d"), paperSize, orientation, copy);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   247
		aProperty.Format(_L("%d/%d/%d"), paperSize, orientation, copy);
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   248
		}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   249
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
   250