forked from qt-creator/qt-creator
Git: Remotedialog, replace QTableView with QTreeView
QTreeView is a better list view with columns than QTableView. One special reason for this change is that QTreeView finds a proper default row height regardless of the system DPI. Change-Id: I3342e2295a3782b480ea811bfe335e3a77482891 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "ui_remotedialog.h"
|
||||
#include "ui_remoteadditiondialog.h"
|
||||
|
||||
#include <utils/headerviewstretcher.h>
|
||||
#include <vcsbase/vcsbaseoutputwindow.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
@@ -94,8 +95,7 @@ RemoteDialog::RemoteDialog(QWidget *parent) :
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->remoteView->setModel(m_remoteModel);
|
||||
m_ui->remoteView->horizontalHeader()->setStretchLastSection(true);
|
||||
m_ui->remoteView->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
|
||||
new Utils::HeaderViewStretcher(m_ui->remoteView->header(), 1);
|
||||
|
||||
connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addRemote()));
|
||||
connect(m_ui->fetchButton, SIGNAL(clicked()), this, SLOT(fetchFromRemote()));
|
||||
|
||||
@@ -2,14 +2,6 @@
|
||||
<ui version="4.0">
|
||||
<class>Git::Internal::RemoteDialog</class>
|
||||
<widget class="QDialog" name="Git::Internal::RemoteDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>507</width>
|
||||
<height>329</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Remotes</string>
|
||||
</property>
|
||||
@@ -62,7 +54,7 @@
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTableView" name="remoteView">
|
||||
<widget class="QTreeView" name="remoteView">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -78,22 +70,29 @@
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="addButton">
|
||||
<property name="text">
|
||||
|
||||
@@ -139,6 +139,14 @@ QVariant RemoteModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant RemoteModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
|
||||
return QVariant();
|
||||
|
||||
return (section == 0) ? tr("Name") : tr("Url");
|
||||
}
|
||||
|
||||
bool RemoteModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (role != Qt::EditRole)
|
||||
|
||||
@@ -59,6 +59,8 @@ public:
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user