[Clam-devel] ProcessingTree patch: if the processing box have an icon, show it on the tree

David García Garzón dgarcia at iua.upf.edu
Tue May 6 15:28:33 PDT 2008


On Tuesday 06 May 2008 17:01:23 Natanael Olaiz wrote:
> El 05/06/2008 05:52 AM, Pau Arumí Albó escribió:
> > El dt 06 de 05 del 2008 a les 05:00 -0300, en/na Natanael Olaiz va
> >
> > escriure:
> >> El 05/06/2008 04:22 AM, David García Garzón escribió:
> >>> Cool! Just a suggestion to improve the patch: reduce duplication.
> >>>
> >>> Call GetValueFromAttribute once and store it in a var. If it is empty
> >>> then assign it to "processing.png". Then call setIcon once.
> >>
> >> Like this? (If I don't get first all the values I get a segmentation
> >> fault...)
> >> Is not simpler to read in the other way?
> >
> > I found it slightly better the second way.
> >
> > Commit 11350. Thanks!
> > Natanael, you'll have to revert your changes since i made minor var
> > renaming on your patch. (Ups, i have to remember to commit "as is" and
> > then modify. This should avoid conflicts with the patch owner)
> > BTW, tabs are ok this time.
> >
> > Every (interface) new feature, a new picture (Natanael, make yourself
> > the honors next time)
> > http://iua-share.upf.edu/wikis/clam/index.php/Image:ProcessingTreeWithIco
> >ns.png
>
> Sorry about that. I just didn't though it as a commitable change. :)

If you can show something, even if not commited, even if it is a fake, take a 
photo ;-)

> > A simple yet great usability feature. As a side effect i foresee that
> > people will add more icons now :-)
>
> BTW, the Tunner monitor points to "tunner.svg" and SpectrogramMonitor to
> "none.svg", both which doesn't exist.

I added a very simple icon for the tunner based on the polarpeaks and i just 
made the spectrogram point to spectrogram.svg which already existed.

Missing metadata for some monitors was also added.

You are adding really a quick and cool features, Natanael. :-)

What i tried to tell you in my previous mail is that the code would be cleaner 
if you decide first which is the icon name for the processing (processing.svg 
or something from the factory) and then building the full path, the icon and 
setting the icon once. You almost got the idea but this patch i just commited 
shows the difference:

--- src/ProcessingTree.cxx      (revisión: 11351)
+++ src/ProcessingTree.cxx      (copia de trabajo)
@@ -204,16 +204,10 @@
                        std::string key = *itKey;
                        QTreeWidgetItem * item = new QTreeWidgetItem( 
categoryTree, QStringList() << description.c_str());

-                       CLAM::ProcessingFactory::Values 
anIconMaybe=factory.GetValuesFromAttribute(key,"icon");
-                       QIcon icon;
-                       if (anIconMaybe.empty())
-                               icon = QIcon(":/icons/images/processing.png");
-                       else
-                       {
-                               std::string iconPath = anIconMaybe.front();
-                               icon = 
QIcon(QString(":/icons/images/%1").arg(iconPath.c_str()));
-                       }
-                       item->setIcon(0, icon);
+                       CLAM::ProcessingFactory::Values 
iconList=factory.GetValuesFromAttribute(key,"icon");
+                       std::string iconPath = "processing.png";
+                       if (! iconList.empty()) iconPath = iconList.front();
+                       item->setIcon(0, 
QIcon(QString(":/icons/images/%1").arg(iconPath.c_str())));

                        item->setText(1, key.c_str());
                }








More information about the clam-devel mailing list