annotate confirmcommentdialog.cpp @ 102:f70ccc15c9d0

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