Skip to content
Permalink
Browse files

browser properties path/uri without spaces wrap

  • Loading branch information
blazek committed Apr 29, 2015
1 parent 4645dd7 commit 4c2844e723f285f2f6b55632c0fac30250a5afe4
@@ -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"
@@ -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 )
{
@@ -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 )
@@ -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 )
@@ -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
@@ -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
@@ -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
@@ -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"/>
@@ -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">
@@ -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>
@@ -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>

0 comments on commit 4c2844e

Please sign in to comment.
You can’t perform that action at this time.