umbrello API Documentation

dialog_utils.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2004-2006                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 // own header
00013 #include "dialog_utils.h"
00014 
00015 // qt/kde includes
00016 #include <qgroupbox.h>
00017 #include <qlayout.h>
00018 #include <qlabel.h>
00019 #include <qlineedit.h>
00020 #include <kinputdialog.h>
00021 
00022 // app includes
00023 #include "uml.h"
00024 #include "umlwidget.h"
00025 
00026 namespace Dialog_Utils {
00027 
00028 QLineEdit* makeLabeledEditField(QGroupBox *containingBox, QGridLayout *layout, int row,
00029                                 QLabel * &label, const QString& labelText,
00030                                 QLineEdit * &editField,
00031                                 const QString& editFieldText /* = QString::null */)
00032 {
00033     label = new QLabel(labelText, containingBox);
00034     layout->addWidget(label, row, 0);
00035     editField = new QLineEdit(editFieldText, containingBox);
00036     layout->addWidget(editField, row, 1 );
00037     label->setBuddy(editField);
00038     return editField;
00039 }
00040 
00041 
00042 void askNameForWidget(UMLWidget * &targetWidget, const QString& dialogTitle,
00043                       const QString& dialogPrompt, const QString& defaultName) {
00044 
00045     bool pressedOK = false;
00046 
00047     QString name = KInputDialog::getText(dialogTitle, dialogPrompt, defaultName, &pressedOK, UMLApp::app());
00048 
00049     if (pressedOK) {
00050         targetWidget->setName(name);
00051     } else {
00052         targetWidget->cleanup();
00053         delete targetWidget;
00054         targetWidget = NULL;
00055     }
00056 }
00057 
00058 
00059 }  // end namespace Dialog_Utils
00060 
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:07:56 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003