本文整理汇总了C++中QScopedPointer::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ QScopedPointer::isNull方法的具体用法?C++ QScopedPointer::isNull怎么用?C++ QScopedPointer::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScopedPointer
的用法示例。
在下文中一共展示了QScopedPointer::isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locker
QApplicationActivityObserver * QApplicationActivityObserver::instance()
{
static QMutex mymutex;
static QScopedPointer<QApplicationActivityObserver> instance;
QMutexLocker locker(&mymutex);
// Creating instance
if (instance.isNull())
{
instance.reset(new QApplicationActivityObserver());
}
// Installing event filter
static bool installed_filter = false;
if (!installed_filter)
{
QCoreApplication * app = QCoreApplication::instance();
if (app)
{
app->installEventFilter(instance.data());
installed_filter = true;
qDebug()<<__FUNCTION__<<"Successfully installed event filter.";
}
else
{
qWarning()<<__FUNCTION__<<"installing event filter failed because QCoreApplication instance doesn't exist, will try later.";
}
}
return instance.data();
}
示例2: report
void Reporter::report(const QString &message, const QScopedPointer<utils::OutFile> &file)
{
if (!file.isNull()) {
(*file)() << message;
file->flush();
}
}
示例3: isNullSignature
void tst_QScopedPointer::isNullSignature()
{
const QScopedPointer<int> p(new int(69));
/* The signature should be const and return bool. */
static_cast<bool>(p.isNull());
}
示例4: readLock
/*
* Initialize app icon
*/
const QIcon &lamexp_app_icon(void)
{
QReadLocker readLock(&g_lamexp_icon_lock);
//Already initialized?
if(!g_lamexp_icon_data.isNull())
{
return *g_lamexp_icon_data;
}
readLock.unlock();
QWriteLocker writeLock(&g_lamexp_icon_lock);
while(g_lamexp_icon_data.isNull())
{
QDate currentDate = QDate::currentDate();
QTime currentTime = QTime::currentTime();
if(lamexp_thanksgiving(currentDate))
{
g_lamexp_icon_data.reset(new QIcon(":/MainIcon6.png"));
}
else if(((currentDate.month() == 12) && (currentDate.day() == 31) && (currentTime.hour() >= 20)) || ((currentDate.month() == 1) && (currentDate.day() == 1) && (currentTime.hour() <= 19)))
{
g_lamexp_icon_data.reset(new QIcon(":/MainIcon5.png"));
}
else if(((currentDate.month() == 10) && (currentDate.day() == 31) && (currentTime.hour() >= 12)) || ((currentDate.month() == 11) && (currentDate.day() == 1) && (currentTime.hour() <= 11)))
{
g_lamexp_icon_data.reset(new QIcon(":/MainIcon4.png"));
}
else if((currentDate.month() == 12) && (currentDate.day() >= 24) && (currentDate.day() <= 26))
{
g_lamexp_icon_data.reset(new QIcon(":/MainIcon3.png"));
}
else if(lamexp_computus(currentDate))
{
g_lamexp_icon_data.reset(new QIcon(":/MainIcon2.png"));
}
else
{
g_lamexp_icon_data.reset(new QIcon(":/MainIcon1.png"));
}
}
return *g_lamexp_icon_data;
}
示例5: readLockTranslations
quint32 MUtils::Translation::get_country(const QString &langId)
{
QReadLocker readLockTranslations(&g_translation_lock);
const QString key = langId.simplified().toLower();
if(key.isEmpty() || g_translation_data.isNull() || (!g_translation_data->contains(key)))
{
return 0;
}
return (*g_translation_data)[key].second.second;
}
示例6: composition
bool QWindowsInputContext::composition(HWND hwnd, LPARAM lParamIn)
{
QObject *fo = qApp->focusObject();
const int lParam = int(lParamIn);
if (QWindowsContext::verboseInputMethods)
qDebug() << '>' << __FUNCTION__ << fo << debugComposition(lParam)
<< " composing=" << m_compositionContext.isComposing;
if (!fo || m_compositionContext.hwnd != hwnd || !lParam)
return false;
const HIMC himc = ImmGetContext(m_compositionContext.hwnd);
if (!himc)
return false;
QScopedPointer<QInputMethodEvent> event;
if (lParam & (GCS_COMPSTR | GCS_COMPATTR | GCS_CURSORPOS)) {
if (!m_compositionContext.isComposing)
startContextComposition();
// Some intermediate composition result. Parametrize event with
// attribute sequence specifying the formatting of the converted part.
int selStart, selLength;
m_compositionContext.composition = getCompositionString(himc, GCS_COMPSTR);
m_compositionContext.position = ImmGetCompositionString(himc, GCS_CURSORPOS, 0, 0);
getCompositionStringConvertedRange(himc, &selStart, &selLength);
if ((lParam & CS_INSERTCHAR) && (lParam & CS_NOMOVECARET)) {
// make Korean work correctly. Hope this is correct for all IMEs
selStart = 0;
selLength = m_compositionContext.composition.size();
}
if (!selLength)
selStart = 0;
event.reset(new QInputMethodEvent(m_compositionContext.composition,
intermediateMarkup(m_compositionContext.position,
m_compositionContext.composition.size(),
selStart, selLength)));
}
if (event.isNull())
event.reset(new QInputMethodEvent);
if (lParam & GCS_RESULTSTR) {
// A fixed result, return the converted string
event->setCommitString(getCompositionString(himc, GCS_RESULTSTR));
endContextComposition();
}
const bool result = QCoreApplication::sendEvent(fo, event.data());
if (QWindowsContext::verboseInputMethods)
qDebug() << '<' << __FUNCTION__ << "sending markup="
<< event->attributes().size()
<< " commit=" << event->commitString()
<< " to " << fo << " returns " << result;
update(Qt::ImQueryAll);
ImmReleaseContext(m_compositionContext.hwnd, himc);
return result;
}
示例7: lamexp_tools_check
/*
* Check for tool
*/
bool lamexp_tools_check(const QString &toolName)
{
QReadLocker readLock(&g_lamexp_tools_lock);
if(!g_lamexp_tools_data.isNull())
{
const QString key = toolName.simplified().toLower();
return g_lamexp_tools_data->contains(key);
}
return false;
}
示例8: isNull
void tst_QScopedPointer::isNull()
{
/* Invoke on default constructed value. */
{
QScopedPointer<int> p;
QVERIFY(p.isNull());
}
/* Invoke on a set value. */
{
QScopedPointer<int> p(new int(69));
QVERIFY(!p.isNull());
}
}
示例9: readLock
/*
* Lookup tool path
*/
const QString &lamexp_tools_lookup(const QString &toolName)
{
QReadLocker readLock(&g_lamexp_tools_lock);
if(!g_lamexp_tools_data.isNull())
{
const QString key = toolName.simplified().toLower();
if(g_lamexp_tools_data->contains(key))
{
return (*g_lamexp_tools_data)[key].first->filePath();
}
}
return g_null_string;
}
示例10: lamexp_tools_clean_up
/*
* Clean-up *all* registered tools
*/
static void lamexp_tools_clean_up(void)
{
QWriteLocker writeLock(&g_lamexp_tools_lock);
qWarning("------------ lamexp_tools_clean_up ------------");
if(!g_lamexp_tools_data.isNull())
{
const QStringList keys = g_lamexp_tools_data->keys();
for(QStringList::ConstIterator iter = keys.constBegin(); iter != keys.constEnd(); iter++)
{
tool_data_t currentTool = (*g_lamexp_tools_data)[*iter];
MUTILS_DELETE(currentTool.first);
}
g_lamexp_tools_data->clear();
}
}
示例11: pages
void Document::pages( QVector<Okular::Page*> * pagesVector )
{
qSort( mEntries.begin(), mEntries.end(), caseSensitiveNaturalOrderLessThen );
QScopedPointer< QIODevice > dev;
int count = 0;
pagesVector->clear();
pagesVector->resize( mEntries.size() );
QImageReader reader;
foreach(const QString &file, mEntries) {
if ( mArchive ) {
const KArchiveFile *entry = static_cast<const KArchiveFile*>( mArchiveDir->entry( file ) );
if ( entry ) {
dev.reset( entry->createDevice() );
}
} else if ( mDirectory ) {
dev.reset( mDirectory->createDevice( file ) );
} else {
dev.reset( mUnrar->createDevice( file ) );
}
if ( ! dev.isNull() ) {
reader.setDevice( dev.data() );
if ( reader.canRead() )
{
QSize pageSize = reader.size();
if ( !pageSize.isValid() ) {
const QImage i = reader.read();
if ( !i.isNull() )
pageSize = i.size();
}
if ( pageSize.isValid() ) {
pagesVector->replace( count, new Okular::Page( count, pageSize.width(), pageSize.height(), Okular::Rotation0 ) );
mPageMap.append(file);
count++;
} else {
qCDebug(OkularComicbookDebug) << "Ignoring" << file << "doesn't seem to be an image even if QImageReader::canRead returned true";
}
}
}
}
pagesVector->resize( count );
}
示例12: QMessageBox
QAbstractButton *ResolveLocationContext::execLocationMessageBox(QWidget *parent,
const QString &file,
bool wantSkipButton)
{
if (messageBox.isNull()) {
messageBox.reset(new QMessageBox(QMessageBox::Warning,
QrcEditor::tr("Invalid file location"),
QString(), QMessageBox::NoButton, parent));
copyButton = messageBox->addButton(QrcEditor::tr("Copy"), QMessageBox::ActionRole);
abortButton = messageBox->addButton(QrcEditor::tr("Abort"), QMessageBox::RejectRole);
messageBox->setDefaultButton(copyButton);
}
if (wantSkipButton && !skipButton) {
skipButton = messageBox->addButton(QrcEditor::tr("Skip"), QMessageBox::DestructiveRole);
messageBox->setEscapeButton(skipButton);
}
messageBox->setText(QrcEditor::tr("The file %1 is not in a subdirectory of the resource file. You now have the option to copy this file to a valid location.")
.arg(QDir::toNativeSeparators(file)));
messageBox->exec();
return messageBox->clickedButton();
}
示例13: findLocalRepository
// Try to find a matching repository for a project by asking the VcsManager.
QString GerritPlugin::findLocalRepository(QString project, const QString &branch) const
{
const QStringList gitRepositories = VcsManager::repositories(GitPlugin::instance()->gitVersionControl());
// Determine key (file name) to look for (qt/qtbase->'qtbase').
const int slashPos = project.lastIndexOf('/');
if (slashPos != -1)
project.remove(0, slashPos + 1);
// When looking at branch 1.7, try to check folders
// "qtbase_17", 'qtbase1.7' with a semi-smart regular expression.
QScopedPointer<QRegExp> branchRegexp;
if (!branch.isEmpty() && branch != "master") {
QString branchPattern = branch;
branchPattern.replace('.', "[\\.-_]?");
const QString pattern = '^' + project
+ "[-_]?"
+ branchPattern + '$';
branchRegexp.reset(new QRegExp(pattern));
if (!branchRegexp->isValid())
branchRegexp.reset(); // Oops.
}
for (const QString &repository : gitRepositories) {
const QString fileName = Utils::FileName::fromString(repository).fileName();
if ((!branchRegexp.isNull() && branchRegexp->exactMatch(fileName))
|| fileName == project) {
// Perform a check on the branch.
if (branch.isEmpty()) {
return repository;
} else {
const QString repositoryBranch = GerritPlugin::branch(repository);
if (repositoryBranch.isEmpty() || repositoryBranch == branch)
return repository;
} // !branch.isEmpty()
} // branchRegexp or file name match
} // for repositories
// No match, do we have a projects folder?
if (DocumentManager::useProjectsDirectory())
return DocumentManager::projectsDirectory().toString();
return QDir::currentPath();
}
示例14: writeLockTranslations
bool MUtils::Translation::insert(const QString &langId, const QString &qmFile, const QString &langName, const quint32 &systemId, const quint32 &country)
{
QWriteLocker writeLockTranslations(&g_translation_lock);
const QString key = langId.simplified().toLower();
if(key.isEmpty() || qmFile.isEmpty() || langName.isEmpty() || (systemId < 1))
{
return false;
}
if(g_translation_data.isNull())
{
g_translation_data.reset(new translation_store_t());
}
if(g_translation_data->contains(key))
{
qWarning("Translation store already contains entry for '%s', going to replace!", MUTILS_UTF8(key));
}
g_translation_data->insert(key, MAKE_ENTRY(langName, qmFile, systemId, country));
return true;
}
示例15: execCopyFileDialog
QString ResolveLocationContext::execCopyFileDialog(QWidget *parent, const QDir &dir, const QString &targetPath)
{
// Delayed creation of file dialog.
if (copyFileDialog.isNull()) {
copyFileDialog.reset(new QFileDialog(parent, QrcEditor::tr("Choose Copy Location")));
copyFileDialog->setFileMode(QFileDialog::AnyFile);
copyFileDialog->setAcceptMode(QFileDialog::AcceptSave);
}
copyFileDialog->selectFile(targetPath);
// Repeat until the path entered is no longer above 'dir'
// (relative is not "../").
while (true) {
if (copyFileDialog->exec() != QDialog::Accepted)
return QString();
const QStringList files = copyFileDialog->selectedFiles();
if (files.isEmpty())
return QString();
const QString relPath = dir.relativeFilePath(files.front());
if (!relPath.startsWith(QLatin1String("../")))
return files.front();
}
return QString();
}