void GitoriousRepositoryWizardPage::initializePage()
{
    // Populate the model
    ui->repositoryTreeView->selectionModel()->clearSelection();
    if (const int oldRowCount = m_model->rowCount())
        m_model->removeRows(0, oldRowCount);
    ui->filterLineEdit->clear();
    // fill model
    const QSharedPointer<GitoriousProject> proj = m_projectPage->project();
    setSubTitle(tr("Choose a repository of the project '%1'.").arg(proj->name));
    // Create a hierarchical list by repository type, sort by type
    QList<GitoriousRepository> repositories = proj->repositories;
    QStandardItem *firstEntry = 0;
    if (!repositories.empty()) {
        int lastRepoType = -1;
        QStandardItem *header = 0;
        qStableSort(repositories.begin(), repositories.end(), gitRepoLessThanByType);
        const QString types[GitoriousRepository::PersonalRepository + 1] =
            { tr("Mainline Repositories"), tr("Clones"), tr("Baseline Repositories"), tr("Shared Project Repositories"), tr("Personal Repositories") };
        foreach(const GitoriousRepository &r, repositories) {
            // New Header?
            if (r.type != lastRepoType || !header) {
                lastRepoType = r.type;
                const QList<QStandardItem *> headerRow = headerEntry(types[r.type]);
                m_model->appendRow(headerRow);
                header = headerRow.front();
            }
            // Repository row
            const QList<QStandardItem *> row = repositoryEntry(r);
            header->appendRow(row);
            if (!firstEntry)
                firstEntry = row.front();
        }
    }
Example #2
0
void PropertiesEditorDialog::valueChanged(QtProperty *property, const QVariant &value)
{
    if (!m_property_to_id.contains(property))
    {
        return;
    }

    if (!m_canvas)
    {
        return;
    }
    QList<QGraphicsSvgItem *> list = m_canvas->selectedGeneralItems();

    m_canvas->beginUndoMacro(tr("Change Property"));
    if (list.empty())
    {
        // Set the property directly on the canvas:
        m_canvas->setProperty(m_property_to_id[property].toLatin1().constData(), value);
    }
    else
    {
        // Otherwise, set it on the first item in the selection:
        QGraphicsSvgItem *item = list.front();
        item->setProperty(m_property_to_id[property].toLatin1().constData(), value);
    }
}
void chanFileSystemDockWidget::renameFolder() {

    //之前这里一直获得的都是size == 0 原因在于context menu设置不正确
    //那个错误的设置是remove folder 但是却导致了这里始终接受的items.size() == 0
    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();
    QTreeWidgetItem* item = items.front();

    //根节点不可修改名字
    if (m_fileSystemTree->itemAbove(item) == NULL) {
        return;
    }

    QString folderName;
    QString path;
    QDir dir;

    folderName = QInputDialog::getText(this, "set folder's name", "enter name:");
    path = m_home + QDir::separator() + folderName;

    if (!QDir().rename(item->data(0, FOLDER_NAME_KEY).toString(), (path))) {
        QMessageBox::warning(this, tr("error"),
                             tr("failed to rename the folder!"));
        return;
    }

    item->setData(0, FOLDER_NAME_KEY, path);
    item->setText(0, folderName);
}
Example #4
0
int
Splitter::getLeftChildrenSize() const
{
    QList<int> list = sizes();
    assert(list.size() == 2);
    return list.front();
}
void chanFileSystemDockWidget::createFile() {

    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();

    if (items.isEmpty()) return;

    QTreeWidgetItem* parent = items.front();

    QString fileName = QFileDialog::getSaveFileName(this, tr("edit name"), ".",
                       tr("c/c++ header file(*.h)\n"
                          "c/c++ header file(*.hpp)\n"
                          "c source file(*.c)\n"
                          "c++ source file(*.cpp)"
                         ));

    if (!QFile(fileName).open(QIODevice::WriteOnly)) {
        QMessageBox::warning(this, "error",
                             tr("create the file %1 failed").arg(fileName));

        return;
    }

    createTreeWidgetItem(fileName, parent);

    emit createdFile(fileName);
}
void chanFileSystemDockWidget::createFolder() {

    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();

    QString folderName;
    QString path;
    QDir dir;

    folderName = QInputDialog::getText(this, "set folder's name", "enter name:");
    path = m_home + QDir::separator() + folderName;

    //修改硬盘中的数据
    if (!dir.mkdir(path)) {
        QMessageBox::warning(this, tr("error"),
                             tr("make directory %1 failed").arg(folderName));
        return;
    }

    QTreeWidgetItem* item = items.empty() ?
                            new QTreeWidgetItem(m_fileSystemTree) :
                            new QTreeWidgetItem(items.front());

    item->setData(0, ITEM_TYPE_KEY, Folder);
    item->setData(0, FOLDER_NAME_KEY,path);
    item->setText(0, folderName);

    item->setIcon(0, QIcon(resourceFileName::pFolder));
}
void chanFileSystemDockWidget::renameFile() {

    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();

    if (items.isEmpty()) return;

    QTreeWidgetItem* parent = items.front();

    QString fileName = QFileDialog::getSaveFileName(this, tr("edit name"), ".",
                       tr("c/c++ header file(*.h)\n"
                          "c/c++ header file(*.hpp)\n"
                          "c source file(*.c)\n"
                          "c++ source file(*.cpp)"
                         ));

    if (fileName.isEmpty()) return;

    QTreeWidgetItem* item = items.front();

    //修改了硬盘中的数据
    if (!QFile::rename(item->data(0, FILE_NAME_KEY).toString(), fileName)) {
        QMessageBox::warning(this, "error", "failed to rename the file");
        return;
    }

    if (QFile().exists(fileName)) {
        QMessageBox::warning(this, tr("error"), tr("failed to rename the file"));
        return;
    }

    //发射修改了的信号
    emit renamedFile(item->data(0, FILE_NAME_KEY).toString(), fileName);

    QFileInfo info(fileName);

    item->setData(0, FILE_NAME_KEY, fileName);
    item->setText(0, info.completeBaseName());

    QString suffix = info.completeSuffix();
    if (suffix == "c")
        item->setIcon(0, QIcon(resourceFileName::pC));
    else if (suffix == "cpp")
        item->setIcon(0, QIcon(resourceFileName::pCpp));
    else if (suffix == "h" || suffix == "hpp")
        item->setIcon(0, QIcon(resourceFileName::pH));
}
Example #8
0
QString WorkerThread::getFirstMessage()
{

        QMutexLocker ll(&m2);
        if (messStack.size()==0) return "";
        QString s = messStack.front();
        messStack.pop_front();
        return s;
}
void GridTriangleFill::sortByAscendingY (QPoint p0In,
                                         QPoint p1In,
                                         QPoint p2In,
                                         QPoint &p0,
                                         QPoint &p1,
                                         QPoint &p2) const
{
  // Sort by ascending y value
  QList<QPoint> list;
  list << p0In << p1In << p2In;
  std::sort (list.begin(), list.end(), compareByY);

  p0 = list.front();
  list.pop_front();
  p1 = list.front();
  list.pop_front();
  p2 = list.front();
}
void chanFileSystemDockWidget::importFile() {

    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();

    if (items.empty() || (items.front()->data(0, ITEM_TYPE_KEY).toInt() == File))
        return;

    QString fileName = QFileDialog::getOpenFileName(this, tr("open"), ".", tr(
                           "c/c++ header file(*.h)\n"
                           "c/c++ header file(*.hpp)\n"
                           "c source file(*.c)\n"
                           "c++ source file(*.cpp)"));

    if (fileName.isEmpty()) return;

    createTreeWidgetItem(fileName, items.front());

    emit importedFile(fileName);
}
Example #11
0
static inline bool isValidIcon(const QIcon &icon)
{
    if (!icon.isNull()) {
        const QList<QSize> availableSizes = icon.availableSizes();
        if (!availableSizes.empty()) {
            return !availableSizes.front().isEmpty();
        }
    }
    return false;
}
Example #12
0
/*!
    Finds the path for the local adapter with \a wantedAddress or an empty string
    if no local adapter with the given address can be found.
    If \a wantedAddress is \c null it returns the first/default adapter or an empty
    string if none is available.

    If \a ok is false the lookup was aborted due to a dbus error and this function
    returns an empty string.
 */
QString findAdapterForAddress(const QBluetoothAddress &wantedAddress, bool *ok = 0)
{
    OrgFreedesktopDBusObjectManagerInterface manager(QStringLiteral("org.bluez"),
                                                     QStringLiteral("/"),
                                                     QDBusConnection::systemBus());

    QDBusPendingReply<ManagedObjectList> reply = manager.GetManagedObjects();
    reply.waitForFinished();
    if (reply.isError()) {
        if (ok)
            *ok = false;

        return QString();
    }

    typedef QPair<QString, QBluetoothAddress> AddressForPathType;
    QList<AddressForPathType> localAdapters;

    ManagedObjectList managedObjectList = reply.value();
    for (ManagedObjectList::const_iterator it = managedObjectList.constBegin(); it != managedObjectList.constEnd(); ++it) {
        const QDBusObjectPath &path = it.key();
        const InterfaceList &ifaceList = it.value();

        for (InterfaceList::const_iterator jt = ifaceList.constBegin(); jt != ifaceList.constEnd(); ++jt) {
            const QString &iface = jt.key();

            if (iface == QStringLiteral("org.bluez.Adapter1")) {
                AddressForPathType pair;
                pair.first = path.path();
                pair.second = QBluetoothAddress(ifaceList.value(iface).value(
                                          QStringLiteral("Address")).toString());
                if (!pair.second.isNull())
                    localAdapters.append(pair);
                break;
            }
        }
    }

    if (ok)
        *ok = true;

    if (localAdapters.isEmpty())
        return QString(); // -> no local adapter found

    if (wantedAddress.isNull())
        return localAdapters.front().first; // -> return first found adapter

    foreach (const AddressForPathType &pair, localAdapters) {
        if (pair.second == wantedAddress)
            return pair.first; // -> found local adapter with wanted address
    }

    return QString(); // nothing matching found
}
QSize ResourceItemDelegate::sizeHint(const QStyleOptionViewItem &/*option*/,
                                     const QModelIndex &index) const
{
    QSize result = QSize(25, 4);
    const QIcon icon(m_model->fileIcon(index));
    if (!icon.isNull()) {
        const QList<QSize> sizes = icon.availableSizes();
        if (!sizes.isEmpty())
            result += sizes.front();
    }
    return result;
}
	QList<QUrl> LocalCollectionModel::ToSourceUrls (const QList<QModelIndex>& indexes) const
	{
		const auto& paths = std::accumulate (indexes.begin (), indexes.end (), QStringList {},
				[this] (const QStringList& paths, decltype (indexes.front ()) item)
					{ return paths + CollectPaths (item, this); });

		QList<QUrl> result;
		result.reserve (paths.size ());
		for (const auto& path : paths)
			result << QUrl::fromLocalFile (path);
		return result;
	}
Example #15
0
void QNode::safeSpeedCallback(const autorally_msgs::safeSpeedConstPtr& msg)
{
  QList<QStandardItem *> items = m_safeSpeedModel.findItems(
                                          QString::fromStdString(msg->sender) );
  if(items.isEmpty())
  {
    //add new item for the sender
    m_safeSpeedModel.appendRow(generateNewSafeSpeed(msg));
    items = m_safeSpeedModel.findItems( QString::fromStdString(msg->sender) );
  }

  if(items.size() == 1)
  {
    //update the safeSpeed
    m_safeSpeedModel.item(items.front()->index().row(),1)->
        setText(QString::number(msg->speed, 'g', 4));
    m_safeSpeedModel.item(items.front()->index().row(),2)->
       setData(QVariant(msg->header.stamp.toSec()));
  } else //found more than one sender with the same name
  {
    ROS_ERROR("Something is wrong with the OCS safeSpeedModel!!!!!");
  }
}
void QgsMilXLibrary::itemClicked( const QModelIndex &index )
{

  QModelIndex sourceIndex = mFilterProxyModel->mapToSource( index );
  QList<QModelIndex> indexStack;
  indexStack.prepend( sourceIndex );
  while ( sourceIndex.parent().isValid() )
  {
    sourceIndex = sourceIndex.parent();
    indexStack.prepend( sourceIndex );
  }

  QStandardItem* item = mGalleryModel->itemFromIndex( indexStack.front() );
  if ( item )
  {
    for ( int i = 1, n = indexStack.size(); i < n; ++i )
    {
      item = item->child( indexStack[i].row() );
    }

    QgsMilxSymbolTemplate symbolTemplate;
    symbolTemplate.symbolXml = item->data( SymbolXmlRole ).toString();
    if ( symbolTemplate.symbolXml.isEmpty() )
    {
      return;
    }
    hide();
    if ( symbolTemplate.symbolXml == "<custom>" )
    {
      MilXClient::SymbolDesc desc;
      WId wid = mIface->mapCanvas()->winId();
      if ( !MilXClient::createSymbol( symbolTemplate.symbolXml, desc, wid ) )
      {
        return;
      }
      symbolTemplate.symbolMilitaryName = desc.militaryName;
      symbolTemplate.minNPoints = desc.minNumPoints;
      symbolTemplate.hasVariablePoints = desc.hasVariablePoints;
      symbolTemplate.pixmap = QPixmap::fromImage( desc.icon ).scaled( 32, 32, Qt::KeepAspectRatio );
    }
    else
    {
      symbolTemplate.symbolMilitaryName = item->data( SymbolMilitaryNameRole ).toString();
      symbolTemplate.minNPoints = item->data( SymbolPointCountRole ).toInt();
      symbolTemplate.hasVariablePoints = item->data( SymbolVariablePointsRole ).toInt();
      symbolTemplate.pixmap = item->icon().pixmap( item->icon().actualSize( QSize( 32, 32 ) ) );
    }
    emit symbolSelected( symbolTemplate );
  }
}
QStringList ModelRestorationForm::getSelectedModels(void)
{
	QStringList list;
	QList<QListWidgetItem *> items;

	items=tmp_files_lst->selectedItems();

	while(!items.isEmpty())
	{
		list.push_back(items.front()->data(Qt::UserRole).toString());
		items.pop_front();
	}

	return(list);
}
Example #18
0
QString const&
SelectSerialPortDlg::setSerialDevice(QString const& pathname)
{
    if (pathname != serialDevicePathname_)
    {
        serialDevicePathname_ = pathname;

        // Search for and select serial device in list.
        QList<QListWidgetItem *> items = ui->serialDeviceListWidget->findItems(pathname, Qt::MatchExactly);
        if (!items.empty())
        {
            ui->serialDeviceListWidget->setCurrentItem(items.front(), QItemSelectionModel::SelectCurrent);
        }
    }

    return serialDevicePathname_;
}
Example #19
0
void InstrumentWizard::on_partiturList_itemSelectionChanged()
      {
      QList<QTreeWidgetItem*> wi = partiturList->selectedItems();
      if (wi.isEmpty()) {
            removeButton->setEnabled(false);
            upButton->setEnabled(false);
            downButton->setEnabled(false);
            linkedButton->setEnabled(false);
            belowButton->setEnabled(false);
            return;
            }
      QTreeWidgetItem* item = wi.front();
      bool flag = item != 0;

      int count = 0; // item can be hidden
      QTreeWidgetItem* it = 0;
      QList<QTreeWidgetItem*> witems;
      if(item->type() == PART_LIST_ITEM) {
            for (int idx = 0; (it = partiturList->topLevelItem(idx)); ++idx) {
                  if (!it->isHidden()) {
                        count++;
                        witems.append(it);
                        }
                  }
            }
      else {
            for (int idx = 0; (it = item->parent()->child(idx)); ++idx) {
                  if (!it->isHidden()){
                        count++;
                        witems.append(it);
                        }
                  }
            }

      bool onlyOne = (count == 1);
      bool onlyOneStaff = ((item->type() == STAFF_LIST_ITEM) && onlyOne);
      bool first = (witems.first() == item);
      bool last = (witems.last() == item);

      removeButton->setEnabled(flag && !onlyOneStaff);
      upButton->setEnabled(flag && !onlyOne && !first);
      downButton->setEnabled(flag && !onlyOne && !last);
      linkedButton->setEnabled(item && item->type() == STAFF_LIST_ITEM);
      belowButton->setEnabled(item && item->type() == STAFF_LIST_ITEM);
      }
/**
 * \brief List removable drives, let the user select one.
 *
 * prevent drawing a list if there is only one drive, et cetera
 */
MythMediaDevice * MediaMonitor::selectDrivePopup(const QString label,
                                                 bool showMounted,
                                                 bool showUsable)
{
    QList <MythMediaDevice *> drives = GetRemovable(showMounted,
                                                    showUsable);

    if (drives.count() == 0)
    {
        QString msg = "MediaMonitor::selectDrivePopup() - no removable devices";

        LOG(VB_MEDIA, LOG_INFO, msg);
        return NULL;
    }

    if (drives.count() == 1)
    {
        LOG(VB_MEDIA, LOG_INFO, 
                 "MediaMonitor::selectDrivePopup(" + label +
                 ") - One suitable device");
        return drives.front();
    }

    QList <MythMediaDevice *>::iterator it;
    QStringList buttonmsgs;
    for (it = drives.begin(); it != drives.end(); ++it)
        buttonmsgs += DevName(*it);
    buttonmsgs += tr("Cancel");
    const DialogCode cancelbtn = (DialogCode)
        (((int)kDialogCodeButton0) + buttonmsgs.size() - 1);

    DialogCode ret = MythPopupBox::ShowButtonPopup(
        GetMythMainWindow(), "select drive", label,
        buttonmsgs, cancelbtn);

    // If the user cancelled, return a special value
    if ((kDialogCodeRejected == ret) || (cancelbtn == ret))
        return (MythMediaDevice *)-1;

    int idx = MythDialog::CalcItemIndex(ret);
    if (idx < drives.count())
        return drives[idx];

    return NULL;
}
Example #21
0
//! maintain QGScene selected items in selection order
void MDIViewPage::sceneSelectionManager()
{
    QList<QGraphicsItem*> sceneSel = m_view->scene()->selectedItems();

    if (sceneSel.isEmpty()) {
        m_sceneSelected.clear(); //TODO: need to signal somebody?  Tree? handled elsewhere
        //clearSelection
        return;
    }

    if (m_sceneSelected.isEmpty() &&
        !sceneSel.isEmpty()) {
        m_sceneSelected.push_back(sceneSel.front());
        return;
    }

    //add to m_sceneSelected anything that is in q_sceneSel
    for (auto qts: sceneSel) {
        bool found = false;
        for (auto ms: m_sceneSelected) {
            if ( qts == ms ) {
                found = true;
                break;
            }
        }
        if (!found) {
            m_sceneSelected.push_back(qts);
            break;
        }
    }

    //remove items from m_sceneSelected that are not in q_sceneSel
    QList<QGraphicsItem*> m_new;
    for (auto m: m_sceneSelected) {
        for (auto q: sceneSel)  {
            if (m == q) {
                m_new.push_back(m);
                break;
            }
        }
    }
    m_sceneSelected = m_new;
}
Example #22
0
ViewTreeModel::ViewTreeModel(const IWorkbenchWindow* window, QObject* parent)
  : QAbstractItemModel(parent)
  , d(new Impl(window))
{
  d->rootItem.reset(new RootTreeItem(this));

  QList<CategoryTreeItem*> categoryItems;

  QList<IViewCategory::Pointer> categories = d->viewRegistry.GetCategories();
  for (auto category : categories)
  {
    if (category->GetViews().isEmpty()) continue;
    CategoryTreeItem* categoryItem = new CategoryTreeItem(this, category);
    if (categoryItem->childCount() == 0)
    {
      delete categoryItem;
    }
    else
    {
      categoryItems.push_back(categoryItem);
    }
  }


  // if there is only one category, return it's children directly
  if (categoryItems.size() == 1)
  {
    QList<ViewTreeItem*> items = categoryItems.front()->takeChildren();
    for (auto item : items)
    {
      d->rootItem->appendChild(item);
    }
    qDeleteAll(categoryItems);
  }
  else
  {
    for (auto category : categoryItems)
    {
      d->rootItem->appendChild(category);
    }
  }
}
Example #23
0
QSharedPointer<VCSBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<QWizardPage *> &parameterPages,
                                                                    QString *checkoutPath)
{
    const CloneWizardPage *page = qobject_cast<const CloneWizardPage *>(parameterPages.front());

    if (!page)
        return QSharedPointer<VCSBase::AbstractCheckoutJob>();

    const MercurialSettings &settings = MercurialPlugin::instance()->settings();

    QString path = page->path();
    QString directory = page->directory();

    QStringList args;
    args << QLatin1String("clone") << page->repository() << directory;
    *checkoutPath = path + QLatin1Char('/') + directory;
    VCSBase::ProcessCheckoutJob *job = new VCSBase::ProcessCheckoutJob;
    job->addStep(settings.stringValue(MercurialSettings::binaryPathKey), args, path);
    return QSharedPointer<VCSBase::AbstractCheckoutJob>(job);
}
Example #24
0
QSharedPointer<VcsBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<QWizardPage *> &parameterPages,
        QString *checkoutPath)
{
    const CloneWizardPage *page = qobject_cast<const CloneWizardPage *>(parameterPages.front());

    if (!page)
        return QSharedPointer<VcsBase::AbstractCheckoutJob>();

    const BazaarSettings &settings = BazaarPlugin::instance()->settings();
    *checkoutPath = page->path() + QLatin1Char('/') + page->directory();

    const CloneOptionsPanel *panel = page->cloneOptionsPanel();
    QStringList extraOptions;
    if (panel->isUseExistingDirectoryOptionEnabled())
        extraOptions += QLatin1String("--use-existing-dir");
    if (panel->isStackedOptionEnabled())
        extraOptions += QLatin1String("--stacked");
    if (panel->isStandAloneOptionEnabled())
        extraOptions += QLatin1String("--standalone");
    if (panel->isBindOptionEnabled())
        extraOptions += QLatin1String("--bind");
    if (panel->isSwitchOptionEnabled())
        extraOptions += QLatin1String("--switch");
    if (panel->isHardLinkOptionEnabled())
        extraOptions += QLatin1String("--hardlink");
    if (panel->isNoTreeOptionEnabled())
        extraOptions += QLatin1String("--no-tree");
    if (!panel->revision().isEmpty())
        extraOptions << QLatin1String("-r") << panel->revision();
    const BazaarClient *client = BazaarPlugin::instance()->client();
    QStringList args;
    args << client->vcsCommandString(BazaarClient::CloneCommand)
         << extraOptions << page->repository() << page->directory();

    VcsBase::ProcessCheckoutJob *job = new VcsBase::ProcessCheckoutJob;
    job->addStep(settings.stringValue(BazaarSettings::binaryPathKey), args, page->path());
    return QSharedPointer<VcsBase::AbstractCheckoutJob>(job);
}
Example #25
0
void FontPanel::setSelectedFont(const QFont &f)
{
    m_familyComboBox->setCurrentFont(f);
    if (m_familyComboBox->currentIndex() < 0) {
        // family not in writing system - find the corresponding one?
        QList<QFontDatabase::WritingSystem> familyWritingSystems = m_fontDatabase.writingSystems(f.family());
        if (familyWritingSystems.empty())
            return;

        setWritingSystem(familyWritingSystems.front());
        m_familyComboBox->setCurrentFont(f);
    }

    updateFamily(family());

    const int pointSizeIndex = closestPointSizeIndex(f.pointSize());
    m_pointSizeComboBox->setCurrentIndex( pointSizeIndex);

    const QString styleString = m_fontDatabase.styleString(f);
    const int styleIndex = m_styleComboBox->findText(styleString);
    m_styleComboBox->setCurrentIndex(styleIndex);
    slotUpdatePreviewFont();
}
Example #26
0
void probe(Settings *settings)
{
    QList<Profile> profiles;
    if (HostOsInfo::isWindowsHost()) {
        msvcProbe(settings, profiles);
    } else {
        gccProbe(settings, profiles, QLatin1String("gcc"));
        gccProbe(settings, profiles, QLatin1String("clang"));

        if (HostOsInfo::isMacosHost()) {
            xcodeProbe(settings, profiles);
        }
    }

    mingwProbe(settings, profiles);

    if (profiles.empty()) {
        qStderr << Tr::tr("Could not detect any toolchains. No profile created.") << endl;
    } else if (profiles.size() == 1 && settings->defaultProfile().isEmpty()) {
        const QString profileName = profiles.front().name();
        qStdout << Tr::tr("Making profile '%1' the default.").arg(profileName) << endl;
        settings->setValue(QLatin1String("defaultProfile"), profileName);
    }
}
void chanFileSystemDockWidget::removeFolder() {

    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();

    //跟节点不可以被删除
    if (!items.isEmpty() && (m_fileSystemTree->itemAbove(items.front()) == NULL)) {
        return;
    }

    std::for_each(items.begin(), items.end(), [this](QTreeWidgetItem* item) {

        QList<QTreeWidgetItem*> list = item->takeChildren();

        std::for_each(list.begin(), list.end(), [this](QTreeWidgetItem* item) {

            emit removedFile(item->text(0));
            delete item;
        });

        //删除硬盘中的目录 及其子项
        QDir(item->data(0, FOLDER_NAME_KEY).toString()).removeRecursively();
        delete item;
    });
}
Example #28
0
void FileBrowser::addItems(const QString & path )
{
	if( m_dirsAsItems )
	{
		m_l->addTopLevelItem( new Directory( path,
						QString::null, m_filter ) );
		return;
	}

	QDir cdir( path );
	QStringList files = cdir.entryList( QDir::Dirs, QDir::Name );
	for( QStringList::const_iterator it = files.constBegin();
						it != files.constEnd(); ++it )
	{
		QString cur_file = *it;
		if( cur_file[0] != '.' )
		{
			bool orphan = true;
			for( int i = 0; i < m_l->topLevelItemCount(); ++i )
			{
				Directory * d = dynamic_cast<Directory *>(
						m_l->topLevelItem( i ) );
				if( d == NULL || cur_file < d->text( 0 ) )
				{
					m_l->insertTopLevelItem( i,
						new Directory( cur_file, path,
								m_filter ) );
					orphan = false;
					break;
				}
				else if( cur_file == d->text( 0 ) )
				{
					d->addDirectory( path );
					orphan = false;
					break;
				}
			}
			if( orphan )
			{
				m_l->addTopLevelItem( new Directory( cur_file,
							path, m_filter ) );
			}
		}
	}

	files = cdir.entryList( QDir::Files, QDir::Name );
	for( QStringList::const_iterator it = files.constBegin();
						it != files.constEnd(); ++it )
	{
		QString cur_file = *it;
		if( cur_file[0] != '.' )
		{
			// TODO: don't insert instead of removing, order changed
			// remove existing file-items
			QList<QTreeWidgetItem *> existing = m_l->findItems(
					cur_file, Qt::MatchFixedString );
			if( !existing.empty() )
			{
				delete existing.front();
			}
			(void) new FileItem( m_l, cur_file, path );
		}
	}
}
void MotionPlanningFrame::saveQueryButtonClicked()
{
  if (planning_scene_storage_)
  {
    QList<QTreeWidgetItem*> sel = ui_->planning_scene_tree->selectedItems();
    if (!sel.empty())
    {
      QTreeWidgetItem* s = sel.front();

      // if we have selected a PlanningScene, add the query as a new one, under that planning scene
      if (s->type() == ITEM_TYPE_SCENE)
      {
        std::string scene = s->text(0).toStdString();
        planning_display_->addBackgroundJob(
            boost::bind(&MotionPlanningFrame::computeSaveQueryButtonClicked, this, scene, ""), "save query");
      }
      else
      {
        // if we selected a query name, then we overwrite that query
        std::string scene = s->parent()->text(0).toStdString();
        std::string query_name = s->text(0).toStdString();

        while (query_name.empty() || planning_scene_storage_->hasPlanningQuery(scene, query_name))
        {
          std::unique_ptr<QMessageBox> q;
          if (query_name.empty())
            q.reset(new QMessageBox(QMessageBox::Question, "Change Planning Query Name",
                                    QString("The name for the planning query should not be empty. Would you like to "
                                            "rename the planning query?'"),
                                    QMessageBox::Cancel, this));
          else
            q.reset(new QMessageBox(QMessageBox::Question, "Confirm Planning Query Overwrite",
                                    QString("A planning query named '")
                                        .append(query_name.c_str())
                                        .append("' already exists. Do you wish "
                                                "to overwrite that query?"),
                                    QMessageBox::Yes | QMessageBox::No, this));
          std::unique_ptr<QPushButton> rename(q->addButton("&Rename", QMessageBox::AcceptRole));
          if (q->exec() == QMessageBox::Yes)
            break;
          else
          {
            if (q->clickedButton() == rename.get())
            {
              bool ok = false;
              QString new_name =
                  QInputDialog::getText(this, "Rename Planning Query", "New name for the planning query:",
                                        QLineEdit::Normal, QString::fromStdString(query_name), &ok);
              if (ok)
                query_name = new_name.toStdString();
              else
                return;
            }
            else
              return;
          }
        }
        planning_display_->addBackgroundJob(
            boost::bind(&MotionPlanningFrame::computeSaveQueryButtonClicked, this, scene, query_name), "save query");
      }
    }
  }
}
Example #30
0
void VtkVisTabWidget::buildProportiesDialog(VtkVisPipelineItem* item)
{
    auto* layout =
        static_cast<QFormLayout*>(this->scrollAreaWidgetContents->layout());
    while (layout->count())
        delete layout->takeAt(0)->widget();

    QMap<QString, QVariant>* propMap = nullptr;
    QMap<QString, QList<QVariant>>* propVecMap = nullptr;
    VtkAlgorithmProperties* algProps = item->getVtkProperties();

    if (algProps == nullptr)
        WARN("VtkAlgorithmProperties null!")

    // Retrieve algorithm properties
    if (item->compositeFilter())
    {
        propMap = item->compositeFilter()->GetAlgorithmUserProperties();
        propVecMap =
            item->compositeFilter()->GetAlgorithmUserVectorProperties();
    }
    else
    {
        if (algProps)
        {
            propMap = algProps->GetAlgorithmUserProperties();
            propVecMap = algProps->GetAlgorithmUserVectorProperties();
        }
    }

    // Select appropriate GUI element and set connect for each property
    if (propMap)
    {
        QMapIterator<QString, QVariant> i(*propMap);
        while (i.hasNext())
        {
            i.next();
            QString key = i.key();
            QVariant value = i.value();

            VtkAlgorithmPropertyLineEdit* lineEdit;
            VtkAlgorithmPropertyCheckbox* checkbox;
            switch (value.type())
            {
            case QVariant::Double:
                lineEdit =
                        new VtkAlgorithmPropertyLineEdit(QString::number(
                                                                 value.toDouble()),
                                                         key, QVariant::Double,
                                                         algProps);
                connect(lineEdit, SIGNAL(editingFinished()), this,
                        SIGNAL(requestViewUpdate()));
                layout->addRow(key, lineEdit);
                break;

            case QVariant::Int:
                lineEdit =
                        new VtkAlgorithmPropertyLineEdit(QString::number(
                                                                 value.toInt()),
                                                         key, QVariant::Int,
                                                         algProps);
                connect(lineEdit, SIGNAL(editingFinished()), this,
                        SIGNAL(requestViewUpdate()));
                layout->addRow(key, lineEdit);
                break;

            case QVariant::Bool:
                checkbox = new VtkAlgorithmPropertyCheckbox(
                        value.toBool(), key, algProps);
                connect(checkbox, SIGNAL(stateChanged(int)), this,
                        SIGNAL(requestViewUpdate()));
                layout->addRow(key, checkbox);
                break;

            default:
                break;
            }
        }
    }

    if (propVecMap)
    {
        QMapIterator<QString, QList<QVariant> > i(*propVecMap);
        while (i.hasNext())
        {
            i.next();
            QString key = i.key();
            QList<QVariant> values = i.value();

            VtkAlgorithmPropertyVectorEdit* vectorEdit;
            if (!values.empty())
            {
                QList<QString> valuesAsString;
                foreach (QVariant variant, values)
                valuesAsString.push_back(variant.toString());

                vectorEdit = new VtkAlgorithmPropertyVectorEdit(valuesAsString, key,
                                                                values.front().type(),
                                                                algProps);
                connect(vectorEdit, SIGNAL(editingFinished()), this,
                        SIGNAL(requestViewUpdate()));
                layout->addRow(key, vectorEdit);
            }
        }
    }
}