[Pkg-owncloud-commits] [owncloud-client] 150/484: FolderDelegate: put the progressbar in place of the remote or local folder #3403 #3569
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:31 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 3f2a2cb14b3e67d45c8d8d2161220a87dc6726e8
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Tue Oct 27 12:52:33 2015 +0100
FolderDelegate: put the progressbar in place of the remote or local folder #3403 #3569
So the size of the delegate does not change
---
src/gui/folderstatusdelegate.cpp | 37 +++++++++++++++++--------------------
src/gui/folderstatusdelegate.h | 1 -
src/gui/folderstatusmodel.cpp | 7 ++-----
3 files changed, 19 insertions(+), 26 deletions(-)
diff --git a/src/gui/folderstatusdelegate.cpp b/src/gui/folderstatusdelegate.cpp
index 9ea0346..52b989e 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 );
diff --git a/src/gui/folderstatusdelegate.h b/src/gui/folderstatusdelegate.h
index fc7050c..1cea50e 100644
--- a/src/gui/folderstatusdelegate.h
+++ b/src/gui/folderstatusdelegate.h
@@ -41,7 +41,6 @@ public:
SyncProgressOverallPercent,
SyncProgressOverallString,
SyncProgressItemString,
- AddProgressSpace,
WarningCount,
SyncRunning,
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp
index 2df83d6..f5e6cc9 100644
--- a/src/gui/folderstatusmodel.cpp
+++ b/src/gui/folderstatusmodel.cpp
@@ -212,8 +212,6 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
} else {
return Theme::instance()->folderOfflineIcon();
}
- case FolderStatusDelegate::AddProgressSpace:
- return !progress.isNull();
case FolderStatusDelegate::SyncProgressItemString:
return progress._progressString;
case FolderStatusDelegate::WarningCount:
@@ -658,7 +656,7 @@ void FolderStatusModel::slotUpdateFolderState(Folder *folder)
for (int i = 0; i < _folders.count(); ++i) {
if (_folders.at(i)._folder == folder) {
emit dataChanged(index(i), index(i),
- QVector<int>() << FolderStatusDelegate::AddProgressSpace);
+ QVector<int>() << FolderStatusDelegate::FolderStatus);
}
}
}
@@ -751,8 +749,7 @@ void FolderStatusModel::slotSetProgress(const ProgressInfo &progress)
auto *pi = &_folders[folderIndex]._progress;
QVector<int> roles;
- roles << FolderStatusDelegate::AddProgressSpace << FolderStatusDelegate::SyncProgressItemString
- << FolderStatusDelegate::WarningCount;
+ roles << FolderStatusDelegate::SyncProgressItemString << FolderStatusDelegate::WarningCount;
if (!progress._currentDiscoveredFolder.isEmpty()) {
pi->_progressString = tr("Checking for changes in '%1'").arg(progress._currentDiscoveredFolder);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list