Пример #1
0
RackSlot::RackSlot(QListWidget* b, AudioTrack* t, int i)
    : QListWidgetItem(b)
{
    node = t;
    idx = i;
    setSizeHint(QSize(10, 17));
}
Пример #2
0
OptionsTiffImporter::OptionsTiffImporter(const QString &initialDirectory) : LabeledSectionGroup(NULL)
{
   QWidget* pFileBrowserWidget = new QWidget(this);
   QLabel* pFileBrowserLabel = new QLabel("Select an ISD metadata file or leave blank for no ISD metadata:",
      pFileBrowserWidget);
   mpFilename = new FileBrowser(pFileBrowserWidget);
   mpFilename->setWhatsThis("<p>An ISD metadata file is an XML file shipped with some imagery such as Quickbird. "
                            "It contains image metadata. If you have an ISD metadata file and would like to load "
                            "it with the cube data, select it here. If you do not want to load an ISD metadata file, "
                            "leave this field blank.</p>"
                            "Currently, the following information is loaded from the ISD file:"
                            "<ul><li>RPC00B"
                            "<li>Image header information needed to use the RPC00B"
                            "</ul>");
   mpFilename->setBrowseCaption("ISD Metadata File");
   mpFilename->setBrowseFileFilters("ISD Metadata Files (*.xml)");
   mpFilename->setBrowseExistingFile(true);
   if (!initialDirectory.isEmpty())
   {
      mpFilename->setBrowseDirectory(initialDirectory);
   }
   QGridLayout* pLayout = new QGridLayout(pFileBrowserWidget);
   pLayout->setMargin(0);
   pLayout->setSpacing(5);
   pLayout->addWidget(pFileBrowserLabel, 0, 0);
   pLayout->addWidget(mpFilename, 1, 0, 1, 2);
   pLayout->setColumnStretch(1, 5);

   LabeledSection* pFileBrowserSection = new LabeledSection(pFileBrowserWidget, "ISD Metadata File", this);

   // Initialization
   addSection(pFileBrowserSection);
   addStretch(10);
   setSizeHint(300, 50);
}
EkgWidget::EkgWidget(AnalysisManager &anaman, Widget *parent) : Widget(parent), _anaman(anaman) {
	_beatt = 1.f;
	_sound = false;
	setSizeHint(Widgets::Size(300,32));

	_beepSample = BASS_SampleLoad(false, "data/ekg.wav",0,0,10,0);
}
QListWidgetItem* KeyframeItem::createParentItem(int row) {
  auto item = new QListWidgetItem();
  item->setSizeHint(QSize(100, 55));
  //item->setFlags(item->flags() | Qt::ItemIsEditable);
  if(row < 0) row = list_->count();
  list_->insertItem(row, item);
  list_->setItemWidget(item, this);
  return item;
}
Пример #5
0
NodeTypeItem::NodeTypeItem(QString label, QString filePath, QListWidget *parent) :
  QListWidgetItem(QIcon(filePath), label, parent)
{
  setSizeHint(QSize(1, 48));

  setData(Qt::UserRole, "svg");
  setData(Qt::UserRole + 1, label);
  setData(Qt::UserRole + 2, filePath);
}
Пример #6
0
	ChannelItem(const unsigned &i, const QString &type, const Config &config = Config())
		: QStandardItem(""),
		m_i(i),
		m_type(type),
		m_config(config)
	{
		setText(title());
		setSizeHint(QSize(0, 22));
		setEditable(false);
	}
ColorDropDownPopup::ColorDropDownPopup(const std::vector<Widgets::Color> &content, Widget *parent)
	: Widget(parent), _content(content), _scroll(0) {
	setSizeHint(Widgets::Size(SLICE_W+15,SLICE_H*4));

	_scrollBar = new Widgets::ScrollBar(Widgets::Vertical, this);
	_scrollBar->valueChanged.connect(this, &ColorDropDownPopup::setScroll);
	scrollChanged.connect(_scrollBar, &Widgets::ScrollBar::updateValue);
	_scrollBar->setGeometry(Widgets::Rect(SLICE_W,0,width()-SLICE_W,height()));
	_scrollBar->updateValue(_scroll);
	_scrollBar->setPageStep(10);
}
Пример #8
0
DropDownList::DropDownList(Widget *parent) : Widget(parent), /*_state2(WAITING_FOR_CLICK_ON_BUTTON),*/ _selectedIndex(0)/*, _highlightedIndex(0), _verticalOffset(0)*/
{
	char buffer[32];
	for (int i = 0; i < 3; i++)
	{
		snprintf(buffer, sizeof(buffer), "Test %i!", i);
		_entries.push_back(std::string(buffer));
	}

	setSizeHint(Size(Application::font()->characterWidth()*24 + 2*BORDER_WIDTH, Application::font()->characterHeight() + 2*BORDER_WIDTH));
}
Пример #9
0
void
AlbumItem::setIconSize( const int iconSize )
{
    static const int padding = 5;

    m_iconSize = iconSize;

    QSize size = sizeHint();
    size.setHeight( iconSize + padding*2 );
    setSizeHint( size );
}
Пример #10
0
 void adjustText()
 {
     if (!treeWidget()) return; /* only for initialised items */
     QFontMetrics metrics (font (0));
     int hei0 = (metrics.height() > 16 ?
                metrics.height() /* text */ : 16 /* icon */) +
                2 * 2 /* 2 pixel per margin */;
     int wid0 = metrics.width (text (0)) /* text */ +
                treeWidget()->indentation() /* indent */ +
                16 /* icon */;
     setSizeHint (0, QSize (wid0, hei0));
 }
Пример #11
0
QListWidgetItem *LogDialog::createRecord(const Record &record)
{
    auto w = new QLabel( record.toString(format_, timeFormat_), ui->listLog );
    w->setContentsMargins(4, 4, 4, 4);

    auto item = new QListWidgetItem(ui->listLog);
    item->setSizeHint(w->sizeHint());
    ui->listLog->addItem(item);
    ui->listLog->setItemWidget(item, w);

    return item;
}
Пример #12
0
DropDownList::DropDownList(Widget *parent, int lineWidth, int lineHeight) : Widget(parent), /*_state2(WAITING_FOR_CLICK_ON_BUTTON),*/ _selectedIndex(0)/*, _highlightedIndex(0), _verticalOffset(0)*/
{
    _lineWidth = lineWidth;
    _lineHeight = lineHeight;
    _disabled = false;
	char buffer[32];
	for (int i = 0; i < 3; i++)
	{
		snprintf(buffer, sizeof(buffer), "Test %i!", i);
		_entries.push_back(std::string(buffer));
	}
	setSizeHint(Widgets::Size(_lineWidth+2*BORDER_WIDTH, Widgets::Application::font()->characterHeight()+6 + 2*BORDER_WIDTH));
}
Пример #13
0
void ShopViewer::addShop(const Shop* shop) {
    auto item = new QListWidgetItem;

    auto widget = new ShopWidget(this, shop->league());
    item->setSizeHint(QSize(item->sizeHint().width(), 80));

    item->setData(Qt::UserRole + 1, QVariant::fromValue<Shop*>((Shop*)shop));
    ui->listWidget->addItem(item);
    ui->listWidget->setItemWidget(item, widget);

    _shopListItems.insert(shop, item);

    updateShopListItem(shop);
}
Пример #14
0
TextDropDownPopup::TextDropDownPopup(const std::vector<std::string> &entries, Widget *parent, int lineWidth, int lineHeight)
: Widget(parent), _entries(entries), _scroll(0) {
    
    _lineHeight = lineHeight;
    _lineWidth = lineWidth;
    setSizeHint(Widgets::Size(_lineWidth+15,_lineHeight*4));
    
    _scrollBar = new Widgets::ScrollBar(Widgets::Vertical, this);
    _scrollBar->valueChanged.connect(this, &TextDropDownPopup::setScroll);
    scrollChanged.connect(_scrollBar, &Widgets::ScrollBar::updateValue);
    _scrollBar->setGeometry(Widgets::Rect(_lineWidth,0,SLICE_W,height()));
    _scrollBar->updateValue(_scroll);
    _scrollBar->setPageStep(10);
}
Пример #15
0
SubProjectItem::SubProjectItem(double display_ratio, QTreeWidgetItem * parent, int in, int out, QString description) :
        QTreeWidgetItem(parent, PROJECTSUBCLIPTYPE), m_in(in), m_out(out), m_description(description)
{
    setSizeHint(0, QSize((int) (itemHeight * display_ratio) + 2, itemHeight + 2));
    setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
    QString name = Timecode::getStringTimecode(in, KdenliveSettings::project_fps());
    setText(0, name);
    setText(1, description);
    GenTime duration = GenTime(out - in, KdenliveSettings::project_fps());
    if (duration != GenTime()) setData(0, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
    QPixmap pix((int) (itemHeight * display_ratio), itemHeight);
    pix.fill(Qt::gray);
    setData(0, Qt::DecorationRole, pix);
    //setFlags(Qt::NoItemFlags);
    //kDebug() << "Constructed with clipId: " << m_clipId;
}
Пример #16
0
OptionsTiffImporter::OptionsTiffImporter(QWidget* pParent) :
   LabeledSectionGroup(pParent),
   mpDescriptor(NULL)
{
   QWidget* pFileBrowserWidget = new QWidget(this);
   QLabel* pFileBrowserLabel = new QLabel("Select an ISD metadata file or leave blank for no ISD metadata:",
      pFileBrowserWidget);
   mpFilename = new FileBrowser(pFileBrowserWidget);
   mpFilename->setWhatsThis("<p>An ISD metadata file is an XML file shipped with some imagery such as Quickbird. "
      "It contains image metadata. If you have an ISD metadata file and would like to load it with the cube data, "
      "select it here. If you do not want to load an ISD metadata file, leave this field blank.</p>"
      "Currently, the following information is loaded from the ISD file:"
      "<ul><li>RPC00B"
      "<li>Image header information needed to use the RPC00B"
      "</ul>");
   mpFilename->setBrowseCaption("Select ISD Metadata File");
   mpFilename->setBrowseFileFilters("ISD Metadata Files (*.xml)");
   mpFilename->setBrowseExistingFile(true);

   QGridLayout* pLayout = new QGridLayout(pFileBrowserWidget);
   pLayout->setMargin(0);
   pLayout->setSpacing(5);
   pLayout->addWidget(pFileBrowserLabel, 0, 0);
   pLayout->addWidget(mpFilename, 1, 0, 1, 2);
   pLayout->setColumnStretch(1, 5);

   LabeledSection* pFileBrowserSection = new LabeledSection(pFileBrowserWidget, "ISD Metadata File", this);

   // Layout
   QWidget* pWidget = widget();
   if (pWidget != NULL)
   {
      QLayout* pLayout = pWidget->layout();
      if (pLayout != NULL)
      {
         pLayout->setMargin(10);
      }
   }

   // Initialization
   addSection(pFileBrowserSection);
   addStretch(10);
   setSizeHint(300, 50);

   // Connections
   VERIFYNR(connect(mpFilename, SIGNAL(filenameChanged(const QString&)), this, SLOT(loadIsdMetadata(const QString&))));
}
Пример #17
0
OptionsPngExporter::OptionsPngExporter() :
   LabeledSectionGroup(NULL)
{
   // Resolution section
   mpResolutionWidget = new ResolutionWidget(this);
   LabeledSection* pResolutionSection = new LabeledSection(mpResolutionWidget, "Image Size", this);
   mpResolutionWidget->setAspectRatioLock(OptionsPngExporter::getSettingAspectRatioLock());
   mpResolutionWidget->setResolution(OptionsPngExporter::getSettingOutputWidth(),
      OptionsPngExporter::getSettingOutputHeight());
   mpResolutionWidget->setUseViewResolution(OptionsPngExporter::getSettingUseViewResolution());

   // Initialization
   addSection(pResolutionSection);
   addStretch(10);
   setSizeHint(350, 150);

}
Пример #18
0
OptionsMovieExporter::OptionsMovieExporter() :
   LabeledSectionGroup(NULL)
{
   // Resolution section
   mpResolutionWidget = new ViewResolutionWidget(this);
   mpResolutionWidget->setResolution(QSize(OptionsMovieExporter::getSettingWidth(),
         OptionsMovieExporter::getSettingHeight()),
      StringUtilities::fromXmlString<ResolutionType>(
         OptionsMovieExporter::getSettingResolutionType()));

   LabeledSection* pResolutionSection = new LabeledSection(mpResolutionWidget, "Output Resolution", this);

   // Playback section
   mpBitrateWidget = new BitrateWidget(this);
   mpBitrateWidget->setBitrate(OptionsMovieExporter::getSettingBitrate());

   LabeledSection* pPlaybackSection = new LabeledSection(mpBitrateWidget, "Playback", this);

   // Advanced options section
   mpAdvancedWidget = new AdvancedOptionsWidget(this);
   mpAdvancedWidget->setMeMethod(OptionsMovieExporter::getSettingMeMethod());
   mpAdvancedWidget->setGopSize(OptionsMovieExporter::getSettingGopSize());
   mpAdvancedWidget->setQCompress(OptionsMovieExporter::getSettingQCompress());
   mpAdvancedWidget->setQBlur(OptionsMovieExporter::getSettingQBlur());
   mpAdvancedWidget->setQMinimum(OptionsMovieExporter::getSettingQMinimum());
   mpAdvancedWidget->setQMaximum(OptionsMovieExporter::getSettingQMaximum());
   mpAdvancedWidget->setQDiffMaximum(OptionsMovieExporter::getSettingQDiffMaximum());
   mpAdvancedWidget->setMaxBFrames(OptionsMovieExporter::getSettingMaxBFrames());
   mpAdvancedWidget->setBQuantFactor(OptionsMovieExporter::getSettingBQuantFactor());
   mpAdvancedWidget->setBQuantOffset(OptionsMovieExporter::getSettingBQuantOffset());
   mpAdvancedWidget->setDiaSize(OptionsMovieExporter::getSettingDiaSize());
   mpAdvancedWidget->setOutputBufferSize(OptionsMovieExporter::getSettingOutputBufferSize());
   mpAdvancedWidget->setFlags(OptionsMovieExporter::getSettingFlags());

   LabeledSection* pAdvancedSection = new LabeledSection(mpAdvancedWidget, "Advanced Options", this);

   // Initialization
   addSection(pResolutionSection);
   addSection(pPlaybackSection);
   addSection(pAdvancedSection);
   addStretch(10);
   setSizeHint(450, 450);
}
Пример #19
0
 void updateLink()
 {
     ChannelListWidget *tw = static_cast<ChannelListWidget *>(treeWidget());
     if (tw->minimumItemHeight())
         setSizeHint(0, QSize(1, tw->minimumItemHeight()));
     if (tw->linkEnabled()) {
         bool enable = false;
         switch (tw->linkType()) {
         case ChannelListWidget::ChannelLink:
             enable = m_channel->isPlayable();
             break;
         case ChannelListWidget::ContactLink:
             enable = m_channel->hasContactUrl();
             break;
         }
         setLink(ChannelListWidget::Name, enable);
     } else {
         setLink(ChannelListWidget::Name, false);
     }
 }
Пример #20
0
ContactListItem::ContactListItem(Contact* contact)
{
	m_contact = contact;
	m_group = 0;
	
	setEditable(false);
	setDragEnabled(true);
	setDropEnabled(false);

	setText(m_contact->nickname());

	if (m_contact->isPhone())
	{
		setIcon(QIcon(":icons/phone.png"));

		setDragEnabled(false);
	}
	else if (m_contact->isConference())
	{
		setIcon(QIcon(":icons/msg_conference.png"));

		setDragEnabled(false);
	}
	else
	{
//		checkVisibility();

		connect(m_contact, SIGNAL(statusChanged(OnlineStatus)), this, SLOT(update()));
		connect(m_contact, SIGNAL(groupChanged(bool)), this, SLOT(changeGroup(bool)));
		connect(m_contact, SIGNAL(visibilityChanged()), this, SLOT(update()));
		connect(m_contact, SIGNAL(ignoredChanged()), this, SLOT(update()));
	}
	QFont f = font();
	/*if (!m_contact->isIgnored())
		f.setPointSize(9);
	setFont(f);*/
	setSizeHint(QSize(sizeHint().width(), 52));

	connect(m_contact, SIGNAL(renamed(QString)), this, SLOT(update()));
	connect(m_contact, SIGNAL(destroyed(QObject*)), this, SLOT(destroyItem()));
}
MovieExportOptionsWidget::MovieExportOptionsWidget() :
   LabeledSectionGroup(NULL)
{
   // Resolution section
   mpResolutionWidget = new ViewResolutionWidget(this);
   LabeledSection* pResolutionSection = new LabeledSection(mpResolutionWidget, "Output Resolution", this);

   // Playback section
   QWidget* pPlaybackWidget = new QWidget(this);
   mpBitrateWidget = new BitrateWidget(pPlaybackWidget);
   mpFramerateWidget = new FramerateWidget(pPlaybackWidget);

   QVBoxLayout* pPlaybackLayout = new QVBoxLayout(pPlaybackWidget);
   pPlaybackLayout->setMargin(0);
   pPlaybackLayout->setSpacing(10);
   pPlaybackLayout->addWidget(mpBitrateWidget);
   pPlaybackLayout->addWidget(mpFramerateWidget);

   LabeledSection* pPlaybackSection = new LabeledSection(pPlaybackWidget, "Playback", this);

   // Subset section
   mpSubsetWidget = new AnimationFrameSubsetWidget(this);
   LabeledSection* pSubsetSection = new LabeledSection(mpSubsetWidget, "Export Subset", this);

   // Advanced options section
   mpAdvancedWidget = new AdvancedOptionsWidget(this);
   LabeledSection* pAdvancedSection = new LabeledSection(mpAdvancedWidget, "Advanced Options", this);
   pAdvancedSection->collapse();

   // Initialization
   addSection(pResolutionSection);
   addSection(pPlaybackSection);
   addSection(pSubsetSection);
   addSection(pAdvancedSection);
   addStretch(10);
   setSizeHint(455, 450);
}
Пример #22
0
bool Spacer::qt_property( int id, int f, QVariant* v)
{
    switch ( id - staticMetaObject()->propertyOffset() ) {
    case 0: switch( f ) {
	case 0: case 1: case 3: case 4: case 5: goto resolve;
	default: return FALSE;
    } break;
    case 1: switch( f ) {
	case 0: setOrientation((Orientation&)v->asInt()); break;
	case 1: *v = QVariant( (int)this->orientation() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 2: switch( f ) {
	case 0: setSizeType((SizeType&)v->asInt()); break;
	case 1: *v = QVariant( (int)this->sizeType() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 3: switch( f ) {
	case 0: setSizeHint(v->asSize()); break;
	case 1: *v = QVariant( this->sizeHint() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 4: switch( f ) {
	case 0: case 1: case 4: case 5: goto resolve;
	default: return FALSE;
    } break;
    default:
	return QWidget::qt_property( id, f, v );
    }
    return TRUE;
resolve:
    return QWidget::qt_property( staticMetaObject()->resolveProperty(id), f, v );
}
 ThresholdWidget::ThresholdWidget(RecordingManager &manager, Widget *parent) : Widget(parent) {
     _manager = &manager;
     setSizeHint(Widgets::Size(74,270+26));
 }
Пример #24
0
Label::Label(Widget *parent) : Widget(parent) {
	setSizeHint(Size(Application::font()->characterWidth()*10+2*PADDING, Application::font()->characterHeight()+2*PADDING));
}
Пример #25
0
void Label::updateSize() {
	setSizeHint(Size(Application::font()->characterWidth()*_text.size()+2*PADDING, Application::font()->characterHeight()+2*PADDING));
}
ErrorBox::ErrorBox(const char *text) : text(text) {
	setSizeHint(Size(20, 20));
}
Пример #27
0
lds_treeWidgetItem::lds_treeWidgetItem(const QStringList &strings, int type):
    QTreeWidgetItem(strings, type)
{
   setSizeHint(0, QSize(60,30));
}
SpectralLibraryMatchOptions::SpectralLibraryMatchOptions()
{
   // match options section
   QWidget* pMatchWidget = new QWidget(this);
   QGridLayout* pMatchLayout = new QGridLayout(pMatchWidget);
   QLabel* pMatchAlgLabel = new QLabel("Algorithm:", pMatchWidget);
   mpMatchAlgCombo = new QComboBox(pMatchWidget);
   mpMatchEachPixel = new QCheckBox("Match each pixel in AOI", pMatchWidget);
   mpLimitByMaxNum = new QCheckBox("Limit by number:", pMatchWidget);
   mpLimitByMaxNum->setToolTip("Check to only display up to this number of matches");
   mpMaxDisplayed = new QSpinBox(pMatchWidget);
   mpLimitByThreshold = new QCheckBox("Limit by threshold:", pMatchWidget);
   mpLimitByThreshold->setToolTip("Check to only display matches below the threshold");
   mpMatchThreshold = new QDoubleSpinBox(pMatchWidget);
   mpMatchThreshold->setSingleStep(0.1);
   mpMatchThreshold->setToolTip("Limit the displayed matches to signatures\n"
      "with match values less than this threshold");
   mpAutoclear = new QCheckBox("Autoclear Results", pMatchWidget);
   mpAutoclear->setToolTip("Check to clear existing results before adding new results.\nIf not checked, new results "
      "will be added to existing results.");
   pMatchLayout->setMargin(0);
   pMatchLayout->setSpacing(5);
   pMatchLayout->addWidget(pMatchAlgLabel, 0, 0, Qt::AlignRight);
   pMatchLayout->addWidget(mpMatchAlgCombo, 0, 1);
   pMatchLayout->setColumnStretch(1, 10);
   pMatchLayout->addWidget(mpMatchEachPixel, 1, 1);
   pMatchLayout->addWidget(mpLimitByMaxNum, 2, 0);
   pMatchLayout->addWidget(mpMaxDisplayed, 2, 1);
   pMatchLayout->addWidget(mpLimitByThreshold, 3, 0);
   pMatchLayout->addWidget(mpMatchThreshold, 3, 1);
   pMatchLayout->addWidget(mpAutoclear, 4, 0);
   LabeledSection* pMatchSection = new LabeledSection(pMatchWidget, "Spectral Library Match Options", this);

   // locate options section
   QWidget* pLocateWidget = new QWidget(this);
   QGridLayout* pLocateLayout = new QGridLayout(pLocateWidget);
   QLabel* pLocAlgLabel = new QLabel("Algorithm:", pLocateWidget);
   mpLocateAlgCombo = new QComboBox(pLocateWidget);
   QLabel* pThresLabel = new QLabel("Locate Threshold:", pLocateWidget);
   mpLocateThreshold = new QDoubleSpinBox(pLocateWidget);
   mpLocateThreshold->setSingleStep(0.1);
   mpDisplayLocateOptions = new QCheckBox("Display Locate options before running", pLocateWidget);
   mpDisplayLocateOptions->setToolTip("Check this box to display the Locate options dialog "
      "before each run of the Locate function.\nUncheck it to suppress the dialog and use the current settings.");

   pLocateLayout->setMargin(0);
   pLocateLayout->setSpacing(5);
   pLocateLayout->addWidget(pLocAlgLabel, 0, 0, Qt::AlignRight);
   pLocateLayout->addWidget(mpLocateAlgCombo, 0, 1);
   pLocateLayout->setColumnStretch(1, 10);
   pLocateLayout->addWidget(pThresLabel, 2, 0);
   pLocateLayout->addWidget(mpLocateThreshold, 2, 1);
   pLocateLayout->addWidget(mpDisplayLocateOptions, 3, 1);
   LabeledSection* pLocateSection = new LabeledSection(pLocateWidget, "Locate Matched Signatures Options", this);

   addSection(pMatchSection);
   addSection(pLocateSection);
   addStretch(10);
   setSizeHint(100, 100);

   // initialize algorithm combo boxes
   std::vector<std::string> algNames =
      StringUtilities::getAllEnumValuesAsDisplayString<SpectralLibraryMatch::MatchAlgorithm>();
   for (std::vector<std::string>::const_iterator it = algNames.begin(); it != algNames.end(); ++it)
   {
      mpMatchAlgCombo->addItem(QString::fromStdString(*it));
   }
   algNames = StringUtilities::getAllEnumValuesAsDisplayString<SpectralLibraryMatch::LocateAlgorithm>();
   for (std::vector<std::string>::const_iterator it = algNames.begin(); it != algNames.end(); ++it)
   {
      mpLocateAlgCombo->addItem(QString::fromStdString(*it));
   }

   // connections
   VERIFYNR(connect(mpMatchAlgCombo, SIGNAL(currentIndexChanged(const QString&)),
      this, SLOT(matchAlgorithmChanged(const QString&))));
   VERIFYNR(connect(mpLocateAlgCombo, SIGNAL(currentIndexChanged(const QString&)),
      this, SLOT(locateAlgorithmChanged(const QString&))));
   VERIFYNR(connect(mpLimitByMaxNum, SIGNAL(toggled(bool)),
      mpMaxDisplayed, SLOT(setEnabled(bool))));
   VERIFYNR(connect(mpLimitByThreshold, SIGNAL(toggled(bool)),
      mpMatchThreshold, SLOT(setEnabled(bool))));
   VERIFYNR(connect(mpMatchThreshold, SIGNAL(valueChanged(double)),
      this, SLOT(matchThresholdChanged(double))));
   VERIFYNR(connect(mpLocateThreshold, SIGNAL(valueChanged(double)),
      this, SLOT(locateThresholdChanged(double))));

   // set up match algorithm threshold map
   std::vector<std::string> matchAlgorithmNames =
      StringUtilities::getAllEnumValuesAsDisplayString<SpectralLibraryMatch::MatchAlgorithm>();
   for (std::vector<std::string>::iterator it = matchAlgorithmNames.begin();
      it != matchAlgorithmNames.end(); ++it)
   {
      float threshold(0.0f);
      switch (StringUtilities::fromDisplayString<SpectralLibraryMatch::MatchAlgorithm>(*it))
      {
      case SpectralLibraryMatch::SLMA_SAM:
         threshold = SpectralLibraryMatchOptions::getSettingMatchSamThreshold();
         break;

      case SpectralLibraryMatch::SLMA_WBI:
         threshold = SpectralLibraryMatchOptions::getSettingMatchWbiThreshold();
         break;

      default:
         threshold = 0.0f;
         break;
      }

      mMatchThresholds.insert(std::pair<std::string, float>(*it, threshold));
   }

   // set up locate algorithm threshold map
   std::vector<std::string> locateAlgorithmNames =
      StringUtilities::getAllEnumValuesAsDisplayString<SpectralLibraryMatch::LocateAlgorithm>();
   for (std::vector<std::string>::iterator it = locateAlgorithmNames.begin();
      it != locateAlgorithmNames.end(); ++it)
   {
      float threshold(0.0f);
      switch (StringUtilities::fromDisplayString<SpectralLibraryMatch::LocateAlgorithm>(*it))
      {
      case SpectralLibraryMatch::SLLA_CEM:
         threshold = SpectralLibraryMatchOptions::getSettingLocateCemThreshold();
         break;

      case SpectralLibraryMatch::SLLA_SAM:
         threshold = SpectralLibraryMatchOptions::getSettingLocateSamThreshold();
         break;

      case SpectralLibraryMatch::SLLA_WBI:
         threshold = SpectralLibraryMatchOptions::getSettingLocateWbiThreshold();
         break;

      default:
         threshold = 0.0f;
         break;
      }

      mLocateThresholds.insert(std::pair<std::string, float>(*it, threshold));
   }

   // Initialize From Settings
   SpectralLibraryMatch::MatchAlgorithm matType = StringUtilities::fromXmlString<SpectralLibraryMatch::MatchAlgorithm>(
      SpectralLibraryMatchOptions::getSettingMatchAlgorithm());
   mpMatchAlgCombo->setCurrentIndex(mpMatchAlgCombo->findText(QString::fromStdString(
      StringUtilities::toDisplayString<SpectralLibraryMatch::MatchAlgorithm>(matType))));
   bool matchEach = SpectralLibraryMatchOptions::getSettingMatchEachPixel();
   mpMatchEachPixel->setChecked(matchEach);
   bool limit = SpectralLibraryMatchOptions::getSettingLimitByMaxNum();
   mpLimitByMaxNum->setChecked(limit);
   mpMaxDisplayed->setValue(SpectralLibraryMatchOptions::getSettingMaxDisplayed());
   mpMaxDisplayed->setEnabled(limit);
   limit = SpectralLibraryMatchOptions::getSettingLimitByThreshold();
   mpLimitByThreshold->setChecked(limit);
   switch (matType)
   {
   case SpectralLibraryMatch::SLMA_SAM:
      mpMatchThreshold->setValue(SpectralLibraryMatchOptions::getSettingMatchSamThreshold());
      break;

   case SpectralLibraryMatch::SLMA_WBI:
      mpMatchThreshold->setValue(SpectralLibraryMatchOptions::getSettingMatchWbiThreshold());
      break;

   default:
      mpMatchThreshold->setValue(0.0);
      break;
   }
   mpMatchThreshold->setEnabled(limit);
   bool autoClear = SpectralLibraryMatchOptions::getSettingAutoclear();
   mpAutoclear->setChecked(autoClear);
   SpectralLibraryMatch::LocateAlgorithm locType =
      StringUtilities::fromXmlString<SpectralLibraryMatch::LocateAlgorithm>(
      SpectralLibraryMatchOptions::getSettingLocateAlgorithm());
   mpLocateAlgCombo->setCurrentIndex(mpLocateAlgCombo->findText(QString::fromStdString(
      StringUtilities::toDisplayString<SpectralLibraryMatch::LocateAlgorithm>(locType))));
   mpLocateThreshold->setValue(mLocateThresholds[mpLocateAlgCombo->currentText().toStdString()]);
   mpDisplayLocateOptions->setChecked(SpectralLibraryMatchOptions::getSettingDisplayLocateOptions());
}
Пример #29
0
bool kvoctrainDoc::parseBody_e (XmlElement elem, XmlReader& xml)
{
  grade_t       grade,
                r_grade;
  int           qcount,
                r_qcount;
  int           bcount,
                r_bcount;
  QString       remark;
  QString       pronunce;
  time_t        qdate,
                r_qdate;
  bool          inquery;
  bool          active;
  QString       lang;
  QString       textstr;
  QString       exprtype;
  bool          org_found = false;
  QString       q_org,
                q_trans;
  QString       query_id;
  kvoctrainExpr expr;
  int           lesson;
  int           width;
  QString       type;
  QString       faux_ami_f;
  QString       faux_ami_t;
  QString       synonym;
  QString       example;
  QString       antonym;
  QString       usage;
  QString       paraphrase;
  vector<Conjugation> conjug;
  Comparison     comparison;
  MultipleChoice mc;

  if (!extract_KVT_E_attr (xml, elem, lesson, inquery, active, exprtype))
    return false;

  if (lesson
      && lesson > (int) lesson_descr.size() ) { // description missing ?
    QString s;
    for (int i = lesson_descr.size(); i < lesson; i++) {
      s.setNum (i+1);
      s.insert (0, "#");  // invent descr according to number
      lesson_descr.push_back (s);
    }
  }

  if (! xml.readElement (elem) ) {
    errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
    return false;
  }

  if (elem.tag() == KV_EXPR && !elem.isEndTag() ) {
    errorKvtMl (xml.lineNumber(),
                i18n("disallowed occurrence of tag <%1>").arg(elem.tag()));
    return false;
  }

  unsigned int count = 0;
  org_found = false;
  while (elem.tag() != KV_EXPR) {

    // now want "original" and one or more "translations"

    // found original <o>

    if (elem.tag() == KV_ORG && !elem.isEndTag() ) {
      if (org_found) {
        errorKvtMl (xml.lineNumber(),
                    i18n("repeated occurrence of tag <%1>").arg(elem.tag()));
        return false;
      }
      org_found = true;

      type = exprtype;
      if (!extract_O_T_attr (
                        xml,
                        elem,
                        lang,
                        grade,  r_grade,
                        qcount, r_qcount,
                        qdate,  r_qdate,
                        remark,
                        bcount, r_bcount,
                        query_id,
                        pronunce,
                        width,
                        type,
                        faux_ami_t,
                        faux_ami_f,
                        synonym,
                        example,
                        antonym,
                        usage,
                        paraphrase))
        return false;


      if (vocabulary.size() == 0) {  // only accept in first entry
        if (width >= 0)
          setSizeHint (count, width);

        if (query_id == KV_O)
          q_org = lang;

        if (query_id == KV_T)
          q_trans = lang;
      }

      if (langs.size() == 0) {          // first entry
        if (lang.isEmpty())                 // no definition in first entry
          lang = "original";
        langs.push_back(lang);

      }
      else {
        if (lang != langs[0] && !lang.isEmpty()) {  // different originals ?
          errorKvtMl (xml.lineNumber(),
                      i18n("ambiguous definition of language code"));
          return false;
        }
      }
      count = 0;

//========================================
// FIXME:: make loop for this

      if (! xml.readElement (elem) ) {
        errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
        return false;
      }

      if (elem.tag () == KV_CONJUG_GRP && !elem.isEndTag() ) {
        if (!loadConjugKvtMl (conjug, (QString) KV_CON_TYPE, elem, xml))
          return false;

        if (! xml.readElement (elem) ) {
          errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
          return false;
        }
      }

      comparison.clear();
      if (elem.tag () == KV_COMPARISON_GRP && !elem.isEndTag() ) {
        if (!loadComparison (comparison, elem, xml))
          return false;

        if (! xml.readElement (elem) ) {
          errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
          return false;
        }
      }

      mc.clear();
      if (elem.tag () == KV_MULTIPLECHOICE_GRP && !elem.isEndTag() ) {
        if (!loadMultipleChoice (mc, elem, xml))
          return false;

        if (! xml.readElement (elem) ) {
          errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
          return false;
        }
      }

      if (elem.tag() == "#PCDATA") { // element data
        textstr = xml.getText();
        if (! xml.readElement (elem) ) {
          errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
          return false;
        }

        if (elem.tag() != KV_ORG || !elem.isEndTag() ) {
          errorKvtMl (xml.lineNumber(),
                      i18n("expected ending tag <%1>").arg(KV_ORG));
          return false;
        }
      }
      else {
        if (elem.tag() != KV_ORG || !elem.isEndTag() ) {
          errorKvtMl (xml.lineNumber(),
                      i18n("expected ending tag <%1>").arg(KV_ORG));
          return false;
        }
        textstr = "";
      }

//========================================

      expr = kvoctrainExpr (textstr);
      expr.setLesson (lesson);
      expr.setInQuery(inquery);
      expr.setActive(active);

      if (conjug.size() > 0) {
        expr.setConjugation(0, conjug[0]);
        conjug.clear();
      }
      if (!comparison.isEmpty()) {
        expr.setComparison(0, comparison);
        comparison.clear();
      }
      if (!mc.isEmpty()) {
        expr.setMultipleChoice(0, mc);
        mc.clear();
      }
      if (!remark.isEmpty() )
        expr.setRemark (0, remark);
      if (!pronunce.isEmpty() )
        expr.setPronunce (0, pronunce);
      if (!type.isEmpty() )
        expr.setType(0, type);
      if (!synonym.isEmpty() )
        expr.setSynonym(0, synonym);
      if (!example.isEmpty() )
        expr.setExample(0, example);
      if (!usage.isEmpty() )
        expr.setUsageLabel(0, usage);
      if (!paraphrase.isEmpty() )
        expr.setParaphrase(0, paraphrase);
      if (!antonym.isEmpty() )
        expr.setAntonym(0, antonym);
    }

    // found translation <t>

    else if (elem.tag() == KV_TRANS && !elem.isEndTag() ) {
      if (!org_found) {   // must be preceded by "original"
        errorKvtMl (xml.lineNumber(),
                    i18n("starting tag <%1> is missing").arg(KV_ORG));
        return false;
      }

      count++;
      type = exprtype;
      if (!extract_O_T_attr (
                        xml,
                        elem,
                        lang,
                        grade,  r_grade,
                        qcount, r_qcount,
                        qdate,  r_qdate,
                        remark,
                        bcount, r_bcount,
                        query_id,
                        pronunce,
                        width,
                        type,
                        faux_ami_f,
                        faux_ami_t,
                        synonym,
                        example,
                        antonym,
                        usage,
                        paraphrase))
       return false;

      if (vocabulary.size() == 0) {  // only accept in first entry
        if (width >= 0)
          setSizeHint (count, width);

        if (query_id == KV_O)
          q_org = lang;

        if (query_id == KV_T)
          q_trans = lang;

      }

      if (langs.size() <= count) {      // new translation
        if (lang.isEmpty()) {               // no definition in first entry ?
          lang.setNum (langs.size() );
          lang.insert (0, "translation ");
        }
        langs.push_back(lang);

      }
      else {
        if (lang != langs[count] && !lang.isEmpty()) { // different language ?
          errorKvtMl (xml.lineNumber(),
                      i18n("ambiguous definition of language code"));
          return false;
        }
      }

//========================================
// FIXME:: make loop for this

      if (! xml.readElement (elem) ) {
        errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
        return false;
      }

      if (elem.tag () == KV_CONJUG_GRP && !elem.isEndTag() ) {
        if (!loadConjugKvtMl (conjug, (QString) KV_CON_TYPE, elem, xml))
          return false;

        if (! xml.readElement (elem) ) {
          errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
          return false;
        }
      }

      comparison.clear();
      if (elem.tag () == KV_COMPARISON_GRP && !elem.isEndTag() ) {
        if (!loadComparison (comparison, elem, xml))
          return false;

        if (! xml.readElement (elem) ) {
          errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
          return false;
        }
      }

      mc.clear();
      if (elem.tag () == KV_MULTIPLECHOICE_GRP && !elem.isEndTag() ) {
        if (!loadMultipleChoice (mc, elem, xml))
          return false;

        if (! xml.readElement (elem) ) {
          errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
          return false;
        }
      }

      textstr = "";
      if (elem.tag() == "#PCDATA") { // element data
        textstr = xml.getText();

        if (! xml.readElement (elem) ) {
          errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
          return false;
        }

        if (elem.tag() != KV_TRANS || !elem.isEndTag() ) {
          errorKvtMl (xml.lineNumber(),
                      i18n("expected ending tag <%1>").arg(KV_TRANS));
          return false;
        }
        // expr ...
      }
      else {
        if (elem.tag() != KV_TRANS || !elem.isEndTag() ) {
          errorKvtMl (xml.lineNumber(),
                      i18n("expected ending tag <%1>").arg(KV_TRANS));
          return false;
        }
        textstr = "";
      }

//========================================

      if (!org_found) {
        errorKvtMl (xml.lineNumber(),
                    i18n("starting tag <%1> is missing").arg(KV_ORG));
        return false;
      }
/*
      if (qcount == 0) {
        grade = KV_NORM_GRADE;
      }

      if (r_qcount == 0) {
        r_grade = KV_NORM_GRADE;
      }
*/
      expr.addTranslation (textstr, grade, r_grade);
      expr.setQueryCount  (count, qcount, false);
      expr.setQueryCount  (count, r_qcount, true);
      expr.setBadCount    (count, bcount, false);
      expr.setBadCount    (count, r_bcount, true);
      expr.setQueryDate   (count, qdate, false);
      expr.setQueryDate   (count, r_qdate, true);

      if (conjug.size() > 0) {
        expr.setConjugation(count, conjug[0]);
        conjug.clear();
      }
      if (!comparison.isEmpty()) {
        expr.setComparison(count, comparison);
        comparison.clear();
      }
      if (!mc.isEmpty()) {
        expr.setMultipleChoice(count, mc);
        mc.clear();
      }
      if (!type.isEmpty() )
        expr.setType (count, type);
      if (!remark.isEmpty() )
        expr.setRemark (count, remark);
      if (!pronunce.isEmpty() )
        expr.setPronunce (count, pronunce);
      if (!faux_ami_f.isEmpty() )
        expr.setFauxAmi (count, faux_ami_f, false);
      if (!faux_ami_t.isEmpty() )
        expr.setFauxAmi (count, faux_ami_t, true);
      if (!synonym.isEmpty() )
        expr.setSynonym (count, synonym);
      if (!example.isEmpty() )
        expr.setExample (count, example);
      if (!usage.isEmpty() )
        expr.setUsageLabel (count, usage);
      if (!paraphrase.isEmpty() )
        expr.setParaphrase (count, paraphrase);
      if (!antonym.isEmpty() )
        expr.setAntonym (count, antonym);
    }
    else {
      if (elem.isEndTag() ) {
        errorKvtMl (xml.lineNumber(),
                    i18n("unexpected ending tag <%1>" ).arg(elem.tag()));
        return false;
      }
      else {
        unknownElement (xml.lineNumber(), elem.tag());
        return false;
      }
    }

    if (! xml.readElement (elem) ) {
      errorKvtMl (xml.lineNumber(), i18n("I/O failure") );
      return false;
    }
  }
  if (numEntries() == 0)
    setQueryLang (q_org, q_trans);
  vocabulary.push_back (expr);

  return true;
}
ColorDropDownList::ColorDropDownList(Widget *parent) : Widget(parent), _selection(0) {
	setSizeHint(Widgets::Size(SLICE_W+15,SLICE_H));
}