Logo Search packages:      
Sourcecode: kcollectd version File versions  Download package

void Graph::mousePressEvent ( QMouseEvent *  e ) [virtual]

Qt mouse-press-event

Definition at line 816 of file graph.cc.

{
  origin_x = e->x ();
  origin_y = e->y ();

  origin_start = data_start;
  origin_end = data_end;

  // context-menu
  if (e->button() == Qt::RightButton) {
    // map for delete-datasource-options
    typedef std::map<QAction *, GraphInfo::iterator> actionmap;
    actionmap acts; 
    
    // context-menu
    KMenu menu(this);
    
    graph_list::iterator s_graph = graphAt(e->pos());
    
    menu.addAction(KIcon("list-add"), 
        i18n("add new subgraph"), this, SLOT(splitGraph()));

    if (s_graph != end()) {
      menu.addAction(KIcon("edit-delete"),
          i18n("delete this subgraph"), this, SLOT(removeGraph()));
      menu.addSeparator();
      
      // generate entries to remove datasources
      for(GraphInfo::iterator i = s_graph->begin(); i != s_graph->end(); ++i) {
      QAction *T = menu.addAction(KIcon("list-remove"),
            i18n("remove ") + i->label);
      acts[T] = i;
      }
    }

    QAction *action = menu.exec(e->globalPos());

    actionmap::iterator result = acts.find(action);
    if (result != acts.end()) {
      s_graph->erase(result->second);
      layout();
      update();
    }
  }
}

Generated by  Doxygen 1.6.0   Back to index