Example #1
0
void VNote::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    if(newnote == false){
        if(getNotetype() == ScoreViewModel::whole || getNotetype() == ScoreViewModel::half || getNotetype() == ScoreViewModel::quarter || getNotetype() == ScoreViewModel::eighth){
            QList <QGraphicsItem *> colList = this->scene()->collidingItems(this);

            if(!colList.isEmpty()){

                shadow->setOpacity(0.5);

                //qDebug() << colList;

                if(colList.last()->parentItem() == this->parentItem() && colList.startsWith(shadow)){ // evade collision with shadow
                    //qDebug() << colList.first()->pos();
                    if(colList.size() > 1){
                        shadow->setY((colList.at(1)->pos().y())-10);
                        //qDebug() << colList.at(1)->y()-10;
                    }

                }else if(colList.first()->parentItem() == this->parentItem()){
                    //qDebug() << colList.first()->pos();
                    shadow->setY((colList.first()->pos().y())-10);
                    //qDebug() << colList.first()->y()-10;
                }
            }

        }

        this->scene()->update();
        //this->scene()->update(boundingRect().x()-10,boundingRect().y()-80,boundingRect().right()+10,boundingRect().bottom());
        //this->scene()->update();
    }

    QGraphicsItem::mouseMoveEvent(event);
}
Example #2
0
QList<QToolButton *> ItemLibraryWidget::createToolBarWidgets()
{
    QList<QToolButton *> buttons;

    return buttons; //import management gets disabled for now (TODO ###)

    buttons << new QToolButton();
    buttons.first()->setText(tr("I "));
    buttons.first()->setIcon(QIcon(QLatin1String(Core::Constants::ICON_FILTER)));
    buttons.first()->setToolTip(tr("Manage imports for components"));
    buttons.first()->setPopupMode(QToolButton::InstantPopup);
    QMenu * menu = new QMenu;
    QAction * basicQtAction = new QAction(menu);
    basicQtAction->setCheckable(true);
    basicQtAction->setText(tr("Basic Qt Quick only"));
    QAction * meegoAction= new QAction(menu);
    meegoAction->setCheckable(true);
    meegoAction->setText(tr("Meego Components"));
    menu->addAction(basicQtAction);
    menu->addAction(meegoAction);
    buttons.first()->setMenu(menu);

    connect(basicQtAction, SIGNAL(toggled(bool)), this, SLOT(onQtBasicOnlyChecked(bool)));
    connect(this, SIGNAL(qtBasicOnlyChecked(bool)), basicQtAction, SLOT(setChecked(bool)));

    connect(meegoAction, SIGNAL(toggled(bool)), this, SLOT(onMeegoChecked(bool)));
    connect(this, SIGNAL(meegoChecked(bool)), meegoAction, SLOT(setChecked(bool)));

    updateImports();

    return buttons;
}
void Ut_NotificationPreviewPresenter::testRemoveNotification()
{
    NotificationPreviewPresenter presenter;
    QSignalSpy changedSpy(&presenter, SIGNAL(notificationChanged()));

    // Create two notifications
    createNotification(1);
    createNotification(2);
    presenter.updateNotification(1);
    presenter.updateNotification(2);

    // Remove the first one
    presenter.removeNotification(1);

    // Check that an empty notification is signaled onwards
    QCOMPARE(changedSpy.count(), 2);
    QCOMPARE(presenter.notification(), (LipstickNotification *)0);

    // Show and remove the second one
    presenter.showNextNotification();
    presenter.removeNotification(2);

    // Check that an empty notification is signaled onwards
    QCOMPARE(changedSpy.count(), 4);
    QCOMPARE(presenter.notification(), (LipstickNotification *)0);

    // Check that the window is not yet hidden
    QCOMPARE(homeWindowVisible[homeWindows.first()], true);

    // Check that the window is hidden when it's time to show the next notification (which doesn't exist)
    presenter.showNextNotification();
    QCOMPARE(homeWindowVisible[homeWindows.first()], false);
}
void
PlaylistModel::insertArtists( const QList< Tomahawk::artist_ptr >& artists, int row )
{
    Q_D( PlaylistModel );
    // FIXME: This currently appends, not inserts!
    Q_UNUSED( row );

    foreach ( const artist_ptr& artist, artists )
    {
        if ( !artist )
            return;

        connect( artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
                                  SLOT( appendQueries( QList<Tomahawk::query_ptr> ) ) );

        appendQueries( artist->playlistInterface( Mixed )->tracks() );
    }

    if ( rowCount( QModelIndex() ) == 0 && artists.count() == 1 )
    {
        setTitle( artists.first()->name() );
        setDescription( tr( "All tracks by %1" ).arg( artists.first()->name() ) );
        d->isTemporary = true;
    }
}
QString QQnxFilePicker::filePickerType() const
{
    bool images = false;
    bool video = false;
    bool music = false;
    QMimeDatabase mimeDb;
    for (int i = 0; i < m_filters.count(); i++) {
        QList<QMimeType> mimeTypes = mimeDb.mimeTypesForFileName(m_filters.at(i));
        if (mimeTypes.isEmpty())
            return QStringLiteral("Other");

        if (mimeTypes.first().name().startsWith(QLatin1String("image")))
            images = true;
        else if (mimeTypes.first().name().startsWith(QLatin1String("audio")))
            music = true;
        else if (mimeTypes.first().name().startsWith(QLatin1String("video")))
            video = true;
        else
            return QStringLiteral("Other");
    }

    if (!video && !music)
        return QStringLiteral("Picture");

    if (!images && !music)
        return QStringLiteral("Video");

    if (!images && !video)
        return QStringLiteral("Music");

    return QStringLiteral("Other");
}
Example #6
0
void Ut_USBModeSelector::testShowDialog()
{
    QFETCH(MeeGo::QmUSBMode::Mode, mode);

    QSignalSpy spy(usbModeSelector, SIGNAL(dialogShown()));
    usbModeSelector->usbMode->setDefaultMode(mode);
    usbModeSelector->applyUSBMode(mode);

    QCOMPARE(qQuickViews.count(), 1);

    // Check window properties
    /*
    QCOMPARE(qQuickViews.first()->testAttribute(Qt::WA_TranslucentBackground), true);
    QCOMPARE(qQuickViews.first()->testAttribute(Qt::WA_X11DoNotAcceptFocus), true);
    QCOMPARE(qQuickViews.first()->testAttribute(Qt::WA_X11NetWmWindowTypeMenu), true);
    QCOMPARE(qQuickViews.first()->windowTitle(), QString("USB Mode"));
    QCOMPARE(qQuickViews.first()->viewport()->autoFillBackground(), false);
    */
    QCOMPARE(qQuickViews.first()->resizeMode(), QQuickView::SizeRootObjectToView);
    QCOMPARE(qQuickViews.first()->rootContext()->contextProperty("initialSize").toSize(), QGuiApplication::primaryScreen()->size());
    QCOMPARE(qQuickViews.first()->rootContext()->contextProperty("usbModeSelector"), QVariant::fromValue(static_cast<QObject *>(usbModeSelector)));

    // Check that the window was shown
    QCOMPARE(qWindowVisible[static_cast<QWindow *>(qQuickViews.first())], true);
    QCOMPARE(spy.count(), 1);
}
Example #7
0
void QmlProfilerTool::populateFileFinder(QString projectDirectory, QString activeSysroot)
{
    // Initialize filefinder with some sensible default
    QStringList sourceFiles;
    QList<Project *> projects = SessionManager::projects();
    if (Project *startupProject = SessionManager::startupProject()) {
        // startup project first
        projects.removeOne(startupProject);
        projects.insert(0, startupProject);
    }
    foreach (Project *project, projects)
        sourceFiles << project->files(Project::SourceFiles);

    if (!projects.isEmpty()) {
        if (projectDirectory.isEmpty())
            projectDirectory = projects.first()->projectDirectory().toString();

        if (activeSysroot.isEmpty()) {
            if (Target *target = projects.first()->activeTarget())
                if (RunConfiguration *rc = target->activeRunConfiguration())
                    activeSysroot = sysroot(rc);
        }
    }

    d->m_projectFinder.setProjectDirectory(projectDirectory);
    d->m_projectFinder.setProjectFiles(sourceFiles);
    d->m_projectFinder.setSysroot(activeSysroot);
}
Example #8
0
void LauncherWindow::set_arg(QString action, QString arg, QString val) {
    qDebug() << "set_arg" << action << " " << arg << " " << val;
    QList<QTreeWidgetItem *> items = tree->findItems(arg, Qt::MatchExactly, 0);

    if(action == "remove") {
        if(items.count() == 0) { //* item not there
            return;
        }
        QTreeWidgetItem *removeItem = items.first();
        tree->invisibleRootItem()->removeChild(removeItem);
        return;
    }

    if(action == "set") {
        if(items.count() == 0) {
            QTreeWidgetItem *newItem = new QTreeWidgetItem(); //* add Item if not exist
            newItem->setText(C_ARG, arg);
            newItem->setTextAlignment(C_ARG, Qt::AlignRight);
            newItem->setText(C_VAL, val);
            tree->addTopLevelItem(newItem);
            return;
        } else {
            QTreeWidgetItem *item =  items.first();  //* update existing
            item->setText(C_VAL, val);
            return;
        }

    }
    qDebug() << "UNHANDLED";

}
void Ut_NotificationPreviewPresenter::testAddNotificationWhenWindowNotOpen()
{
    NotificationPreviewPresenter presenter;
    QSignalSpy changedSpy(&presenter, SIGNAL(notificationChanged()));
    QSignalSpy presentedSpy(&presenter, SIGNAL(notificationPresented(uint)));

    // Check that the window is not automatically created
    QCOMPARE(homeWindows.isEmpty(), true);

    // Check that the window is created when a notification is added
    LipstickNotification *notification = createNotification(1);
    presenter.updateNotification(1);
    QCOMPARE(homeWindows.count(), 1);

    // Check window properties
    QCOMPARE(homeWindowTitle[homeWindows.first()], QString("Notification"));
    QCOMPARE(homeWindowContextProperties[homeWindows.first()].value("initialSize").toSize(), QGuiApplication::primaryScreen()->size());
    QCOMPARE(homeWindowContextProperties[homeWindows.first()].value("notificationPreviewPresenter"), QVariant::fromValue(static_cast<QObject *>(&presenter)));
    QCOMPARE(homeWindowCategories[homeWindows.first()], QString("notification"));

    // Check that the window was shown
    QCOMPARE(homeWindowVisible[homeWindows.first()], true);

    // Check that the expected notification is signaled onwards
    QCOMPARE(changedSpy.count(), 1);
    QCOMPARE(presenter.notification(), notification);
    QCOMPARE(presentedSpy.count(), 1);
    QCOMPARE(presentedSpy.last().at(0).toUInt(), (uint)1);
}
Example #10
0
void QSslKeyPrivate::decodePem(const QByteArray &pem, const QByteArray &passPhrase,
                               bool deepClear)
{
    QMap<QByteArray, QByteArray> headers;
    QByteArray data = derFromPem(pem, &headers);
    if (headers.value("Proc-Type") == "4,ENCRYPTED") {
        QList<QByteArray> dekInfo = headers.value("DEK-Info").split(',');
        if (dekInfo.size() != 2) {
            clear(deepClear);
            return;
        }

        Cipher cipher;
        if (dekInfo.first() == "DES-CBC") {
            cipher = DesCbc;
        } else if (dekInfo.first() == "DES-EDE3-CBC") {
            cipher = DesEde3Cbc;
        } else if (dekInfo.first() == "RC2-CBC") {
            cipher = Rc2Cbc;
        } else {
            clear(deepClear);
            return;
        }

        const QByteArray iv = QByteArray::fromHex(dekInfo.last());
        const QByteArray key = deriveKey(cipher, passPhrase, iv);
        data = decrypt(cipher, data, key, iv);
    }
    decodeDer(data, deepClear);
}
Example #11
0
    ZVariant mid(const QList<ZVariant> &args)
    {
        if (args.count() == 2)
            return args.first().toString().mid(args.at(1).toInt());
        else if (args.count() > 2)
            return args.first().toString().mid(args.at(1).toInt(), args.at(2).toInt());

        return ZVariant();
    }
Example #12
0
    ZVariant clear(const QList<ZVariant> &args)
    {
        QList<ZVariant> list = args.first().toList();

        list.clear();
        args.first().depthCopyAssign(list);

        return ZVariant();
    }
Example #13
0
    ZVariant insert(const QList<ZVariant> &args)
    {
        if (args.count() < 3)
            return ZVariant();

        ZVariant variant = args.first();

        variant.depthCopyAssign(variant.toString().insert(args.at(1).toInt(), args.at(2).toString()));

        return args.first();
    }
Example #14
0
    ZVariant replace(const QList<ZVariant> &args)
    {
        if (args.count() > 2) {
            QList<ZVariant> list = args.first().toList();

            list.replace(args.at(1).toInt(), args.at(2));
            args.first().depthCopyAssign(list);
        }

        return ZVariant();
    }
Example #15
0
void LevelFileList::finalizeDig()
{
    ui->FileList->sortItems(Qt::AscendingOrder);
    QList<QListWidgetItem *> list = ui->FileList->findItems(lastCurrentFile, Qt::MatchFixedString);
    if(!list.isEmpty())
    {
        list.first()->setSelected(true);
        ui->FileList->scrollToItem(list.first());
    }
    setCursor(Qt::ArrowCursor);
}
Example #16
0
    ZVariant append(const QList<ZVariant> &args)
    {
        QString string = args.first().toString();

        for (int i = 1; i < args.count(); ++i)
            string.append(args.at(i).toString());

        args.first().depthCopyAssign(string);

        return args.first();
    }
Example #17
0
    ZVariant removeOne(const QList<ZVariant> &args)
    {
        if (args.count() > 1) {
            QList<ZVariant> list = args.first().toList();

            list.removeOne(args.at(1));
            args.first().depthCopyAssign(list);
        }

        return args.first();
    }
Example #18
0
    ZVariant append(const QList<ZVariant> &args)
    {
        QList<ZVariant> list = args.first().toList();

        for (int i = 1; i < args.count(); ++i)
            list.append(args.at(i));

        args.first().depthCopyAssign(list);

        return ZVariant();
    }
IMPLEMENT_TEST(AnnotationGroupUnitTest, groupHierarchy) {
    const U2DbiRef dbiRef(getDbiRef());
    SharedAnnotationData anData = createTestAnnotationData();
    const QString groupName1 = "subgroup1";
    const QString groupName2 = "subgroup1/subgroup11";
    const QString groupName3 = "subgroup2/subgroup21";

    AnnotationTableObject ft("aname_table", dbiRef);
    ft.addAnnotations(QList<SharedAnnotationData>() << anData, groupName1);
    ft.addAnnotations(QList<SharedAnnotationData>() << anData, groupName2);
    ft.addAnnotations(QList<SharedAnnotationData>() << anData, groupName3);

    AnnotationGroup *rootGroup = ft.getRootGroup();
    CHECK_FALSE(rootGroup->isTopLevelGroup(), "Unexpected top level group");
    CHECK_EQUAL(1, rootGroup->getGroupDepth(), "Root group's depth");
    CHECK_EQUAL(QString(), rootGroup->getGroupPath(), "Root group's path");

    const QList<AnnotationGroup *> subgroups = rootGroup->getSubgroups();
    CHECK_EQUAL(2, subgroups.size(), "Count of subgroups");

    QBitArray groupMatches(2, false);
    foreach (AnnotationGroup *subgroup, subgroups) {
        CHECK_TRUE(subgroup->isTopLevelGroup(), "Unexpected top level group");
        CHECK_TRUE(rootGroup->isParentOf(subgroup), "Unexpected parent group");
        CHECK_EQUAL(2, subgroup->getGroupDepth(), "Subgroup's depth");

        U2OpStatusImpl os;
        const U2Feature f = U2FeatureUtils::getFeatureById(subgroup->id, dbiRef, os);
        CHECK_NO_ERROR(os);
        AnnotationGroup *secondLevelSubgroup = subgroup;
        if ("subgroup1" == f.name) {
            groupMatches.setBit(0, true);
            CHECK_EQUAL("subgroup1", subgroup->getGroupPath(), "Subgroup's path");

            const QList<AnnotationGroup *> secondLevelSubgroups = subgroup->getSubgroups();
            CHECK_EQUAL(1, secondLevelSubgroups.size(), "Count of 2nd level subgroups");

            secondLevelSubgroup = secondLevelSubgroups.first();
            CHECK_EQUAL("subgroup1/subgroup11", secondLevelSubgroup->getGroupPath(), "Subgroup's path");
        } else if ("subgroup2" == f.name) {
            groupMatches.setBit(1, true);
            CHECK_EQUAL("subgroup2", subgroup->getGroupPath(), "Subgroup's path");

            const QList<AnnotationGroup *> secondLevelSubgroups = subgroup->getSubgroups();
            CHECK_EQUAL(1, secondLevelSubgroups.size(), "Count of 2nd level subgroups");

            secondLevelSubgroup = secondLevelSubgroups.first();
            CHECK_EQUAL("subgroup2/subgroup21", secondLevelSubgroup->getGroupPath(), "Subgroup's path");
        }
        CHECK_FALSE(secondLevelSubgroup->isTopLevelGroup(), "Unexpected top level group");
        CHECK_TRUE(subgroup->isParentOf(secondLevelSubgroup), "Unexpected parent group");
        CHECK_EQUAL(3, secondLevelSubgroup->getGroupDepth(), "Subgroup's depth");
    }
Example #20
0
void Dialog::dropEvent(QDropEvent* event)
{
    QList<QUrl> lqUrl;
    if(event->mimeData()->hasUrls())
        lqUrl = event->mimeData()->urls();

    if(lqUrl.size() > 0)
    {
        this->setWindowTitle(lqUrl.first().toLocalFile());
        openWithFile(lqUrl.first().toLocalFile());
    }
}
const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tree ) {
    QList<CSwordModuleInfo*> modules = collectModules(&tree);
    qDebug("CDisplayRendering::finishText");

    //marking words is very slow, we have to find a better solution

    /*
     //mark all words by spans

     QString text = oldText;

     QRegExp re("(\\b)(?=\\w)"); //word begin marker
     int pos = text.find(re, 0);

     while (pos != -1) { //word begin found
      //qWarning("found word at %i in %i", pos, text.length());
      int endPos = pos + 1;
      if (!CToolClass::inHTMLTag(pos+1, text)) { //the re has a positive look ahead which matches one char before the word start
       //qWarning("matched %s", text.mid(pos+1, 4).latin1());

       //find end of word and put a marker around it
       endPos = text.find(QRegExp("\\b|[,.:]"), pos+1);
       if ((endPos != -1) && !CToolClass::inHTMLTag(endPos, text) && (endPos - pos >= 3)) { //reuire wordslonger than 3 chars
        text.insert(endPos, "</span>");
        text.insert(pos, "<span class=\"word\">");

        endPos += 26;
       }
      }
      pos = text.find(re, endPos);
     }
    */
    const CLanguageMgr::Language* const lang =
        (modules.count() >= 1)
        ? modules.first()->language()
        : CPointers::languageMgr()->defaultLanguage();

    CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager();

    //Q_ASSERT(modules.count() >= 1);

    CDisplayTemplateMgr::Settings settings;
    settings.modules = modules;
    settings.langAbbrev = ((modules.count() == 1) && lang->isValid()) ? lang->abbrev() : QString::null;

    if (modules.count() == 1)
        settings.pageDirection = (modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr"  : "rtl";
    else
        settings.pageDirection = QString::null;

    return tMgr->fillTemplate(CBTConfig::get(CBTConfig::displayStyle), oldText, settings);
}
void MarkerExplorer::onSelectionChangedFromPlotWidget( QList<QwtPlotItem*>& selectedItems, QList<QwtPlotItem*>& deselectedItems )
{
	int itemType;
	if( selectedItems.count() != 0 )
		itemType = selectedItems.first()->rtti();
	else if( deselectedItems.count() != 0 )
		itemType = deselectedItems.first()->rtti();
	else
		return;

	if( itemType == Globals::Rtti_PlotMarker )
		ExplorerBase::onSelectionChangedFromPlotWidget( selectedItems, deselectedItems );
}
Example #23
0
void LevelFileList::addItem(QString item)
{
    ui->FileList->addItem(item);
    if(lastCurrentFile == item)
    {
        QList<QListWidgetItem *> list = ui->FileList->findItems(item, Qt::MatchFixedString);
        if(!list.isEmpty())
        {
            list.first()->setSelected(true);
            ui->FileList->scrollToItem(list.first());
        }
    }
}
Example #24
0
    ZVariant replace(const QList<ZVariant> &args)
    {
        QString string = args.first().toString();

        if (args.count() == 3)
            string.replace(args.at(1).toString(), args.at(2).toString());
        else if (args.count() > 3)
            string.replace(args.at(1).toInt(), args.at(2).toInt(), args.at(3).toString());

        args.first().depthCopyAssign(string);

        return args.first();
    }
Example #25
0
    ZVariant prepend(const QList<ZVariant> &args)
    {
        if (args.count() < 2)
            return ZVariant();

        QString string = args.first().toString();

        string.prepend(args.at(1).toString());

        args.first().depthCopyAssign(string);

        return args.first();
    }
Example #26
0
//! [11]
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (line != 0 && myMode == InsertLine) {
        QList<QGraphicsItem *> startItems = items(line->line().p1());
        if (startItems.count() && startItems.first() == line)
            startItems.removeFirst();
        QList<QGraphicsItem *> endItems = items(line->line().p2());
        if (endItems.count() && endItems.first() == line)
            endItems.removeFirst();

        removeItem(line);
        delete line;
//! [11] //! [12]

        if (startItems.count() > 0 && endItems.count() > 0 &&
            startItems.first()->type() == DiagramItem::Type &&
            endItems.first()->type() == DiagramItem::Type &&
            startItems.first() != endItems.first()) {
            DiagramItem *startItem =
                qgraphicsitem_cast<DiagramItem *>(startItems.first());
            DiagramItem *endItem =
                qgraphicsitem_cast<DiagramItem *>(endItems.first());
            Arrow *arrow = new Arrow(startItem, endItem);
            arrow->setColor(myLineColor);
            startItem->addArrow(arrow);
            endItem->addArrow(arrow);
            arrow->setZValue(-1000.0);
            addItem(arrow);
            arrow->updatePosition();
        }
    }
//! [12] //! [13]
    line = 0;
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
void QamUdpSocket::lookupHost(const QHostInfo& hostInfo )
{
	if ( hostInfo.error() != QHostInfo::NoError ) {
		emit sockInfo( QString("host not found!") ) ;
		return ;
	}

	QList<QHostAddress> addresses = hostInfo.addresses() ;

	if ( addresses.first().toString() == "::1" )				// loopback IPv6
			setAddress(addresses.at(1) ) ;						// 127.0.0.1
	else	setAddress(addresses.first() ) ;

	m_hostResolved = true ;
}
Example #28
0
/*!
    Returns the first charset from the preferred list that is capable of encoding
    the content of \a text.

    \since 1.0
    \sa preferredCharsets(), setBody()
*/
QByteArray QMessage::preferredCharsetFor(const QString &text)
{
    QList<QTextCodec*> codecs;
    foreach (const QByteArray &name, charsets) {
        if (QTextCodec* codec = QTextCodec::codecForName(name)) {
            codecs.append(codec);
        } else {
            qWarning() << "No codec is available for:" << name;
        }
    }

    if (!codecs.isEmpty()) {
        // See if any of these codecs can encode the data
        QString::const_iterator sit = text.begin(), end = text.end();
        for ( ; sit != end; ++sit) {
            QList<QTextCodec*>::iterator cit = codecs.begin();
            if (!(*cit)->canEncode(*sit)) {
                // This codec is not acceptable
                cit = codecs.erase(cit);
                if (codecs.isEmpty()) {
                    break;
                }
            } else {
                ++cit;
            }
        }

        if (!codecs.isEmpty()) {
            // Return the first remaining codec
            return codecs.first()->name();
        }
    }

    return QByteArray();
}
void TrackerFiltersList::handleFavicoDownload(const QString &url, const QString &filePath)
{
    const QString host = getHost(url);

    if (!m_trackers.contains(host)) {
        Utils::Fs::forceRemove(filePath);
        return;
    }

    QListWidgetItem *trackerItem = item(rowFromTracker(host));
    if (!trackerItem) return;

    QIcon icon(filePath);
    //Detect a non-decodable icon
    QList<QSize> sizes = icon.availableSizes();
    bool invalid = (sizes.isEmpty() || icon.pixmap(sizes.first()).isNull());
    if (invalid) {
        if (url.endsWith(".ico", Qt::CaseInsensitive))
            downloadFavicon(url.left(url.size() - 4) + ".png");
        Utils::Fs::forceRemove(filePath);
    }
    else {
        trackerItem->setData(Qt::DecorationRole, QVariant(QIcon(filePath)));
        m_iconPaths.append(filePath);
    }
}
QCharsetMatch QCharsetDetector::detect()
{
    // Just call QCharsetDetector::detectAll() and take the first
    // match here instead of using ucsdet_detect() to get only a
    // single match. The list returned by ucsdet_detectAll() maybe
    // tweaked a bit in QCharsetDetector::detectAll() to improve
    // the quality of the detection. Therefore, the first element
    // of the list returned by QCharsetDetector::detectAll() may
    // differ from the single match returned by ucsdet_detect().
    Q_D(QCharsetDetector);
    QList<QCharsetMatch> qCharsetMatchList = detectAll();
    if(hasError()) {
        qWarning() << __PRETTY_FUNCTION__ << errorString();
        return QCharsetMatch();
    }
    if (qCharsetMatchList.isEmpty()) {
        // should never happen, because detectAll() already sets an
        // error if no matches are found which the previous
        // if(hasError()) should detect.
        d->_status = U_CE_NOT_FOUND_ERROR;
        qWarning() << __PRETTY_FUNCTION__
                   << "no matches found at all" << errorString();
        return QCharsetMatch();
    }
    return qCharsetMatchList.first();
}