]> sigrok.org Git - pulseview.git/blobdiff - pv/prop/enum.cpp
Build fixes for Qt5 Windows/mingw/MXE support.
[pulseview.git] / pv / prop / enum.cpp
index 03524344048d5ca27e4a06b3a7f72f3f17e18fd6..a4c542af55fb9f05caaccd5043b0d7b098bbdaf2 100644 (file)
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <assert.h>
 
 #include <QComboBox>
 
-#include "enum.h"
+#include "enum.hpp"
 
 using std::pair;
 using std::vector;
@@ -34,54 +33,50 @@ Enum::Enum(QString name,
        vector<pair<Glib::VariantBase, QString> > values,
        Getter getter, Setter setter) :
        Property(name, getter, setter),
-       _values(values),
-       _selector(NULL)
-{
-}
-
-Enum::~Enum()
+       values_(values),
+       selector_(nullptr)
 {
 }
 
 QWidget* Enum::get_widget(QWidget *parent, bool auto_commit)
 {
-       if (_selector)
-               return _selector;
+       if (selector_)
+               return selector_;
 
-       if (!_getter)
-               return NULL;
+       if (!getter_)
+               return nullptr;
 
-       Glib::VariantBase variant = _getter();
+       Glib::VariantBase variant = getter_();
        if (!variant.gobj())
-               return NULL;
+               return nullptr;
 
-       _selector = new QComboBox(parent);
-       for (unsigned int i = 0; i < _values.size(); i++) {
-               const pair<Glib::VariantBase, QString> &v = _values[i];
-               _selector->addItem(v.second, qVariantFromValue(v.first));
+       selector_ = new QComboBox(parent);
+       for (unsigned int i = 0; i < values_.size(); i++) {
+               const pair<Glib::VariantBase, QString> &v = values_[i];
+               selector_->addItem(v.second, qVariantFromValue(v.first));
                if (v.first.equal(variant))
-                       _selector->setCurrentIndex(i);
+                       selector_->setCurrentIndex(i);
        }
 
        if (auto_commit)
-               connect(_selector, SIGNAL(currentIndexChanged(int)),
+               connect(selector_, SIGNAL(currentIndexChanged(int)),
                        this, SLOT(on_current_item_changed(int)));
 
-       return _selector;
+       return selector_;
 }
 
 void Enum::commit()
 {
-       assert(_setter);
+       assert(setter_);
 
-       if (!_selector)
+       if (!selector_)
                return;
 
-       const int index = _selector->currentIndex();
+       const int index = selector_->currentIndex();
        if (index < 0)
                return;
 
-       _setter(_selector->itemData(index).value<Glib::VariantBase>());
+       setter_(selector_->itemData(index).value<Glib::VariantBase>());
 }
 
 void Enum::on_current_item_changed(int)