add min/max size entries to adv search + convert size display to decimal (instead of 1024-based)
This commit is contained in:
parent
7ddbbb1ee8
commit
420157d998
@ -145,6 +145,46 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line2">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::HLine</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Sunken</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelminsize">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Minimum size. You can use k/K,m/M,g/G as multipliers</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Min. Size</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="minSizeLE"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelmaxsize">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Maximum size. You can use k/K,m/M,g/G as multipliers</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Max. Size</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="maxSizeLE"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line4">
|
<widget class="Line" name="line4">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
|
|||||||
@ -300,6 +300,30 @@ void AdvSearch::saveFileTypes()
|
|||||||
rwSettings(true);
|
rwSettings(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t AdvSearch::stringToSize(QString qsize)
|
||||||
|
{
|
||||||
|
size_t size = size_t(-1);
|
||||||
|
qsize.replace(QRegExp("[\\s]+"), "");
|
||||||
|
if (!qsize.isEmpty()) {
|
||||||
|
string csize((const char*)qsize.toAscii());
|
||||||
|
char *cp;
|
||||||
|
size = strtoll(csize.c_str(), &cp, 10);
|
||||||
|
if (*cp != 0) {
|
||||||
|
switch (*cp) {
|
||||||
|
case 'k': case 'K': size *= 1E3;break;
|
||||||
|
case 'm': case 'M': size *= 1E6;break;
|
||||||
|
case 'g': case 'G': size *= 1E9;break;
|
||||||
|
case 't': case 'T': size *= 1E12;break;
|
||||||
|
default:
|
||||||
|
QMessageBox::warning(0, "Recoll",
|
||||||
|
tr("Bad multiplier suffix in size filter"));
|
||||||
|
size = size_t(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
using namespace Rcl;
|
using namespace Rcl;
|
||||||
void AdvSearch::runSearch()
|
void AdvSearch::runSearch()
|
||||||
{
|
{
|
||||||
@ -343,6 +367,11 @@ void AdvSearch::runSearch()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t size = stringToSize(minSizeLE->text());
|
||||||
|
sdata->setMinSize(size);
|
||||||
|
size = stringToSize(maxSizeLE->text());
|
||||||
|
sdata->setMaxSize(size);
|
||||||
|
|
||||||
if (!subtreeCMB->currentText().isEmpty()) {
|
if (!subtreeCMB->currentText().isEmpty()) {
|
||||||
QString current = subtreeCMB->currentText();
|
QString current = subtreeCMB->currentText();
|
||||||
sdata->setTopdir((const char*)subtreeCMB->currentText().toUtf8(),
|
sdata->setTopdir((const char*)subtreeCMB->currentText().toUtf8(),
|
||||||
|
|||||||
@ -68,6 +68,7 @@ private:
|
|||||||
bool m_ignByCats;
|
bool m_ignByCats;
|
||||||
void saveCnf();
|
void saveCnf();
|
||||||
void fillFileTypes();
|
void fillFileTypes();
|
||||||
|
size_t stringToSize(QString);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -594,17 +594,17 @@ string displayableBytes(off_t size)
|
|||||||
char sizebuf[50];
|
char sizebuf[50];
|
||||||
const char *unit;
|
const char *unit;
|
||||||
|
|
||||||
if (size < 1024) {
|
if (size < 1000) {
|
||||||
unit = " B ";
|
unit = " B ";
|
||||||
} else if (size < 1024*1024) {
|
} else if (size < 1E6) {
|
||||||
unit = " KB ";
|
unit = " KB ";
|
||||||
size /= 1024;
|
size /= 1000;
|
||||||
} else if (size < 1024*1024*1024) {
|
} else if (size < 1E9) {
|
||||||
unit = " MB ";
|
unit = " MB ";
|
||||||
size /= (1024*1024);
|
size /= (1E6);
|
||||||
} else {
|
} else {
|
||||||
unit = " GB ";
|
unit = " GB ";
|
||||||
size /= (1024*1024*1024);
|
size /= (1E9);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(sizebuf, OFFTPC "%s", size, unit);
|
sprintf(sizebuf, OFFTPC "%s", size, unit);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user