Bug 67490 - edit chat style fails own dupe check, makes style disappear from list
Summary: edit chat style fails own dupe check, makes style disappear from list
Status: RESOLVED FIXED
Alias: None
Product: kopete
Classification: Applications
Component: Main Application (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR major
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
: 67931 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-11-07 11:10 UTC by Will Stephenson
Modified: 2003-11-20 14:25 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Will Stephenson 2003-11-07 11:10:20 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

If you edit a style and click Ok, the changed style fails a duplicate style name check.  Looks like we think the changed style is a new style being added, instead of changes to an existing style.  

The style being edited then disappears from the style list.
Comment 1 Matt Rogers 2003-11-11 22:20:29 UTC
*** Bug 67931 has been marked as a duplicate of this bug. ***
Comment 2 Matt Rogers 2003-11-11 22:21:05 UTC
yeah, this should be fixed for kde 3.2. It makes having custom styles useless
Comment 3 Olivier Goffart 2003-11-12 20:18:18 UTC
Oups, sorry, i closed the wrong bug with this mail,  of course, this is this one i wanted to close with this commit
-----------------------------------------------------------


CVS commit by ogoffart: 

Fix Bug 67494: crash on exit after editing chat style

CCMAIL: 67494-done@bugs.kde.org


  M +21 -13    appearanceconfig.cpp   1.14
  M +1 -1      appearanceconfig.h   1.3


--- kdenetwork/kopete/kopete/config/appearance/appearanceconfig.cpp  #1.13:1.14
@@ -489,6 +489,6 @@ void AppearanceConfig::slotDeleteStyle()
 void AppearanceConfig::slotStyleSaved()
 {
-        addStyle( styleEditor->styleName->text(), KTextEditor::editInterface( \
editDocument )->text() ); -
+        if( addStyle( styleEditor->styleName->text(), KTextEditor::editInterface( \
editDocument )->text() ) ) +        {
         // Remove our tempfile
         QString filePath = itemMap[ editedItem ];
@@ -499,12 +499,16 @@ void AppearanceConfig::slotStyleSaved()
         }
         delete editedItem;
+                editedItem=0L;
 
         styleEditor->deleteLater();
         emit changed( true );
+        }
+        else //The style has not been saved for a reason or another - don't loose it
+                styleEditor->show();
 }
 
-void AppearanceConfig::addStyle( const QString &styleName, const QString &styleSheet \
) +bool AppearanceConfig::addStyle( const QString &styleName, const QString \
&styleSheet )  {
-        if( !mPrfsChatWindow->styleList->findItem( styleName ) )
+        if( !mPrfsChatWindow->styleList->findItem( styleName )  ||  \
(mPrfsChatWindow->styleList->selectedItem() && \
mPrfsChatWindow->styleList->selectedItem()->text()==styleName)  )  {
                 QString filePath = locateLocal("appdata", \
QString::fromLatin1("styles/%1.xsl").arg( styleName ) ); @@ -521,4 +525,5 @@ void \
AppearanceConfig::addStyle( const Q  mPrfsChatWindow->styleList->sort();
                         styleChanged = true;
+                        return true;
                 }
                 else
@@ -531,4 +536,7 @@ void AppearanceConfig::addStyle( const Q
                 KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("A \
style named \"%1\" already exists. Please rename the style.").arg( styleName ), \
i18n("Could Not Save") );  }
+
+        //The style has not been saved for a reason or another
+        return false;
 }
 

--- kdenetwork/kopete/kopete/config/appearance/appearanceconfig.h  #1.2:1.3
@@ -104,5 +104,5 @@ private:
         void updateHighlight();
         QString fileContents(const QString &path);
-        void addStyle(const QString &styleName, const QString &xslString);
+        bool addStyle(const QString &styleName, const QString &xslString);
 
         KopeteAppearanceConfigPrivate *d;
Comment 4 Will Stephenson 2003-11-19 14:30:11 UTC
Just tried to verify this was fixed, but edited styles disappear and cause the deadly XML error message. 

(edit style, click onto a different style, click onto the edited style). 

The next time you open the dialog, the edited styles will have disappeared.
Comment 5 Will Stephenson 2003-11-20 14:25:56 UTC
CVS commit by wstephens: 

We were deleting just edited styles, don't do that.  I couldn't find any mention of a tempfile anywhere else.

Don't add edited files into the listview, they already exist there.

Update the preview after an edit.
CCMAIL: 67490-done@bugs.kde


  M +15 -15    appearanceconfig.cpp   1.16


--- kdenetwork/kopete/kopete/config/appearance/appearanceconfig.cpp  #1.15:1.16
@@ -501,14 +501,4 @@ void AppearanceConfig::slotStyleSaved()
         if( addStyle( styleEditor->styleName->text(), KTextEditor::editInterface( editDocument )->text() ) )
         {
-                // Remove our tempfile
-                QString filePath = itemMap[ editedItem ];
-                if ( !filePath.isNull() )
-                {
-                        if ( QFileInfo( filePath ).isWritable() )
-                                QFile::remove( filePath );
-                }
-                delete editedItem;
-                editedItem=0L;
-
                 styleEditor->deleteLater();
                 emit changed( true );
@@ -520,5 +510,9 @@ void AppearanceConfig::slotStyleSaved()
 bool AppearanceConfig::addStyle( const QString &styleName, const QString &styleSheet )
 {
-        if( !mPrfsChatWindow->styleList->findItem( styleName )  ||  (mPrfsChatWindow->styleList->selectedItem() && mPrfsChatWindow->styleList->selectedItem()->text()==styleName)  )
+        bool newStyleName = !mPrfsChatWindow->styleList->findItem( styleName );
+        bool editExistingStyle = (mPrfsChatWindow->styleList->selectedItem() &&
+                                 mPrfsChatWindow->styleList->selectedItem()->text()==styleName);
+        
+        if ( newStyleName || editExistingStyle )
         {
                 QString filePath = locateLocal("appdata", QString::fromLatin1("styles/%1.xsl").arg( styleName ) );
@@ -530,8 +524,14 @@ bool AppearanceConfig::addStyle( const Q
                         out.close();
 
+                        if ( newStyleName )
+                        {
                         mPrfsChatWindow->styleList->insertItem( styleName, 0 );
                         itemMap.insert( mPrfsChatWindow->styleList->firstItem(), filePath );
                         mPrfsChatWindow->styleList->setSelected( mPrfsChatWindow->styleList->firstItem(), true );
                         mPrfsChatWindow->styleList->sort();
+                        }
+                        else
+                                slotUpdatePreview();
+
                         styleChanged = true;
                         return true;