bool ApplicationList::LoadSettings()
{
    QSettings settings;
    QStringList names = settings.value(SETTINGS_APPLICATION_NAMES, QStringList()).toStringList();
    QStringList paths = settings.value(SETTINGS_APPLICATION_PATHS, QStringList()).toStringList();
    QStringList params = settings.value(SETTINGS_APPLICATION_PARAMS, QStringList()).toStringList();
    int defapp = settings.value(SETTINGS_APPLICATION_DEFAULT, -1).toInt();

    // Params will be empty first time starting with the new setting.
    // Return false and inform user about problem with application settings.
    bool succeeded = true;
    if (!names.empty() && !paths.empty() && params.empty()) {
        for (int i = 0; i < paths.length(); i++)
            params << "";
        succeeded = false;
    }

    if (names.empty() && paths.empty() && params.empty()) {
#ifndef _WIN32
        // use as default for gnome environments
        if (QFileInfo("/usr/bin/gedit").isExecutable()) {
            Application app;
            app.setName("gedit");
            app.setPath("/usr/bin/gedit");
            app.setParameters("+(line) (file)");
            AddApplication(app);
            defapp = 0;
        }
        CheckAndAddApplication("/usr/bin/geany","geany","+(line) (file)");
        CheckAndAddApplication("/usr/bin/qtcreator","Qt Creator","-client (file):(line)");
        // use as default for kde environments
        if (QFileInfo("/usr/bin/kate").isExecutable()) {
            Application app;
            app.setName("kate");
            app.setPath("/usr/bin/kate");
            app.setParameters("-l(line) (file)");
            AddApplication(app);
            defapp = 0;
        }
#else
        if (FindDefaultWindowsEditor()) {
            defapp = 0;
        }
#endif
    } else if (names.size() == paths.size()) {
        for (int i = 0; i < names.size(); i++) {
            const Application app(names[i], paths[i], params[i]);
            AddApplication(app);
        }
    }

    if (defapp == -1)
        mDefaultApplicationIndex = 0;
    else if (defapp < names.size())
        mDefaultApplicationIndex = defapp;
    else
        mDefaultApplicationIndex = 0;

    return succeeded;
}
Beispiel #2
0
bool ApplicationList::FindDefaultWindowsEditor()
{
    const QString appPath(getenv("ProgramFiles"));
    const QString notepadppPath = appPath + "\\Notepad++\\notepad++.exe";
    if (QFileInfo(notepadppPath).isExecutable()) {
        Application app;
        app.setName("Notepad++");
        app.setPath("\"" + notepadppPath + "\"");
        app.setParameters("-n(line) (file)");
        AddApplication(app);
        return true;
    }

    const QString notepadTwoPath = appPath + "\\Notepad2\\Notepad2.exe";
    if (QFileInfo(notepadTwoPath).isExecutable()) {
        Application app;
        app.setName("Notepad2");
        app.setPath("\"" + notepadTwoPath + "\"");
        app.setParameters("/g (line) (file)");
        AddApplication(app);
        return true;
    }

    const QString windowsPath(getenv("windir"));
    const QString notepadPath = windowsPath + "\\system32\\notepad.exe";
    if (QFileInfo(notepadPath).isExecutable()) {
        Application app;
        app.setName("Notepad");
        app.setPath(notepadPath);
        app.setParameters("(file)");
        AddApplication(app);
        return true;
    }
    return false;
}
Beispiel #3
0
StatusType iDroid::UpgradeApplication(int appID) {
	if (appID <= 0)
		return INVALID_INPUT;
	try {
		DataByID appByID(appID);
		Tree<DataByID>::Node* node = _appsByIDtree.find(appByID);
		CMP_DATA(node, appID);
		Version version(node->getData()._versionCode);
		List<Version>::Iterator it = _versions.find(version);

		if (++it == _versions.end()) {
			return FAILURE;
		}
		it = _versions.find(version);

		appByID = node->getData();
		DataByDowns appByDowns(appByID);

		StatusType status = RemoveApplication(appID);
		if (status != SUCCESS)
			return status;
		status = AddApplication(appID, (++it)->_versionID, appByID._downloads);
		if (status != SUCCESS)
			return status;

	} catch (Tree<DataByID>::TreeIsEmpty& e) {
		return FAILURE;
	} catch (Tree<DataByDowns>::TreeIsEmpty& e) {
		return FAILURE;
	}
	return SUCCESS;
}
Beispiel #4
0
SettingsDialog::SettingsDialog(ApplicationList *list,
                               TranslationHandler *translator,
                               QWidget *parent) :
    QDialog(parent),
    mApplications(list),
    mTempApplications(new ApplicationList(this)),
    mTranslator(translator)
{
    mUI.setupUi(this);
    QSettings settings;
    mTempApplications->Copy(list);

    mUI.mJobs->setText(settings.value(SETTINGS_CHECK_THREADS, 1).toString());
    mUI.mForce->setCheckState(BoolToCheckState(settings.value(SETTINGS_CHECK_FORCE, false).toBool()));
    mUI.mShowFullPath->setCheckState(BoolToCheckState(settings.value(SETTINGS_SHOW_FULL_PATH, false).toBool()));
    mUI.mShowNoErrorsMessage->setCheckState(BoolToCheckState(settings.value(SETTINGS_SHOW_NO_ERRORS, false).toBool()));
    mUI.mShowDebugWarnings->setCheckState(BoolToCheckState(settings.value(SETTINGS_SHOW_DEBUG_WARNINGS, false).toBool()));
    mUI.mSaveAllErrors->setCheckState(BoolToCheckState(settings.value(SETTINGS_SAVE_ALL_ERRORS, false).toBool()));
    mUI.mSaveFullPath->setCheckState(BoolToCheckState(settings.value(SETTINGS_SAVE_FULL_PATH, false).toBool()));
    mUI.mInlineSuppressions->setCheckState(BoolToCheckState(settings.value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool()));
    mUI.mEnableInconclusive->setCheckState(BoolToCheckState(settings.value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool()));
    mUI.mShowErrorId->setCheckState(BoolToCheckState(settings.value(SETTINGS_SHOW_ERROR_ID, false).toBool()));

    connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(Ok()));
    connect(mUI.mButtons, SIGNAL(rejected()), this, SLOT(reject()));
    connect(mUI.mBtnAddApplication, SIGNAL(clicked()),
            this, SLOT(AddApplication()));
    connect(mUI.mBtnRemoveApplication, SIGNAL(clicked()),
            this, SLOT(RemoveApplication()));
    connect(mUI.mBtnEditApplication, SIGNAL(clicked()),
            this, SLOT(EditApplication()));
    connect(mUI.mBtnDefaultApplication, SIGNAL(clicked()),
            this, SLOT(DefaultApplication()));
    connect(mUI.mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
            this, SLOT(EditApplication()));
    connect(mUI.mBtnAddIncludePath, SIGNAL(clicked()),
            this, SLOT(AddIncludePath()));
    connect(mUI.mBtnRemoveIncludePath, SIGNAL(clicked()),
            this, SLOT(RemoveIncludePath()));
    connect(mUI.mBtnEditIncludePath, SIGNAL(clicked()),
            this, SLOT(EditIncludePath()));

    mUI.mListWidget->setSortingEnabled(false);
    PopulateApplicationList();

    const int count = QThread::idealThreadCount();
    if (count != -1)
        mUI.mLblIdealThreads->setText(QString::number(count));
    else
        mUI.mLblIdealThreads->setText(tr("N/A"));

    LoadSettings();
    InitTranslationsList();
    InitIncludepathsList();
}
bool ApplicationList::CheckAndAddApplication(QString appPath, QString name, QString parameters)
{
    if (QFileInfo(appPath).exists() && QFileInfo(appPath).isExecutable()) {
        Application app;
        app.setName(name);
        app.setPath("\"" + appPath + "\"");
        app.setParameters(parameters);
        AddApplication(app);
        return true;
    }
    return false;
}
Beispiel #6
0
void ApplicationList::Copy(const ApplicationList *list)
{
    if (!list) {
        return;
    }

    Clear();
    for (int i = 0; i < list->GetApplicationCount(); i++) {
        const Application app = list->GetApplication(i);
        AddApplication(app);
    }
    mDefaultApplicationIndex = list->GetDefaultApplication();
}
Beispiel #7
0
void MimeTypeNode::SetDefault(ApplicationNode * app)
{
    if(!app)
		return;

	// If the app is already in the applications list - remove it
	RemoveApplication(app);

	// If we have a default already - add it to the applications list
	if(m_default_app)
		AddApplication(m_default_app);

	// Set the default to be the new one
    m_default_app = app;
}
Beispiel #8
0
SettingsDialog::SettingsDialog(QSettings *programSettings,
                               ApplicationList *list,
                               QWidget *parent) :
    QDialog(parent),
    mSettings(programSettings),
    mApplications(list),
    mTempApplications(new ApplicationList(this))
{
    mUI.setupUi(this);
    mTempApplications->Copy(list);

    mUI.mEditIncludePaths->setText(programSettings->value(SETTINGS_GLOBAL_INCLUDE_PATHS).toString());
    mUI.mJobs->setText(programSettings->value(SETTINGS_CHECK_THREADS, 1).toString());
    mUI.mForce->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_CHECK_FORCE, false).toBool()));
    mUI.mShowFullPath->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_FULL_PATH, false).toBool()));
    mUI.mShowNoErrorsMessage->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_NO_ERRORS, false).toBool()));
    mUI.mShowDebugWarnings->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_DEBUG_WARNINGS, false).toBool()));
    mUI.mSaveAllErrors->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SAVE_ALL_ERRORS, false).toBool()));
    mUI.mSaveFullPath->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SAVE_FULL_PATH, false).toBool()));
    mUI.mInlineSuppressions->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool()));

    connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(Ok()));
    connect(mUI.mButtons, SIGNAL(rejected()), this, SLOT(reject()));
    connect(mUI.mButtonAdd, SIGNAL(clicked()),
            this, SLOT(AddApplication()));
    connect(mUI.mButtonDelete, SIGNAL(clicked()),
            this, SLOT(DeleteApplication()));
    connect(mUI.mButtonModify, SIGNAL(clicked()),
            this, SLOT(ModifyApplication()));
    connect(mUI.mButtonDefault, SIGNAL(clicked()),
            this, SLOT(DefaultApplication()));
    connect(mUI.mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
            this, SLOT(ModifyApplication()));
    connect(mUI.mBtnAddIncludePath, SIGNAL(clicked()),
            this, SLOT(AddIncludePath()));

    mUI.mListWidget->setSortingEnabled(false);
    PopulateListWidget();

    const int count = QThread::idealThreadCount();
    if (count != -1)
        mUI.mLblIdealThreads->setText(QString::number(count));
    else
        mUI.mLblIdealThreads->setText(tr("N/A"));

    LoadSettings();
}
Beispiel #9
0
StatusType iDroid::IncreaseDownloads(int appID, int downloadIncrease) {
	if (appID <= 0 || downloadIncrease <= 0)
		return INVALID_INPUT;
	try {
		DataByID appByID(appID);
		Tree<DataByID>::Node* node = _appsByIDtree.find(appByID);
		CMP_DATA(node, appID);
		appByID = node->getData();
		StatusType status = RemoveApplication(appID);
		if (status != SUCCESS)
			return status;
		appByID._downloads += downloadIncrease;
		status = AddApplication(appID, appByID._versionCode,
				appByID._downloads);
		if (status != SUCCESS)
			return status;
	} catch (Tree<DataByID>::TreeIsEmpty& e) {
		return FAILURE;
	} catch (Tree<DataByDowns>::TreeIsEmpty& e) {
		return FAILURE;
	}
	return SUCCESS;
}