mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Dive sites: add fulltext filter
In the dive site tab, add a fulltext filter. The UI is only a mock up. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									9afea37e15
								
							
						
					
					
						commit
						22fe0c14e8
					
				
					 5 changed files with 34 additions and 7 deletions
				
			
		| 
						 | 
					@ -74,3 +74,8 @@ void TabDiveSite::on_purgeUnused_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Command::purgeUnusedDiveSites();
 | 
						Command::purgeUnusedDiveSites();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TabDiveSite::on_filterText_textChanged(const QString &text)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						model.setFilter(text);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,7 @@ private slots:
 | 
				
			||||||
	void diveSiteAdded(struct dive_site *, int idx);
 | 
						void diveSiteAdded(struct dive_site *, int idx);
 | 
				
			||||||
	void diveSiteChanged(struct dive_site *ds, int field);
 | 
						void diveSiteChanged(struct dive_site *ds, int field);
 | 
				
			||||||
	void on_purgeUnused_clicked();
 | 
						void on_purgeUnused_clicked();
 | 
				
			||||||
 | 
						void on_filterText_textChanged(const QString &text);
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	Ui::TabDiveSite ui;
 | 
						Ui::TabDiveSite ui;
 | 
				
			||||||
	DiveSiteSortedModel model;
 | 
						DiveSiteSortedModel model;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,11 +15,18 @@
 | 
				
			||||||
  </property>
 | 
					  </property>
 | 
				
			||||||
  <layout class="QVBoxLayout" name="verticalLayout">
 | 
					  <layout class="QVBoxLayout" name="verticalLayout">
 | 
				
			||||||
   <item>
 | 
					   <item>
 | 
				
			||||||
    <widget class="QToolButton" name="purgeUnused">
 | 
					    <layout class="QHBoxLayout" name="layout">
 | 
				
			||||||
     <property name="text">
 | 
					     <item>
 | 
				
			||||||
      <string>Purge unused dive sites</string>
 | 
					      <widget class="QToolButton" name="purgeUnused">
 | 
				
			||||||
     </property>
 | 
					       <property name="text">
 | 
				
			||||||
    </widget>
 | 
					        <string>Purge unused dive sites</string>
 | 
				
			||||||
 | 
					       </property>
 | 
				
			||||||
 | 
					      </widget>
 | 
				
			||||||
 | 
					     </item>
 | 
				
			||||||
 | 
					     <item>
 | 
				
			||||||
 | 
					      <widget class="QLineEdit" name="filterText"/>
 | 
				
			||||||
 | 
					     </item>
 | 
				
			||||||
 | 
					    </layout>
 | 
				
			||||||
   </item>
 | 
					   </item>
 | 
				
			||||||
   <item>
 | 
					   <item>
 | 
				
			||||||
    <widget class="TableView" name="diveSites" native="true"/>
 | 
					    <widget class="TableView" name="diveSites" native="true"/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -178,8 +178,14 @@ void LocationInformationModel::diveSiteDivesChanged(struct dive_site *ds)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool DiveSiteSortedModel::filterAcceptsRow(int sourceRow, const QModelIndex &source_parent) const
 | 
					bool DiveSiteSortedModel::filterAcceptsRow(int sourceRow, const QModelIndex &source_parent) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// TODO: filtering
 | 
						if (fullText.isEmpty())
 | 
				
			||||||
	return true;
 | 
							return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (sourceRow < 0 || sourceRow > dive_site_table.nr)
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						struct dive_site *ds = dive_site_table.dive_sites[sourceRow];
 | 
				
			||||||
 | 
						QString text = QString(ds->name) + QString(ds->description) + QString(ds->notes);
 | 
				
			||||||
 | 
						return text.contains(fullText, Qt::CaseInsensitive);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool DiveSiteSortedModel::lessThan(const QModelIndex &i1, const QModelIndex &i2) const
 | 
					bool DiveSiteSortedModel::lessThan(const QModelIndex &i1, const QModelIndex &i2) const
 | 
				
			||||||
| 
						 | 
					@ -272,6 +278,12 @@ void DiveSiteSortedModel::remove(const QModelIndex &index)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif // SUBSURFACE_MOBILE
 | 
					#endif // SUBSURFACE_MOBILE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DiveSiteSortedModel::setFilter(const QString &text)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						fullText = text.trimmed();
 | 
				
			||||||
 | 
						invalidateFilter();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GeoReferencingOptionsModel *GeoReferencingOptionsModel::instance()
 | 
					GeoReferencingOptionsModel *GeoReferencingOptionsModel::instance()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static GeoReferencingOptionsModel *self = new GeoReferencingOptionsModel();
 | 
						static GeoReferencingOptionsModel *self = new GeoReferencingOptionsModel();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,6 +44,7 @@ private:
 | 
				
			||||||
	struct dive_site *getDiveSite(const QModelIndex &idx);
 | 
						struct dive_site *getDiveSite(const QModelIndex &idx);
 | 
				
			||||||
	bool filterAcceptsRow(int sourceRow, const QModelIndex &source_parent) const override;
 | 
						bool filterAcceptsRow(int sourceRow, const QModelIndex &source_parent) const override;
 | 
				
			||||||
	bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const override;
 | 
						bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const override;
 | 
				
			||||||
 | 
						QString fullText;
 | 
				
			||||||
#ifndef SUBSURFACE_MOBILE
 | 
					#ifndef SUBSURFACE_MOBILE
 | 
				
			||||||
	bool setData(const QModelIndex &index, const QVariant &value, int role) override;
 | 
						bool setData(const QModelIndex &index, const QVariant &value, int role) override;
 | 
				
			||||||
public slots:
 | 
					public slots:
 | 
				
			||||||
| 
						 | 
					@ -52,6 +53,7 @@ public slots:
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	DiveSiteSortedModel();
 | 
						DiveSiteSortedModel();
 | 
				
			||||||
	QStringList allSiteNames() const;
 | 
						QStringList allSiteNames() const;
 | 
				
			||||||
 | 
						void setFilter(const QString &text);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// To access only divesites at the given GPS coordinates with the exception of a given dive site
 | 
					// To access only divesites at the given GPS coordinates with the exception of a given dive site
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue