haiku/docs/userguide/zh_CN/queries.html
2010-10-28 08:57:17 +00:00

165 lines
12 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<!--
*
* Copyright 2008-2009, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Humdinger <humdingerb@gmail.com>
* Translators:
* Pengphei Han
*
-->
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="robots" content="all" />
<title>查询</title>
<link rel="stylesheet" type="text/css" href="../Haiku-doc.css" />
</head>
<body>
<div id="banner">
<div><span>用户指南</span></div>
</div>
<div class="nav">
<div class="inner">
<ul class="lang-menu">
<li class="now"><img src="../images/flags/zh_CN.png" alt="" />  中文 [中文]</li>
<li><a href="../fr/queries.html"><img src="../images/flags/fr.png" alt="" />Français</a></li>
<li><a href="../de/queries.html"><img src="../images/flags/de.png" alt="" />Deutsch</a></li>
<li><a href="../it/queries.html"><img src="../images/flags/it.png" alt="" />Italiano</a></li>
<li><a href="../ru/queries.html"><img src="../images/flags/ru.png" alt="" />Русский</a></li>
<li><a href="../es/queries.html"><img src="../images/flags/es.png" alt="" />Español</a></li>
<li><a href="../sv_SE/queries.html"><img src="../images/flags/sv_SE.png" alt="" />Svensk</a></li>
<li><a href="../jp/queries.html"><img src="../images/flags/jp.png" alt="" />日本語</a></li>
<li><a href="../uk/queries.html"><img src="../images/flags/uk.png" alt="" />Українська</a></li>
<li><a href="../pt_PT/queries.html"><img src="../images/flags/pt_PT.png" alt="" />Português</a></li>
<li><a href="../en/queries.html"><img src="../images/flags/gb.png" alt="" />English</a></li>
</ul>
<span>
« <a href="index.html">索引</a>
:: <a href="contents.html" class="uplink">内容</a>
:: <a href="workshop-filetypes+attributes.html">操作讲解</a> »
</span></div>
</div>
<div id="content">
<div>
<div class="box-info">本节的翻译还未完成。在未完成之前,所有的未完成部分都将使用英语原文。</div>
<table class="index" id="index" summary="index">
<tr class="heading"><td>索引</td></tr>
<tr class="index"><td>
<a href="#find-window">查询窗口</a><br />
<a href="#basic-query">基本查询 - "使用名字"</a><br />
<a href="#adv-query">标准查询 - "使用属性"</a><br />
<a href="#more-adv-query">高级查询 - "使用表达式"</a><br />
<a href="#result-window">结果窗口</a><br />
<a href="#query-template">查询模板</a>
</td></tr>
</table>
<h1>查询</h1>
<p>查询是基于文件属性的文件搜索可以在Tracker或者终端中进行。所有的查询保存在 <span class="path">/boot/home/queries/</span> ,并且保持七天才予以清除。需要注意的是,这些并不是您静态的搜索结果列表,而是查询的规则,当您打开它们时,将会再次进行搜索。
<br />
比较方便的是,您不需要双击来再次执行查询,而是可以<a href="tracker.html#navigating">深入</a>一个保存的查询,就如右键点击任何的文件夹,然后导航至相应的子菜单。</p>
<h2>
<a href="#"><img src="../images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="find-window" name="find-window">查询窗口</a></h2>
<p>您可以从 <span class="menu">Find...</span> 菜单桌面栏菜单任何Tracker窗口或者桌面一个全屏的Tracker窗口调用查询。对应的快捷键是 <span class="key">ALT</span> <span class="key">F</span>。它将会呈现如下查找窗口:</p>
<img src="images/queries-images/basic-query.png" alt="basic-query.png" />
<ol>
<li><p>选择最近或者保存的查询,或者保存当前的搜索参数为 <a href="#query-template">查询模板</a></p></li>
<li><p>查询范围从 <span class="menu">All files and folders</span> 缩小到特定的文件类型。</p></li>
<li>定义搜索方法:<ul>
<li><span class="menu">by Name</span> - 基本搜索,基于文件或者文件夹名的查询</li>
<li><span class="menu">by Attribute</span> - 标准搜索,基于一个或多个属性的查询</li>
<li><span class="menu">by Formula</span> - 高级搜索,基于查询规则的复杂查询</li></ul></li>
<li><p>选择所要搜索的目标驱动。</p></li>
<li><p>输入搜索词。</p></li>
<li><p>扩展项是否隐藏附加选项。</p></li>
<li><p>如果您不希望查询保存7天您可以不勾选 <span class="menu">Temporary</span> 复选框。</p></li>
<li><p>如果您打算查询垃圾箱,您可以选中 <span class="menu">Include trash</span></p></li>
<li><p>可选的,如果您希望保存查询,您可以输入名字为其命名。</p></li>
<li><p>您可以拖拽图标到任何位置保存查询。右键点击查询文件,提供了选项将其保存为模板。</p></li>
</ol>
<h2>
<a href="#"><img src="../images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="basic-query" name="basic-query">基本查询 - "使用名字"</a></h2>
<p>If you simply want to find all files and folders on your mounted disks that match a certain pattern, simply leave the search method at <span class="menu">by Name</span>, enter the search term into the text box and press <span class="key">ENTER</span>.</p>
<h2>
<a href="#"><img src="../images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="adv-query" name="adv-query">标准查询 - "使用属性"</a></h2>
<p>You can create more advanced queries by searching within the attributes of specific file types. For that to work, these attributes have to be <a href="index.html">indexed</a>.</p>
<img src="images/queries-images/query-window.png" alt="query-window.png" />
<p>You start by setting the filetype from <span class="menu">All files and folders</span> to, for example, <span class="menu">Text | E-mail</span> and change the search method to <span class="menu">by Attribute</span>.</p>
<p>This adds a pop-up menu to the left of the textbox and the buttons <span class="button">Add</span> and <span class="button">Remove</span> under that. From the menu you choose which attribute to query. With <span class="button">Add</span> and <span class="button">Remove</span> you can query additional attributes or remove them again. These attributes can be logically linked with AND/OR.</p>
<p>Let's do an email query as an example:</p>
<img src="images/queries-images/query-window-filled.png" alt="query-window-filled.png" />
<p>This is your Find window when you're looking for all emails Clara Botters has sent to you in the last two months that had in the subject "vibraphone" or "skepticality".<br />
As you see, searching through time-based attributes supports some useful phrases: besides for the "last 2 months", you could also use "today", "yesterday", "Monday" or "last Monday" (which would be the Monday last week), or "last 2 minutes/hours/days/weeks".<br />
A good way to cut down the number of search results.</p>
<h2>
<a href="#"><img src="../images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="more-adv-query" name="more-adv-query">高级查询 - "使用表达式"</a></h2>
<p>Typing in a formula query by hand is daunting and really quite unpractical. It still has its uses.</p>
<p>Take the above query by attribute of Clara's mails concerning vibraphones etc. If you have all the attributes and their search terms set, try switching to <span class="menu">by Formula</span> mode and be overwhelmed by this one line query string:</p>
<img src="images/queries-images/formula-query.png" alt="formula-query.png" />
<p>Once more as text, edited for readability:</p>
<pre>(((((MAIL:from=="*[cC][lL][aA][rR][aA] [bB][oO][tT][tT][eE][rR][sS]*")
&amp;&amp;(MAIL:when&gt;=%2 months%))
&amp;&amp;(MAIL:subject=="*[vV][iI][bB][rR][aA][pP][hH][oO][nN][eE]*"))
||(MAIL:subject=="*[sS][kK][eE][pP][tT][iI][cC][aA][lL][iI][tT][yY]*"))
&amp;&amp;(BEOS:TYPE=="text/x-email"))</pre>
<p>What's the use?</p>
<ul>
<li><p>You could copy and paste the string into an email, forum or IRC for others to use or debug.</p></li>
<li><p>You can use this method to construct a query in <span class="menu">Attribute</span> mode and then switch to <span class="menu">Formula</span> mode, to comfortably generate a search string to use for a query in Terminal or a script.</p></li>
<li><p>You can fine tune your query by inserting parenthesis where needed, make parts case-sensitive or negate logical combinations by changing. e.g. "<tt>==</tt>" to "<tt>!=</tt>" for a NOT AND. All you need is a basic understanding of <a href="http://en.wikipedia.org/wiki/Regular_expression" class="external free" title="Wikipedia: Regular expression">regular expressions</a> and maybe some scripting basics.</p></li>
</ul>
<h2>
<a href="#"><img src="../images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="result-window" name="result-window">结果窗口</a></h2>
<p>After you start a search, the Find window will be replaced by a result window. Here is an example that queried for "server":</p>
<img src="images/queries-images/result-window.png" alt="result-window.png" />
<p>Besides the gray background, result windows work exactly like any other Tracker window. Some things are worth noting:</p>
<ul>
<li><p>You can open the location of a file or folder by double clicking on its path attribute.</p></li>
<li><p>With <span class="menu">File | Edit Query</span> or <span class="key">ALT</span> <span class="key">G</span> you get back to your Find window to refine your query.</p></li>
<li><p>A query is live, i.e. if a file that matches your search criteria appears or disappears from your system, this change is reflected in your results in real-time.</p></li>
</ul>
<p>You can assign a sensible attribute layout for query results of a specific filetype. Open a folder containing files of the filetype you'd like to create a template for and arrange the attributes how you'd like to have query results presented. Copy this layout with <span class="menu">Attributes | Copy Layout</span>.</p>
<p>Open <span class="path">/boot/home/config/settings/Tracker/DefaultQueryTemplates</span>, create a new folder named <i>group/filetype</i>, replacing the slash with an underscore, e.g. "audio_x-mp3". Open the new folder and paste in the previously copied layout with <span class="menu">Attributes | Paste Layout</span>.</p>
<h2>
<a href="#"><img src="../images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="query-template" name="query-template">查询模板</a></h2>
<p>If you double click a saved query, the file search is at once started and the result window opens immediately. However, you may not want to search with these <i>exact</i> search parameters, but use it as starting point to only slightly tweak the formula.<br />
By using the <span class="menu">Save Query as Template</span> menu item (see <a href="#find-window">(1) in screenshot</a> at the top) or drag&amp;dropping the icon (10) anywhere with the right mouse button, you can create just such a template. Double clicking it won't open a result window, but the Find panel, giving you the opportunity to quickly change search strings or add/remove attributes.</p>
<p>Wherever you choose to save query templates, they'll be listed in the Find panel's menu of recent queries.</p>
</div>
</div>
<div class="nav">
<div class="inner"><span>
« <a href="index.html">索引</a>
:: <a href="contents.html" class="uplink">内容</a>
:: <a href="workshop-filetypes+attributes.html">操作讲解</a> »
</span></div>
</div>
</body>
</html>