tagpropertiesdialog.cpp
00001 /* 00002 This file is part of Akregator. 00003 00004 Copyright (C) 2005 Frank Osterfeld <frank.osterfeld at kdemail.net> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of TQt, and distribute the resulting executable, 00022 without including the source code for TQt in the source distribution. 00023 */ 00024 00025 #include <kicondialog.h> 00026 #include <klocale.h> 00027 00028 #include <tqlineedit.h> 00029 00030 #include "tag.h" 00031 #include "tagpropertiesdialog.h" 00032 #include "tagpropertieswidgetbase.h" 00033 00034 namespace Akregator { 00035 00036 class TagPropertiesDialog::TagPropertiesDialogPrivate 00037 { 00038 public: 00039 Tag tag; 00040 TagPropertiesWidgetBase* widget; 00041 }; 00042 00043 TagPropertiesDialog::TagPropertiesDialog(TQWidget *parent, const char *name) : KDialogBase(KDialogBase::Swallow, TQt::WStyle_DialogBorder, parent, name, true, i18n("Tag Properties"), KDialogBase::Ok|KDialogBase::Cancel|KDialogBase::Apply), d(new TagPropertiesDialogPrivate) 00044 { 00045 d->widget = new TagPropertiesWidgetBase(this); 00046 setMainWidget(d->widget); 00047 d->widget->le_title->setFocus(); 00048 enableButtonOK(false); 00049 enableButtonApply(false); 00050 connect(d->widget->le_title, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotTextChanged(const TQString& ))); 00051 } 00052 00053 TagPropertiesDialog::~TagPropertiesDialog() 00054 { 00055 delete d; 00056 d = 0; 00057 } 00058 00059 void TagPropertiesDialog::setTag(const Tag& tag) 00060 { 00061 d->tag = tag; 00062 d->widget->le_title->setText(tag.name()); 00063 d->widget->iconButton->setIcon(tag.icon()); 00064 enableButtonOK(!tag.name().isEmpty()); 00065 enableButtonApply(!tag.name().isEmpty()); 00066 } 00067 00068 void TagPropertiesDialog::slotOk() 00069 { 00070 d->tag.setName(d->widget->le_title->text()); 00071 d->tag.setIcon(d->widget->iconButton->icon()); 00072 KDialogBase::slotOk(); 00073 } 00074 00075 void TagPropertiesDialog::slotTextChanged(const TQString& text) 00076 { 00077 enableButtonOK(!text.isEmpty()); 00078 enableButtonApply(!text.isEmpty()); 00079 } 00080 00081 void TagPropertiesDialog::slotApply() 00082 { 00083 d->tag.setName(d->widget->le_title->text()); 00084 d->tag.setIcon(d->widget->iconButton->icon()); 00085 KDialogBase::slotApply(); 00086 } 00087 00088 } // namespace Akregator 00089 00090 #include "tagpropertiesdialog.moc"