summaryrefslogtreecommitdiffstats
path: root/tdefilereplace/tdefilereplacepart.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2019-06-21 23:01:51 +0900
committerMichele Calgaro <[email protected]>2019-06-21 23:01:51 +0900
commit10db438b9a5b758a384d4c007e88f1cda2981cc8 (patch)
tree0ea1dcecb2f18ce4d77ec5081dad16e8b76fb654 /tdefilereplace/tdefilereplacepart.cpp
parentc722431cbb37b120038bd2d0731e7ef74cce9d75 (diff)
downloadtdeutils-10db438b9a5b758a384d4c007e88f1cda2981cc8.tar.gz
tdeutils-10db438b9a5b758a384d4c007e88f1cda2981cc8.zip
tdefilereplace:
- removed old unused code - removed broken and non functional "recent string files" menu code - moved string load code from part to view, together with the save code. Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'tdefilereplace/tdefilereplacepart.cpp')
-rw-r--r--tdefilereplace/tdefilereplacepart.cpp122
1 files changed, 1 insertions, 121 deletions
diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp
index d562437..766366f 100644
--- a/tdefilereplace/tdefilereplacepart.cpp
+++ b/tdefilereplace/tdefilereplacepart.cpp
@@ -322,39 +322,6 @@ void TDEFileReplacePart::slotQuickStringsAdd()
}
}
-void TDEFileReplacePart::slotStringsLoad()
-{
- // Selects the file to load from
- TQString menu = "*.kfr|" + i18n("TDEFileReplace strings") + " (*.kfr)\n*|"+i18n("All Files") + " (*)";
- TQString fileName = KFileDialog::getOpenFileName(TQString(), menu, m_w, i18n("Load Strings From File"));
-
- if(!fileName.isEmpty())
- loadRulesFile(fileName);
-
- updateGUI();
-}
-
-void TDEFileReplacePart::slotOpenRecentStringFile(const KURL& urlFile)
-{
- TQString fileName;
-
- // Downloads file if need (if url is "http://...")
- if (!(TDEIO::NetAccess::download(urlFile, fileName, 0)))
- return;
-
- // Checks it's not a directory
- TQFileInfo fileInfo;
- fileInfo.setFile(fileName);
- if(fileInfo.isDir())
- {
- KMessageBox::error(m_w, i18n("Cannot open folders."));
- return;
- }
-
- loadRulesFile(fileName);
- updateGUI();
-}
-
void TDEFileReplacePart::slotOptionRecursive()
{
m_option->m_recursive = !m_option->m_recursive;
@@ -553,8 +520,7 @@ void TDEFileReplacePart::initGUI()
(void)new TDEAction(i18n("&Delete String"), "editremove", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsDeleteItem()), actionCollection(), "strings_del");
(void)new TDEAction(i18n("&Empty Strings List"), "edit-delete", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsEmpty()), actionCollection(), "strings_empty");
(void)new TDEAction(i18n("&Save Strings List to File..."), "document-save-as", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsSave()), actionCollection(), "strings_save");
- (void)new TDEAction(i18n("&Load Strings List From File..."), "unsortedList", 0, TQT_TQOBJECT(this), TQT_SLOT(slotStringsLoad()), actionCollection(), "strings_load");
- (void)new TDERecentFilesAction(i18n("&Load Recent Strings Files"), "document-open", 0, TQT_TQOBJECT(this), TQT_SLOT(slotOpenRecentStringFile(const KURL&)), actionCollection(),"strings_load_recent");
+ (void)new TDEAction(i18n("&Load Strings List From File..."), "unsortedList", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsLoad()), actionCollection(), "strings_load");
(void)new TDEAction(i18n("&Invert Current String (search <--> replace)"), "invert", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsInvertCur()), actionCollection(), "strings_invert");
(void)new TDEAction(i18n("&Invert All Strings (search <--> replace)"), "invert", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotStringsInvertAll()), actionCollection(), "strings_invert_all");
@@ -654,8 +620,6 @@ void TDEFileReplacePart::loadOptions()
{
m_config->setGroup("General Options");
- m_option->m_recentStringFileList = m_config->readListEntry(rcRecentFiles);
-
m_option->m_searchingOnlyMode = m_config->readBoolEntry(rcSearchMode,SearchModeOption);
m_config->setGroup("Options");
@@ -793,7 +757,6 @@ void TDEFileReplacePart::saveOptions()
{
m_config->setGroup("General Options");
- m_config->writeEntry(rcRecentFiles, m_option->m_recentStringFileList);
m_config->writeEntry(rcSearchMode,m_option->m_searchingOnlyMode);
m_config->setGroup("Options");
@@ -1525,89 +1488,6 @@ void TDEFileReplacePart::loadViewContent()
m_replacementMap = tempMap;
}
-void TDEFileReplacePart::loadRulesFile(const TQString& fileName)
-{
- // Loads a file with kfr extension, creates a xml document and browses it
- TQDomDocument doc("mydocument");
- TQFile file(fileName);
- TDEListView* sv = m_view->getStringsView();
-
- if(!file.open(IO_ReadOnly))
- {
- KMessageBox::error(m_w, i18n("<qt>Cannot open the file <b>%1</b> and load the string list.</qt>").arg(fileName));
- return ;
- }
-
- if(!doc.setContent(&file))
- {
- file.close();
-
- KMessageBox::information(m_w, i18n("<qt>File <b>%1</b> seems not to be written in new kfr format. Remember that the old kfr format will be soon abandoned. You can convert your old rules files by simply saving them with tdefilereplace.</qt>").arg(fileName),i18n("Warning"));
-
- TDEFileReplaceLib::convertOldToNewKFRFormat(fileName, sv);
-
- return;
- }
- else
- file.close();
-
- //clears view
- sv->clear();
-
- TQDomElement docElem = doc.documentElement();
- TQDomNode n = docElem.firstChild();
- TQString searchAttribute = n.toElement().attribute("search").latin1();
-
- KeyValueMap docMap;
-
- if(searchAttribute.isNull() || searchAttribute.isEmpty())
- {
- int answer = KMessageBox::warningYesNo(m_w, i18n("<qt>The format of kfr files has been changed; attempting to load <b>%1</b>. Please see the KFilereplace manual for details. Do you want to load a search-and-replace list of strings?</qt>").arg(fileName),i18n("Warning"),i18n("Load"),i18n("Do Not Load"));
-
- if(answer == KMessageBox::Yes)
- searchAttribute = "false";
- else
- searchAttribute = "true";
- }
- //Verifies the search mode
- if(searchAttribute == "true")
- m_option->m_searchingOnlyMode = true;
- else
- m_option->m_searchingOnlyMode = false;
-
- //Refreshes the view appearances
- m_view->changeView(m_option->m_searchingOnlyMode);
- //Goes to next tag
- n = n.nextSibling();
- //Reads the string list
- while(!n.isNull())
- {
- TQDomElement e = n.toElement(); // tries to convert the node to an element.
- if(!e.isNull())
- {
- TQString oldString = e.firstChild().toElement().text(),
- newString = e.lastChild().toElement().text();
- docMap[oldString] = newString;
- }
- n = n.nextSibling();
- }
-
- // Adds file to "load strings from file" menu
- TQStringList fileList = m_option->m_recentStringFileList;
- if(!fileList.contains(fileName))
- {
- fileList.append(fileName);
- ((TDERecentFilesAction* ) actionCollection()->action("strings_load_recent"))->setItems(fileList);
- m_option->m_recentStringFileList = fileList;
- }
-
- m_view->changeView(m_option->m_searchingOnlyMode);
-
- m_view->loadMap(docMap);
-
- updateGUI();
-}
-
bool TDEFileReplacePart::launchNewProjectDialog(const KURL & startURL)
{
if(!startURL.isEmpty())