OSDN Git Service

Change idx sub dir's time stamp when saving idx.
[fukui-no-namari/dialektos.git] / src / board_view_column.cxx
1 /*
2  * Copyright (C) 2009 by Aiwota Programmer
3  * aiwotaprog@tetteke.tk
4  *
5  * This file is part of Dialektos.
6  *
7  * Dialektos is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * Dialektos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Dialektos.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include "board_view_column.hxx"
22
23 #include <sigc++/functors/mem_fun.h>
24 #include <glibmm/ustring.h>
25 #include <gtkmm/cellrenderer.h>
26 #include <gtkmm/treeviewcolumn.h>
27 #include <gtkmm/treemodel.h>
28
29 #include <boost/date_time/posix_time/posix_time.hpp>
30 #include <boost/lexical_cast.hpp>
31 #include <boost/mpl/find.hpp>
32
33 #include "thread_list_model.hxx"
34
35
36 namespace dialektos {
37
38 namespace view_column {
39
40
41 Base::Base(const Glib::ustring& title) :
42       Gtk::TreeViewColumn(title) {
43   set_min_width(15);
44   set_reorderable(true);
45   set_resizable(true);
46   set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED);
47   set_clickable(true);
48 //    set_fixed_width(30); // specify in a derived class.
49
50   Gtk::CellRendererText* cell = Gtk::manage(new Gtk::CellRendererText);
51   pack_start(*cell, true);
52   set_cell_data_func(*cell,
53       sigc::mem_fun(*this, &Base::on_cell_data));
54 }
55
56 Base::~Base() {}
57 void Base::on_cell_data(Gtk::CellRenderer* cell,
58     const Gtk::TreeModel::iterator& iter) {
59   do_cell_data(cell, iter);
60 }
61
62 StartTime::StartTime() : Base("Since") {
63   set_fixed_width(50);
64 }
65 StartTime::~StartTime() {}
66
67 void StartTime::do_cell_data(Gtk::CellRenderer* cell,
68     const Gtk::TreeModel::iterator& iter) {
69
70   model_column::ID::type value;
71   iter->get_value(boost::mpl::find<ModelColumns::type,
72       model_column::ID>::type::pos::value, value);
73
74   try {
75     std::time_t t = boost::lexical_cast<std::time_t>(value);
76     boost::posix_time::ptime ptime = boost::posix_time::from_time_t(t);
77     boost::posix_time::time_facet* facet =
78       new boost::posix_time::time_facet("%Y/%m/%d %H:%M:%S");
79     std::stringstream ss;
80     ss.imbue(std::locale(ss.getloc(), facet));
81     ss << ptime;
82     value = ss.str();
83   } catch (const std::exception& /*e*/) {
84     value = "";
85   }
86
87   cell->set_property("text", value);
88 }
89
90
91 Average::Average() : Base("Average") {
92   set_fixed_width(50);
93 }
94 Average::~Average() {}
95
96 void Average::do_cell_data(Gtk::CellRenderer* cell,
97     const Gtk::TreeModel::iterator& iter) {
98   on_cell_data_int<model_column::Average>(cell, iter);
99 }
100
101
102 Title::Title() : Base("Title") {
103   set_fixed_width(200);
104 }
105 Title::~Title() {}
106 void Title::do_cell_data(Gtk::CellRenderer* cell,
107     const Gtk::TreeModel::iterator& iter) {
108   on_cell_data_string<model_column::Title>(cell, iter);
109 }
110
111
112 ResNum::ResNum() : Base("ResNum") {
113   set_fixed_width(30);
114 }
115 ResNum::~ResNum() {}
116 void ResNum::do_cell_data(Gtk::CellRenderer* cell,
117     const Gtk::TreeModel::iterator& iter) {
118   on_cell_data_int<model_column::ResNum>(cell, iter);
119 }
120
121
122 Number::Number() : Base("No.") {
123   set_fixed_width(30);
124 }
125 Number::~Number() {}
126 void Number::do_cell_data(Gtk::CellRenderer* cell,
127     const Gtk::TreeModel::iterator& iter) {
128   on_cell_data_int<model_column::Number>(cell, iter);
129 }
130
131
132 LineCount::LineCount() : Base("Read") {
133   set_fixed_width(30);
134 }
135 LineCount::~LineCount() {}
136 void LineCount::do_cell_data(Gtk::CellRenderer* cell,
137     const Gtk::TreeModel::iterator& iter) {
138   on_cell_data_int<model_column::LineCount>(cell, iter);
139 }
140
141
142 } // namespace view_column
143
144 } // namespace dialektos