Exemple #1
0
void QgsColorRampButton::prepareMenu()
{
  mMenu->clear();

  QAction *invertAction = new QAction( tr( "Invert color ramp" ), this );
  invertAction->setEnabled( !isNull() && !isRandomColorRamp() );
  mMenu->addAction( invertAction );
  connect( invertAction, &QAction::triggered, this, &QgsColorRampButton::invertColorRamp );

  if ( mShowNull )
  {
    QAction *nullAction = new QAction( tr( "Clear current ramp" ), this );
    mMenu->addAction( nullAction );
    connect( nullAction, &QAction::triggered, this, &QgsColorRampButton::setToNull );
  }

  mMenu->addSeparator();

  //show default color option if set
  if ( mDefaultColorRamp )
  {
    QAction *defaultColorRampAction = new QAction( tr( "Default color ramp" ), this );
    defaultColorRampAction->setIcon( createMenuIcon( mDefaultColorRamp ) );
    mMenu->addAction( defaultColorRampAction );
    connect( defaultColorRampAction, &QAction::triggered, this, &QgsColorRampButton::setToDefaultColorRamp );
  }

  if ( mShowRandomColorRamp )
  {
    QAction *randomColorRampAction = new QAction( tr( "Random color ramp" ), this );
    randomColorRampAction->setCheckable( true );
    randomColorRampAction->setChecked( isRandomColorRamp() );
    mMenu->addAction( randomColorRampAction );
    connect( randomColorRampAction, &QAction::triggered, this, &QgsColorRampButton::setRandomColorRamp );

    if ( isRandomColorRamp() || dynamic_cast<QgsLimitedRandomColorRamp *>( mColorRamp ) )
    {
      QAction *shuffleRandomColorRampAction = new QAction( tr( "Shuffle random colors" ), this );
      mMenu->addAction( shuffleRandomColorRampAction );
      connect( shuffleRandomColorRampAction, &QAction::triggered, this, &QgsColorRampButton::colorRampChanged );
    }
  }

  mMenu->addSeparator();

  QStringList rampNames = mStyle->symbolsOfFavorite( QgsStyle::ColorrampEntity );
  rampNames.sort();
  for ( QStringList::iterator it = rampNames.begin(); it != rampNames.end(); ++it )
  {
    std::unique_ptr< QgsColorRamp > ramp( mStyle->colorRamp( *it ) );

    if ( !mShowGradientOnly || ( ramp->type() == QLatin1String( "gradient" ) || ramp->type() == QLatin1String( "cpt-city" ) ) )
    {
      QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), QSize( 16, 16 ) );
      QAction *ra = new QAction( *it, this );
      ra->setIcon( icon );
      connect( ra, &QAction::triggered, this, &QgsColorRampButton::loadColorRamp );
      mMenu->addAction( ra );
    }
  }

  mMenu->addSeparator();

  mAllRampsMenu->clear();
  mMenu->addMenu( mAllRampsMenu );
  rampNames = mStyle->colorRampNames();
  rampNames.sort();
  for ( QStringList::iterator it = rampNames.begin(); it != rampNames.end(); ++it )
  {
    std::unique_ptr< QgsColorRamp > ramp( mStyle->colorRamp( *it ) );

    if ( !mShowGradientOnly || ( ramp->type() == QLatin1String( "gradient" ) || ramp->type() == QLatin1String( "cpt-city" ) ) )
    {
      QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), QSize( 16, 16 ) );
      QAction *ra = new QAction( *it, this );
      ra->setIcon( icon );
      connect( ra, &QAction::triggered, this, &QgsColorRampButton::loadColorRamp );
      mAllRampsMenu->addAction( ra );
    }
  }

  mMenu->addSeparator();

  QAction *newColorRampAction = new QAction( tr( "Create new color ramp..." ), this );
  connect( newColorRampAction, &QAction::triggered, this, &QgsColorRampButton::createColorRamp );
  mMenu->addAction( newColorRampAction );

  QAction *editColorRampAction = new QAction( tr( "Edit color ramp..." ), this );
  editColorRampAction->setEnabled( !isNull() && !isRandomColorRamp() );
  connect( editColorRampAction, &QAction::triggered, this, &QgsColorRampButton::showColorRampDialog );
  mMenu->addAction( editColorRampAction );

  QAction *saveColorRampAction = new QAction( tr( "Save color ramp..." ), this );
  saveColorRampAction->setEnabled( !isNull() && !isRandomColorRamp() );
  connect( saveColorRampAction, &QAction::triggered, this, &QgsColorRampButton::saveColorRamp );
  mMenu->addAction( saveColorRampAction );
}
Exemple #2
0
void Wizard::populateUI()
{
    QStringList formats = Types::paperFormats().keys();
    formats.sort();
    m_paperFormatComboBox->addItems(formats);
}
Exemple #3
0
/**
 * Stream operator for QDebug
 */
QDebug operator<<(QDebug dbg, RStorage& s) {
    dbg.nospace() << "RStorage(" << QString("%1").arg((long int)&s, 0, 16) << ", ";
    dbg.nospace() << "\n";
    //dbg.nospace() << "current block ID: " << s.getCurrentBlockId() << "\n";
    QSharedPointer<RBlock> block = s.queryCurrentBlock();
    if (block.isNull()) {
        dbg.nospace() << "current block: INVALID\n";
    }
    else {
        dbg.nospace() << "current block: " << block->getName() << "\n";
    }
    //dbg.nospace() << "current layer ID: " << s.getCurrentLayerId() << "\n";
    QSharedPointer<RLayer> layer = s.queryCurrentLayer();
    if (layer.isNull()) {
        dbg.nospace() << "current layer: INVALID\n";
    }
    else {
        dbg.nospace() << "current layer: " << layer->getName() << "\n";
    }
    dbg.nospace() << "current view ID: " << s.getCurrentViewId() << "\n";
    dbg.nospace() << "drawing unit: " << s.getUnit() << "\n";
    dbg.nospace() << "bounding box: " << s.getBoundingBox() << "\n";

    {
        QSet<RLayer::Id> layers = s.queryAllLayers(true);
        QSetIterator<RLayer::Id> i(layers);
        while (i.hasNext()) {
            RLayer::Id id = i.next();
            QSharedPointer<RLayer> l = s.queryObjectDirect(id).dynamicCast<RLayer>();
            if (l.isNull()) {
                dbg.nospace() << "layer not found: " << id;
                continue;
            }
            dbg.nospace() << *l.data() << "\n";
        }
    }

    {
        QSet<RLayer::Id> views = s.queryAllViews(true);
        QSetIterator<RView::Id> i(views);
        while (i.hasNext()) {
            RView::Id id = i.next();
            QSharedPointer<RView> v = s.queryObjectDirect(id).dynamicCast<RView>();
            if (v.isNull()) {
                dbg.nospace() << "view not found: " << id;
                continue;
            }
            dbg.nospace() << *v.data() << "\n";
        }
    }

    {
        QSet<RLayer::Id> blocks = s.queryAllBlocks(true);
        QSetIterator<RBlock::Id> i(blocks);
        while (i.hasNext()) {
            RBlock::Id id = i.next();
            QSharedPointer<RBlock> b = s.queryObjectDirect(id).dynamicCast<RBlock>();
            if (b.isNull()) {
                dbg.nospace() << "block not found: " << id;
                continue;
            }
            dbg.nospace() << *b.data() << "\n";
        }
    }

    {
        QSet<REntity::Id> entities = s.querySelectedEntities();
        if (entities.size()==0) {
            entities = s.queryAllEntities(true, true);
        }
        QSetIterator<REntity::Id> i(entities);
        while (i.hasNext()) {
            REntity::Id id = i.next();
            QSharedPointer<REntity> e = s.queryObjectDirect(id).dynamicCast<REntity>();
            if (e.isNull()) {
                dbg.nospace() << "entity not found: " << id;
                continue;
            }
            dbg.nospace() << "Bounding Box: " << e->getBoundingBox() << "\n";
            dbg.nospace() << *e.data() << "\n\n";
        }
    }

    dbg.nospace() << "lastTransactionId: " << s.getLastTransactionId() << "\n";
    for (int a = 0; a <= s.getMaxTransactionId(); ++a) {
        RTransaction t = s.getTransaction(a);
        dbg.nospace() << t << "\n";
    }

    dbg.nospace() << "variables: \n";

    {
        QStringList vars = s.getVariables();
        vars.sort();
        QListIterator<QString> i(vars);
        while (i.hasNext()) {
            QString key = i.next();
            dbg.nospace() << "\t" << key << ": " << s.getVariable(key) << "\n";
        }
    }

    dbg.nospace() << "Known variables (DXF): \n";

    {
        for (int i=0; i<=RS::MaxKnownVariable; i++) {
            QVariant v = s.getKnownVariable((RS::KnownVariable)i);
            if (v.isValid()) {
                dbg.nospace() << "\t"
                              << RStorage::getKnownVariableName((RS::KnownVariable)i)
                              << ": " << v << "\n";
            }
        }
    }

    dbg.nospace() << ")";
    return dbg.space();
}
Exemple #4
0
/*!
 * \brief Xyce::createNetlist
 * \param[out] stream QTextStream that associated with spice netlist file
 * \param[in] simulations The list of simulations that need to included in netlist.
 * \param[out] vars The list of output variables and node names.
 * \param[out] outputs The list of spice output raw text files.
 */
void Xyce::createNetlist(QTextStream &stream, int , QStringList &simulations,
                    QStringList &vars, QStringList &outputs)
{
    QString s;
    bool hasParSweep = false;

    if(!prepareSpiceNetlist(stream,true)) return; // Unable to perform spice simulation
    startNetlist(stream,true);

    // set variable names for named nodes and wires
    vars.clear();
    for(Node *pn = Sch->DocNodes.first(); pn != 0; pn = Sch->DocNodes.next()) {
      if(pn->Label != 0) {
          if (!vars.contains(pn->Label->Name)) {
              vars.append(pn->Label->Name);
          }
      }
    }
    for(Wire *pw = Sch->DocWires.first(); pw != 0; pw = Sch->DocWires.next()) {
      if(pw->Label != 0) {
          if (!vars.contains(pw->Label->Name)) {
              vars.append(pw->Label->Name);
          }
      }
    }
    for(Component *pc = Sch->DocComps.first(); pc != 0; pc = Sch->DocComps.next()) {
        if (pc->isProbe) {
            QString var_pr = pc->getProbeVariable(true);
            if (!vars.contains(var_pr)) {
                vars.append(var_pr);
            }
        }
        /*if (pc->isEquation) {
            Equation *eq = (Equation *)pc;
            QStringList vars_eq;
            eq->getDepVars(vars_eq);
            vars.append(vars_eq);
        }*/
    }
    vars.sort();
    qDebug()<<vars;

    //execute simulations

    QFileInfo inf(Sch->DocName);
    QString basenam = inf.baseName();

    QString nod,nods;
    nods.clear();
    foreach (nod,vars) {
        if (!nod.startsWith("I(")) {
            nods += QString("v(%1) ").arg(nod);
        } else {
            nods += nod + " ";
        }
    }
    QString sim = simulations.first();

    for(Component *pc = Sch->DocComps.first(); pc != 0; pc = Sch->DocComps.next()) { // Xyce can run
       if(pc->isSimulation) {                        // only one simulations per time.
           QString sim_typ = pc->Model;              // Multiple simulations are forbidden.
           QString s = pc->getSpiceNetlist(true);
           if ((sim_typ==".AC")&&(sim=="ac")) stream<<s;
           if ((sim_typ==".TR")&&(sim=="tran")){
               stream<<s;
               Q3PtrList<Component> comps(Sch->DocComps); // find Fourier tran
               for(Component *pc1 = comps.first(); pc1 != 0; pc1 = comps.next()) {
                   if (pc1->Model==".FOURIER") {
                       if (pc1->Props.at(0)->Value==pc->Name) {
                           QString s1 = pc1->getSpiceNetlist(true);
                           outputs.append("spice4qucs.tran.cir.four");
                           stream<<s1;
                       }
                   }
               }
           }
           if ((sim_typ==".HB")&&(sim=="hb")) stream<<s;
           if (sim_typ==".SW") {
               QString SwpSim = pc->Props.at(0)->Value;
               if (SwpSim.startsWith("DC")&&(sim=="dc")) stream<<s;
               else if (SwpSim.startsWith("AC")&&(sim=="ac")) {
                   stream<<s;
                   hasParSweep = true;
               } else if (SwpSim.startsWith("TR")&&(sim=="tran")) {
                   stream<<s;
                   hasParSweep = true;
               } if (SwpSim.startsWith("HB")&&(sim=="hb")) {
                   stream<<s;
                   hasParSweep = true;
               }
           }
           if ((sim_typ==".DC")) stream<<s;
       }
    }


    QString filename;
    if (hasParSweep) filename = QString("%1_%2_swp.txt").arg(basenam).arg(sim);
    else filename = QString("%1_%2.txt").arg(basenam).arg(sim);
    QString write_str;
    if (sim=="hb") {
        write_str = QString(".PRINT  %1 file=%2 %3\n").arg(sim).arg(filename).arg(nods);
    } else {
        write_str = QString(".PRINT  %1 format=raw file=%2 %3\n").arg(sim).arg(filename).arg(nods);
    }
    stream<<write_str;
    outputs.append(filename);

    stream<<".END\n";
}
void SystemOptions::readSettings(bool reload) {
  QSettings settings(m_settingsFileName,QSettings::IniFormat);
  settings.setIniCodec("UTF-8");
  settings.beginGroup(m_section);

  m_contentsLinked->setChecked(settings.value(SID_SYSTEM_CONTENTS_LINKED,true).toBool());
  m_lexicon->setText(settings.value(SID_SYSTEM_DATABASE,"lexicon.sqlite").toString());

  m_docked->setChecked(settings.value(SID_SYSTEM_DOCKED,true).toBool());
  m_importCheck->setChecked(settings.value(SID_SYSTEM_IMPORTLINKS_IGNORE,false).toBool());
  m_importShow->setChecked(settings.value(SID_SYSTEM_IMPORTLINKS_SHOW_WARNING,false).toBool());
  m_minimalInterface->setChecked(settings.value(SID_SYSTEM_MINIMAL,true).toBool());
  m_restoreBookmarks->setChecked(settings.value(SID_SYSTEM_RESTORE_BOOKMARKS,true).toBool());
  m_restoreTabs->setChecked(settings.value(SID_SYSTEM_RESTORE_TABS,true).toBool());
  //  m_saveSettings->setChecked(settings.value(SID_SYSTEM_SAVE_SETTINGS,true).toBool());
  m_saveTabs->setChecked(settings.value(SID_SYSTEM_SAVE_TABS,true).toBool());
  m_rootNavigation->setChecked(settings.value(SID_SYSTEM_BY_ROOT,true).toBool());
  m_interval->setText(settings.value(SID_SYSTEM_MESSAGE_TIMEOUT,2).toString());
  m_appendNewTab->setChecked(settings.value(SID_SYSTEM_APPEND_NEW_TABS,true).toBool());
  m_insertNewTab->setChecked(! m_appendNewTab->isChecked());
  QString newStyle = m_qtStyle->currentText();
  m_qtStyle->setCurrentText(settings.value(SID_SYSTEM_QT_STYLE).toString());
  if (reload) {
    QString oldStyle = m_qtStyle->currentText();
    if (oldStyle != newStyle) {
      QApplication::setStyle(QStyleFactory::create(oldStyle));
    }
  }
#ifndef STANDALONE
  m_keyboard->addItems(getLexicon()->getKeyboards());
  m_keyboard->setCurrentText(getLexicon()->getDefaultKeyboard());
  QStringList themes = getLexicon()->getThemes();
  themes.sort();
  m_theme->addItems(themes);
  m_theme->setCurrentText(getLexicon()->currentTheme());
#endif
  //  QString d = settings.value(SID_SYSTEM_RUN_DATE,QString()).toString();
  //  m_runDate->setDateTime(QDateTime::fromString(d,Qt::ISODate));
  m_allowDuplicates->setChecked(settings.value(SID_SYSTEM_ALLOW_DUPLICATES,false).toBool());

  m_showInterfaceWarning->setChecked(settings.value(SID_SYSTEM_INTERFACE_WARNING,true).toBool());
  m_css->setText(settings.value(SID_SYSTEM_STYLESHEET,"app.css").toString());

  m_title->setText(settings.value(SID_SYSTEM_TITLE,"Lane's Lexicon").toString());
  m_toolbarText->setChecked(settings.value(SID_SYSTEM_TOOLBAR_TEXT,true).toBool());
  m_optionsWarning->setChecked(settings.value(SID_SYSTEM_OPTIONS_CLOSE,true).toBool());
  settings.endGroup();
  settings.beginGroup("Notes");
  //  m_useNotes->setChecked(settings.value(SID_NOTES_ENABLED,false).toBool());
  m_notesDb->setText(settings.value(SID_NOTES_DATABASE,"notes.sqlite").toString());
  settings.endGroup();
  settings.beginGroup("Splash");
  m_splashScreen->setChecked(settings.value(SID_SPLASH_ENABLED,true).toBool());
  m_splashDuration->setText(settings.value(SID_SPLASH_DELAY,3).toString());
  settings.endGroup();
  settings.beginGroup("History");
  m_historyDb->setText(settings.value(SID_HISTORY_DATABASE,"history.sqlite").toString());
  settings.endGroup();
  settings.beginGroup("Help");
  m_onlineUrl->setText(settings.value(SID_HELP_ONLINE_PREFIX).toString());
  m_onlineCurrentPage->setText(settings.value(SID_HELP_ONLINE_URL,QUrl()).toUrl().toString());
  m_offlineLocation->setText(settings.value(SID_HELP_LOCAL_LOCATION,"site").toString());

  QDir dd(m_offlineLocation->text());
  //  QUrl u = settings.value(SID_HELP_LOCAL_URL,QUrl()).toUrl();
  //  m_offlineCurrentPage->setText(dd.relativeFilePath(u.fileName()));
  m_offlineCurrentPage->setText(settings.value(SID_HELP_LOCAL_URL,"index.html").toString());
  //u.tom_offlineLocation->text();
  m_localDocs->setChecked(settings.value(SID_HELP_LOCAL,true).toBool());

  m_dirty = false;
}
void ApplicationSettings::readSettings()
{
    KSharedConfigPtr config    = d->config;

    // ---------------------------------------------------------------------

    KConfigGroup group         = config->group(d->configGroupDefault);
    QStringList collectionList = group.readEntry(d->configAlbumCollectionsEntry, QStringList());

    if (!collectionList.isEmpty())
    {
        collectionList.sort();
        d->albumCategoryNames = collectionList;
    }

    d->albumSortRole                    = ApplicationSettings::AlbumSortRole(group.readEntry(d->configAlbumSortRoleEntry,
                                          (int)ApplicationSettings::ByFolder));

    d->imageSortOrder                   = group.readEntry(d->configImageSortOrderEntry,      (int)ImageSortSettings::SortByFileName);
    d->imageSorting                     = group.readEntry(d->configImageSortingEntry,        (int)ImageSortSettings::AscendingOrder);
    d->imageGroupMode                   = group.readEntry(d->configImageGroupModeEntry,      (int)ImageSortSettings::CategoryByAlbum);
    d->imageGroupSortOrder              = group.readEntry(d->configImageGroupSortOrderEntry, (int)ImageSortSettings::AscendingOrder);

    d->itemLeftClickAction              = ApplicationSettings::ItemLeftClickAction(group.readEntry( d->configItemLeftClickActionEntry,
                                          (int)ApplicationSettings::ShowPreview));

    d->thumbnailSize                    = group.readEntry(d->configDefaultIconSizeEntry,              (int)ThumbnailSize::Medium);
    d->treeThumbnailSize                = group.readEntry(d->configDefaultTreeIconSizeEntry,          22);
    d->treeviewFont                     = group.readEntry(d->configTreeViewFontEntry,                 QFontDatabase::systemFont(QFontDatabase::GeneralFont));
    d->currentTheme                     = group.readEntry(d->configThemeEntry,                        ThemeManager::instance()->defaultThemeName());

    d->sidebarTitleStyle                = (DMultiTabBar::TextStyle)group.readEntry(d->configSidebarTitleStyleEntry,
                                          (int)DMultiTabBar::ActiveIconText);

    d->ratingFilterCond                 = group.readEntry(d->configRatingFilterConditionEntry,
                                          (int)ImageFilterSettings::GreaterEqualCondition);

    d->recursiveAlbums                  = group.readEntry(d->configRecursiveAlbumsEntry,              false);
    d->recursiveTags                    = group.readEntry(d->configRecursiveTagsEntry,                true);


    d->iconShowName                     = group.readEntry(d->configIconShowNameEntry,                 false);
    d->iconShowResolution               = group.readEntry(d->configIconShowResolutionEntry,           false);
    d->iconShowAspectRatio              = group.readEntry(d->configIconShowAspectRatioEntry,          false);
    d->iconShowSize                     = group.readEntry(d->configIconShowSizeEntry,                 false);
    d->iconShowDate                     = group.readEntry(d->configIconShowDateEntry,                 true);
    d->iconShowModDate                  = group.readEntry(d->configIconShowModificationDateEntry,     true);
    d->iconShowTitle                    = group.readEntry(d->configIconShowTitleEntry,                true);
    d->iconShowComments                 = group.readEntry(d->configIconShowCommentsEntry,             true);
    d->iconShowTags                     = group.readEntry(d->configIconShowTagsEntry,                 true);
    d->iconShowOverlays                 = group.readEntry(d->configIconShowOverlaysEntry,             true);
    d->iconShowFullscreen               = group.readEntry(d->configIconShowFullscreenEntry,           true);
    d->iconShowRating                   = group.readEntry(d->configIconShowRatingEntry,               true);
    d->iconShowImageFormat              = group.readEntry(d->configIconShowImageFormatEntry,          false);
    d->iconShowCoordinates              = group.readEntry(d->configIconShowCoordinatesEntry,          false);
    d->iconviewFont                     = group.readEntry(d->configIconViewFontEntry,                 QFontDatabase::systemFont(QFontDatabase::GeneralFont));

    d->toolTipsFont                     = group.readEntry(d->configToolTipsFontEntry,                 QFontDatabase::systemFont(QFontDatabase::GeneralFont));
    d->showToolTips                     = group.readEntry(d->configShowToolTipsEntry,                 false);
    d->tooltipShowFileName              = group.readEntry(d->configToolTipsShowFileNameEntry,         true);
    d->tooltipShowFileDate              = group.readEntry(d->configToolTipsShowFileDateEntry,         false);
    d->tooltipShowFileSize              = group.readEntry(d->configToolTipsShowFileSizeEntry,         false);
    d->tooltipShowImageType             = group.readEntry(d->configToolTipsShowImageTypeEntry,        false);
    d->tooltipShowImageDim              = group.readEntry(d->configToolTipsShowImageDimEntry,         true);
    d->tooltipShowImageAR               = group.readEntry(d->configToolTipsShowImageAREntry,          true);
    d->tooltipShowPhotoMake             = group.readEntry(d->configToolTipsShowPhotoMakeEntry,        true);
    d->tooltipShowPhotoDate             = group.readEntry(d->configToolTipsShowPhotoDateEntry,        true);
    d->tooltipShowPhotoFocal            = group.readEntry(d->configToolTipsShowPhotoFocalEntry,       true);
    d->tooltipShowPhotoExpo             = group.readEntry(d->configToolTipsShowPhotoExpoEntry,        true);
    d->tooltipShowPhotoMode             = group.readEntry(d->configToolTipsShowPhotoModeEntry,        true);
    d->tooltipShowPhotoFlash            = group.readEntry(d->configToolTipsShowPhotoFlashEntry,       false);
    d->tooltipShowPhotoWb               = group.readEntry(d->configToolTipsShowPhotoWBEntry,          false);
    d->tooltipShowAlbumName             = group.readEntry(d->configToolTipsShowAlbumNameEntry,        false);
    d->tooltipShowComments              = group.readEntry(d->configToolTipsShowCommentsEntry,         true);
    d->tooltipShowTags                  = group.readEntry(d->configToolTipsShowTagsEntry,             true);
    d->tooltipShowLabelRating           = group.readEntry(d->configToolTipsShowLabelRatingEntry,      true);

    d->tooltipShowVideoAspectRatio      = group.readEntry(d->configToolTipsShowVideoAspectRatioEntry,      true);
    d->tooltipShowVideoAudioBitRate     = group.readEntry(d->configToolTipsShowVideoAudioBitRateEntry,     true);
    d->tooltipShowVideoAudioChannelType = group.readEntry(d->configToolTipsShowVideoAudioChannelTypeEntry, true);
    d->tooltipShowVideoAudioCompressor  = group.readEntry(d->configToolTipsShowVideoAudioCompressorEntry,  true);
    d->tooltipShowVideoDuration         = group.readEntry(d->configToolTipsShowVideoDurationEntry,         true);
    d->tooltipShowVideoFrameRate        = group.readEntry(d->configToolTipsShowVideoFrameRateEntry,        true);
    d->tooltipShowVideoVideoCodec       = group.readEntry(d->configToolTipsShowVideoVideoCodecEntry,       true);

    d->showAlbumToolTips                = group.readEntry(d->configShowAlbumToolTipsEntry,            false);
    d->tooltipShowAlbumTitle            = group.readEntry(d->configToolTipsShowAlbumTitleEntry,       true);
    d->tooltipShowAlbumDate             = group.readEntry(d->configToolTipsShowAlbumDateEntry,        true);
    d->tooltipShowAlbumCollection       = group.readEntry(d->configToolTipsShowAlbumCollectionEntry,  true);
    d->tooltipShowAlbumCategory         = group.readEntry(d->configToolTipsShowAlbumCategoryEntry,    true);
    d->tooltipShowAlbumCaption          = group.readEntry(d->configToolTipsShowAlbumCaptionEntry,     true);
    d->tooltipShowAlbumPreview          = group.readEntry(d->configToolTipsShowAlbumPreviewEntry,     false);

    if (group.readEntry(d->configPreviewLoadFullImageSizeEntry, true))
    {
        d->previewSettings.quality = PreviewSettings::HighQualityPreview;
        if (group.readEntry(d->configPreviewRawUseEmbeddedPreview, false))
        {
            d->previewSettings.rawLoading = PreviewSettings::RawPreviewFromEmbeddedPreview;
        }
        else if (group.readEntry(d->configPreviewRawUseHalfSizeData, false))
        {
            d->previewSettings.rawLoading = PreviewSettings::RawPreviewFromRawHalfSize;
        }
        else
        {
            d->previewSettings.rawLoading = PreviewSettings::RawPreviewAutomatic;
        }
    }
    else
    {
        d->previewSettings.quality = PreviewSettings::FastPreview;
    }
    d->previewShowIcons                 = group.readEntry(d->configPreviewShowIconsEntry,             true);
    d->showThumbbar                     = group.readEntry(d->configShowThumbbarEntry,                 true);

    d->showFolderTreeViewItemsCount     = group.readEntry(d->configShowFolderTreeViewItemsCountEntry, false);

    // ---------------------------------------------------------------------

    group                               = generalConfigGroup();

    d->showSplash                       = group.readEntry(d->configShowSplashEntry,                                  true);
    d->useTrash                         = group.readEntry(d->configUseTrashEntry,                                    true);
    d->showTrashDeleteDialog            = group.readEntry(d->configShowTrashDeleteDialogEntry,                       true);
    d->showPermanentDeleteDialog        = group.readEntry(d->configShowPermanentDeleteDialogEntry,                   true);
    d->sidebarApplyDirectly             = group.readEntry(d->configApplySidebarChangesDirectlyEntry,                 false);
    d->scrollItemToCenter               = group.readEntry(d->configScrollItemToCenterEntry,                          false);
    d->stringComparisonType             = (StringComparisonType) group.readEntry(d->configStringComparisonTypeEntry, (int) Natural);
    setApplicationStyle(group.readEntry(d->configApplicationStyleEntry, qApp->style()->objectName()));
    d->iconTheme                        = group.readEntry(d->configIconThemeEntry,                                   QString());

    // ---------------------------------------------------------------------

    d->databaseParams.readFromConfig();

#ifdef HAVE_KFILEMETADATA

    group                               = config->group(d->configGroupBaloo);

    d->syncToDigikam                    = group.readEntry(d->configSyncBalootoDigikamEntry, false);
    d->syncToBaloo                      = group.readEntry(d->configSyncDigikamtoBalooEntry, false);

    emit balooSettingsChanged();

#endif // HAVE_KFILEMETADATA

    // ---------------------------------------------------------------------

    group = config->group(d->configGroupVersioning);
    d->versionSettings.readFromConfig(group);

    // ---------------------------------------------------------------------

    group                    = config->group(d->configGroupFaceDetection);
    d->faceDetectionAccuracy = group.readEntry(d->configFaceDetectionAccuracyEntry, double(0.8));

    emit setupChanged();
    emit recurseSettingsChanged();
    emit balooSettingsChanged();
}
Exemple #7
0
bool
QMakeProperty::exec()
{
    bool ret = true;
    if(Option::qmake_mode == Option::QMAKE_QUERY_PROPERTY) {
        if(Option::prop::properties.isEmpty()) {
            initSettings();
            settings->beginGroup(keyBase(false));
            QStringList subs = settings->childGroups();
            settings->endGroup();
            subs.sort();
            for(int x = subs.count() - 1; x >= 0; x--) {
                QString s = subs[x];
                if(s.isEmpty())
                    continue;
                settings->beginGroup(keyBase(false) + s);
                QStringList keys = settings->childKeys();
                settings->endGroup();
                for(QStringList::ConstIterator it2 = keys.begin(); it2 != keys.end(); it2++) {
                    QString ret = settings->value(keyBase(false) + s + "/" + (*it2)).toString();
                    if(s != qmake_version())
                        fprintf(stdout, "%s/", s.toLatin1().constData());
                    fprintf(stdout, "%s:%s\n", (*it2).toLatin1().constData(), ret.toLatin1().constData());
                }
            }
            QStringList specialProps;
            specialProps.append("QT_INSTALL_PREFIX");
            specialProps.append("QT_INSTALL_DATA");
            specialProps.append("QT_INSTALL_DOCS");
            specialProps.append("QT_INSTALL_HEADERS");
            specialProps.append("QT_INSTALL_LIBS");
            specialProps.append("QT_INSTALL_BINS");
            specialProps.append("QT_INSTALL_PLUGINS");
            specialProps.append("QT_INSTALL_IMPORTS");
            specialProps.append("QT_INSTALL_TRANSLATIONS");
            specialProps.append("QT_INSTALL_CONFIGURATION");
            specialProps.append("QT_INSTALL_EXAMPLES");
            specialProps.append("QT_INSTALL_DEMOS");
            specialProps.append("QMAKE_MKSPECS");
            specialProps.append("QMAKE_VERSION");
#ifdef QT_VERSION_STR
            specialProps.append("QT_VERSION");
#endif
            foreach (QString prop, specialProps)
                fprintf(stdout, "%s:%s\n", prop.toLatin1().constData(), value(prop).toLatin1().constData());
            return true;
        }
        for(QStringList::ConstIterator it = Option::prop::properties.begin();
            it != Option::prop::properties.end(); it++) {
            if(Option::prop::properties.count() > 1)
                fprintf(stdout, "%s:", (*it).toLatin1().constData());
            if(!hasValue((*it))) {
                ret = false;
                fprintf(stdout, "**Unknown**\n");
            } else {
                fprintf(stdout, "%s\n", value((*it)).toLatin1().constData());
            }
        }
    } else if(Option::qmake_mode == Option::QMAKE_SET_PROPERTY) {
        for(QStringList::ConstIterator it = Option::prop::properties.begin();
            it != Option::prop::properties.end(); it++) {
            QString var = (*it);
            it++;
            if(it == Option::prop::properties.end()) {
                ret = false;
                break;
            }
            if(!var.startsWith("."))
                setValue(var, (*it));
        }
    } else if(Option::qmake_mode == Option::QMAKE_UNSET_PROPERTY) {
        for(QStringList::ConstIterator it = Option::prop::properties.begin();
            it != Option::prop::properties.end(); it++) {
            QString var = (*it);
            if(!var.startsWith("."))
                remove(var);
        }
    }
    return ret;
}
QStringList Attribute::listValuesFromNode(const QDomElement &m_node)
{
    QStringList result;
    if (m_references.size() == 0) {
        // Parse the content of the attribute
        QDomElement content = m_node.firstChildElement();
        if ((content.tagName() == "choice") && (m_name != "style:text-emphasize")) {
            QDomElement valueChild = content.firstChildElement();
            do {
                if (valueChild.tagName() == "value") {
                    result << valueChild.text();
                } else if (valueChild.tagName() == "ref") {
                    m_references << valueChild.attribute("name");
                } else if (valueChild.tagName() == "list") {
                    // Parse that sublist
                    if (valueChild.childNodes().length() != 1) {
                        kFatal() << "Unrecognized list element in " << m_name;
                    }
                    QDomElement subElement = valueChild.firstChildElement();
                    if (subElement.nodeName() == "oneOrMore") {
                        // Build a list of each sub item
                        QStringList allowedValues;
                        QDomElement subChoices = subElement.firstChildElement();
                        if (subChoices.nodeName() != "choice") {
                            kFatal() << "Unrecognized oneOrMore element in " << m_name;
                        }
                        QDomElement subValueChild = subChoices.firstChildElement();
                        do {
                            if (subValueChild.nodeName() == "value") {
                                allowedValues << subValueChild.text();
                            } else {
                                kFatal() << "Unrecognized oneOrMore element in " << m_name;
                            }
                            subValueChild = subValueChild.nextSiblingElement();
                        } while (!subValueChild.isNull());
                        QStringList mergedAllowedValues;
                        while (mergedAllowedValues.length() != (pow((double) allowedValues.length(), allowedValues.length()))) {
                            foreach (QString baseValue, allowedValues) {
                                if (!mergedAllowedValues.contains(baseValue))
                                    mergedAllowedValues << baseValue;
                                foreach (QString knownValue, mergedAllowedValues) {
                                    if ((knownValue == baseValue) || (knownValue.contains(baseValue + ' ')) || (knownValue.contains(' ' + baseValue))) {
                                        continue;
                                    }
                                    QString builtValue = knownValue + ' ' + baseValue;
                                    if (!mergedAllowedValues.contains(builtValue))
                                        mergedAllowedValues << builtValue;
                                }
                            }
                        }
                        foreach (QString allowedValue, mergedAllowedValues) {
                            QStringList equivalenceList;
                            equivalenceList << allowedValue;
                            
                            QStringList currentList = allowedValue.split(' ');
                            currentList.sort();
                            
                            foreach (QString otherAllowedValue, mergedAllowedValues) {
                                if (otherAllowedValue == allowedValue)
                                    continue;
                                
                                QStringList otherList = otherAllowedValue.split(' ');
                                otherList.sort();
                                if (otherList == currentList)
                                    equivalenceList << otherAllowedValue;
                            }
                            equivalenceList.sort();
                            if (!m_equivalences.contains(equivalenceList))
                                m_equivalences << equivalenceList;
                        }
                        result << mergedAllowedValues;
                    }
                } else {
Exemple #9
0
bool
DspMakefileGenerator::writeDspParts(QTextStream &t)
{
    QString dspfile;
    if ( !project->variables()["DSP_TEMPLATE"].isEmpty() ) {
	dspfile = project->first("DSP_TEMPLATE");
    } else {
	dspfile = project->first("MSVCDSP_TEMPLATE");
    }
    if (dspfile.startsWith("\"") && dspfile.endsWith("\""))
	dspfile = dspfile.mid(1, dspfile.length() - 2);
    QString dspfile_loc = findTemplate(dspfile);

    QFile file(dspfile_loc);
    if(!file.open(IO_ReadOnly)) {
	fprintf(stderr, "Cannot open dsp file: %s\n", dspfile.latin1());
	return FALSE;
    }
    QTextStream dsp(&file);

    QString platform = "Win32";
    if ( !project->variables()["QMAKE_PLATFORM"].isEmpty() )
	platform = varGlue("QMAKE_PLATFORM", "", " ", "");

    // Setup PCH variables
    precompH = project->first("PRECOMPILED_HEADER");
    QString namePCH = QFileInfo(precompH).fileName();
    usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header");
    if (usePCH) {
	// Created files
	QString origTarget = project->first("QMAKE_ORIG_TARGET");
	origTarget.replace(QRegExp("-"), "_");
	precompObj = "\"$(IntDir)\\" + origTarget + Option::obj_ext + "\"";
	precompPch = "\"$(IntDir)\\" + origTarget + ".pch\"";
	// Add PRECOMPILED_HEADER to HEADERS
	if (!project->variables()["HEADERS"].contains(precompH))
	    project->variables()["HEADERS"] += precompH;
	// Add precompile compiler options
	project->variables()["PRECOMPILED_FLAGS_REL"]  = "/Yu\"" + namePCH + "\" /FI\"" + namePCH + "\" ";
	project->variables()["PRECOMPILED_FLAGS_DEB"]  = "/Yu\"" + namePCH + "\" /FI\"" + namePCH + "\" ";
	// Return to variable pool
	project->variables()["PRECOMPILED_OBJECT"] = precompObj;
	project->variables()["PRECOMPILED_PCH"]    = precompPch;
    }
    int rep;
    QString line;
    while ( !dsp.eof() ) {
	line = dsp.readLine();
	while((rep = line.find(QRegExp("\\$\\$[a-zA-Z0-9_-]*"))) != -1) {
	    QString torep = line.mid(rep, line.find(QRegExp("[^\\$a-zA-Z0-9_-]"), rep) - rep);
	    QString variable = torep.right(torep.length()-2);

	    t << line.left(rep); //output the left side
	    line = line.right(line.length() - (rep + torep.length())); //now past the variable
	    if(variable == "MSVCDSP_SOURCES") {
		if(project->variables()["SOURCES"].isEmpty())
		    continue;

		QString mocpath = var( "QMAKE_MOC" );
		mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";

		QStringList list = project->variables()["SOURCES"] + project->variables()["DEF_FILE"];
		if(!project->isActiveConfig("flat"))
		    list.sort();
		QStringList::Iterator it;
		for( it = list.begin(); it != list.end(); ++it) {
		    beginGroupForFile((*it), t);
		    t << "# Begin Source File\n\nSOURCE=" << (*it) << endl;
		    if (usePCH && (*it).endsWith(".c"))
			t << "# SUBTRACT CPP /FI\"" << namePCH << "\" /Yu\"" << namePCH << "\" /Fp" << endl;
		    if ( project->isActiveConfig("moc") && (*it).endsWith(Option::cpp_moc_ext)) {
			QString base = (*it);
			base.replace(QRegExp("\\..*$"), "").upper();
			base.replace(QRegExp("[^a-zA-Z]"), "_");

			QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) +
					"...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\""
					" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"
					"\t" + mocpath + findMocSource((*it)) + " -o " +
					(*it) + "\n\n" "# End Custom Build\n\n";

			t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl;

			t << "!IF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build
			  << "!ELSEIF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\""
			  << build << "!ENDIF " << endl << endl;
		    }
		    t << "# End Source File" << endl;
		}
		endGroups(t);
	    } else if(variable == "MSVCDSP_IMAGES") {
		if(project->variables()["IMAGES"].isEmpty())
		    continue;
		t << "# Begin Source File\n\nSOURCE=" << project->first("QMAKE_IMAGE_COLLECTION") << endl;
		t << "# End Source File" << endl;
	    } else if(variable == "MSVCDSP_HEADERS") {
		if(project->variables()["HEADERS"].isEmpty())
		    continue;

		QStringList list = project->variables()["HEADERS"];
		if(!project->isActiveConfig("flat"))
		    list.sort();
		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
//		    beginGroupForFile((*it), t);
		    t << "# Begin Source File\n\nSOURCE=" << (*it) << endl << endl;
		    QString compilePCH;
		    QStringList customDependencies;
		    QString createMOC;
		    QString buildCmdsR, buildCmdsD;
		    QString buildCmds = "\nBuildCmds= \\\n";
		    // Create unique baseID
		    QString base = (*it);
		    {
			base.replace(QRegExp("\\..*$"), "").upper();
			base.replace(QRegExp("[^a-zA-Z]"), "_");
		    }
		    if (usePCH && precompH.endsWith(*it)) {
			QString basicBuildCmd = QString("\tcl.exe /TP /W3 /FD /c /D \"WIN32\" /Yc /Fp\"%1\" /Fo\"%2\" %3 %4 %5 %6 %7 %8 %9 /D \"")
							.arg(precompPch)
							.arg(precompObj)
							.arg(var("MSVCDSP_INCPATH"))
							.arg(var("MSVCDSP_DEFINES"))
							.arg(var("MSVCDSP_CXXFLAGS"));
			buildCmdsR = basicBuildCmd
					    .arg("/D \"NDEBUG\"")
					    .arg(var("QMAKE_CXXFLAGS_RELEASE"))
					    .arg(var("MSVCDSP_MTDEF"))
					    .arg(var("MSVCDSP_RELDEFS"));
			buildCmdsD = basicBuildCmd
					    .arg("/D \"_DEBUG\" /Od")
					    .arg(var("QMAKE_CXXFLAGS_DEBUG"))
					    .arg(var("MSVCDSP_MTDEFD"))
					    .arg(var("MSVCDSP_DEBUG_OPT"));
			if (project->first("TEMPLATE") == "vcapp") {	// App
			    buildCmdsR += var("MSVCDSP_WINCONDEF");
			    buildCmdsD += var("MSVCDSP_WINCONDEF");
			} else if (project->isActiveConfig("dll")) {	// Dll
			    buildCmdsR += "_WINDOWS\" /D \"_USRDLL";
			    buildCmdsD += "_WINDOWS\" /D \"_USRDLL";
			} else {					// Lib
			    buildCmdsR += "_LIB";
			    buildCmdsD += "_LIB";
			}
			buildCmdsR += "\" /Fd\"$(IntDir)\\\\\" " + (*it) + " \\\n";
			buildCmdsD += "\" /Fd\"$(IntDir)\\\\\" " + (*it) + " \\\n";

			compilePCH = precompPch + " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n   $(BuildCmds)\n\n";

			QStringList &tmp = findDependencies(precompH);
			if(!tmp.isEmpty()) // Got Deps for PCH
			    customDependencies += tmp;
		    }
		    if (project->isActiveConfig("moc") && !findMocDestination((*it)).isEmpty()) {
			QString mocpath = var( "QMAKE_MOC" );
			mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";
			buildCmds += "\t" + mocpath + (*it)  + " -o " + findMocDestination((*it)) + " \\\n";
			createMOC  = "\"" + findMocDestination((*it)) +	"\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n   $(BuildCmds)\n\n";
			customDependencies += "\"$(QTDIR)\\bin\\moc.exe\"";
		    }
		    if (!createMOC.isEmpty() || !compilePCH.isEmpty()) {
			bool doMOC = !createMOC.isEmpty();
			bool doPCH = !compilePCH.isEmpty();
			QString build = "\n\n# Begin Custom Build - "+ 
					QString(doMOC?"Moc'ing ":"") +
					QString((doMOC&&doPCH)?" and ":"") +
					QString(doPCH?"Creating PCH cpp from ":"") +
					(*it) + "...\nInputPath=.\\" + (*it) + "\n\n" +
					buildCmds + "%1\n" +
					createMOC + 
					compilePCH +
					"# End Custom Build\n\n";

			t << "USERDEP_" << base << "=" << valGlue(customDependencies, "\"", "\" \"", "\"") << endl << endl;
			t << "!IF  \"$(CFG)\" == \""     << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build.arg(buildCmdsR)
			  << "!ELSEIF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\""   << build.arg(buildCmdsD)
			  << "!ENDIF " << endl << endl;
		    }
		    t << "# End Source File" << endl;
		}
//		endGroups(t);
	    } else if(variable == "MSVCDSP_FORMSOURCES" || variable == "MSVCDSP_FORMHEADERS") {
		if(project->variables()["FORMS"].isEmpty())
		    continue;

		QString uiSourcesDir;
		QString uiHeadersDir;
		if(!project->variables()["UI_DIR"].isEmpty()) {
		    uiSourcesDir = project->first("UI_DIR");
		    uiHeadersDir = project->first("UI_DIR");
		} else {
		    if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() )
			uiSourcesDir = project->first("UI_SOURCES_DIR");
		    else
			uiSourcesDir = "";
		    if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() )
			uiHeadersDir = project->first("UI_HEADERS_DIR");
		    else
			uiHeadersDir = "";
		}

		QStringList list = project->variables()["FORMS"];
		if(!project->isActiveConfig("flat"))
		    list.sort();
		QString ext = variable == "MSVCDSP_FORMSOURCES" ? ".cpp" : ".h";
		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
		    QString base = (*it);
		    int dot = base.findRev(".");
  		    base.replace( dot, base.length() - dot, ext );
		    QString fname = base;

		    int lbs = fname.findRev( "\\" );
		    QString fpath;
		    if ( lbs != -1 )
			fpath = fname.left( lbs + 1 );
		    fname = fname.right( fname.length() - lbs - 1 );

		    if ( ext == ".cpp" && !uiSourcesDir.isEmpty() )
			fname.prepend(uiSourcesDir);
		    else if ( ext == ".h" && !uiHeadersDir.isEmpty() )
			fname.prepend(uiHeadersDir);
		    else
			fname = base;
//		    beginGroupForFile(fname, t);
		    t << "# Begin Source File\n\nSOURCE=" << fname
		      << "\n# End Source File" << endl;
		}
//		endGroups(t);
	    } else if(variable == "MSVCDSP_TRANSLATIONS" ) {
		if(project->variables()["TRANSLATIONS"].isEmpty())
		    continue;

		t << "# Begin Group \"Translations\"\n";
		t << "# Prop Default_Filter \"ts\"\n";

		QStringList list = project->variables()["TRANSLATIONS"];
		if(!project->isActiveConfig("flat"))
		    list.sort();
		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
		    QString sify = *it;
		    sify.replace('/', '\\' );
		    QString base = (*it);
		    base.replace(QRegExp("\\..*$"), "").upper();
		    base.replace(QRegExp("[^a-zA-Z]"), "_");

//		    beginGroupForFile(sify, t);
		    t << "# Begin Source File\n\nSOURCE=" << sify << endl;
		    t << "\n# End Source File" << endl;
		}
//		endGroups(t);
		t << "\n# End Group\n";
	    } else if (variable == "MSVCDSP_MOCSOURCES" && project->isActiveConfig("moc")) {
		if ( project->variables()["SRCMOC"].isEmpty())
		    continue;

		QString mocpath = var( "QMAKE_MOC" );
		mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";

		QStringList list = project->variables()["SRCMOC"];
		if(!project->isActiveConfig("flat"))
		    list.sort();
		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
//		    beginGroupForFile((*it), t);
		    t << "# Begin Source File\n\nSOURCE=" << (*it) << endl;
		    if ( project->isActiveConfig("moc") && (*it).endsWith(Option::cpp_moc_ext)) {
			QString base = (*it);
			base.replace(QRegExp("\\..*$"), "").upper();
			base.replace(QRegExp("[^a-zA-Z]"), "_");

			QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) +
					"...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\""
					" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"
					"\t" + mocpath + findMocSource((*it)) + " -o " +
					(*it) + "\n\n" "# End Custom Build\n\n";

			t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl;

			t << "!IF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build
			  << "!ELSEIF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\""
			  << build << "!ENDIF " << endl << endl;
		    }
		    t << "# End Source File" << endl;
		}
//		endGroups(t);
	    } else if(variable == "MSVCDSP_PICTURES") {
		if(project->variables()["IMAGES"].isEmpty())
		    continue;

		t << "# Begin Group \"Images\"\n"
		  << "# Prop Default_Filter \"png jpeg bmp xpm\"\n";

		QStringList list = project->variables()["IMAGES"];
		if(!project->isActiveConfig("flat"))
		    list.sort();
		QStringList::Iterator it;

		// dump the image list to a file UIC can read.
		QFile f( "images.tmp" );
		f.open( IO_WriteOnly );
		QTextStream ts( &f );
		for( it = list.begin(); it != list.end(); ++it )
		    ts << " " << *it;
		f.close();

		// create an output step for images not more than once
		bool imagesBuildDone = FALSE;
		for( it = list.begin(); it != list.end(); ++it ) {
//		    beginGroupForFile((*it), t);
		    t << "# Begin Source File\n\nSOURCE=" << (*it) << endl;

		    QString base = (*it);
		    QString uicpath = var("QMAKE_UIC");
		    uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " ";

		    if ( !imagesBuildDone ) {
			imagesBuildDone = TRUE;
			QString build = "\n\n# Begin Custom Build - Creating image collection...\n"
			    "InputPath=.\\" + base + "\n\n";

			build += "\"" + project->first("QMAKE_IMAGE_COLLECTION") + "\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n";
			build += "\t" + uicpath + "-embed " + project->first("QMAKE_ORIG_TARGET") + " -f images.tmp -o "
				      + project->first("QMAKE_IMAGE_COLLECTION") + "\n\n";
			build.append("# End Custom Build\n\n");

			t << "USERDEP_" << base << "=";
			QStringList::Iterator it2 = list.begin();
			while ( it2 != list.end() ) {
			    t << "\"" << (*it2) << "\"";
			    it2++;
			    if ( it2 != list.end() )
				t << "\\\n";
			}
			t << endl << endl;

			t << "!IF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build
			  << "!ELSEIF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build
			  << "!ENDIF \n\n" << endl;
		    }

		    t << "# End Source File" << endl;
		}
//		endGroups(t);
		t << "\n# End Group\n";
	    } else if(variable == "MSVCDSP_FORMS") {
		if(project->variables()["FORMS"].isEmpty())
		    continue;

		t << "# Begin Group \"Forms\"\n"
		  << "# Prop Default_Filter \"ui\"\n";

		QString uicpath = var("QMAKE_UIC");
		uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " ";
		QString mocpath = var( "QMAKE_MOC" );
		mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";

		QStringList list = project->variables()["FORMS"];
		if(!project->isActiveConfig("flat"))
		    list.sort();
		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
		    QString base = (*it);
//		    beginGroupForFile(base, t);
		    t <<  "# Begin Source File\n\nSOURCE=" << base << endl;

		    QString fname = base;
		    fname.replace(".ui", "");
		    int lbs = fname.findRev( "\\" );
		    QString fpath;
		    if ( lbs != -1 )
			fpath = fname.left( lbs + 1 );
		    fname = fname.right( fname.length() - lbs - 1 );

		    QString mocFile;
		    if(!project->variables()["MOC_DIR"].isEmpty())
			mocFile = project->first("MOC_DIR");
		    else
			mocFile = fpath;

		    QString uiSourcesDir;
		    QString uiHeadersDir;
		    if(!project->variables()["UI_DIR"].isEmpty()) {
			uiSourcesDir = project->first("UI_DIR");
			uiHeadersDir = project->first("UI_DIR");
		    } else {
			if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() )
			    uiSourcesDir = project->first("UI_SOURCES_DIR");
			else
			    uiSourcesDir = fpath;
			if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() )
			    uiHeadersDir = project->first("UI_HEADERS_DIR");
			else
			    uiHeadersDir = fpath;
		    }

		    t << "USERDEP_" << base << "=\"$(QTDIR)\\bin\\moc.exe\" \"$(QTDIR)\\bin\\uic.exe\"" << endl << endl;

		    QString build = "\n\n# Begin Custom Build - Uic'ing " + base + "...\n"
			"InputPath=.\\" + base + "\n\n" "BuildCmds= \\\n\t" + uicpath + base +
				    " -o " + uiHeadersDir + fname + ".h \\\n" "\t" + uicpath  + base +
				    " -i " + fname + ".h -o " + uiSourcesDir + fname + ".cpp \\\n"
				    "\t" + mocpath + " " + uiHeadersDir +
				    fname + ".h -o " + mocFile + Option::h_moc_mod + fname + Option::h_moc_ext + " \\\n";

		    build.append("\n\"" + uiHeadersDir + fname + ".h\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\""  "\n"
				 "\t$(BuildCmds)\n\n"
				 "\"" + uiSourcesDir + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
				 "\t$(BuildCmds)\n\n"
				 "\"" + mocFile + Option::h_moc_mod + fname + Option::h_moc_ext + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
				 "\t$(BuildCmds)\n\n");

		    build.append("# End Custom Build\n\n");

		    t << "!IF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build
		      << "!ELSEIF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build
		      << "!ENDIF \n\n" << "# End Source File" << endl;
		}
//		endGroups(t);
		t << "\n# End Group\n";
	    } else if(variable == "MSVCDSP_LEXSOURCES") {
		if(project->variables()["LEXSOURCES"].isEmpty())
		    continue;

		t << "# Begin Group \"Lexables\"\n"
		  << "# Prop Default_Filter \"l\"\n";

		QString lexpath = var("QMAKE_LEX") + varGlue("QMAKE_LEXFLAGS", " ", " ", "") + " ";

		QStringList list = project->variables()["LEXSOURCES"];
		if(!project->isActiveConfig("flat"))
		    list.sort();
		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
		    QString fname = (*it);
//		    beginGroupForFile(fname, t);
		    t <<  "# Begin Source File\n\nSOURCE=" << fname << endl;
		    fname.replace(".l", Option::lex_mod + Option::cpp_ext.first());

		    QString build = "\n\n# Begin Custom Build - Lex'ing " + (*it) + "...\n"
			"InputPath=.\\" + (*it) + "\n\n"
				    "\"" + fname + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
				    "\t" + lexpath + (*it) + "\\\n"
				    "\tdel " + fname + "\\\n"
				    "\tcopy lex.yy.c " + fname + "\n\n" +
				    "# End Custom Build\n\n";
		    t << "!IF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build
		      << "!ELSEIF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build
		      << "!ENDIF \n\n" << build

		      << "# End Source File" << endl;
		}
//		endGroups(t);
		t << "\n# End Group\n";
	    } else if(variable == "MSVCDSP_YACCSOURCES") {
		if(project->variables()["YACCSOURCES"].isEmpty())
		    continue;

		t << "# Begin Group \"Yaccables\"\n"
		  << "# Prop Default_Filter \"y\"\n";

		QString yaccpath = var("QMAKE_YACC") + varGlue("QMAKE_YACCFLAGS", " ", " ", "") + " ";

		QStringList list = project->variables()["YACCSOURCES"];
		if(!project->isActiveConfig("flat"))
		    list.sort();
		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
		    QString fname = (*it);
//		    beginGroupForFile(fname, t);
		    t <<  "# Begin Source File\n\nSOURCE=" << fname << endl;
		    fname.replace(".y", Option::yacc_mod);

		    QString build = "\n\n# Begin Custom Build - Yacc'ing " + (*it) + "...\n"
			"InputPath=.\\" + (*it) + "\n\n"
				    "\"" + fname + Option::cpp_ext.first() + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n"
				    "\t" + yaccpath + (*it) + "\\\n"
				    "\tdel " + fname + Option::h_ext.first() + "\\\n"
				    "\tmove y.tab.h " + fname + Option::h_ext.first() + "\n\n" +
				    "\tdel " + fname + Option::cpp_ext.first() + "\\\n"
				    "\tmove y.tab.c " + fname + Option::cpp_ext.first() + "\n\n" +
				    "# End Custom Build\n\n";

		    t << "!IF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build
		      << "!ELSEIF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build
		      << "!ENDIF \n\n"
		      << "# End Source File" << endl;
		}
//		endGroups(t);
		t << "\n# End Group\n";
	    } else if( variable == "MSVCDSP_CONFIGMODE" ) {
		if( project->isActiveConfig( "debug" ) )
		    t << "Debug";
		else
		    t << "Release";
	    } else if( variable == "MSVCDSP_IDLSOURCES" ) {
		QStringList list = project->variables()["MSVCDSP_IDLSOURCES"];
		if(!project->isActiveConfig("flat"))
		    list.sort();
		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
		    t << "# Begin Source File" << endl << endl;
		    t << "SOURCE=" << (*it) << endl;
		    t << "# PROP Exclude_From_Build 1" << endl;
		    t << "# End Source File" << endl << endl;
		}
	    }
	    else
		t << var(variable);
	}
	t << line << endl;
    }
    t << endl;
    file.close();
    return TRUE;
}
/**
 * @brief Scans the given path for concert files.
 * Results are in a list which contains a QStringList for every concert.
 * @param startPath Scanning started at this path
 * @param path Path to scan
 * @param contents List of contents
 * @param separateFolders Are concerts in separate folders
 * @param firstScan When this is true, subfolders are scanned, regardless of separateFolders
 */
void ConcertFileSearcher::scanDir(QString startPath, QString path, QList<QStringList> &contents, bool separateFolders, bool firstScan)
{
    emit currentDir(path.mid(startPath.length()));

    QDir dir(path);
    foreach (const QString &cDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
        if (m_aborted)
            return;

        // Skip "Extras" folder
        if (QString::compare(cDir, "Extras", Qt::CaseInsensitive) == 0 ||
            QString::compare(cDir, ".actors", Qt::CaseInsensitive) == 0 ||
            QString::compare(cDir, "extrafanarts", Qt::CaseInsensitive) == 0)
            continue;

        // Handle DVD
        if (Helper::isDvd(path + QDir::separator() + cDir)) {
            contents.append(QStringList() << QDir::toNativeSeparators(path + "/" + cDir + "/VIDEO_TS/VIDEO_TS.IFO"));
            continue;
        }

        // Handle BluRay
        if (Helper::isBluRay(path + QDir::separator() + cDir)) {
            contents.append(QStringList() << QDir::toNativeSeparators(path + "/" + cDir + "/BDMV/index.bdmv"));
            continue;
        }

        // Don't scan subfolders when separate folders is checked
        if (!separateFolders || firstScan)
            scanDir(startPath, path + "/" + cDir, contents, separateFolders);
    }

    QStringList files;
    QStringList entries = getFiles(path);
    foreach (const QString &file, entries) {
        if (m_aborted)
            return;

        // Skip Trailers and Sample files
        if (file.contains("-trailer", Qt::CaseInsensitive) || file.contains("-sample", Qt::CaseInsensitive))
            continue;
        files.append(file);
    }
    files.sort();

    if (separateFolders) {
        QStringList concertFiles;
        foreach (const QString &file, files)
            concertFiles.append(QDir::toNativeSeparators(path + "/" + file));
        if (concertFiles.count() > 0)
            contents.append(concertFiles);
        return;
    }

    QRegExp rx("((part|cd)[\\s_]*)(\\d+)", Qt::CaseInsensitive);
    for (int i=0, n=files.size() ; i<n ; i++) {
        if (m_aborted)
            return;

        QStringList concertFiles;
        QString file = files.at(i);
        if (file.isEmpty())
            continue;

        concertFiles << QDir::toNativeSeparators(path + QDir::separator() + file);

        int pos = rx.indexIn(file);
        if (pos != -1) {
            QString left = file.left(pos) + rx.cap(1);
            QString right = file.mid(pos+rx.cap(1).size()+rx.cap(2).size());
            for (int x=0 ; x<n ; x++) {
                QString subFile = files.at(x);
                if (subFile != file) {
                    if (subFile.startsWith(left) && subFile.endsWith(right)) {
                        concertFiles << QDir::toNativeSeparators(path + QDir::separator() + subFile);
                        files[x] = ""; // set an empty file name, this way we can skip this file in the main loop
                    }
                }
            }
        }
        if (concertFiles.count() > 0 )
            contents.append(concertFiles);
    }
}
Exemple #11
0
void CliApplication::status() const
{
    // Output the status of all the plugins that should (have) normally be(en)
    // loaded, so first make sure that we have at least one of them

    if (mPluginManager->loadedPlugins().isEmpty()) {
        std::cout << "No plugins could be found." << std::endl;

        return;
    }

    // First, we retrieve all the plugins information

    QStringList pluginsInfo = QStringList();

    for (auto plugin : mPluginManager->plugins()) {
        // Retrieve the plugin and its status

        QString pluginInfo = plugin->name()+": ";

        // Retrieve the plugin's status

        switch (plugin->status()) {
        case Plugin::Status::NotWanted:
            pluginInfo += "the plugin is not wanted.";

            break;
        case Plugin::Status::NotNeeded:
            pluginInfo += "the plugin is not needed.";

            break;
        case Plugin::Status::Loaded:

            pluginInfo += "the plugin is loaded and fully functional.";

            break;
        case Plugin::Status::NotLoaded:
            pluginInfo += QString("the plugin could not be loaded due to the following problem: %1.").arg(formatMessage(plugin->statusErrors()));

            break;
        case Plugin::Status::NotPlugin:
            pluginInfo += "this is not a plugin.";

            break;
        case Plugin::Status::OldPlugin:
            pluginInfo += "the plugin could not be loaded (one or several of the interfaces it supports are too old).";

            break;
        case Plugin::Status::NotCorePlugin:
            pluginInfo += "the plugin claims to be the core plugin, but it is not.";

            break;
        case Plugin::Status::InvalidCorePlugin:
            pluginInfo += "the plugin should be the core plugin, but it does not support the core interface.";

            break;
        case Plugin::Status::NotCliPluginNoCliSupport:
            pluginInfo += "the plugin supports the CLI interface, but it does not claim to be CLI-capable.";

            break;
        case Plugin::Status::NotCliPluginNoCliInterface:
            pluginInfo += "the plugin claims to be CLI-capable, but it does not support the CLI interface.";

            break;
        case Plugin::Status::MissingOrInvalidDependencies:
            if (plugin->statusErrorsCount() == 1) {
                pluginInfo += QString("the plugin could not be loaded due to the %1 plugin being missing or invalid.").arg(plugin->statusErrors());
            } else {
                pluginInfo += QString("the plugin could not be loaded due to missing or invalid plugins:\n%1").arg(plugin->statusErrors());
            }

            break;
        }

        // Add the plugin information to our list

        pluginsInfo << pluginInfo;
    }

    // Now, we can output the plugin information in alphabetical order

    pluginsInfo.sort(Qt::CaseInsensitive);

    if (pluginsInfo.count() == 1) {
        std::cout << "The following plugin is available:" << std::endl;
    } else {
        std::cout << "The following plugins are available:" << std::endl;
    }

    for (const auto &pluginInfo : pluginsInfo) {
        std::cout << " - " << pluginInfo.toStdString() << std::endl;
    }
}
Exemple #12
0
void BranchesTree::addNode(ItemType headerType, Reference::Type type)
{
    // получаем нужную инфу по типу
    QStringList tempList = g->getAllRefNames(type, !Git::optOnlyLoaded);

    // делаем хедер и добавляем на верхний уровень
    BranchesTreeItem *node;
    switch (headerType) {
    case (BranchesTree::HeaderBranches):
        node = new BranchesTreeItem(this, QStringList("Branches"), headerType);
        break;
    case (BranchesTree::HeaderRemotes):
        node = new BranchesTreeItem(this, QStringList("Remotes"), headerType);
        break;
    case (BranchesTree::HeaderTags):
        node = new BranchesTreeItem(this, QStringList("Tags"), headerType);
        break;
    default:
        break;
    }

    tempList.sort();

    QFont font = node->font(0);
    font.setBold(true);
    node->setFont(0, font);


    addTopLevelItem(node);

    BranchesTreeItem *tempItemList;

    // заполняем дерево потомками
    FOREACH_SL (it, tempList) {
        bool isCurrent = (g->currentBranch().compare(*it) == 0);
        switch (headerType) {
        case (HeaderBranches):
            tempItemList = new BranchesTreeItem(node, QStringList(QString(*it)), LeafBranch);
            if (isCurrent) {
                QFont font = tempItemList->font(0);
                font.setBold(true);
                tempItemList->setFont(0, font);
                tempItemList->setForeground(0, Qt::red);
            }
            tempItemList->setIcon(0, branchIcon);
            if (*it == "master") {
                tempItemList->setIcon(0, masterBranchIcon);
            }
            break;
        case (HeaderRemotes):
            tempItemList = new BranchesTreeItem(node, QStringList(QString(*it)), LeafRemote);
            tempItemList->setIcon(0, branchIcon);
            break;
        case (HeaderTags):
            tempItemList = new BranchesTreeItem(node, QStringList(QString(*it)), LeafTag);
            tempItemList->setIcon(0, tagIcon);
            break;
        default:
            break;
        }
        tempItemList->setBranch(QString(*it));
    }
Exemple #13
0
void FunctionWidget::setAttributes(DatabaseModel *model, OperationList *op_list, Schema *schema, Function *func)
{
	vector<BaseObject *> languages;
	Language *lang=nullptr;
	QStringList list;
	unsigned count=0, i;
	Parameter param;
	PgSQLType aux_type;

	connect(parameter_wgt, SIGNAL(finished(int)), this, SLOT(handleParameter(int)));

	BaseObjectWidget::setAttributes(model, op_list, func, schema);
	languages=model->getObjects(OBJ_LANGUAGE);

	while(!languages.empty())
	{
		lang=dynamic_cast<Language *>(languages.back());
		languages.pop_back();
		list.append(lang->getName());
	}

	list.sort();
	language_cmb->addItems(list);

	if(func)
	{
		aux_type=func->getReturnType();

		language_cmb->setCurrentIndex(language_cmb->findText(func->getLanguage()->getName()));
		func_type_cmb->setCurrentIndex(func_type_cmb->findText(~func->getFunctionType()));
		window_func_chk->setChecked(func->isWindowFunction());
		leakproof_chk->setChecked(func->isLeakProof());
		exec_cost_spb->setValue(func->getExecutionCost());
		rows_ret_spb->setValue(func->getRowAmount());
		behavior_cmb->setCurrentIndex(behavior_cmb->findText(~func->getBehaviorType()));
		security_cmb->setCurrentIndex(security_cmb->findText(~func->getSecurityType()));

		if(func->isReturnSetOf())
			set_rb->setChecked(true);
		else if(func->isReturnTable())
			table_rb->setChecked(true);
		else
			simple_rb->setChecked(true);

		count=func->getParameterCount();

		parameters_tab->blockSignals(true);
		return_tab->blockSignals(true);

		for(i=0; i < count; i++)
		{
			parameters_tab->addRow();
			param=func->getParameter(i);
			showParameterData(param,parameters_tab,i);
		}
		parameters_tab->clearSelection();

		count=func->getReturnedTableColumnCount();
		if(count > 0)
		{
			ret_table_gb->setVisible(true);
			ret_type->setVisible(false);

			for(i=0; i < count; i++)
			{
				return_tab->addRow();
				param=func->getReturnedTableColumn(i);
				showParameterData(param,return_tab,i);
			}
		}
		return_tab->clearSelection();


		if(!func->getLibrary().isEmpty())
		{
			symbol_edt->setText(func->getSymbol());
			library_edt->setText(func->getLibrary());
		}
		else
		{
			source_code_txt->setPlainText(Utf8String::create(func->getSourceCode()));
		}

		parameters_tab->blockSignals(false);
		return_tab->blockSignals(false);
	}

	ret_type->setAttributes(aux_type, model);
}
QString SettingsManager::getReport()
{
	QString report;
	QTextStream stream(&report);
	stream.setFieldAlignment(QTextStream::AlignLeft);
	stream << QLatin1String("Settings:\n");

	QStringList excludeValues;
	QSettings defaults(QLatin1String(":/schemas/options.ini"), QSettings::IniFormat);
	const QStringList defaultsGroups = defaults.childGroups();

	for (int i = 0; i < defaultsGroups.count(); ++i)
	{
		defaults.beginGroup(defaultsGroups.at(i));

		const QStringList keys = defaults.childGroups();

		for (int j = 0; j < keys.count(); ++j)
		{
			const QString type = defaults.value(QStringLiteral("%1/type").arg(keys.at(j))).toString();

			if (type == QLatin1String("string") || type == QLatin1String("path"))
			{
				excludeValues.append(QStringLiteral("%1/%2").arg(defaultsGroups.at(i)).arg(keys.at(j)));
			}
		}

		defaults.endGroup();
	}

	QHash<QString, int> overridenValues;
	QSettings overrides(m_overridePath, QSettings::IniFormat);
	const QStringList overridesGroups = overrides.childGroups();

	for (int i = 0; i < overridesGroups.count(); ++i)
	{
		overrides.beginGroup(overridesGroups.at(i));

		const QStringList keys = overrides.allKeys();

		for (int j = 0; j < keys.count(); ++j)
		{
			if (overridenValues.contains(keys.at(j)))
			{
				++overridenValues[keys.at(j)];
			}
			else
			{
				overridenValues[keys.at(j)] = 1;
			}
		}

		overrides.endGroup();
	}

	QStringList keys = m_defaults.keys();
	keys.sort();

	for (int i = 0; i < keys.count(); ++i)
	{
		stream << QLatin1Char('\t');
		stream.setFieldWidth(50);
		stream << keys.at(i);
		stream.setFieldWidth(20);

		if (excludeValues.contains(keys.at(i)))
		{
			stream << QLatin1Char('-');
		}
		else
		{
			stream << m_defaults[keys.at(i)].toString();
		}

		stream << ((m_defaults[keys.at(i)] == getValue(keys.at(i))) ? QLatin1String("default") : QLatin1String("non default"));
		stream << (overridenValues.contains(keys.at(i)) ? QStringLiteral("%1 override(s)").arg(overridenValues[keys.at(i)]) : QLatin1String("no overrides"));
		stream.setFieldWidth(0);
		stream << QLatin1Char('\n');
	}

	stream << QLatin1Char('\n');

	return report;
}
// Returns true if both are equal.
QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportFrom(const QString &makefile)
{
    QMakeStep *qs = qmakeStep();
    if (QFileInfo(makefile).exists() && qs) {
        FileName qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(makefile);
        BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit());
        if (!version)
            return MakefileForWrongProject;
        if (QtSupport::QtVersionManager::makefileIsFor(makefile, qs->project()->projectFilePath().toString())
                != QtSupport::QtVersionManager::SameProject) {
            if (debug) {
                qDebug() << "different profile used to generate the Makefile:"
                         << makefile << " expected profile:" << qs->project()->projectFilePath();
            }
            return MakefileIncompatible;
        }
        if (version->qmakeCommand() == qmakePath) {
            // same qtversion
            QPair<BaseQtVersion::QmakeBuildConfigs, QString> result =
                    QtVersionManager::scanMakeFile(makefile, version->defaultBuildConfig());
            if (qmakeBuildConfiguration() == result.first) {
                // The qmake Build Configuration are the same,
                // now compare arguments lists
                // we have to compare without the spec/platform cmd argument
                // and compare that on its own
                QString workingDirectory = QFileInfo(makefile).absolutePath();
                QStringList actualArgs;
                QString userArgs = qs->userArguments();
                // This copies the settings from userArgs to actualArgs (minus some we
                // are not interested in), splitting them up into individual strings:
                extractSpecFromArguments(&userArgs, workingDirectory, version, &actualArgs);
                actualArgs = qs->deducedArguments() + actualArgs + qs->deducedArgumentsAfter();
                FileName actualSpec = qs->mkspec();

                QString qmakeArgs = result.second;
                QStringList parsedArgs;
                FileName parsedSpec = extractSpecFromArguments(&qmakeArgs, workingDirectory, version, &parsedArgs);

                if (debug) {
                    qDebug() << "Actual args:" << actualArgs;
                    qDebug() << "Parsed args:" << parsedArgs;
                    qDebug() << "Actual spec:" << actualSpec.toString();
                    qDebug() << "Parsed spec:" << parsedSpec.toString();
                }

                // Comparing the sorted list is obviously wrong
                // Though haven written a more complete version
                // that managed had around 200 lines and yet faild
                // to be actually foolproof at all, I think it's
                // not feasible without actually taking the qmake
                // command line parsing code

                // Things, sorting gets wrong:
                // parameters to positional parameters matter
                //  e.g. -o -spec is different from -spec -o
                //       -o 1 -spec 2 is diffrent from -spec 1 -o 2
                // variable assignment order matters
                // variable assignment vs -after
                // -norecursive vs. recursive
                actualArgs.sort();
                parsedArgs.sort();
                if (actualArgs == parsedArgs) {
                    // Specs match exactly
                    if (actualSpec == parsedSpec)
                        return MakefileMatches;
                    // Actual spec is the default one
//                    qDebug() << "AS vs VS" << actualSpec << version->mkspec();
                    if ((actualSpec == version->mkspec() || actualSpec == FileName::fromLatin1("default"))
                        && (parsedSpec == version->mkspec() || parsedSpec == FileName::fromLatin1("default") || parsedSpec.isEmpty()))
                        return MakefileMatches;
                }
                return MakefileIncompatible;
            } else {
                if (debug)
                    qDebug() << "different qmake buildconfigurations buildconfiguration:"
                             << qmakeBuildConfiguration() << " Makefile:" << result.first;
                return MakefileIncompatible;
            }
        } else {
            if (debug)
                qDebug() << "different Qt versions, buildconfiguration:" << version->qmakeCommand().toString()
                         << " Makefile:"<< qmakePath.toString();
            return MakefileForWrongProject;
        }
    }
    return MakefileMissing;
}
void MenuEventEditor::setupEventTree()
{
	QTreeWidgetItem *objectItem;
	QTreeWidgetItem *eventItem;
	QStringList objectNames;
	if (mainRef != NULL)
		objectNames = (*mainRef)->getObjectNamesByType(MenuObject::TYPE_SELECTABLEAREA) + (*mainRef)->getObjectNamesByType(MenuObject::TYPE_ITEMLIST);
	else if (popupRef != NULL)
		objectNames = (*popupRef)->getObjectNamesByType(MenuObject::TYPE_SELECTABLEAREA) + (*popupRef)->getObjectNamesByType(MenuObject::TYPE_ITEMLIST);
	else if (titleMenuLayout != NULL)
		objectNames = titleMenuLayout->getObjectNamesByType(MenuObject::TYPE_SELECTABLEAREA) + titleMenuLayout->getObjectNamesByType(MenuObject::TYPE_ITEMLIST);
	objectNames.sort();
	objectItem = new QTreeWidgetItem(QStringList() << "Menu's Global Events" << "-1");
	objectItem->setFlags(Qt::ItemIsEnabled);
	twObjects->addTopLevelItem(objectItem);
	eventItem = new QTreeWidgetItem(QStringList() << "On Accept" << "0");
	eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
	objectItem->addChild(eventItem);
	eventItem->setSelected(true);
	eventItem = new QTreeWidgetItem(QStringList() << "On Cancel" << "1");
	eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
	objectItem->addChild(eventItem);
	eventItem = new QTreeWidgetItem(QStringList() << "On Load" << "2");
	eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
	objectItem->addChild(eventItem);
	eventItem = new QTreeWidgetItem(QStringList() << "On Leave" << "3");
	eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
	objectItem->addChild(eventItem);
	eventItem = new QTreeWidgetItem(QStringList() << "Up Arrow" << "4");
	eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
	objectItem->addChild(eventItem);
	eventItem = new QTreeWidgetItem(QStringList() << "Down Arrow" << "5");
	eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
	objectItem->addChild(eventItem);
	eventItem = new QTreeWidgetItem(QStringList() << "Left Arrow" << "6");
	eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
	objectItem->addChild(eventItem);
	eventItem = new QTreeWidgetItem(QStringList() << "Right Arrow" << "7");
	eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
	objectItem->addChild(eventItem);
	objectItem->setExpanded(true);
	for (int i = 0; i < objectNames.size(); ++i)
	{
		MenuObject *object;
		int objectType;
		if (mainRef != NULL)
			object = (*mainRef)->getObjectByName(objectNames[i]);
		else if (popupRef != NULL)
			object = (*popupRef)->getObjectByName(objectNames[i]);
		else if (titleMenuLayout != NULL)
			object = titleMenuLayout->getObjectByName(objectNames[i]);
		else
			object = NULL;
		objectType = object->getType();
		objectItem = new QTreeWidgetItem(QStringList() << objectNames[i] << "-1");
		objectItem->setFlags(Qt::ItemIsEnabled);
		twObjects->addTopLevelItem(objectItem);
		if (objectType == MenuObject::TYPE_SELECTABLEAREA)
		{
			eventItem = new QTreeWidgetItem(QStringList() << "On highlight" << "0");
			eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
			objectItem->addChild(eventItem);
			eventItem = new QTreeWidgetItem(QStringList() << "Left Arrow" << "1");
			eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
			objectItem->addChild(eventItem);
			eventItem = new QTreeWidgetItem(QStringList() << "Right Arrow" << "2");
			eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
			objectItem->addChild(eventItem);
			eventItem = new QTreeWidgetItem(QStringList() << "Up Arrow" << "3");
			eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
			objectItem->addChild(eventItem);
			eventItem = new QTreeWidgetItem(QStringList() << "Down Arrow" << "4");
			eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
			objectItem->addChild(eventItem);
			eventItem = new QTreeWidgetItem(QStringList() << "On Selected" << "5");
			eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
			objectItem->addChild(eventItem);
			eventItem = new QTreeWidgetItem(QStringList() << "On Cancel" << "6");
			eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
			objectItem->addChild(eventItem);
		}
		else if (objectType == MenuObject::TYPE_ITEMLIST)
		{
			eventItem = new QTreeWidgetItem(QStringList() << "Selection Changed" << "0");
			eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
			objectItem->addChild(eventItem);
			eventItem = new QTreeWidgetItem(QStringList() << "On Accept" << "1");
			eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
			objectItem->addChild(eventItem);
			eventItem = new QTreeWidgetItem(QStringList() << "On Cancel" << "2");
			eventItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
			objectItem->addChild(eventItem);
		}
	}
}
Exemple #17
0
//=============================================================================
// Perform Import operation
bool KexiMigrate::performImport(Kexi::ObjectStatus* result)
{
    if (result)
        result->clearStatus();

    KexiDB::DriverManager drvManager;
    KexiDB::Driver *destDriver = drvManager.driver(
                                     m_migrateData->destination->connectionData()->driverName);
    if (!destDriver) {
        result->setStatus(&drvManager,
                          i18n("Could not create database \"%1\".",
                               m_migrateData->destination->databaseName()));
        return false;
    }

    QStringList tables;

    // Step 1 - connect
    kDebug() << "KexiMigrate::performImport() CONNECTING...";
    if (!drv_connect()) {
        kDebug() << "Couldnt connect to database server";
        if (result)
            result->setStatus(i18n("Could not connect to data source \"%1\".",
                                   m_migrateData->source->serverInfoString()), "");
        return false;
    }

    // Step 2 - get table names
    kDebug() << "KexiMigrate::performImport() GETTING TABLENAMES...";
    if (!tableNames(tables)) {
        kDebug() << "Couldnt get list of tables";
        if (result)
            result->setStatus(
                i18n("Could not get a list of table names for data source \"%1\".",
                     m_migrateData->source->serverInfoString()), "");
        return false;
    }

    // Check if there are any tables
    if (tables.isEmpty()) {
        kDebug() << "There were no tables to import";
        if (result)
            result->setStatus(
                i18n("No tables to import found in data source \"%1\".",
                     m_migrateData->source->serverInfoString()), "");
        return false;
    }

    // Step 3 - Read table schemas
    tables.sort();
    m_tableSchemas.clear();
    if (!destDriver) {
        result->setStatus(&drvManager);
        return false;
    }
    const bool kexi__objects_exists = tables.contains("kexi__objects");
    QStringList kexiDBTables;
    if (kexi__objects_exists) {
        tristate res = drv_queryStringListFromSQL(
                           QString::fromLatin1("SELECT o_name FROM kexi__objects WHERE o_type=%1")
                           .arg((int)KexiDB::TableObjectType), 0, kexiDBTables, -1);
        if (res == true) {
            // prepend KexiDB-compatible tables to 'tables' list, so we'll copy KexiDB-compatible tables first,
            // to make sure existing IDs will not be in conflict with IDs newly generated for non-KexiDB tables
            kexiDBTables.sort();
            foreach(const QString& tableName, kexiDBTables)
            tables.removeAt(tables.indexOf(tableName));
//kDebug() << "KexiDB-compat tables: " << kexiDBTables;
//kDebug() << "non-KexiDB tables: " << tables;
        }
    }
Exemple #18
0
int main(int argc, char **argv)
{
// Check windows
#if _WIN32 || _WIN64
#if _WIN64
#define ENVIRONMENT64
#else
#define ENVIRONMENT32
#endif
#endif

// Check GCC
#if __GNUC__
#if __x86_64__ || __ppc64__
#define ENVIRONMENT64
#else
#define ENVIRONMENT32
#endif
#endif

	QProcess *process = new QProcess();
	QString sDebugMode;		//Release mode
	QString sArchitecture;	//Win32 architecture
	QStringList lDebugMessages;
	int nRetVal = 0;

#ifdef _DEBUG
	sDebugMode = "d";
#else
	sDebugMode = "r";
#endif
#ifdef ENVIRONMENT32
	sArchitecture = "1";
#else
	sArchitecture = "2";
#endif
	QString sConfigureFileName = "AutoStartConfigure.bat";
	QString sConfigureFilePath = QDir::currentPath() + QDir::separator() + sConfigureFileName;
	if (QFile(sConfigureFilePath).exists())
	{
		process->start(sConfigureFileName, QStringList() << sArchitecture << sDebugMode << QT_VERSION_STR);
		if(process->waitForStarted())
		{ 
			if (process->waitForFinished())
			{
				lDebugMessages.append(QString(__FUNCTION__) + ": " + sConfigureFileName + ", output: \n" + process->readAll());
				qDebug() << lDebugMessages.last();
				while(process->waitForReadyRead())
				{
					lDebugMessages.append(QString(__FUNCTION__) + ": " + process->readAll());
					qDebug() << lDebugMessages.last();
				}
			}
		}
	}
	else
	{
		lDebugMessages.append(QString(__FUNCTION__) + ": " + "Configuration file not found: " + sConfigureFileName);
		qDebug() << lDebugMessages.last();
	}

	bool bProceed = true;
	MainAppExchange appExchange(argc, argv, MAIN_PROGRAM_SHARED_MEM_KEY);

	bool bFirstUserInitialization = false;
	QVariant tmpVariant;
	GlobalApplicationInformation *globAppInformation = appExchange.getGlobalAppInformationObjectPointer(bFirstUserInitialization);
	//Now the BrainStim.ini file is initialized/created if it did not yet exist.
	QString sConfigurationFilePath = globAppInformation->getConfigurationFilePath();
	if (bFirstUserInitialization)
	{
		lDebugMessages.append(QString(__FUNCTION__) + ": " + "First time this account initializes BrainStim: " + sConfigurationFilePath);
		qDebug() << lDebugMessages.last();
	}
	
	if (argc >= 2)
	{
		QString sArg = QString(argv[1]);
		if (sArg == "-i" || sArg == "-I")//only initialization, to make sure INI file exists?
			goto EXITAPP;
	}

	if (globAppInformation->getSettingsInformation(REGISTRY_ENABLECUSTOMUSERLOGINS, tmpVariant) == true)
	{
		if(tmpVariant.toBool() == true)
		{
			QStringList lRegisteredUsers;
			QList<QByteArray> lRegisteredPasswordHashes;
			globAppInformation->getRegisteredUserCredentials(lRegisteredUsers, lRegisteredPasswordHashes);
			LoginDialog* loginDialog = new LoginDialog(NULL);
			lRegisteredUsers.sort(Qt::CaseInsensitive);
			QList <LoginDialog::strcUserCredential> lUserCredentials;
			for (int i = 0; i < lRegisteredUsers.count(); i++)
			{
				LoginDialog::strcUserCredential tmpUserCredential;
				tmpUserCredential.sUserName = lRegisteredUsers.at(i);
				tmpUserCredential.baPasswordHash = lRegisteredPasswordHashes.at(i);
				lUserCredentials.append(tmpUserCredential);
			}
			loginDialog->insertUsers(lUserCredentials);
			loginDialog->exec();
			QString sLogonName = "";
			QByteArray baLogonHashedPass;
			loginDialog->getCurrentUserCredentials(sLogonName, baLogonHashedPass);
			//bool bResult = 
				globAppInformation->setCurrentUserCredentials(sLogonName, baLogonHashedPass);
		}
	}

	bool bDoAllowMultipleInstances = false;
	if (argc >= 2)
	{
		QString tempStr = "";
		for (int i = 1; i < argc; i++)
		{
			tempStr = argv[i];
			if ((tempStr == "-m") || (tempStr == "-M"))//allow multiple instances?
			{
				bDoAllowMultipleInstances = true;
				break;
			}
			else if ((tempStr == "-o") || (tempStr == "-O"))//options defined?
			{
				if (i < (argc - 1))//another argument available?
				{
					i = i + 1;
					tempStr = argv[i];
					GlobalApplicationInformation::MainProgramModeFlags flags = GlobalApplicationInformation::Default;
					flags = (flags | GlobalApplicationInformation::MainProgramModeFlag(tempStr.toInt()));
					if (flags & GlobalApplicationInformation::AllowMultipleInstances)
					{
						bDoAllowMultipleInstances = true;
						break;
					}
				}
			}
		}
	}

	if (appExchange.isRunning())
	{
		appExchange.sendMessage("Log(\"New BrainStim Instance Initializing...\");");
		//if (appExchange.getSharedDataSegment("AllowMultipleInstance") == "false")
		QVariant tmpVariant;
		if ((globAppInformation->getSettingsInformation(REGISTRY_ALLOWMULTIPLEINHERITANCE, tmpVariant) == false) && (bDoAllowMultipleInstances == false))
			bProceed = false;
		if ((tmpVariant == false) && (bDoAllowMultipleInstances == false))
		{
			QStringList sFilesToOpen;
			int i;
			bool bExecuteDocument = false;
			if (argc > 2)
			{
				QString tempStr = "";
				for (i = 1; i<argc;i++)
				{
					tempStr = argv[i];
					if ((tempStr == "-f") || (tempStr == "-F"))//path exists?
					{				
						if (i<(argc-1))//another argument available?
						{
							i = i + 1;
							sFilesToOpen.append(QString(argv[i]).split(";"));//separate multiple files (cmd) using a ';' Character!
						}
					}
					else if ((tempStr == "-e") || (tempStr == "-E"))//Immediately execute the loaded (-f <document) document?
					{
						bExecuteDocument = true;
					}
				}
			}
			else if (argc == 2)//only path declared!
			{
				sFilesToOpen.append(QString(argv[1]).split(";"));
			}
			if(sFilesToOpen.isEmpty() == false)
			{
				for(i=0;i<sFilesToOpen.count();i++)
				{
					sFilesToOpen[i] = "\"" + QDir::cleanPath(sFilesToOpen.at(i)) + "\"";					
				}
				//BrainStim.openFiles(null,["E:/temp/1.txt","E:/temp/2.txt"]);
				QString sFileCombination = sFilesToOpen.join(",");
				appExchange.sendMessage("BrainStim.openFiles(null,[" + sFileCombination  + "]);");
			}
			appExchange.sendMessage("BrainStim.activateMainWindow();");
			if(bExecuteDocument)
				appExchange.sendMessage("BrainStim.executeActiveDocument();");
			bProceed = false;
		}
	}
	//else//First occurrence
	//{
	//	//globAppInformation->setMainAppInformationStructure();
	//}

	if(bProceed)
	{
		Q_INIT_RESOURCE(brainstim);
		MainWindow *appWindow = new MainWindow();
		appWindow->appendDebugMessages(lDebugMessages);
		appWindow->setGlobalApplicationInformationObject(globAppInformation);
		MainAppInfo::setMainWindow(appWindow);
		GlobalApplicationInformation::MainProgramModeFlags flags = GlobalApplicationInformation::Default;
		QString tempStr = "";
		if (argc > 2)
		{
			for (int i = 1; i<argc;i++)
			{
				tempStr = argv[i];
				if ((tempStr == "-f") || (tempStr == "-F"))//path exists?
				{				
					if (i<(argc-1))//another argument available?
					{
						i = i + 1;
						appWindow->setStartupFiles(argv[i]);//separate multiple files (cmd) using a ';' Character!
					}
				}
				else if ((tempStr == "-m") || (tempStr == "-M"))//allow multiple instances?
				{
					//see above handling
				}
				else if ((tempStr == "-o") || (tempStr == "-O"))//valid argument?
				{
					if (i<(argc-1))//another argument available?
					{
						i = i + 1;
						tempStr = argv[i];					
						flags = (flags | GlobalApplicationInformation::MainProgramModeFlag(tempStr.toInt()));
					}				
				}
				else if ((tempStr == "-v") || (tempStr == "-V"))//verbose mode?
				{
					flags = (flags | GlobalApplicationInformation::VerboseMode);
				}
				else if ((tempStr == "-e") || (tempStr == "-E"))//Immediately execute the loaded (-f <document) document?
				{
					flags = (flags | GlobalApplicationInformation::ExecuteDocument);
				}
			}
		}
		else if (argc == 2)//only one parameter defined!
		{
			tempStr = argv[1];
			if ((tempStr == "-v") || (tempStr == "-V"))//verbose mode?
			{
				flags = (flags | GlobalApplicationInformation::VerboseMode);
			}
			else if ((tempStr == "-m") || (tempStr == "-M"))//allow multiple instances?
			{
				//see above handling
			}
			//else if (tempStr == "-e" | tempStr == "-E")//Immediately execute the loaded (-f <document) document? --> doesn't work here because there's no file loaded, too few parameters
			//{
				//flags = (flags | GlobalApplicationInformation::ExecuteDocument);
			//}
			else
			{
				appWindow->setStartupFiles(argv[1]);
			}			
		}
		if (appExchange.isRunning())
			flags = flags | GlobalApplicationInformation::DisableNetworkServer;
		if (bFirstUserInitialization)
			flags = flags | GlobalApplicationInformation::UserFirstTimeInit;

		appWindow->initialize(flags);
		// connect message queue to the main window.
		bool bConnectResult = false;
		bConnectResult = QObject::connect(&appExchange, SIGNAL(messageAvailable(QString)), appWindow, SLOT(receiveExchangeMessage(QString)));
		bConnectResult = QObject::connect(appWindow, SIGNAL(TerminateAppExchange()), &appExchange, SLOT(stopRunning()));
		appWindow->show();//showMaximized() creates weird behaviour!;
		centerWidget(appWindow, false);
		appWindow->recoverLastScreenWindowSettings();
		appWindow->preExecuteTask();
		nRetVal = appExchange.exec();
		delete appWindow;
		appWindow = NULL;
	}
EXITAPP:
	return nRetVal;
}
Exemple #19
0
void LDeskBarPlugin::updateFiles(){
  QFileInfoList homefiles = LSession::handle()->DesktopFiles();
  QStringList favitems = LUtils::listFavorites();
  //Remember for format for favorites: <name>::::[app/dir/<mimetype>]::::<full path>
    for(int i=0; i<homefiles.length(); i++){
      QString type;
      if(homefiles[i].isDir()){ type="dir"; }
      else if(homefiles[i].fileName().endsWith(".desktop")){ type="app"; }
      else{ type=LXDG::findAppMimeForFile(homefiles[i].fileName()); }
      favitems << homefiles[i].fileName()+"::::"+type+"::::"+homefiles[i].absoluteFilePath();
      //qDebug() << "Desktop Item:" << favitems.last();
    }
  
  favitems.sort(); //sort them alphabetically
  //Now add the items to the lists
  appM->clear();
  dirM->clear();
  audioM->clear();
  videoM->clear();
  pictureM->clear();
  docM->clear();
  otherM->clear();
  for(int i=0; i<favitems.length(); i++){
    QString type = favitems[i].section("::::",1,1);
    QString name = favitems[i].section("::::",0,0);
    QString path = favitems[i].section("::::",2,50);
    if(type=="app"){
      //Add it to appM
      bool ok = false;
      XDGDesktop df = LXDG::loadDesktopFile(path, ok);
      if(ok){
        if( LXDG::checkValidity(df) && !df.isHidden ){ 
	  appM->addAction( newAction(df.filePath, df.name, LXDG::findIcon(df.icon, ":/images/default-application.png")) );
	}
      }
    }else if(type=="dir"){
      //Add it to dirM
      dirM->addAction( newAction(path, name, LXDG::findIcon("folder","")) );
    }else if(type.startsWith("audio/")){
      //Add it to audioM
      audioM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) );
    }else if(type.startsWith("video/")){
      //Add it to videoM
      videoM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) );
    }else if(type.startsWith("image/")){
      //Add it to pictureM
      if(LUtils::imageExtensions().contains(path.section("/",-1).section(".",-1).toLower()) ){
	pictureM->addAction( newAction(path, name, QIcon(path)) );
      }else{
        pictureM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) );
      }
    }else if(type.startsWith("text/")){
      //Add it to docM
      docM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) );
    }else{
      //Add it to otherM
      otherM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) );
    }

  }

    //Now update the file menu as appropriate
    fileM->clear();
    if(!audioM->isEmpty()){ fileM->addMenu(audioM); }
    if(!docM->isEmpty()){ fileM->addMenu(docM); }
    if(!pictureM->isEmpty()){ fileM->addMenu(pictureM); }
    if(!videoM->isEmpty()){ fileM->addMenu(videoM); }
    if(!otherM->isEmpty()){ fileM->addMenu(otherM); }
    //Check for a single submenu, and skip the main if need be
    disconnect(fileB->menu(), SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed()) );
    if(fileM->actions().length()==1){
      if(!audioM->isEmpty()){ fileB->setMenu(audioM); }
      else if(!pictureM->isEmpty()){ fileB->setMenu(pictureM); }
      else if(!videoM->isEmpty()){ fileB->setMenu(videoM); }
      else if(!docM->isEmpty()){ fileB->setMenu(docM); }
      else if(!otherM->isEmpty()){ fileB->setMenu(otherM); }
    }else{
      fileB->setMenu(fileM);	    
    }
    connect(fileB->menu(), SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed()));

  //Setup the visibility of the buttons
  appB->setVisible( !appM->isEmpty() );
  dirB->setVisible( !dirM->isEmpty() );
  fileB->setVisible( !fileM->isEmpty() );
}
CLanguageSettingsPage::CLanguageSettingsPage(QWidget* /*parent*/)
        : BtConfigPage() {
    namespace DU = util::directory;

    QVBoxLayout* layout = new QVBoxLayout(this);

    //Sword locales
    layout->addWidget(
        util::tool::explanationLabel(
            this,
            tr(""),
            tr("Select the language in which the Biblical book names are displayed.")
        ));

    m_swordLocaleCombo = new QComboBox(this);
    QLabel* label = new QLabel( tr("Language for names of Bible books:"), this);
    label->setBuddy(m_swordLocaleCombo);
    m_swordLocaleCombo->setToolTip(tr("The languages which can be used for the biblical booknames"));


    QHBoxLayout* hBoxLayout = new QHBoxLayout();
    hBoxLayout->addWidget(label);
    hBoxLayout->addWidget(m_swordLocaleCombo);
    hBoxLayout->addStretch();
    layout->addLayout(hBoxLayout);

    QStringList languageNames;
    languageNames.append( languageMgr()->languageForAbbrev("en_US")->translatedName() );

    std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
    for (std::list<sword::SWBuf>::const_iterator it = locales.begin(); it != locales.end(); it++) {
        //    qWarning("working on %s", (*it).c_str());
        const CLanguageMgr::Language* const l =
            CPointers::languageMgr()->languageForAbbrev( sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName() );

        if (l->isValid()) {
            languageNames.append( l->translatedName() );
        }
        else {
            languageNames.append(
                sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getDescription()
            );
        }
    } //for

    languageNames.sort();
    m_swordLocaleCombo->addItems( languageNames );

    const CLanguageMgr::Language* const l =
        CPointers::languageMgr()->languageForAbbrev( CBTConfig::get(CBTConfig::language) );

    QString currentLanguageName;
    if ( l->isValid() && languageNames.contains(l->translatedName()) ) { 	//tranlated language name is in the box
        currentLanguageName = l->translatedName();
    }
    else { 	//a language like "German Abbrevs" might be the language to set
        sword::SWLocale* locale =
            sword::LocaleMgr::getSystemLocaleMgr()->getLocale( CBTConfig::get(CBTConfig::language).toLocal8Bit() );
        if (locale) {
            currentLanguageName = QString::fromLatin1(locale->getDescription());
        }
    }

    if (currentLanguageName.isEmpty()) { 	// set english as default if nothing was chosen
        Q_ASSERT(languageMgr()->languageForAbbrev("en_US"));
        currentLanguageName = languageMgr()->languageForAbbrev("en_US")->translatedName();
    }

    //now set the item with the right name as current item
    for (int i = 0; i < m_swordLocaleCombo->count(); ++i) {
        if (currentLanguageName == m_swordLocaleCombo->itemText(i)) {
            m_swordLocaleCombo->setCurrentIndex(i);
            break; //item found, finish the loop
        }
    }

    layout->addSpacing(20);

    //Font settings

    layout->addWidget(
        util::tool::explanationLabel(
            this,
            tr("Fonts"),
            tr("You can specify a custom font for each language.")
        )
    );
    QHBoxLayout* hLayout = new QHBoxLayout();

    m_usageCombo = new QComboBox(this);
    m_usageCombo->setToolTip(tr("The font selection below will apply to all texts in this language"));

    hLayout->addWidget(m_usageCombo);

    CLanguageMgr::LangMap langMap = languageMgr()->availableLanguages();

    for (CLanguageMgr::LangMapIterator it = langMap.constBegin() ; it != langMap.constEnd(); ++it ) {
        const QString name =
            (*it)->translatedName().isEmpty()
            ? (*it)->abbrev()
            : (*it)->translatedName();

        m_fontMap.insert(name, CBTConfig::get(*it) );
    }

    for ( QMap<QString, CBTConfig::FontSettingsPair>::Iterator it = m_fontMap.begin(); it != m_fontMap.end(); ++it ) {
        if ( m_fontMap[it.key()].first ) { 	//show font icon
            m_usageCombo->addItem(DU::getIcon("fonts.svg"), it.key() );
        }
        else { 	//don't show icon for font
            m_usageCombo->addItem(it.key());
        }
    }

    m_useOwnFontCheck = new QCheckBox(tr("Use custom font"), this);
    m_useOwnFontCheck->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    connect(m_useOwnFontCheck, SIGNAL(toggled(bool)), SLOT(useOwnFontClicked(bool)) );
    hLayout->addWidget(m_useOwnFontCheck);

    layout->addLayout(hLayout);
    hLayout->setContentsMargins(0, 0, 0, 0);
    /// \todo remember the last selected font and jump there.

    m_fontChooser = new CFontChooser(this);

    /// \todo Eeli's wishlist: why not show something relevant here, like a Bible verse in chosen (not tr()'ed!) language?
    QString sampleText;
    sampleText.append("1 In the beginning God created the heaven and the earth.  ");
    sampleText.append("2 And the earth was without form, and void; and darkness was on the face of the deep.");
    sampleText.append(" And the Spirit of God moved on the face of the waters.");

    m_fontChooser->setSampleText(sampleText);
    layout->addWidget(m_fontChooser);

    connect(m_fontChooser, SIGNAL(fontSelected(const QFont&)), SLOT(newDisplayWindowFontSelected(const QFont&)));
    connect(m_usageCombo, SIGNAL(activated(const QString&)), SLOT(newDisplayWindowFontAreaSelected(const QString&)));

    m_fontChooser->setFont( m_fontMap[m_usageCombo->currentText()].second );
    useOwnFontClicked( m_fontMap[m_usageCombo->currentText()].first );
    m_useOwnFontCheck->setChecked( m_fontMap[m_usageCombo->currentText()].first );
    m_fontChooser->setMinimumSize(m_fontChooser->sizeHint());
}
Exemple #21
0
QString
QMakeProperty::value(QString v, bool just_check)
{
    if(v == "QT_INSTALL_PREFIX")
        return QLibraryInfo::location(QLibraryInfo::PrefixPath);
    else if(v == "QT_INSTALL_DATA")
        return QLibraryInfo::location(QLibraryInfo::DataPath);
    else if(v == "QT_INSTALL_DOCS")
        return QLibraryInfo::location(QLibraryInfo::DocumentationPath);
    else if(v == "QT_INSTALL_HEADERS")
        return QLibraryInfo::location(QLibraryInfo::HeadersPath);
    else if(v == "QT_INSTALL_LIBS")
        return QLibraryInfo::location(QLibraryInfo::LibrariesPath);
    else if(v == "QT_INSTALL_BINS")
        return QLibraryInfo::location(QLibraryInfo::BinariesPath);
    else if(v == "QT_INSTALL_PLUGINS")
        return QLibraryInfo::location(QLibraryInfo::PluginsPath);
    else if(v == "QT_INSTALL_IMPORTS")
        return QLibraryInfo::location(QLibraryInfo::ImportsPath);
    else if(v == "QT_INSTALL_TRANSLATIONS")
        return QLibraryInfo::location(QLibraryInfo::TranslationsPath);
    else if(v == "QT_INSTALL_CONFIGURATION")
        return QLibraryInfo::location(QLibraryInfo::SettingsPath);
    else if(v == "QT_INSTALL_EXAMPLES")
        return QLibraryInfo::location(QLibraryInfo::ExamplesPath);
    else if(v == "QT_INSTALL_DEMOS")
        return QLibraryInfo::location(QLibraryInfo::DemosPath);
    else if(v == "QMAKE_MKSPECS")
        return qmake_mkspec_paths().join(Option::dirlist_sep);
    else if(v == "QMAKE_VERSION")
        return qmake_version();
#ifdef QT_VERSION_STR
    else if(v == "QT_VERSION")
        return QT_VERSION_STR;
#endif

    initSettings();
    int slash = v.lastIndexOf('/');
    QVariant var = settings->value(keyBase(slash == -1) + v);
    bool ok = var.isValid();
    QString ret = var.toString();
    if(!ok) {
        QString version = qmake_version();
        if(slash != -1) {
            version = v.left(slash-1);
            v = v.mid(slash+1);
        }
        settings->beginGroup(keyBase(false));
        QStringList subs = settings->childGroups();
        settings->endGroup();
        subs.sort();
        for (int x = subs.count() - 1; x >= 0; x--) {
            QString s = subs[x];
            if(s.isEmpty() || s > version)
                continue;
            var = settings->value(keyBase(false) + s + "/" + v);
            ok = var.isValid();
            ret = var.toString();
            if (ok) {
                if(!just_check)
                    debug_msg(1, "Fell back from %s -> %s for '%s'.", version.toLatin1().constData(),
                              s.toLatin1().constData(), v.toLatin1().constData());
                return ret;
            }
        }
    }
    return ok ? ret : QString();
}
Exemple #22
0
//
// Thesaurus
//
void Thesaurus::findTermThesaurus(const QString &searchTerm)
{
    if (!QFile::exists(m_dataFile)) {
        KMessageBox::error(0, i18n("The thesaurus file '%1' was not found. "
            "Please use 'Change Language...' to select a thesaurus file.", m_dataFile));
        return;
    }

    // Find only whole words. Looks clumsy, but this way we don't have to rely on
    // features that might only be in certain versions of grep:
    QString searchTermTmp = ';' + searchTerm.trimmed() + ';';
    m_thesProc->setOutputChannelMode(KProcess::SeparateChannels);
    m_thesProc->clearProgram();
    m_thesProc->setReadChannel(QProcess::StandardOutput);
    *m_thesProc << "grep" << "-i" << searchTermTmp;
    *m_thesProc << m_dataFile;

    QStringList syn;
    QStringList hyper;
    QStringList hypo;

    m_thesProc->start();
    if (!m_thesProc->waitForFinished()) {
        KMessageBox::error(0, i18n("<b>Error:</b> Failed to execute grep."));
        return;
    }

    if (!m_thesProc->waitForReadyRead()) {
    }
    QByteArray byteArray = m_thesProc->readAllStandardOutput();
    QString stdoutString(byteArray);
    QStringList lines = stdoutString.split(QChar('\n'));

    for (QStringList::Iterator it = lines.begin(); it != lines.end(); ++it) {
        QString line = (*it);
        if (line.startsWith("  ")) {  // ignore license (two spaces)
            continue;
        }

        int sep_pos = line.indexOf("#");
        QString synPart = line.left(sep_pos);
        QString hyperPart = line.right(line.length() - sep_pos - 1);
        QStringList synTmp = synPart.split(QChar(';'));
        QStringList hyperTmp = hyperPart.split(QChar(';'));

        if (synTmp.filter(searchTerm, Qt::CaseInsensitive).size() > 0) {
            // match on the left side of the '#' -- synonyms
            for (QStringList::Iterator it2 = synTmp.begin(); it2 != synTmp.end(); ++it2) {
                // add if it's not the searchTerm itself and if it's not yet in the list
                QString term = (*it2);
                if (term.toLower() != searchTerm.toLower() && syn.contains(term) == 0 && !term.isEmpty()) {
                    syn.append(term);
                }
            }
            for (QStringList::Iterator it2 = hyperTmp.begin(); it2 != hyperTmp.end(); ++it2) {
                QString term = (*it2);
                if (term.toLower() != searchTerm.toLower() && hyper.contains(term) == 0 && !term.isEmpty()) {
                    hyper.append(term);
                }
            }
        }
        if (hyperTmp.filter(searchTerm, Qt::CaseInsensitive).size() > 0) {
            // match on the right side of the '#' -- hypernyms
            for (QStringList::Iterator it2 = synTmp.begin(); it2 != synTmp.end(); ++it2) {
                QString term = (*it2);
                if (term.toLower() != searchTerm && hypo.contains(term) == 0 && !term.isEmpty()) {
                    hypo.append(term);
                }
            }
        }
    }

    m_synListWidget->clear();
    if (syn.size() > 0) {
        syn.sort();
        m_synListWidget->addItems(syn);
        m_synListWidget->setEnabled(true);
    }
    else {
        m_synListWidget->addItem(m_noMatch);
        m_synListWidget->setEnabled(false);
    }

    m_hyperListWidget->clear();
    if (hyper.size() > 0) {
        hyper.sort();
        m_hyperListWidget->addItems(hyper);
        m_hyperListWidget->setEnabled(true);
    }
    else {
        m_hyperListWidget->addItem(m_noMatch);
        m_hyperListWidget->setEnabled(false);
    }

    m_hypoListWidget->clear();
    if (hypo.size() > 0) {
        hypo.sort();
        m_hypoListWidget->addItems(hypo);
        m_hypoListWidget->setEnabled(true);
    }
    else {
        m_hypoListWidget->addItem(m_noMatch);
        m_hypoListWidget->setEnabled(false);
    }
}
Exemple #23
0
QStringList Pack::allFiles() const
{
	QStringList ret = m_archive->files();
	ret.sort();
	return ret;
}
Exemple #24
0
bool QMakeStep::init(const QString &name)
{
    m_buildConfiguration = name;
    const QtVersion *qtVersion = m_pro->qtVersion(name);


    if (!qtVersion->isValid()) {
#if defined(Q_OS_MAC)
        emit addToOutputWindow(tr("\n<font color=\"#ff0000\"><b>No valid Qt version set. Set one in Preferences </b></font>\n"));
#else
        emit addToOutputWindow(tr("\n<font color=\"#ff0000\"><b>No valid Qt version set. Set one in Tools/Options </b></font>\n"));
#endif
        return false;
    }

    QStringList args = arguments(name);
    QString workingDirectory = m_pro->buildDirectory(name);

    Environment environment = m_pro->environment(name);
    if (!environment.value("QMAKESPEC").isEmpty() && environment.value("QMAKESPEC") != qtVersion->mkspec())
        emit addToOutputWindow(tr("QMAKESPEC set to ") + environment.value("QMAKESPEC") +
                               tr(" overrides mkspec of selected qt ")+qtVersion->mkspec());

    QString program = qtVersion->qmakeCommand();

    // Check wheter we need to run qmake
    bool needToRunQMake = true;
    if (QDir(workingDirectory).exists(QLatin1String("Makefile")))
        needToRunQMake = false;

    QStringList newEnv = environment.toStringList();
    newEnv.sort();

    if (m_lastEnv != newEnv) {
        m_lastEnv = newEnv;
        needToRunQMake = true;
    }
    if (m_lastWorkingDirectory != workingDirectory) {
        m_lastWorkingDirectory = workingDirectory;
        needToRunQMake = true;
    }

    if (m_lastArguments != args) {
        m_lastArguments = args;
        needToRunQMake = true;
    }

    if (m_lastProgram != program) {
        m_lastProgram = program;
        needToRunQMake = true;
    }

    if (m_forced) {
        m_forced = false;
        needToRunQMake = true;
    }

    setEnabled(name, needToRunQMake);
    setWorkingDirectory(name, workingDirectory);
    setCommand(name, program);
    setArguments(name, args);
    setEnvironment(name, environment);
    return AbstractProcessStep::init(name);
}
Exemple #25
0
bool NoteTable::updateNoteList(qint32 lid, Note &t, bool isDirty) {

    NotebookTable notebookTable;
    qint32 notebookLid = notebookTable.getLid(t.notebookGuid);
    Notebook notebook;
    notebookTable.get(notebook, notebookLid);
    // Now let's update the user table
    QSqlQuery query;

    query.prepare("Delete from NoteTable where lid=:lid");
    query.bindValue(":lid", lid);
    query.exec();

    query.prepare(QString("Insert into NoteTable (lid, title, author, ") +
                  QString("dateCreated, dateUpdated, dateSubject, dateDeleted, source, sourceUrl, sourceApplication, ") +
                  QString("latitude, longitude, altitude, hasEncryption, hasTodo, isDirty, size, notebook, notebookLid, tags) ") +
                  QString("Values (:lid, :title, :author, ") +
                  QString(":dateCreated, :dateUpdated, :dateSubject, :dateDeleted, :source, :sourceUrl, :sourceApplication, ") +
                  QString(":latitude, :longitude, :altitude, :hasEncryption, :hasTodo, :isDirty, :size, :notebook, :notebookLid, :tags) ")) ;

    query.bindValue(":lid", lid);

    if (t.__isset.title)
        query.bindValue(":title", QString::fromStdString(t.title));
    else
        query.bindValue(":title", "");
    if (t.__isset.attributes && t.attributes.__isset.author)
        query.bindValue(":author", QString::fromStdString(t.attributes.author));
    else
        query.bindValue(":author", "");
    if (t.__isset.created)
        query.bindValue(":dateCreated", QVariant::fromValue(t.created));
    else
        query.bindValue(":dateCreated", 0);
    if (t.__isset.updated)
        query.bindValue(":dateUpdated", QVariant::fromValue(t.updated));
    else
        query.bindValue(":dateUpdated", 0);
    if (t.__isset.attributes && t.attributes.__isset.subjectDate)
        query.bindValue(":dateSubject", QVariant::fromValue(t.attributes.subjectDate));
    else
        query.bindValue(":dateSubject", 0);
    if (t.__isset.deleted)
        query.bindValue(":dateDeleted", QVariant::fromValue(t.deleted));
    else
        query.bindValue(":dateDeleted", 0);
    if (t.__isset.attributes && t.attributes.__isset.source)
        query.bindValue(":source", QString::fromStdString(t.attributes.source));
    else
        query.bindValue(":source", "");
    if (t.__isset.attributes && t.attributes.__isset.sourceURL)
        query.bindValue(":sourceUrl", QString::fromStdString(t.attributes.sourceURL));
    else
        query.bindValue(":sourceUrl", "");
    if (t.__isset.attributes && t.attributes.__isset.sourceApplication)
        query.bindValue(":sourceApplication", QString::fromStdString(t.attributes.sourceApplication));
    else
        query.bindValue(":sourceApplication", "");
    if (t.__isset.attributes && t.attributes.__isset.latitude)
        query.bindValue(":latitude", QVariant::fromValue(t.attributes.latitude));
    else
        query.bindValue(":latitude", 0);
    if (t.__isset.attributes && t.attributes.__isset.longitude)
        query.bindValue(":longitude", QVariant::fromValue(t.attributes.longitude));
    else
        query.bindValue(":longitude", 0);
    if (t.__isset.attributes && t.attributes.__isset.altitude)
        query.bindValue(":altitude", QVariant::fromValue(t.attributes.altitude));
    else
        query.bindValue(":altitude", 0);


    bool hasEncryption;
    if (t.content.find("<en-crypt") != string::npos)
        hasEncryption = true;
    else
        hasEncryption = false;
    query.bindValue(":hasEncryption", hasEncryption);
    bool hasTodo;
    if (t.content.find("<en-todo") != string::npos)
        hasTodo = true;
    else
        hasTodo = false;
    query.bindValue(":hasTodo", hasTodo);
    query.bindValue(":isDirty", isDirty);
    qlonglong size = t.content.length();
    for (unsigned int i=0; i<t.resources.size(); i++) {
        size+=t.resources[i].data.size;
    }
    query.bindValue(":size", size);

    query.bindValue(":notebook", QString::fromStdString(notebook.name));
    query.bindValue(":notebookLid", notebookLid);

    QString tagNames;
    QStringList sortedNames;
    for (unsigned int i=0; i<t.tagNames.size(); i++) {
        sortedNames.append(QString::fromStdString(t.tagNames.at(i)).toLower());
    }
    sortedNames.sort();

    TagTable tagTable;
    LinkedNotebookTable linkedTable;
    qint32 account = 0;
    notebookLid = notebookTable.getLid(t.notebookGuid);
    if (linkedTable.exists(notebookLid))
        account = notebookLid;

    for (int i=0; i<sortedNames.size(); i++) {
        if (i>0)
            tagNames = tagNames+", ";
        Tag currentTag;
        qint32 tagLid = tagTable.findByName(sortedNames[i], account);
        tagTable.get(currentTag, tagLid);
        tagNames = tagNames + QString::fromStdString(currentTag.name);
    }

    query.bindValue(":tags", tagNames);

    if (!query.exec()) {
        QLOG_ERROR() << "Error inserting into NoteTable: " << query.lastError();
        return false;
    }
    return true;
}
SettingsTabOther::SettingsTabOther(QWidget *parent, QMap<QString, QVariant> set, bool v) : QWidget(parent) {

	// The global settings
	globSet = set;

	verbose = v;

	this->setObjectName("tabother");
	this->setStyleSheet("#tabother { background: transparent; color: white; }");

	tabs = new TabWidget;
	tabs->expand(false);
	tabs->setBorderTop("rgba(150,150,150,100)",2);
	tabs->setBorderBot("rgba(150,150,150,100)",2);

	QVBoxLayout *mainLay = new QVBoxLayout;
	mainLay->addWidget(tabs);
	this->setLayout(mainLay);

	// the main scroll widget for all LOOK content
	scrollbarOther = new CustomScrollbar;
	QScrollArea *scrollOther = new QScrollArea;
	QVBoxLayout *layOther = new QVBoxLayout(scrollOther);
	QWidget *scrollWidgOther = new QWidget(scrollOther);
	scrollWidgOther->setLayout(layOther);
	scrollOther->setWidget(scrollWidgOther);
	scrollOther->setWidgetResizable(true);
	scrollOther->setVerticalScrollBar(scrollbarOther);

	// the main scroll widget for all FEEL content
	scrollbarFile = new CustomScrollbar;
	QScrollArea *scrollFile = new QScrollArea;
	QVBoxLayout *layFile = new QVBoxLayout(scrollFile);
	QWidget *scrollWidgFile = new QWidget(scrollFile);
	scrollWidgFile->setLayout(layFile);
	scrollFile->setWidget(scrollWidgFile);
	scrollFile->setWidgetResizable(true);
	scrollFile->setVerticalScrollBar(scrollbarFile);

	tabOther = new QWidget;
	tabFile = new QWidget;

	QVBoxLayout *scrollLayOther = new QVBoxLayout;
	scrollLayOther->addWidget(scrollOther);
	tabOther->setLayout(scrollLayOther);

	QVBoxLayout *scrollLayFile = new QVBoxLayout;
	scrollLayFile->addWidget(scrollFile);
	tabFile->setLayout(scrollLayFile);

	tabs->addTab(tabOther,tr("Other"));
	tabs->addTab(tabFile,tr("File Types"));



	// The titles
	CustomLabel *titleOther = new CustomLabel("<center><h1>" + tr("Other Settings") + "</h1></center>");
	layOther->addWidget(titleOther);
	layOther->addSpacing(20);
	CustomLabel *titleFile = new CustomLabel("<center><h1>" + tr("Known File Types") + "</h1></center>");
	layFile->addWidget(titleFile);
	layFile->addSpacing(20);



	// CHOOSE A LANGUAGE
	CustomLabel *langLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Choose Language") + "</span></b><br><br>" + tr("There are a good few different languages available. Thanks to everybody who took the time to translate PhotoQt!"));
	langLabel->setWordWrap(true);
	layOther->addWidget(langLabel);
	layOther->addSpacing(15);


	// All the languages available. They are sorted according to their language code (except English)
	// A GOOD FEW OF THE TRANSLATIONS HAVEN'T BEEN UPDATED IN A LONG TIME AND ARE STANDING AT 0-5%
	// These translations are NOT included!

	langDesc << "English";
	langShort << "en";

	// Arabic
//	langDesc << QString::fromUtf8("العربية (Amar T.)");
//	langShort << "ar";

	// Czech
	langDesc << QString::fromUtf8("Čeština (Robin H. & Petr Š.)");
	langShort << "cs";

	// German
	langDesc << "Deutsch";
	langShort << "de";

	// Greek
	langDesc << QString::fromUtf8("Ελληνικά (Dimitrios G.)");
	langShort << "el";

	// Spanish
	langDesc << QString::fromUtf8("Español (Hector C. & Victoria P.)");
	langShort << "es_ES";

	// Finnish
	langDesc << QString::fromUtf8("Suomen kieli (Jiri G.)");
	langShort << "fi";

	// French
	langDesc << QString::fromUtf8("Français (Olivier D. & Tubuntu)");
	langShort << "fr";

	// Hungarian
//	langDesc << QString::fromUtf8("Magyar (Zoltan H.)");
//	langShort << "hu";

	// Hebrew
	langDesc << QString::fromUtf8("עברית (GenghisKhan)");
	langShort << "he";

	// Italian
	langDesc << "Italiano (Vincenzo C. & Fabio M.)";
	langShort << "it";

	// Japanese
	langDesc << QString::fromUtf8("日本語 (Obytetest)");
	langShort << "ja";

	// Norwegian Bokmal
//	langDesc << QString::fromUtf8("Bokmål (Ola Haugen H.)");
//	langShort << "nb_NO";

	// Norwegian Nynorsk
//	langDesc << "Nynorsk (Ola Haugen H.)";
//	langShort << "nn_NO";

	// Polish
//	langDesc << "Polski (Daniel K.)";
//	langShort << "pl";

	// Portugal (Brazil)
	langDesc << QString::fromUtf8("Português (Brasil) (Rafael N. & Everton)");
	langShort << "pt_BR";

	// Portugal (Portugal)
	langDesc << QString::fromUtf8("Português (Portugal) (Sérgio M. & Manuela S. & Willow)");
	langShort << "pt_PT";

	// Russian
	langDesc << QString::fromUtf8("Pусский (Yuriy T.)");
	langShort << "ru_RU";

	//Slovak
	langDesc << QString::fromUtf8("Slovenčina (Lukáš D.)");
	langShort << "sk";

	// Serbian
//	langDesc << QString::fromUtf8("српски екавски (Mladen Pejaković)");
//	langShort << "sr_RS";

	// Turkish
//	langDesc << QString::fromUtf8("Türkçe (Onuralp SEZER)");
//	langShort << "tr";

	// Ukrainian
	langDesc << QString::fromUtf8("Українська (neeesdfsdf & zubr139)");
	langShort << "uk_UA";

	// Viatnemese
//	langDesc << QString::fromUtf8("Tiếng Việt (Nguyễn Hữu Tài)");
//	langShort << "vi";

	// Chinese (China)
	langDesc << "Chinese (Min Zhang)";
	langShort << "zh_CN";

	langDesc << "Chinese (traditional) (Min Zhang)";
	langShort << "zh_TW";

	FlowLayout *langLay = new FlowLayout;
	QButtonGroup *langButGrp = new QButtonGroup;

	for(int i = 0; i < langDesc.length(); ++i) {

		SettingsTabOtherLanguageTiles *tile = new SettingsTabOtherLanguageTiles(langDesc.at(i), langShort.at(i));
		allLangTiles << tile;
		langButGrp->addButton(tile->button);
		langLay->addWidget(tile);

	}

	QHBoxLayout *langWidgLay = new QHBoxLayout;
	langWidgLay->addSpacing(50);
	langWidgLay->addLayout(langLay);
	langWidgLay->addSpacing(50);

	layOther->addLayout(langWidgLay);
	layOther->addSpacing(30);


	// Adjust quick settings trigering
	CustomLabel *quickSetLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Quick Settings") + "</span></b><br><br>" + tr("The 'Quick Settings' is a widget hidden on the right side of the screen. When you move the cursor there, it shows up, and you can adjust a few simple settings on the spot without having to go through this settings dialog. Of course, only a small subset of settings is available (the ones needed most often). Here you can disable the dialog so that it doesn't show on mouse movement anymore."));
	quickSet = new CustomCheckBox(tr("Show 'Quick Settings' on mouse hovering"));
	QHBoxLayout *quickSetLay = new QHBoxLayout;
	quickSetLay->addStretch();
	quickSetLay->addWidget(quickSet);
	quickSetLay->addStretch();

	layOther->addWidget(quickSetLabel);
	layOther->addSpacing(20);
	layOther->addLayout(quickSetLay);
	layOther->addSpacing(30);



	// Adjust context menu
	CustomLabel *contextMenuLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Adjust Context Menu") + "</span></b><br><br>" + tr("Here you can adjust the context menu. You can simply drag and drop the entries, edit them, add a new one and remove an existing one."));
	context = new Context;
	QHBoxLayout *contextLay = new QHBoxLayout;
	contextLay->addStretch();
	contextLay->addWidget(context);
	contextLay->addStretch();
	CustomPushButton *addNew = new CustomPushButton("+ " + tr("Add new Entry"),this);
	QHBoxLayout *addNewLay = new QHBoxLayout;
	connect(addNew, SIGNAL(clicked()), context, SLOT(addNewEntry()));
	addNewLay->addStretch();
	addNewLay->addWidget(addNew);
	addNewLay->addStretch();
	layOther->addWidget(contextMenuLabel);
	layOther->addSpacing(10);
	layOther->addLayout(contextLay);
	layOther->addLayout(addNewLay);
	layOther->addSpacing(20);



	allCheckQt.clear();
	allCheckGm.clear();
	allCheckGmUnstable.clear();


	// Adjust known file formats
	CustomLabel *titleQt = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("File Types - Qt") + "</span></b><br><br>" + tr("These are the standard file types supported by Qt. Depending on your system, this list can vary a little.") + "<br>" + tr("If you want to add a file type not in the list, you can add them in the text box below. You have to enter the formats like '*.ending', all seperated by commas.") + "</b>");
	titleQt->setWordWrap(true);

	FlowLayout *layQt = new FlowLayout;
	QStringList formatsQt;
	formatsQt << ".bmp" << ".gif" << ".tif" << ".tiff" << ".jpeg2000" << ".jpeg" << ".jpg" << ".png" << ".pbm" << ".pgm" << ".ppm" << ".xbm" << ".xpm";
	formatsQt.sort();
	for(int i = 0; i < formatsQt.length(); ++i) {

		SettingsTabOtherFileTypesTiles *check = new SettingsTabOtherFileTypesTiles(formatsQt.at(i));
		check->setToolTip(formatsQt.at(i));
		allCheckQt.insert(formatsQt.at(i),check);
		layQt->addWidget(check);

	}

	QHBoxLayout *layQtBut = new QHBoxLayout;
	CustomLabel *extraQt = new CustomLabel(tr("Extra File Types:"));
	extraQt->setWordWrap(false);
	extraQtEdit = new CustomLineEdit;
	CustomPushButton *qtMarkAll = new CustomPushButton(tr("Mark All"));
	CustomPushButton *qtMarkNone = new CustomPushButton(tr("Mark None"));
	layQtBut->addWidget(extraQt);
	layQtBut->addWidget(extraQtEdit);
	layQtBut->addStretch();
	layQtBut->addWidget(qtMarkAll);
	layQtBut->addWidget(qtMarkNone);

	layFile->addWidget(titleQt);
	layFile->addSpacing(10);
	layFile->addLayout(layQt);
	layFile->addSpacing(5);
	layFile->addLayout(layQtBut);
	layFile->addSpacing(35);

	QSignalMapper *mapQtMark = new QSignalMapper;
	mapQtMark->setMapping(qtMarkAll,"qtMark");
	connect(qtMarkAll, SIGNAL(clicked()), mapQtMark, SLOT(map()));
	connect(mapQtMark, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString)));

	QSignalMapper *mapQtNone = new QSignalMapper;
	mapQtNone->setMapping(qtMarkNone,"qtNone");
	connect(qtMarkNone, SIGNAL(clicked()), mapQtNone, SLOT(map()));
	connect(mapQtNone, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString)));

#ifndef GM
	CustomLabel *gmDisabled = new CustomLabel("<b><i>" + tr("Use of GraphicsMagick has been disabled as PhotoQt was compiled/installed!") + "</i></b>");
	gmDisabled->setWordWrap(true);
#endif

	CustomLabel *titleGmWorking = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("File Types - GraphicsMagick") + "</span></b><br><br>" + tr("PhotoQt makes use of GraphicsMagick for support of many different file types. Not all of the formats supported by GraphicsMagick make sense in an image viewer. There are some that aren't quite working at the moment, you can find them in the 'Unstable' category below.") + "<br>" + tr("If you want to add a file type not in the list, you can add them in the text box below. You have to enter the formats like '*.ending', all seperated by commas.") + "</b>");
	titleGmWorking->setWordWrap(true);

	FlowLayout *layGm = new FlowLayout;
	QStringList formatsGm;
	formatsGm << ".art" << ".avs" << ".x" << ".cals" << ".cgm" << ".cur" << ".cut" << ".acr" << ".dcm" << ".dicom" << ".dic" << ".dcx" << ".dib" << ".dpx" << ".emf" << ".epdf" << ".epi" << ".eps" << ".eps2" << ".eps3" << ".epsf" << ".epsi" << ".ept" << ".fax" << ".fig" << ".fits" << ".fts" << ".fit" << ".fpx" << ".gplt" << ".ico" << ".jbg" << ".jbig" << ".jng" << ".jp2" << ".j2k" << ".jpf" << ".jpx" << ".jpm" << ".mj2" << ".jpc" << ".mat" << ".miff" << ".mng" << ".mpc" << ".mtv" << ".otb" << ".p7" << ".palm" << ".pam" << ".pcd" << ".pcds" << ".pcx" << ".pdb" << ".pdf" << ".picon" << ".pict" << ".pct" << ".pic" << ".pix" << ".pnm" << ".ps" << ".ps2" << ".ps3" << ".psd" << ".ptif" << ".ras" << ".rast" << ".rad" << ".sgi" << ".sun" << ".svg" << ".tga" << ".vicar" << ".viff" << ".wbmp" << ".wbm" << ".xcf" << ".xwd";
	formatsGm.sort();
	for(int i = 0; i < formatsGm.length(); ++i) {

		SettingsTabOtherFileTypesTiles *check = new SettingsTabOtherFileTypesTiles(formatsGm.at(i));
		allCheckGm.insert(formatsGm.at(i),check);
		check->setToolTip(formatsGm.at(i));
		layGm->addWidget(check);
#ifndef GM
		check->setEnabled(false);
#endif

	}

	QHBoxLayout *layGmBut = new QHBoxLayout;
	CustomLabel *extraGm = new CustomLabel(tr("Extra File Types:"));
	extraGm->setWordWrap(false);
	extraGmEdit = new CustomLineEdit;
	CustomPushButton *gmMarkAll = new CustomPushButton(tr("Mark All"));
	CustomPushButton *gmMarkNone = new CustomPushButton(tr("Mark None"));
	layGmBut->addWidget(extraGm);
	layGmBut->addWidget(extraGmEdit);
	layGmBut->addStretch();
	layGmBut->addWidget(gmMarkAll);
	layGmBut->addWidget(gmMarkNone);

#ifndef GM
	titleGmWorking->setEnabled(false);
	gmMarkAll->setEnabled(false);
	gmMarkNone->setEnabled(false);
	extraGm->setEnabled(false);
	extraGmEdit->setEnabled(false);

	layFile->addWidget(gmDisabled);
	layFile->addSpacing(10);
#endif
	layFile->addWidget(titleGmWorking);
	layFile->addSpacing(10);
	layFile->addLayout(layGm);
	layFile->addSpacing(5);
	layFile->addLayout(layGmBut);
	layFile->addSpacing(35);


	QSignalMapper *mapGmMark = new QSignalMapper;
	mapGmMark->setMapping(gmMarkAll,"gmMark");
	connect(gmMarkAll, SIGNAL(clicked()), mapGmMark, SLOT(map()));
	connect(mapGmMark, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString)));

	QSignalMapper *mapGmNone = new QSignalMapper;
	mapGmNone->setMapping(gmMarkNone,"gmNone");
	connect(gmMarkNone, SIGNAL(clicked()), mapGmNone, SLOT(map()));
	connect(mapGmNone, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString)));





	CustomLabel *titleGmUnstable = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("File Types - GraphicsMagick (Unstable)") + "</span></b><br><br>" + tr("The following file types are supported by GraphicsMagick, but aren't quite working in PhotoQt just yet. If you want to experiment around a little, feel free to enable some of them. They shouldn't cause PhotoQt to crash, but you might see an error image instead of the actual image.") + "</b>");
	titleGmUnstable->setWordWrap(true);

	FlowLayout *layGmUnstable = new FlowLayout;
	QStringList formatsGmUnstable;
	formatsGmUnstable << ".gray" << ".hpgl" << ".mono" << ".msl" << ".mvg" << ".pcl" << ".pfa" << ".pfb" << ".pwp" << ".rgb" << ".rgba" << ".rla" << ".rle" << ".sct" << ".sfw" << ".tim" << ".uil" << ".uyvy" << ".wmf" << ".wpg" << ".yuv";
	formatsGmUnstable.sort();
	for(int i = 0; i < formatsGmUnstable.length(); ++i) {

		SettingsTabOtherFileTypesTiles *check = new SettingsTabOtherFileTypesTiles(formatsGmUnstable.at(i));
		check->setToolTip(formatsGmUnstable.at(i));
		allCheckGmUnstable.insert(formatsGmUnstable.at(i),check);
		layGmUnstable->addWidget(check);
#ifndef GM
		check->setEnabled(false);
#endif

	}

	QHBoxLayout *layGmButUnstable = new QHBoxLayout;
	CustomPushButton *gmMarkAllUnstable = new CustomPushButton(tr("Mark All"));
	CustomPushButton *gmMarkNoneUnstable = new CustomPushButton(tr("Mark None"));
	layGmButUnstable->addStretch();
	layGmButUnstable->addWidget(gmMarkAllUnstable);
	layGmButUnstable->addWidget(gmMarkNoneUnstable);

	layFile->addWidget(titleGmUnstable);
	layFile->addSpacing(10);
	layFile->addLayout(layGmUnstable);
	layFile->addSpacing(5);
	layFile->addLayout(layGmButUnstable);
	layFile->addSpacing(35);

#ifndef GM
	titleGmUnstable->setEnabled(false);
	gmMarkAllUnstable->setEnabled(false);
	gmMarkNoneUnstable->setEnabled(false);
#endif

	QSignalMapper *mapGmMarkUnst = new QSignalMapper;
	mapGmMarkUnst->setMapping(gmMarkAllUnstable,"gmunstMark");
	connect(gmMarkAllUnstable, SIGNAL(clicked()), mapGmMarkUnst, SLOT(map()));
	connect(mapGmMarkUnst, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString)));

	QSignalMapper *mapGmNoneUnst = new QSignalMapper;
	mapGmNoneUnst->setMapping(gmMarkNoneUnstable,"gmunstNone");
	connect(gmMarkNoneUnstable, SIGNAL(clicked()), mapGmNoneUnst, SLOT(map()));
	connect(mapGmNoneUnst, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString)));



	layOther->addStretch();
	layFile->addStretch();

}
Exemple #27
0
int main() {
	
	QString filename = "B-small-practice1";
	//QString filename = "test";
	QFile file(filename+".in");
	if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
	 return 0;
	 
	QFile file2(filename+".out");
	if (!file2.open(QIODevice::WriteOnly | QIODevice::Text))
	 return 0;
       
	QTextStream out(&file2);
	QTextStream in(&file);

	QFile file3(filename+".liste");
	if (!file3.open(QIODevice::WriteOnly | QIODevice::Text))
	 return 0;
       
	QTextStream f3(&file3);
	
	int test_case = in.readLine().toInt();

	for(int i=0; i < test_case; i++) //on parcours toute notre liste
	{
		int nbSong = in.readLine().toInt();
		QStringList  songList;
		for(int j=0; j < nbSong; j++) // on crée notre liste
			songList.append(in.readLine().toUpper());
				
		cout << "Case #"<< i+1 << ":" <<  endl;
		out << "Case #"<< i+1 << ":" <<  endl;
		if(nbSong == 1) //si elle est seule
		{
			cout << "\"\"" << endl;
			out << "\"\"" << endl;
		}
		else
		{
			for(int j=0; j < nbSong; j++)  //on cherche le nombre d'occurences possible par chanson
			{
				int tailleSubstr = 1;
				bool ok = true;
				QString mot;
				QStringList result;
				
				while (tailleSubstr <= songList[j].size() && ok)
				{
					for(int l=0; l < songList[j].size()-tailleSubstr+1;l++)
					{
						
						QString sub = songList[j].mid(l, tailleSubstr);
						
						mot = QString();
						mot.append(".*");
						mot.append(sub); //lower
						mot.append(".*");
						
						QRegExp rx(mot);
						bool ajouter = true;
						for(int k = 0; k < nbSong; k++)
						{	
							
							if(songList[k].compare(songList[j]) != 0)
							{
								if(rx.exactMatch(songList[k])) //lower
								{
									//cout << songList[j].toStdString() << " " << songList[k].toStdString() << " " << mot.toStdString() << endl;
									ajouter = false;
								}
							}
							
							
						}
						if(ajouter)
								result.append(sub);

					}
					if(!result.isEmpty())
							ok = false;
					tailleSubstr++;
				}
				
				result.sort();
				if(!result.isEmpty() && result.size()>1)
				{
					cout << endl;
					displayList(result, "result");
					cout << endl;
					
					for(int l=0;l<result.size(); l++)
						f3 << result[l] << endl;
					f3 << endl;
					
				}
				if(!result.isEmpty())
				{
					cout << "\"" << result[0].toUpper().toStdString() <<  "\"" << endl;
					out << "\"" << result[0].toUpper() << "\"" << endl;
				}
				else
				{
					cout << ":(" << endl;
					out << ":(" << endl;
				}
			}
		}
	}

	

	printf("time=%.3lfsec\n",0.001*(clock()-start));
	return 0;
}
void DocDigestDetailView::documentListing( TextTemplate *tmpl, int year, int month )
{

    QString minDate;
    QString maxDate;
    if( month > -1 ) {
        QDate theDate(year, month, 1);
        // not a year
        minDate = theDate.toString("yyyy-MM-dd");
        int lastDay = theDate.daysInMonth();
        theDate.setDate(year, month, lastDay);
        maxDate = theDate.toString("yyyy-MM-dd");
    } else {
        // is is a year
        minDate = QString::number(year)+"-01-01";
        maxDate = QString::number(year)+"-12-31";
    }

    // read data in the given timeframe from database
    QSqlQuery q;
    const QString query = QString("SELECT archDocID, ident, MAX(printDate) FROM archdoc WHERE "
                                  "date BETWEEN date('%1') AND date('%2') "
                                  "GROUP BY ident").arg(minDate, maxDate);

    // qDebug() << "***" << query;
    QMap<QString, QPair<int, Geld> > docMatrix;
    q.prepare(query);
    q.exec();
    while( q.next() ) {
       dbID archDocId(q.value(0).toInt());

       const ArchDoc doc(archDocId);
       const QString docType = doc.docType();
       Geld g;
       int n = 0;
       if( docMatrix.contains(docType)) {
           g = docMatrix[docType].second;
           n = docMatrix[docType].first;
       }
       Geld g1 = doc.nettoSum();
       g += g1;
       docMatrix[docType].first = n+1;
       docMatrix[docType].second = g;
     }

    // now create the template

    tmpl->setValue("I18N_AMOUNT", i18n("Amount"));
    tmpl->setValue("I18N_TYPE",   i18n("Type"));
    tmpl->setValue("I18N_SUM",    i18n("Sum"));

    QStringList doctypes = docMatrix.keys();
    doctypes.sort();

    foreach( const QString dtype, doctypes ) {
        qDebug() << "creating doc list for "<<dtype;
        tmpl->createDictionary( "DOCUMENTS" );
        tmpl->setValue("DOCUMENTS", "DOCTYPE", dtype);
        const QString am = QString::number(docMatrix[dtype].first);
        tmpl->setValue("DOCUMENTS", "AMOUNT", am);
        const QString sm = docMatrix[dtype].second.toString(DefaultProvider::self()->locale());
        tmpl->setValue("DOCUMENTS", "SUM", sm);
    }
Exemple #29
0
CDDAHeaderDataDialog::CDDAHeaderDataDialog(CDDAModel *cddaModel, QWidget *parent) : QDialog(parent) {

  Q_UNUSED(parent);

  cdda_model = cddaModel;
  if (!cdda_model) {
    qDebug() << "CDDAModel is NULL!";
    return;
  }



  setWindowTitle(i18n("Edit Data"));

  QVBoxLayout *mainLayout = new QVBoxLayout;
  setLayout(mainLayout);

  QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Apply|QDialogButtonBox::Cancel);
  okButton = buttonBox->button(QDialogButtonBox::Ok);
  applyButton = buttonBox->button(QDialogButtonBox::Apply);
  okButton->setDefault(true);
  okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
  connect(buttonBox, &QDialogButtonBox::accepted, this, &CDDAHeaderDataDialog::slotAccepted);
  connect(buttonBox, &QDialogButtonBox::rejected, this, &CDDAHeaderDataDialog::reject);
  connect(applyButton, &QPushButton::clicked, this, &CDDAHeaderDataDialog::slotApplied);

  QWidget *widget = new QWidget(this);
  mainLayout->addWidget(widget);
  mainLayout->addWidget(buttonBox);
  ui.setupUi(widget);

  QStringList genres; for (int i = 0; i < GENRE_MAX; ++i) genres.append(QString().fromAscii(ID3_GENRES[i]));
  genres.sort();
  KCompletion *comp = ui.kcombobox_genre->completionObject();
  comp->insertItems(genres);
  ui.kcombobox_genre->addItems(genres);
  connect(ui.kcombobox_genre, SIGNAL(returnPressed(const QString&)), comp, SLOT(addItem(const QString&)));

  ui.checkBox_various->setChecked(cdda_model->isVarious());
  connect(ui.checkBox_various, SIGNAL(toggled(bool)), this, SLOT(trigger_changed()));
  ui.checkBox_multicd->setChecked(cdda_model->isMultiCD());
  connect(ui.checkBox_multicd, SIGNAL(toggled(bool)), this, SLOT(enable_checkbox_multicd(bool)));
  connect(ui.checkBox_multicd, SIGNAL(toggled(bool)), this, SLOT(trigger_changed()));
  ui.qlineedit_artist->setText(cdda_model->artist());
  connect(ui.qlineedit_artist, SIGNAL(textEdited(const QString&)), this, SLOT(trigger_changed()));
  ui.qlineedit_title->setText(cdda_model->title());
  connect(ui.qlineedit_title, SIGNAL(textEdited(const QString&)), this, SLOT(trigger_changed()));
  ui.kintspinbox_cdnum->setValue(cdda_model->cdNum());
  connect(ui.kintspinbox_cdnum, SIGNAL(valueChanged(int)), this, SLOT(trigger_changed()));
  ui.kintspinbox_trackoffset->setValue(cdda_model->trackOffset());
  connect(ui.kintspinbox_trackoffset, SIGNAL(valueChanged(int)), this, SLOT(trigger_changed()));
  ui.kcombobox_genre->lineEdit()->setText(cdda_model->genre());
  connect(ui.kcombobox_genre->lineEdit(), SIGNAL(textEdited(const QString&)), this, SLOT(trigger_changed()));
  {
    bool ok; int year = cdda_model->year().toInt(&ok);
    if (ok) ui.kintspinbox_year->setValue(year); else ui.kintspinbox_year->setValue(QDate::currentDate().year());
  }
  connect(ui.kintspinbox_year, SIGNAL(valueChanged(int)), this, SLOT(trigger_changed()));
  ui.ktextedit_extdata->setText(cdda_model->extendedData().join("\n"));
  connect(ui.ktextedit_extdata, SIGNAL(textChanged()), this, SLOT(trigger_changed()));
  ui.qlineedit_freedbdiscid->setText(QString("0x%1").arg(DiscIDCalculator::FreeDBId(cdda_model->discSignature()), 0, 16));

  enable_checkbox_multicd(cdda_model->isMultiCD());

  applyButton->setEnabled(false);

}
Exemple #30
0
PickKnobDialog::PickKnobDialog(DockablePanel* panel,
                               QWidget* parent)
    : QDialog(parent)
    , _imp( new PickKnobDialogPrivate(panel) )
{
    NodeSettingsPanel* nodePanel = dynamic_cast<NodeSettingsPanel*>(panel);

    assert(nodePanel);
    if (!nodePanel) {
        throw std::logic_error("PickKnobDialog::PickKnobDialog()");
    }
    NodeGuiPtr nodeGui = nodePanel->getNodeGui();
    NodePtr node = nodeGui->getNode();
    NodeGroupPtr isGroup = node->isEffectNodeGroup();
    NodeCollectionPtr collec = node->getGroup();
    NodeGroupPtr isCollecGroup = toNodeGroup(collec);
    NodesList collectNodes = collec->getNodes();
    for (NodesList::iterator it = collectNodes.begin(); it != collectNodes.end(); ++it) {
        if ((*it)->isActivated() && (*it)->getNodeGui() && ( (*it)->getKnobs().size() > 0 ) ) {
            _imp->allNodes.push_back(*it);
        }
    }
    if (isCollecGroup) {
        _imp->allNodes.push_back( isCollecGroup->getNode() );
    }
    if (isGroup) {
        NodesList groupnodes = isGroup->getNodes();
        for (NodesList::iterator it = groupnodes.begin(); it != groupnodes.end(); ++it) {
            if ( (*it)->getNodeGui() &&
                (*it)->isActivated() &&
                ( (*it)->getKnobs().size() > 0 ) ) {
                _imp->allNodes.push_back(*it);
            }
        }
    }
    QStringList nodeNames;
    for (NodesList::iterator it = _imp->allNodes.begin(); it != _imp->allNodes.end(); ++it) {
        QString name = QString::fromUtf8( (*it)->getLabel().c_str() );
        nodeNames.push_back(name);
    }
    nodeNames.sort();

    _imp->mainLayout = new QGridLayout(this);
    _imp->selectNodeLabel = new Label( tr("Node:") );
    _imp->nodeSelectionCombo = new CompleterLineEdit(nodeNames, nodeNames, false, this);
    _imp->nodeSelectionCombo->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Input the name of a node in the current project."), NATRON_NAMESPACE::WhiteSpaceNormal) );
    _imp->nodeSelectionCombo->setFocus(Qt::PopupFocusReason);

    _imp->knobSelectionCombo = new ComboBox(this);
    QObject::connect( _imp->knobSelectionCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onKnobComboIndexChanged(int)) );
    QString useAliasTt = NATRON_NAMESPACE::convertFromPlainText(tr("If checked, an alias of the selected parameter will be created, coyping entirely its state. "
                                                           "Only the script-name, label and tooltip will be editable.\n"
                                                           "For choice parameters this will also "
                                                           "dynamically refresh the menu entries when the original parameter's menu is changed.\n"
                                                           "When unchecked, a simple expression will be set linking the two parameters, but things such as dynamic menus "
                                                           "will be disabled."), NATRON_NAMESPACE::WhiteSpaceNormal);
    _imp->useAliasLabel = new Label(tr("Make Alias:"), this);
    _imp->useAliasLabel->setToolTip(useAliasTt);
    _imp->useAliasCheckBox = new QCheckBox(this);
    _imp->useAliasCheckBox->setToolTip(useAliasTt);
    _imp->useAliasCheckBox->setChecked(true);

    QObject::connect( _imp->nodeSelectionCombo, SIGNAL(itemCompletionChosen()), this, SLOT(onNodeComboEditingFinished()) );

    _imp->destPageLabel = new Label(tr("Page:"), this);
    QString pagett = NATRON_NAMESPACE::convertFromPlainText(tr("Select the page into which the parameter will be created."), NATRON_NAMESPACE::WhiteSpaceNormal);
    _imp->destPageLabel->setToolTip(pagett);
    _imp->destPageCombo = new ComboBox(this);
    _imp->destPageCombo->setToolTip(pagett);
    QObject::connect( _imp->destPageCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onPageComboIndexChanged(int)) );
    const KnobsVec& knobs = node->getKnobs();
    for (std::size_t i = 0; i < knobs.size(); ++i) {
        if ( knobs[i]->isUserKnob() ) {
            KnobPagePtr isPage = toKnobPage(knobs[i]);
            if (isPage) {
                _imp->pages.push_back(isPage);
                _imp->destPageCombo->addItem( QString::fromUtf8( isPage->getName().c_str() ) );
            } else {
                KnobGroupPtr isGrp = toKnobGroup(knobs[i]);
                if (isGrp) {
                    _imp->groups.push_back(isGrp);
                }
            }
        }
    }
    if (_imp->destPageCombo->count() == 0) {
        _imp->destPageLabel->hide();
        _imp->destPageCombo->hide();
    }


    _imp->groupLabel = new Label(tr("Group:"), this);
    QString grouptt = NATRON_NAMESPACE::convertFromPlainText(tr("Select the group into which the parameter will be created."), NATRON_NAMESPACE::WhiteSpaceNormal);
    _imp->groupCombo = new ComboBox(this);
    _imp->groupLabel->setToolTip(grouptt);
    _imp->groupCombo->setToolTip(grouptt);
    onPageComboIndexChanged(0);

    _imp->buttons = new DialogButtonBox(QDialogButtonBox::StandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel),
                                         Qt::Horizontal, this);
    QObject::connect( _imp->buttons, SIGNAL(accepted()), this, SLOT(accept()) );
    QObject::connect( _imp->buttons, SIGNAL(rejected()), this, SLOT(reject()) );

    _imp->mainLayout->addWidget(_imp->selectNodeLabel, 0, 0, 1, 1);
    _imp->mainLayout->addWidget(_imp->nodeSelectionCombo, 0, 1, 1, 1);
    _imp->mainLayout->addWidget(_imp->knobSelectionCombo, 0, 2, 1, 1);
    _imp->mainLayout->addWidget(_imp->useAliasLabel, 1, 0, 1, 1);
    _imp->mainLayout->addWidget(_imp->useAliasCheckBox, 1, 1, 1, 1);
    _imp->mainLayout->addWidget(_imp->destPageLabel, 2, 0, 1, 1);
    _imp->mainLayout->addWidget(_imp->destPageCombo, 2, 1, 1, 1);
    _imp->mainLayout->addWidget(_imp->groupLabel, 2, 2, 1, 1);
    _imp->mainLayout->addWidget(_imp->groupCombo, 2, 3, 1, 1);
    _imp->mainLayout->addWidget(_imp->buttons, 3, 0, 1, 3);

    QTimer::singleShot( 25, _imp->nodeSelectionCombo, SLOT(showCompleter()) );
}