Some refactoring of FileThumbnailViewItem::updateLines()

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
(cherry picked from commit 79826b760f)
pull/34/head
Alexander Golubev 9 months ago committed by Michele Calgaro
parent d84beae42a
commit a5931c83bd
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -204,21 +204,16 @@ void FileThumbnailViewItem::updateLines() {
mLines.clear(); mLines.clear();
if (!mFileItem) return; if (!mFileItem) return;
bool showName, showDate, showImageSize, showFilesize;
bool isDir=mFileItem->isDir(); bool isDir=mFileItem->isDir();
if (iconView()->itemTextPos()==TQIconView::Right) { if (iconView()->itemTextPos()==TQIconView::Right) {
// Text is on the right, show everything // Text is on the right, show everything
showName = true;
time_t time = TimeUtils::getTime(mFileItem); showDate = true;
mLines.append( new WrappedLine(this, mFileItem->name()) ); showImageSize = true;
mLines.append( new CroppedLine(this, TimeUtils::formatTime(time)) ); showFilesize = !isDir;
if (mImageSize.isValid()) {
TQString txt=TQString::number(mImageSize.width())+"x"+TQString::number(mImageSize.height());
mLines.append( new CroppedLine(this, txt) );
}
if (!isDir) {
mLines.append( new CroppedLine(this, TDEIO::convertSize(mFileItem->size())) );
}
} else { } else {
// Text is below the icon, only show details selected in // Text is below the icon, only show details selected in
// view->itemDetails() // view->itemDetails()
@ -226,26 +221,30 @@ void FileThumbnailViewItem::updateLines() {
int details=view->itemDetails(); int details=view->itemDetails();
bool isImage=!Archive::fileItemIsDirOrArchive(mFileItem); bool isImage=!Archive::fileItemIsDirOrArchive(mFileItem);
if (!isImage || (details & FileThumbnailView::FILENAME)) { showName = !isImage || ( details & FileThumbnailView::FILENAME );
showDate = ( details & FileThumbnailView::FILEDATE );
showImageSize = ( details & FileThumbnailView::IMAGESIZE );
showFilesize = !isDir && ( details & FileThumbnailView::FILESIZE );
}
if (showName) {
mLines.append( new WrappedLine(this, mFileItem->name()) ); mLines.append( new WrappedLine(this, mFileItem->name()) );
} }
if (details & FileThumbnailView::FILEDATE) { if (showDate) {
time_t time = TimeUtils::getTime(mFileItem); time_t time = TimeUtils::getTime(mFileItem);
mLines.append( new CroppedLine(this, TimeUtils::formatTime(time)) ); mLines.append( new CroppedLine(this, TimeUtils::formatTime(time)) );
} }
if (details & FileThumbnailView::IMAGESIZE) { if (showImageSize) {
TQString txt; TQString txt;
if (mImageSize.isValid()) { if (mImageSize.isValid()) {
txt=TQString::number(mImageSize.width())+"x"+TQString::number(mImageSize.height()); txt=TQString::number(mImageSize.width())+"x"+TQString::number(mImageSize.height());
} }
mLines.append( new CroppedLine(this, txt) ); mLines.append( new CroppedLine(this, txt) );
} }
if (!isDir && (details & FileThumbnailView::FILESIZE)) { if (showFilesize) {
mLines.append( new CroppedLine(this, TDEIO::convertSize(mFileItem->size())) ); mLines.append( new CroppedLine(this, TDEIO::convertSize(mFileItem->size())) );
} }
}
calcRect(); calcRect();
} }

Loading…
Cancel
Save