-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to add/remove/modify applications to open errors with.
Only the list of applications added, errors cant be opened yet.
- Loading branch information
Showing
9 changed files
with
470 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Cppcheck - A tool for static C/C++ code analysis | ||
* Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam, | ||
* Leandro Penz, Kimmo Varis, Vesa Pikki | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/ | ||
*/ | ||
|
||
#include "applicationdialog.h" | ||
#include <QVBoxLayout> | ||
#include <QPushButton> | ||
#include <QHBoxLayout> | ||
#include <QLabel> | ||
#include <QFileDialog> | ||
#include <QDebug> | ||
|
||
ApplicationDialog::ApplicationDialog(const QString &name, | ||
const QString &path, | ||
const QString &title) | ||
{ | ||
QVBoxLayout *layout = new QVBoxLayout(); | ||
mName = new QLineEdit(name); | ||
mPath = new QLineEdit(path); | ||
|
||
QString guide = tr("Here you can add applications that can open error files.\n" \ | ||
"Specify a name for the application and the application to execute.\n\n" \ | ||
"The following texts are replaced with appriproate values when application is executed:\n" \ | ||
"(file) - Filename containing the error\n" \ | ||
"(line) - Line number containing the error\n" \ | ||
"(message) - Error message\n" \ | ||
"(severity) - Error severity\n" \ | ||
"\n" \ | ||
"Example opening a file with Kate and make Kate scroll to the corret line:\n" \ | ||
"kate -l(line) (file)"); | ||
|
||
layout->addWidget(new QLabel(guide)); | ||
|
||
layout->addWidget(new QLabel(tr("Application's name"))); | ||
layout->addWidget(mName); | ||
layout->addWidget(new QLabel(tr("Application to execute"))); | ||
layout->addWidget(mPath); | ||
QPushButton *browse = new QPushButton(tr("Browse")); | ||
connect(browse,SIGNAL(clicked()), this, SLOT(Browse())); | ||
layout->addWidget(browse); | ||
|
||
QPushButton *cancel = new QPushButton(tr("Cancel")); | ||
QPushButton *ok = new QPushButton(tr("Ok")); | ||
|
||
//Add a layout for ok/cancel buttons | ||
QHBoxLayout *buttonLayout = new QHBoxLayout(); | ||
buttonLayout->addWidget(ok); | ||
buttonLayout->addWidget(cancel); | ||
layout->addLayout(buttonLayout); | ||
|
||
//Connect OK buttons | ||
connect(ok, SIGNAL(clicked()), | ||
this, SLOT(accept())); | ||
connect(cancel, SIGNAL(clicked()), | ||
this, SLOT(reject())); | ||
setLayout(layout); | ||
setWindowTitle(title); | ||
} | ||
|
||
|
||
ApplicationDialog::~ApplicationDialog() | ||
{ | ||
//dtor | ||
} | ||
|
||
|
||
void ApplicationDialog::Browse() | ||
{ | ||
QFileDialog dialog(this); | ||
dialog.setFileMode(QFileDialog::ExistingFiles); | ||
|
||
if (dialog.exec()) | ||
{ | ||
QStringList list = dialog.selectedFiles(); | ||
if (list.size() > 0) | ||
{ | ||
mPath->setText(list[0]); | ||
} | ||
} | ||
} | ||
|
||
QString ApplicationDialog::GetName() | ||
{ | ||
return mName->text(); | ||
} | ||
|
||
|
||
QString ApplicationDialog::GetPath() | ||
{ | ||
return mPath->text(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Cppcheck - A tool for static C/C++ code analysis | ||
* Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam, | ||
* Leandro Penz, Kimmo Varis, Vesa Pikki | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/ | ||
*/ | ||
|
||
#ifndef APPLICATIONDIALOG_H | ||
#define APPLICATIONDIALOG_H | ||
|
||
#include <QDialog> | ||
#include <QLineEdit> | ||
|
||
|
||
class ApplicationDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
public: | ||
ApplicationDialog(const QString &name, | ||
const QString &path, | ||
const QString &title); | ||
virtual ~ApplicationDialog(); | ||
QString GetName(); | ||
QString GetPath(); | ||
protected slots: | ||
void Browse(); | ||
protected: | ||
QLineEdit *mName; | ||
QLineEdit *mPath; | ||
private: | ||
}; | ||
|
||
#endif // APPLICATIONDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Cppcheck - A tool for static C/C++ code analysis | ||
* Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam, | ||
* Leandro Penz, Kimmo Varis, Vesa Pikki | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/ | ||
*/ | ||
|
||
#include "applicationlist.h" | ||
#include <QStringList> | ||
|
||
ApplicationList::ApplicationList() | ||
{ | ||
//ctor | ||
} | ||
|
||
ApplicationList::~ApplicationList() | ||
{ | ||
//dtor | ||
} | ||
|
||
void ApplicationList::LoadSettings(QSettings &programSettings) | ||
{ | ||
|
||
QStringList names = programSettings.value(tr("Application names"), QStringList()).toStringList(); | ||
QStringList paths = programSettings.value(tr("Application paths"), QStringList()).toStringList(); | ||
if (names.size() == paths.size()) { | ||
for(int i=0;i<names.size();i++) { | ||
AddApplicationType(names[i],paths[i]); | ||
} | ||
} | ||
} | ||
|
||
void ApplicationList::SaveSettings(QSettings &programSettings) | ||
{ | ||
QStringList names; | ||
QStringList paths; | ||
|
||
for(int i=0;i<GetApplicationCount();i++) { | ||
names<<GetApplicationName(i); | ||
paths<<GetApplicationPath(i); | ||
} | ||
|
||
programSettings.setValue(tr("Application names"),names); | ||
programSettings.setValue(tr("Application paths"),paths); | ||
|
||
} | ||
|
||
int ApplicationList::GetApplicationCount() | ||
{ | ||
return mApplications.size(); | ||
} | ||
|
||
QString ApplicationList::GetApplicationName(const int index) | ||
{ | ||
if (index >= 0 && index < mApplications.size()) | ||
{ | ||
return mApplications[index].Name; | ||
} | ||
|
||
return QString(); | ||
} | ||
|
||
QString ApplicationList::GetApplicationPath(const int index) | ||
{ | ||
if (index >= 0 && index < mApplications.size()) | ||
{ | ||
return mApplications[index].Path; | ||
} | ||
|
||
return QString(); | ||
|
||
} | ||
|
||
|
||
void ApplicationList::SetApplicationType(const int index, | ||
const QString &name, | ||
const QString &path) | ||
{ | ||
if (index >= 0 && index < mApplications.size()) | ||
{ | ||
mApplications[index].Name = name; | ||
mApplications[index].Path = path; | ||
} | ||
} | ||
|
||
void ApplicationList::AddApplicationType(const QString &name, const QString &path) | ||
{ | ||
ApplicationType type; | ||
type.Name = name; | ||
type.Path = path; | ||
mApplications<<type; | ||
} | ||
|
||
void ApplicationList::RemoveApplication(const int index) | ||
{ | ||
mApplications.removeAt(index); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Cppcheck - A tool for static C/C++ code analysis | ||
* Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam, | ||
* Leandro Penz, Kimmo Varis, Vesa Pikki | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/ | ||
*/ | ||
|
||
#ifndef APPLICATIONLIST_H | ||
#define APPLICATIONLIST_H | ||
|
||
#include <QObject> | ||
#include <QSettings> | ||
|
||
|
||
class ApplicationList : public QObject | ||
{ | ||
public: | ||
typedef struct | ||
{ | ||
QString Name; | ||
QString Path; | ||
}ApplicationType; | ||
|
||
ApplicationList(); | ||
virtual ~ApplicationList(); | ||
|
||
void LoadSettings(QSettings &programSettings); | ||
|
||
void SaveSettings(QSettings &programSettings); | ||
|
||
int GetApplicationCount(); | ||
|
||
QString GetApplicationName(const int index); | ||
|
||
QString GetApplicationPath(const int index); | ||
|
||
void SetApplicationType(const int index, | ||
const QString &name, | ||
const QString &path); | ||
|
||
void AddApplicationType(const QString &name, const QString &path); | ||
|
||
void RemoveApplication(const int index); | ||
protected: | ||
|
||
|
||
QList<ApplicationType> mApplications; | ||
private: | ||
}; | ||
|
||
#endif // APPLICATIONLIST_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,6 +161,8 @@ protected slots: | |
*/ | ||
ThreadHandler mThread; | ||
|
||
ApplicationList mApplications; | ||
|
||
private: | ||
}; | ||
|
||
|
Oops, something went wrong.