Re: Some missing features of Gtk::TreeModelColumn
- From: Bob Caryl <bob fis-cal com>
- To: Kari Pahula <kari sammakko yok utu fi>
- Cc: gtkmm-list gnome org
- Subject: Re: Some missing features of Gtk::TreeModelColumn
- Date: Tue, 17 May 2005 11:39:27 -0500
Kari Pahula wrote:
I've been going through hoops since Gtk::TreeModelColumn is missing a
few methods, for which I see no really good reason to not be there.
class FooClass
{
public:
int bar;
};
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
Gtk::TreeModelColumn<int> a;
Gtk::TreeModelColumn<int> b;
Gtk::TreeModelColumn<FooClass *> c;
};
ModelColumns m_columns;
First off, you fail to provide a constructor for your ModelColumns class
that adds your Gtk::TreeModelColumns, ala
ModelColumns(){add(a); add(b); add(c);};
Perhaps you omitted this for clarity;
...
Gtk::TreeModel::Row row; // Set somewhere
std::ifstream foo("somefile");
foo >> row[m_columns.a]; // Fails.
I have to do something like this, for no good reason:
int tmp;
foo >> tmp;
row[m_columns.a] = tmp;
It seems to me that with a bit of work with templates this could be
made to work.
Another problem:
row[m_columns.a] = row[m_columns.b]; // Fails.
Once again, I have to work around this.
int tmp;
tmp = row[m_columns.b];
row[m_columns.a] = tmp;
Is there really any good reason to have the copy
constructor/operator=() private here?
One more annoyance:
row[m_columns.c]->bar = 5; // Fails.
Simple enough to work around with:
(*row[m_columns.c]).bar = 5;
But having operator->() in the first place would be polite.
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
In the case of the std::ifstream situation, this convenience does not
allow the __istream_type & operator>> to determine the data type in use
by the Gtk::TreeModelColumn in question (you must supply that data along
with the column number in a call to Gtk::TreeRow::set_value or
Gtk::TreeRow::get_value). Therefore, a direct assignation using the
Gtk::TreeRow::operator[] will fail since __istream_type & operator>>
supports only the following data types: bool, short, unsigned short,
int, unsigned int, long, unsigned long, float, double, long double,
void*, and streambuf_type*.
The Gtk::TreeRow::operator[], depending on its position relative to the
"=" operator, merely provides a convenient syntax for invoking the
Gtk::TreeRow::set_value and Gtk::TreeRow::get_value methods.
Furthermore, the values supplied to this operater must match the data
type used when initializing the Gtk::TreeModelColumn template member
used with the operator. These facts should amply explain why your
attempts at assigning one operator[] call to another won't work.
Personally, I find the implementation of the Gtk::TreeRow::operator[] to
be wonderfully convenient considering the alternative. You would be
much further along had the effort you expended criticizing the
Gtk::TreeRow class implementation been applied to your own project(s)
using the Gtk::TreeRow::operator[] as documented.
Bob Caryl
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]