mirror of
https://github.com/Murmele/Gittyup.git
synced 2024-09-17 13:37:18 +03:00
Add setting for multicolumn
This commit is contained in:
parent
7bb4a7a5f0
commit
1f3e81ab0b
@ -40,6 +40,7 @@ void Setting::initialize(QMap<Id, QString> &keys) {
|
||||
keys[Id::ShowCommitsId] = "commit/id";
|
||||
keys[Id::ShowChangedFilesAsList] = "doubletreeview/listview";
|
||||
keys[Id::ShowChangedFilesInSingleView] = "doubletreeview/single";
|
||||
keys[Id::ShowChangedFilesMultiColumn] = "doubletreeview/listviewmulticolumn";
|
||||
keys[Id::HideUntracked] = "untracked.hide";
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
ShowCommitsDate,
|
||||
ShowCommitsId,
|
||||
ShowChangedFilesAsList,
|
||||
ShowChangedFilesMultiColumn, // For the list only
|
||||
ShowChangedFilesInSingleView,
|
||||
HideUntracked,
|
||||
Language,
|
||||
|
@ -37,10 +37,17 @@ bool asList() {
|
||||
|
||||
DiffTreeModel::DiffTreeModel(const git::Repository &repo, QObject *parent)
|
||||
: QAbstractItemModel(parent), mRepo(repo) {
|
||||
setMultiColumn(mMultiColumn);
|
||||
}
|
||||
|
||||
DiffTreeModel::~DiffTreeModel() { delete mRoot; }
|
||||
|
||||
void DiffTreeModel::setMultiColumn(bool multi) {
|
||||
beginResetModel();
|
||||
mMultiColumn = multi;
|
||||
endResetModel(); // Notify view about the change
|
||||
}
|
||||
|
||||
void DiffTreeModel::createDiffTree() {
|
||||
|
||||
for (int patchNum = 0; patchNum < mDiff.count(); ++patchNum) {
|
||||
@ -416,7 +423,7 @@ Node *DiffTreeModel::node(const QModelIndex &index) const {
|
||||
|
||||
QVariant DiffTreeModel::getDisplayRole(const QModelIndex &index) const {
|
||||
Node *node = this->node(index);
|
||||
if (asList()) {
|
||||
if (asList() && mMultiColumn) {
|
||||
QFileInfo fileInfo(node->path(true));
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
@ -424,7 +431,7 @@ QVariant DiffTreeModel::getDisplayRole(const QModelIndex &index) const {
|
||||
case 1:
|
||||
return fileInfo.path();
|
||||
default:
|
||||
return "";
|
||||
return ""; // State
|
||||
}
|
||||
}
|
||||
return node->name();
|
||||
|
@ -99,6 +99,7 @@ public:
|
||||
|
||||
void setDiff(const git::Diff &diff = git::Diff());
|
||||
void refresh(const QStringList &paths);
|
||||
void setMultiColumn(bool);
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
|
@ -98,6 +98,8 @@ DoubleTreeWidget::DoubleTreeWidget(const git::Repository &repo, QWidget *parent)
|
||||
"Single View", Setting::Id::ShowChangedFilesInSingleView);
|
||||
QAction *listView =
|
||||
setupAppearanceAction("List View", Setting::Id::ShowChangedFilesAsList);
|
||||
QAction *multiColumn = setupAppearanceAction(
|
||||
"Multi Column", Setting::Id::ShowChangedFilesMultiColumn, true);
|
||||
RepoView::parentView(this)->refresh(); // apply read settings
|
||||
|
||||
QAction *hideUntrackedFiles = setupAppearanceAction(
|
||||
@ -105,6 +107,7 @@ DoubleTreeWidget::DoubleTreeWidget(const git::Repository &repo, QWidget *parent)
|
||||
|
||||
contextMenu->addAction(singleTree);
|
||||
contextMenu->addAction(listView);
|
||||
contextMenu->addAction(multiColumn);
|
||||
contextMenu->addAction(hideUntrackedFiles);
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
||||
buttonLayout->addStretch();
|
||||
@ -411,9 +414,14 @@ void DoubleTreeWidget::setDiff(const git::Diff &diff, const QString &file,
|
||||
bool listView = Settings::instance()
|
||||
->value(Setting::Id::ShowChangedFilesAsList, false)
|
||||
.toBool();
|
||||
const bool multiColumn =
|
||||
Settings::instance()
|
||||
->value(Setting::Id::ShowChangedFilesMultiColumn, true)
|
||||
.toBool();
|
||||
|
||||
// Widget modifications.
|
||||
model->enableListView(listView);
|
||||
model->setMultiColumn(multiColumn);
|
||||
stagedFiles->setRootIsDecorated(!listView);
|
||||
unstagedFiles->setRootIsDecorated(!listView);
|
||||
// mUnstagedCommitedFiles->setVisible(!singleTree);
|
||||
|
Loading…
Reference in New Issue
Block a user