bool QsvTextOperationsWidget::issue_search( const QString &text, QTextCursor newCursor, QFlags<QTextDocument::FindFlag> findOptions, QLineEdit *l, bool moveCursor ) { QTextCursor c = m_document->find( text, newCursor, findOptions ); bool found = ! c.isNull(); //lets try again, from the start if (!found) { c.movePosition(findOptions.testFlag(QTextDocument::FindBackward)? QTextCursor::End : QTextCursor::Start); c = m_document->find(text, c, findOptions); found = ! c.isNull(); } QPalette p = l->palette(); if (found) { p.setColor(QPalette::Base, searchFoundColor); } else { if (!text.isEmpty()) p.setColor(QPalette::Base, searchNotFoundColor); else p.setColor(QPalette::Base, l->style()->standardPalette().base().color() ); c = m_searchCursor; } l->setPalette(p); if (moveCursor){ int start = c.selectionStart(); int end = c.selectionEnd(); c.setPosition(end ,QTextCursor::MoveAnchor); c.setPosition(start,QTextCursor::KeepAnchor); setTextCursor(c); } return found; }
bool HotKeyEdit::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); QFlags<Qt::KeyboardModifier> modifiers = keyEvent->modifiers(); QString shortcut; if (modifiers.testFlag(Qt::ControlModifier)) shortcut.append("Ctrl").append('+'); if (modifiers.testFlag(Qt::AltModifier)) shortcut.append("Alt").append('+'); if (modifiers.testFlag(Qt::ShiftModifier)) shortcut.append("Shift").append('+'); int key = keyEvent->key(); if (key >= Qt::Key_A && key <= Qt::Key_Z) shortcut.append((char)key); else if (key >= Qt::Key_F1 && key <= Qt::Key_F12) shortcut.append('F').append(QString().setNum(key-Qt::Key_F1+1)); else key = 0; if (key) setText(shortcut); shortcut.clear(); qDebug("Ate key press %X", keyEvent->key()); return true; } else { return QObject::eventFilter(obj, event); } }
FileInfoList Dir::entryInfoList(QFlags<Filters> filters, QFlags<SortFlags> sortFlags) { if(filters == NoFilter) filters = m_filters; if(sortFlags == NoSort) sortFlags == m_sort_flags; FileInfoList ret; // use our internal method to get an unsorted list, then sort it foreach(QString entry, m_entry_list()) { // this list contains absolute URIs FileInfo i(entry); // apply the filters // // is this a hidden file ? if(i.fileName().startsWith('.') && !filters.testFlag(Hidden)) continue; // yes, don't include it unless Hidden flag is set // check permissions if(!i.isReadable() && filters.testFlag(Readable)) continue; // non readable, and we must ony include readable // as above, for +w and +x if(!i.isWritable() && filters.testFlag(Writeable)) continue; if(!i.isExecutable() && filters.testFlag(Executable)) continue; // is it a symlink ? if(i.isSymlink()) { // can we include it ? if(!filters.testFlag(NoSymlinks)) ret.append(i); } // is it a dir ? else if(i.isDir()) { if(filters.testFlag(AllDirs)) ret.append(i); // yes, but flag AllDirs tells we should include it even he does not match name filters else if(filters.testFlag(Dirs) || filters.testFlag(AllEntries)/* && TODO: add nameFilters */) ret.append(i); // yes, but he must match the name filters to be included } // is it a file ? else if(i.isFile()) { if(filters.testFlag(Files) || filters.testFlag(AllEntries)) ret.append(i); } }
bool BlackBerryCreatePackageStep::doUpdateAppDescriptorFile(const Utils::FileName &appDescriptorPath, QFlags<EditMode> types, bool skipConfirmation) { Core::FileChangeBlocker fb(appDescriptorPath.toString()); BarDescriptorDocument doc; QString errorString; if (!doc.open(&errorString, appDescriptorPath.toString())) { raiseError(tr("Error opening BAR application descriptor file \"%1\" - %2") .arg(appDescriptorPath.toUserOutput()) .arg(errorString)); return false; } BarDescriptorAssetList assetList = doc.value(BarDescriptorDocument::asset) .value<BarDescriptorAssetList>(); bool updated = false; if (types.testFlag(PlaceHolders)) { foreach (const BarDescriptorAsset &a, assetList) { if (a.source.contains(QLatin1String("%SRC_DIR%"))) { // Keep backward compatibility with older templates QHash<QString, QString> placeHoldersHash; placeHoldersHash[QLatin1String("%SRC_DIR%")] = QString(); doc.expandPlaceHolders(placeHoldersHash); updated = true; } // Update the entry point source path to make use of the BUILD_DIR variable // if not set if (a.entry) { BarDescriptorAsset asset = a; if (asset.source.contains(QLatin1String("${BUILD_DIR}/"))) break; asset.source = QLatin1String("${BUILD_DIR}/") + asset.destination; assetList.removeOne(a); assetList << asset; updated = true; break; } } }