CFileType CFileUtil:: getType(CFileBase *file) { CFileType type = file->getType(); if (type != CFILE_TYPE_INODE_REG) return type; type = getImageType(file); if (type != CFILE_TYPE_NONE) return type; type = getSoundType(file); if (type != CFILE_TYPE_NONE) return type; type = getTextType(file); if (type != CFILE_TYPE_NONE) return type; //------ std::string filename = file->getName(); type = getImageTypeFromName(filename); if (type != CFILE_TYPE_NONE) return type; type = getSoundTypeFromName(filename); if (type != CFILE_TYPE_NONE) return type; type = getTextTypeFromName(filename); if (type != CFILE_TYPE_NONE) return type; //------ type = isText(file); if (type != CFILE_TYPE_NONE) return type; return CFILE_TYPE_TEXT_BINARY; }
void TextEventDialog::slotTextChanged(const QString &qtext) { std::string type(getTextType()); QString qtrunc(qtext); if (qtrunc.length() > 20) qtrunc = qtrunc.left(20) + "..."; std::string text(qstrtostr(qtrunc)); if (text == "") text = "Sample"; Text rtext(text, type); m_textExampleLabel->setPixmap(m_notePixmapFactory->makeTextPixmap(rtext)); }
gkResource* gkTextManager::createImpl(const gkResourceName& name, const gkResourceHandle& handle) { UTsize tt = getTextType(name.getName()); return new gkTextFile(this, name, handle, tt); }
void TextEventDialog::slotTypeChanged(const QString &) { std::string type(getTextType()); QString qtrunc(m_text->text()); if (qtrunc.length() > 20) qtrunc = qtrunc.left(20) + "..."; std::string text(qstrtostr(qtrunc)); if (text == "") text = "Sample"; Text rtext(text, type); m_textExampleLabel->setPixmap(m_notePixmapFactory->makeTextPixmap(rtext)); // // swap widgets in and out, depending on the current text type // if (type == Text::Dynamic) { m_optionLabel->setCurrentWidget(m_dynamicShortcutLabel); m_optionWidget->setCurrentWidget(m_dynamicShortcutCombo); slotDynamicShortcutChanged(strtoqstr(text)); } if (type == Text::Direction) { m_optionLabel->setCurrentWidget(m_directionShortcutLabel); m_optionWidget->setCurrentWidget(m_directionShortcutCombo); slotDirectionShortcutChanged(strtoqstr(text)); } if (type == Text::LocalDirection) { m_optionLabel->setCurrentWidget(m_localDirectionShortcutLabel); m_optionWidget->setCurrentWidget(m_localDirectionShortcutCombo); slotLocalDirectionShortcutChanged(strtoqstr(text)); } if (type == Text::Tempo) { m_optionLabel->setCurrentWidget(m_tempoShortcutLabel); m_optionWidget->setCurrentWidget(m_tempoShortcutCombo); slotTempoShortcutChanged(strtoqstr(text)); } if (type == Text::LocalTempo) { m_optionLabel->setCurrentWidget(m_localTempoShortcutLabel); m_optionWidget->setCurrentWidget(m_localTempoShortcutCombo); slotLocalTempoShortcutChanged(strtoqstr(text)); } if (type == Text::Lyric) { m_optionLabel->setCurrentWidget(m_verseLabel); m_optionWidget->setCurrentWidget(m_verseSpin); } if (type == Text::Annotation || type == Text::Chord || type == Text::UnspecifiedType) { m_optionLabel->setCurrentWidget(m_blankLabel); m_optionWidget->setCurrentWidget(m_blankWidget); } // restore previous text of appropriate type if (type == Text::Lyric) m_text->setText(m_prevLyric); else if (type == Text::Chord) m_text->setText(m_prevChord); else if (type == Text::Annotation) m_text->setText(m_prevAnnotation); // // LilyPond directives only taking temporary residence here; will move out // into some new class eventually // if (type == Text::LilyPondDirective) { m_optionWidget->setCurrentWidget(m_lilyPondDirectiveCombo); m_optionLabel->setCurrentWidget(m_directiveLabel); m_staffAboveLabel->hide(); m_staffBelowLabel->show(); m_text->setReadOnly(true); m_text->setEnabled(false); slotLilyPondDirectiveChanged(strtoqstr(text)); } else { m_text->setReadOnly(false); m_text->setEnabled(true); if (type == Text::Dynamic || type == Text::LocalDirection || type == Text::UnspecifiedType || type == Text::Lyric || type == Text::Annotation) { m_staffAboveLabel->show(); m_staffBelowLabel->hide(); } else { m_staffAboveLabel->hide(); m_staffBelowLabel->show(); } } adjustSize(); }