|
| 1 | +/* |
| 2 | + * Cppcheck - A tool for static C/C++ code analysis |
| 3 | + * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam, |
| 4 | + * Leandro Penz, Kimmo Varis, Vesa Pikki |
| 5 | + * |
| 6 | + * This program is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU General Public License |
| 17 | + * along with this program. If not, see <http://www.gnu.org/licenses/ |
| 18 | + */ |
| 19 | + |
| 20 | +#include "applicationdialog.h" |
| 21 | +#include <QVBoxLayout> |
| 22 | +#include <QPushButton> |
| 23 | +#include <QHBoxLayout> |
| 24 | +#include <QLabel> |
| 25 | +#include <QFileDialog> |
| 26 | +#include <QDebug> |
| 27 | + |
| 28 | +ApplicationDialog::ApplicationDialog(const QString &name, |
| 29 | +const QString &path, |
| 30 | +const QString &title) |
| 31 | +{ |
| 32 | + QVBoxLayout *layout = new QVBoxLayout(); |
| 33 | + mName = new QLineEdit(name); |
| 34 | + mPath = new QLineEdit(path); |
| 35 | + |
| 36 | + QString guide = tr("Here you can add applications that can open error files.\n" \ |
| 37 | + "Specify a name for the application and the application to execute.\n\n" \ |
| 38 | + "The following texts are replaced with appriproate values when application is executed:\n" \ |
| 39 | + "(file) - Filename containing the error\n" \ |
| 40 | + "(line) - Line number containing the error\n" \ |
| 41 | + "(message) - Error message\n" \ |
| 42 | + "(severity) - Error severity\n" \ |
| 43 | + "\n" \ |
| 44 | + "Example opening a file with Kate and make Kate scroll to the corret line:\n" \ |
| 45 | + "kate -l(line) (file)"); |
| 46 | + |
| 47 | + layout->addWidget(new QLabel(guide)); |
| 48 | + |
| 49 | + layout->addWidget(new QLabel(tr("Application's name"))); |
| 50 | + layout->addWidget(mName); |
| 51 | + layout->addWidget(new QLabel(tr("Application to execute"))); |
| 52 | + layout->addWidget(mPath); |
| 53 | + QPushButton *browse = new QPushButton(tr("Browse")); |
| 54 | + connect(browse,SIGNAL(clicked()), this, SLOT(Browse())); |
| 55 | + layout->addWidget(browse); |
| 56 | + |
| 57 | + QPushButton *cancel = new QPushButton(tr("Cancel")); |
| 58 | + QPushButton *ok = new QPushButton(tr("Ok")); |
| 59 | + |
| 60 | + //Add a layout for ok/cancel buttons |
| 61 | + QHBoxLayout *buttonLayout = new QHBoxLayout(); |
| 62 | + buttonLayout->addWidget(ok); |
| 63 | + buttonLayout->addWidget(cancel); |
| 64 | + layout->addLayout(buttonLayout); |
| 65 | + |
| 66 | + //Connect OK buttons |
| 67 | + connect(ok, SIGNAL(clicked()), |
| 68 | + this, SLOT(accept())); |
| 69 | + connect(cancel, SIGNAL(clicked()), |
| 70 | + this, SLOT(reject())); |
| 71 | + setLayout(layout); |
| 72 | + setWindowTitle(title); |
| 73 | +} |
| 74 | + |
| 75 | + |
| 76 | +ApplicationDialog::~ApplicationDialog() |
| 77 | +{ |
| 78 | + //dtor |
| 79 | +} |
| 80 | + |
| 81 | + |
| 82 | +void ApplicationDialog::Browse() |
| 83 | +{ |
| 84 | + QFileDialog dialog(this); |
| 85 | + dialog.setFileMode(QFileDialog::ExistingFiles); |
| 86 | + |
| 87 | + if (dialog.exec()) |
| 88 | + { |
| 89 | + QStringList list = dialog.selectedFiles(); |
| 90 | + if (list.size() > 0) |
| 91 | + { |
| 92 | + mPath->setText(list[0]); |
| 93 | + } |
| 94 | + } |
| 95 | +} |
| 96 | + |
| 97 | +QString ApplicationDialog::GetName() |
| 98 | +{ |
| 99 | + return mName->text(); |
| 100 | +} |
| 101 | + |
| 102 | + |
| 103 | +QString ApplicationDialog::GetPath() |
| 104 | +{ |
| 105 | + return mPath->text(); |
| 106 | +} |
0 commit comments