dbhub: Improve default settings table views in Remote dock a bit

This makes the database name columns a bit wider by default. It also
reduces the width of the size columns, moves the commit id column to the
end of the remote table, and hides the file name column in local table.

See issue #2334.
This commit is contained in:
Martin Kleusberg
2020-07-18 10:50:28 +02:00
parent 5341112bbe
commit fbfcdbe4bc
2 changed files with 15 additions and 8 deletions
+7
View File
@@ -33,6 +33,13 @@ RemoteDock::RemoteDock(MainWindow* parent)
ui->treeLocal->setModel(remoteLocalFilesModel);
ui->treeDatabaseCommits->setModel(remoteCommitsModel);
// Set initial column widths for tree views
ui->treeRemote->setColumnWidth(0, 300); // Make name column wider
ui->treeRemote->setColumnWidth(2, 80); // Make size column narrower
ui->treeLocal->setColumnWidth(RemoteLocalFilesModel::ColumnName, 300); // Make name column wider
ui->treeLocal->setColumnWidth(RemoteLocalFilesModel::ColumnSize, 80); // Make size column narrower
ui->treeLocal->setColumnHidden(RemoteLocalFilesModel::ColumnFile, true); // Hide local file name
// When a database has been downloaded and must be opened, notify users of this class
connect(&remoteDatabase, &RemoteDatabase::openFile, this, &RemoteDock::openFile);
+8 -8
View File
@@ -100,7 +100,7 @@ std::vector<RemoteModelItem*> RemoteModelItem::loadArray(const json& array, Remo
RemoteModel::RemoteModel(QObject* parent, RemoteDatabase& remote) :
QAbstractItemModel(parent),
headerList({tr("Name"), tr("Commit"), tr("Last modified"), tr("Size")}),
headerList({tr("Name"), tr("Last modified"), tr("Size"), tr("Commit")}),
rootItem(new RemoteModelItem()),
remoteDatabase(remote)
{
@@ -227,16 +227,10 @@ QVariant RemoteModel::data(const QModelIndex& index, int role) const
return item->value(RemoteModelColumnName);
}
case 1:
{
if(type == "folder")
return QVariant();
return item->value(RemoteModelColumnCommitId);
}
case 2:
{
return item->value(RemoteModelColumnLastModified);
}
case 3:
case 2:
{
// Folders don't have a size
if(type == "folder")
@@ -246,6 +240,12 @@ QVariant RemoteModel::data(const QModelIndex& index, int role) const
unsigned int size = item->value(RemoteModelColumnSize).toUInt();
return humanReadableSize(size);
}
case 3:
{
if(type == "folder")
return QVariant();
return item->value(RemoteModelColumnCommitId);
}
}
}