void CharTableModel::appendUnicode(const QString & s, uint base) { int orig = rowCount(); bool ok; int a = s.indexOf("#"); QString si = s.left(a); QString sf = (a >= 0) ? s.mid(a+1) : ""; if (sf.isEmpty()) sf = m_fontInUse; int val = si.toInt(&ok, base); if (!ok) return; if ((!m_characters.contains(val)) || (!m_fonts.contains(sf))) { beginResetModel(); m_characters.append(val); m_fonts.append(sf); endResetModel(); } else { // select already contained glyph int ix = m_characters.indexOf(val); int ixrow = ix / m_cols; int ixcol = ix % m_cols; m_selectionModel->select(index(ixrow, ixcol, QModelIndex()), QItemSelectionModel::ClearAndSelect); emit selectionChanged(m_selectionModel); } if (orig < rowCount()) emit rowAppended(); }
CharSelect::CharSelect(QWidget* parent) : ScrPaletteBase(parent, "CharSelect"), m_doc(0), m_enhanced(0), m_Item(0) { setupUi(this); paletteFileMask = tr("Scribus Char Palette (*.ucp);;All Files (*)"); hideButton->setIcon(loadIcon("22/insert-table.png")); unicodeButton->setIcon(loadIcon("find.png")); uniLoadButton->setIcon(loadIcon("22/document-open.png")); uniSaveButton->setIcon(loadIcon("22/document-save.png")); uniClearButton->setIcon(loadIcon("22/document-new.png")); m_userTableModel = new CharTableModel(this, 6, m_doc, PrefsManager::instance()->appPrefs.itemToolPrefs.textFont); loadUserContent(ScPaths::getApplicationDataDir() + "charpalette.ucp"); m_userTable->setModel(m_userTableModel); m_userTable->setAcceptDrops(true); // signals and slots connections connect(m_userTable, SIGNAL(selectChar(uint, QString)), this, SLOT(userNewChar(uint, QString))); connect(m_userTableModel, SIGNAL(selectionChanged(QItemSelectionModel*)), m_userTable, SLOT(modelSelectionChanged(QItemSelectionModel*))); connect(m_userTableModel, SIGNAL(rowAppended()), m_userTable, SLOT(resizeLastRow())); connect(unicodeButton, SIGNAL(chosenUnicode(const QString &)), m_userTableModel, SLOT(appendUnicode(const QString &))); connect(hideButton, SIGNAL(toggled(bool)), this, SLOT(hideButton_toggled(bool))); connect(this, SIGNAL(insertUserSpecialChar(QChar, QString)), this, SLOT(slot_insertUserSpecialChar(QChar, QString))); connect(uniLoadButton, SIGNAL(clicked()), this, SLOT(uniLoadButton_clicked())); connect(uniSaveButton, SIGNAL(clicked()), this, SLOT(uniSaveButton_clicked())); connect(uniClearButton, SIGNAL(clicked()), this, SLOT(uniClearButton_clicked())); }
void FileListModel::addFile(const AudioFileModel &file) { const QString key = MAKE_KEY(file.filePath()); const bool flag = (!m_blockUpdates); if(!m_fileStore.contains(key)) { if(flag) beginInsertRows(QModelIndex(), m_fileList.count(), m_fileList.count()); m_fileStore.insert(key, file); m_fileList.append(key); if(flag) endInsertRows(); emit rowAppended(); } }
void CharTableModel::addCharacter(QString ch) { int orig = rowCount(); bool ok; int a = ch.indexOf(" "); QString si = ch.left(a); QString sf = ch.mid(a+1); int val = si.toInt(&ok, 10); if (!ok) return; beginResetModel(); m_characters.append(val); m_fonts.append(sf); endResetModel(); if (orig < rowCount()) emit rowAppended(); }
void FileListModel::addFile(const QString &filePath) { QFileInfo fileInfo(filePath); const QString key = MAKE_KEY(fileInfo.canonicalFilePath()); const bool flag = (!m_blockUpdates); if(!m_fileStore.contains(key)) { AudioFileModel audioFile(fileInfo.canonicalFilePath()); audioFile.metaInfo().setTitle(fileInfo.baseName()); if(flag) beginInsertRows(QModelIndex(), m_fileList.count(), m_fileList.count()); m_fileStore.insert(key, audioFile); m_fileList.append(key); if(flag) endInsertRows(); emit rowAppended(); } }