void ProjectChangesModel::addProject(IProject* p)
{
    QStandardItem* it = new QStandardItem(p->name());
    it->setData(p->name(), ProjectChangesModel::ProjectNameRole);
    IPlugin* plugin = p->versionControlPlugin();
    if(plugin) {
        IBasicVersionControl* vcs = plugin->extension<IBasicVersionControl>();

        auto info = ICore::self()->pluginController()->pluginInfo(plugin);

        it->setIcon(QIcon::fromTheme(info.iconName()));
        it->setToolTip(vcs->name());

        IBranchingVersionControl* branchingExtension = plugin->extension<KDevelop::IBranchingVersionControl>();
        if(branchingExtension) {
            const auto pathUrl = p->path().toUrl();
            branchingExtension->registerRepositoryForCurrentBranchChanges(pathUrl);
            // can't use new signal slot syntax here, IBranchingVersionControl is not a QObject
            connect(plugin, SIGNAL(repositoryBranchChanged(QUrl)), this, SLOT(repositoryBranchChanged(QUrl)));
            repositoryBranchChanged(pathUrl);
        } else
            reload(QList<IProject*>() << p);
    } else {
        it->setEnabled(false);
    }
    
    appendRow(it);
}
Beispiel #2
0
void PluginsDialog::appendInfo(const LiteApi::PluginInfo *info)
{
    if (!info) {
        return;
    }
    QList<QStandardItem*> items;
    items.append(new QStandardItem(info->name()));
    QStandardItem *load = new QStandardItem();
    load->setCheckable(true);
    load->setData(info->id());
    if (info->isMustLoad()) {
        load->setEnabled(false);
    }
    bool b = m_liteApp->settings()->value(QString("liteapp/%1_load").arg(info->id()),true).toBool();
    if (b) {
        load->setCheckState(Qt::Checked);
    } else {
        load->setCheckState(Qt::Unchecked);
    }
    items.append(load);
    items.append(new QStandardItem(info->info()));
    items.append(new QStandardItem(info->author()));
    items.append(new QStandardItem(info->ver()));
    items.append(new QStandardItem(QFileInfo(info->filePath()).fileName()));
    items.at(5)->setToolTip(info->filePath());
    m_model->appendRow(items);
}
Beispiel #3
0
void SoundThemeSelector::fillModel(const SoundTheme &theme)
{
	QStringList headers;
	headers.append(QT_TRANSLATE_NOOP("Notifications", "Type"));
	headers.append(QT_TRANSLATE_NOOP("SoundTheme", "Preview"));
	m_model->setHorizontalHeaderLabels(headers);

	for (int i = 0; i <= Notification::LastType; ++i) {
		Notification::Type type = static_cast<Notification::Type>(i);
		QList<QStandardItem *> items;

		QStandardItem *item = new QStandardItem(Notification::typeString(type));
		item->setToolTip(QT_TRANSLATE_NOOP("SoundTheme","Type"));
		item->setSelectable(false);
		items << item;

		item = new QStandardItem();
		item->setEditable(false);
		item->setIcon(Icon("media-playback-start"));
		item->setToolTip(QT_TRANSLATE_NOOP("SoundTheme","Play"));
		item->setEnabled(!theme.path(type).isNull());
		item->setSelectable(false);
		items << item;

		m_model->appendRow(items);
	}
	ui->treeView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
}
Beispiel #4
0
QStandardItem *ResultsTree::CreateCheckboxItem(bool checked)
{
    QStandardItem *item = new QStandardItem;
    item->setCheckable(true);
    item->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
    item->setEnabled(false);
    return item;
}
void DefaultFilterModel::addSeparator(const QString &caption)
{
    QList<QStandardItem *> newRow;
    QStandardItem *item = new QStandardItem(caption);
    item->setEnabled(false);
    item->setData(true, SeparatorRole);

    newRow << item;
    appendRow(newRow);
}
Beispiel #6
0
DirKnot * HPSKnotDirModel::creatNewDeactiveKnot(const QString &name, const bool isExpanded)
{
    DirKnot *newKnot = new DirKnot();
    newKnot->name = name;

    QStandardItem *newItem = new QStandardItem(name);
    newItem->setEnabled(false);
    newItem->setData(isExpanded,Qt::UserRole+1);
    newKnot->item = newItem;

    return newKnot;
}
FlightVisualization::FlightVisualization(QWidget * parent) :
    QWidget(parent), ui(new Ui::Form)
{
    ui->setupUi(this);
    popupPlaneSelector = new QListWidget();
    popupPlaneSelector->setWindowTitle(POPUP_SELECTOR_TITLE);
    QListWidgetItem * item = new QListWidgetItem(ALL_PLANES_LABEL,
            popupPlaneSelector);

    item->setCheckState(Qt::Checked);
    popupPlaneSelector->addItem(item);

    connect(ui -> flightPathCheckBox, SIGNAL(stateChanged(int)), this, SLOT(toggleFlightPath(int)));
    connect(ui -> wayPointCheckBox, SIGNAL(stateChanged(int)), this, SLOT(toggleWayPoints(int)));
    connect(ui -> webView, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
    connect(ui -> autoCenterCheckBox, SIGNAL(stateChanged(int)), this, SLOT(toggleAutoCenter(int)));
    connect(ui -> autoFitCheckBox, SIGNAL(stateChanged(int)), this, SLOT(toggleAutoFit(int)));
    connect(ui->resetFlightPathButton, SIGNAL(clicked()), this,
            SLOT(resetFlightPaths()));
    connect(ui -> planeSelectorComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentPlane(int)));
    connect(ui->selectPlaneButton, SIGNAL(clicked()), this,
            SLOT(showPlaneSelector()));
    connect(popupPlaneSelector, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(togglePlaneVisibility(QListWidgetItem*)));
    QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled,
            true);
    ui->webView->setUrl(VIZ_MAP_URL);

    // http://stackoverflow.com/questions/12523753/sleep-inside-a-loop-that-uses-paintevent-in-qt-c
    connect(&_timer, SIGNAL(timeout()), this, SLOT(adjustMapCenter()));

    _timer.start(AUTO_CENTER_DURATION);

    //initialize everything in the active planes to the defaults. There is probably a better/more efficienct way to initialize the struct, but I was short on time.
    for (int i = 0; i < TOTAL_NUM_OF_PLANES; i++) {
        activePlanes[i].planeActive = false;
        activePlanes[i].latitude = 0;
        activePlanes[i].longitude = 0;
    }

    firstMessage = true;
    autoFitMap = false;
    currentPlane = INVALID_PLANE_ID;

    // prevent "select a plane" from being selectable
    QStandardItemModel * model = qobject_cast<QStandardItemModel *>(
                                     ui->planeSelectorComboBox->model());
    QModelIndex firstIndex = model->index(0,
                                          ui->planeSelectorComboBox->modelColumn(),
                                          ui->planeSelectorComboBox->rootModelIndex());
    QStandardItem * firstItem = model->itemFromIndex(firstIndex);
    firstItem->setEnabled(false);
}
void PluginDialog::addDefaultNodes()
{
    QList<QStandardItem *> rowItems;
    QStandardItem* scItem = new QStandardItem(QIcon(":/uploaders/screencloud.png"), "ScreenCloud");
    scItem->setData("screencloud", Qt::UserRole);
    //scItem->setEnabled(false);
    rowItems << scItem;
    QStandardItem* enableItem = new QStandardItem("");
    enableItem->setCheckable(true);
    enableItem->setCheckState(Qt::Checked);
    enableItem->setEnabled(false);
    rowItems << enableItem;
    categoryOnline->appendRow(rowItems);
}
Beispiel #9
0
InterceptWidget::InterceptWidget(IntercepSource * source, QWidget *parent) :
    QWidget(parent),
    source(source)
{
    currentBlockSource = NULL;
    currentGui = NULL;
    ui = new(std::nothrow) Ui::InterceptWidget;
    if (ui == NULL) {
        qFatal("Cannot allocate memory for Ui::InterceptWidget X{");
    }
    ui->setupUi(this);

    packetsTable = new(std::nothrow) QTableView(this);
    if (packetsTable == NULL) {
        qFatal("Cannot allocate memory for QTableView X{");
    }
    QAbstractItemModel *old = packetsTable->model();
    model = source->getModel();
    packetsTable->setModel(model);
    delete old;

    packetsTable->setSelectionMode(QAbstractItemView::ContiguousSelection);
    packetsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
    packetsTable->verticalHeader()->setFont(RegularFont);
    packetsTable->horizontalHeader()->setFont(RegularFont);
    packetsTable->setColumnWidth(PayloadModel::TIMESPTAMP_COLUMN,TIMESTAMP_COLUMN_WIDTH);
    packetsTable->setColumnWidth(PayloadModel::DIRECTION_COLUMN,25);
    packetsTable->verticalHeader()->setDefaultSectionSize(20);
#if QT_VERSION >= 0x050000
    packetsTable->horizontalHeader()->setSectionsMovable( false );
#else
    packetsTable->horizontalHeader()->setMovable(true);
#endif
    connect(packetsTable->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(onCurrentSelectedChanged(QModelIndex,QModelIndex)));
    ui->listLayout->addWidget(packetsTable);

    updateColumns();

    sourceChoices << CHOOSE_TEXT << UDP_EXTERNAL_SOURCE_TEXT << TCP_EXTERNAL_SOURCE_TEXT << RAW_TCP_SOURCE_TEXT;
    ui->blockSourceComboBox->addItems(sourceChoices);
    ui->blockSourceComboBox->setCurrentIndex(0);
    QStandardItem * item = qobject_cast<QStandardItemModel *>(ui->blockSourceComboBox->model())->item(0);
    item->setEnabled( false );
    item->setTextAlignment(Qt::AlignCenter);
    item->setBackground(Qt::darkGray);
    item->setForeground(Qt::white);

    connect(ui->blockSourceComboBox, SIGNAL(currentIndexChanged(QString)), SLOT(onSourceChanged(QString)));
}
Beispiel #10
0
void BarPackageModel::load(const QVariantList &datas)
{
clear();
setHorizontalHeaderLabels(QStringList()<<"application"<<"version");


foreach ( QVariant item, datas)
{


    QString rawName =item.toMap().value("name").toString();
    QString id =item.toMap().value("id").toString();
    QString version =item.toMap().value("version").toString();


    QStringList names = rawName.remove(id.replace("-",".")).split(".");




    QString name = names[names.length()-2];

    QStandardItem * nameItem = new QStandardItem(0);
    nameItem->setData(item);
    nameItem->setText(name);
    nameItem->setIcon(QIcon(":app.png"));
    if (rawName.contains("sys"))
    nameItem->setEnabled(false);

    QStandardItem * versionItem = new QStandardItem(1);
    versionItem->setText(version);

    QList<QStandardItem*> items;
    items.append(nameItem);
    items.append(versionItem);

    appendRow(items);




}
OrchestratorChooser::OrchestratorChooser(GuiHelper *guiHelper, SourcesOrchestatorAbstract *orchestrator, QWidget *parent) :
    QComboBox(parent),
    orchestrator(orchestrator),
    guiHelper(guiHelper)
{

    addItem(tr("Select IO type"));
    QStandardItem * item = qobject_cast<QStandardItemModel *>(model())->item(0); // there is one and only one item right now
    item->setEnabled( false );
    addItems(SourcesOrchestatorAbstract::OrchestratorsList);

    setToolTip(tr("Select a configuration"));

    if (orchestrator != nullptr) {
        setCurrentIndex(orchestrator->getType());
    }

    //connect(this, qOverload<int>(&OrchestratorChooser::currentIndexChanged), this, &OrchestratorChooser::onSelection);
    connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelection(int)));
}
void repo::gui::RepoDialogUserManager::addUser(const core::RepoUser &user)
{
    QList<QStandardItem *> row;
    //--------------------------------------------------------------------------
    // User object itself
    QVariant var;
    var.setValue(user);

    QStandardItem *item = new QStandardItem();
    item->setData(var);
    item->setEnabled(true);
    item->setCheckable(true);
    item->setCheckState(Qt::Checked);
    item->setTristate(false);
    item->setEditable(false);
    row.append(item);

    // Username
    row.append(createItem(QString::fromStdString(user.getUsername())));

    // First Name
    row.append(createItem(QString::fromStdString(user.getFirstName())));

    // Last Name
    row.append(createItem(QString::fromStdString(user.getLastName())));

    // Email
    row.append(createItem(QString::fromStdString(user.getEmail())));

    // Projects count
    row.append(createItem((qulonglong)(user.getProjectsList().size())));

    // Groups count
    row.append(createItem((qulonglong)(user.getGroupsList().size())));

    // Roles count
    row.append(createItem((qulonglong)(user.getRolesList().size())));

    //--------------------------------------------------------------------------
    model->invisibleRootItem()->appendRow(row);
}
Beispiel #13
0
DirKnot * HPSKnotDirModel::creatNewActiveKnot(const QString &name,bool hasFiles, const QString &path, const bool isExpanded)
{
    DirKnot *newKnot = new DirKnot();
    newKnot->name = name;
qDebug() << Q_FUNC_INFO << hasFiles;
    QStandardItem *newItem = new QStandardItem(name);
    newItem->setEnabled(true);
    newItem->setToolTip(QDir::toNativeSeparators(path));
    newItem->setData(isExpanded,Qt::UserRole+1);
    newItem->setData(QDir::fromNativeSeparators(path),Qt::UserRole);
    if(hasFiles){
        newKnot->hasFiles = true;
        newItem->setBackground(QBrush(QColor(0,255,0,40)));
    } else {
        newKnot->hasFiles = false;
        newItem->setBackground(QBrush(QColor(0,0,0,0)));
    }
    newKnot->item = newItem;

    return newKnot;
}
QgsMilXLibrary::QgsMilXLibrary( QgisInterface *iface, QWidget *parent )
    : QWidget( parent ), mIface( iface ), mLoader( 0 )
{
  setWindowFlags( Qt::Popup );
  setObjectName( "QgsMilXLibrary" );
  setStyleSheet( "QWidget#QgsMilXLibrary { background-color: white;}" );

  QVBoxLayout* layout = new QVBoxLayout( this );
  layout->setMargin( 2 );
  layout->setSpacing( 2 );
  setLayout( layout );

  mFilterLineEdit = new QgsFilterLineEdit( this );
  mFilterLineEdit->setPlaceholderText( tr( "Filter..." ) );
  layout->addWidget( mFilterLineEdit );
  connect( mFilterLineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( filterChanged( QString ) ) );

  mTreeView = new QTreeView( this );
  mTreeView->setFrameShape( QTreeView::NoFrame );
  mTreeView->setEditTriggers( QTreeView::NoEditTriggers );
  mTreeView->setHeaderHidden( true );
  mTreeView->setIconSize( QSize( 32, 32 ) );
  layout->addWidget( mTreeView );
  connect( mTreeView, SIGNAL( clicked( QModelIndex ) ), this, SLOT( itemClicked( QModelIndex ) ) );

  mGalleryModel = new QStandardItemModel( this );
  mFilterProxyModel = new TreeFilterProxyModel( this );
  mFilterProxyModel->setSourceModel( mGalleryModel );

  mLoadingModel = new QStandardItemModel( this );
  QStandardItem* loadingItem = new QStandardItem( tr( "Loading..." ) );
  loadingItem->setEnabled( false );
  mLoadingModel->appendRow( loadingItem );

  setCursor( Qt::WaitCursor );
  mTreeView->setModel( mLoadingModel );
  mLoader = new QgsMilXLibraryLoader( this );
  connect( mLoader, SIGNAL( finished() ), this, SLOT( loaderFinished() ) );
  mLoader->start();
}
Beispiel #15
0
QList<QStandardItem*> DkFileAssociationsPreference::getItems(const QString& filter, bool browse, bool reg) {

	QList<QStandardItem* > items;
	QStandardItem* item = new QStandardItem(filter);
	item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
	items.append(item);
	item = new QStandardItem("");
	//item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
	item->setCheckable(true);
	item->setCheckState(browse ? Qt::Checked : Qt::Unchecked);
	items.append(item);
	item = new QStandardItem("");
	//item->setFlags(Qt::Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
	item->setCheckable(true);
	item->setCheckState(reg ? Qt::Checked : Qt::Unchecked);
#ifndef Q_OS_WIN	// registering is windows only
	item->setEnabled(false);
#endif
	items.append(item);

	return items;

}
Beispiel #16
0
void TransformsGui::buildSavedCombo()
{
    ui->savedComboBox->blockSignals(true);
    ui->savedComboBox->clear();
    int row = 0;
    // first inactive element
    ui->savedComboBox->addItem(QString("User's chains"));
    QStandardItem * item = qobject_cast<QStandardItemModel *>(ui->savedComboBox->model())->item( row );
    item->setEnabled( false );
    item->setTextAlignment(Qt::AlignCenter);
    item->setBackground(Qt::darkGray);
    item->setForeground(Qt::white);
    // then the rest
    QHash<QString, QString> hash = transformFactory->getSavedConfs();
    QStringList list = hash.keys();
    if (list.isEmpty()) {
        ui->savedComboBox->setEnabled(false);
    } else {
        ui->savedComboBox->addItems(list);
        ui->savedComboBox->setEnabled(true);
    }

    ui->savedComboBox->blockSignals(false);
}
Beispiel #17
0
QWidget *TTriadEditor::buildPage1()
{
	QWidget *ret = new QWidget(this);

	QFont font;
	font.setPointSize(10);

	cardE_model = new QStandardItemModel(ret);
	cardE_view = new QTreeView(ret);
	cardE_view->setModel(cardE_model);
	cardE_view->setEditTriggers(QAbstractItemView::DoubleClicked);
	cardE_view->setFont(font);
	cardE_view->setItemDelegate(new SpinBoxDelegate(ret));
	cardE_view->setIndentation(0);
	cardE_view->setItemsExpandable(false);
	cardE_view->header()->setStretchLastSection(false);
	cardE_view->setUniformRowHeights(true);
	cardE_view->setAllColumnsShowFocus(true);

	cardE_model2 = new QStandardItemModel(ret);
	cardE_view2 = new QTreeView(ret);
	cardE_view2->setModel(cardE_model2);
	cardE_view2->setEditTriggers(QAbstractItemView::DoubleClicked);
	cardE_view2->setFont(font);
	cardE_view2->setItemDelegate(new SpinBoxDelegate(ret));
	cardE_view2->setIndentation(0);
	cardE_view2->setItemsExpandable(false);
	cardE_view2->header()->setStretchLastSection(false);
	cardE_view2->setUniformRowHeights(true);
	cardE_view2->setAllColumnsShowFocus(true);

	QStringList labels;
	QStandardItem *standardItem;
	QIcon cardIcon(":/images/icons/carte.png");

	labels << tr("Nom") << tr("Qté");
	cardE_model->setHorizontalHeaderLabels(labels);

	for(quint8 i=0 ; i<77 ; ++i)
	{
		if(i % 11 == 0) {
			QList<QStandardItem *> items;

			standardItem = new QStandardItem(tr("Niveau %1").arg(i/11 + 1));
			standardItem->setEditable(false);
			standardItem->setEnabled(false);
			standardItem->setCheckable(false);
			standardItem->setData(-1, Qt::UserRole+2);
			items.append(standardItem);

			standardItem = new QStandardItem();
			standardItem->setEditable(false);
			standardItem->setEnabled(false);
			standardItem->setCheckable(false);
			standardItem->setData(-1, Qt::UserRole+2);
			items.append(standardItem);

			cardE_model->appendRow(items);
		}

		QList<QStandardItem *> items;

		standardItem = new QStandardItem(Data::cards().at(i));
		standardItem->setEditable(false);
		standardItem->setCheckable(true);
		standardItem->setIcon(cardIcon);
		standardItem->setData(i, Qt::UserRole+2);
		items.append(standardItem);

		standardItem = new QStandardItem();
		standardItem->setData(i, Qt::UserRole+2);
		standardItem->setData(SpinBoxDelegate::SpinBox127, Qt::UserRole);
		items.append(standardItem);

		cardE_model->appendRow(items);
	}

	cardE_view->header()->HEADER_VIEW_SET_RESIZE_MODE(0, QHeaderView::Stretch);
	cardE_view->header()->HEADER_VIEW_SET_RESIZE_MODE(1, QHeaderView::ResizeToContents);

	labels.replace(1, tr("Possesseur"));
	cardE_model2->setHorizontalHeaderLabels(labels);

	for(quint8 i=0 ; i<33 ; ++i)
	{
		if(i % 11 == 0) {
			QList<QStandardItem *> items;

			standardItem = new QStandardItem(tr("Niveau %1").arg(i/11 + 8));
			standardItem->setEditable(false);
			standardItem->setEnabled(false);
			standardItem->setCheckable(false);
			standardItem->setData(-1, Qt::UserRole+2);
			items.append(standardItem);

			standardItem = new QStandardItem();
			standardItem->setEditable(false);
			standardItem->setEnabled(false);
			standardItem->setCheckable(false);
			standardItem->setData(-1, Qt::UserRole+2);
			items.append(standardItem);

			cardE_model2->appendRow(items);
		}

		QList<QStandardItem *> items;

		standardItem = new QStandardItem(Data::cards().at(77+i));
		standardItem->setEditable(false);
		standardItem->setCheckable(true);
		standardItem->setIcon(cardIcon);
		standardItem->setData(i, Qt::UserRole+2);
		items.append(standardItem);

		standardItem = new QStandardItem();
		standardItem->setData(i, Qt::UserRole+2);
		standardItem->setData(SpinBoxDelegate::ComboBoxLocations, Qt::UserRole);
		items.append(standardItem);

		cardE_model2->appendRow(items);
	}

	cardE_view2->header()->HEADER_VIEW_SET_RESIZE_MODE(0, QHeaderView::ResizeToContents);
	cardE_view2->header()->HEADER_VIEW_SET_RESIZE_MODE(1, QHeaderView::Stretch);

	font.setPixelSize(10);
	QString selectAll = tr("Sélectionner tout");
	QCheckBox *selectAll1 = new QCheckBox(selectAll, ret);
	QCheckBox *selectAll2 = new QCheckBox(selectAll, ret);
	selectAll1->setFont(font);
	selectAll2->setFont(font);
	QWidget *qtyAll = new QWidget;
	QPushButton *qtyAllOK = new QPushButton(tr("Tout"), qtyAll);
	QPushButton *squallAll = new QPushButton(tr("Squall"), ret);
	qtyAllOK->setFont(font);
	squallAll->setFont(font);
	qtyAllSpin = new QSpinBox(qtyAll);
	qtyAllSpin->setRange(0, 127);
	QHBoxLayout *qtyLayout = new QHBoxLayout(qtyAll);
	qtyLayout->addWidget(qtyAllSpin, 1);
	qtyLayout->addWidget(qtyAllOK);
	qtyLayout->setContentsMargins(QMargins());

	cardPreview = new QLabel(ret);
	setCardPreview(110);

	connect(selectAll1, SIGNAL(toggled(bool)), SLOT(selectAll1(bool)));
	connect(selectAll2, SIGNAL(toggled(bool)), SLOT(selectAll2(bool)));
	connect(qtyAllOK, SIGNAL(released()), SLOT(qtyAll()));
	connect(squallAll, SIGNAL(released()), SLOT(squallAll()));
	connect(cardE_view->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(changeCardPreview()));
	connect(cardE_view2->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(changeCardPreview2()));

	HelpWidget *info = new HelpWidget(16, tr("<b>Case cochée :</b> carte connue<br/><b>Possesseur :</b> joueur "
											 "possédant la carte rare, mettre Squall pour l'avoir dans votre jeu."), ret);

	QGridLayout *layout = new QGridLayout(ret);
	layout->addWidget(info, 0, 2, 2, 1, Qt::AlignTop);
	layout->addWidget(cardPreview, 0, 3, 2, 1, Qt::AlignRight);
	layout->addWidget(cardE_view, 0, 0, 3, 2);
	layout->addWidget(selectAll1, 3, 0, Qt::AlignLeft);
	layout->addWidget(qtyAll, 3, 1, Qt::AlignRight);
	layout->addWidget(cardE_view2, 2, 2, 1, 2);
	layout->addWidget(selectAll2, 3, 2, Qt::AlignLeft);
	layout->addWidget(squallAll, 3, 3, Qt::AlignRight);

	return ret;
}
Beispiel #18
0
void tst_QStandardItem::getSetFlags()
{
    QStandardItem item;
    item.setEnabled(true);
    QVERIFY(item.isEnabled());
    QVERIFY(item.flags() & Qt::ItemIsEnabled);
    item.setEditable(true);
    QVERIFY(item.isEditable());
    QVERIFY(item.flags() & Qt::ItemIsEditable);
    item.setSelectable(true);
    QVERIFY(item.isSelectable());
    QVERIFY(item.flags() & Qt::ItemIsSelectable);
    item.setCheckable(true);
    QVERIFY(item.isCheckable());
    QCOMPARE(item.checkState(), Qt::Unchecked);
    QVERIFY(item.flags() & Qt::ItemIsUserCheckable);
    item.setTristate(true);
    QVERIFY(item.isTristate());
    QVERIFY(item.flags() & Qt::ItemIsTristate);
#ifndef QT_NO_DRAGANDDROP
    item.setDragEnabled(true);
    QVERIFY(item.isDragEnabled());
    QVERIFY(item.flags() & Qt::ItemIsDragEnabled);
    item.setDropEnabled(true);
    QVERIFY(item.isDropEnabled());
    QVERIFY(item.flags() & Qt::ItemIsDropEnabled);
#endif
    
    QVERIFY(item.isEnabled());
    item.setEnabled(false);
    QVERIFY(!item.isEnabled());
    QVERIFY(!(item.flags() & Qt::ItemIsEnabled));
    QVERIFY(item.isEditable());
    item.setEditable(false);
    QVERIFY(!item.isEditable());
    QVERIFY(!(item.flags() & Qt::ItemIsEditable));
    QVERIFY(item.isSelectable());
    item.setSelectable(false);
    QVERIFY(!item.isSelectable());
    QVERIFY(!(item.flags() & Qt::ItemIsSelectable));
    QVERIFY(item.isCheckable());
    item.setCheckable(false);
    QVERIFY(!item.isCheckable());
    QVERIFY(!(item.flags() & Qt::ItemIsUserCheckable));
    QVERIFY(item.isTristate());
    item.setTristate(false);
    QVERIFY(!item.isTristate());
    QVERIFY(!(item.flags() & Qt::ItemIsTristate));
#ifndef QT_NO_DRAGANDDROP
    QVERIFY(item.isDragEnabled());
    item.setDragEnabled(false);
    QVERIFY(!item.isDragEnabled());
    QVERIFY(!(item.flags() & Qt::ItemIsDragEnabled));
    QVERIFY(item.isDropEnabled());
    item.setDropEnabled(false);
    QVERIFY(!item.isDropEnabled());
    QVERIFY(!(item.flags() & Qt::ItemIsDropEnabled));
#endif

    item.setCheckable(false);
    item.setCheckState(Qt::Checked);
    item.setCheckable(true);
    QCOMPARE(item.checkState(), Qt::Checked);
}    
Beispiel #19
0
void StitcherWorkspace::loadGeometry() {
    /*
       This is a prefix to distinguish Hawk Geometry properties from the
       normal widget properties
    */
    const QString tag("HawkGeometry_");
    QList<QGraphicsItem *> ii  = _stitcherView->items();
    QMap<QString,ImageItem *> sortMap;
    for(int i = 0; i<ii.size(); i++) {
        if(ImageItem * imageItem = qgraphicsitem_cast<ImageItem *>(ii[i])) {
            if(imageItem->isVisible()) {
                sortMap.insert(imageItem->identifier(),imageItem);
            }
        }
    }
    QList<ImageItem *>sortedItems = sortMap.values();
    QStandardItemModel * model = qobject_cast<QStandardItemModel *>(geometryTree->model());
    model->clear();
    model->setHorizontalHeaderLabels(QStringList() << "Parameter" << "Value" << "Locked");

    for(int i = 0; i<sortedItems.size(); i++) {
        ImageItem * imageItem = sortedItems[i];
        const QMetaObject *metaobject =  imageItem->metaObject();
        int count = metaobject->propertyCount();
        QStandardItem * itemName = new QStandardItem(imageItem->identifier());
        QStandardItem * itemValue = new QStandardItem();
        QStandardItem * itemLocked = new QStandardItem();
        itemLocked->setFlags(itemLocked->flags() & ~Qt::ItemIsEditable);
        QStandardItem *parentItem = model->invisibleRootItem();
        itemName->setFlags(itemName->flags() & ~Qt::ItemIsEditable);
        itemValue->setFlags(itemValue->flags() & ~Qt::ItemIsEditable);
        if(model->findItems(itemName->text()).empty()) {
            parentItem->appendRow(QList<QStandardItem *>() << itemName <<  itemValue << itemLocked);
            parentItem = itemName;
        } else {
            parentItem = model->findItems(itemName->text()).first();
        }
        for (int j=0; j<count; ++j) {
            QMetaProperty metaproperty = metaobject->property(j);
            const char *name = metaproperty.name();
            if(!QString(name).startsWith(tag)) {
                continue;
            }
            QVariant var =  imageItem->property(name);
            Qt::ItemFlags itemValueFlags = Qt::ItemIsSelectable|Qt::ItemIsEnabled;
            if(metaproperty.isWritable()) {
                itemValueFlags |= Qt::ItemIsEditable;
            }
            if(var.type() == QVariant::Double) {
                double value = var.toDouble();
                if(QString(name).endsWith("_theta") || QString(name).endsWith("_alpha")) {
                    /* convert to degrees */
                    value *= 180/M_PI;
                }
                if(QString(name).endsWith("_dy")) {
                    /* swap axis */
                    value = -value;
                }
                QStandardItem * itemName = new QStandardItem(_stitcherView->propertyNameToDisplayName(name,tag));
                QStandardItem * itemValue = new QStandardItem(QString("%0").arg(value));
                itemValue->setData(value,Qt::UserRole + 1);
                itemValue->setData(QString(name),Qt::UserRole + 2);
                itemValue->setData(QVariant::fromValue(imageItem),Qt::UserRole + 3);
                itemName->setFlags(itemName->flags() & ~Qt::ItemIsEditable);
                itemValue->setFlags(itemValueFlags);
                QStandardItem * itemLocked = new QStandardItem();
                itemLocked->setFlags(itemLocked->flags() & ~Qt::ItemIsEditable);
                /* check for lock property */
                QString lockedPropertyName = name + QString("_locked");
                if(imageItem->property(lockedPropertyName.toAscii().data()).isValid()) {
                    bool locked = imageItem->property(lockedPropertyName.toAscii().data()).toBool();
                    itemLocked->setCheckable(true);
                    itemLocked->setData(locked,Qt::UserRole + 1);
                    itemLocked->setData(QString(lockedPropertyName),Qt::UserRole + 2);
                    itemLocked->setData(QVariant::fromValue(imageItem),Qt::UserRole + 3);
                    if(locked) {
                        itemLocked->setCheckState(Qt::Checked);
                        itemValue->setEnabled(false);
                    }
                }
                /* Temporarily disable Dz and Alpha */
                if(itemName->text() == "Dz" ||
                        itemName->text() == "Alpha") {
                    itemLocked->setCheckState(Qt::Checked);
                    itemName->setEnabled(false);
                    itemValue->setEnabled(false);
                    itemLocked->setEnabled(false);
                    itemName->setToolTip("Currently disabled");
                    itemValue->setToolTip("Currently disabled");
                    itemLocked->setToolTip("Currently disabled");
                }
                parentItem->appendRow(QList<QStandardItem *>() << itemName << itemValue << itemLocked);
            }
        }
    }
    geometryTree->expandAll();
    geometryTree->resizeColumnToContents(0);
    geometryTree->sortByColumn(0,Qt::AscendingOrder);
}
void PreferencesDialog::InitChanInfo()
{
    QHash<MachineType, int> toprows;

    chanModel->clear();
    toplevel.clear();
    toprows.clear();
    QStringList headers;
    headers.append(tr("Name"));
    headers.append(tr("Color"));
    headers.append(tr("Overview"));
    headers.append(tr("Flag Type"));
    headers.append(tr("Label"));
    headers.append(tr("Details"));
    chanModel->setHorizontalHeaderLabels(headers);
    ui->chanView->setColumnWidth(0, 200);
    ui->chanView->setColumnWidth(1, 40);
    ui->chanView->setColumnWidth(2, 60);
    ui->chanView->setColumnWidth(3, 100);
    ui->chanView->setColumnWidth(4, 100);
    ui->chanView->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->chanView->setSelectionBehavior(QAbstractItemView::SelectItems);

    chanModel->setColumnCount(6);

    QStandardItem *hdr = nullptr;

    QMap<MachineType, QString> Section;

    Section[MT_CPAP] = tr("CPAP Events");
    Section[MT_OXIMETER] = tr("Oximeter Events");
    Section[MT_POSITION] = tr("Positional Events");
    Section[MT_SLEEPSTAGE] = tr("Sleep Stage Events");
    Section[MT_UNCATEGORIZED] = tr("Unknown Events");

    QMap<MachineType, QString>::iterator it;

    QHash<QString, schema::Channel *>::iterator ci;

    for (it = Section.begin(); it != Section.end(); ++it) {
        toplevel[it.key()] = hdr = new QStandardItem(it.value());
        hdr->setEditable(false);
        QList<QStandardItem *> list;
        list.append(hdr);
        for (int i=0; i<5; i++) {
            QStandardItem *it = new QStandardItem();
            it->setEnabled(false);
            list.append(it);
        }
        chanModel->appendRow(list);
    }

    ui->chanView->setAlternatingRowColors(true);

    // ui->graphView->setFirstColumnSpanned(0,daily->index(),true); // Crashes on windows.. Why do I need this again?


    ComboBoxDelegate * combobox = new ComboBoxDelegate(ui->waveView);

    ui->chanView->setItemDelegateForColumn(3,combobox);

    int row = 0;
    for (ci = schema::channel.names.begin(); ci != schema::channel.names.end(); ci++) {
        schema::Channel * chan = ci.value();
        if ((chan->type() == schema::DATA) || (chan->type() == schema::SETTING) || chan->type() == schema::WAVEFORM) continue;

        QList<QStandardItem *> items;
        QStandardItem *it = new QStandardItem(chan->fullname());
        it->setCheckable(true);
        it->setCheckState(chan->enabled() ? Qt::Checked : Qt::Unchecked);
        it->setEditable(true);
        it->setData(chan->id(), Qt::UserRole);

        // Dear translators: %1 is a unique ascii english string used to indentify channels in the code, I'd like feedback on how this goes..
        // It's here in case users mess up which field is which.. it will always show the Channel Code underneath in the tooltip.
        it->setToolTip(tr("Double click to change the descriptive name the '%1' channel.").arg(chan->code()));
        items.push_back(it);


        it = new QStandardItem();
        it->setBackground(QBrush(chan->defaultColor()));
        it->setEditable(false);
        it->setData(chan->defaultColor().rgba(), Qt::UserRole);
        it->setToolTip(tr("Double click to change the default color for this channel plot/flag/data."));
        it->setSelectable(false);
        items.push_back(it);

        it = new QStandardItem(QString());
        it->setToolTip(tr("Whether this flag has a dedicated overview chart."));
        it->setCheckable(true);
        it->setCheckState(chan->showInOverview() ? Qt::Checked : Qt::Unchecked);
        it->setTextAlignment(Qt::AlignCenter);
        it->setData(chan->id(), Qt::UserRole);
        items.push_back(it);

        schema::ChanType type = chan->type();

        it = new QStandardItem(channeltype[type]);
        it->setToolTip(tr("Here you can change the type of flag shown for this event"));
        it->setEditable(type != schema::UNKNOWN);
        items.push_back(it);

        it = new QStandardItem(chan->label());
        it->setToolTip(tr("This is the short-form label to indicate this channel on screen."));

        it->setEditable(true);
        items.push_back(it);

        it = new QStandardItem(chan->description());
        it->setToolTip(tr("This is a description of what this channel does."));

        it->setEditable(true);
        items.push_back(it);

        MachineType mt = chan->machtype();
        if (chan->type() == schema::UNKNOWN) mt = MT_UNCATEGORIZED;
        row = toprows[mt]++;
        toplevel[mt]->insertRow(row, items);
    }


    for(QHash<MachineType, QStandardItem *>::iterator i = toplevel.begin(); i != toplevel.end(); ++i) {
        if (i.value()->rowCount() == 0) {
            chanModel->removeRow(i.value()->row());
        }
    }

    ui->chanView->expandAll();
    ui->chanView->setSortingEnabled(true);
}
void PreferencesDialog::InitWaveInfo()
{
    QHash<MachineType, int> toprows;

    waveModel->clear();
    machlevel.clear();
    toprows.clear();
    QStringList headers;
    headers.append(tr("Name"));
    headers.append(tr("Color"));
    headers.append(tr("Overview"));
    headers.append(tr("Lower"));
    headers.append(tr("Upper"));
    headers.append(tr("Label"));
    headers.append(tr("Details"));
    waveModel->setHorizontalHeaderLabels(headers);
    ui->waveView->setColumnWidth(0, 200);
    ui->waveView->setColumnWidth(1, 40);
    ui->waveView->setColumnWidth(2, 60);
    ui->waveView->setColumnWidth(3, 50);
    ui->waveView->setColumnWidth(4, 50);
    ui->waveView->setColumnWidth(5, 100);
    ui->waveView->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->waveView->setSelectionBehavior(QAbstractItemView::SelectItems);

    waveModel->setColumnCount(7);

    QStandardItem *hdr = nullptr;

    QMap<MachineType, QString> Section;

    Section[MT_CPAP] = tr("CPAP Waveforms");
    Section[MT_OXIMETER] = tr("Oximeter Waveforms");
    Section[MT_POSITION] = tr("Positional Waveforms");
    Section[MT_SLEEPSTAGE] = tr("Sleep Stage Waveforms");

    QMap<MachineType, QString>::iterator it;

    for (it = Section.begin(); it != Section.end(); ++it) {
        machlevel[it.key()] = hdr = new QStandardItem(it.value());
        hdr->setEditable(false);
        QList<QStandardItem *> list;
        list.append(hdr);
        for (int i=0; i<6; i++) {
            QStandardItem *it = new QStandardItem();
            it->setEnabled(false);
            list.append(it);
        }
        waveModel->appendRow(list);
    }

    ui->waveView->setAlternatingRowColors(true);

    // ui->graphView->setFirstColumnSpanned(0,daily->index(),true); // Crashes on windows.. Why do I need this again?

    QHash<QString, schema::Channel *>::iterator ci;

    SpinBoxDelegate * spinbox = new SpinBoxDelegate(ui->waveView);

    ui->waveView->setItemDelegateForColumn(3,spinbox);
    ui->waveView->setItemDelegateForColumn(4,spinbox);

    int row = 0;
    for (ci = schema::channel.names.begin(); ci != schema::channel.names.end(); ci++) {
        schema::Channel * chan = ci.value();
        if (chan->type() != schema::WAVEFORM) continue;

        QList<QStandardItem *> items;
        QStandardItem *it = new QStandardItem(chan->fullname());

        it->setCheckable(true);
        it->setCheckState(chan->enabled() ? Qt::Checked : Qt::Unchecked);
        it->setEditable(true);
        it->setData(chan->id(), Qt::UserRole);
        it->setToolTip(tr("Double click to change the descriptive name this channel."));
        items.push_back(it);

        it = new QStandardItem();
        it->setBackground(QBrush(chan->defaultColor()));
        it->setEditable(false);
        it->setData(chan->defaultColor().rgba(), Qt::UserRole);
        it->setToolTip(tr("Double click to change the default color for this channel plot/flag/data."));
        it->setSelectable(false);
        items.push_back(it);

        it = new QStandardItem();
        it->setCheckable(true);
        it->setCheckState(chan->showInOverview() ? Qt::Checked : Qt::Unchecked);
        it->setEditable(true);
        it->setData(chan->id(), Qt::UserRole);
        it->setToolTip(tr("Whether a breakdown of this waveform displays in overview."));
        items.push_back(it);


        it = new QStandardItem(QString::number(chan->lowerThreshold(),'f',1));
        it->setToolTip(tr("Here you can set the <b>lower</b> threshold used for certain calculations on the %1 waveform").arg(chan->fullname()));
        it->setEditable(true);
        items.push_back(it);

        it = new QStandardItem(QString::number(chan->upperThreshold(),'f',1));
        it->setToolTip(tr("Here you can set the <b>upper</b> threshold used for certain calculations on the %1 waveform").arg(chan->fullname()));
        it->setEditable(true);
        items.push_back(it);

        it = new QStandardItem(chan->label());
        it->setToolTip(tr("This is the short-form label to indicate this channel on screen."));

        it->setEditable(true);
        items.push_back(it);

        it = new QStandardItem(chan->description());
        it->setToolTip(tr("This is a description of what this channel does."));

        it->setEditable(true);
        items.push_back(it);

        row = toprows[chan->machtype()]++;
        machlevel[chan->machtype()]->insertRow(row, items);
    }

    for(QHash<MachineType, QStandardItem *>::iterator i = machlevel.begin(); i != machlevel.end(); ++i) {
        if (i.value()->rowCount() == 0) {
            waveModel->removeRow(i.value()->row());
        }
    }

    ui->waveView->expandAll();
    ui->waveView->setSortingEnabled(true);
}
void QgsPluginManager::getPythonPluginDescriptions()
{
  if ( !mPythonUtils || !mPythonUtils->isEnabled() )
    return;

  // look for plugins systemwide
  QStringList pluginList = mPythonUtils->pluginList();

  for ( int i = 0; i < pluginList.size(); i++ )
  {
    QString packageName = pluginList[i];

    // import plugin's package - skip loading it if an error occured
    if ( !mPythonUtils->loadPlugin( packageName ) )
      continue;

    // get information from the plugin
    QString pluginName  = mPythonUtils->getPluginMetadata( packageName, "name" );
    QString description = mPythonUtils->getPluginMetadata( packageName, "description" );
    QString category    = mPythonUtils->getPluginMetadata( packageName, "category" );
    QString version     = mPythonUtils->getPluginMetadata( packageName, "version" );
    QString iconName    = mPythonUtils->getPluginMetadata( packageName, "icon" );

    if ( pluginName == "__error__" || description == "__error__" || version == "__error__" )
      continue;

    // if there is no category in Python plugin assume default 'Plugins' category
    if ( category == "__error__" )
    {
      category = tr( "Plugins" );
    }

    bool isCompatible = QgsPluginRegistry::instance()->isPythonPluginCompatible( packageName );
    QString compatibleString; // empty by default
    if ( !isCompatible )
      compatibleString = "  " + tr( "[ incompatible ]" );

    // filtering will be done on the display role so give it name and desription
    // user wont see this text since we are using a custome delegate
    QStandardItem * mypDetailItem = new QStandardItem( pluginName + " - " + description );
    QString myLibraryName = "python:" + packageName;
    mypDetailItem->setData( myLibraryName, PLUGIN_LIBRARY_ROLE ); //for loading libs later
    mypDetailItem->setData( packageName, PLUGIN_BASE_NAME_ROLE ); //for matching in registry later
    mypDetailItem->setCheckable( false );
    mypDetailItem->setEditable( false );
    mypDetailItem->setEnabled( isCompatible );
    // setData in the delegate with a variantised QgsDetailedItemData
    QgsDetailedItemData myData;
    myData.setTitle( pluginName + " (" + version + ")" + compatibleString );
    myData.setEnabled( isCompatible );
    myData.setDetail( description );
    myData.setCategory( tr( "Installed in %1 menu/toolbar" ).arg( category ) );
    //myData.setIcon(pixmap); //todo use a python logo here
    myData.setCheckable( true );
    myData.setRenderAsWidget( false );
    myData.setChecked( false ); //start off assuming false
    if ( iconName == "__error__" )
      myData.setIcon( QPixmap( QgsApplication::defaultThemePath() + "/plugin.png" ) );
    else
    {
      bool relative = QFileInfo( iconName ).isRelative();
      if ( relative )
      {
        QString pluginDir;
        mPythonUtils->evalString( QString( "qgis.utils.pluginDirectory('%1')" ).arg( packageName ), pluginDir );
        iconName = pluginDir + "/" + iconName;
      }
      myData.setIcon( QPixmap( iconName ) );
    }

    // check to see if the plugin is loaded and set the checkbox accordingly
    QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance();
    if ( pRegistry->isLoaded( packageName ) && pRegistry->isPythonPlugin( packageName ) )
    {
      QgsDebugMsg( "Found plugin in the registry" );
      // set the checkbox
      myData.setChecked( true );
    }
    else
    {
      QgsDebugMsg( "Couldn't find plugin in the registry: " + packageName );
    }
    QVariant myVariant = qVariantFromValue( myData );
    mypDetailItem->setData( myVariant, PLUGIN_DATA_ROLE );
    // Add item to model
    mModelPlugins->appendRow( mypDetailItem );
  }
}