projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
AnalogSignal: Split up divs during autoranging if needed
[pulseview.git]
/
pv
/
prop
/
string.cpp
diff --git
a/pv/prop/string.cpp
b/pv/prop/string.cpp
index b8f3351cf8fb2acbc160a7bcd41bfb529443ddd3..1cba8e4a7c2341103be17cfe7b2d214ad2aecaf7 100644
(file)
--- a/
pv/prop/string.cpp
+++ b/
pv/prop/string.cpp
@@
-14,18
+14,19
@@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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 <assert.h>
+#include <QLineEdit>
#include <QSpinBox>
#include <QSpinBox>
-#include "string.h"
+#include "string.h
pp
"
-using namespace std;
-using namespace boost;
+using std::string;
+
+using Glib::ustring;
namespace pv {
namespace prop {
namespace pv {
namespace prop {
@@
-34,40
+35,44
@@
String::String(QString name,
Getter getter,
Setter setter) :
Property(name, getter, setter),
Getter getter,
Setter setter) :
Property(name, getter, setter),
-
_line_edit(NULL
)
+
line_edit_(nullptr
)
{
}
QWidget* String::get_widget(QWidget *parent, bool auto_commit)
{
{
}
QWidget* String::get_widget(QWidget *parent, bool auto_commit)
{
- if (_line_edit)
- return _line_edit;
+ if (line_edit_)
+ return line_edit_;
+
+ if (!getter_)
+ return nullptr;
+
+ Glib::VariantBase variant = getter_();
+ if (!variant.gobj())
+ return nullptr;
- _line_edit = new QLineEdit(parent);
+ string value = Glib::VariantBase::cast_dynamic<Glib::Variant<ustring>>(
+ variant).get();
- GVariant *const value = _getter ? _getter() : NULL;
- if (value) {
- _line_edit->setText(QString(
- g_variant_get_string(value, NULL)));
- g_variant_unref(value);
- }
+ line_edit_ = new QLineEdit(parent);
+ line_edit_->setText(QString::fromStdString(value));
if (auto_commit)
if (auto_commit)
- connect(
_line_edit
, SIGNAL(textEdited(const QString&)),
+ connect(
line_edit_
, SIGNAL(textEdited(const QString&)),
this, SLOT(on_text_edited(const QString&)));
this, SLOT(on_text_edited(const QString&)));
- return
_line_edit
;
+ return
line_edit_
;
}
void String::commit()
{
}
void String::commit()
{
- assert(
_setter
);
+ assert(
setter_
);
- if (!
_line_edit
)
+ if (!
line_edit_
)
return;
return;
- QByteArray ba =
_line_edit
->text().toLocal8Bit();
-
_setter(g_variant_new_string
(ba.data()));
+ QByteArray ba =
line_edit_
->text().toLocal8Bit();
+
setter_(Glib::Variant<ustring>::create
(ba.data()));
}
void String::on_text_edited(const QString&)
}
void String::on_text_edited(const QString&)