[PATCH] Qt: Implement trip merging logic

Thiago Macieira thiago at macieira.org
Wed Jun 26 22:54:31 PDT 2013


On quarta-feira, 26 de junho de 2013 19.22.11, Linus Torvalds wrote:
> So stupid C++/Qt question: I'd really like to make the "merge_trip()" 
> helper function to be static, do I really have to declare it at all? Is 
> there some way to avoid having to mention it as a private function in the 
> header file? I hate having to list these private helpers.

If you make it a member function, it needs to be mentioned in the header.

You can make it a file-static function in the .cpp, but then you won't have 
access to the privates directly.

> +void DiveListView::merge_trip(const QModelIndex &a, int offset)

static void merge_trip(DiveListView *view, const QModelIndex &a, int offset)

> +       reload(currentLayout, false);

Here you use two members: the public reload() function and the private 
currentLayout.

I'd change this line to:
	view->reload();

And I'd add a new public member to the header:
	inline reload() { reload(currentLayout, false); }


Or make the static function return a boolean whether reloading is needed (that 
is, if there was any merging). Then:

> +void DiveListView::mergeTripAbove()
> +{
> +       merge_trip(contextMenuIndex, -1);
> +}

	if (merge_trip(this, contextMenuIndex, -1))
		reload(currentLayout, false);

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130626/7fa41787/attachment.sig>


More information about the subsurface mailing list