Exemplo n.º 1
0
PhotoView::PhotoView(QAbstractGallery *gallery, QWidget *parent, Qt::WindowFlags flags)
    : GalleryView(parent, flags)
    , model(new ThumbnailModel(gallery))
{
    model->setRootType(QDocumentGallery::Image);

    QHash<int, QString> properties;
    properties.insert(Qt::DisplayRole, QDocumentGallery::fileName);
    model->addColumn(properties);

    model->setSortPropertyNames(QStringList()
            << QDocumentGallery::title);

    QListView *view = new QListView;
    view->setIconSize(ThumbnailModel::thumbnailSize);
    view->setFlow(QListView::TopToBottom);
    view->setViewMode(QListView::IconMode);
    view->setUniformItemSizes(true);
    view->setWrapping(true);
    view->setModel(model.data());
    view->setItemDelegate(new PhotoDelegate(this));
    connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));

    QBoxLayout *layout = new QVBoxLayout;
    layout->setMargin(0);
    layout->setSpacing(0);
    layout->addWidget(view);

    setLayout(layout);
}
void AnnotationImagePaletteWidget::addPalette(const QString& path)
{
   QListView* pPalette = new QListView(this);
   pPalette->setWrapping(true);
   pPalette->setLayoutMode(QListView::Batched);
   pPalette->setBatchSize(10);
   pPalette->setMovement(QListView::Static);
   pPalette->setFlow(QListView::LeftToRight);
   pPalette->setIconSize(QSize(32, 32));
   pPalette->setViewMode(QListView::IconMode);
   pPalette->setDragEnabled(true);
   pPalette->setDragDropMode(QAbstractItemView::DragOnly);
   pPalette->setSelectionMode(QAbstractItemView::SingleSelection);
   pPalette->setResizeMode(QListView::Adjust);

   if (QFileInfo(path).isDir())
   {
      QDirModel* pModel = new PaletteModel(this);
      pModel->setFilter(QDir::Files | QDir::Readable);
      QStringList formats;
      QList<QByteArray> rawFormats = QImageReader::supportedImageFormats();
      foreach (const QByteArray& rawFormat, rawFormats)
      {
         formats << "*." + QString(rawFormat);
      }
Exemplo n.º 3
0
	CWirelessSettings::CWirelessSettings(CDevice * wireless, QWidget * parent) : QWidget(parent), m_Device(wireless) {
		ui.setupUi(this);

		QListView * hiddenListView = new QListView(this);
		hiddenListView->hide();
		hiddenListView->setViewMode(QListView::IconMode);
		hiddenListView->setIconSize(QSize(24, 24));
		hiddenListView->setGridSize(QSize(96, 64));

		setWindowTitle(tr("QNUT - Wireless Settings for \"%1\"").arg(m_Device->getName()));
		setWindowIcon(QIcon(UI_ICON_AP));

		ui.nameLabel->setText(m_Device->getName());

		m_ManagedAPProxyModel = new CManagedAPProxyModel(this);
		m_ManagedAPModel = new CManagedAPModel(m_Device->getWireless()->getWpaSupplicant(), this);
		m_ManagedAPProxyModel->setSourceModel(m_ManagedAPModel);

		m_AvailableAPProxyModel = new CAvailableAPProxyModel(this);
		m_AvailableAPModel = new CAvailableAPModel(m_Device->getWireless()->getHardware(), this);
		m_AvailableAPProxyModel->setSourceModel(m_AvailableAPModel);

		createActions();

		ui.managedView->setModel(m_ManagedAPProxyModel);
		ui.availableView->setModel(m_AvailableAPProxyModel);

		ui.managedView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
		ui.availableView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);

		updateUi(m_Device->getState());

		ui.managedView->header()->setMinimumSectionSize(-1);
		ui.availableView->header()->setMinimumSectionSize(-1);

		connect(m_Device, &CDevice::stateChanged, this, &CWirelessSettings::updateUi);

		connect(ui.managedView->selectionModel(), &QItemSelectionModel::selectionChanged,
			this, &CWirelessSettings::handleManagedAPSelectionChanged);

		connect(ui.availableView, &QAbstractItemView::doubleClicked, this, &CWirelessSettings::addNetwork);
		connect(ui.managedView, &QAbstractItemView::doubleClicked, this, &CWirelessSettings::switchToSelectedNetwork);

		connect(ui.availableAPFilterEdit, &QLineEdit::textChanged, m_AvailableAPProxyModel, &CAvailableAPProxyModel::setFilterWildcard);

		connect(m_Device->getWireless()->getHardware(), &CWirelessHW::signalQualityUpdated,
			this, &CWirelessSettings::updateSignalInfo);

		connect(m_AvailableAPModel, &CAvailableAPModel::cachedScansUpdated, this, &CWirelessSettings::updateBSSIDMenu);
	}
Exemplo n.º 4
0
::fwActivities::registry::ActivityInfo SCreateActivity::show( const ActivityInfoContainer& infos )
{
    QWidget* parent = qApp->activeWindow();

    QDialog* dialog = new QDialog(parent);
    dialog->setWindowTitle(QString::fromStdString("Choose an activity"));
    dialog->resize(600, 400);

    QStandardItemModel* model = new QStandardItemModel(dialog);
    for( const ::fwActivities::registry::ActivityInfo& info :  infos)
    {
        std::string text;
        if(info.title.empty())
        {
            text = info.id;
        }
        else
        {
            text = info.title + (info.description.empty() ? "" : "\n" + info.description);
        }

        QStandardItem* item = new QStandardItem(QIcon(info.icon.c_str()), QString::fromStdString(text));
        item->setData(QVariant::fromValue(info));
        item->setEditable(false);
        model->appendRow(item);
    }

    QListView* selectionList = new QListView();
    selectionList->setIconSize(QSize(40, 40));
    selectionList->setUniformItemSizes(true);
    selectionList->setModel(model);

    QModelIndex index = model->index( 0, 0 );
    if ( index.isValid() )
    {
        selectionList->selectionModel()->select( index, QItemSelectionModel::Select );
    }

    QPushButton* okButton     = new QPushButton("Ok");
    QPushButton* cancelButton = new QPushButton("Cancel");

    QHBoxLayout* hLayout = new QHBoxLayout();
    hLayout->addWidget(okButton);
    hLayout->addWidget(cancelButton);

    QVBoxLayout* vLayout = new QVBoxLayout();
    vLayout->addWidget(selectionList);
    vLayout->addLayout(hLayout);

    dialog->setLayout(vLayout);
    QObject::connect(okButton, SIGNAL(clicked()), dialog, SLOT(accept()));
    QObject::connect(cancelButton, SIGNAL(clicked()), dialog, SLOT(reject()));
    QObject::connect(selectionList, SIGNAL(doubleClicked(const QModelIndex&)), dialog, SLOT(accept()));

    ::fwActivities::registry::ActivityInfo info;
    if(dialog->exec())
    {
        QModelIndex currentIndex = selectionList->selectionModel()->currentIndex();
        QStandardItem* item      = model->itemFromIndex( currentIndex );
        QVariant var             = item->data();
        info = var.value< ::fwActivities::registry::ActivityInfo >();
    }

    return info;
}