Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Create QgsHistoryWidget resuable widget for showing history entries
  • Loading branch information
nyalldawson committed Apr 22, 2023
1 parent a71671c commit 34ce4d7
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/gui/gui_auto.sip
Expand Up @@ -346,6 +346,7 @@
%Include auto_generated/history/qgshistoryentrynode.sip
%Include auto_generated/history/qgshistoryprovider.sip
%Include auto_generated/history/qgshistoryproviderregistry.sip
%Include auto_generated/history/qgshistorywidget.sip
%Include auto_generated/labeling/qgslabellineanchorwidget.sip
%Include auto_generated/labeling/qgslabelobstaclesettingswidget.sip
%Include auto_generated/labeling/qgslabelsettingswidgetbase.sip
Expand Down
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Expand Up @@ -241,6 +241,7 @@ set(QGIS_GUI_SRCS
history/qgshistoryentrynode.cpp
history/qgshistoryprovider.cpp
history/qgshistoryproviderregistry.cpp
history/qgshistorywidget.cpp

labeling/qgslabelengineconfigdialog.cpp
labeling/qgslabelinggui.cpp
Expand Down Expand Up @@ -1150,6 +1151,7 @@ set(QGIS_GUI_HDRS
history/qgshistoryentrynode.h
history/qgshistoryprovider.h
history/qgshistoryproviderregistry.h
history/qgshistorywidget.h

labeling/qgslabelengineconfigdialog.h
labeling/qgslabelinggui.h
Expand Down
28 changes: 28 additions & 0 deletions src/gui/history/qgshistorywidget.cpp
@@ -0,0 +1,28 @@
/***************************************************************************
qgshistorywidget.cpp
------------------
Date : April 2023
Copyright : (C) 2023 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgshistorywidget.h"
#include "qgsgui.h"
#include "qgshistoryentrymodel.h"

QgsHistoryWidget::QgsHistoryWidget( const QString &providerId, Qgis::HistoryProviderBackends backends, QgsHistoryProviderRegistry *registry, QWidget *parent )
: QgsPanelWidget( parent )
{
setupUi( this );

mModel = new QgsHistoryEntryModel( providerId, backends, registry, this );
mTreeView->setModel( mModel );

}
60 changes: 60 additions & 0 deletions src/gui/history/qgshistorywidget.h
@@ -0,0 +1,60 @@
/***************************************************************************
qgshistorywidget.h
------------------
Date : April 2023
Copyright : (C) 2023 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSHISTORYWIDGET_H
#define QGSHISTORYWIDGET_H

#include "qgis.h"
#include "qgis_gui.h"
#include "ui_qgshistorywidgetbase.h"
#include "qgspanelwidget.h"

class QgsHistoryProviderRegistry;
class QgsHistoryEntryModel;

/**
* A widget showing entries from a QgsHistoryProviderRegistry.
* \ingroup gui
* \since QGIS 3.32
*/
class GUI_EXPORT QgsHistoryWidget : public QgsPanelWidget, private Ui::QgsHistoryWidgetBase
{
Q_OBJECT

public:

/**
* Constructor for QgsHistoryWidget, with the specified \a parent widget.
*
* If \a providerId is specified then the widget will contain only items from the matching
* history provider.
* If \a backends is specified then the widget will be filtered to only matching backends.
*
* If no \a registry is specified then the singleton QgsHistoryProviderRegistry from QgsGui::historyProviderRegistry()
* will be used.
*/
QgsHistoryWidget( const QString &providerId = QString(),
Qgis::HistoryProviderBackends backends = Qgis::HistoryProviderBackend::LocalProfile,
QgsHistoryProviderRegistry *registry = nullptr,
QWidget *parent = nullptr );


private:

QgsHistoryEntryModel *mModel = nullptr;

};

#endif // QGSHISTORYWIDGET_H
52 changes: 52 additions & 0 deletions src/ui/qgshistorywidgetbase.ui
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsHistoryWidgetBase</class>
<widget class="QgsPanelWidget" name="QgsHistoryWidgetBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>500</height>
</rect>
</property>
<property name="windowTitle">
<string>History</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="margin" stdset="0">
<number>9</number>
</property>
<item>
<widget class="QSplitter" name="mSplitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QTreeView" name="mTreeView">
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
</widget>
<widget class="QWidget" name="mEntryContainerWidget" native="true"/>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

0 comments on commit 34ce4d7

Please sign in to comment.