[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/amarok/src/dialogs
From:       Teo Mrnjavac <teo.mrnjavac () gmail ! com>
Date:       2009-03-17 10:39:17
Message-ID: 1237286357.776533.24698.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 940362 by mrnjavac:

Fixed error messages for layout names.
Implemented playlist layout renaming. This operation is applied immediately to the \
LayoutManager, like layout deletion and unlike creation and copying.

 M  +48 -14    PlaylistLayoutEditDialog.cpp  
 M  +1 -0      PlaylistLayoutEditDialog.h  


--- trunk/extragear/multimedia/amarok/src/dialogs/PlaylistLayoutEditDialog.cpp \
#940361:940362 @@ -116,6 +116,7 @@
     const KIcon renameIcon( "edit-rename" );
     renameLayoutButton->setIcon( renameIcon );
     renameLayoutButton->setToolTip( i18n( "Rename playlist layout" ) );
+    connect( renameLayoutButton, SIGNAL( clicked() ), this, SLOT( renameLayout() ) \
);  }
 
 
@@ -173,11 +174,11 @@
                     i18n( "Please enter a name for the playlist layout you are about \
to define as copy of the layout '%1':",  layoutListWidget->currentItem()->text() ) );
         if( layoutName == "" )
-            KMessageBox::sorry( this, i18n( "Layout name error" ), i18n( "Can't \
create a layout with no name." ) ); +            KMessageBox::sorry( this, i18n( \
"Can't create a layout with no name." ), i18n( "Layout name error" ) );  if( \
                m_layoutsMap->keys().contains( layoutName ) )
-            KMessageBox::sorry( this, i18n( "Layout name error" ), i18n( "Can't \
create a layout with the same name as an existing layout." ) ); +            \
KMessageBox::sorry( this, i18n( "Can't create a layout with the same name as an \
existing layout." ), i18n( "Layout name error" ) );  }
-    debug() << "Creating new layout " << layoutName;
+    debug() << "Copying layout " << layoutName;
     layoutListWidget->addItem( layoutName );
     layoutListWidget->setCurrentItem( (layoutListWidget->findItems( layoutName, \
Qt::MatchExactly )).first() );  PlaylistLayout layout;
@@ -194,6 +195,50 @@
 }
 
 /**
+ * Deletes the current layout selected in the layoutListWidget.
+ */
+void PlaylistLayoutEditDialog::deleteLayout()   //SLOT
+{
+    m_layoutsMap->remove( layoutListWidget->currentItem()->text() );
+    if( LayoutManager::instance()->layouts().contains( \
layoutListWidget->currentItem()->text() ) )  //if the layout is already saved in the \
LayoutManager +        LayoutManager::instance()->deleteLayout( \
layoutListWidget->currentItem()->text() );         //delete it +    delete \
layoutListWidget->currentItem(); +}
+
+/**
+ * Renames the current layout selected in the layoutListWidget.
+ */
+void PlaylistLayoutEditDialog::renameLayout()
+{
+    PlaylistLayout layout = m_layoutsMap->value( \
layoutListWidget->currentItem()->text() ); +    
+    QString layoutName( "" );
+    while( layoutName == "" || m_layoutsMap->keys().contains( layoutName ) )
+    {
+        layoutName = QInputDialog::getText( this, i18n( "Choose a new name for the \
playlist layout" ), +                    i18n( "Please enter a new name for the \
playlist layout you are about to rename:" ) ); +        if( \
LayoutManager::instance()->isDefaultLayout( layoutName ) ) +        {
+            KMessageBox::sorry( this, i18n( "Can't rename one of the default \
layouts." ), i18n( "Layout name error" ) ); +            return;
+        }
+        if( layoutName == "" )
+            KMessageBox::sorry( this, i18n( "Can't rename a layout with no name." ), \
i18n( "Layout name error" ) ); +        if( m_layoutsMap->keys().contains( layoutName \
) ) +            KMessageBox::sorry( this, i18n( "Can't rename a layout with the same \
name as an existing layout." ), i18n( "Layout name error" ) ); +    }
+    debug() << "Renaming layout " << layoutName;
+    m_layoutsMap->remove( layoutListWidget->currentItem()->text() );
+    if( LayoutManager::instance()->layouts().contains( \
layoutListWidget->currentItem()->text() ) )  //if the layout is already saved in the \
LayoutManager +        LayoutManager::instance()->deleteLayout( \
layoutListWidget->currentItem()->text() );         //delete it +    \
LayoutManager::instance()->addUserLayout( layoutName, layout ); +    \
m_layoutsMap->insert( layoutName, layout ); +    \
layoutListWidget->currentItem()->setText( layoutName ); +
+    setLayout( layoutName );
+}
+
+/**
  * Loads the configuration of the layout layoutName from the m_layoutsMap to the \
                LayoutItemConfig area.
  * @param layoutName the name of the PlaylistLayout to be loaded for configuration
  */
@@ -219,17 +264,6 @@
 }
 
 /**
- * Deletes the current layout selected in the layoutListWidget.
- */
-void PlaylistLayoutEditDialog::deleteLayout()   //SLOT
-{
-    m_layoutsMap->remove( layoutListWidget->currentItem()->text() );
-    if( LayoutManager::instance()->layouts().contains( \
layoutListWidget->currentItem()->text() ) )  //if the layout is already saved in the \
                LayoutManager
-        LayoutManager::instance()->deleteLayout( \
                layoutListWidget->currentItem()->text() );         //delete it
-    delete layoutListWidget->currentItem();
-}
-
-/**
  * Applies to the playlist a preview of the currently defined layout.
  */
 void PlaylistLayoutEditDialog::preview()
--- trunk/extragear/multimedia/amarok/src/dialogs/PlaylistLayoutEditDialog.h \
#940361:940362 @@ -48,6 +48,7 @@
         void newLayout();
         void copyLayout();
         void deleteLayout();
+        void renameLayout();
         void toggleDeleteButton();
 
     private:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic