23 #include <tqbuttongroup.h> 24 #include <tqpushbutton.h> 30 #include "pickfileradio.moc" 34 : RadioButton(text, parent, name),
43 mButton->setEnabled(
false);
44 connect(mButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotPickFile()));
46 mEdit->setEnabled(
false);
47 connect(mGroup, TQT_SIGNAL(buttonSet(
int)), TQT_SLOT(slotSelectionChanged(
int)));
51 : RadioButton(text, parent, name),
66 mButton->setEnabled(
false);
67 connect(mButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotPickFile()));
69 mEdit->setEnabled(
false);
70 connect(mGroup, TQT_SIGNAL(buttonSet(
int)), TQT_SLOT(slotSelectionChanged(
int)));
76 RadioButton::setReadOnly(ro);
80 mEdit->setReadOnly(ro);
95 return mEdit ? mEdit->text() : mFile;
105 RadioButton::setEnabled(enable);
106 enable = enable && mGroup->selected() ==
this;
109 if (!pickFileIfNone())
112 mButton->setEnabled(enable);
114 mEdit->setEnabled(enable);
120 void PickFileRadio::slotSelectionChanged(
int id)
122 if (
id == mLastId || mRevertId)
124 int radioId = mGroup->id(
this);
125 if (mLastId == radioId)
127 mButton->setEnabled(
false);
129 mEdit->setEnabled(
false);
131 else if (
id == radioId)
133 if (!pickFileIfNone())
135 mButton->setEnabled(
true);
137 mEdit->setEnabled(
true);
145 bool PickFileRadio::pickFileIfNone()
148 mFile = mEdit->text();
149 if (!mFile.isEmpty())
152 return !mFile.isEmpty();
158 void PickFileRadio::slotPickFile()
162 mEdit->setText(mFile);
168 TQTimer::singleShot(0,
this, TQT_SLOT(setLastId()));
175 void PickFileRadio::setLastId()
180 mGroup->setButton(mLastId);
virtual TQString pickFile()=0
Chooses a file, for example by displaying a file selection dialogue.
virtual void setEnabled(bool)
Enables or disables the radio button, and adjusts the enabled state of the associated browse button a...
virtual void setReadOnly(bool readOnly)
Sets whether the radio button and associated widgets are read-only for the user.
void setFile(const TQString &file)
Notifies the widget of the currently selected file name.
PickFileRadio(TQPushButton *button, LineEdit *edit, const TQString &text, TQButtonGroup *parent, const char *name=0)
Constructor.
TQString file() const
Returns the currently selected file name.
void init(TQPushButton *button, LineEdit *edit=0)
Initialises the widget.