四、删除一個entry從Phone List中删除一個entry。
mmi_phb_entry_op_option_sim()
ShowCategory15Screen()
選擇[删除],SetHiliteHandler(MITEM1012_PBOOK_DELETE, mmi_phb_highlight_op_delete_entry);
mmi_phb_entry_op_delete_confirm() //是否删除?
mmi_phb_op_delete_entry_req() //删除
mmi_phb_show_in_progress(STR_PHB_DELETING, IMG_GLOBAL_DELETED); //顯示“正在處理”資訊
store_index = g_phb_name_index[g_phb_cntx.active_index]; //擷取這個entry在PhoneBook[]中的存儲位置
myMsgPtr->index = (storage == MMI_SIM) ? (store_index + 1) - MAX_PB_PHONE_ENTRIES : (store_index + 1); //entry在L4中存儲位置
發送消息:PRT_PHB_DEL_ENTRY_REQ到L4.
SetProtocolEventHandler(mmi_phb_op_delete_entry_rsp, PRT_PHB_DEL_ENTRY_RSP); //設定CBack函數
調整histroy screen。
L4傳回消息:
mmi_phb_op_delete_entry_rsp()
if (localPtr->result.flag == 0 /* OK */ )
{
PhbUpdateSpeedDial(storage, record_index, MMI_PHB_PHONEBOOK, NULL, NULL); //根據NVRAM的存儲位置record_index,更新速撥資訊。(速撥資訊中也儲存 record_index資訊。)
if (store_index >= MAX_PB_PHONE_ENTRIES) //删除的entry是SIM卡中号碼
{
g_phb_cntx.sim_used--;
}
else //删除的是ME中号碼
{
g_phb_cntx.phone_used--;
删除optional IDs.
删除video.
删除生日。
deletedCnt = mmi_phb_op_clear_lookup_table_by_index(store_index); 設定LookUpTable[]中number = 1000000000(無效号碼)
if (deletedCnt)
{
mmi_phb_lookup_table_sort(); //對LookUpTable[]重新排序
g_phb_cntx.lookup_table_count -= deletedCnt;
}
mmi_phb_op_delete_update_index(store_index);
for (pos = 0; pos < PhoneBookEntryCount; pos++)
{
if (g_phb_name_index[pos] == store_index)
{
PhoneBookEntryCount--; //總的phone entries遞減
break;
}
}
for (i = pos; i < PhoneBookEntryCount; i++) //調整g_phb_name_index[]中的索引位置。
{
g_phb_name_index[i] = g_phb_name_index[i + 1];
}
//注意:這裡并沒有清除PhoneBook[store_index]中的内容。因為在對phone entries進行操作時,不是直接操作PhoneBook[]的,而是通過索引的。
//另外:在上面的存儲一個entry時,在把姓名和号碼儲存到PhoneBook[]時,并沒有在PhoneBook[]中查找一個空的位置來存儲,所使用的stort_index是從 L4傳過來的。也就是:在儲存一個entry到L4時,在CBack函數中,L4會傳回一個存儲位置:record_index,然後store_index = record_index – 1。
}
}
else //删除失敗
{
}
五、快速查找
思路是:第一次進入快速查找時,SHOW出所有的entry。使用者輸入一個字母後,輸入的字母與所有的entries的前2個位元組比較,如果符合的話,就把該entry增加到一個指針數組中。使用者輸入第二個字母後,再把輸入的所有字母與所有的entries比較,再次設定指針。。。。。。
mmi_phb_quick_search_list_pre_entry()
//注意這2個函數:第一個是MTK的快速查詢,第二個是進入百家姓
mmi_phb_entry_quick_search_list()
mmi_phb_entry_quick_search_list_ex()
mmi_phb_entry_quick_search_list()
RegisterCat200SearchFunction(mmi_phb_quick_search_find_entry);
ShowCategory200Screen();
mmi_phb_quick_search_make_cache(); //把PhoneBook[]中的entries姓名第一個字母,放入g_phb_qsearch_cache[]中。(前2個位元組)
當使用者輸入一個字母如:a,進入:
Cat200multitap_inputcallback(UI_character_type inp) //inp=’a’
if (inp != 0)
{
gui_single_line_input_box_insert_multitap_character(&MMI_singleline_inputbox, inp); //把’a’插入MMI_singleline_inputbox中。
}
if (!gui_single_line_input_box_test_overflow(&MMI_singleline_inputbox)) //判斷輸入是否溢出
{
if (cat200_search_function) //上面注冊的函數
{
no_entries = cat200_search_function(MMI_singleline_inputbox.text);//輸入的字母與PhoneBook[]中比較,過濾,設定g_phb_qsearch[]
load_dynamic_item_buffer(no_entries); //根據g_phb_qsearch[]的值,動态擷取比對的entry
if (no_entries >= 0)
{
refresh_search_list_change_list(no_entries);
}
singleline_inputbox_input_callback();
redraw_singleline_inputbox();
gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
}
}
小結:
1.Show 出所有的entries,最下面供使用者輸入,設定g_phb_qsearch[]全部為1。
2.使用者輸入第一個字母。把這個字母與所有entries的首字母比較。若相等,設定g_phb_qsearch[i]=1;否則g_phb_qsearch[i]=0。
然後重新擷取所有g_phb_qsearch[i]=1的entries,并show list。
3.使用者輸入第二個字母。把這2個輸入的字母與所有的entries比較。若相等,設定g_phb_qsearch[i]=1;否則g_phb_qsearch[i]=0。
然後重新擷取所有g_phb_qsearch[i]=1的entries,并show list。
4.如此繼續。。。。。。
5.當删除一個字母時,所做的操作相同。
六、姓名查找
mmi_phb_highlight_search_name()
mmi_phb_search_name_pre_entry()
if (PhoneBookEntryCount)
{
mmi_phb_entry_search_name();
ShowCategory5Screen_ext(); //接收使用者輸入姓名:pbName。
SetLeftSoftkeyFunction(mmi_phb_entry_search_name_option, KEY_EVENT_UP);
}
左軟體選項:
mmi_phb_entry_search_name_option()
ShowCategory15Screen(); //2個選擇:[查找] mmi_phb_highlight_search_name_option_search()
[輸入法] mmi_phb_highlight_search_name_option_input_method()
1.輸入法相關知識
EntryInputMethodScreen()
ShowCategory15Screen()
左軟體響應:
InputMethodScreenHandleLSK()
S32 index = GetHighlightedItem();
currPreFuncPtr = preHandleInputMethodLSKFuncPtrs[index];
currPostFuncPtr = postHandleInputMethodLSKFuncPtrs[index];
if (currPreFuncPtr != NULL)
{
(*currPreFuncPtr) ();
}
if (currPostFuncPtr != NULL)
{
(*currPostFuncPtr) ();
}
2.查找
mmi_phb_search_name()
g_phb_cntx.highlight_entry = mmi_phb_search_name_find_closet(); //查找到的應該高亮的entry
mmi_phb_list_pre_entry(); //動态show所有的entries。
mmi_phb_entry_list( PhoneBookEntryCount, /* Total Entry */
STR_SCR_PBOOK_VIEW_CAPTION, /* Title String */
IMG_SCR_PBOOK_CAPTION, /* Title Image */
STR_GLOBAL_OPTIONS, /* LSK */
IMG_GLOBAL_OPTIONS, /* LSK */
#if defined(__MMI_INTELLIGENT_CALL_ALERT__)
mmi_phb_get_index_speak_name,
#else
mmi_phb_get_index, /* Highlight Callback */
#endif
mmi_phb_entry_op_option, /* LSK Callback */
send_key_ptr, /* SEND Key Callback */
mmi_phb_list_get_item, /* List Callback */
mmi_phb_list_get_hint, /* Hint Callback */
mmi_phb_list_pre_entry, /* Re-Entry Callback */
TRUE, /* Alpha Index */
TRUE); /* Right Arrow Key */
ShowCategory184Screen(
STR_TITLE,
IMG_TITLE,
STR_LSK,
IMG_LSK,
STR_GLOBAL_BACK,
IMG_GLOBAL_BACK,
EntryCount,
ItemPtr,
HintPtr,
g_phb_cntx.highlight_entry,
guiBuffer);
如何根據姓名查找:
mmi_phb_search_name_find_closet()
if (pfnUnicodeStrlen((S8*) pbName) == 0)
{
return 0;
}
result_index = mmi_phb_search_name_binary_search(0, (PhoneBookEntryCount - 1), (S8*) pbName);
//find the position of ucs2_name in the array g_phb_name_index[] between low and high;
mmi_phb_search_name_binary_search()
輸入的姓名與PhoneBook[]中的姓名比較,直到找出一個合适的entry作為高亮。