Commit 3ceac0a8 authored by Thorsten Roeder's avatar Thorsten Roeder
Browse files

- Allow kfind to search for files greater

than 2GB (INT_MAX), if a size range is specified.
- Allow size ranges greater than 2GB to be entered
into the search form.

Okay to backport this to 3.5.3 ?
(without breaking the message freeze)

CCBUG: 123838

svn path=/trunk/KDE/kdebase/kfind/; revision=539481
parent 63d68dc9
......@@ -208,6 +208,7 @@ KfindTabWidget::KfindTabWidget(QWidget *parent, const char *name)
sizeUnitBox ->addItem( i18n("Bytes") );
sizeUnitBox ->addItem( i18n("KB") );
sizeUnitBox ->addItem( i18n("MB") );
sizeUnitBox ->addItem( i18n("GB") );
sizeUnitBox ->setCurrentIndex(1);
int tmp = sizeEdit->fontMetrics().width(" 000000000 ");
......@@ -603,7 +604,8 @@ bool KfindTabWidget::isDateValid()
void KfindTabWidget::setQuery(KQuery *query)
{
int size;
KIO::filesize_t size;
KIO::filesize_t sizeunit;
bool itemAlreadyContained(false);
// only start if we have valid dates
if (!isDateValid()) return;
......@@ -632,42 +634,41 @@ void KfindTabWidget::setQuery(KQuery *query)
switch (sizeUnitBox->currentIndex())
{
case 0:
size = 1; //one byte
sizeunit = 1; //one byte
break;
case 2:
size = 1048576; //1M
sizeunit = 1048576; //1M
break;
case 1:
default:
size=1024; //1k
case 3:
sizeunit = 1073741824; //1G
break;
case 1: // fall to default case
default:
sizeunit=1024; //1k
break;
}
size = sizeEdit->value() * size;
size = sizeEdit->value() * sizeunit;
// TODO: troeder: do we need this check since it is very unlikely
// to exceed ULLONG_MAX with INT_MAX * 1024^3.
// Or is there an arch where this can happen?
#if 0
if (size < 0) // overflow
if (KMessageBox::warningYesNo(this, i18n("Size is too big. Set maximum size value?"), i18n("Error"),i18n("Set"),i18n("Do Not Set"))
{
if (KMessageBox::warningYesNo(this, i18n("Size is too big. Set maximum size value?"), i18n("Error"),i18n("Set"),i18n("Do Not Set"))
== KMessageBox::Yes)
{
sizeEdit->setValue(INT_MAX);
sizeUnitBox->setCurrentIndex(0);
size = INT_MAX;
sizeUnitBox->setCurrentIndex(0);
size = INT_MAX;
}
else
return;
switch (sizeBox->currentIndex())
{
case 1:
query->setSizeRange(size, -1);
break;
case 2:
query->setSizeRange(-1, size);
break;
case 3:
query->setSizeRange(size,size);
break;
default:
query->setSizeRange(-1, -1);
}
#endif
// set range mode and size value
query->setSizeRange(sizeBox->currentIndex(),size,0);
// dates
QDateTime epoch;
......
......@@ -16,7 +16,7 @@
KQuery::KQuery(QObject *parent, const char * name)
: QObject(parent),
m_minsize(-1), m_maxsize(-1),
m_sizemode(0), m_sizeboundary1(0), m_sizeboundary2(0),
m_timeFrom(0), m_timeTo(0),
job(0), m_insideCheckEntries(false), m_result(0)
{
......@@ -194,9 +194,25 @@ void KQuery::processQuery( KFileItem* file)
return;
// make sure the files are in the correct range
if ( ( m_minsize >= 0 && (int)file->size() < m_minsize ) ||
( m_maxsize >= 0 && (int)file->size() > m_maxsize ) )
return;
switch( m_sizemode )
{
case 1: // "at least"
if ( file->size() < m_sizeboundary1 ) return;
break;
case 2: // "at most"
if ( file->size() > m_sizeboundary1 ) return;
break;
case 3: // "equal"
if ( file->size() != m_sizeboundary1 ) return;
break;
case 4: // "between"
if ( (file->size() < m_sizeboundary1) ||
(file->size() > m_sizeboundary2) ) return;
break;
case 0: // "none" -> Fall to default
default:
break;
}
// make sure it's in the correct date range
// what about 0 times?
......@@ -424,10 +440,11 @@ void KQuery::setFileType(int filetype)
m_filetype = filetype;
}
void KQuery::setSizeRange(int min, int max)
void KQuery::setSizeRange(int mode, KIO::filesize_t value1, KIO::filesize_t value2)
{
m_minsize = min;
m_maxsize = max;
m_sizemode = mode;
m_sizeboundary1 = value1;
m_sizeboundary2 = value2;
}
void KQuery::setTimeRange(time_t from, time_t to)
......@@ -446,7 +463,6 @@ void KQuery::setGroupname(QString groupname)
m_groupname = groupname;
}
void KQuery::setRegExp(const QString &regexp, bool caseSensitive)
{
QRegExp *regExp;
......
......@@ -24,7 +24,7 @@ class KQuery : public QObject
KQuery(QObject *parent = 0, const char * name = 0);
~KQuery();
void setSizeRange( int min, int max );
void setSizeRange( int mode, KIO::filesize_t value1, KIO::filesize_t value2);
void setTimeRange( time_t from, time_t to );
void setRegExp( const QString &regexp, bool caseSensitive );
void setRecursive( bool recursive );
......@@ -66,8 +66,9 @@ class KQuery : public QObject
void checkEntries();
int m_filetype;
int m_minsize;
int m_maxsize;
int m_sizemode;
KIO::filesize_t m_sizeboundary1;
KIO::filesize_t m_sizeboundary2;
KUrl m_url;
time_t m_timeFrom;
time_t m_timeTo;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment