* 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 <cassert>
#include <QLineEdit>
#include <QSpinBox>
namespace prop {
String::String(QString name,
+ QString desc,
Getter getter,
Setter setter) :
- Property(name, getter, setter),
- line_edit_(NULL)
+ Property(name, desc, getter, setter),
+ line_edit_(nullptr)
{
}
return line_edit_;
if (!getter_)
- return NULL;
+ return nullptr;
Glib::VariantBase variant = getter_();
if (!variant.gobj())
- return NULL;
-
- string value = Glib::VariantBase::cast_dynamic<Glib::Variant<ustring>>(
- variant).get();
+ return nullptr;
line_edit_ = new QLineEdit(parent);
- line_edit_->setText(QString::fromStdString(value));
+
+ update_widget();
if (auto_commit)
connect(line_edit_, SIGNAL(textEdited(const QString&)),
return line_edit_;
}
+void String::update_widget()
+{
+ if (!line_edit_)
+ return;
+
+ Glib::VariantBase variant = getter_();
+ assert(variant.gobj());
+
+ string value = Glib::VariantBase::cast_dynamic<Glib::Variant<ustring>>(
+ variant).get();
+
+ line_edit_->setText(QString::fromStdString(value));
+}
+
void String::commit()
{
assert(setter_);
commit();
}
-} // prop
-} // pv
+} // namespace prop
+} // namespace pv