예제 #1
0
void LocationDialog::updateLocationsTable()
{
    locationsTable->setUpdatesEnabled(false);
    locationsTable->setRowCount(0);

    for (int i = 0; i < 2; ++i) {
        if (i == 0 && scope() == QSettings::SystemScope)
            continue;

        QSettings::Scope actualScope = (i == 0) ? QSettings::UserScope
                                                : QSettings::SystemScope;
        for (int j = 0; j < 2; ++j) {
            if (j == 0 && application().isEmpty())
                continue;

            QString actualApplication;
            if (j == 0)
                actualApplication = application();
            QSettings settings(format(), actualScope, organization(),
                               actualApplication);

            int row = locationsTable->rowCount();
            locationsTable->setRowCount(row + 1);

            QTableWidgetItem *item0 = new QTableWidgetItem;
            item0->setText(settings.fileName());

            QTableWidgetItem *item1 = new QTableWidgetItem;
            bool disable = (settings.childKeys().isEmpty()
                            && settings.childGroups().isEmpty());

            if (row == 0) {
                if (settings.isWritable()) {
                    item1->setText(tr("Read-write"));
                    disable = false;
                } else {
                    item1->setText(tr("Read-only"));
                }
                buttonBox->button(QDialogButtonBox::Ok)->setDisabled(disable);
            } else {
                item1->setText(tr("Read-only fallback"));
            }

            if (disable) {
                item0->setFlags(item0->flags() & ~Qt::ItemIsEnabled);
                item1->setFlags(item1->flags() & ~Qt::ItemIsEnabled);
            }

            locationsTable->setItem(row, 0, item0);
            locationsTable->setItem(row, 1, item1);
        }
    }
    locationsTable->setUpdatesEnabled(true);
}
TEST (kdbrestModelsEntryTest, ConstructorByParts)
{
	std::string organization ("the-organization");
	std::string application ("some-application");
	std::string scope ("app-scope-here");
	std::string slug ("and-finally-a-unique-slug");

	kdbrest::model::Entry entry (organization, application, scope, slug);

	ASSERT_EQ (entry.getName (), kdbrest::Config::instance ().getConfig ().get<std::string> ("kdb.path.configs") + std::string ("/") +
					     organization + std::string ("/") + application + std::string ("/") + scope +
					     std::string ("/") + slug);
	ASSERT_NE (entry.getName (), organization + std::string ("/") + application + std::string ("/") + scope + std::string ("/") + slug);
	ASSERT_EQ (entry.getPublicName (),
		   organization + std::string ("/") + application + std::string ("/") + scope + std::string ("/") + slug);
}
예제 #3
0
void FuzzyTester::storeSettings() const
{
    QSettings s(organization(), app());
    s.setValue(unbuildableCommitsKey(), m_unbuildableCommits);
    s.setValue(buildableCommitsKey(), m_buildableCommits);
}
예제 #4
0
void FuzzyTester::loadSettings()
{
    QSettings s(organization(), app());
    m_unbuildableCommits = s.value(unbuildableCommitsKey()).toStringList();
    m_buildableCommits = s.value(buildableCommitsKey()).toStringList();
}
예제 #5
0
void NewsArticle::assemble()
{
    Headers::Base *h;
    QCString newHead = "";

    //Message-ID
    if((h = messageID(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Control
    if((h = control(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Supersedes
    if((h = supersedes(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //From
    h = from(); // "From" is mandatory
    newHead += h->as7BitString() + "\n";

    //Subject
    h = subject(); // "Subject" is mandatory
    newHead += h->as7BitString() + "\n";

    //To
    if((h = to(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Newsgroups
    if((h = newsgroups(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Followup-To
    if((h = followUpTo(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Reply-To
    if((h = replyTo(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Mail-Copies-To
    if((h = mailCopiesTo(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Date
    h = date(); // "Date" is mandatory
    newHead += h->as7BitString() + "\n";

    //References
    if((h = references(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Lines
    h = lines(); // "Lines" is mandatory
    newHead += h->as7BitString() + "\n";

    //Organization
    if((h = organization(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //User-Agent
    if((h = userAgent(false)) != 0)
        newHead += h->as7BitString() + "\n";

    //Mime-Version
    newHead += "MIME-Version: 1.0\n";

    //Content-Type
    newHead += contentType()->as7BitString() + "\n";

    //Content-Transfer-Encoding
    newHead += contentTransferEncoding()->as7BitString() + "\n";

    //X-Headers
    int pos = h_ead.find("\nX-");
    if(pos > -1) //we already have some x-headers => "recycle" them
        newHead += h_ead.mid(pos + 1, h_ead.length() - pos);
    else if(h_eaders && !h_eaders->isEmpty())
    {
        for(h = h_eaders->first(); h; h = h_eaders->next())
        {
            if(h->isXHeader() && (strncasecmp(h->type(), "X-KNode", 7) != 0))
                newHead += h->as7BitString() + "\n";
        }
    }

    h_ead = newHead;
}
예제 #6
0
	QList<QPair<QString, QVariant>> EntryBase::GetVCardRepresentation () const
	{
		Account_->GetClientConnection ()->FetchVCard (GetJID ());

		const auto vcard = GetVCard ();

		QList<QPair<QString, QVariant>> result
		{
			{ tr ("Photo"), QImage::fromData (vcard.photo ()) },
			{ "JID", vcard.from () },
			{ tr ("Real name"), vcard.fullName () },
			{ tr ("Birthday"), vcard.birthday () },
			{ "URL", vcard.url () },
			{ tr ("About"), vcard.description () }
		};

		for (const auto& phone : vcard.phones ())
		{
			if (phone.number ().isEmpty ())
				continue;

			QStringList attrs;
			if (phone.type () & QXmppVCardPhone::Preferred)
				attrs << tr ("preferred");
			if (phone.type () & QXmppVCardPhone::Home)
				attrs << tr ("home");
			if (phone.type () & QXmppVCardPhone::Work)
				attrs << tr ("work");
			if (phone.type () & QXmppVCardPhone::Cell)
				attrs << tr ("cell");

			result.append ({ tr ("Phone"), attrs.isEmpty () ?
						phone.number () :
						phone.number () + " (" + attrs.join (", ") + ")" });
		}

		for (const auto& email : vcard.emails ())
		{
			if (email.address ().isEmpty ())
				continue;

			QStringList attrs;
			if (email.type () == QXmppVCardEmail::Preferred)
				attrs << tr ("preferred");
			if (email.type () == QXmppVCardEmail::Home)
				attrs << tr ("home");
			if (email.type () == QXmppVCardEmail::Work)
				attrs << tr ("work");
			if (email.type () == QXmppVCardEmail::X400)
				attrs << "X400";

			result.append ({ "Email", attrs.isEmpty () ?
						email.address () :
						email.address () + " (" + attrs.join (", ") + ")" });
		}

		for (const auto& address : vcard.addresses ())
		{
			if ((address.country () + address.locality () + address.postcode () +
					address.region () + address.street ()).isEmpty ())
				continue;

			QStringList attrs;
			if (address.type () & QXmppVCardAddress::Home)
				attrs << tr ("home");
			if (address.type () & QXmppVCardAddress::Work)
				attrs << tr ("work");
			if (address.type () & QXmppVCardAddress::Postal)
				attrs << tr ("postal");
			if (address.type () & QXmppVCardAddress::Preferred)
				attrs << tr ("preferred");

			QString str;
			QStringList fields;
			auto addField = [&fields] (const QString& label, const QString& val)
			{
				if (!val.isEmpty ())
					fields << label.arg (val);
			};
			addField (tr ("Country: %1"), address.country ());
			addField (tr ("Region: %1"), address.region ());
			addField (tr ("Locality: %1", "User's locality"), address.locality ());
			addField (tr ("Street: %1"), address.street ());
			addField (tr ("Postal code: %1"), address.postcode ());

			result.append ({ tr ("Address"), fields });
		}

#if QXMPP_VERSION >= 0x000800
		const auto& orgInfo = vcard.organization ();
		result.append ({ tr ("Organization"), orgInfo.organization () });
		result.append ({ tr ("Organization unit"), orgInfo.unit () });
		result.append ({ tr ("Job title"), orgInfo.title () });
		result.append ({ tr ("Job role"), orgInfo.role () });
#endif
		return result;
	}