Is there any way to search for text in backup QM file (.qml). I understand that with the File Viewer you can search for QM-items, but not for text in QM-items.
#sub DlgProc v function# hdlg message wParam lParam
sel message ,caseWM_INITDIALOGsub.Init hdlg ,caseWM_DESTROY ,caseWM_COMMANDgoto messages2 ,caseWM_NOTIFYgoto messages3 ret ;messages2 sel wParam ,case6sub.Find;;Find ,case7;;Stop ,case14RegExpMenuid(3 hDlg);;RX , ret1 ;messages3 NMHDR* nh=+lParam NMITEMACTIVATE* na=+nh int i sel nh.code ,caseLVN_ITEMCHANGED ,if(na.uNewState&LVIS_SELECTEDand na.uOldState&LVIS_SELECTED=0);;listview item selected ,,sel nh.idFrom ,,,case8;;files ,,,SendMessage hItems LVM_DELETEALLITEMS00 ,,,i=na.iItem;if(i<0or i>=aFiles.len)ret ,,,hid hItems ;;10 times faster; we don't use ownerdraw ,,,currentFile=aFiles[i] ,,,sub.FindInFile(currentFile 1) ,,,hid- hItems ,,, ,,,case9;;items ,,,sub.OpenItem na.lParam
#sub Init v function hdlg
hDlg=hdlg; hFiles=id(8 hDlg); hItems=id(9 hDlg)
int h=id(5 hDlg) rget _s "backup folder""software\gindi\qm2\settings"0"$my qm$\backup";CB_Add h _s rget _s "file""software\gindi\qm2\settings"0"$my qm$\main.qml";CB_Add h _s.getpath(_s "") CB_SelectItem h 0
int es=LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP SendMessage hFiles LVM_SETEXTENDEDLISTVIEWSTYLE es es SendMessage hItems LVM_SETEXTENDEDLISTVIEWSTYLE es es sub.LvAddCol hFiles 0"File"-54 sub.LvAddCol hFiles 1"Date modified"-40 sub.LvAddCol hItems 0"Item"-90 SendMessage hItems LVM_SETIMAGELISTLVSIL_SMALL__ImageListFromIcons("$qm$\empty.ico[]$qm$\macro.ico[]$qm$\function.ico[]$qm$\menu.ico[]$qm$\toolbar.ico[]$qm$\tsm.ico[]$qm$\folder.ico[]$qm$\member.ico[]$qm$\filelink.ico"16)
DT_SetAutoSizeControls hDlg "8sv 9s"
#sub Find v
str sFolder int i j
SendMessage hFiles LVM_DELETEALLITEMS00 SendMessage hItems LVM_DELETEALLITEMS00
aFiles=0; aItems=0
sFolder.getwintext(id(5 hDlg)) ARRAY(str) a
i=32;if(but(13 hDlg)) i|4 GetFilesInFolder a sFolder "*.qml" i 2 if(!a.len)ret
a.sort(9) for i 0 a.len ,DateTime t=val(a[i] 1 _i) ,str sPath=a[i]+_i+1 ,j=sub.FindInFile(sPath 0);if(!j)continue;elseif(j<0)break ,t.UtcToLocal ,aFiles[]=sPath ,sub.LvAdd hFiles i 0-2 sPath.getfilename t.ToStr(4)
#sub FindInFile v function#$sPath !all ;;returns: 1 found, 0 not found, -1 rx error
str sFind.getwintext(id(3 hDlg));if(!sFind.len)ret1 int flags=!but(10 hDlg)|(but(11 hDlg)*2)|(but(12 hDlg)*4);;1 insens, 2 word, 4 regexp str sf if(flags&4)findrx("" sFind 0 flags&3|128 sf);errout _error.description;ret-1 else sf=sFind int found i Sqlite x.Open(sPath 1) SqliteStatement t g
t.Prepare(x "SELECT text,rowid FROM texts")
g.Prepare(x "SELECT name,flags FROM items WHERE rowid=?1") rep ,if(!t.FetchRow)break ,lpstr st=t.GetText(0) ,;find sf in st ,if(flags&4) i=findrx(st sf) ,elseif(flags&2) i=findw(st sf 0"" flags&1|64) ,else i=find(st sf 0 flags&1) ,if(i<0)continue ,found=1 ,if(!all)break ,;add to items listview ,str s;int rowid=t.GetInt(1) ,g.BindInt(1 rowid) ,g.FetchRow ,s=g.GetText(0) ,sub.LvAdd hItems -1 rowid g.GetInt(1)&255 s ,g.Reset ret found err+outF"Cannot search in {sPath}. Error: {_error.description}"
#sub OpenItem v function rowid Sqlite x.Open(currentFile 1) ARRAY(str) a
x.Exec(F"SELECT text FROM texts WHERE rowid={rowid}" a) ;QmHelp F"<code>{a[0 0]}</code>" 0 6 newitem"Find text in QM files" a[00] "Macro"""""3|4|128
#sub LvAddCol function hlv index $txt width
;Adds column to SysListView32 control that has LVS_REPORT style (1). ;Index of first colunm is 0. If index <0, adds to the end. ;If width <0, it is interpreted as -percentage.
if index>=0 ,int i;str* p=&s ,for i 1getopt(nargs)-4 ,,lvi.iItem=index ,,lvi.iSubItem=i ,,lvi.pszText=@p[i] ,,SendMessage(hlv LVM_SETITEMTEXTW index &lvi)
I would appreciate it if you could kindly supply some information and/or redirection to some other URL addreess (MSDN ?), regarding the values of the 4-th parameter (image) in LvAdd. I have already seen values equal to -2 and -1. I understand it has to do with the image potentially associated with a line. Many thanks in advance.
I wonder whether this excellent routine could be extended, so as to include searching for the existence of a particular qm-item in the .qml files to examined, and if positive to give its time modified. Furthermore, I would like to ask whether there exists a qmitem-like routine to search for a particular qm-item in a given .qml file.
I would much appreciate your advice. Best regards.
I attach my contribution on the above routine "dialog_find_text_in_qm_files" so as to search for qm-items in a qml file. Any suggestion will be appreciated.