Schnellfiltersuche mit mehreren Wörtern?

Aktuelle Version: 12.21 (22.06.2020)
Alles zum Thema Directory Opus
Antworten
Jochen
Beiträge: 115
Registriert: 19. Feb 2008 14:17
Betriebssystem: Windows 10 64 bit

Schnellfiltersuche mit mehreren Wörtern?

Beitrag von Jochen »

Hallo,
ich verwende sehr häufig die Schnellfiltersuche um eine lange Reihe von Ordner zu filtern und nur die passenden anzuzeigen. Ebenso innerhalb eines Ordners mit einer Vielzahl von Dateien.
Kann man auch mehrere Wörter kombinieren um die Anzeige noch weiter einzugrenzen?
Vielen Dank
Benutzeravatar
tbone
Berater
Beiträge: 656
Registriert: 22. Nov 2014 21:16
Betriebssystem: 7*64

Re: Schnellfiltersuche mit mehreren Wörtern?

Beitrag von tbone »

Geht leider mit dem Standard nicht, habe ich auch schon mehrmals angefragt.
Meiner Meinung wäre das einfach umzusetzen für die Entwickler, aber was ist meine Meinung. o)

Daher habe ich irgendwann mal diesen Button hier entwickelt, er öffnet ein Feld und erlaubt die Eingabe mehrerer Suchbegriffe, die dann über eine Permutation alle möglichen "ODER" Fälle generiert, weil der Quickfilter eben nur "odern" kann.

Vielleicht probierste den mal.. o)

Code: Alles auswählen

<?xml version="1.0"?>
<button backcol="none" display="icon" label_pos="right" textcol="none">
	<label>ISEFilter</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>//https://resource.dopus.com/t/select-folders-which-sub-folder-s-contains-certain-file/17860/28</instruction>
		<instruction />
		<instruction>String.prototype.lTrim = function(chr){chr=chr||&quot;\\s&quot;;return new String(this.replace(new RegExp(&quot;^&quot;+chr+&quot;*&quot;),&apos;&apos;));}</instruction>
		<instruction>String.prototype.rTrim = function(chr){chr=chr||&quot;\\s&quot;;return new String(this.replace(new RegExp(chr+&quot;*$&quot;),&apos;&apos;));}</instruction>
		<instruction>String.prototype.trim = function(chr){return this.lTrim(chr).rTrim(chr);}</instruction>
		<instruction>String.prototype.left = function(chrs){return this.substring(0,chrs);}</instruction>
		<instruction>String.prototype.right = function(chrs){return this.substring(this.length-chrs);}</instruction>
		<instruction>String.prototype.contains = function (s,nocs){return (nocs?this.toUpperCase():this).indexOf(nocs?s.toUpperCase():s)&gt;=0;};</instruction>
		<instruction>String.prototype.startsWith = function (s,nocs){return (nocs?this.toUpperCase():this).indexOf(nocs?s.toUpperCase():s)==0;};</instruction>
		<instruction>String.prototype.endsWith = function (s,nocs){return (nocs?this.toUpperCase():this).slice(-s.length)==(nocs?s.toUpperCase():s);};</instruction>
		<instruction />
		<instruction>function OnClick(data) {</instruction>
		<instruction>	var Dlg = DOpus.Dlg;</instruction>
		<instruction>	var f = data.func, stab = f.sourcetab;</instruction>
		<instruction>	Dlg.window = stab;</instruction>
		<instruction>	Dlg.template = &quot;ISEFilter_dlg&quot;;</instruction>
		<instruction>	Dlg.detach = true;</instruction>
		<instruction>	var previous = { filter:stab.quickfilter.filter };</instruction>
		<instruction>	//ApplyFilter(data,&apos;&apos;,previous);</instruction>
		<instruction>	</instruction>
		<instruction>	</instruction>
		<instruction>	DOpus.Output(&quot;CurrentFilter: &quot; + stab.quickfilter.filter);</instruction>
		<instruction>	Dlg.Show(); </instruction>
		<instruction>	if (!stab.quickfilter.regex) //wildcard mode</instruction>
		<instruction>		Dlg.Control(&quot;Filter_tbx&quot;).value = parseItemsFromWildcard(stab.quickfilter.filter);</instruction>
		<instruction>		</instruction>
		<instruction>    do {</instruction>
		<instruction>		var Msg = Dlg.GetMsg();</instruction>
		<instruction>		EditChanged(data, Dlg, Msg, previous);</instruction>
		<instruction>		//DOpus.Output(&quot;Msg:&quot; + Msg.event);</instruction>
		<instruction>	} while (Msg.result);</instruction>
		<instruction>    //DOpus.Output(&quot;Return code = &quot; + Dlg.result);</instruction>
		<instruction>}</instruction>
		<instruction />
		<instruction />
		<instruction>function EditChanged(data, Dlg, Msg, previous) {</instruction>
		<instruction>    //we only want to process this when the control has focus - otherwise</instruction>
		<instruction>	//the change is one we made ourselves rather than the user</instruction>
		<instruction>    if (!Msg.focus) return;</instruction>
		<instruction>	var input = (&apos;&apos;+Msg.value).trim();</instruction>
		<instruction>	if (input==&apos;&apos;) {</instruction>
		<instruction>		ApplyFilter(data,&apos;&apos;,previous);</instruction>
		<instruction>		return;</instruction>
		<instruction>	}</instruction>
		<instruction>	input = input.split(&apos; &apos;);</instruction>
		<instruction>	input = GetPermutations(input, 100);</instruction>
		<instruction>	ApplyFilter(data,input,previous);</instruction>
		<instruction>}</instruction>
		<instruction />
		<instruction>function ApplyFilter(data,input,previous) {</instruction>
		<instruction>	if (previous.filter==input) return;</instruction>
		<instruction>	if (input==&quot;&quot;) {</instruction>
		<instruction>		data.func.command.RunCommand(&quot;Set QUICKFILTERCLEAR&quot;);</instruction>
		<instruction>		//DOpus.Output(&quot;FILTER: CLEAR&quot; + previous.filter + &quot;-&quot;);</instruction>
		<instruction>	} else {</instruction>
		<instruction>		data.func.command.RunCommand(&quot;Set QUICKFILTER=&quot;+input);</instruction>
		<instruction>		//DOpus.Output(&quot;FILTER: &quot; + input + previous.filter + &quot;-&quot;);</instruction>
		<instruction>	}</instruction>
		<instruction>	previous.filter = input;</instruction>
		<instruction>}</instruction>
		<instruction />
		<instruction>function GetPermutations(Input, limit) {</instruction>
		<instruction>	Input.sort();</instruction>
		<instruction>	for(var i=0;i&lt;Input.length;i++) {</instruction>
		<instruction>		if (Input[i].substring(0,1) == &apos;+&apos;) {</instruction>
		<instruction>			Input[i] = Input[i].substring(1);</instruction>
		<instruction>			Input[i] = &apos;(&apos;+Input[i]+&apos;)&apos;</instruction>
		<instruction>		} else {</instruction>
		<instruction>			Input[i] = &apos;&apos;+Input[i]+&apos;&apos;</instruction>
		<instruction>		}</instruction>
		<instruction>	}</instruction>
		<instruction />
		<instruction>	Values = new Array();</instruction>
		<instruction />
		<instruction>	TotalItems = Input.length;</instruction>
		<instruction />
		<instruction>	var b = Input.length;</instruction>
		<instruction>	var c = 0;</instruction>
		<instruction>	var d = 0;</instruction>
		<instruction>	Values[0] = new Array();</instruction>
		<instruction />
		<instruction>	for (var a = 0; a &lt; b; a++) {</instruction>
		<instruction>		if (a == 0 || Input[a] == Input[a - 1]) Values[c].push(Input[a]);</instruction>
		<instruction>		else {</instruction>
		<instruction>			c++;</instruction>
		<instruction>			Values[c] = new Array(Input[a]);</instruction>
		<instruction>		}</instruction>
		<instruction>	}</instruction>
		<instruction />
		<instruction />
		<instruction>	Totals = new Array();</instruction>
		<instruction />
		<instruction>	var b = Values.length;</instruction>
		<instruction>	var spaces = Input.length;</instruction>
		<instruction>	for (a = 0; a &lt; b; a++) {</instruction>
		<instruction>		Totals[a] = Choose(spaces, Values[a].length);</instruction>
		<instruction>		spaces = spaces - Values[a].length;</instruction>
		<instruction>	}</instruction>
		<instruction />
		<instruction />
		<instruction />
		<instruction>	var c = 1;</instruction>
		<instruction>	var b = Totals.length;</instruction>
		<instruction />
		<instruction>	for (a = 0; a &lt; b; a++)</instruction>
		<instruction>	c = c * Totals[a];</instruction>
		<instruction />
		<instruction>	var d = c;</instruction>
		<instruction />
		<instruction>	Totals2 = new Array();</instruction>
		<instruction>	for (a = 0; a &lt; b; a++) {</instruction>
		<instruction>		Totals2[a] = d / Totals[a];</instruction>
		<instruction>		d = Totals2[a];</instruction>
		<instruction>	}</instruction>
		<instruction />
		<instruction>	Totals2[Totals2.length - 1] = 0;</instruction>
		<instruction />
		<instruction>	return Show(1, limit, c, &apos;Permutations&apos;);</instruction>
		<instruction>}</instruction>
		<instruction />
		<instruction>function Show(From, To, Of, Type) {</instruction>
		<instruction />
		<instruction>	var Seperator = &quot;-&quot;;</instruction>
		<instruction />
		<instruction>	if (To &gt; Of) To = Of;</instruction>
		<instruction />
		<instruction>	var E = &quot;&quot;</instruction>
		<instruction>	if (To &lt; Of || From &gt; 1) E += From + &apos; to &apos; + To + &apos; of &apos;;</instruction>
		<instruction />
		<instruction>	E += Of + &apos; &apos; + Type;</instruction>
		<instruction />
		<instruction>	var b = 0;</instruction>
		<instruction>	var str = &apos;&apos;;</instruction>
		<instruction />
		<instruction>	var list = &quot;&quot;</instruction>
		<instruction>	for (var a = From - 1; a &lt; To; a++) {</instruction>
		<instruction>		var ThisStr = new Array();</instruction>
		<instruction>		ThisStr.length = TotalItems;</instruction>
		<instruction />
		<instruction>		for (b = 0; b &lt; Values.length; b++) {</instruction>
		<instruction>			if (Type == &apos;Combinations&apos;) {</instruction>
		<instruction>				f = Math.floor(a / Totals[b]) % Values[b].length;</instruction>
		<instruction>				ThisStr[b] = Values[b][f];</instruction>
		<instruction>			} else {</instruction>
		<instruction>				var FreePos = new Array();</instruction>
		<instruction>				for (var d = 0; d &lt; ThisStr.length; d++)</instruction>
		<instruction>				if (ThisStr[d] == null) FreePos.push(d);</instruction>
		<instruction />
		<instruction>				if (b == 0) n = Math.floor(a / (Of / Totals[0]));</instruction>
		<instruction>				else if (b == Values.length - 1) n = 0;</instruction>
		<instruction>				else</instruction>
		<instruction>				n = Math.floor(a / Totals2[b]) % Totals[b];</instruction>
		<instruction />
		<instruction />
		<instruction>				var Pos = GetPositions(FreePos.length, Values[b].length, n);</instruction>
		<instruction />
		<instruction>				for (var d = 0; d &lt; Pos.length; d++)</instruction>
		<instruction>				ThisStr[FreePos[Pos[d] - 1]] = Values[b][0];</instruction>
		<instruction>			}</instruction>
		<instruction>		}</instruction>
		<instruction />
		<instruction>		itemCount = ThisStr.length;</instruction>
		<instruction>		E = &quot;&quot;;</instruction>
		<instruction>		E += ThisStr.join(&apos;*&apos;);</instruction>
		<instruction>		if (0);</instruction>
		<instruction>		else if (a==From-1) { //first</instruction>
		<instruction>			list = &apos;&apos;+E+&apos;&apos;;</instruction>
		<instruction>		}</instruction>
		<instruction>		else {</instruction>
		<instruction>			list += &quot;|&quot; + &apos;&apos;+E+&apos;&apos;;</instruction>
		<instruction>		}</instruction>
		<instruction />
		<instruction>	}</instruction>
		<instruction />
		<instruction>	if (itemCount == 1) return list;</instruction>
		<instruction>	return &apos;(&apos;+list+&apos;)&apos;;</instruction>
		<instruction>	//((A).*(B)?.*(C)?) || ((A).*(C)?.*(B)?) || ((B)?.*(A).*(C)?) || ((C)?.*(A).*(B)?) || ((B)?.*(C)?.*(A)) || ((C)?.*(B)?.*(A))</instruction>
		<instruction>	//((X)?.*(Y)?.*(Z)?) || ((X)?.*(Z)?.*(Y)?) || ((Y)?.*(X)?.*(Z)?) || ((Z)?.*(X)?.*(Y)?) || ((Y)?.*(Z)?.*(X)?) || ((Z)?.*(Y)?.*(X)?)</instruction>
		<instruction>	//AddButtons(From,To,Of,Type);</instruction>
		<instruction>}</instruction>
		<instruction />
		<instruction>var Values;</instruction>
		<instruction>var Totals;</instruction>
		<instruction>var TotalItems;</instruction>
		<instruction />
		<instruction>function Factorial(n) {</instruction>
		<instruction>	if (n &lt;= 1) return 1;</instruction>
		<instruction>	else</instruction>
		<instruction>	return Factorial(n - 1) * n;</instruction>
		<instruction>}</instruction>
		<instruction />
		<instruction>function GetCombinations() {</instruction>
		<instruction>	var limit = 100;</instruction>
		<instruction>	var Input = [&apos;A&apos;, &apos;B&apos;, &apos;C&apos;];</instruction>
		<instruction>	Values = new Array();</instruction>
		<instruction />
		<instruction>	var b = Input.length;</instruction>
		<instruction>	var c = 0;</instruction>
		<instruction>	var d = 0;</instruction>
		<instruction>	Values[0] = new Array();</instruction>
		<instruction />
		<instruction>	for (var a = 0; a &lt; b; a++) {</instruction>
		<instruction>		if (Input[a] == &apos;&apos;) {</instruction>
		<instruction>			if (Values[c].length &gt; 0 &amp;&amp; Input[a + 1] != &apos;&apos;) {</instruction>
		<instruction>				c++;</instruction>
		<instruction>				d = 0;</instruction>
		<instruction>				Values[c] = new Array();</instruction>
		<instruction>			}</instruction>
		<instruction>		} else</instruction>
		<instruction>		if (Input[a].charAt(0) == &apos;*&apos;) {</instruction>
		<instruction>			var f = Number(Input[a].substr(1)) - 1;</instruction>
		<instruction>			for (var e = 0; e &lt; f; e++) {</instruction>
		<instruction>				c++;</instruction>
		<instruction>				Values[c] = Values[c - 1].slice(); // copies array</instruction>
		<instruction>			}</instruction>
		<instruction>		} else {</instruction>
		<instruction>			Values[c][d] = Input[a];</instruction>
		<instruction>			d++;</instruction>
		<instruction>		}</instruction>
		<instruction>	}</instruction>
		<instruction />
		<instruction />
		<instruction>	TotalItems = Values.length;</instruction>
		<instruction>	b = Values.length;</instruction>
		<instruction>	c = 1;</instruction>
		<instruction />
		<instruction>	Totals = new Array();</instruction>
		<instruction />
		<instruction>	for (var a = b - 1; a &gt; -1; a--) {</instruction>
		<instruction>		Totals[a] = c;</instruction>
		<instruction>		c = c * Values[a].length;</instruction>
		<instruction>	}</instruction>
		<instruction />
		<instruction>	// C ends up as the total number of combinations</instruction>
		<instruction />
		<instruction>	Show(1, limit, c, &apos;Combinations&apos;);</instruction>
		<instruction>}</instruction>
		<instruction />
		<instruction>// returns number of ways to fill N positions with k objects</instruction>
		<instruction />
		<instruction>function Choose(n, k) {</instruction>
		<instruction>	//alert(n+&apos;\n&apos;+k)</instruction>
		<instruction>	var x = Factorial(n) / (Factorial(k) * Factorial(n - k));</instruction>
		<instruction>	return x;</instruction>
		<instruction>}</instruction>
		<instruction />
		<instruction>function GetPositions(Positions, Items, n) {</instruction>
		<instruction>	var Output = new Array();</instruction>
		<instruction>	for (var a = 0; a &lt; Items; a++)</instruction>
		<instruction>	Output[a] = a + 1;</instruction>
		<instruction />
		<instruction>	var b = Items - 1;</instruction>
		<instruction />
		<instruction>	for (a = 0; a &lt; n; a++) {</instruction>
		<instruction>		if (Output[b] &lt; (Positions - (Items - b - 1))) Output[b]++;</instruction>
		<instruction>		else {</instruction>
		<instruction>			while (b &gt; 0 &amp;&amp; Output[b] == (Positions - (Items - b - 1)))</instruction>
		<instruction>			b--;</instruction>
		<instruction />
		<instruction>			Output[b]++;</instruction>
		<instruction>			for (; b &lt; Items - 1; b++)</instruction>
		<instruction>			Output[b + 1] = Output[b] + 1;</instruction>
		<instruction>		}</instruction>
		<instruction>	}</instruction>
		<instruction />
		<instruction>	return Output;</instruction>
		<instruction>}</instruction>
		<instruction />
		<instruction>function parseItemsFromWildcard( filter ) {</instruction>
		<instruction>	var matches = filter.match(/[a-z]+/g);</instruction>
		<instruction>	if (matches){</instruction>
		<instruction>		DOpus.Output(&quot;Matches.length: &quot; + matches.length);</instruction>
		<instruction>		DOpus.Output(&quot;Matches: &quot; + matches[0]);</instruction>
		<instruction>		var myMatches = [];</instruction>
		<instruction>		for(i=0;i&lt;matches.length;i++) {</instruction>
		<instruction>			if (!myMatches[ matches[i] ]) {</instruction>
		<instruction>				myMatches.push(matches[i]);</instruction>
		<instruction>				myMatches[ matches[i] ] = &quot;set&quot;;</instruction>
		<instruction>			}</instruction>
		<instruction>		}</instruction>
		<instruction>		DOpus.Output(&quot;MyMatches.length: &quot; + myMatches.length);</instruction>
		<instruction>		DOpus.Output(&quot;MyMatches: &quot; + myMatches);</instruction>
		<instruction>		return myMatches.join(&apos; &apos;);</instruction>
		<instruction>	} </instruction>
		<instruction>	DOpus.Output(&quot;no match&quot;);</instruction>
		<instruction>	return filter;</instruction>
		<instruction>}</instruction>
		<instruction>==SCRIPT RESOURCES</instruction>
		<instruction>&lt;resources&gt;</instruction>
		<instruction>	&lt;resource name=&quot;ISEFilter_dlg&quot; type=&quot;dialog&quot;&gt;</instruction>
		<instruction>		&lt;dialog fontsize=&quot;8&quot; height=&quot;40&quot; lang=&quot;english&quot; title=&quot;ISE Filter&quot; width=&quot;298&quot;&gt;</instruction>
		<instruction>			&lt;control halign=&quot;left&quot; height=&quot;12&quot; name=&quot;Filter_tbx&quot; type=&quot;edit&quot; width=&quot;290&quot; x=&quot;4&quot; y=&quot;4&quot; /&gt;</instruction>
		<instruction>			&lt;control close=&quot;0&quot; height=&quot;14&quot; name=&quot;button1&quot; title=&quot;Close&quot; type=&quot;button&quot; width=&quot;50&quot; x=&quot;244&quot; y=&quot;22&quot; /&gt;</instruction>
		<instruction>		&lt;/dialog&gt;</instruction>
		<instruction>	&lt;/resource&gt;</instruction>
		<instruction>&lt;/resources&gt;</instruction>
	</function>
</button>
Jochen
Beiträge: 115
Registriert: 19. Feb 2008 14:17
Betriebssystem: Windows 10 64 bit

Re: Schnellfiltersuche mit mehreren Wörtern?

Beitrag von Jochen »

Danke. Funktioniert.
Jochen
Beiträge: 115
Registriert: 19. Feb 2008 14:17
Betriebssystem: Windows 10 64 bit

Re: Schnellfiltersuche mit mehreren Wörtern?

Beitrag von Jochen »

Ich rufe das Thema nochmal auf.
Der Schalter funktioniert wunderbar. Toll wäre es noch dass, wenn ich mir eine relativ lange Ordnerliste per Flatview anzeigen lasse, ich bei der Dateifiltersuche nur die entsprechenden Dateien angezeigt bekomme und die Ordner, in denen keine entsprechenden Dateien gefunden werden, ausgeblendet werden. Könnte das funktionieren?
Benutzeravatar
tbone
Berater
Beiträge: 656
Registriert: 22. Nov 2014 21:16
Betriebssystem: 7*64

Re: Schnellfiltersuche mit mehreren Wörtern?

Beitrag von tbone »

Mhh ja, aber leider geht das mit dem Quickfilter nicht, ist aber auch eine Option die ich vermisse:
"Folder ohne Quickfilter-Treffer ausblenden" sozusagen.

Man könnte sich da eine Funktion bauen, die den Filter nicht über den Quickfilter anwendet, aber mit quasi den gleichen Kriterien eine Liste der ein/auszublendenden Items erstellt. Die nicht-passenden Items könnte man im FlatView dann über ein Select-Kommando ausblenden, so wird man die Folder dann los die keine Treffer haben.

Du kannst Dir mal SelectEx dazu angucken, das geht stark in die Richtung:
https://resource.dopus.com/t/command-se ... mand/20517
Jochen
Beiträge: 115
Registriert: 19. Feb 2008 14:17
Betriebssystem: Windows 10 64 bit

Re: Schnellfiltersuche mit mehreren Wörtern?

Beitrag von Jochen »

Manchmal sieht man ja den Wald vor lauter Bäumen nicht. Man kann ja einfach auf den Flatview-Modus ohne Ordneranzeige schalten :-)
Das reicht mir so. Der Ordner, in der sich die Datei befindet wird ja in der Spalte Ort angezeigt. Für mich völlig ausreichend.
Antworten