Esempio n. 1
0
bool XSettingsModel::save_profile()
{
    // get lastused profile name
    QString previous = getLastUsed(); // or default if none

#ifdef USE_ALTERNATE_GETFILE
    QString filename = util_getFileName(0, "Save Profiles", previous, QStringList("*.ini"));
#else // !#ifdef USE_ALTERNATE_GETFILE
    QString filename = QFileDialog::getSaveFileName(0, "Save Profiles", previous, "Profile files (*.ini)" );
#endif // #ifdef USE_ALTERNATE_GETFILE y/n

    if (filename.length() == 0) {
        outLog("*** Profile write abandoneed");
        return false;
    }

    QSettings settings(filename,QSettings::IniFormat);
	
	// selected profile filename will be stored in settings
	set_option("profile", true, filename);

    setLastUsed(filename);

	//= loop rows and save each "option" as an [ini section] with enabled, value as values
	for(int row_idx=0; row_idx < rowCount(); row_idx++){
		settings.beginGroup(item(row_idx, C_OPTION)->text());
		settings.setValue( "enabled", item(row_idx, C_ENABLED)->text());
		settings.setValue( "value", item(row_idx, C_VALUE)->text());
		settings.endGroup();
	}
	
	outLog("*** Profile written to disk: "+filename);
    return true;
}
Esempio n. 2
0
 void beginSession(const std::string& rVersion,
                   const std::string& rVersionHome)
 {
    setLastUsed();
    setRunning(true);
    setRVersion(rVersion, rVersionHome);
 }
void
DcpAppletMetadata::incrementUsage()
{ 
    if (widgetTypeID() == DcpWidgetType::Button)
        return;
    MostUsedCounter::instance()->incrementUsageCount (
            QFileInfo(fileName()).baseName()
    );
    setLastUsed (this);
}
Esempio n. 4
0
bool XSettingsModel::load_profile()
{
	_loading = true;
    // get lastused profile name
    QString previous = getLastUsed();   // or default if none

#ifdef USE_ALTERNATE_GETFILE
    QString filename = util_getFileName(0,  "Load Profiles",  previous, QStringList("*.ini") );
#else // !#ifdef USE_ALTERNATE_GETFILE
    QString filename = QFileDialog::getOpenFileName(0,  "Load Profiles",  previous, "Profile files (*.ini)" );
#endif // #ifdef USE_ALTERNATE_GETFILE y/n

    QFile file;
    if ((filename.length() == 0) || (!file.exists(filename))) {
        outLog("*** Profile load abandonned!");
        _loading = false;
        return false;   // NO LOAD POSSIBLE
    }

	QSettings settings(filename,QSettings::IniFormat);
	
	bool ena;
	for(int row_idx=0; row_idx < rowCount(); row_idx++){
		//= loop rows and load each "option" as an [ini section] with enabled, value as values
		settings.beginGroup(item(row_idx, C_OPTION)->text());
		ena = settings.value("enabled").toBool() ;
		item(row_idx, C_ENABLED)->setText( ena ? "1" : "0");
		QString val = settings.value("value").toString();
		if(val == ""){
			val = item(row_idx, C_DEFAULT)->text();
		}
		item(row_idx, C_VALUE)->setText(val );
		set_row_bg(row_idx, ena ? QColor(200,255,200) : QColor(240,240,240));
		//= Broadcast changes
		emit upx(item(row_idx, C_OPTION)->text(),
				 item(row_idx, C_ENABLED)->text() == "1",
				 item(row_idx, C_VALUE)->text()
				 );
		settings.endGroup();
	}
	emit updated(get_fgfs_list());
	outLog("*** Profile loaded: "+filename);

    setLastUsed(filename);  // store lastused profile name
    return true;

}
Media::TextRecording* Media::TextRecording::fromJson(const QList<QJsonObject>& items, const ContactMethod* cm, CollectionInterface* backend)
{
    TextRecording* t = new TextRecording();
    if (backend)
        t->setCollection(backend);

    ConfigurationManagerInterface& configurationManager = ConfigurationManager::instance();

    //Load the history data
    for (const QJsonObject& obj : items) {
        Serializable::Peers* p = SerializableEntityManager::fromJson(obj,cm);
        t->d_ptr->m_lAssociatedPeers << p;
    }

    //Create the model
    bool statusChanged = false; // if a msg status changed during parsing, we need to re-save the model
    t->instantMessagingModel();

    //Reconstruct the conversation
    //TODO do it right, right now it flatten the graph
    for (const Serializable::Peers* p : t->d_ptr->m_lAssociatedPeers) {
        //Seems old version didn't store that
        if (p->peers.isEmpty())
            continue;
        // TODO: for now assume the convo is with only 1 CM at a time
        auto peerCM = p->peers.at(0)->m_pContactMethod;

        // get the latest timestamp to set last used
        time_t lastUsed = 0;
        for (const Serializable::Group* g : p->groups) {
            for (Serializable::Message* m : g->messages) {
                ::TextMessageNode* n  = new ::TextMessageNode();
                n->m_pMessage         = m                      ;
                if (!n->m_pMessage->contactMethod) {
                    if (cm) {
                        n->m_pMessage->contactMethod = const_cast<ContactMethod*>(cm); //TODO remove in 2016
                        n->m_pMessage->authorSha1 = cm->sha1();

                        if (p->peers.isEmpty())
                            addPeer(const_cast<Serializable::Peers*>(p), cm);
                    } else {
                        if (p->m_hSha1.contains(n->m_pMessage->authorSha1)) {
                            n->m_pMessage->contactMethod = p->m_hSha1[n->m_pMessage->authorSha1];
                        } else {
                            // message was outgoing and author sha1 was set to that of the sending account
                            n->m_pMessage->contactMethod = peerCM;
                            n->m_pMessage->authorSha1 = peerCM->sha1();
                        }
                    }
                }
                n->m_pContactMethod   = m->contactMethod;
                t->d_ptr->m_pImModel->addRowBegin();
                t->d_ptr->m_lNodes << n;
                t->d_ptr->m_pImModel->addRowEnd();

                if (lastUsed < n->m_pMessage->timestamp)
                    lastUsed = n->m_pMessage->timestamp;
                if (m->id) {
                    int status = configurationManager.getMessageStatus(m->id);
                    t->d_ptr->m_hPendingMessages[m->id] = n;
                    if (t->d_ptr->updateMessageStatus(m, static_cast<TextRecording::Status>(status)))
                        statusChanged = true;
                }
            }
        }

        if (statusChanged)
            t->save();

        // update the timestamp of the CM
        peerCM->setLastUsed(lastUsed);
    }

    return t;
}
Esempio n. 6
0
 void endSession()
 {
    setLastUsed();
    setRunning(false);
    setExecuting(false);
 }