| Reply | « Previous Thread | Next Thread » |
|
One cool feature of windows based phones is that you can search contacts by typing their numbers, my idea is to simulate that in symbian, with this program user will be able to search in numbers, names, email addressed, URLs and even notes.
this program will seprate numbers to three parts, so you don't have to type area code in your search. this will categorize data using their contents, not field names, so if you type an E-mail address in notes field, it will categorized as E-mail. Code:
import e32
import string
import appuifw
import contacts
import telephone
from key_codes import EScancode0, EScancode1, EScancode2, EScancode3, EScancode4, EScancode5
digits='0123456789+'
currentList=[]
mailList=[]
nameList=[]
numList=[]
otherList=[]
wwwList=[]
myDic={}
db=contacts.open()
def FillLists():
global currentList, mailList, nameList, numList, otherList, wwwList, myDic
for recordKey in db:
nameList.append(db[recordKey].title)
myDic[db[recordKey].title]=recordKey
for field in db[recordKey]:
data=field.value
if string.find(digits, data[0])>-1:
str=data[0:len(data)-7]+" "+data[len(data)-7:len(data)-4]+" "+data[len(data)-4:len(data)]
numList.append(str)
elif string.find(data,'@')>-1:
str=data[0:string.find(data,'@')+1]+" "+data[string.find(data,'@')+1:len(data)]
mailList.append(str)
elif string.find(data,'www.')>-1:
str=data[0:string.find(data,'.')+1]+" "+data[string.find(data,'.')+1:string.rfind(data,'.')+1]+" "+data[string.rfind(data,'.')+1:len(data)]
wwwList.append(str)
elif string.find(data,'http:')>-1:
str=data[0:string.find(data,'/')+2]+" "+data[string.find(data,'/')+2:string.rfind(data,'.')+1]+" "+data[string.rfind(data,'.')+1:len(data)]
wwwList.append(str)
else:
str=data
otherList.append(str)
myDic[str]=recordKey
def Call():
oldTitle=appuifw.app.title
appuifw.app.title=u'Dial'
tmpList=[]
for i in db[myDic[currentList[mainList.current()]]]:
if string.find(digits, i.value[0])>-1:
tmpList.append(i.value)
if len(tmpList)==0:
appuifw.note(u'No numbers found' ,'error')
elif len(tmpList)==1:
telephone.dial(tmpList[0])
else:
index=appuifw.selection_list(tmpList)
telephone.dial(tmpList[index])
appuifw.app.title=oldTitle
def Search(inList):
oldTitle=appuifw.app.title
appuifw.app.title=u'Search'
index=appuifw.multi_selection_list(inList,'checkbox',1)
tmpList=[]
for i in index:
dbID=myDic[inList[i]]
tmpList.append(db[dbID].title)
global currentList
if len(tmpList)>0:
currentList=tmpList
mainList.set_list(currentList)
appuifw.app.title=oldTitle
APP_LOCK=e32.Ao_lock()
mainList=appuifw.Listbox([u'Collecting data...', u'Please wait'])
mainList.bind(EScancode1, lambda:Search(nameList))
mainList.bind(EScancode2, lambda:Search(numList))
mainList.bind(EScancode3, lambda:Search(mailList))
mainList.bind(EScancode4, lambda:Search(wwwList))
mainList.bind(EScancode5, lambda:Search(otherList))
mainList.bind(EScancode0, lambda:mainList.set_list(nameList))
appuifw.app.body=mainList
appuifw.app.exit_key_handler=APP_LOCK.signal
appuifw.app.title=u'Contact search'
appuifw.app.menu=[(u"Call", lambda:Call()),
(u"[1] Search in names", lambda:Search(nameList)),
(u"[2] Search in numbers", lambda:Search(numList)),
(u"[3] Search in mails", lambda:Search(mailList)),
(u"[4] Search in URLs", lambda:Search(wwwList)),
(u"[5] Search in others", lambda:Search(otherList)),
(u"[0] View all", lambda:mainList.set_list(nameList))]
FillLists()
currentList=nameList
mainList.set_list(currentList)
APP_LOCK.wait()
Last edited by pythonkid : 2008-10-27 at 11:56.
Reason: typing mistake
|
|
Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Rafael T.
Offline
Forum Nokia Champion
|
|
Hi pythonkid,
Now we have another great idea here. I've seen applications like that in Symbian C++ already, but never in PyS60 ![]() I'll probably use this many times, since the application I used for this is too buggy. Thanks for contributing with the Python DiBo! Keep it up! BR, Rafael.
Last edited by Rafael T. : 2008-10-26 at 20:53.
|
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
Nice work. Maybe you should add it to the Wiki as example code.
|
|
Hi python kid,
its really a nice idea and great work done. Do add your code at wiki also. Best regards. Jajal Mehul |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Online
Forum Nokia Champion
|
|
hi pythonkid
this is a very excellent code. Good work keep it up. Enjoy Pythoning Gaba88 Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
Quote:
![]() I guess you can still add some more comments to the Search and Call functions, in the code snippet, so that others can understand it better ![]() Best Regards, Croozeus |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| [Announce] Sensor API Sample Code | JOM | Python | 2 | 2008-05-01 11:44 |
| New sample code "Sensor" has been developed! | liuxg | Symbian | 2 | 2008-03-06 02:50 |
| Getting started using Carbide c++ 1.1 -> how to import the sample code | terchris | Carbide.c++ IDE and plug-ins | 3 | 2007-11-20 10:12 |
| Where can i find sample code? | eqing2008 | General Symbian C++ | 2 | 2006-11-30 08:15 |
| Symbian Source Code Repository and Search Engine | SimonJudge | General Symbian C++ | 0 | 2005-07-08 19:38 |