From 04d3010f7abb47f47ac6b328a408cc855cb9af4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Tue, 26 Feb 2013 15:46:33 +0100 Subject: Fix unintended rename of pickfile* --- kalarm/CMakeLists.txt | 2 +- kalarm/Makefile.am | 4 +- kalarm/editdlg.cpp | 2 +- kalarm/pickfileradio.cpp | 182 +++++++++++++++++++++++++++++++++++++++++++++ kalarm/pickfileradio.h | 121 ++++++++++++++++++++++++++++++ kalarm/pictdefileradio.cpp | 182 --------------------------------------------- kalarm/pictdefileradio.h | 121 ------------------------------ 7 files changed, 307 insertions(+), 307 deletions(-) create mode 100644 kalarm/pickfileradio.cpp create mode 100644 kalarm/pickfileradio.h delete mode 100644 kalarm/pictdefileradio.cpp delete mode 100644 kalarm/pictdefileradio.h (limited to 'kalarm') diff --git a/kalarm/CMakeLists.txt b/kalarm/CMakeLists.txt index cd7295a47..b93cc6712 100644 --- a/kalarm/CMakeLists.txt +++ b/kalarm/CMakeLists.txt @@ -59,7 +59,7 @@ install( FILES uninstall.desktop DESTINATION ${APPS_INSTALL_DIR}/Applications RE tde_add_executable( kalarm AUTOMOC SOURCES birthdaydlg.cpp main.cpp alarmevent.cpp editdlg.cpp - emailidcombo.cpp find.cpp pictdefileradio.cpp + emailidcombo.cpp find.cpp pickfileradio.cpp calendarcompat.cpp eventlistviewbase.cpp alarmlistview.cpp kamail.cpp timeselector.cpp fontcolourbutton.cpp alarmtimewidget.cpp fontcolour.cpp soundpicker.cpp diff --git a/kalarm/Makefile.am b/kalarm/Makefile.am index 9f3fb32a8..cbf43ea3a 100644 --- a/kalarm/Makefile.am +++ b/kalarm/Makefile.am @@ -20,7 +20,7 @@ kalarm_SOURCES = birthdaydlg.cpp main.cpp alarmevent.cpp editdlg.cpp \ eventlistviewbase.cpp alarmlistview.cpp kamail.cpp timeselector.cpp \ templatelistview.cpp templatepickdlg.cpp templatedlg.cpp \ templatemenuaction.cpp latecancel.cpp repetition.cpp alarmtext.cpp \ - emailidcombo.cpp find.cpp pictdefileradio.cpp calendarcompat.cpp + emailidcombo.cpp find.cpp pickfileradio.cpp calendarcompat.cpp kalarm_LDFLAGS = $(all_libraries) $(KDE_RPATH) -L$(top_builddir)/libtdenetwork/qgpgme if include_ARTS ARTSLIB = -lartskde @@ -37,7 +37,7 @@ noinst_HEADERS = alarmcalendar.h alarmevent.h alarmlistview.h alarmtext.h \ editdlg.h editdlgprivate.h emailidcombo.h eventlistviewbase.h find.h \ fontcolour.h fontcolourbutton.h functions.h kalarm.h kalarmapp.h \ kamail.h karecurrence.h latecancel.h mainwindow.h mainwindowbase.h \ - messagewin.h pictdefileradio.h prefdlg.h preferences.h recurrenceedit.h \ + messagewin.h pickfileradio.h prefdlg.h preferences.h recurrenceedit.h \ recurrenceeditprivate.h reminder.h repetition.h sounddlg.h \ soundpicker.h specialactions.h startdaytimer.h templatedlg.h \ templatelistview.h templatemenuaction.h templatepickdlg.h timeselector.h \ diff --git a/kalarm/editdlg.cpp b/kalarm/editdlg.cpp index 0a7b3d587..ced834833 100644 --- a/kalarm/editdlg.cpp +++ b/kalarm/editdlg.cpp @@ -71,7 +71,7 @@ #include "latecancel.h" #include "lineedit.h" #include "mainwindow.h" -#include "pictdefileradio.h" +#include "pickfileradio.h" #include "preferences.h" #include "radiobutton.h" #include "recurrenceedit.h" diff --git a/kalarm/pickfileradio.cpp b/kalarm/pickfileradio.cpp new file mode 100644 index 000000000..15b56d942 --- /dev/null +++ b/kalarm/pickfileradio.cpp @@ -0,0 +1,182 @@ +/* + * pickfileradio.cpp - radio button with an associated file picker + * Program: kalarm + * Copyright (C) 2005 by David Jarvie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kalarm.h" + +#include +#include +#include + +#include + +#include "lineedit.h" +#include "pickfileradio.moc" + + +PickFileRadio::PickFileRadio(TQPushButton* button, LineEdit* edit, const TQString& text, TQButtonGroup* parent, const char* name) + : RadioButton(text, parent, name), + mGroup(parent), + mEdit(edit), + mButton(button), + mLastId(-1), // set to an invalid value + mRevertId(false) +{ + Q_ASSERT(parent); + Q_ASSERT(button); + mButton->setEnabled(false); + connect(mButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotPickFile())); + if (mEdit) + mEdit->setEnabled(false); + connect(mGroup, TQT_SIGNAL(buttonSet(int)), TQT_SLOT(slotSelectionChanged(int))); +} + +PickFileRadio::PickFileRadio(const TQString& text, TQButtonGroup* parent, const char* name) + : RadioButton(text, parent, name), + mGroup(parent), + mEdit(0), + mButton(0), + mLastId(-1), // set to an invalid value + mRevertId(false) +{ + Q_ASSERT(parent); +} + +void PickFileRadio::init(TQPushButton* button, LineEdit* edit) +{ + Q_ASSERT(button); + mEdit = edit; + mButton = button; + mButton->setEnabled(false); + connect(mButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotPickFile())); + if (mEdit) + mEdit->setEnabled(false); + connect(mGroup, TQT_SIGNAL(buttonSet(int)), TQT_SLOT(slotSelectionChanged(int))); + setReadOnly(RadioButton::isReadOnly()); +} + +void PickFileRadio::setReadOnly(bool ro) +{ + RadioButton::setReadOnly(ro); + if (mButton) + { + if (mEdit) + mEdit->setReadOnly(ro); + if (ro) + mButton->hide(); + else + mButton->show(); + } +} + +void PickFileRadio::setFile(const TQString& file) +{ + mFile = file; +} + +TQString PickFileRadio::file() const +{ + return mEdit ? mEdit->text() : mFile; +} + +/****************************************************************************** +* Set the radio button enabled or disabled. +* Adjusts the enabled/disabled state of other controls appropriately. +*/ +void PickFileRadio::setEnabled(bool enable) +{ + Q_ASSERT(mButton); + RadioButton::setEnabled(enable); + enable = enable && mGroup->selected() == this; + if (enable) + { + if (!pickFileIfNone()) + enable = false; // revert to previously selected type + } + mButton->setEnabled(enable); + if (mEdit) + mEdit->setEnabled(enable); +} + +/****************************************************************************** +* Called when the selected radio button changes. +*/ +void PickFileRadio::slotSelectionChanged(int id) +{ + if (id == mLastId || mRevertId) + return; + int radioId = mGroup->id(this); + if (mLastId == radioId) + { + mButton->setEnabled(false); + if (mEdit) + mEdit->setEnabled(false); + } + else if (id == radioId) + { + if (!pickFileIfNone()) + return; // revert to previously selected type + mButton->setEnabled(true); + if (mEdit) + mEdit->setEnabled(true); + } + mLastId = id; +} + +/****************************************************************************** +* Prompt for a file name if there is none currently entered. +*/ +bool PickFileRadio::pickFileIfNone() +{ + if (mEdit) + mFile = mEdit->text(); + if (!mFile.isEmpty()) + return true; + slotPickFile(); + return !mFile.isEmpty(); +} + +/****************************************************************************** +* Called when the file picker button is clicked. +*/ +void PickFileRadio::slotPickFile() +{ + mFile = pickFile(); + if (mEdit) + mEdit->setText(mFile); + if (mFile.isEmpty()) + { + // No file is selected, so revert to the previous radio button selection. + // But wait a moment before setting the radio button, or it won't work. + mRevertId = true; // prevent picker dialogue popping up twice + TQTimer::singleShot(0, this, TQT_SLOT(setLastId())); + } +} + +/****************************************************************************** +* Select the previously selected radio button in the group. +*/ +void PickFileRadio::setLastId() +{ + if (mLastId == -1) + setOn(false); // we don't know the previous selection, so just turn this button off + else + mGroup->setButton(mLastId); + mRevertId = false; +} diff --git a/kalarm/pickfileradio.h b/kalarm/pickfileradio.h new file mode 100644 index 000000000..f30ca7f63 --- /dev/null +++ b/kalarm/pickfileradio.h @@ -0,0 +1,121 @@ +/* + * pickfileradio.h - radio button with an associated file picker + * Program: kalarm + * Copyright (C) 2005 by David Jarvie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef PICKFILERADIO_H +#define PICKFILERADIO_H + +/** @file pickfileradio.h - radio button with an associated file picker */ + +#include "radiobutton.h" + +class TQPushButton; +class LineEdit; + +/** + * @short Radio button with associated file picker controls. + * + * The PickFileRadio class is a radio button with an associated button to choose + * a file, and an optional file name edit box. Its purpose is to ensure that while + * the radio button is selected, the chosen file name is never blank. + * + * To achieve this, whenever the button is newly selected and the + * file name is currently blank, the file picker dialogue is displayed to choose a + * file. If the dialogue exits without a file being chosen, the radio button selection + * is reverted to the previously selected button in the parent button group. + * + * The class handles the activation of the file picker dialogue (via a virtual method + * which must be supplied by deriving a class from this one). It also handles all + * enabling and disabling of the browse button and edit box when the enable state of + * the radio button is changed, and when the radio button selection changes. + * + * @author David Jarvie + */ +class PickFileRadio : public RadioButton +{ + Q_OBJECT + + public: + /** Constructor. + * @param button Push button to invoke the file picker dialogue. + * @param edit File name edit widget, or null if there is none. + * @param text Radio button's text. + * @param parent Button group which is to be the parent object for the radio button. + * @param name The name of this widget. + */ + PickFileRadio(TQPushButton* button, LineEdit* edit, const TQString& text, TQButtonGroup* parent, const char* name = 0); + /** Constructor. + * The init() method must be called before the widget can be used. + * @param text Radio button's text. + * @param parent Button group which is to be the parent object for the radio button. + * @param name The name of this widget. + */ + PickFileRadio(const TQString& text, TQButtonGroup* parent, const char* name = 0); + /** Initialises the widget. + * @param button Push button to invoke the file picker dialogue. + * @param edit File name edit widget, or null if there is none. + */ + void init(TQPushButton* button, LineEdit* edit = 0); + /** Sets whether the radio button and associated widgets are read-only for the user. + * If read-only, their states cannot be changed by the user. + * @param readOnly True to set the widgets read-only, false to set them read-write. + */ + virtual void setReadOnly(bool readOnly); + /** Chooses a file, for example by displaying a file selection dialogue. + * This method is called when the push button is clicked - the client + * should not activate a file selection dialogue directly. + * @return Selected file name, or TQString() if no selection made. + */ + virtual TQString pickFile() = 0; + /** Notifies the widget of the currently selected file name. + * This should only be used when no file name edit box is used. + * It should be called to initialise the widget's data, and also any time the file + * name is changed without using the push button. + */ + void setFile(const TQString& file); + /** Returns the currently selected file name. */ + TQString file() const; + /** Returns the associated file name edit widget, or null if none. */ + LineEdit* fileEdit() const { return mEdit; } + /** Returns the associated file browse push button. */ + TQPushButton* pushButton() const { return mButton; } + + public slots: + /** Enables or disables the radio button, and adjusts the enabled state of the + * associated browse button and file name edit box. + */ + virtual void setEnabled(bool); + + private slots: + void slotSelectionChanged(int id); + void slotPickFile(); + void setLastId(); + + private: + bool pickFileIfNone(); + + TQButtonGroup* mGroup; // button group which radio button is in + LineEdit* mEdit; // file name edit box, or null if none + TQPushButton* mButton; // push button to pick a file + TQString mFile; // saved file name (if mEdit is null) + int mLastId; // previous radio button selected + bool mRevertId; // true to revert to the previous radio button selection +}; + +#endif // PICKFILERADIO_H diff --git a/kalarm/pictdefileradio.cpp b/kalarm/pictdefileradio.cpp deleted file mode 100644 index 80911c298..000000000 --- a/kalarm/pictdefileradio.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * pictdefileradio.cpp - radio button with an associated file picker - * Program: kalarm - * Copyright (C) 2005 by David Jarvie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "kalarm.h" - -#include -#include -#include - -#include - -#include "lineedit.h" -#include "pictdefileradio.moc" - - -PickFileRadio::PickFileRadio(TQPushButton* button, LineEdit* edit, const TQString& text, TQButtonGroup* parent, const char* name) - : RadioButton(text, parent, name), - mGroup(parent), - mEdit(edit), - mButton(button), - mLastId(-1), // set to an invalid value - mRevertId(false) -{ - Q_ASSERT(parent); - Q_ASSERT(button); - mButton->setEnabled(false); - connect(mButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotPickFile())); - if (mEdit) - mEdit->setEnabled(false); - connect(mGroup, TQT_SIGNAL(buttonSet(int)), TQT_SLOT(slotSelectionChanged(int))); -} - -PickFileRadio::PickFileRadio(const TQString& text, TQButtonGroup* parent, const char* name) - : RadioButton(text, parent, name), - mGroup(parent), - mEdit(0), - mButton(0), - mLastId(-1), // set to an invalid value - mRevertId(false) -{ - Q_ASSERT(parent); -} - -void PickFileRadio::init(TQPushButton* button, LineEdit* edit) -{ - Q_ASSERT(button); - mEdit = edit; - mButton = button; - mButton->setEnabled(false); - connect(mButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotPickFile())); - if (mEdit) - mEdit->setEnabled(false); - connect(mGroup, TQT_SIGNAL(buttonSet(int)), TQT_SLOT(slotSelectionChanged(int))); - setReadOnly(RadioButton::isReadOnly()); -} - -void PickFileRadio::setReadOnly(bool ro) -{ - RadioButton::setReadOnly(ro); - if (mButton) - { - if (mEdit) - mEdit->setReadOnly(ro); - if (ro) - mButton->hide(); - else - mButton->show(); - } -} - -void PickFileRadio::setFile(const TQString& file) -{ - mFile = file; -} - -TQString PickFileRadio::file() const -{ - return mEdit ? mEdit->text() : mFile; -} - -/****************************************************************************** -* Set the radio button enabled or disabled. -* Adjusts the enabled/disabled state of other controls appropriately. -*/ -void PickFileRadio::setEnabled(bool enable) -{ - Q_ASSERT(mButton); - RadioButton::setEnabled(enable); - enable = enable && mGroup->selected() == this; - if (enable) - { - if (!pickFileIfNone()) - enable = false; // revert to previously selected type - } - mButton->setEnabled(enable); - if (mEdit) - mEdit->setEnabled(enable); -} - -/****************************************************************************** -* Called when the selected radio button changes. -*/ -void PickFileRadio::slotSelectionChanged(int id) -{ - if (id == mLastId || mRevertId) - return; - int radioId = mGroup->id(this); - if (mLastId == radioId) - { - mButton->setEnabled(false); - if (mEdit) - mEdit->setEnabled(false); - } - else if (id == radioId) - { - if (!pickFileIfNone()) - return; // revert to previously selected type - mButton->setEnabled(true); - if (mEdit) - mEdit->setEnabled(true); - } - mLastId = id; -} - -/****************************************************************************** -* Prompt for a file name if there is none currently entered. -*/ -bool PickFileRadio::pickFileIfNone() -{ - if (mEdit) - mFile = mEdit->text(); - if (!mFile.isEmpty()) - return true; - slotPickFile(); - return !mFile.isEmpty(); -} - -/****************************************************************************** -* Called when the file picker button is clicked. -*/ -void PickFileRadio::slotPickFile() -{ - mFile = pickFile(); - if (mEdit) - mEdit->setText(mFile); - if (mFile.isEmpty()) - { - // No file is selected, so revert to the previous radio button selection. - // But wait a moment before setting the radio button, or it won't work. - mRevertId = true; // prevent picker dialogue popping up twice - TQTimer::singleShot(0, this, TQT_SLOT(setLastId())); - } -} - -/****************************************************************************** -* Select the previously selected radio button in the group. -*/ -void PickFileRadio::setLastId() -{ - if (mLastId == -1) - setOn(false); // we don't know the previous selection, so just turn this button off - else - mGroup->setButton(mLastId); - mRevertId = false; -} diff --git a/kalarm/pictdefileradio.h b/kalarm/pictdefileradio.h deleted file mode 100644 index 87e4478e0..000000000 --- a/kalarm/pictdefileradio.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * pictdefileradio.h - radio button with an associated file picker - * Program: kalarm - * Copyright (C) 2005 by David Jarvie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef PICTDEFILERADIO_H -#define PICTDEFILERADIO_H - -/** @file pictdefileradio.h - radio button with an associated file picker */ - -#include "radiobutton.h" - -class TQPushButton; -class LineEdit; - -/** - * @short Radio button with associated file picker controls. - * - * The PickFileRadio class is a radio button with an associated button to choose - * a file, and an optional file name edit box. Its purpose is to ensure that while - * the radio button is selected, the chosen file name is never blank. - * - * To achieve this, whenever the button is newly selected and the - * file name is currently blank, the file picker dialogue is displayed to choose a - * file. If the dialogue exits without a file being chosen, the radio button selection - * is reverted to the previously selected button in the parent button group. - * - * The class handles the activation of the file picker dialogue (via a virtual method - * which must be supplied by deriving a class from this one). It also handles all - * enabling and disabling of the browse button and edit box when the enable state of - * the radio button is changed, and when the radio button selection changes. - * - * @author David Jarvie - */ -class PickFileRadio : public RadioButton -{ - Q_OBJECT - - public: - /** Constructor. - * @param button Push button to invoke the file picker dialogue. - * @param edit File name edit widget, or null if there is none. - * @param text Radio button's text. - * @param parent Button group which is to be the parent object for the radio button. - * @param name The name of this widget. - */ - PickFileRadio(TQPushButton* button, LineEdit* edit, const TQString& text, TQButtonGroup* parent, const char* name = 0); - /** Constructor. - * The init() method must be called before the widget can be used. - * @param text Radio button's text. - * @param parent Button group which is to be the parent object for the radio button. - * @param name The name of this widget. - */ - PickFileRadio(const TQString& text, TQButtonGroup* parent, const char* name = 0); - /** Initialises the widget. - * @param button Push button to invoke the file picker dialogue. - * @param edit File name edit widget, or null if there is none. - */ - void init(TQPushButton* button, LineEdit* edit = 0); - /** Sets whether the radio button and associated widgets are read-only for the user. - * If read-only, their states cannot be changed by the user. - * @param readOnly True to set the widgets read-only, false to set them read-write. - */ - virtual void setReadOnly(bool readOnly); - /** Chooses a file, for example by displaying a file selection dialogue. - * This method is called when the push button is clicked - the client - * should not activate a file selection dialogue directly. - * @return Selected file name, or TQString() if no selection made. - */ - virtual TQString pickFile() = 0; - /** Notifies the widget of the currently selected file name. - * This should only be used when no file name edit box is used. - * It should be called to initialise the widget's data, and also any time the file - * name is changed without using the push button. - */ - void setFile(const TQString& file); - /** Returns the currently selected file name. */ - TQString file() const; - /** Returns the associated file name edit widget, or null if none. */ - LineEdit* fileEdit() const { return mEdit; } - /** Returns the associated file browse push button. */ - TQPushButton* pushButton() const { return mButton; } - - public slots: - /** Enables or disables the radio button, and adjusts the enabled state of the - * associated browse button and file name edit box. - */ - virtual void setEnabled(bool); - - private slots: - void slotSelectionChanged(int id); - void slotPickFile(); - void setLastId(); - - private: - bool pickFileIfNone(); - - TQButtonGroup* mGroup; // button group which radio button is in - LineEdit* mEdit; // file name edit box, or null if none - TQPushButton* mButton; // push button to pick a file - TQString mFile; // saved file name (if mEdit is null) - int mLastId; // previous radio button selected - bool mRevertId; // true to revert to the previous radio button selection -}; - -#endif // PICTDEFILERADIO_H -- cgit v1.2.1