Now starts the default application by double clicking the error.

This commit is contained in:
Vesa Pikki 2009-05-23 18:45:05 +03:00
parent 31a88bd0ba
commit 2b7bf671d7
8 changed files with 51 additions and 21 deletions

View File

@ -111,3 +111,12 @@ void ApplicationList::RemoveApplication(const int index)
mApplications.removeAt(index);
}
void ApplicationList::MoveFirst(const int index)
{
if (index < mApplications.size() && index > 0)
{
mApplications.move(index, 0);
}
}

View File

@ -53,6 +53,8 @@ public:
void AddApplicationType(const QString &name, const QString &path);
void RemoveApplication(const int index);
void MoveFirst(const int index);
protected:

View File

@ -191,19 +191,6 @@ Settings MainWindow::GetCppCheckSettings()
return result;
}
QStringList MainWindow::RemoveDuplicates(const QStringList &list)
{
QHash<QString, int> hash;
QString str;
foreach(str, list)
{
hash[str] = 0;
}
return QStringList(hash.uniqueKeys());
}
QStringList MainWindow::GetFilesRecursively(const QString &path)
{
QFileInfo info(path);

View File

@ -80,7 +80,6 @@ protected:
void EnableCheckButtons(bool enable);
void DoCheckFiles(QFileDialog::FileMode mode);
QStringList GetFilesRecursively(const QString &path);
QStringList RemoveDuplicates(const QStringList &list);
Settings GetCppCheckSettings();
QStringList RemoveUnacceptedFiles(const QStringList &list);

View File

@ -33,8 +33,11 @@ ResultsTree::ResultsTree(QSettings &settings, ApplicationList &list) :
QStringList labels;
labels << tr("File") << tr("Severity") << tr("Line") << tr("Message");
mModel.setHorizontalHeaderLabels(labels);
setExpandsOnDoubleClick(false);
LoadSettings();
connect(this, SIGNAL(doubleClicked(const QModelIndex &)),
this, SLOT(QuickStartApplication(const QModelIndex &)));
}
ResultsTree::~ResultsTree()
@ -365,12 +368,11 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
}
}
void ResultsTree::Context(int application)
void ResultsTree::StartApplication(QStandardItem *target, int application)
{
if (mContextItem)
if (target && application >= 0 && application < mApplications.GetApplicationCount())
{
QVariantMap data = mContextItem->data().toMap();
QVariantMap data = target->data().toMap();
QString program = mApplications.GetApplicationPath(application);
@ -402,6 +404,17 @@ void ResultsTree::Context(int application)
program.replace("(message)", data["message"].toString(), Qt::CaseInsensitive);
program.replace("(severity)", data["severity"].toString(), Qt::CaseInsensitive);
QProcess::execute(program);
QProcess::startDetached(program);
}
}
void ResultsTree::Context(int application)
{
StartApplication(mContextItem, application);
}
void ResultsTree::QuickStartApplication(const QModelIndex &index)
{
StartApplication(mModel.itemFromIndex(index), 0);
}

View File

@ -62,6 +62,7 @@ public:
void ShowResults(ShowTypes type, bool show);
protected slots:
void QuickStartApplication(const QModelIndex &index);
/**
* @brief Slot for context menu item to open an error with specified application
*
@ -69,6 +70,7 @@ protected slots:
*/
void Context(int application);
protected:
void StartApplication(QStandardItem *target, int application);
void contextMenuEvent(QContextMenuEvent * e);
QStandardItem *AddBacktraceFiles(QStandardItem *parent,

View File

@ -105,10 +105,15 @@ SettingsDialog::SettingsDialog(QSettings &programSettings, ApplicationList &list
connect(modify, SIGNAL(clicked()),
this, SLOT(ModifyApplication()));
QPushButton *def = new QPushButton(tr("Make default application"));
appslayout->addWidget(def);
connect(def, SIGNAL(clicked()),
this, SLOT(DefaultApplication()));
connect(mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
this, SLOT(ModifyApplication()));
mListWidget->setSortingEnabled(false);
PopulateListWidget();
@ -219,6 +224,18 @@ void SettingsDialog::ModifyApplication()
}
}
void SettingsDialog::DefaultApplication()
{
QList<QListWidgetItem *> selected = mListWidget->selectedItems();
if (selected.size() > 0)
{
int index = mListWidget->row(selected[0]);
mApplications.MoveFirst(index);
mListWidget->clear();
PopulateListWidget();
}
}
void SettingsDialog::PopulateListWidget()
{
for (int i = 0;i < mApplications.GetApplicationCount();i++)

View File

@ -50,6 +50,7 @@ protected slots:
void AddApplication();
void DeleteApplication();
void ModifyApplication();
void DefaultApplication();
protected:
void PopulateListWidget();
/**