comparison confirmcommentdialog.cpp @ 102:f70ccc15c9d0

* Add ConfirmCommentDialog
author Chris Cannam
date Wed, 24 Nov 2010 22:24:55 +0000
parents
children 0bd32aedc6f6
comparison
equal deleted inserted replaced
101:f9af5e93de0e 102:f70ccc15c9d0
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 EasyMercurial
5
6 Based on hgExplorer by Jari Korhonen
7 Copyright (c) 2010 Jari Korhonen
8 Copyright (c) 2010 Chris Cannam
9 Copyright (c) 2010 Queen Mary, University of London
10
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version. See the file
15 COPYING included with this distribution for more information.
16 */
17
18 #include "confirmcommentdialog.h"
19
20 #include <QMessageBox>
21 #include <QInputDialog>
22
23 bool ConfirmCommentDialog::confirmFilesAction(QWidget *parent,
24 QString title,
25 QString introText,
26 QString introTextWithCount,
27 QStringList files)
28 {
29 QString text;
30 if (files.size() <= 10) {
31 text = "<qt>" + introText;
32 text += "<code>";
33 foreach (QString file, files) {
34 text += file + "<br>";
35 }
36 text += "</code></qt>";
37 } else {
38 text = "<qt>" + introText.arg(files.size());
39 }
40 return (QMessageBox::information(parent,
41 title,
42 text,
43 QMessageBox::Ok | QMessageBox::Cancel,
44 QMessageBox::Ok)
45 == QMessageBox::Ok);
46 }
47
48 bool ConfirmCommentDialog::confirmAndComment(QWidget *parent,
49 QString title,
50 QString introText,
51 QString introTextWithCount,
52 QStringList files,
53 QString &comment)
54 {
55 QString text;
56 if (files.size() <= 10) {
57 text = "<qt>" + introText;
58 text += "<code>";
59 foreach (QString file, files) {
60 text += file + "<br>";
61 }
62 text += "</code></qt>";
63 } else {
64 text = "<qt>" + introText.arg(files.size());
65 }
66 return confirmAndComment(parent, title, text, comment);
67 }
68
69 bool ConfirmCommentDialog::confirmAndComment(QWidget *parent,
70 QString title,
71 QString introText,
72 QString &comment)
73 {
74 bool ok = false;
75 comment = QInputDialog::getText(parent, title, introText,
76 QLineEdit::Normal, comment, &ok);
77 return ok;
78 }