forked from qt-creator/qt-creator
Git: Move filter widget to GitEditor
and make it a QToolBar. Change-Id: I6a16b1a828bfabaace8e14ef39344f7f2bac7e8a Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
Orgad Shaneh
parent
d21f72d0dd
commit
2110be00ab
@@ -42,17 +42,15 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMenu>
|
||||
#include <QRegExp>
|
||||
#include <QSet>
|
||||
#include <QTextCodec>
|
||||
#include <QDir>
|
||||
|
||||
#include <QTextCursor>
|
||||
#include <QTextBlock>
|
||||
#include <QMessageBox>
|
||||
#include <QTextCodec>
|
||||
#include <QTextCursor>
|
||||
|
||||
#define CHANGE_PATTERN "[a-f0-9]{7,40}"
|
||||
|
||||
@@ -61,6 +59,45 @@ using namespace VcsBase;
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
class GitLogFilterWidget : public QToolBar
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Git::Internal::GitLogFilterWidget);
|
||||
|
||||
public:
|
||||
GitLogFilterWidget(GitEditorWidget *editor)
|
||||
{
|
||||
auto addLineEdit = [](const QString &placeholder,
|
||||
const QString &tooltip,
|
||||
GitEditorWidget *editor)
|
||||
{
|
||||
auto lineEdit = new Utils::FancyLineEdit;
|
||||
lineEdit->setFiltering(true);
|
||||
lineEdit->setToolTip(tooltip);
|
||||
lineEdit->setPlaceholderText(placeholder);
|
||||
lineEdit->setMaximumWidth(200);
|
||||
connect(lineEdit, &QLineEdit::returnPressed,
|
||||
editor, &GitEditorWidget::refresh);
|
||||
connect(lineEdit, &Utils::FancyLineEdit::rightButtonClicked,
|
||||
editor, &GitEditorWidget::refresh);
|
||||
return lineEdit;
|
||||
};
|
||||
grepLineEdit = addLineEdit(tr("Filter by message"),
|
||||
tr("Filter log entries by text in the commit message."),
|
||||
editor);
|
||||
pickaxeLineEdit = addLineEdit(tr("Filter by content"),
|
||||
tr("Filter log entries by added or removed string."),
|
||||
editor);
|
||||
addWidget(new QLabel(tr("Filter:")));
|
||||
addSeparator();
|
||||
addWidget(grepLineEdit);
|
||||
addSeparator();
|
||||
addWidget(pickaxeLineEdit);
|
||||
}
|
||||
|
||||
Utils::FancyLineEdit *grepLineEdit;
|
||||
Utils::FancyLineEdit *pickaxeLineEdit;
|
||||
};
|
||||
|
||||
GitEditorWidget::GitEditorWidget() :
|
||||
m_changeNumberPattern(CHANGE_PATTERN)
|
||||
{
|
||||
@@ -360,44 +397,31 @@ QString GitEditorWidget::sourceWorkingDirectory() const
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
void GitEditorWidget::lineEditChanged()
|
||||
void GitEditorWidget::refresh()
|
||||
{
|
||||
if (VcsBaseEditorConfig *config = editorConfig())
|
||||
config->handleArgumentsChanged();
|
||||
}
|
||||
|
||||
void GitEditorWidget::refreshOnLineEdit(Utils::FancyLineEdit *lineEdit)
|
||||
QWidget *GitEditorWidget::addFilterWidget()
|
||||
{
|
||||
connect(lineEdit, &QLineEdit::returnPressed,
|
||||
this, &GitEditorWidget::lineEditChanged);
|
||||
connect(lineEdit, &Utils::FancyLineEdit::rightButtonClicked,
|
||||
this, &GitEditorWidget::lineEditChanged);
|
||||
}
|
||||
|
||||
void GitEditorWidget::setGrepLineEdit(Utils::FancyLineEdit *lineEdit)
|
||||
{
|
||||
m_grepLineEdit = lineEdit;
|
||||
refreshOnLineEdit(lineEdit);
|
||||
}
|
||||
|
||||
void GitEditorWidget::setPickaxeLineEdit(Utils::FancyLineEdit *lineEdit)
|
||||
{
|
||||
m_pickaxeLineEdit = lineEdit;
|
||||
refreshOnLineEdit(lineEdit);
|
||||
if (!m_logFilterWidget)
|
||||
m_logFilterWidget = new GitLogFilterWidget(this);
|
||||
return m_logFilterWidget;
|
||||
}
|
||||
|
||||
QString GitEditorWidget::grepValue() const
|
||||
{
|
||||
if (!m_grepLineEdit)
|
||||
if (!m_logFilterWidget)
|
||||
return QString();
|
||||
return m_grepLineEdit->text();
|
||||
return m_logFilterWidget->grepLineEdit->text();
|
||||
}
|
||||
|
||||
QString GitEditorWidget::pickaxeValue() const
|
||||
{
|
||||
if (!m_pickaxeLineEdit)
|
||||
if (!m_logFilterWidget)
|
||||
return QString();
|
||||
return m_pickaxeLineEdit->text();
|
||||
return m_logFilterWidget->pickaxeLineEdit->text();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -34,6 +34,8 @@ namespace Utils { class FancyLineEdit; }
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
class GitLogFilterWidget;
|
||||
|
||||
class GitEditorWidget : public VcsBase::VcsBaseEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -42,10 +44,11 @@ public:
|
||||
GitEditorWidget();
|
||||
|
||||
void setPlainText(const QString &text) override;
|
||||
void setGrepLineEdit(Utils::FancyLineEdit *lineEdit);
|
||||
QWidget *addFilterWidget();
|
||||
void setPickaxeLineEdit(Utils::FancyLineEdit *lineEdit);
|
||||
QString grepValue() const;
|
||||
QString pickaxeValue() const;
|
||||
void refresh();
|
||||
|
||||
private:
|
||||
void applyDiffChunk(const VcsBase::DiffChunk& chunk, bool revert);
|
||||
@@ -64,13 +67,10 @@ private:
|
||||
bool supportChangeLinks() const override;
|
||||
QString fileNameForLine(int line) const override;
|
||||
QString sourceWorkingDirectory() const;
|
||||
void refreshOnLineEdit(Utils::FancyLineEdit *lineEdit);
|
||||
void lineEditChanged();
|
||||
|
||||
mutable QRegExp m_changeNumberPattern;
|
||||
QString m_currentChange;
|
||||
Utils::FancyLineEdit *m_grepLineEdit = nullptr;
|
||||
Utils::FancyLineEdit *m_pickaxeLineEdit = nullptr;
|
||||
GitLogFilterWidget *m_logFilterWidget = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Git
|
||||
|
@@ -60,7 +60,6 @@
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
|
||||
#include <aggregation/aggregate.h>
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -85,7 +84,6 @@
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMenu>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -146,29 +144,15 @@ public:
|
||||
|
||||
class GitLogEditorWidget : public QWidget
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Git::Internal::GitLogEditorWidget);
|
||||
public:
|
||||
GitLogEditorWidget(GitEditorWidget *gitEditor)
|
||||
{
|
||||
auto vlayout = new QVBoxLayout;
|
||||
auto hlayout = new QHBoxLayout;
|
||||
vlayout->setSpacing(0);
|
||||
vlayout->setContentsMargins(0, 0, 0, 0);
|
||||
auto grepLineEdit = addLineEdit(tr("Filter by message"),
|
||||
tr("Filter log entries by text in the commit message."));
|
||||
auto pickaxeLineEdit = addLineEdit(tr("Filter by content"),
|
||||
tr("Filter log entries by added or removed string."));
|
||||
hlayout->setSpacing(20);
|
||||
hlayout->setContentsMargins(0, 0, 0, 0);
|
||||
hlayout->addWidget(new QLabel(tr("Filter:")));
|
||||
hlayout->addWidget(grepLineEdit);
|
||||
hlayout->addWidget(pickaxeLineEdit);
|
||||
hlayout->addStretch();
|
||||
vlayout->addLayout(hlayout);
|
||||
vlayout->addWidget(gitEditor->addFilterWidget());
|
||||
vlayout->addWidget(gitEditor);
|
||||
setLayout(vlayout);
|
||||
gitEditor->setGrepLineEdit(grepLineEdit);
|
||||
gitEditor->setPickaxeLineEdit(pickaxeLineEdit);
|
||||
|
||||
auto textAgg = Aggregation::Aggregate::parentAggregate(gitEditor);
|
||||
auto agg = textAgg ? textAgg : new Aggregation::Aggregate;
|
||||
@@ -176,17 +160,6 @@ public:
|
||||
agg->add(gitEditor);
|
||||
setFocusProxy(gitEditor);
|
||||
}
|
||||
|
||||
private:
|
||||
FancyLineEdit *addLineEdit(const QString &placeholder, const QString &tooltip)
|
||||
{
|
||||
auto lineEdit = new FancyLineEdit;
|
||||
lineEdit->setFiltering(true);
|
||||
lineEdit->setToolTip(tooltip);
|
||||
lineEdit->setPlaceholderText(placeholder);
|
||||
lineEdit->setMaximumWidth(200);
|
||||
return lineEdit;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Editor>
|
||||
|
Reference in New Issue
Block a user