┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tagcloud/newtagdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tagcloud/newtagdialog.cpp')
-rw-r--r--src/tagcloud/newtagdialog.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/tagcloud/newtagdialog.cpp b/src/tagcloud/newtagdialog.cpp
new file mode 100644
index 000000000..0fe574fdc
--- /dev/null
+++ b/src/tagcloud/newtagdialog.cpp
@@ -0,0 +1,83 @@
+/*
+ Copyright (C) 2008 by Sebastian Trueg <trueg at kde.org>
+
+ 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, 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 "newtagdialog.h"
+
+#include <nepomuk/tag.h>
+
+#include <KDebug>
+#include <KLocale>
+#include <KTitleWidget>
+
+
+NewTagDialog::NewTagDialog( QWidget* parent )
+ : KDialog( parent )
+{
+ setCaption( i18n( "Create new Tag" ) );
+ setButtons( Ok|Cancel );
+ enableButtonOk( false );
+
+ setupUi( mainWidget() );
+
+ connect( m_editTagLabel, SIGNAL( textChanged(const QString&) ),
+ this, SLOT( slotLabelChanged(const QString&) ) );
+}
+
+
+NewTagDialog::~NewTagDialog()
+{
+}
+
+
+void NewTagDialog::slotLabelChanged( const QString& text )
+{
+ enableButtonOk( !text.isEmpty() );
+}
+
+
+Nepomuk::Tag NewTagDialog::createTag( QWidget* parent )
+{
+ NewTagDialog dlg( parent );
+ dlg.m_labelTitle->setText( i18n( "Create New Tag" ) );
+ dlg.m_labelTitle->setComment( i18n( "with optional icon and description" ) );
+ dlg.m_labelTitle->setPixmap( KIcon( "nepomuk" ).pixmap( 32, 32 ) );
+
+ dlg.m_editTagLabel->setFocus();
+
+ if ( dlg.exec() ) {
+ QString name = dlg.m_editTagLabel->text();
+ QString comment = dlg.m_editTagComment->text();
+ QString icon = dlg.m_buttonTagIcon->icon();
+
+ Nepomuk::Tag newTag( name );
+ newTag.setLabel( name );
+ newTag.addIdentifier( name );
+ if ( !comment.isEmpty() ) {
+ newTag.setDescription( comment );
+ }
+ if ( !icon.isEmpty() ) {
+ newTag.addSymbol( icon );
+ }
+ return newTag;
+ }
+ else {
+ return Nepomuk::Tag();
+ }
+}
+
+#include "newtagdialog.moc"