956 // Prosesses menu commands |
951 // Prosesses menu commands |
957 // ----------------------------------------------------------------------------- |
952 // ----------------------------------------------------------------------------- |
958 // |
953 // |
959 EXPORT_C void CFindItemDialog::ProcessCommandL( TInt aCommandId ) |
954 EXPORT_C void CFindItemDialog::ProcessCommandL( TInt aCommandId ) |
960 { |
955 { |
961 TBool selectionVisibility ( ETrue ); |
|
962 if ( iSingleClick && iEdwin && iEdwin->TextView() ) |
|
963 { |
|
964 selectionVisibility = iEdwin->TextView()->SelectionVisible(); |
|
965 iEdwin->TextView()->SetSelectionVisibilityL( EFalse ); |
|
966 |
|
967 CFindItemEngine::SFoundItem item; |
|
968 TBool founditem = iController->Item( item ); |
|
969 if ( founditem ) |
|
970 { |
|
971 iEdwin->SetSelectionL( item.iStartPos, item.iStartPos + item.iLength ); |
|
972 } |
|
973 else |
|
974 { |
|
975 iEdwin->SetSelectionL( iLastTappedItem.iX, iLastTappedItem.iY ); |
|
976 } |
|
977 } |
|
978 |
|
979 CAknDialog::ProcessCommandL( aCommandId ); |
956 CAknDialog::ProcessCommandL( aCommandId ); |
980 switch (aCommandId) |
957 switch (aCommandId) |
981 { |
958 { |
982 // General cmds |
959 // General cmds |
983 case EFindItemCmdNextItem: |
960 case EFindItemCmdNextItem: |
1162 } |
1133 } |
1163 #endif // RD_VIRTUAL_PHONEBOOK |
1134 #endif // RD_VIRTUAL_PHONEBOOK |
1164 break; |
1135 break; |
1165 } |
1136 } |
1166 } |
1137 } |
1167 if ( iSingleClick && iEdwin && iEdwin->TextView() ) |
|
1168 { |
|
1169 iEdwin->TextView()->SetSelectionVisibilityL( selectionVisibility ); |
|
1170 if ( aCommandId != EFindItemCmdNextItem && aCommandId != EFindItemCmdPrevItem ) |
|
1171 { |
|
1172 iEdwin->ClearSelectionL(); |
|
1173 } |
|
1174 iEdwin->DrawDeferred(); |
|
1175 } |
|
1176 } |
1138 } |
1177 |
1139 |
1178 // ----------------------------------------------------------------------------- |
1140 // ----------------------------------------------------------------------------- |
1179 // CFindItemDialog::DynInitMenuPaneL |
1141 // CFindItemDialog::DynInitMenuPaneL |
1180 // Initializes items on the menu |
1142 // Initializes items on the menu |
1288 ; |
1250 ; |
1289 } |
1251 } |
1290 |
1252 |
1291 aMenuPane->AddMenuItemsL( resource, EAknFormMaxDefault - 1, ETrue ); |
1253 aMenuPane->AddMenuItemsL( resource, EAknFormMaxDefault - 1, ETrue ); |
1292 |
1254 |
1293 if ( iSingleClick && !foundItem ) |
|
1294 { |
|
1295 switch ( resource ) |
|
1296 { |
|
1297 case (R_FINDITEM_MAIL_ADDRESS_MENU): |
|
1298 { |
|
1299 aMenuPane->SetItemDimmed ( EFindItemCmdCopy, ETrue ); |
|
1300 aMenuPane->SetItemDimmed ( EFindItemSubMenuSend, ETrue ); |
|
1301 aMenuPane->SetItemDimmed ( EFindItemCmdCreateContactCard, ETrue ); |
|
1302 break; |
|
1303 } |
|
1304 |
|
1305 case (R_FINDITEM_URL_ADDRESS_MENU): |
|
1306 { |
|
1307 aMenuPane->SetItemDimmed ( EFindItemCmdGoToUrl, ETrue ); |
|
1308 aMenuPane->SetItemDimmed ( EFindItemCmdAddToBookmark, ETrue ); |
|
1309 aMenuPane->SetItemDimmed ( EFindItemCmdCreateContactCard, ETrue ); |
|
1310 aMenuPane->SetItemDimmed ( EFindItemCmdCopy, ETrue ); |
|
1311 break; |
|
1312 } |
|
1313 |
|
1314 case (R_FINDITEM_PHONENUMBER_MENU): // fall through |
|
1315 case (R_FINDITEM_TELINTERNETNUMBER_MENU): |
|
1316 { |
|
1317 aMenuPane->SetItemDimmed ( EFindItemCmdCall, ETrue ); |
|
1318 aMenuPane->SetItemDimmed ( EFindItemCmdCopy, ETrue ); |
|
1319 aMenuPane->SetItemDimmed ( EFindItemSubMenuSend, ETrue ); |
|
1320 aMenuPane->SetItemDimmed ( EFindItemCmdCreateContactCard, ETrue ); |
|
1321 break; |
|
1322 } |
|
1323 |
|
1324 default: |
|
1325 { |
|
1326 break; |
|
1327 } |
|
1328 } |
|
1329 } |
|
1330 |
1255 |
1331 if ( iSearchCase == KSearchTelInternetNumber && |
1256 if ( iSearchCase == KSearchTelInternetNumber && |
1332 iFindItemVoIPExtension->VoIPProfilesExistL() || |
1257 iFindItemVoIPExtension->VoIPProfilesExistL() || |
1333 iSearchCase == KSearchTelInternetNumber && |
1258 iSearchCase == KSearchTelInternetNumber && |
1334 !iFindItemVoIPExtension->VoIPProfilesExistL() && |
1259 !iFindItemVoIPExtension->VoIPProfilesExistL() && |
1352 } |
1277 } |
1353 else if ( |
1278 else if ( |
1354 iSearchCase & CFindItemEngine::EFindItemSearchPhoneNumberBin && |
1279 iSearchCase & CFindItemEngine::EFindItemSearchPhoneNumberBin && |
1355 !iHideCallMenu ) |
1280 !iHideCallMenu ) |
1356 { |
1281 { |
1357 if ( !iSingleClick || foundItem ) |
1282 aMenuPane->SetItemDimmed( EFindItemCmdCall, ETrue ); |
1358 { |
1283 aMenuPane->AddMenuItemsL( |
1359 aMenuPane->SetItemDimmed( EFindItemCmdCall, ETrue ); |
1284 R_FINDITEM_CALLUI_AIW_ITEM, |
1360 aMenuPane->AddMenuItemsL( |
1285 EFindItemCmdCall ); |
1361 R_FINDITEM_CALLUI_AIW_ITEM, |
|
1362 EFindItemCmdCall ); |
|
1363 } |
|
1364 } |
1286 } |
1365 |
1287 |
1366 aMenuPane->DeleteMenuItem( EAknFormCmdEdit ); |
1288 aMenuPane->DeleteMenuItem( EAknFormCmdEdit ); |
1367 aMenuPane->DeleteMenuItem( EAknFormCmdAdd ); |
1289 aMenuPane->DeleteMenuItem( EAknFormCmdAdd ); |
1368 aMenuPane->DeleteMenuItem( EAknFormCmdSave ); |
1290 aMenuPane->DeleteMenuItem( EAknFormCmdSave ); |
1369 aMenuPane->DeleteMenuItem( EAknFormCmdLabel ); |
1291 aMenuPane->DeleteMenuItem( EAknFormCmdLabel ); |
1370 aMenuPane->DeleteMenuItem( EAknFormCmdDelete ); |
1292 aMenuPane->DeleteMenuItem( EAknFormCmdDelete ); |
1371 |
1293 |
1372 #ifndef RD_VIRTUAL_PHONEBOOK |
1294 #ifndef RD_VIRTUAL_PHONEBOOK |
1373 if ( !iSingleClick || foundItem ) |
1295 iPbkDataSave->AddMenuItemsL( |
1374 { |
1296 aMenuPane, |
1375 iPbkDataSave->AddMenuItemsL( |
1297 EFindItemCmdCreateContactCard ); |
1376 aMenuPane, |
|
1377 EFindItemCmdCreateContactCard ); |
|
1378 } |
|
1379 #else |
1298 #else |
1380 if ( !iSingleClick || foundItem ) |
1299 aMenuPane->SetItemDimmed( EFindItemCmdCreateContactCard, ETrue ); |
1381 { |
1300 aMenuPane->AddMenuItemsL( |
1382 aMenuPane->SetItemDimmed( EFindItemCmdCreateContactCard, ETrue ); |
1301 R_FINDITEM_CONTACTS_AIW_ITEM, |
1383 aMenuPane->AddMenuItemsL( |
1302 EFindItemCmdCreateContactCard ); |
1384 R_FINDITEM_CONTACTS_AIW_ITEM, |
|
1385 EFindItemCmdCreateContactCard ); |
|
1386 } |
|
1387 #endif // !RD_VIRTUAL_PHONEBOOK |
1303 #endif // !RD_VIRTUAL_PHONEBOOK |
1388 |
1304 |
1389 // Delete next/prev item items from menu if a last/next |
1305 // Delete next/prev item items from menu if a last/next |
1390 // item is currently selected (or if sensitive menu) |
1306 // item is currently selected (or if sensitive menu) |
1391 if ( iController->FirstItem() || iIsSensitiveMenu ) |
1307 if ( iController->FirstItem() || iIsSensitiveMenu ) |
1450 TBool founditem = EFalse; |
1366 TBool founditem = EFalse; |
1451 |
1367 |
1452 switch ( code ) |
1368 switch ( code ) |
1453 { |
1369 { |
1454 case EKeyRightArrow: |
1370 case EKeyRightArrow: |
1455 if ( iSingleClick && !CurrentItemHasHighlight() ) |
|
1456 { |
|
1457 HighlightCurrentItem(); |
|
1458 break; |
|
1459 } |
|
1460 iController->NextItemL(); |
1371 iController->NextItemL(); |
1461 break; |
1372 break; |
1462 case EKeyDownArrow: |
1373 case EKeyDownArrow: |
1463 if ( iSingleClick && !CurrentItemHasHighlight() ) |
|
1464 { |
|
1465 HighlightCurrentItem(); |
|
1466 break; |
|
1467 } |
|
1468 iController->MoveDownL(); |
1374 iController->MoveDownL(); |
1469 break; |
1375 break; |
1470 case EKeyLeftArrow: |
1376 case EKeyLeftArrow: |
1471 if ( iSingleClick && !CurrentItemHasHighlight() ) |
|
1472 { |
|
1473 HighlightCurrentItem(); |
|
1474 break; |
|
1475 } |
|
1476 iController->PrevItemL(); |
1377 iController->PrevItemL(); |
1477 break; |
1378 break; |
1478 case EKeyUpArrow: |
1379 case EKeyUpArrow: |
1479 if ( iSingleClick && !CurrentItemHasHighlight() ) |
|
1480 { |
|
1481 HighlightCurrentItem(); |
|
1482 break; |
|
1483 } |
|
1484 iController->MoveUpL(); |
1380 iController->MoveUpL(); |
1485 break; |
1381 break; |
1486 case EKeyOK: |
1382 case EKeyOK: |
1487 case EKeyEnter: |
1383 case EKeyEnter: |
1488 if ( iSingleClick && !CurrentItemHasHighlight() ) |
|
1489 { |
|
1490 HighlightCurrentItem(); |
|
1491 break; |
|
1492 } |
|
1493 iIsSensitiveMenu = ETrue; |
1384 iIsSensitiveMenu = ETrue; |
1494 iMenuBar->SetMenuType(CEikMenuBar::EMenuContext); |
1385 iMenuBar->SetMenuType(CEikMenuBar::EMenuContext); |
1495 CAknDialog::DisplayMenuL(); |
1386 CAknDialog::DisplayMenuL(); |
1496 break; |
1387 break; |
1497 case EKeyPhoneSend: |
1388 case EKeyPhoneSend: |
1498 if ( iSingleClick && !CurrentItemHasHighlight() ) |
|
1499 { |
|
1500 HighlightCurrentItem(); |
|
1501 break; |
|
1502 } |
|
1503 |
1389 |
1504 if ( !iDialData ) |
1390 if ( !iDialData ) |
1505 { |
1391 { |
1506 break; |
1392 break; |
1507 } |
1393 } |
1924 } |
1810 } |
1925 |
1811 |
1926 UpdateScrollIndicatorL(); |
1812 UpdateScrollIndicatorL(); |
1927 |
1813 |
1928 iEdwin->TextView()->SetSelectionVisibilityL( ETrue ); |
1814 iEdwin->TextView()->SetSelectionVisibilityL( ETrue ); |
1929 if ( !iSingleClick ) |
1815 iEdwin->SetSelectionL( item.iStartPos, item.iLength + item.iStartPos ); |
1930 { |
|
1931 iEdwin->SetSelectionL( item.iStartPos, item.iLength + item.iStartPos ); |
|
1932 } |
|
1933 } |
1816 } |
1934 else |
1817 else |
1935 {// Let's show a information note if no items were found |
1818 {// Let's show a information note if no items were found |
1936 HBufC* infoNote = |
1819 HBufC* infoNote = |
1937 iEikonEnv->AllocReadResourceLC( |
1820 iEikonEnv->AllocReadResourceLC( |
2404 default: |
2287 default: |
2405 break; |
2288 break; |
2406 } |
2289 } |
2407 } |
2290 } |
2408 |
2291 |
2409 // ---------------------------------------------------------------------------- |
|
2410 // CFindItemDialog::CurrentItemHasHighlight |
|
2411 // ---------------------------------------------------------------------------- |
|
2412 // |
|
2413 TBool CFindItemDialog::CurrentItemHasHighlight() |
|
2414 { |
|
2415 CFindItemEngine::SFoundItem item; |
|
2416 TBool foundItem = iController->Item( item ); |
|
2417 |
|
2418 // foundItem remains as ETrue, if item found by controller is exactly |
|
2419 // same as highlighted selection |
|
2420 |
|
2421 TCursorSelection selection( iEdwin->Selection() ); |
|
2422 TInt selectionLength = iEdwin->SelectionLength(); |
|
2423 |
|
2424 foundItem = foundItem && ( ( item.iLength == selectionLength ) && ( item.iStartPos == Min( selection.iCursorPos, selection.iAnchorPos ) ) ); |
|
2425 |
|
2426 foundItem = foundItem && ( iEdwin && iEdwin->TextView() |
|
2427 && iEdwin->TextView()->SelectionVisible() ); |
|
2428 |
|
2429 return foundItem; |
|
2430 } |
|
2431 |
|
2432 // ---------------------------------------------------------------------------- |
|
2433 // CFindItemDialog::HighlightCurrentItem |
|
2434 // ---------------------------------------------------------------------------- |
|
2435 // |
|
2436 void CFindItemDialog::HighlightCurrentItem() |
|
2437 { |
|
2438 CFindItemEngine::SFoundItem item; |
|
2439 TBool found = iController->Item( item ); |
|
2440 |
|
2441 if ( found && iEdwin && iEdwin->TextView() ) |
|
2442 { |
|
2443 TRAPD( err, iEdwin->TextView()->SetSelectionVisibilityL( ETrue ) ); |
|
2444 if ( KErrNone == err ) |
|
2445 { |
|
2446 //When set selection leaves, we can't highlight the item, so just ignore this leave. |
|
2447 TRAP_IGNORE( iEdwin->SetSelectionL( item.iStartPos, item.iStartPos + item.iLength ) ); |
|
2448 } |
|
2449 } |
|
2450 } |
|
2451 |
|
2452 |
2292 |
2453 // |
2293 // |
2454 // CONTAINER CLASS |
2294 // CONTAINER CLASS |
2455 // |
2295 // |
2456 |
2296 |