Ejemplo n.º 1
0
void MenuFactory::addItem(
    Q3PopupMenu&      menu,
    const char *const name,
    const int         id,
    const char *const whatsThis)
{
    const int itemId = menu.insertItem(
                           TR(name),
                           id );
    if ( NULL != whatsThis )
    {
        menu.setWhatsThis( itemId, TR( whatsThis ) );
    }
}
Ejemplo n.º 2
0
JavaCatWindow::JavaCatWindow() : Q3MainWindow(0, "Java Catalog", Qt::WDestructiveClose) {
  the = this;
  setCaption("Java Catalog");
  commented = 0;
  
  Q3PopupMenu * menu;
  QPixmap pixmap;
  
  Q3ToolBar * tools = new Q3ToolBar(this, "operations");
  
  addToolBar(tools, "Operations", Qt::DockTop, TRUE);
  
  menu = new Q3PopupMenu(this);
  menuBar()->insertItem("&File", menu);
  
  pixmap = QPixmap(fileopen);
  Q3WhatsThis::add(new QToolButton(pixmap, "Open", QString::null,
				  this, SLOT(load()), tools, "open"),
		  OpenText);
  menu->setWhatsThis(menu->insertItem(pixmap, "&Open", this,
				      SLOT(load()), Qt::CTRL+Qt::Key_O),
		     OpenText);
  
  pixmap = QPixmap(filesave);
  Q3WhatsThis::add(new QToolButton(pixmap, "Save", QString::null,
				  this, SLOT(save()), tools, "save"),
		  SaveText);
  menu->setWhatsThis(menu->insertItem(pixmap, "&Save", this,
				      SLOT(save()), Qt::CTRL+Qt::Key_S),
		     SaveText);
  
  menu->insertSeparator();
  pixmap = QPixmap(::scan);
  Q3WhatsThis::add(new QToolButton(pixmap, "Scan", QString::null,
				  this, SLOT(scan()), tools, "scan"),
		  ScanText);
  menu->setWhatsThis(menu->insertItem(pixmap, "S&can", this,
				      SLOT(scan()), Qt::CTRL+Qt::Key_C),
		     ScanText);
  
  menu->insertSeparator();
  menu->insertItem("&Quit", this, SLOT(quit()), Qt::CTRL+Qt::Key_Q);
  
  menu = new Q3PopupMenu(this);
  menuBar()->insertItem("&Browse", menu);
  
  pixmap = QPixmap(browsersearch);
  Q3WhatsThis::add(new QToolButton(pixmap, "Search", QString::null,
				  this, SLOT(browser_search()), tools, "search"),
		  SearchText);
  menu->setWhatsThis(menu->insertItem(pixmap, "&Search", this,
				      SLOT(browser_search()), Qt::CTRL+Qt::Key_S),
		     SearchText);
  
  pixmap = QPixmap(left_xpm);
  Q3WhatsThis::add(new QToolButton(pixmap, "Back", QString::null,
				  this, SLOT(historic_back()),
				  tools, "back"),
		  LeftText);
  
  pixmap = QPixmap(right_xpm);
  Q3WhatsThis::add(new QToolButton(pixmap, "Forward", QString::null,
				  this, SLOT(historic_forward()),
				  tools, "forward"),
		  RightText);
  
  (void)Q3WhatsThis::whatsThisButton(tools);

  //
  
  menu = new Q3PopupMenu(this);
  menuBar()->insertItem("&Style", menu);
  
#if !defined(QT_NO_STYLE_MOTIF)
  menu->insertItem("Motif", this, SLOT(motif_style()));
#endif
#if !defined(QT_NO_STYLE_MOTIFPLUS)
  menu->insertItem("MotifPlus", this, SLOT(motifplus_style()));
#endif
  menu->insertItem("Windows", this, SLOT(windows_style()));
  
  //
  
  menuBar()->insertSeparator();
  menu = new Q3PopupMenu(this);
  menuBar()->insertItem("&Help", menu);
  
  menu->insertItem("&About", this, SLOT(about()), Qt::Key_F1);
  menu->insertItem("About&Qt", this, SLOT(aboutQt()));
  menu->insertSeparator();
  menu->insertItem("What's This", this, SLOT(whatsThis()), Qt::SHIFT+Qt::Key_F1);
    
  //
  
  spl = new QSplitter(Qt::Vertical, this, "spl");
  
  browser = new BrowserView(spl);
  comment = new CommentView(spl);
  
  connect(comment, SIGNAL(refer(const QString &)),
	  browser, SLOT(refer(const QString &)));
  
  spl->moveToFirst(browser);

  Q3ValueList<int> lsz = spl->sizes();
  int h = lsz.first() + lsz.last();
  
  lsz.first() = (h*3)/4;
  lsz.last() = h - lsz.first();
  
  spl->setSizes(lsz);
  
  spl->setResizeMode(comment, QSplitter::KeepSize);
  setCentralWidget(spl);
}
Ejemplo n.º 3
0
void BrowserNode::mark_menu(Q3PopupMenu & m, const char * s, int bias) const {
  if (! is_marked) {
    m.insertSeparator();
    m.setWhatsThis(m.insertItem(TR("Mark"), bias),
		   TR("to mark %1", s));

    if (!marked_list.isEmpty()) {
      bool parents_marked = FALSE;
      const BrowserNode * bn = this;
      
      while (bn != BrowserView::get_project()) {
	bn = (BrowserNode *) bn->parent();
	if (bn->is_marked) {
	  parents_marked = TRUE;
	  break;
	}
      }
      
      bool moveable = TRUE;
#ifndef SIMPLE_DUPLICATION
      bool rec = FALSE;
#endif
      Q3PtrListIterator<BrowserNode> it(marked_list);
      
      for (; (bn = it.current()) != 0; ++it) {
	if ((bn == BrowserView::get_project()) ||
	    !((BrowserNode *) bn->parent())->is_writable()) {
	  moveable = FALSE;
#ifndef SIMPLE_DUPLICATION
	}
	if (bn->firstChild() != 0) {
	  rec = TRUE;
#else
	  break;
#endif
	}
      }
      
      BooL duplicable_into = TRUE;
      BooL duplicable_after = TRUE;
      bool into = may_contains_them(marked_list, duplicable_into) 
	&& is_writable();
      bool after = (this != BrowserView::get_project()) &&
	((BrowserNode *) parent())->is_writable() &&
	  ((BrowserNode *) parent())->may_contains_them(marked_list, duplicable_after);
      
      if (!parents_marked) {
	if (moveable) {
	  if (into)
	    m.setWhatsThis(m.insertItem(TR("Move marked into"), bias + 3),
			   TR("to move the marked items into %1", s));
	  if (after)
	    m.setWhatsThis(m.insertItem(TR("Move marked after"), bias + 4),
			   TR("to move the marked items after %1", s));
	}
      }
      if (into && duplicable_into) {
	m.setWhatsThis(m.insertItem(TR("Duplicate marked into"), bias + 5),
		       TR("to duplicate the marked items into %1", s));
#ifndef SIMPLE_DUPLICATION
	if (rec && !parents_marked)
	  m.setWhatsThis(m.insertItem(TR("Duplicate recursivelly marked into"), bias + 6),
			 TR("to recurcivelly duplicate the marked items into %1", s));
#endif
      }
      if (after && duplicable_after) {
	m.setWhatsThis(m.insertItem(TR("Duplicate marked after"), bias + 7),
		       TR("to duplicate the marked items after %1", s));
#ifndef SIMPLE_DUPLICATION
	if (rec && !parents_marked)
	  m.setWhatsThis(m.insertItem(TR("Duplicate marked recursivelly after"), bias + 8),
			 TR("to recurcivelly duplicate the marked items after %1", s));
#endif
      }
    }
  }
  else {
    m.insertSeparator();
    m.setWhatsThis(m.insertItem(TR("Unmark"), bias + 1),
		   TR("to unmark %1", s));
    if (!marked_list.isEmpty())
      m.setWhatsThis(m.insertItem(TR("Unmark all"), bias + 2),
		     QString(TR("to unmark all the marked items")));
  }
}