void FontWidget::openFontEditor(bool show) { if (show && m_fontDialog.isNull()) { m_fontDialog = new QFontDialog(); m_fontDialog->setAttribute(Qt::WA_DeleteOnClose); m_fontDialog->setCurrentFont(m_font); QComboBox *comboBox = m_fontDialog->findChild<QComboBox*>(); QList<QLabel*> labels = m_fontDialog->findChildren<QLabel*>(); foreach (QLabel *label, labels) if (label->buddy() == comboBox) label->hide(); comboBox->hide(); m_fontDialog->show(); connect(m_fontDialog.data(), SIGNAL(accepted()), SLOT(updateFont())); connect(m_fontDialog.data(), SIGNAL(destroyed(QObject*)), SLOT(resetFontButton())); } else {
void Tomahawk::EchonestControl::updateWidgets() { if( !m_input.isNull() ) delete m_input.data(); if( !m_match.isNull() ) delete m_match.data(); m_overrideType = -1; // make sure the widgets are the proper kind for the selected type, and hook up to their slots if( selectedType() == "Artist" ) { m_currentType = Echonest::DynamicPlaylist::Artist; QComboBox* match = new QComboBox(); QLineEdit* input = new QLineEdit(); match->addItem( tr( "Similar To" ), Echonest::DynamicPlaylist::ArtistRadioType ); match->addItem( tr( "Limit To" ), Echonest::DynamicPlaylist::ArtistType ); m_matchString = match->currentText(); m_matchData = match->itemData( match->currentIndex() ).toString(); input->setPlaceholderText( tr( "Artist name" ) ); input->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Fixed ); input->setCompleter( new QCompleter( QStringList(), input ) ); input->completer()->setCaseSensitivity( Qt::CaseInsensitive ); connect( match, SIGNAL( currentIndexChanged(int) ), this, SLOT( updateData() ) ); connect( match, SIGNAL( currentIndexChanged(int) ), this, SIGNAL( changed() ) ); connect( input, SIGNAL( textChanged(QString) ), this, SLOT( updateData() ) ); connect( input, SIGNAL( editingFinished() ), this, SLOT( editingFinished() ) ); connect( input, SIGNAL( textEdited( QString ) ), &m_editingTimer, SLOT( stop() ) ); connect( input, SIGNAL( textEdited( QString ) ), &m_delayedEditTimer, SLOT( start() ) ); connect( input, SIGNAL( textEdited( QString ) ), this, SLOT( artistTextEdited( QString ) ) ); match->hide(); input->hide(); m_match = QPointer< QWidget >( match ); m_input = QPointer< QWidget >( input ); m_data.first = m_currentType; }
void FileDescriptorWidget::initialize() { mpTreeWidget->clear(); mpGcpTree->clear(); mpGcpGroup->hide(); if (mpFileDescriptor == NULL) { return; } // Filename QTreeWidgetItem* pFilenameItem = new QTreeWidgetItem(mpTreeWidget); if (pFilenameItem != NULL) { string filename = mpFileDescriptor->getFilename(); pFilenameItem->setText(0, "Filename"); pFilenameItem->setText(1, QString::fromStdString(filename)); } // Data set location QTreeWidgetItem* pDatasetLocationItem = new QTreeWidgetItem(mpTreeWidget); if (pDatasetLocationItem != NULL) { string datasetLocation = mpFileDescriptor->getDatasetLocation(); pDatasetLocationItem->setText(0, "Data Set Location"); pDatasetLocationItem->setText(1, QString::fromStdString(datasetLocation)); } // Endian QTreeWidgetItem* pEndianItem = new QTreeWidgetItem(mpTreeWidget); if (pEndianItem != NULL) { EndianType endian = mpFileDescriptor->getEndian(); string endianText = StringUtilities::toDisplayString(endian); pEndianItem->setText(0, "Endian"); pEndianItem->setText(1, QString::fromStdString(endianText)); if (mReadOnly == false) { QComboBox* pEndianCombo = new QComboBox(mpTreeWidget); pEndianCombo->setEditable(false); pEndianCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(LITTLE_ENDIAN_ORDER))); pEndianCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(BIG_ENDIAN_ORDER))); pEndianCombo->hide(); mpTreeWidget->setCellWidgetType(pEndianItem, 1, CustomTreeWidget::COMBO_BOX); mpTreeWidget->setComboBox(pEndianItem, 1, pEndianCombo); } } // Raster element file descriptor items RasterFileDescriptor* pRasterDescriptor = dynamic_cast<RasterFileDescriptor*>(mpFileDescriptor); if (pRasterDescriptor == NULL) { return; } mpGcpGroup->show(); // Rows QTreeWidgetItem* pRowsItem = new QTreeWidgetItem(); if (pRowsItem != NULL) { unsigned int rows = pRasterDescriptor->getRowCount(); pRowsItem->setText(0, "Rows"); pRowsItem->setText(1, QString::number(rows)); mpTreeWidget->insertTopLevelItem(2, pRowsItem); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pRowsItem, 1, CustomTreeWidget::LINE_EDIT); } } // Columns QTreeWidgetItem* pColumnsItem = new QTreeWidgetItem(); if (pColumnsItem != NULL) { unsigned int columns = pRasterDescriptor->getColumnCount(); pColumnsItem->setText(0, "Columns"); pColumnsItem->setText(1, QString::number(columns)); mpTreeWidget->insertTopLevelItem(3, pColumnsItem); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pColumnsItem, 1, CustomTreeWidget::LINE_EDIT); } } // Bits per element QTreeWidgetItem* pBitsPerElementItem = new QTreeWidgetItem(); if (pBitsPerElementItem != NULL) { unsigned int bitsPerElement = pRasterDescriptor->getBitsPerElement(); pBitsPerElementItem->setText(0, "Bits Per Element"); pBitsPerElementItem->setText(1, QString::number(bitsPerElement)); mpTreeWidget->insertTopLevelItem(4, pBitsPerElementItem); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pBitsPerElementItem, 1, CustomTreeWidget::LINE_EDIT); } } // Header bytes QTreeWidgetItem* pHeaderBytesItem = new QTreeWidgetItem(mpTreeWidget); if (pHeaderBytesItem != NULL) { unsigned int headerBytes = pRasterDescriptor->getHeaderBytes(); pHeaderBytesItem->setText(0, "Header Bytes"); pHeaderBytesItem->setText(1, QString::number(headerBytes)); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pHeaderBytesItem, 1, CustomTreeWidget::LINE_EDIT); } } // Trailer bytes QTreeWidgetItem* pTrailerBytesItem = new QTreeWidgetItem(mpTreeWidget); if (pTrailerBytesItem != NULL) { unsigned int trailerBytes = pRasterDescriptor->getTrailerBytes(); pTrailerBytesItem->setText(0, "Trailer Bytes"); pTrailerBytesItem->setText(1, QString::number(trailerBytes)); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pTrailerBytesItem, 1, CustomTreeWidget::LINE_EDIT); } } // Preline bytes QTreeWidgetItem* pPrelineBytesItem = new QTreeWidgetItem(mpTreeWidget); if (pPrelineBytesItem != NULL) { unsigned int prelineBytes = pRasterDescriptor->getPrelineBytes(); pPrelineBytesItem->setText(0, "Preline Bytes"); pPrelineBytesItem->setText(1, QString::number(prelineBytes)); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pPrelineBytesItem, 1, CustomTreeWidget::LINE_EDIT); } } // Postline bytes QTreeWidgetItem* pPostlineBytesItem = new QTreeWidgetItem(mpTreeWidget); if (pPostlineBytesItem != NULL) { unsigned int postlineBytes = pRasterDescriptor->getPostlineBytes(); pPostlineBytesItem->setText(0, "Postline Bytes"); pPostlineBytesItem->setText(1, QString::number(postlineBytes)); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pPostlineBytesItem, 1, CustomTreeWidget::LINE_EDIT); } } // Pixel size QTreeWidgetItem* pXPixelSizeItem = new QTreeWidgetItem(mpTreeWidget); if (pXPixelSizeItem != NULL) { double pixelSize = pRasterDescriptor->getXPixelSize(); pXPixelSizeItem->setText(0, "X Pixel Size"); pXPixelSizeItem->setText(1, QString::number(pixelSize)); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pXPixelSizeItem, 1, CustomTreeWidget::LINE_EDIT); } } QTreeWidgetItem* pYPixelSizeItem = new QTreeWidgetItem(mpTreeWidget); if (pYPixelSizeItem != NULL) { double pixelSize = pRasterDescriptor->getYPixelSize(); pYPixelSizeItem->setText(0, "Y Pixel Size"); pYPixelSizeItem->setText(1, QString::number(pixelSize)); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pYPixelSizeItem, 1, CustomTreeWidget::LINE_EDIT); } } // Units const Units* pUnits = pRasterDescriptor->getUnits(); if (pUnits != NULL) { QTreeWidgetItem* pUnitsItem = new QTreeWidgetItem(mpTreeWidget); if (pUnitsItem != NULL) { pUnitsItem->setText(0, "Units"); pUnitsItem->setBackgroundColor(1, Qt::lightGray); // Name QTreeWidgetItem* pNameItem = new QTreeWidgetItem(pUnitsItem); if (pNameItem != NULL) { string unitsName = pUnits->getUnitName(); pNameItem->setText(0, "Name"); pNameItem->setText(1, QString::fromStdString(unitsName)); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pNameItem, 1, CustomTreeWidget::LINE_EDIT); } } // Type QTreeWidgetItem* pTypeItem = new QTreeWidgetItem(pUnitsItem); if (pTypeItem != NULL) { UnitType unitType = pUnits->getUnitType(); string unitTypeText = StringUtilities::toDisplayString(unitType); pTypeItem->setText(0, "Type"); pTypeItem->setText(1, QString::fromStdString(unitTypeText)); if (mReadOnly == false) { QComboBox* pUnitTypeCombo = new QComboBox(mpTreeWidget); pUnitTypeCombo->setEditable(false); pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(ABSORBANCE))); pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(ABSORPTANCE))); pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(DIGITAL_NO))); pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(DISTANCE))); pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(EMISSIVITY))); pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(RADIANCE))); pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(REFLECTANCE))); pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(REFLECTANCE_FACTOR))); pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(TRANSMITTANCE))); pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(CUSTOM_UNIT))); pUnitTypeCombo->hide(); mpTreeWidget->setCellWidgetType(pTypeItem, 1, CustomTreeWidget::COMBO_BOX); mpTreeWidget->setComboBox(pTypeItem, 1, pUnitTypeCombo); } } // Scale QTreeWidgetItem* pScaleItem = new QTreeWidgetItem(pUnitsItem); if (pScaleItem != NULL) { double dScale = pUnits->getScaleFromStandard(); pScaleItem->setText(0, "Scale"); pScaleItem->setText(1, QString::number(dScale)); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pScaleItem, 1, CustomTreeWidget::LINE_EDIT); } } // Range minimum QTreeWidgetItem* pMinimumItem = new QTreeWidgetItem(pUnitsItem); if (pMinimumItem != NULL) { double dMinimum = pUnits->getRangeMin(); pMinimumItem->setText(0, "Range Minimum"); pMinimumItem->setText(1, QString::number(dMinimum)); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pMinimumItem, 1, CustomTreeWidget::LINE_EDIT); } } // Range maximum QTreeWidgetItem* pMaximumItem = new QTreeWidgetItem(pUnitsItem); if (pMaximumItem != NULL) { double dMaximum = pUnits->getRangeMax(); pMaximumItem->setText(0, "Range Maximum"); pMaximumItem->setText(1, QString::number(dMaximum)); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pMaximumItem, 1, CustomTreeWidget::LINE_EDIT); } } } } // GCPs if (mpGcpTree != NULL) { const list<GcpPoint>& gcps = pRasterDescriptor->getGcps(); if (gcps.empty() == false) { list<GcpPoint>::const_iterator iter; unsigned int i = 0; for (iter = gcps.begin(), i = 0; iter != gcps.end(); ++iter, ++i) { GcpPoint gcp = *iter; QTreeWidgetItem* pGcpItem = new QTreeWidgetItem(mpGcpTree); if (pGcpItem != NULL) { QString strLatitude; QString strLongitude; LatLonPoint latLonPoint(gcp.mCoordinate); string latText = latLonPoint.getLatitudeText(); if (latText.empty() == false) { strLatitude = QString::fromStdString(latText); } string longText = latLonPoint.getLongitudeText(); if (longText.empty() == false) { strLongitude = QString::fromStdString(longText); } pGcpItem->setText(0, QString("GCP ") + QString::number(i + 1)); pGcpItem->setText(1, QString::number(gcp.mPixel.mX + 1.0)); pGcpItem->setText(2, QString::number(gcp.mPixel.mY + 1.0)); pGcpItem->setText(3, strLatitude); pGcpItem->setText(4, strLongitude); } } mpGcpTree->setEnabled(true); } else { mpGcpTree->setEnabled(false); } } // Bands QTreeWidgetItem* pBandsItem = new QTreeWidgetItem(); if (pBandsItem != NULL) { unsigned int bands = pRasterDescriptor->getBandCount(); pBandsItem->setText(0, "Bands"); pBandsItem->setText(1, QString::number(bands)); mpTreeWidget->insertTopLevelItem(4, pBandsItem); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pBandsItem, 1, CustomTreeWidget::LINE_EDIT); } } // Interleave format InterleaveFormatType interleave = pRasterDescriptor->getInterleaveFormat(); QTreeWidgetItem* pInterleaveItem = new QTreeWidgetItem(); if (pInterleaveItem != NULL) { string interleaveText = StringUtilities::toDisplayString(interleave); if (interleave == BSQ) { const vector<const Filename*>& bandFiles = pRasterDescriptor->getBandFiles(); if (bandFiles.size() > 0) { interleaveText += BSQ_MULTI_SUFFIX; } else { interleaveText += BSQ_SINGLE_SUFFIX; } } pInterleaveItem->setText(0, "Interleave Format"); pInterleaveItem->setText(1, QString::fromStdString(interleaveText)); mpTreeWidget->insertTopLevelItem(7, pInterleaveItem); if (mReadOnly == false) { QComboBox* pInterleaveCombo = new QComboBox(mpTreeWidget); pInterleaveCombo->setEditable(false); pInterleaveCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(BIL))); pInterleaveCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(BIP))); pInterleaveCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(BSQ) + BSQ_SINGLE_SUFFIX)); pInterleaveCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(BSQ) + BSQ_MULTI_SUFFIX)); pInterleaveCombo->hide(); mpTreeWidget->setCellWidgetType(pInterleaveItem, 1, CustomTreeWidget::COMBO_BOX); mpTreeWidget->setComboBox(pInterleaveItem, 1, pInterleaveCombo); } } // Band files const vector<const Filename*>& bandFiles = pRasterDescriptor->getBandFiles(); for (unsigned int i = 0; i < bandFiles.size(); ++i) { string bandFilename = bandFiles[i]->getFullPathAndName(); if (bandFilename.empty() == false) { QTreeWidgetItem* pBandItem = new QTreeWidgetItem(pFilenameItem); if (pBandItem != NULL) { pBandItem->setText(0, QString::number(i + 1)); pBandItem->setText(1, QString::fromStdString(bandFilename)); if (mReadOnly == false) { mpTreeWidget->setCellWidgetType(pBandItem, 1, CustomTreeWidget::BROWSE_FILE_EDIT); mpTreeWidget->setFileBrowser(pBandItem, 1, mpFileBrowser); } } } } // Preband bytes QTreeWidgetItem* pPrebandBytesItem = new QTreeWidgetItem(); if (pPrebandBytesItem != NULL) { QString strPrebandBytes; QColor cellColor = Qt::lightGray; if (interleave == BSQ) { strPrebandBytes = QString::number(pRasterDescriptor->getPrebandBytes()); cellColor = Qt::white; } pPrebandBytesItem->setText(0, "Preband Bytes"); pPrebandBytesItem->setText(1, strPrebandBytes); pPrebandBytesItem->setBackgroundColor(1, cellColor); mpTreeWidget->insertTopLevelItem(12, pPrebandBytesItem); if ((mReadOnly == false) && (interleave == BSQ)) { mpTreeWidget->setCellWidgetType(pPrebandBytesItem, 1, CustomTreeWidget::LINE_EDIT); } } // Postband bytes QTreeWidgetItem* pPostbandBytesItem = new QTreeWidgetItem(); if (pPostbandBytesItem != NULL) { QString strPostbandBytes; QColor cellColor = Qt::lightGray; if (interleave == BSQ) { strPostbandBytes = QString::number(pRasterDescriptor->getPostbandBytes()); cellColor = Qt::white; } pPostbandBytesItem->setText(0, "Postband Bytes"); pPostbandBytesItem->setText(1, strPostbandBytes); pPostbandBytesItem->setBackgroundColor(1, cellColor); mpTreeWidget->insertTopLevelItem(13, pPostbandBytesItem); if ((mReadOnly == false) && (interleave == BSQ)) { mpTreeWidget->setCellWidgetType(pPostbandBytesItem, 1, CustomTreeWidget::LINE_EDIT); } } }
void BuildingComponentDialogCentralWidget::createLayout() { bool isConnected = false; QLabel * label = new QLabel("Sort by:"); label->hide(); // TODO remove this hack when we have sorts to do QComboBox * comboBox = new QComboBox(this); comboBox->hide(); // TODO remove this hack when we have sorts to do isConnected = connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(comboBoxIndexChanged(const QString &))); OS_ASSERT(isConnected); QPushButton * upperPushButton = new QPushButton("Check All"); isConnected = connect(upperPushButton, SIGNAL(clicked()), this, SLOT(upperPushButtonClicked())); OS_ASSERT(isConnected); QHBoxLayout * upperLayout = new QHBoxLayout(); upperLayout->addWidget(label); upperLayout->addWidget(comboBox); upperLayout->addStretch(); upperLayout->addWidget(upperPushButton); m_collapsibleComponentList = new CollapsibleComponentList(); isConnected = connect(m_collapsibleComponentList, SIGNAL(headerClicked(bool)), this, SIGNAL(headerClicked(bool))); OS_ASSERT(isConnected); isConnected = connect(m_collapsibleComponentList, SIGNAL(headerClicked(bool)), this, SLOT(on_headerClicked(bool))); OS_ASSERT(isConnected); isConnected = connect(m_collapsibleComponentList, SIGNAL(componentClicked(bool)), this, SIGNAL(componentClicked(bool))); OS_ASSERT(isConnected); isConnected = connect(m_collapsibleComponentList, SIGNAL(componentClicked(bool)), this, SLOT(on_componentClicked(bool))); OS_ASSERT(isConnected); isConnected = connect(m_collapsibleComponentList, SIGNAL(collapsibleComponentClicked(bool)), this, SIGNAL(collapsibleComponentClicked(bool))); OS_ASSERT(isConnected); isConnected = connect(m_collapsibleComponentList, SIGNAL(collapsibleComponentClicked(bool)), this, SLOT(on_collapsibleComponentClicked(bool))); OS_ASSERT(isConnected); isConnected = connect(m_collapsibleComponentList, SIGNAL(getComponentsByPage(int)), this, SIGNAL(getComponentsByPage(int))); OS_ASSERT(isConnected); isConnected = connect(m_collapsibleComponentList, SIGNAL(getComponentsByPage(int)), this, SLOT(on_getComponentsByPage(int))); OS_ASSERT(isConnected); //******************************************************************* // Hack code to be removed (TODO) m_componentList = new ComponentList(); // TODO refactor and remove CollapsibleComponentHeader * collapsibleComponentHeader = NULL; collapsibleComponentHeader = new CollapsibleComponentHeader("Constructions",100,5); CollapsibleComponent * collapsibleComponent = NULL; collapsibleComponent = new CollapsibleComponent(collapsibleComponentHeader,m_componentList); m_collapsibleComponentList->addCollapsibleComponent(collapsibleComponent); //******************************************************************* m_progressBar = new QProgressBar(this); m_progressBar->setVisible(false); QPushButton * lowerPushButton = new QPushButton("Download"); isConnected = connect(lowerPushButton, SIGNAL(clicked()), this, SLOT(lowerPushButtonClicked())); OS_ASSERT(isConnected); QHBoxLayout * lowerLayout = new QHBoxLayout(); lowerLayout->addStretch(); lowerLayout->addWidget(m_progressBar); lowerLayout->addWidget(lowerPushButton); QVBoxLayout * mainLayout = new QVBoxLayout(); mainLayout->addLayout(upperLayout); mainLayout->addWidget(m_collapsibleComponentList,0,Qt::AlignTop); mainLayout->addLayout(lowerLayout); setLayout(mainLayout); }