Back to index

scribus-ng  1.3.4.dfsg+svn20071115
query.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "query.h"
00008 #include "query.moc"
00009 extern QPixmap loadIcon(QString nam);
00010 
00011 #include <qtooltip.h>
00012 #include <qdialog.h>
00013 #include <qlayout.h>
00014 #include <qlabel.h>
00015 #include <qlineedit.h>
00016 #include <qpushbutton.h>
00017 #include "commonstrings.h"
00018 
00019 Query::Query( QWidget* parent,  const char* name, bool modal, WFlags fl, QString text, QString titel )
00020               : QDialog( parent, name, modal, fl )
00021 {
00022        if ( !name )
00023               setName( "Query" );
00024        setCaption( titel );
00025        setIcon(loadIcon("AppIcon.png"));
00026        queryLayout = new QVBoxLayout( this, 11, 6 );
00027        editLayout = new QHBoxLayout;
00028        editLayout->setSpacing( 6 );
00029        editLayout->setMargin( 0 );
00030        answerEdit = new QLineEdit( this, "answerEdit" );
00031        questionLabel = new QLabel( answerEdit, text, this, "questionLabel" );
00032        questionLabel->setFrameShape( QLabel::MShape );
00033        questionLabel->setFrameShadow( QLabel::MShadow );
00034        questionLabel->adjustSize();
00035        editLayout->addWidget( questionLabel );
00036        editLayout->addWidget( answerEdit );
00037        queryLayout->addLayout( editLayout );
00038        okCancelLayout = new QHBoxLayout;
00039        okCancelLayout->setSpacing( 6 );
00040        okCancelLayout->setMargin( 0 );
00041        QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00042        okCancelLayout->addItem( spacer );
00043        okButton = new QPushButton( CommonStrings::tr_OK, this, "okButton" );
00044        okButton->setDefault( true );
00045        okCancelLayout->addWidget( okButton );
00046        cancelButton = new QPushButton( CommonStrings::tr_Cancel, this, "cancelButton" );
00047        okCancelLayout->addWidget( cancelButton );
00048        queryLayout->addLayout( okCancelLayout );
00049        setMaximumSize(sizeHint());
00050        answerEdit->setFocus();
00051 
00052        // signals and slots connections
00053        connect( okButton, SIGNAL( clicked() ), this, SLOT( Leave() ) );
00054        connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
00055 
00056        // tab order
00057        setTabOrder( answerEdit, okButton );
00058        setTabOrder( okButton, cancelButton );
00059 }
00060 
00061 void Query::Leave()
00062 {
00063        if (answerEdit->text().isEmpty())
00064               return;
00065        else
00066               accept();
00067 }
00068 
00069 const QString Query::getEditText()
00070 {
00071        return answerEdit->text();
00072 }
00073 
00074 void Query::setEditText(QString newText, bool setSelected)
00075 {
00076        answerEdit->setText(newText);
00077        if (setSelected)
00078               answerEdit->selectAll();
00079 }