Ejemplo n.º 1
0
void AntProjectPart::contextMenu(QPopupMenu *popup, const Context *context)
{
  if (!context->hasType( Context::FileContext ))
    return;

  const FileContext *fcontext = static_cast<const FileContext*>(context);
  KURL url = fcontext->urls().first();
  if (URLUtil::isDirectory(url))
    return;

  m_contextFileName = url.fileName();
  bool inProject = project()->allFiles().contains(m_contextFileName.mid ( project()->projectDirectory().length() + 1 ) );
  QString popupstr = QFileInfo(m_contextFileName).fileName();
  if (m_contextFileName.startsWith(projectDirectory()+ "/"))
    m_contextFileName.remove(0, projectDirectory().length()+1);

  popup->insertSeparator();
  if (inProject)
  {
    int id = popup->insertItem( i18n("Remove %1 From Project").arg(popupstr),
                       this, SLOT(slotRemoveFromProject()) );
    popup->setWhatsThis(id, i18n("<b>Remove from project</b><p>Removes current file from the project."));
  }
  else
  {
    int id = popup->insertItem( i18n("Add %1 to Project").arg(popupstr),
                       this, SLOT(slotAddToProject()) );
    popup->setWhatsThis(id, i18n("<b>Add to project</b><p>Adds current file from the project."));
  }
}
Ejemplo n.º 2
0
/*! Constructor
 * \brief This class implements the project management
 *
 * This also handles the mouse and keyboad events, and sends
 * when appropiate, the file names to be opened by the parent.
 *
 * \param parent Parent of the widget.
 */
Project::Project(QWidget *parent) : QWidget(parent)
{
    projectLibrary = 0;
    m_libraryFileName = "";
    m_libraryName = "";

    QVBoxLayout *layout = new QVBoxLayout(this);

    QToolBar *toolbar = new QToolBar;

    QToolButton *projNew = new QToolButton();
    projNew->setIcon(QIcon(Qucs::bitmapDirectory() + "project-new.png"));
    projNew->setStatusTip(tr("Creates a new project"));
    projNew->setToolTip(tr("Creates a new project"));
    projNew->setWhatsThis(tr("New Project\n\nCreates a new project"));

    QToolButton *projOpen = new QToolButton();
    projOpen->setIcon(QIcon(Qucs::bitmapDirectory() + "fileopen.png"));
    projOpen->setStatusTip(tr("Opens an existing project"));
    projOpen->setToolTip(tr("Opens an existing project"));
    projOpen->setWhatsThis(tr("Open Project\n\nOpens an existing project"));

    QToolButton *addToProj = new QToolButton();
    addToProj->setIcon(QIcon(Qucs::bitmapDirectory() + "filenew.png"));
    addToProj->setStatusTip(tr("Adds a file to current project"));
    addToProj->setToolTip(tr("Adds a file to current project"));
    addToProj->setWhatsThis(tr("Add File to Project\n\nAdds a file to current project"));

    QToolButton *projDel = new QToolButton();
    projDel->setIcon(QIcon(Qucs::bitmapDirectory() + "fileclose.png"));
    projDel->setStatusTip(tr("Removes a file from current project"));
    projDel->setToolTip(tr("Removes a file from current project"));
    projDel->setWhatsThis(tr("Remove from Project\n\nRemoves a file from current project"));

    QToolButton *projClose = new QToolButton();
    projClose->setIcon(QIcon(Qucs::bitmapDirectory() + "project-close.png"));
    projClose->setStatusTip(tr("Closes the current project"));
    projClose->setToolTip(tr("Closes the current project"));
    projClose->setWhatsThis(tr("Close Project\n\nCloses the current project"));

    connect(projNew, SIGNAL(clicked()), this, SLOT(slotNewProject()));
    connect(projOpen, SIGNAL(clicked()), this, SLOT(slotOpenProject()));
    connect(addToProj, SIGNAL(clicked()), this, SLOT(slotAddToProject()));
    connect(projDel, SIGNAL(clicked()), this, SLOT(slotRemoveFromProject()));
    connect(projClose, SIGNAL(clicked()), this, SLOT(slotCloseProject()));

    toolbar->addWidget(projNew);
    toolbar->addWidget(projOpen);
    toolbar->addWidget(addToProj);
    toolbar->addWidget(projDel);
    toolbar->addWidget(projClose);

    m_projectsSidebar = new ComponentsSidebar(this);
    connect(m_projectsSidebar, SIGNAL(itemClicked(const QString&, const QString&)), this,
            SLOT(slotOnClicked(const QString&, const QString&)));
    connect(m_projectsSidebar, SIGNAL(itemDoubleClicked(const QString&, const QString&)), this,
            SLOT(slotOnDoubleClicked(const QString&, const QString&)));


    layout->addWidget(toolbar);
    layout->addWidget(m_projectsSidebar);

    setWindowTitle(tr("Project View"));
}