forked from qt-creator/qt-creator
Git: inline stashdialog.ui
Change-Id: I3665fcf7622c45d1aef3dacae936252a4f73d32f Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -37,5 +37,5 @@ add_qtc_plugin(Git
|
|||||||
remoteadditiondialog.ui
|
remoteadditiondialog.ui
|
||||||
remotedialog.cpp remotedialog.h remotedialog.ui
|
remotedialog.cpp remotedialog.h remotedialog.ui
|
||||||
remotemodel.cpp remotemodel.h
|
remotemodel.cpp remotemodel.h
|
||||||
stashdialog.cpp stashdialog.h stashdialog.ui
|
stashdialog.cpp stashdialog.h
|
||||||
)
|
)
|
||||||
|
@@ -63,7 +63,6 @@ QtcPlugin {
|
|||||||
"remotemodel.h",
|
"remotemodel.h",
|
||||||
"stashdialog.cpp",
|
"stashdialog.cpp",
|
||||||
"stashdialog.h",
|
"stashdialog.h",
|
||||||
"stashdialog.ui",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
|
@@ -24,22 +24,29 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "stashdialog.h"
|
#include "stashdialog.h"
|
||||||
|
|
||||||
#include "gitclient.h"
|
#include "gitclient.h"
|
||||||
#include "gitplugin.h"
|
#include "gitplugin.h"
|
||||||
#include "gitutils.h"
|
#include "gitutils.h"
|
||||||
#include "ui_stashdialog.h"
|
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/fancylineedit.h>
|
||||||
|
#include <utils/itemviews.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QApplication>
|
||||||
#include <QDir>
|
|
||||||
#include <QModelIndex>
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QStandardItemModel>
|
#include <QDebug>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QDialogButtonBox>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QLabel>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QModelIndex>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -48,7 +55,7 @@ enum { NameColumn, BranchColumn, MessageColumn, ColumnCount };
|
|||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static inline QList<QStandardItem*> stashModelRowItems(const Stash &s)
|
static QList<QStandardItem*> stashModelRowItems(const Stash &s)
|
||||||
{
|
{
|
||||||
Qt::ItemFlags itemFlags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
Qt::ItemFlags itemFlags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||||
auto nameItem = new QStandardItem(s.name);
|
auto nameItem = new QStandardItem(s.name);
|
||||||
@@ -63,7 +70,8 @@ static inline QList<QStandardItem*> stashModelRowItems(const Stash &s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------- StashModel
|
// ----------- StashModel
|
||||||
class StashModel : public QStandardItemModel {
|
class StashModel : public QStandardItemModel
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
explicit StashModel(QObject *parent = nullptr);
|
explicit StashModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
@@ -93,7 +101,6 @@ void StashModel::setStashes(const QList<Stash> &stashes)
|
|||||||
|
|
||||||
// ---------- StashDialog
|
// ---------- StashDialog
|
||||||
StashDialog::StashDialog(QWidget *parent) : QDialog(parent),
|
StashDialog::StashDialog(QWidget *parent) : QDialog(parent),
|
||||||
ui(new Ui::StashDialog),
|
|
||||||
m_model(new StashModel),
|
m_model(new StashModel),
|
||||||
m_proxyModel(new QSortFilterProxyModel),
|
m_proxyModel(new QSortFilterProxyModel),
|
||||||
m_deleteAllButton(new QPushButton(tr("Delete &All..."))),
|
m_deleteAllButton(new QPushButton(tr("Delete &All..."))),
|
||||||
@@ -105,52 +112,76 @@ StashDialog::StashDialog(QWidget *parent) : QDialog(parent),
|
|||||||
m_refreshButton(new QPushButton(tr("Re&fresh")))
|
m_refreshButton(new QPushButton(tr("Re&fresh")))
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose, true); // Do not update unnecessarily
|
setAttribute(Qt::WA_DeleteOnClose, true); // Do not update unnecessarily
|
||||||
|
setWindowTitle(tr("Stashes"));
|
||||||
|
|
||||||
|
resize(599, 485);
|
||||||
|
|
||||||
|
m_repositoryLabel = new QLabel(this);
|
||||||
|
|
||||||
|
auto filterLineEdit = new FancyLineEdit(this);
|
||||||
|
filterLineEdit->setFiltering(true);
|
||||||
|
|
||||||
|
auto buttonBox = new QDialogButtonBox(this);
|
||||||
|
buttonBox->setOrientation(Qt::Vertical);
|
||||||
|
buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
||||||
|
|
||||||
ui->setupUi(this);
|
|
||||||
ui->filterLineEdit->setFiltering(true);
|
|
||||||
// Buttons
|
// Buttons
|
||||||
ui->buttonBox->addButton(m_showCurrentButton, QDialogButtonBox::ActionRole);
|
buttonBox->addButton(m_showCurrentButton, QDialogButtonBox::ActionRole);
|
||||||
connect(m_showCurrentButton, &QPushButton::clicked,
|
connect(m_showCurrentButton, &QPushButton::clicked,
|
||||||
this, &StashDialog::showCurrent);
|
this, &StashDialog::showCurrent);
|
||||||
ui->buttonBox->addButton(m_refreshButton, QDialogButtonBox::ActionRole);
|
buttonBox->addButton(m_refreshButton, QDialogButtonBox::ActionRole);
|
||||||
connect(m_refreshButton, &QPushButton::clicked,
|
connect(m_refreshButton, &QPushButton::clicked,
|
||||||
this, &StashDialog::forceRefresh);
|
this, &StashDialog::forceRefresh);
|
||||||
ui->buttonBox->addButton(m_restoreCurrentButton, QDialogButtonBox::ActionRole);
|
buttonBox->addButton(m_restoreCurrentButton, QDialogButtonBox::ActionRole);
|
||||||
connect(m_restoreCurrentButton, &QPushButton::clicked,
|
connect(m_restoreCurrentButton, &QPushButton::clicked,
|
||||||
this, &StashDialog::restoreCurrent);
|
this, &StashDialog::restoreCurrent);
|
||||||
ui->buttonBox->addButton(m_restoreCurrentInBranchButton, QDialogButtonBox::ActionRole);
|
buttonBox->addButton(m_restoreCurrentInBranchButton, QDialogButtonBox::ActionRole);
|
||||||
connect(m_restoreCurrentInBranchButton, &QPushButton::clicked,
|
connect(m_restoreCurrentInBranchButton, &QPushButton::clicked,
|
||||||
this, &StashDialog::restoreCurrentInBranch);
|
this, &StashDialog::restoreCurrentInBranch);
|
||||||
ui->buttonBox->addButton(m_deleteSelectionButton, QDialogButtonBox::ActionRole);
|
buttonBox->addButton(m_deleteSelectionButton, QDialogButtonBox::ActionRole);
|
||||||
connect(m_deleteSelectionButton, &QPushButton::clicked,
|
connect(m_deleteSelectionButton, &QPushButton::clicked,
|
||||||
this, &StashDialog::deleteSelection);
|
this, &StashDialog::deleteSelection);
|
||||||
ui->buttonBox->addButton(m_deleteAllButton, QDialogButtonBox::ActionRole);
|
buttonBox->addButton(m_deleteAllButton, QDialogButtonBox::ActionRole);
|
||||||
connect(m_deleteAllButton, &QPushButton::clicked,
|
connect(m_deleteAllButton, &QPushButton::clicked,
|
||||||
this, &StashDialog::deleteAll);
|
this, &StashDialog::deleteAll);
|
||||||
|
|
||||||
// Models
|
// Models
|
||||||
m_proxyModel->setSourceModel(m_model);
|
m_proxyModel->setSourceModel(m_model);
|
||||||
m_proxyModel->setFilterKeyColumn(-1);
|
m_proxyModel->setFilterKeyColumn(-1);
|
||||||
m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
ui->stashView->setActivationMode(Utils::DoubleClickActivation);
|
|
||||||
ui->stashView->setModel(m_proxyModel);
|
m_stashView = new TreeView(this);
|
||||||
ui->stashView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
m_stashView->setActivationMode(Utils::DoubleClickActivation);
|
||||||
ui->stashView->setAllColumnsShowFocus(true);
|
m_stashView->setModel(m_proxyModel);
|
||||||
ui->stashView->setUniformRowHeights(true);
|
m_stashView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
connect(ui->filterLineEdit, &Utils::FancyLineEdit::filterChanged,
|
m_stashView->setAllColumnsShowFocus(true);
|
||||||
|
m_stashView->setUniformRowHeights(true);
|
||||||
|
m_stashView->setFocus();
|
||||||
|
|
||||||
|
using namespace Layouting;
|
||||||
|
Row {
|
||||||
|
Column {
|
||||||
|
m_repositoryLabel,
|
||||||
|
filterLineEdit,
|
||||||
|
m_stashView
|
||||||
|
},
|
||||||
|
buttonBox
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(filterLineEdit, &Utils::FancyLineEdit::filterChanged,
|
||||||
m_proxyModel, &QSortFilterProxyModel::setFilterFixedString);
|
m_proxyModel, &QSortFilterProxyModel::setFilterFixedString);
|
||||||
connect(ui->stashView->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
connect(m_stashView->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||||
this, &StashDialog::enableButtons);
|
this, &StashDialog::enableButtons);
|
||||||
connect(ui->stashView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
connect(m_stashView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||||
this, &StashDialog::enableButtons);
|
this, &StashDialog::enableButtons);
|
||||||
connect(ui->stashView, &Utils::TreeView::activated,
|
connect(m_stashView, &Utils::TreeView::activated,
|
||||||
this, &StashDialog::showCurrent);
|
this, &StashDialog::showCurrent);
|
||||||
ui->stashView->setFocus();
|
|
||||||
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
StashDialog::~StashDialog()
|
StashDialog::~StashDialog() = default;
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StashDialog::refresh(const FilePath &repository, bool force)
|
void StashDialog::refresh(const FilePath &repository, bool force)
|
||||||
{
|
{
|
||||||
@@ -158,7 +189,7 @@ void StashDialog::refresh(const FilePath &repository, bool force)
|
|||||||
return;
|
return;
|
||||||
// Refresh
|
// Refresh
|
||||||
m_repository = repository;
|
m_repository = repository;
|
||||||
ui->repositoryLabel->setText(GitPlugin::msgRepositoryLabel(repository));
|
m_repositoryLabel->setText(GitPlugin::msgRepositoryLabel(repository));
|
||||||
if (m_repository.isEmpty()) {
|
if (m_repository.isEmpty()) {
|
||||||
m_model->setStashes(QList<Stash>());
|
m_model->setStashes(QList<Stash>());
|
||||||
} else {
|
} else {
|
||||||
@@ -167,7 +198,7 @@ void StashDialog::refresh(const FilePath &repository, bool force)
|
|||||||
m_model->setStashes(stashes);
|
m_model->setStashes(stashes);
|
||||||
if (!stashes.isEmpty()) {
|
if (!stashes.isEmpty()) {
|
||||||
for (int c = 0; c < ColumnCount; c++)
|
for (int c = 0; c < ColumnCount; c++)
|
||||||
ui->stashView->resizeColumnToContents(c);
|
m_stashView->resizeColumnToContents(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enableButtons();
|
enableButtons();
|
||||||
@@ -346,7 +377,7 @@ void StashDialog::restoreCurrentInBranch()
|
|||||||
|
|
||||||
int StashDialog::currentRow() const
|
int StashDialog::currentRow() const
|
||||||
{
|
{
|
||||||
const QModelIndex proxyIndex = ui->stashView->currentIndex();
|
const QModelIndex proxyIndex = m_stashView->currentIndex();
|
||||||
if (proxyIndex.isValid()) {
|
if (proxyIndex.isValid()) {
|
||||||
const QModelIndex index = m_proxyModel->mapToSource(proxyIndex);
|
const QModelIndex index = m_proxyModel->mapToSource(proxyIndex);
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
@@ -358,7 +389,7 @@ int StashDialog::currentRow() const
|
|||||||
QList<int> StashDialog::selectedRows() const
|
QList<int> StashDialog::selectedRows() const
|
||||||
{
|
{
|
||||||
QList<int> rc;
|
QList<int> rc;
|
||||||
const QModelIndexList rows = ui->stashView->selectionModel()->selectedRows();
|
const QModelIndexList rows = m_stashView->selectionModel()->selectedRows();
|
||||||
for (const QModelIndex &proxyIndex : rows) {
|
for (const QModelIndex &proxyIndex : rows) {
|
||||||
const QModelIndex index = m_proxyModel->mapToSource(proxyIndex);
|
const QModelIndex index = m_proxyModel->mapToSource(proxyIndex);
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
@@ -382,7 +413,7 @@ void StashDialog::enableButtons()
|
|||||||
m_showCurrentButton->setEnabled(hasCurrentRow);
|
m_showCurrentButton->setEnabled(hasCurrentRow);
|
||||||
m_restoreCurrentButton->setEnabled(hasCurrentRow);
|
m_restoreCurrentButton->setEnabled(hasCurrentRow);
|
||||||
m_restoreCurrentInBranchButton->setEnabled(hasCurrentRow);
|
m_restoreCurrentInBranchButton->setEnabled(hasCurrentRow);
|
||||||
const bool hasSelection = !ui->stashView->selectionModel()->selectedRows().isEmpty();
|
const bool hasSelection = !m_stashView->selectionModel()->selectedRows().isEmpty();
|
||||||
m_deleteSelectionButton->setEnabled(hasSelection);
|
m_deleteSelectionButton->setEnabled(hasSelection);
|
||||||
m_refreshButton->setEnabled(hasRepository);
|
m_refreshButton->setEnabled(hasRepository);
|
||||||
}
|
}
|
||||||
|
@@ -30,14 +30,16 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSortFilterProxyModel;
|
class QLabel;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QSortFilterProxyModel;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Utils { class TreeView; }
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
namespace Ui { class StashDialog; }
|
|
||||||
class StashModel;
|
class StashModel;
|
||||||
|
|
||||||
/* StashDialog: Non-modal dialog that manages the list of stashes
|
/* StashDialog: Non-modal dialog that manages the list of stashes
|
||||||
@@ -78,7 +80,6 @@ private:
|
|||||||
int currentRow() const;
|
int currentRow() const;
|
||||||
QList<int> selectedRows() const; \
|
QList<int> selectedRows() const; \
|
||||||
|
|
||||||
Ui::StashDialog *ui;
|
|
||||||
StashModel *m_model;
|
StashModel *m_model;
|
||||||
QSortFilterProxyModel *m_proxyModel;
|
QSortFilterProxyModel *m_proxyModel;
|
||||||
QPushButton *m_deleteAllButton;
|
QPushButton *m_deleteAllButton;
|
||||||
@@ -88,6 +89,9 @@ private:
|
|||||||
QPushButton *m_restoreCurrentInBranchButton;
|
QPushButton *m_restoreCurrentInBranchButton;
|
||||||
QPushButton *m_refreshButton;
|
QPushButton *m_refreshButton;
|
||||||
Utils::FilePath m_repository;
|
Utils::FilePath m_repository;
|
||||||
|
|
||||||
|
QLabel *m_repositoryLabel;
|
||||||
|
Utils::TreeView *m_stashView;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -1,93 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Git::Internal::StashDialog</class>
|
|
||||||
<widget class="QDialog" name="Git::Internal::StashDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>599</width>
|
|
||||||
<height>485</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Stashes</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="repositoryLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">Repository: Dummy</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Utils::FancyLineEdit" name="filterLineEdit"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Utils::TreeView" name="stashView"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Close</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>Utils::FancyLineEdit</class>
|
|
||||||
<extends>QLineEdit</extends>
|
|
||||||
<header location="global">utils/fancylineedit.h</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
|
||||||
<class>Utils::TreeView</class>
|
|
||||||
<extends>QTreeView</extends>
|
|
||||||
<header location="global">utils/itemviews.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Git::Internal::StashDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Git::Internal::StashDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
Reference in New Issue
Block a user