diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2015-10-27 14:52:33 +0300 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2015-10-27 14:52:33 +0300 |
commit | 3f2a2cb14b3e67d45c8d8d2161220a87dc6726e8 (patch) | |
tree | 579df228d466ff74c19906e3fe2aa1386a248436 /src/gui/folderstatusdelegate.cpp | |
parent | fac00348d9a6be968f80bc385078ef807b639248 (diff) |
FolderDelegate: put the progressbar in place of the remote or local folder #3403 #3569
So the size of the delegate does not change
Diffstat (limited to 'src/gui/folderstatusdelegate.cpp')
-rw-r--r-- | src/gui/folderstatusdelegate.cpp | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/gui/folderstatusdelegate.cpp b/src/gui/folderstatusdelegate.cpp index 9ea0346dc..52b989ef2 100644 --- a/src/gui/folderstatusdelegate.cpp +++ b/src/gui/folderstatusdelegate.cpp @@ -79,12 +79,6 @@ QSize FolderStatusDelegate::sizeHint(const QStyleOptionViewItem & option , h += aliasMargin*2 + errMsgs.count()*fm.height(); } - if( qvariant_cast<bool>(index.data(AddProgressSpace)) ) { - int margin = fm.height()/4; - h += (5 * margin); // All the margins - h += 2* fm.boundingRect(tr("File")).height(); - } - return QSize( 0, h); } @@ -221,20 +215,23 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & painter->setFont(aliasFont); painter->drawText(aliasRect, elidedAlias); - painter->setFont(subFont); - QString elidedRemotePathText; + const bool showProgess = !overallString.isEmpty() || !itemString.isEmpty(); + if(!showProgess) { + painter->setFont(subFont); + QString elidedRemotePathText; + + if (remotePath.isEmpty() || remotePath == QLatin1String("/")) { + elidedRemotePathText = subFm.elidedText(tr("Syncing selected files in your account with"), + Qt::ElideRight, remotePathRect.width()); + } else { + elidedRemotePathText = subFm.elidedText(tr("Remote path: %1").arg(remotePath), + Qt::ElideMiddle, remotePathRect.width()); + } + painter->drawText(remotePathRect, elidedRemotePathText); - if (remotePath.isEmpty() || remotePath == QLatin1String("/")) { - elidedRemotePathText = subFm.elidedText(tr("Syncing selected files in your account with"), - Qt::ElideRight, remotePathRect.width()); - } else { - elidedRemotePathText = subFm.elidedText(tr("Remote path: %1").arg(remotePath), - Qt::ElideMiddle, remotePathRect.width()); + QString elidedPathText = subFm.elidedText(pathText, Qt::ElideMiddle, localPathRect.width()); + painter->drawText(localPathRect, elidedPathText); } - painter->drawText(remotePathRect, elidedRemotePathText); - - QString elidedPathText = subFm.elidedText(pathText, Qt::ElideMiddle, localPathRect.width()); - painter->drawText(localPathRect, elidedPathText); // paint an error overlay if there is an error string @@ -270,7 +267,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & h += aliasMargin; // Sync File Progress Bar: Show it if syncFile is not empty. - if( !overallString.isEmpty() || !itemString.isEmpty()) { + if (showProgess) { int fileNameTextHeight = subFm.boundingRect(tr("File")).height(); int barHeight = qMax(fileNameTextHeight, aliasFm.height()+4); ; int overallWidth = option.rect.width()-aliasMargin-nextToIcon; @@ -283,7 +280,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & // Overall Progress Bar. QRect pBRect; - pBRect.setTop( h ); + pBRect.setTop( remotePathRect.top() ); pBRect.setLeft( nextToIcon ); pBRect.setHeight(barHeight); pBRect.setWidth( overallWidth - progressTextWidth - 2 * margin ); |