KDevelop API Documentation

addfilegroupdlg.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Bernd Gehrmann                                  *
00003  *   bernd@kdevelop.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00012 #include <qlabel.h>
00013 #include <qlayout.h>
00014 #include <qpushbutton.h>
00015 #include <kbuttonbox.h>
00016 #include <klocale.h>
00017 #include <kstdguiitem.h>
00018 #include <kdeversion.h>
00019 
00020 #include "addfilegroupdlg.h"
00021 
00022 
00023 AddFileGroupDialog::AddFileGroupDialog(const QString& old_title, const QString& old_pattern, QWidget *parent, const char *name)
00024     : QDialog(parent, name, true)
00025 {
00026     QLabel *title_label = new QLabel(i18n("&Title:"), this);
00027     title_edit = new QLineEdit(old_title, this);
00028     title_edit->setFocus();
00029     title_label->setBuddy(title_edit);
00030     connect( title_edit, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotTextChanged() ) );
00031 
00032     QLabel *pattern_label = new QLabel(i18n("&Pattern:"), this);
00033     pattern_edit = new QLineEdit(old_pattern, this);
00034     pattern_label->setBuddy(pattern_edit);
00035     QFontMetrics fm(pattern_edit->fontMetrics());
00036     pattern_edit->setMinimumWidth(fm.width('X')*35);
00037     connect( pattern_edit, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotTextChanged() ) );
00038     QVBoxLayout *layout = new QVBoxLayout(this, 10);
00039 
00040     QGridLayout *grid = new QGridLayout(2, 2);
00041     layout->addLayout(grid);
00042     grid->addWidget(title_label, 0, 0);
00043     grid->addWidget(title_edit, 0, 1);
00044     grid->addWidget(pattern_label, 1, 0);
00045     grid->addWidget(pattern_edit, 1, 1);
00046 
00047     QFrame *frame = new QFrame(this);
00048     frame->setFrameStyle(QFrame::HLine | QFrame::Sunken);
00049     layout->addWidget(frame, 0);
00050 
00051     KButtonBox *buttonbox = new KButtonBox(this);
00052     buttonbox->addStretch();
00053 #if KDE_IS_VERSION( 3, 2, 90 )
00054     m_pOk = buttonbox->addButton(KStdGuiItem::ok());
00055     QPushButton *cancel = buttonbox->addButton(KStdGuiItem::cancel());
00056 #else
00057     m_pOk = buttonbox->addButton(KStdGuiItem::ok().text());
00058     QPushButton *cancel = buttonbox->addButton(KStdGuiItem::cancel().text());
00059 #endif
00060 
00061     m_pOk->setDefault(true);
00062     connect( m_pOk, SIGNAL(clicked()), this, SLOT(accept()) );
00063     connect( cancel, SIGNAL(clicked()), this, SLOT(reject()) );
00064     buttonbox->layout();
00065     layout->addWidget(buttonbox, 0);
00066     slotTextChanged();
00067 }
00068 
00069 
00070 AddFileGroupDialog::~AddFileGroupDialog()
00071 {}
00072 
00073 void AddFileGroupDialog::slotTextChanged()
00074 {
00075     m_pOk->setEnabled( !title_edit->text().isEmpty() && !pattern_edit->text().isEmpty() );
00076 }
00077 
00078 #include "addfilegroupdlg.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:41 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003