2 Copyright (C) <2010> <Markus Scharnowski markus.scharnowski@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <QPushButton>
18 #include <QTextBrowser>
19 #include <QHBoxLayout>
20 #include <QFileDialog>
21 #include <QMessageBox>
26 #include "showfulllistdialog.hpp"
28 ShowFullListDialog::ShowFullListDialog(QWidget *parent, QString text) :
31 QPushButton *doneButton = new QPushButton(tr("&Done"));
32 QPushButton *saveButton = new QPushButton(tr("&Save"));
33 QPushButton *saveEditedButton = new QPushButton(tr("S&ave edited version"));
34 textEdit = new QTextBrowser;
35 textEdit->setReadOnly(false);
36 textEdit->setText(text);
39 QVBoxLayout *layout = new QVBoxLayout;
40 layout->addWidget(doneButton);
41 layout->addWidget(saveButton);
42 layout->addWidget(saveEditedButton);
45 QHBoxLayout *mainLayout = new QHBoxLayout;
46 mainLayout->addLayout(layout);
47 mainLayout->addWidget(textEdit);
49 connect(doneButton, SIGNAL(clicked()), this, SLOT(deleteLater()));
50 connect(saveButton, SIGNAL(clicked()), this, SLOT(save()));
51 connect(saveEditedButton, SIGNAL(clicked()), this, SLOT(saveEdited()));
53 setLayout(mainLayout);
54 setWindowTitle(tr("History"));
57 setMinimumHeight(400);
61 ShowFullListDialog::~ShowFullListDialog()
65 int ShowFullListDialog::saveToFile(QString string)
67 QString fileName = QFileDialog::getSaveFileName(0,
69 tr("Push-It textfile (*.pushit);;All Files (*.*)"));
70 if (fileName.isEmpty())
77 myfile.open(fileName.toStdString().c_str());
78 if (!myfile.is_open())
80 QMessageBox::information(0, tr("Unable to open file"),
81 tr("Unable to open file"));
84 myfile << string.toStdString();
90 void ShowFullListDialog::save()
92 saveToFile(initialString);
95 void ShowFullListDialog::saveEdited()
97 saveToFile(textEdit->toPlainText());