forked from qt-creator/qt-creator
VcsBase: Inline nicknamedialog.ui
Change-Id: I98b0d300d78336c67103483bdf5c552b36e0a868 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -9,7 +9,7 @@ add_qtc_plugin(VcsBase
|
|||||||
cleandialog.cpp cleandialog.h
|
cleandialog.cpp cleandialog.h
|
||||||
commonvcssettings.cpp commonvcssettings.h
|
commonvcssettings.cpp commonvcssettings.h
|
||||||
diffandloghighlighter.cpp diffandloghighlighter.h
|
diffandloghighlighter.cpp diffandloghighlighter.h
|
||||||
nicknamedialog.cpp nicknamedialog.h nicknamedialog.ui
|
nicknamedialog.cpp nicknamedialog.h
|
||||||
submiteditorfile.cpp submiteditorfile.h
|
submiteditorfile.cpp submiteditorfile.h
|
||||||
submiteditorwidget.cpp submiteditorwidget.h submiteditorwidget.ui
|
submiteditorwidget.cpp submiteditorwidget.h submiteditorwidget.ui
|
||||||
submitfieldwidget.cpp submitfieldwidget.h
|
submitfieldwidget.cpp submitfieldwidget.h
|
||||||
|
|||||||
@@ -2,11 +2,14 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "nicknamedialog.h"
|
#include "nicknamedialog.h"
|
||||||
#include "ui_nicknamedialog.h"
|
|
||||||
|
|
||||||
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
#include <utils/itemviews.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
@@ -28,8 +31,7 @@ enum { NickNameRole = Qt::UserRole + 1 };
|
|||||||
be preferred.
|
be preferred.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace VcsBase::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
// For code clarity, a struct representing the entries of a mail map file
|
// For code clarity, a struct representing the entries of a mail map file
|
||||||
// with parse and model functions.
|
// with parse and model functions.
|
||||||
@@ -143,42 +145,54 @@ QDebug operator<<(QDebug d, const NickNameEntry &e)
|
|||||||
|
|
||||||
NickNameDialog::NickNameDialog(QStandardItemModel *model, QWidget *parent) :
|
NickNameDialog::NickNameDialog(QStandardItemModel *model, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
m_ui(new Internal::Ui::NickNameDialog),
|
|
||||||
m_model(model),
|
m_model(model),
|
||||||
m_filterModel(new QSortFilterProxyModel(this))
|
m_filterModel(new QSortFilterProxyModel(this))
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
auto filterLineEdit = new FancyLineEdit;
|
||||||
|
|
||||||
|
m_filterTreeView = new TreeView;
|
||||||
|
|
||||||
|
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||||
|
|
||||||
okButton()->setEnabled(false);
|
okButton()->setEnabled(false);
|
||||||
|
|
||||||
// Populate model and grow tree to accommodate it
|
// Populate model and grow tree to accommodate it
|
||||||
m_filterModel->setSourceModel(model);
|
m_filterModel->setSourceModel(model);
|
||||||
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
m_ui->filterTreeView->setModel(m_filterModel);
|
m_filterTreeView->setModel(m_filterModel);
|
||||||
m_ui->filterTreeView->setActivationMode(DoubleClickActivation);
|
m_filterTreeView->setActivationMode(DoubleClickActivation);
|
||||||
const int columnCount = m_filterModel->columnCount();
|
const int columnCount = m_filterModel->columnCount();
|
||||||
int treeWidth = 0;
|
int treeWidth = 0;
|
||||||
for (int c = 0; c < columnCount; c++) {
|
for (int c = 0; c < columnCount; c++) {
|
||||||
m_ui->filterTreeView->resizeColumnToContents(c);
|
m_filterTreeView->resizeColumnToContents(c);
|
||||||
treeWidth += m_ui->filterTreeView->columnWidth(c);
|
treeWidth += m_filterTreeView->columnWidth(c);
|
||||||
}
|
}
|
||||||
m_ui->filterTreeView->setMinimumWidth(treeWidth + 20);
|
m_filterTreeView->setMinimumWidth(treeWidth + 20);
|
||||||
m_ui->filterLineEdit->setFiltering(true);
|
filterLineEdit->setFiltering(true);
|
||||||
connect(m_ui->filterTreeView, &QAbstractItemView::activated, this,
|
|
||||||
|
using namespace Layouting;
|
||||||
|
Column {
|
||||||
|
filterLineEdit,
|
||||||
|
m_filterTreeView,
|
||||||
|
m_buttonBox
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
|
connect(m_filterTreeView, &QAbstractItemView::activated, this,
|
||||||
&NickNameDialog::slotActivated);
|
&NickNameDialog::slotActivated);
|
||||||
connect(m_ui->filterTreeView->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
connect(m_filterTreeView->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||||
this, &NickNameDialog::slotCurrentItemChanged);
|
this, &NickNameDialog::slotCurrentItemChanged);
|
||||||
connect(m_ui->filterLineEdit, &FancyLineEdit::filterChanged,
|
connect(filterLineEdit, &FancyLineEdit::filterChanged,
|
||||||
m_filterModel, &QSortFilterProxyModel::setFilterFixedString);
|
m_filterModel, &QSortFilterProxyModel::setFilterFixedString);
|
||||||
}
|
}
|
||||||
|
|
||||||
NickNameDialog::~NickNameDialog()
|
NickNameDialog::~NickNameDialog() = default;
|
||||||
{
|
|
||||||
delete m_ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPushButton *NickNameDialog::okButton() const
|
QPushButton *NickNameDialog::okButton() const
|
||||||
{
|
{
|
||||||
return m_ui->buttonBox->button(QDialogButtonBox::Ok);
|
return m_buttonBox->button(QDialogButtonBox::Ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NickNameDialog::slotCurrentItemChanged(const QModelIndex &index)
|
void NickNameDialog::slotCurrentItemChanged(const QModelIndex &index)
|
||||||
@@ -194,7 +208,7 @@ void NickNameDialog::slotActivated(const QModelIndex &)
|
|||||||
|
|
||||||
QString NickNameDialog::nickName() const
|
QString NickNameDialog::nickName() const
|
||||||
{
|
{
|
||||||
const QModelIndex index = m_ui->filterTreeView->selectionModel()->currentIndex();
|
const QModelIndex index = m_filterTreeView->selectionModel()->currentIndex();
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
const QModelIndex sourceIndex = m_filterModel->mapToSource(index);
|
const QModelIndex sourceIndex = m_filterModel->mapToSource(index);
|
||||||
if (const QStandardItem *item = m_model->itemFromIndex(sourceIndex))
|
if (const QStandardItem *item = m_model->itemFromIndex(sourceIndex))
|
||||||
@@ -250,5 +264,4 @@ QStringList NickNameDialog::nickNameList(const QStandardItemModel *model)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // VcsBase::Internal
|
||||||
} // namespace VcsBase
|
|
||||||
|
|||||||
@@ -6,16 +6,16 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSortFilterProxyModel;
|
class QDialogButtonBox;
|
||||||
class QStandardItemModel;
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QSortFilterProxyModel;
|
||||||
|
class QStandardItemModel;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace Utils { class TreeView; }
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
namespace Ui { class NickNameDialog; }
|
namespace VcsBase::Internal {
|
||||||
|
|
||||||
class NickNameDialog : public QDialog
|
class NickNameDialog : public QDialog
|
||||||
{
|
{
|
||||||
@@ -42,10 +42,11 @@ private:
|
|||||||
|
|
||||||
QPushButton *okButton() const;
|
QPushButton *okButton() const;
|
||||||
|
|
||||||
Ui::NickNameDialog *m_ui;
|
|
||||||
QStandardItemModel *m_model;
|
QStandardItemModel *m_model;
|
||||||
QSortFilterProxyModel *m_filterModel;
|
QSortFilterProxyModel *m_filterModel;
|
||||||
|
|
||||||
|
Utils::TreeView *m_filterTreeView;
|
||||||
|
QDialogButtonBox *m_buttonBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // VcsBase::Internal
|
||||||
} // namespace VcsBase
|
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>VcsBase::Internal::NickNameDialog</class>
|
|
||||||
<widget class="QDialog" name="VcsBase::Internal::NickNameDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>618</width>
|
|
||||||
<height>414</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Nicknames</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="Utils::FancyLineEdit" name="filterLineEdit"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Utils::TreeView" name="filterTreeView"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</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>VcsBase::Internal::NickNameDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>252</x>
|
|
||||||
<y>405</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>VcsBase::Internal::NickNameDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>293</x>
|
|
||||||
<y>405</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
||||||
@@ -33,7 +33,6 @@ QtcPlugin {
|
|||||||
"diffandloghighlighter.h",
|
"diffandloghighlighter.h",
|
||||||
"nicknamedialog.cpp",
|
"nicknamedialog.cpp",
|
||||||
"nicknamedialog.h",
|
"nicknamedialog.h",
|
||||||
"nicknamedialog.ui",
|
|
||||||
"submiteditorfile.cpp",
|
"submiteditorfile.cpp",
|
||||||
"submiteditorfile.h",
|
"submiteditorfile.h",
|
||||||
"submiteditorwidget.cpp",
|
"submiteditorwidget.cpp",
|
||||||
|
|||||||
Reference in New Issue
Block a user