Example #1
0
/**
 * This method may be called multiple times during the life time of an Aspect, or it might not get
 * called at all. Aspects must not depend on the existence of a view for their operation.
 */
QWidget* DatapickerImage::view() const {
	if (!m_view) {
		m_view = new DatapickerImageView(const_cast<DatapickerImage *>(this));
		connect(m_view, SIGNAL(statusInfo(QString)), this, SIGNAL(statusInfo(QString)));
	}
	return m_view;
}
Example #2
0
/**
 * This method may be called multiple times during the life time of an Aspect, or it might not get
 * called at all. Aspects must not depend on the existence of a view for their operation.
 */
QWidget *Worksheet::view() const {
	if (!m_view) {
		m_view = new WorksheetView(const_cast<Worksheet *>(this));
		connect(m_view, SIGNAL(statusInfo(QString)), this, SIGNAL(statusInfo(QString)));
	}
	return m_view;
}
Example #3
0
void Datapicker::init() {
	m_image = new DatapickerImage(0, i18n("Plot"));
	m_image->setHidden(true);
	setUndoAware(false);
	addChild(m_image);
	setUndoAware(true);

	connect(m_image, SIGNAL(statusInfo(QString)), this, SIGNAL(statusInfo(QString)));
}
// ---------------------------------------------------------------------------
// Handles the result of a LIW command
// ---------------------------------------------------------------------------
//
TInt CMPXBackSteppingUtilityImp::HandleResultL()
    {
    MPX_DEBUG1( "-->CMPXBackSteppingUtilityImp::HandleResultL" );
    TInt statusInfo( KErrNotFound );
    
    TInt posErr( 0 );
    iOutParamList->FindFirst( posErr, LIW::EGenericParamError );
    if( posErr != KErrNotFound )
        {
        // error code found - extract and handle
        TInt errorCode( KErrNone );
        (*iOutParamList)[posErr].Value().Get( errorCode );
        
        User::LeaveIfError( errorCode );
        }

    // if no error returned, carry on
    TInt posStat( 0 );
    iOutParamList->FindFirst( posStat, KBSOutParamStatusInfo );
    if( posStat != KErrNotFound )
        {
        // status info present - extract and return
        (*iOutParamList)[posStat].Value().Get( statusInfo );
        }
    else
        {
        // no return value
        // this should not happen
        User::Leave( KErrNotFound );
        }

    MPX_DEBUG2( "<--CMPXBackSteppingUtilityImp::HandleResultL statusInfo=%d", statusInfo );
    return statusInfo;
    }
QList<KUrl> VcsFileChangesModel::urls(QStandardItem *parent) const
{
    QList<KUrl> ret;

    for(int i = 0; i < parent->rowCount(); i++) {
        ret << statusInfo(parent->child(i)).url();
    }

    return ret;
}
void VcsFileChangesModel::checkUrls(QStandardItem *parent, const QList<KUrl>& urls) const
{
    QSet<KUrl> urlSet(urls.toSet());

    if(!d->allowSelection)
        return;

    for(int i = 0; i < parent->rowCount(); i++) {
        QStandardItem* item = parent->child(i);
        item->setCheckState(urlSet.contains(statusInfo(item).url()) ? Qt::Checked : Qt::Unchecked);
    }
}
QList<KUrl> VcsFileChangesModel::checkedUrls(QStandardItem *parent) const
{
    QList<KUrl> ret;

    for(int i = 0; i < parent->rowCount(); i++) {
        QStandardItem* item = parent->child(i);
        if(!d->allowSelection || item->checkState() == Qt::Checked) {
            ret << statusInfo(item).url();
        }
    }

    return ret;
}
Example #8
0
void Datapicker::handleAspectAboutToBeRemoved(const AbstractAspect* aspect) {
	const DatapickerCurve* curve = qobject_cast<const DatapickerCurve*>(aspect);
	if (curve) {
		//clear scene
		QList<DatapickerPoint *> childPoints = curve->children<DatapickerPoint>(IncludeHidden);
		foreach(DatapickerPoint *point, childPoints) {
			handleChildAspectAboutToBeRemoved(point);
		}

		if (curve==m_activeCurve) {
			m_activeCurve = 0;
			emit statusInfo("");
		}
	} else {
Example #9
0
/*!
    this slot is called when a datapicker child is selected in the project explorer.
    emits \c datapickerItemSelected() to forward this event to the \c DatapickerView
    in order to select the corresponding tab.
 */
void Datapicker::childSelected(const AbstractAspect* aspect) {
	m_activeCurve = dynamic_cast<DatapickerCurve*>(const_cast<AbstractAspect*>(aspect));

	int index = -1;
	if (m_activeCurve) {
		//if one of the curves is currently selected, select the image with the plot (the very first child)
		index = 0;
		emit statusInfo(this->name() + ", " + i18n("active curve") + " \"" + m_activeCurve->name() + "\"");
		emit requestUpdateActions();
	} else {
		const DatapickerCurve* curve = aspect->ancestor<const DatapickerCurve>();
		index= indexOfChild<AbstractAspect>(curve);
		++index; //+1 because of the hidden plot image being the first child and shown in the first tab in the view
	}

	emit datapickerItemSelected(index);
}
Example #10
0
void CreateAccount::addAttachment()
{
    QString supportedFiles = tr("PDF Documents (*.pdf);;"
                                "Images (*.png *.jpeg *.jpg)"
                                );

    QString filename = QFileDialog::getOpenFileName(this,
                                                    tr("Add Attachment:"),
                                                    QDir::currentPath(),
                                                    supportedFiles
                                                    );
    if(!filename.isEmpty()) {
        ui->editAttachment->setText(filename);
        enableSubmit();
        emit statusInfo("Photo ID attached");
    }
}
Example #11
0
/** ***************************************************************************/
void Files::Extension::Indexer::run() {

    // Notification
    qDebug("[%s] Start indexing in background thread", extension_->name_);
    emit statusInfo("Indexing files ...");

    // Prepare the iterator properties
    QDir::Filters filters = QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot;
    if (extension_->indexHidden_)
        filters |= QDir::Hidden;

    // Get a new index
    std::vector<shared_ptr<File>> newIndex;
    std::set<QString> indexedDirs;


    // Anonymous function that implemnents the index recursion
    std::function<void(const QFileInfo&)> indexRecursion =
            [this, &newIndex, &indexedDirs, &filters, &indexRecursion](const QFileInfo& fileInfo){
        if (abort_) return;

        const QString canonicalPath = fileInfo.canonicalFilePath();


        if (fileInfo.isFile()) {

            // If the file matches the index options, index it
            QMimeType mimetype = mimeDatabase_.mimeTypeForFile(canonicalPath);
            const QString mimeName = mimetype.name();
            if ((extension_->indexAudio_ && mimeName.startsWith("audio"))
                    ||(extension_->indexVideo_ && mimeName.startsWith("video"))
                    ||(extension_->indexImage_ && mimeName.startsWith("image"))
                    ||(extension_->indexDocs_ &&
                       (mimeName.startsWith("application") || mimeName.startsWith("text")))) {
                newIndex.push_back(std::make_shared<File>(canonicalPath, mimetype));
            }
        } else if (fileInfo.isDir()) {

            emit statusInfo(QString("Indexing %1.").arg(canonicalPath));

            // Skip if this dir has already been indexed
            if (indexedDirs.find(canonicalPath)!=indexedDirs.end())
                return;

            // Remember that this dir has been indexed to avoid loops
            indexedDirs.insert(canonicalPath);

            // If the dir matches the index options, index it
            if (extension_->indexDirs_) {
                QMimeType mimetype = mimeDatabase_.mimeTypeForFile(canonicalPath);
                newIndex.push_back(std::make_shared<File>(canonicalPath, mimetype));
            }

            // Ignore ignorefile by default
            std::vector<QRegExp> ignores;
            ignores.push_back(QRegExp(extension_->IGNOREFILE, Qt::CaseSensitive, QRegExp::Wildcard));

            // Read the ignore file, see http://doc.qt.io/qt-5/qregexp.html#wildcard-matching
            QFile file(QDir(canonicalPath).filePath(extension_->IGNOREFILE));
            if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
                QTextStream in(&file);
                while (!in.atEnd())
                    ignores.push_back(QRegExp(in.readLine().trimmed(), Qt::CaseSensitive, QRegExp::Wildcard));
                file.close();
            }

            // Index all children in the dir
            QDirIterator dirIterator(canonicalPath, filters, QDirIterator::NoIteratorFlags);
            while (dirIterator.hasNext()) {
                const QString fileName = dirIterator.next();

                // Skip if this file matches one of the ignore patterns
                for (const QRegExp& ignore : ignores)
                    if(ignore.exactMatch(fileName))
                        goto SKIP_THIS;

                // Skip if this file is a symlink and we shoud skip symlinks
                if (dirIterator.fileInfo().isSymLink() && !extension_->followSymlinks_)
                    goto SKIP_THIS;

                // Index this file
                indexRecursion(dirIterator.fileInfo());
                SKIP_THIS:;
            }
        }
    };


    // Start the indexing
    for (const QString &rootDir : extension_->rootDirs_) {
        indexRecursion(QFileInfo(rootDir));
        if (abort_) return;
    }


    // Sort the new index for linear usage copy [O(n*log(n))]
    emit statusInfo("Sorting ... ");
    std::sort(newIndex.begin(), newIndex.end(), [](const shared_ptr<File> &lhs, const shared_ptr<File> &rhs) {
                  return QString::compare(lhs->path(), rhs->path(), Qt::CaseInsensitive) < 0;
              });


    // Copy the usagecounters  [O(n)]
    emit statusInfo("Copy usage statistics ... ");
    size_t i=0, j=0;
    while (i < extension_->index_.size() && j < newIndex.size()) {
        if (extension_->index_[i]->path() == newIndex[j]->path()) {
            newIndex[j]->setUsage(extension_->index_[i]->usage());
            ++i;++j;
        } else if (extension_->index_[i]->path() < newIndex[j]->path()) {
            ++i;
        } else {// if ((*_fileIndex)[i]->path > (*newIndex)[j]->path) {
            ++j;
        }
    }

    /*
     *  ▼ CRITICAL ▼
     */

    // Lock the access
    QMutexLocker locker(&extension_->indexAccess_);

    // Abortion requested while block
    if (abort_)
        return;

    // Set the new index (use swap to shift destruction out of critical area)
    std::swap(extension_->index_, newIndex);

    // Rebuild the offline index
    extension_->offlineIndex_.clear();
    for (auto &item : extension_->index_)
        extension_->offlineIndex_.add(item);

    // Notification
    qDebug("[%s] Indexing done (%d items)", extension_->name_, static_cast<int>(extension_->index_.size()));
    emit statusInfo(QString("Indexed %1 files").arg(extension_->index_.size()));
}
Example #12
0
/** ***************************************************************************/
void Files::Indexer::run() {

    // Notification
    QString msg("Indexing files ...");
    emit statusInfo(msg);
    qDebug() << "[Files]" << msg;


    // Prepare the iterator properties
    QDir::Filters filters = QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot;
    if (_extension->_indexHidden)
        filters |= QDir::Hidden;
    QDirIterator::IteratorFlags flags;
    if (_extension->_followSymlinks)
        flags = QDirIterator::FollowSymlinks;


    // Get a new index
    std::vector<shared_ptr<File>> newIndex;
    std::set<QString> indexedDirs;


    // Anonymous function that implemnents the index recursion
    std::function<void(const QFileInfo&)> indexRecursion =
            [this, &newIndex, &indexedDirs, &filters, &flags, &indexRecursion](const QFileInfo& fileInfo){
        if (_abort) return;

        QString canonicalPath = fileInfo.canonicalFilePath();


        if (fileInfo.isFile()) {

            // If the file matches the index options, index it
            QMimeType mimetype = _mimeDatabase.mimeTypeForFile(canonicalPath);
            QString mimeName = mimetype.name();
            if ((_extension->_indexAudio && mimeName.startsWith("audio"))
                    ||(_extension->_indexVideo && mimeName.startsWith("video"))
                    ||(_extension->_indexImage && mimeName.startsWith("image"))
                    ||(_extension->_indexDocs &&
                       (mimeName.startsWith("application") || mimeName.startsWith("text")))) {
                newIndex.push_back(std::make_shared<File>(canonicalPath, mimetype));
            }
        } else if (fileInfo.isDir()) {

            emit statusInfo(QString("Indexing %1.").arg(canonicalPath));

            // Skip if this dir has already been indexed
            if (indexedDirs.find(canonicalPath)!=indexedDirs.end()){
                return;
            }

            // If the dir matches the index options, index it
            if (_extension->_indexDirs) {
                QMimeType mimetype = _mimeDatabase.mimeTypeForFile(canonicalPath);
                newIndex.push_back(std::make_shared<File>(canonicalPath, mimetype));
            }

            // Ignore ignorefile by default
            std::vector<QRegExp> ignores;
            ignores.push_back(QRegExp(_extension->IGNOREFILE, Qt::CaseSensitive, QRegExp::Wildcard));

            // Read the ignore file, see http://doc.qt.io/qt-5/qregexp.html#wildcard-matching
            QFile file(QDir(canonicalPath).filePath(_extension->IGNOREFILE));
            if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
                QTextStream in(&file);
                while (!in.atEnd())
                    ignores.push_back(QRegExp(in.readLine().trimmed(), Qt::CaseSensitive, QRegExp::Wildcard));
                file.close();
            }

            // Index all children in the dir
            QDirIterator dirIterator(canonicalPath, filters, flags);
            while (dirIterator.hasNext()) {
                dirIterator.next();

                // Skip if this file matches one of the ignore patterns
                for (QRegExp& ignore : ignores){
                    QString s = dirIterator.fileName(); // This is insane works only if its a lvalue
                    if(ignore.exactMatch(s))
                        goto SKIP_THIS;
                }

                // Index this file
                indexRecursion(dirIterator.fileInfo());
                SKIP_THIS:;
            }

            // Remember that this dir has been indexed to avoid loops
            indexedDirs.insert(canonicalPath);
        }
    };


    // Start the indexing
    for (const QString& rootDir : _extension->_rootDirs) {
        indexRecursion(QFileInfo(rootDir));
        if (_abort) return;
    }


    // Sort the new index for linear usage copy [O(n*log(n))]
    emit statusInfo("Sorting ... ");
    std::sort(newIndex.begin(), newIndex.end(), [](const shared_ptr<File> &lhs, const shared_ptr<File> &rhs) {
                  return QString::compare(lhs->path(), rhs->path(), Qt::CaseInsensitive) < 0;
              });


    // Copy the usagecounters  [O(n)]
    emit statusInfo("Copy usage statistics ... ");
    size_t i=0, j=0;
    while (i < _extension->_fileIndex.size() && j < newIndex.size()) {
        if (_extension->_fileIndex[i]->path_ == newIndex[j]->path_) {
            newIndex[j]->usage_ = _extension->_fileIndex[i]->usage_;
            ++i;++j;
        } else if (_extension->_fileIndex[i]->path_ < newIndex[j]->path_) {
            ++i;
        } else {// if ((*_fileIndex)[i]->path > (*newIndex)[j]->path) {
            ++j;
        }
    }

    /*
     *  ▼ CRITICAL ▼
     */

    // Lock the access
    _extension->_indexAccess.lock();

    // Set the new index
    _extension->_fileIndex = std::move(newIndex);

    // Reset the offline index
    emit statusInfo("Build offline index... ");
    _extension->_searchIndex.clear();

    // Build the new offline index
    for (shared_ptr<IIndexable> i : _extension->_fileIndex)
        _extension->_searchIndex.add(i);

    // Unlock the accress
    _extension->_indexAccess.unlock();

    /*
     *  ▲ CRITICAL ▲
     */


    // Notification
    msg = QString("Indexed %1 files.").arg(_extension->_fileIndex.size());
    emit statusInfo(msg);
    qDebug() << "[Files]" << msg;
}