Esempio n. 1
0
//
// Deletes the current selection.
//
bool ResultsTree::deleteSelection(void)
{
	bool empty = false;

	// Go through selected items
	list<TreeModel::Path> selectedItems = get_selection()->get_selected_rows();
	list<TreeModel::Path>::iterator itemPath = selectedItems.begin();
	while (itemPath != selectedItems.end())
	{
		TreeModel::iterator iter = m_refStore->get_iter(*itemPath);
		TreeModel::Row row = *iter;
		TreeModel::iterator parentIter;
		bool updateParent = false;

		// This could be a group that's in the map and should be removed first
		if (row[m_resultsColumns.m_type] != ResultsModelColumns::RESULT_TITLE)
		{
			string groupName = from_utf8(row[m_resultsColumns.m_text]);
			std::map<string, TreeModel::iterator>::iterator mapIter = m_resultsGroups.find(groupName);
			if (mapIter != m_resultsGroups.end())
			{
				m_resultsGroups.erase(mapIter);
#ifdef DEBUG
				cout << "ResultsTree::deleteResults: erased group " << groupName << endl;
#endif
			}
		}
		else
		{
			// This item is a result
			parentIter = row.parent();
			updateParent = true;
		}

		// Unselect and erase
		get_selection()->unselect(iter);
		m_refStore->erase(row);

		// Update group ?
		if (updateParent == true)
		{
			// Update the group this result belongs to
			updateGroup(parentIter);
		}

		selectedItems = get_selection()->get_selected_rows();
		itemPath = selectedItems.begin();
	}

	TreeModel::Children children = m_refStore->children();
	empty = children.empty();

	refresh();

	return empty;
}
Esempio n. 2
0
Gtk::TreeModel::iterator TaskList::subSearch(int id, TreeModel::Children children)
{
	TreeIter iter;

	for (iter = children.begin(); iter != children.end(); iter++)
	{
		TreeModel::Row row = *iter;
		if (row.children().size() > 0)
		{
			TreeIter subIter = subSearch(id, row.children());
			if (subIter != row.children().end())
			{
				iter = subIter;
				break;
			}
		}
		if (row[columns.col_id] == id)
		{
			break;
		}
	}
	return iter;
}
Esempio n. 3
0
NeWindow::NeWindow(Engine *_en)
  :b_cancel(Stock::CANCEL),
   b_ok(Stock::OK)
{
  cout << "NeWindow::NeWindow(Engine)" << endl;
  // Set variables
  en = _en;
  
  // Set window properties
  set_title("Linjap 2 :: New Session");
  set_border_width(5);
  set_default_size(400, 300);
  //set_icon_from_file("src/jping.png");

  // Get data from the db
  Data *data; 
  if((data = en->get_data())) { 
    
    // Packing widgets
    swindow.add(tview);
    swindow.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC);    

    // Create Tree Model
    tmodel = TreeStore::create(columns);
    tview.set_model(tmodel);

    // Fill the Tree
    TreeModel::Row row;
    TreeModel::Row crow;
    vector<string> *chap_names = data->get_chap_names();
    vector<string> *part_names = data->get_part_names();
    int x, y;
    
    for (x = 0; x < data->length_x(); x++) {
      for (y = 0; y < data->length_y(); y++) {
	if (y == 0) {
	  if (data->get_place(x, y)) {
	    row = *(tmodel->append());
	    row[columns.m_col_chap] = x + 1;
	    row[columns.m_col_part] = y;
	    if ((unsigned int) x < chap_names->size()) {
	      string cname = chap_names->at(x);
	      if (cname.size() > 0) {
		row[columns.m_col_name] = cname;
	      } else {
		ostringstream oss;
		oss << "Chapter " << (x + 1);
		row[columns.m_col_name] = oss.str();
	      }
	    } else {
	      ostringstream oss;
	      oss << "Chapter " << (x + 1);
	      row[columns.m_col_name] = oss.str();
	    }
	  } else break;
	} else {
	  if (data->get_place(x, y)) {
	    crow = *(tmodel->append(row.children()));
	    crow[columns.m_col_chap] = x + 1;
	    crow[columns.m_col_part] = y;
	    if ((unsigned int) (y - 1) < part_names->size()) {
	      string pname = part_names->at(y - 1);
	      if (pname.size() > 0) {
		crow[columns.m_col_name] = pname;
	      } else {
		ostringstream oss;
		oss << "Part " << (x + 1);
		crow[columns.m_col_name] = oss.str();
	      }
	    } else {
	      ostringstream oss;
	      oss << "Part " << (x + 1);
	      crow[columns.m_col_name] = oss.str();
	    }}}}}
    
    tview.append_column("Chapter", columns.m_col_chap);
    tview.append_column("Name", columns.m_col_name);
    tview.append_column_editable("Add", columns.m_col_bools);
    tview.append_column("Part", columns.m_col_part);
    vbox.pack_start(swindow);
  } else {
    //tmodel = NULL;
    vbox.pack_start(*(new Label("NO DICT LOADED YET")), PACK_SHRINK);
  }
  
  bbox.pack_start(b_ok, PACK_SHRINK);
  bbox.pack_start(b_cancel, PACK_SHRINK);

  vbox.pack_start(bbox, PACK_SHRINK);

  add(vbox);

  // Set Widget Properties
  bbox.set_border_width(5);
  bbox.set_layout(BUTTONBOX_END);

  // Connect Signals
  b_cancel.signal_clicked().connect(sigc::mem_fun(*this,
						  &NeWindow::on_button_cancel));
  b_ok.signal_clicked().connect(sigc::mem_fun(*this,
					      &NeWindow::on_button_ok));

  show_all_children();
  delete data;
  
}