Skip to content

Commit

Permalink
dbhub: Improve default settings table views in Remote dock a bit
Browse files Browse the repository at this point in the history
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 sqlitebrowser#2334.
  • Loading branch information
MKleusberg committed Jul 18, 2020
1 parent 5341112 commit fbfcdbe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/RemoteDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 8 additions & 8 deletions src/RemoteModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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")
Expand All @@ -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);
}
}
}

Expand Down

0 comments on commit fbfcdbe

Please sign in to comment.