Show a shortened version of the path in the account settings and activity

Issue #3576, #3567
This commit is contained in:
Olivier Goffart 2015-08-17 11:39:45 +02:00
parent c98ee987cd
commit 7ca8040788
4 changed files with 33 additions and 15 deletions

View file

@ -204,6 +204,23 @@ QString Folder::path() const
return p;
}
QString Folder::shortGuiPath() const
{
QString p = _definition.localPath;
QString home = QDir::homePath();
if( ! home.endsWith('/') ) {
home.append('/');
}
if (p.startsWith(home)) {
p = p.mid(home.length());
}
if (p.length() > 1 && p.endsWith('/')) {
p.chop(1);
}
return QDir::toNativeSeparators(p);
}
bool Folder::ignoreHiddenFiles()
{
bool re(_definition.ignoreHiddenFiles);
@ -241,11 +258,6 @@ QUrl Folder::remoteUrl() const
return Account::concatUrlPath(_accountState->account()->davUrl(), remotePath());
}
QString Folder::nativePath() const
{
return QDir::toNativeSeparators(path());
}
bool Folder::syncPaused() const
{
return _definition.paused;

View file

@ -103,6 +103,11 @@ public:
QString alias() const;
QString aliasGui() const; // since 2.0 we don't want to show aliases anymore, show the path instead
/**
* short path to display on the GUI (native separators)
*/
QString shortGuiPath() const;
/**
* local folder path
*/
@ -123,11 +128,6 @@ public:
*/
QUrl remoteUrl() const;
/**
* local folder path with native separators
*/
QString nativePath() const;
/**
* switch sync on or off
* If the sync is switched off, the startSync method is not going to

View file

@ -154,7 +154,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
const bool accountConnected = _accountState->isConnected();
switch (role) {
case FolderStatusDelegate::FolderPathRole : return f->nativePath();
case FolderStatusDelegate::FolderPathRole : return f->shortGuiPath();
case FolderStatusDelegate::FolderSecondPathRole : return f->remotePath();
case FolderStatusDelegate::HeaderRole : return f->aliasGui();
case FolderStatusDelegate::FolderAliasRole : return f->alias();

View file

@ -99,7 +99,7 @@ void ProtocolWidget::copyToClipboard()
<< qSetFieldWidth(64)
<< child->data(1,Qt::DisplayRole).toString()
// folder
<< qSetFieldWidth(15)
<< qSetFieldWidth(30)
<< child->data(2, Qt::DisplayRole).toString()
// action
<< qSetFieldWidth(15)
@ -161,7 +161,7 @@ void ProtocolWidget::cleanIgnoreItems(const QString& folder)
for( int cnt = itemCnt-1; cnt >=0 ; cnt-- ) {
QTreeWidgetItem *item = _ui->_treeWidget->topLevelItem(cnt);
bool isErrorItem = item->data(0, IgnoredIndicatorRole).toBool();
QString itemFolder = item->data(2, Qt::DisplayRole).toString();
QString itemFolder = item->data(2, Qt::UserRole).toString();
if( isErrorItem && itemFolder == folder ) {
delete item;
}
@ -179,7 +179,7 @@ QString ProtocolWidget::timeString(QDateTime dt, QLocale::FormatType format) con
void ProtocolWidget::slotOpenFile( QTreeWidgetItem *item, int )
{
QString folderName = item->text(2);
QString folderName = item->data(2, Qt::UserRole).toString();
QString fileName = item->text(1);
Folder *folder = FolderMan::instance()->folder(folderName);
@ -203,6 +203,11 @@ QString ProtocolWidget::fixupFilename( const QString& name )
QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& folder, const SyncFileItem& item)
{
auto f = FolderMan::instance()->folder(folder);
if (!f) {
return 0;
}
QStringList columns;
QDateTime timestamp = QDateTime::currentDateTime();
const QString timeStr = timeString(timestamp);
@ -210,7 +215,7 @@ QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& fo
columns << timeStr;
columns << fixupFilename(item._originalFile);
columns << folder;
columns << f->shortGuiPath();
// If the error string is set, it's prefered because it is a useful user message.
QString message = item._errorString;
@ -241,6 +246,7 @@ QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& fo
twitem->setToolTip(0, longTimeStr);
twitem->setToolTip(1, item._file);
twitem->setToolTip(3, message );
twitem->setData(2, Qt::UserRole, folder);
return twitem;
}