Skip to content

Commit

Permalink
browser properties path/uri without spaces wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Apr 29, 2015
1 parent 4645dd7 commit 4c2844e
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 53 deletions.
31 changes: 31 additions & 0 deletions src/app/qgsbrowserdockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
***************************************************************************/
#include "qgsbrowserdockwidget.h"

#include <QAbstractTextDocumentLayout>
#include <QHeaderView>
#include <QTreeView>
#include <QMenu>
#include <QSettings>
#include <QToolButton>
#include <QFileDialog>
#include <QPlainTextDocumentLayout>
#include <QSortFilterProxyModel>

#include "qgsbrowsermodel.h"
Expand Down Expand Up @@ -243,6 +245,29 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
}
};

QgsBrowserPropertiesWrapLabel::QgsBrowserPropertiesWrapLabel( const QString& text, QWidget* parent )
: QTextEdit( text, parent )
{
setReadOnly( true );
setFrameStyle( QFrame::NoFrame );
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
QPalette pal = palette();
pal.setColor( QPalette::Base, Qt::transparent );
setPalette( pal );
setLineWrapMode( QTextEdit::WidgetWidth );
setWordWrapMode( QTextOption::WrapAnywhere );
connect( qobject_cast<QObject*>( document()->documentLayout() ), SIGNAL( documentSizeChanged( QSizeF ) ),
this, SLOT( adjustHeight( QSizeF ) ) );
setMaximumHeight( 20 );
}

void QgsBrowserPropertiesWrapLabel::adjustHeight( const QSizeF& size )
{
int height = size.height() + 2 * frameWidth();
setMinimumHeight( height );
setMaximumHeight( height );
}

QgsBrowserPropertiesWidget::QgsBrowserPropertiesWidget( QWidget* parent ) :
QWidget( parent )
{
Expand All @@ -268,6 +293,9 @@ QgsBrowserLayerProperties::QgsBrowserLayerProperties( QWidget* parent ) :
QgsBrowserPropertiesWidget( parent )
{
setupUi( this );

mUriLabel = new QgsBrowserPropertiesWrapLabel( "", this );
mHeaderGridLayout->addItem( new QWidgetItem( mUriLabel ), 1, 1 );
}

void QgsBrowserLayerProperties::setItem( QgsDataItem* item )
Expand Down Expand Up @@ -363,6 +391,9 @@ QgsBrowserDirectoryProperties::QgsBrowserDirectoryProperties( QWidget* parent )
, mDirectoryWidget( 0 )
{
setupUi( this );

mPathLabel = new QgsBrowserPropertiesWrapLabel( "", mHeaderWidget );
mHeaderGridLayout->addItem( new QWidgetItem( mPathLabel ), 0, 1 );
}

void QgsBrowserDirectoryProperties::setItem( QgsDataItem* item )
Expand Down
16 changes: 15 additions & 1 deletion src/app/qgsbrowserdockwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ class QgsLayerItem;
class QgsDataItem;
class QgsBrowserTreeFilterProxyModel;

// hack to show wrapped text without spaces
class QgsBrowserPropertiesWrapLabel : public QTextEdit
{
Q_OBJECT
public:
QgsBrowserPropertiesWrapLabel( const QString& text, QWidget* parent = 0 );

private slots:
void adjustHeight( const QSizeF& size );
};

class QgsBrowserPropertiesWidget : public QWidget
{
Q_OBJECT
Expand All @@ -44,8 +55,10 @@ class QgsBrowserLayerProperties : public QgsBrowserPropertiesWidget, private Ui:
Q_OBJECT
public:
QgsBrowserLayerProperties( QWidget* parent = 0 );

void setItem( QgsDataItem* item ) override;

private:
QgsBrowserPropertiesWrapLabel *mUriLabel;
};

class QgsBrowserDirectoryProperties : public QgsBrowserPropertiesWidget , private Ui::QgsBrowserDirectoryPropertiesBase
Expand All @@ -57,6 +70,7 @@ class QgsBrowserDirectoryProperties : public QgsBrowserPropertiesWidget , privat
void setItem( QgsDataItem* item ) override;
private:
QgsDirectoryParamWidget* mDirectoryWidget;
QgsBrowserPropertiesWrapLabel *mPathLabel;
};

class QgsBrowserPropertiesDialog : public QDialog , private Ui::QgsBrowserPropertiesDialogBase
Expand Down
54 changes: 26 additions & 28 deletions src/ui/qgsbrowserdirectorypropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,33 @@
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="mPathTitleLabel">
<property name="text">
<string>Path</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="mPathLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>path</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<widget class="QWidget" name="mHeaderWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="mHeaderGridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="mPathTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Path</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="mLayout"/>
Expand Down
59 changes: 35 additions & 24 deletions src/ui/qgsbrowserlayerpropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>284</height>
<height>703</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand All @@ -16,32 +16,33 @@
</property>
<item>
<widget class="QWidget" name="mHeaderWidget" native="true">
<layout class="QGridLayout" name="gridLayout">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="mHeaderGridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="mNameTitleLabel">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mUriTitleLabel">
<property name="text">
<string>URI</string>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mProviderTItleLabel">
<property name="text">
<string>Provider</string>
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="mNameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand All @@ -54,26 +55,36 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="mUriLabel">
<item row="1" column="0">
<widget class="QLabel" name="mUriTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>uri</string>
<string>URI</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mProviderTItleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Provider</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="mProviderLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down

0 comments on commit 4c2844e

Please sign in to comment.