mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:40:06 +00:00 
			
		
		
		
	Added a basic location marker manager.
This commit is contained in:
		
							parent
							
								
									84233868d6
								
							
						
					
					
						commit
						19415cd0a1
					
				
					 16 changed files with 806 additions and 44 deletions
				
			
		
							
								
								
									
										45
									
								
								scwx-qt/source/scwx/qt/ui/marker_dialog.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								scwx-qt/source/scwx/qt/ui/marker_dialog.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,45 @@ | |||
| #include "marker_dialog.hpp" | ||||
| #include "ui_marker_dialog.h" | ||||
| 
 | ||||
| #include <scwx/qt/ui/marker_settings_widget.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace ui | ||||
| { | ||||
| 
 | ||||
| static const std::string logPrefix_ = "scwx::qt::ui::marker_dialog"; | ||||
| static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||
| 
 | ||||
| class MarkerDialogImpl | ||||
| { | ||||
| public: | ||||
|    explicit MarkerDialogImpl() {} | ||||
|    ~MarkerDialogImpl() = default; | ||||
| 
 | ||||
|    MarkerSettingsWidget* markerSettingsWidget_ {nullptr}; | ||||
| }; | ||||
| 
 | ||||
| MarkerDialog::MarkerDialog(QWidget* parent) : | ||||
|     QDialog(parent), | ||||
|     p {std::make_unique<MarkerDialogImpl>()}, | ||||
|     ui(new Ui::MarkerDialog) | ||||
| { | ||||
|    ui->setupUi(this); | ||||
| 
 | ||||
|    p->markerSettingsWidget_ = new MarkerSettingsWidget(this); | ||||
|    p->markerSettingsWidget_->layout()->setContentsMargins(0, 0, 0, 0); | ||||
|    ui->contentsFrame->layout()->addWidget(p->markerSettingsWidget_); | ||||
| } | ||||
| 
 | ||||
| MarkerDialog::~MarkerDialog() | ||||
| { | ||||
|    delete ui; | ||||
| } | ||||
| 
 | ||||
| } // namespace ui
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
							
								
								
									
										35
									
								
								scwx-qt/source/scwx/qt/ui/marker_dialog.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								scwx-qt/source/scwx/qt/ui/marker_dialog.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <QDialog> | ||||
| 
 | ||||
| namespace Ui | ||||
| { | ||||
| class MarkerDialog; | ||||
| } | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace ui | ||||
| { | ||||
| 
 | ||||
| class MarkerDialogImpl; | ||||
| 
 | ||||
| class MarkerDialog : public QDialog | ||||
| { | ||||
|    Q_OBJECT | ||||
| 
 | ||||
| public: | ||||
|    explicit MarkerDialog(QWidget* parent = nullptr); | ||||
|    ~MarkerDialog(); | ||||
| 
 | ||||
| private: | ||||
|    friend class MarkerDialogImpl; | ||||
|    std::unique_ptr<MarkerDialogImpl> p; | ||||
|    Ui::MarkerDialog*                 ui; | ||||
| }; | ||||
| 
 | ||||
| } // namespace ui
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
							
								
								
									
										88
									
								
								scwx-qt/source/scwx/qt/ui/marker_dialog.ui
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								scwx-qt/source/scwx/qt/ui/marker_dialog.ui
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,88 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <ui version="4.0"> | ||||
|  <class>MarkerDialog</class> | ||||
|  <widget class="QDialog" name="MarkerDialog"> | ||||
|   <property name="geometry"> | ||||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>700</width> | ||||
|     <height>600</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="windowTitle"> | ||||
|    <string>Marker Manager</string> | ||||
|   </property> | ||||
|   <layout class="QVBoxLayout" name="verticalLayout"> | ||||
|    <item> | ||||
|     <widget class="QFrame" name="contentsFrame"> | ||||
|      <property name="frameShape"> | ||||
|       <enum>QFrame::StyledPanel</enum> | ||||
|      </property> | ||||
|      <property name="frameShadow"> | ||||
|       <enum>QFrame::Raised</enum> | ||||
|      </property> | ||||
|      <layout class="QVBoxLayout" name="verticalLayout_2"> | ||||
|       <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> | ||||
|      </layout> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QDialogButtonBox" name="buttonBox"> | ||||
|      <property name="orientation"> | ||||
|       <enum>Qt::Horizontal</enum> | ||||
|      </property> | ||||
|      <property name="standardButtons"> | ||||
|       <set>QDialogButtonBox::Close</set> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|   </layout> | ||||
|  </widget> | ||||
|  <resources/> | ||||
|  <connections> | ||||
|   <connection> | ||||
|    <sender>buttonBox</sender> | ||||
|    <signal>accepted()</signal> | ||||
|    <receiver>MarkerDialog</receiver> | ||||
|    <slot>accept()</slot> | ||||
|    <hints> | ||||
|     <hint type="sourcelabel"> | ||||
|      <x>248</x> | ||||
|      <y>254</y> | ||||
|     </hint> | ||||
|     <hint type="destinationlabel"> | ||||
|      <x>157</x> | ||||
|      <y>274</y> | ||||
|     </hint> | ||||
|    </hints> | ||||
|   </connection> | ||||
|   <connection> | ||||
|    <sender>buttonBox</sender> | ||||
|    <signal>rejected()</signal> | ||||
|    <receiver>MarkerDialog</receiver> | ||||
|    <slot>reject()</slot> | ||||
|    <hints> | ||||
|     <hint type="sourcelabel"> | ||||
|      <x>316</x> | ||||
|      <y>260</y> | ||||
|     </hint> | ||||
|     <hint type="destinationlabel"> | ||||
|      <x>286</x> | ||||
|      <y>274</y> | ||||
|     </hint> | ||||
|    </hints> | ||||
|   </connection> | ||||
|  </connections> | ||||
| </ui> | ||||
							
								
								
									
										105
									
								
								scwx-qt/source/scwx/qt/ui/marker_settings_widget.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								scwx-qt/source/scwx/qt/ui/marker_settings_widget.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,105 @@ | |||
| #include "marker_settings_widget.hpp" | ||||
| #include "ui_marker_settings_widget.h" | ||||
| 
 | ||||
| #include <scwx/qt/manager/marker_manager.hpp> | ||||
| #include <scwx/qt/model/marker_model.hpp> | ||||
| #include <scwx/qt/types/qt_types.hpp> | ||||
| #include <scwx/qt/ui/open_url_dialog.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
| 
 | ||||
| #include <QSortFilterProxyModel> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace ui | ||||
| { | ||||
| 
 | ||||
| static const std::string logPrefix_ = "scwx::qt::ui::marker_settings_widget"; | ||||
| static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||
| 
 | ||||
| class MarkerSettingsWidgetImpl | ||||
| { | ||||
| public: | ||||
|    explicit MarkerSettingsWidgetImpl(MarkerSettingsWidget* self) : | ||||
|       self_ {self}, | ||||
|       markerModel_ {new model::MarkerModel(self_)} | ||||
|    { | ||||
|    } | ||||
| 
 | ||||
|    void ConnectSignals(); | ||||
| 
 | ||||
|    MarkerSettingsWidget* self_; | ||||
|    model::MarkerModel* markerModel_; | ||||
|    std::shared_ptr<manager::MarkerManager> markerManager_ { | ||||
|       manager::MarkerManager::Instance()}; | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| MarkerSettingsWidget::MarkerSettingsWidget(QWidget* parent) : | ||||
|     QFrame(parent), | ||||
|     p {std::make_unique<MarkerSettingsWidgetImpl>(this)}, | ||||
|     ui(new Ui::MarkerSettingsWidget) | ||||
| { | ||||
|    ui->setupUi(this); | ||||
| 
 | ||||
|    ui->removeButton->setEnabled(false); | ||||
| 
 | ||||
|    ui->markerView->setModel(p->markerModel_); | ||||
| 
 | ||||
|    p->ConnectSignals(); | ||||
| } | ||||
| 
 | ||||
| MarkerSettingsWidget::~MarkerSettingsWidget() | ||||
| { | ||||
|    delete ui; | ||||
| } | ||||
| 
 | ||||
| void MarkerSettingsWidgetImpl::ConnectSignals() | ||||
| { | ||||
|    QObject::connect(self_->ui->addButton, | ||||
|                     &QPushButton::clicked, | ||||
|                     self_, | ||||
|                     [this]() | ||||
|                     { | ||||
|                        markerManager_->add_marker(types::MarkerInfo("", 0, 0)); | ||||
|                     }); | ||||
|    QObject::connect(self_->ui->removeButton, | ||||
|                     &QPushButton::clicked, | ||||
|                     self_, | ||||
|                     [this]() | ||||
|                     { | ||||
|                        auto selectionModel = | ||||
|                           self_->ui->markerView->selectionModel(); | ||||
|                        QModelIndex selected = | ||||
|                           selectionModel | ||||
|                              ->selectedRows(static_cast<int>( | ||||
|                                 model::MarkerModel::Column::Name)) | ||||
|                              .first(); | ||||
| 
 | ||||
|                        markerManager_->remove_marker(selected.row()); | ||||
|                     }); | ||||
|    QObject::connect( | ||||
|       self_->ui->markerView->selectionModel(), | ||||
|       &QItemSelectionModel::selectionChanged, | ||||
|       self_, | ||||
|       [this](const QItemSelection& selected, const QItemSelection& deselected) | ||||
|       { | ||||
|          if (selected.size() == 0 && deselected.size() == 0) | ||||
|          { | ||||
|             // Items which stay selected but change their index are not
 | ||||
|             // included in selected and deselected. Thus, this signal might
 | ||||
|             // be emitted with both selected and deselected empty, if only
 | ||||
|             // the indices of selected items change.
 | ||||
|             return; | ||||
|          } | ||||
| 
 | ||||
|          bool itemSelected = selected.size() > 0; | ||||
|          self_->ui->removeButton->setEnabled(itemSelected); | ||||
|       }); | ||||
| } | ||||
| 
 | ||||
| } // namespace ui
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
							
								
								
									
										35
									
								
								scwx-qt/source/scwx/qt/ui/marker_settings_widget.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								scwx-qt/source/scwx/qt/ui/marker_settings_widget.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <QFrame> | ||||
| 
 | ||||
| namespace Ui | ||||
| { | ||||
| class MarkerSettingsWidget; | ||||
| } | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace ui | ||||
| { | ||||
| 
 | ||||
| class MarkerSettingsWidgetImpl; | ||||
| 
 | ||||
| class MarkerSettingsWidget : public QFrame | ||||
| { | ||||
|    Q_OBJECT | ||||
| 
 | ||||
| public: | ||||
|    explicit MarkerSettingsWidget(QWidget* parent = nullptr); | ||||
|    ~MarkerSettingsWidget(); | ||||
| 
 | ||||
| private: | ||||
|    friend class MarkerSettingsWidgetImpl; | ||||
|    std::unique_ptr<MarkerSettingsWidgetImpl> p; | ||||
|    Ui::MarkerSettingsWidget*                 ui; | ||||
| }; | ||||
| 
 | ||||
| } // namespace ui
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
							
								
								
									
										88
									
								
								scwx-qt/source/scwx/qt/ui/marker_settings_widget.ui
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								scwx-qt/source/scwx/qt/ui/marker_settings_widget.ui
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,88 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <ui version="4.0"> | ||||
|  <class>MarkerSettingsWidget</class> | ||||
|  <widget class="QFrame" name="MarkerSettingsWidget"> | ||||
|   <property name="geometry"> | ||||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>400</width> | ||||
|     <height>300</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="windowTitle"> | ||||
|    <string>Frame</string> | ||||
|   </property> | ||||
|   <layout class="QVBoxLayout" name="verticalLayout"> | ||||
|    <item> | ||||
|     <widget class="QTreeView" name="markerView"> | ||||
|      <property name="alternatingRowColors"> | ||||
|       <bool>true</bool> | ||||
|      </property> | ||||
|      <property name="indentation"> | ||||
|       <number>0</number> | ||||
|      </property> | ||||
|      <property name="sortingEnabled"> | ||||
|       <bool>true</bool> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QFrame" name="buttonFrame"> | ||||
|      <property name="frameShape"> | ||||
|       <enum>QFrame::Shape::StyledPanel</enum> | ||||
|      </property> | ||||
|      <property name="frameShadow"> | ||||
|       <enum>QFrame::Shadow::Raised</enum> | ||||
|      </property> | ||||
|      <layout class="QHBoxLayout" name="horizontalLayout_2"> | ||||
|       <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> | ||||
|       <item> | ||||
|        <spacer name="horizontalSpacer"> | ||||
|         <property name="orientation"> | ||||
|          <enum>Qt::Orientation::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"> | ||||
|          <string>&Add</string> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item> | ||||
|        <widget class="QPushButton" name="removeButton"> | ||||
|         <property name="enabled"> | ||||
|          <bool>false</bool> | ||||
|         </property> | ||||
|         <property name="text"> | ||||
|          <string>R&emove</string> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|      </layout> | ||||
|     </widget> | ||||
|    </item> | ||||
|   </layout> | ||||
|  </widget> | ||||
|  <resources/> | ||||
|  <connections/> | ||||
| </ui> | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 AdenKoperczak
						AdenKoperczak