Example #1
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();
}
Example #2
0
void PropertiesDock::pasteProperties()
{
    auto clipboardManager = ClipboardManager::instance();

    Properties pastedProperties = clipboardManager->properties();
    if (pastedProperties.isEmpty())
        return;

    const QList<Object *> objects = mDocument->currentObjects();
    if (objects.isEmpty())
        return;

    QList<QUndoCommand*> commands;

    for (Object *object : objects) {
        Properties properties = object->properties();
        properties.merge(pastedProperties);

        if (object->properties() != properties) {
            commands.append(new ChangeProperties(mDocument, QString(), object,
                                                 properties));
        }
    }

    if (!commands.isEmpty()) {
        QUndoStack *undoStack = mDocument->undoStack();
        undoStack->beginMacro(tr("Paste Property/Properties", nullptr,
                                 pastedProperties.size()));

        for (QUndoCommand *command : commands)
            undoStack->push(command);

        undoStack->endMacro();
    }
}
Example #3
0
void	DebugRenderer::renderUpdate()
{
  QList<ToyundaText> subText = toySubStream->getCurrentTextSubtitle();
  QList<ToyundaSyl> subSyl = toySubStream->getCurrentSylSubtitle();

  QTextStream cout(stdout);
  QTextStream cerr(stderr);
  if (subText.isEmpty()) {
    cout << "no current text to display\n";
  } else {
    cout << "----" << toySubStream->getCurrentFrame() << "----\n";
    QListIterator<ToyundaText> itText(subText);
    while (itText.hasNext())
    {
        cout << "--";
        cout << (ToyundaText) itText.next();
    }
  }
  cout << "== Syl ==" << "\n";
  if (subSyl.isEmpty()) {
    cout << "no current Syl to display\n";
  } else {
    QListIterator<ToyundaSyl> itSyl(subSyl);
    while (itSyl.hasNext())
    {
                cout << "--";
      cout << (ToyundaSyl) itSyl.next();
    }
  }
}
Example #4
0
int tacticControl::findBestPlayerForPass()
{
int index = -1;
double min = 10000;
QList<int> ourAgents = wm->kn->ActiveAgents();
QList<int> freeAgents;
while( !ourAgents.isEmpty() )
{
int index = ourAgents.takeFirst();
if(isFree(index))
freeAgents.append(index);
}
while ( !freeAgents.isEmpty() )
{
int i = freeAgents.takeFirst();
if(wm->ourRobot[i].isValid && this->id != i)
{
if( (wm->ball.pos.loc-wm->ourRobot[i].pos.loc).length() < min)
{
min = (wm->ball.pos.loc-wm->ourRobot[i].pos.loc).length();
index = i;
}
}
}
return index;
}
Example #5
0
void MainWindow::trainingDataChanged()
{
    QList<QImage> maleTrainingImages = ui->lblMaleTraining->getImages();
    QVector<int> maleLabels;
    maleLabels.fill(MALEINDEX,maleTrainingImages.count());

    QList<QImage> femaleTrainingImages = ui->lblFemaleTraining->getImages();
    QVector<int> femaleLabels;
    femaleLabels.fill(FEMALEINDEX,femaleTrainingImages.count());

    if (maleTrainingImages.isEmpty()) {
        ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Need male images..."));
    }
    if (femaleTrainingImages.isEmpty()) {
        ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Need female images..."));
    }
    if (maleTrainingImages.isEmpty()||femaleTrainingImages.isEmpty())
        return;
    //
    QList<QImage> trainingImages;
    QVector<int> labels;
    trainingImages << maleTrainingImages << femaleTrainingImages;
    labels << maleLabels << femaleLabels;
    //
    ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Training..."));
    recognizer->trainFaces(trainingImages, labels);
    ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Training complete."));
    reevaluateMale();
    reevaluateFemale();
}
/**
 * Adds new subtitle, finishes last if needed.
 * This is a version for DVB graphical subtitles only.
 * @param list Queue of subtitles we modify.
 * @param content Content of the new subtitle (may be empty).
 * We're going to use it's img & start_time fields.
 */
void MythCCExtractorPlayer::IngestSubtitle(
    QList<OneSubtitle> &list, const OneSubtitle &content)
{
    bool update_last =
        !list.isEmpty() &&
        content.start_time == list.back().start_time &&
        !content.img.isNull();

    if (update_last)
    {
        list.back().img = content.img; // update image only
        return;
    }

    OneSubtitle last_one = list.isEmpty() ? OneSubtitle() : list.back();
    if (content.img != last_one.img || last_one.length >= 0)
    {
        // Finish previous subtitle.
        if (!last_one.img.isNull() && last_one.length < 0)
        {
            list.back().length = content.start_time - last_one.start_time;
        }

        // Put new one if it isn't empty.
        if (!content.img.isNull())
        {
            OneSubtitle new_one;
            new_one.start_time = content.start_time;
            new_one.img = content.img;

            list.push_back(new_one);
        }
    }
}
void MythCCExtractorPlayer::IngestSubtitle(
    QList<OneSubtitle> &list, const QStringList &content)
{
    bool update_last =
        !list.isEmpty() &&
        (int64_t)m_curTime == list.back().start_time &&
        !content.isEmpty();

    if (update_last)
    {
        //update text only (need for cc608)
        list.back().text = content;
        return;
    }

    OneSubtitle last_one = list.isEmpty() ? OneSubtitle() : list.back();
    if (content != last_one.text || last_one.length >= 0)
    {
        // Finish previous subtitle.
        if (!last_one.text.isEmpty() && last_one.length < 0)
        {
            list.back().length = (int64_t)m_curTime - last_one.start_time;
        }

        // Put new one if it isn't empty.
        if (!content.isEmpty())
        {
            OneSubtitle new_one;
            new_one.start_time = (int64_t)m_curTime;
            new_one.text = content;

            list.push_back(new_one);
        }
    }
}
Example #8
0
	void Plugin::RefreshItems (const QList<QModelIndex>& indices)
	{
		auto clearRoot = [] (QStandardItem *item)
		{
			if (const auto rc = item->rowCount ())
				item->removeRows (0, rc);
		};

		const auto& items = indices.isEmpty () ?
				Root2Fetcher_.keys () :
				Util::Map (indices,
						[this] (const QModelIndex& index) { return Model_->itemFromIndex (index); });
		for (auto item : items)
		{
			if (!Root2Fetcher_.contains (item))
				continue;

			clearRoot (item);
			Root2Fetcher_ [item] (item);
		}

		auto models = indices.isEmpty () ?
				Model2Fetcher_.keys () :
				Util::Map (indices,
						[this] (const QModelIndex& index) { return index.model (); });
		models.removeAll (Model_);
		for (auto model : models)
			Model2Fetcher_ [model] ();
	}
Example #9
0
void CardContainer::fillCards(const QList<int> &card_ids, const QList<int> &disabled_ids) {
    QList<CardItem *> card_items;
    if (card_ids.isEmpty() && items.isEmpty())
        return;
    else if (card_ids.isEmpty() && !items.isEmpty()) {
        card_items = items;
        items.clear();
    } else if (!items.isEmpty()) {
        retained_stack.push(retained());
        items_stack.push(items);
        foreach (CardItem *item, items)
            item->hide();
        items.clear();
    }

    close_button->hide();
    if (card_items.isEmpty())
        card_items = _createCards(card_ids);

    int card_width = G_COMMON_LAYOUT.m_cardNormalWidth;
    QPointF pos1(30 + card_width / 2, 40 + G_COMMON_LAYOUT.m_cardNormalHeight / 2);
    QPointF pos2(30 + card_width / 2, 184 + G_COMMON_LAYOUT.m_cardNormalHeight / 2);
    int skip = 102;
    qreal whole_width = skip * 4;
    items.append(card_items);
    int n = items.length();

    for (int i = 0; i < n; i++) {
        QPointF pos;
        if (n <= 10) {
            if (i < 5) {
                pos = pos1;
                pos.setX(pos.x() + i * skip);
            } else {
                pos = pos2;
                pos.setX(pos.x() + (i - 5) * skip);
            }
        } else {
            int half = (n + 1) / 2;
            qreal real_skip = whole_width / (half - 1);

            if (i < half) {
                pos = pos1;
                pos.setX(pos.x() + i * real_skip);
            } else {
                pos = pos2;
                pos.setX(pos.x() + (i - half) * real_skip);
            }
        }
        CardItem *item = items[i];
        item->setPos(pos);
        item->setHomePos(pos);
        item->setOpacity(1.0);
        item->setHomeOpacity(1.0);
        item->setFlag(QGraphicsItem::ItemIsFocusable);
        if (disabled_ids.contains(item->getCard()->getEffectiveId())) item->setEnabled(false);
        item->show();
    }
}
Example #10
0
bool QiaobianCard::targetsFeasible(const QList<const Player *> &targets, const Player *Self) const{
    if(Self->getPhase() == Player::Draw)
        return targets.length() <= 2 && !targets.isEmpty();
    else if(Self->getPhase() == Player::Play)
        return targets.length() == 1;
    else
        return targets.isEmpty();
}
Example #11
0
BlurHelper::BlurHelper (QObject* parent, QList<int> menuS, QList<int> tooltipS) : QObject (parent)
{
#if defined Q_WS_X11 || defined Q_OS_LINUX
  atom_blur_ = XInternAtom (QX11Info::display(), "_KDE_NET_WM_BLUR_BEHIND_REGION", False);
#endif

  if (!menuS.isEmpty() && menuS.size() >= 4)
    menuShadow_ = menuS;
  if (!tooltipS.isEmpty() && tooltipS.size() >= 4)
    tooltipShadow_ = tooltipS;
}
void ClipboardHandler::copy()
{
	QList<NodeElement *> nodes = getNodesForCopying();

	QList<NodeData> nodesData = getNodesData(nodes);
	QList<EdgeData> edgesData = getEdgesData();

	if (!nodesData.isEmpty() || !edgesData.isEmpty()) {
		pushDataToClipboard(nodesData, edgesData);
	}
}
void DesignModeWidget::updateErrorStatus(const QList<RewriterError> &errors)
{
    if (debug)
        qDebug() << Q_FUNC_INFO << errors.count();

    if (m_isDisabled && errors.isEmpty()) {
        enableWidgets();
     } else if (!errors.isEmpty()) {
        disableWidgets();
        showErrorMessageBox(errors);
    }
}
Example #14
0
QString DocumentAPI::groupItems(QList< QVariant > list)
{
	QString name;
	if (!check())
		RAISE("No document open");
	if (list.isEmpty() && ScCore->primaryMainWindow()->doc->m_Selection->count() < 2)
	{
		RAISE("Need selection or argument list of items to group");
	}
	Selection *tempSelection=0;
	Selection *finalSelection=0;
	//uint ap = ScCore->primaryMainWindow()->doc->currentPage()->pageNr();
	// If we were passed a list of items to group...
	if (!list.isEmpty())
	{
		int len = list.length();
		tempSelection = new Selection(ScCore->primaryMainWindow(), false);
		for (int i = 0; i < len; i++)
		{
			// FIXME: We might need to explicitly get this string as utf8
			// but as sysdefaultencoding is utf8 it should be a no-op to do
			// so anyway.
			name = list[i].toString();
			PageItem *ic = GetUniqueItem(name);
			if (ic == NULL)
			{
				delete tempSelection;
				return NULL;
			}
			tempSelection->addItem(ic, true);
		}
		finalSelection=tempSelection;
	}
	else
		finalSelection=ScCore->primaryMainWindow()->doc->m_Selection;
	if (finalSelection->count() < 2)
	{
		// We can't very well group only one item
		RAISE("Cannot group less than two items");
		finalSelection=0;
		delete tempSelection;
		return NULL;
	}

	const PageItem* group = ScCore->primaryMainWindow()->doc->itemSelection_GroupObjects(false, false, finalSelection);
	finalSelection=0;
	delete tempSelection;

	return (group ? group->itemName() : NULL);
}
Example #15
0
NZMQT_INLINE QByteArray ZMQSocket::receiveBlockingMessage()
{
    QList<QByteArray> response;
    for(;;) {
        response = receiveMessage();
        if (!response.isEmpty() || QThread::currentThread()->isInterruptionRequested())
            break;
        QThread::msleep(500);
    }
    if (!response.isEmpty())
        return response.first();
    else
        return QByteArray();
}
Example #16
0
void KShortcutsEditorItem::setKeySequence(uint column, const QKeySequence &seq)
{
    QList<QKeySequence> ks;
#if HAVE_GLOBALACCEL
    if (column == GlobalPrimary || column == GlobalAlternate) {
        ks = KGlobalAccel::self()->shortcut(m_action);
        if (!m_oldGlobalShortcut) {
            m_oldGlobalShortcut = new QList<QKeySequence>(ks);
        }
    } else
#endif
    {
        ks = m_action->shortcuts();
        if (!m_oldLocalShortcut) {
            m_oldLocalShortcut = new QList<QKeySequence>(ks);
        }
    }

    if (column == LocalAlternate || column == GlobalAlternate) {
        if (ks.isEmpty()) {
            ks << QKeySequence();
        }

        if (ks.size() <= 1) {
            ks << seq;
        } else {
            ks[1] = seq;
        }
    } else {
        if (ks.isEmpty()) {
            ks << seq;
        } else {
            ks[0] = seq;
        }
    }

    //avoid also setting the default shortcut - what we are setting here is custom by definition
#if HAVE_GLOBALACCEL
    if (column == GlobalPrimary || column == GlobalAlternate) {
        KGlobalAccel::self()->setShortcut(m_action, ks, KGlobalAccel::NoAutoloading);

    } else
#endif
    {
        m_action->setShortcuts(ks);
    }

    updateModified();
}
Example #17
0
bool KNMusicModel::insertMusicRows(int row,
                                   const QList<KNMusicDetailInfo> &detailInfos)
{
    //Check the row first.
    Q_ASSERT(row>-1 && row<=m_detailInfos.size());
    //Ignore the empty list.
    if(detailInfos.isEmpty())
    {
        return true;
    }
    //Follow the documentation, we have to do this.
    beginInsertRows(QModelIndex(), row, row + detailInfos.size() -1);
    //Insert the data to the detail info list.
    for(int i=detailInfos.size()-1; i>-1; --i)
    {
        //Insert the data to the specific position.
        m_detailInfos.insert(row, detailInfos.at(i));
        //Add the duration to the total duration counter.
        m_totalDuration+=detailInfos.at(i).duration;
    }
    //As the documentation said, called this after insert rows.
    endInsertRows();
    //Because this operation change the row count, the row count changed signal
    //will be emitted.
    emit rowCountChanged();
    return true;
}
Example #18
0
void KNMusicModel::appendRows(const QList<KNMusicDetailInfo> &detailInfos)
{
    //Ignore the empty adding request.
    if(detailInfos.isEmpty())
    {
        return;
    }
    //Follow the documentation, we have to do this.
    beginInsertRows(QModelIndex(),
                    m_detailInfos.size(),
                    m_detailInfos.size() + detailInfos.size() - 1);
    //Append the data at the end of the rows.
    m_detailInfos.append(detailInfos);
    //Add all the duration to the total duration counter.
    for(auto i=detailInfos.constBegin(); i!=detailInfos.constEnd(); ++i)
    {
        //Add each duration to the total duration.
        m_totalDuration+=(*i).duration;
    }
    //As the documentation said, called this after insert rows.
    endInsertRows();
    //Because this operation change the row count, the row count changed signal
    //will be emitted.
    emit rowCountChanged();
}
/*!
 * Converts \a document into a corresponding list of QOrganizerItems.  After calling this, the
 * converted organizer items can be retrieved by calling items().
 *
 * Returns true on success.  The document should contain at least one subdocument.  In the
 * importing process, each subdocument roughly corresponds to a QOrganizerItem.  If any of the
 * subdocuments cannot be imported as organizer items (eg. they don't conform to the iCalendar
 * format), false is returned and errorMap() will return a list describing the errors that occurred.
 * The successfully imported items will still be available via items().
 *
 * \sa items(), errorMap()
 */
bool QVersitOrganizerImporter::importDocument(const QVersitDocument& document)
{
    d->mItems.clear();
    d->mErrors.clear();
    bool ok = true;
    if (document.type() != QVersitDocument::ICalendar20Type
        || document.componentType() != QLatin1String("VCALENDAR")) {
        d->mErrors.insert(-1, QVersitOrganizerImporter::InvalidDocumentError);
        return false;
    }
    const QList<QVersitDocument> subDocuments = document.subDocuments();
    if (subDocuments.isEmpty()) {
        d->mErrors.insert(-1, QVersitOrganizerImporter::EmptyDocumentError);
        return false;
    }

    int documentIndex = 0;
    foreach (const QVersitDocument& subDocument, subDocuments) {
        QOrganizerItem item;
        QVersitOrganizerImporter::Error error;
        if (d->importDocument(document, subDocument, &item, &error)) {
            d->mItems.append(item);
        } else {
            // importDocument can return false with no error if it's a non-document component
            if (error != QVersitOrganizerImporter::NoError) {
                d->mErrors.insert(documentIndex, error);
                ok = false;
            }
        }
        documentIndex++;
    }
Example #20
0
void ReplayGain::showResults()
{
    QList<TrackScanner *> okScanners;
    for (int i=0; i<files.count(); ++i) {
        TrackScanner *s=scanners[i];
        const Track &t=tracks[i];
        if (t.success && s->ok()) {
            printf("TRACK: %d %s %s\n", i, formatDouble(TrackScanner::reference(s->results().loudness)).toLatin1().constData(),
                                           formatDouble(s->results().peakValue()).toLatin1().constData());
            okScanners.append(s);
        } else {
            printf("TRACK: %d FAILED\n", i);
        }
    }

    if (okScanners.isEmpty()) {
        printf("ALBUM: FAILED\n");
    } else {
        TrackScanner::Data album=TrackScanner::global(okScanners);
        printf("ALBUM: %s %s\n", formatDouble(TrackScanner::reference(album.loudness)).toLatin1().constData(),
                                 formatDouble(album.peak).toLatin1().constData());
    }
    fflush(stdout);

    QCoreApplication::exit(0);
}
Example #21
0
/**
 * @brief Reload smileys and size information.
 */
void UserInterfaceForm::reloadSmileys()
{
    QList<QStringList> emoticons = SmileyPack::getInstance().getEmoticons();

    // sometimes there are no emoticons available, don't crash in this case
    if (emoticons.isEmpty()) {
        qDebug() << "reloadSmilies: No emoticons found";
        return;
    }

    QStringList smileys;
    for (int i = 0; i < emoticons.size(); ++i)
        smileys.push_front(emoticons.at(i).first());

    const QSize size(18, 18);
    for (int i = 0; i < smileLabels.size(); ++i) {
        QIcon icon = SmileyPack::getInstance().getAsIcon(smileys[i]);
        smileLabels[i]->setPixmap(icon.pixmap(size));
        smileLabels[i]->setToolTip(smileys[i]);
    }

    // set maximum size of emoji
    QDesktopWidget desktop;
    // 8 is the count of row and column in emoji's in widget
    const int sideSize = 8;
    int maxSide = qMin(desktop.geometry().height() / sideSize, desktop.geometry().width() / sideSize);
    QSize maxSize(maxSide, maxSide);

    QIcon icon = SmileyPack::getInstance().getAsIcon(smileys[0]);
    QSize actualSize = icon.actualSize(maxSize);
    bodyUI->emoticonSize->setMaximum(actualSize.width());
}
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);
    }
}
Example #23
0
void SendCoinsDialog::on_sendButton_clicked()
{
    if(!model || !model->getOptionsModel())
        return;

    QList<SendCoinsRecipient> recipients;
    bool valid = true;

    for(int i = 0; i < ui->entries->count(); ++i)
    {
        SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
        if(entry)
        {
            if(entry->validate())
            {
                recipients.append(entry->getValue());
            }
            else
            {
                valid = false;
            }
        }
    }

    if(!valid || recipients.isEmpty())
    {
        return;
    }

    // Format confirmation message
    QStringList formatted;
    foreach(const SendCoinsRecipient &rcp, recipients)
    {
        formatted.append(tr("<b>%1</b> to %2 (%3)").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount), Qt::escape(rcp.label), rcp.address));
    }
QVariant QgsMergeAttributesDialog::calcStatistic( int col, QgsStatisticalSummary::Statistic stat )
{
  QgsStatisticalSummary summary( stat );

  bool conversion = false;
  QList<double> values;
  for ( int i = 0; i < mFeatureList.size(); ++i )
  {
    double currentValue = mTableWidget->item( i + 1, col )->text().toDouble( &conversion );
    if ( conversion )
    {
      values << currentValue;
    }
  }

  if ( values.isEmpty() )
  {
    return QVariant( mVectorLayer->fields().at( col ).type() );
  }

  summary.calculate( values );

  double val = summary.statistic( stat );
  return std::isnan( val ) ? QVariant( QVariant::Double ) : val;
}
void chanFileSystemDockWidget::createFile() {

    QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();

    if (items.isEmpty()) return;

    QTreeWidgetItem* parent = items.front();

    QString fileName = QFileDialog::getSaveFileName(this, tr("edit name"), ".",
                       tr("c/c++ header file(*.h)\n"
                          "c/c++ header file(*.hpp)\n"
                          "c source file(*.c)\n"
                          "c++ source file(*.cpp)"
                         ));

    if (!QFile(fileName).open(QIODevice::WriteOnly)) {
        QMessageBox::warning(this, "error",
                             tr("create the file %1 failed").arg(fileName));

        return;
    }

    createTreeWidgetItem(fileName, parent);

    emit createdFile(fileName);
}
Example #26
0
/* private slots */
qint64 ShredThread::getDirSize(QString &dir)
{
    uint _size = 0;
    QDir::Filters flags =
            QDir::AllEntries |
            QDir::NoDotAndDotDot |
            QDir::Hidden |
            QDir::System |
            QDir::AllDirs;
    QDir d;
    d.setPath(dir);
    QList<QFileInfo> entry = d.entryInfoList(flags);
    if ( !entry.isEmpty() ) {
        QList<QFileInfo>::const_iterator i;
        for ( i=entry.constBegin(); i<entry.constEnd(); i++ ) {
            QFileInfo item = *i;
            if ( !item.exists() ) continue;
            QString path = item.canonicalFilePath();
            if ( path==d.absoluteFilePath(dir)
                 || item.isSymLink() )
                continue;
            if ( item.isDir() ) {
                _size += getDirSize(path);
            } else {
                _size += item.size();
            };
        };
    };
    return _size;
}
Example #27
0
void GeneralForm::reloadSmiles()
{
    QList<QStringList> emoticons = SmileyPack::getInstance().getEmoticons();
    if (emoticons.isEmpty())
    { // sometimes there are no emoticons available, don't crash in this case
        qDebug() << "reloadSmilies: No emoticons found";
        return;
    }

    QStringList smiles;
    for (int i = 0; i < emoticons.size(); i++)
        smiles.push_front(emoticons.at(i).first());

    const QSize size(18,18);
    bodyUI->smile1->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[0]).pixmap(size));
    bodyUI->smile2->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[1]).pixmap(size));
    bodyUI->smile3->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[2]).pixmap(size));
    bodyUI->smile4->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[3]).pixmap(size));
    bodyUI->smile5->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[4]).pixmap(size));

    bodyUI->smile1->setToolTip(smiles[0]);
    bodyUI->smile2->setToolTip(smiles[1]);
    bodyUI->smile3->setToolTip(smiles[2]);
    bodyUI->smile4->setToolTip(smiles[3]);
    bodyUI->smile5->setToolTip(smiles[4]);
}
void SendMessagesDialog::on_sendButton_clicked()
{
    QList<SendMessagesRecipient> recipients;
    bool valid = true;

    if(!model)
        return;

    valid = validate();

    for(int i = 0; i < ui->entries->count(); ++i)
    {
        SendMessagesEntry *entry = qobject_cast<SendMessagesEntry*>(ui->entries->itemAt(i)->widget());
        if(entry)
        {
            if(entry->validate())
                recipients.append(entry->getValue());
            else
                valid = false;
        }
    }

    if(!valid || recipients.isEmpty())
        return;

    // Format confirmation message
    QStringList formatted;
    foreach(const SendMessagesRecipient &rcp, recipients)
    {
        formatted.append(tr("<b>%1</b> to %2 (%3)").arg(rcp.message, Qt::escape(rcp.label), rcp.address));
    }
Example #29
0
void
QResourcePrivate::ensureInitialized() const
{
    if(!related.isEmpty())
        return;
    QResourcePrivate *that = const_cast<QResourcePrivate *>(this);
    if(fileName == QLatin1String(":"))
        that->fileName += QLatin1Char('/');
    that->absoluteFilePath = fileName;
    if(!that->absoluteFilePath.startsWith(QLatin1Char(':')))
        that->absoluteFilePath.prepend(QLatin1Char(':'));

    QString path = fileName;
    if(path.startsWith(QLatin1Char(':')))
        path = path.mid(1);

    if(path.startsWith(QLatin1Char('/'))) {
        that->load(path);
    } else {
        QMutexLocker lock(resourceMutex());
        QStringList searchPaths = *resourceSearchPaths();
        searchPaths << QLatin1String("");
        for(int i = 0; i < searchPaths.size(); ++i) {
            const QString searchPath(searchPaths.at(i) + QLatin1Char('/') + path);
            if(that->load(searchPath)) {
                that->absoluteFilePath = QLatin1Char(':') + searchPath;
                break;
            }
        }
    }
}
Example #30
0
void
QResourcePrivate::ensureChildren() const
{
    ensureInitialized();
    if(!children.isEmpty() || !container || related.isEmpty())
        return;

    QString path = absoluteFilePath, k;
    if(path.startsWith(QLatin1Char(':')))
        path = path.mid(1);
    QSet<QString> kids;
    QString cleaned = cleanPath(path);
    for(int i = 0; i < related.size(); ++i) {
        QResourceRoot *res = related.at(i);
        if(res->mappingRootSubdir(path, &k) && !k.isEmpty()) {
            if(!kids.contains(k)) {
                children += k;
                kids.insert(k);
            }
        } else {
            const int node = res->findNode(cleaned);
            if(node != -1) {
                QStringList related_children = res->children(node);
                for(int kid = 0; kid < related_children.size(); ++kid) {
                    k = related_children.at(kid);
                    if(!kids.contains(k)) {
                        children += k;
                        kids.insert(k);
                    }
                }
            }
        }
    }
}