From bfd50121e0bef4cf7b856cd646062c9b93e7fe40 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 20 Jun 2019 16:02:22 +0900 Subject: [PATCH] tdefilereplace: simplified format of kfr files for string lists. Signed-off-by: Michele Calgaro --- tdefilereplace/tdefilereplacepart.cpp | 5 ++-- tdefilereplace/tdefilereplaceview.cpp | 38 +++++++++++---------------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp index 7d0da75..5e08355 100644 --- a/tdefilereplace/tdefilereplacepart.cpp +++ b/tdefilereplace/tdefilereplacepart.cpp @@ -1570,8 +1570,7 @@ void TDEFileReplacePart::loadViewContent() void TDEFileReplacePart::loadRulesFile(const TQString& fileName) { - /* Loads a file with kfr extension. - * creates a xml document and browses it*/ + // Loads a file with kfr extension, creates a xml document and browses it TQDomDocument doc("mydocument"); TQFile file(fileName); TDEListView* sv = m_view->getStringsView(); @@ -1636,7 +1635,7 @@ void TDEFileReplacePart::loadRulesFile(const TQString& fileName) n = n.nextSibling(); } - // Adds file to "load strings form file" menu + // Adds file to "load strings from file" menu TQStringList fileList = m_option->m_recentStringFileList; if(!fileList.contains(fileName)) { diff --git a/tdefilereplace/tdefilereplaceview.cpp b/tdefilereplace/tdefilereplaceview.cpp index dd23ad5..2220c13 100644 --- a/tdefilereplace/tdefilereplaceview.cpp +++ b/tdefilereplace/tdefilereplaceview.cpp @@ -466,54 +466,47 @@ void TDEFileReplaceView::slotStringsEdit() void TDEFileReplaceView::slotStringsSave() { // Check there are strings in the list - TDEListView* sv = getStringsView(); - - if (sv->firstChild() == 0) + TDEListView *sv = getStringsView(); + if (!sv->firstChild()) { KMessageBox::error(0, i18n("No strings to save as the list is empty.")); - return ; + return; } - TQString header("\n"), - footer("\n"), - body; + TQString header("\n"), footer("\n"), body; if(m_option->m_searchingOnlyMode) header += "\n\t"; else header += "\n\t"; - TQListViewItem* lvi = sv->firstChild(); + TQListViewItem *lvi = sv->firstChild(); - while( lvi ) + while (lvi) { body += TQString("\n\t" - "\n\t\t" - "\n\t\t" - "\n\t").arg(lvi->text(0)).arg(lvi->text(1)); + "\n\t\t%1" + "\n\t\t%2" + "\n\t").arg(lvi->text(0)).arg(lvi->text(1)); lvi = lvi->nextSibling(); } - // Selects the file where strings will be saved + // Selects the file where strings will be saved TQString menu = "*.kfr|" + i18n("TDEFileReplace Strings") + " (*.kfr)\n*|" + i18n("All Files") + " (*)"; TQString fileName = KFileDialog::getSaveFileName(TQString(), menu, 0, i18n("Save Strings to File")); if (fileName.isEmpty()) return; - // Forces the extension to be "kfr" == TDEFileReplace extension - + // Forces the extension to be "kfr" == TDEFileReplace extension fileName = TDEFileReplaceLib::addExtension(fileName, "kfr"); - - TQFile file( fileName ); - if(!file.open( IO_WriteOnly )) + TQFile file(fileName); + if(!file.open(IO_WriteOnly)) { KMessageBox::error(0, i18n("File %1 cannot be saved.").arg(fileName)); return ; } - TQTextStream oTStream( &file ); + TQTextStream oTStream(&file); oTStream.setEncoding(TQTextStream::UnicodeUTF8); - oTStream << header - << body - << footer; + oTStream << header << body << footer; file.close(); } @@ -726,7 +719,6 @@ void TDEFileReplaceView::loadMapIntoView(KeyValueMap map) { m_sv->clear(); KeyValueMap::Iterator itMap; - for(itMap = map.begin(); itMap != map.end(); ++itMap) { TQListViewItem* lvi = new TQListViewItem(m_sv);