tdefilereplace:

1) fixed delete button logic
2) added remove entry functionality

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/11/head
Michele Calgaro 5 years ago
parent 75fedf7ef2
commit 588b1440b5
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -501,9 +501,13 @@ void TDEFileReplacePart::resetActions()
// Results // Results
actionCollection()->action("results_infos")->setEnabled(hasItems); actionCollection()->action("results_infos")->setEnabled(hasItems);
actionCollection()->action("results_openfile")->setEnabled(hasItems); actionCollection()->action("results_openfile")->setEnabled(hasItems);
actionCollection()->action("results_openfilewith")->setEnabled(hasItems);
if (actionCollection()->action("results_editfile")) if (actionCollection()->action("results_editfile"))
{
actionCollection()->action("results_editfile")->setEnabled(hasItems); actionCollection()->action("results_editfile")->setEnabled(hasItems);
}
actionCollection()->action("results_opendir")->setEnabled(hasItems); actionCollection()->action("results_opendir")->setEnabled(hasItems);
actionCollection()->action("results_removeentry")->setEnabled(hasItems);
actionCollection()->action("results_delete")->setEnabled(hasItems); actionCollection()->action("results_delete")->setEnabled(hasItems);
actionCollection()->action("results_treeexpand")->setEnabled(hasItems); actionCollection()->action("results_treeexpand")->setEnabled(hasItems);
actionCollection()->action("results_treereduce")->setEnabled(hasItems); actionCollection()->action("results_treereduce")->setEnabled(hasItems);
@ -606,13 +610,15 @@ void TDEFileReplacePart::initGUI()
// Results // Results
(void)new TDEAction(i18n("&Properties"), "informations", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultProperties()), actionCollection(), "results_infos"); (void)new TDEAction(i18n("&Properties"), "informations", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultProperties()), actionCollection(), "results_infos");
(void)new TDEAction(i18n("&Open"), "document-new", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultOpen()), actionCollection(), "results_openfile"); (void)new TDEAction(i18n("&Open"), "document-open", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultOpen()), actionCollection(), "results_openfile");
(void)new TDEAction(i18n("Open &With..."), "document-open", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultOpen()), actionCollection(), "results_openfilewith");
if(quantaFound) if(quantaFound)
{ {
(void)new TDEAction(i18n("&Edit in Quanta"), "quanta", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultEdit()), actionCollection(), "results_editfile"); (void)new TDEAction(i18n("&Edit in Quanta"), "quanta", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultEdit()), actionCollection(), "results_editfile");
} }
(void)new TDEAction(i18n("Open Parent &Folder"), "document-open", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultDirOpen()), actionCollection(), "results_opendir"); (void)new TDEAction(i18n("Open Parent &Folder"), "go-up", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultDirOpen()), actionCollection(), "results_opendir");
(void)new TDEAction(i18n("Remove &Entry"), "edit-clear", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultRemoveEntry()), actionCollection(), "results_removeentry");
(void)new TDEAction(i18n("&Delete"), "edit-delete", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultDelete()), actionCollection(), "results_delete"); (void)new TDEAction(i18n("&Delete"), "edit-delete", 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultDelete()), actionCollection(), "results_delete");
(void)new TDEAction(i18n("E&xpand Tree"), 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultTreeExpand()), actionCollection(), "results_treeexpand"); (void)new TDEAction(i18n("E&xpand Tree"), 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultTreeExpand()), actionCollection(), "results_treeexpand");
(void)new TDEAction(i18n("&Reduce Tree"), 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultTreeReduce()), actionCollection(), "results_treereduce"); (void)new TDEAction(i18n("&Reduce Tree"), 0, TQT_TQOBJECT(m_view), TQT_SLOT(slotResultTreeReduce()), actionCollection(), "results_treereduce");
@ -659,8 +665,11 @@ void TDEFileReplacePart::freezeActions()
actionCollection()->action("results_infos")->setEnabled(false); actionCollection()->action("results_infos")->setEnabled(false);
actionCollection()->action("results_openfile")->setEnabled(false); actionCollection()->action("results_openfile")->setEnabled(false);
if (actionCollection()->action("results_editfile")) if (actionCollection()->action("results_editfile"))
{
actionCollection()->action("results_editfile")->setEnabled(false); actionCollection()->action("results_editfile")->setEnabled(false);
}
actionCollection()->action("results_opendir")->setEnabled(false); actionCollection()->action("results_opendir")->setEnabled(false);
actionCollection()->action("results_removeentry")->setEnabled(false);
actionCollection()->action("results_delete")->setEnabled(false); actionCollection()->action("results_delete")->setEnabled(false);
actionCollection()->action("results_treeexpand")->setEnabled(false); actionCollection()->action("results_treeexpand")->setEnabled(false);
actionCollection()->action("results_treereduce")->setEnabled(false); actionCollection()->action("results_treereduce")->setEnabled(false);

@ -1,5 +1,5 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="tdefilereplace" version="6"> <kpartgui name="tdefilereplace" version="7">
<MenuBar> <MenuBar>
<Menu name="tdefilerepace"><text>Search/&amp;Replace</text> <Menu name="tdefilerepace"><text>Search/&amp;Replace</text>
<Action name="new_project"/> <Action name="new_project"/>
@ -23,8 +23,10 @@
</Menu> </Menu>
<Menu name="results"><text>&amp;Results</text> <Menu name="results"><text>&amp;Results</text>
<Action name="results_openfile"/> <Action name="results_openfile"/>
<Action name="results_opendir"/> <Action name="results_openfilewith"/>
<Action name="results_editfile"/> <Action name="results_editfile"/>
<Action name="results_opendir"/>
<Action name="results_removeentry"/>
<Action name="results_delete"/> <Action name="results_delete"/>
<Action name="results_infos"/> <Action name="results_infos"/>
<Separator/> <Separator/>

@ -74,17 +74,31 @@ TDEFileReplaceView::TDEFileReplaceView(RCOptions* info, TQWidget *parent,const c
whatsThis(); whatsThis();
} }
TQString TDEFileReplaceView::currentPath() TQString TDEFileReplaceView::getItemPath(const TQListViewItem *lvi)
{ {
TQListViewItem *lvi; if (!lvi)
{
if(! m_lviCurrent) lvi = m_rv->currentItem(); return TQString::null;
else lvi = (TQListViewItem*) m_lviCurrent; }
return TQString(lvi->text(1)+"/"+lvi->text(0));
}
TQListViewItem* TDEFileReplaceView::getCurrItemTopLevelParent()
{
TQListViewItem *lvi;
if (!m_lviCurrent)
{
lvi = m_rv->currentItem();
}
else
{
lvi = (TQListViewItem*)m_lviCurrent;
}
while (lvi->parent()) while (lvi->parent())
{
lvi = lvi->parent(); lvi = lvi->parent();
}
return TQString(lvi->text(1)+"/"+lvi->text(0)); return lvi;
} }
void TDEFileReplaceView::showSemaphore(TQString s) void TDEFileReplaceView::showSemaphore(TQString s)
@ -216,10 +230,10 @@ void TDEFileReplaceView::slotResultReturnPressed (TQListViewItem *lvi)
void TDEFileReplaceView::slotResultProperties() void TDEFileReplaceView::slotResultProperties()
{ {
TQString currItem = currentPath(); TQString currItemPath = getItemPath(getCurrItemTopLevelParent());
if(! currItem.isEmpty()) if (!currItemPath.isEmpty())
{ {
KURL url(currItem); KURL url(currItemPath);
(void) new KPropertiesDialog(url); (void) new KPropertiesDialog(url);
m_lviCurrent = 0; m_lviCurrent = 0;
} }
@ -227,21 +241,21 @@ void TDEFileReplaceView::slotResultProperties()
void TDEFileReplaceView::slotResultOpen() void TDEFileReplaceView::slotResultOpen()
{ {
TQString currItem = currentPath(); TQString currItemPath = getItemPath(getCurrItemTopLevelParent());
if(!currItem.isEmpty()) if (!currItemPath.isEmpty())
{ {
(void) new KRun(KURL(currItem), 0, true, true); (void) new KRun(KURL(currItemPath), 0, true, true);
m_lviCurrent = 0; m_lviCurrent = 0;
} }
} }
void TDEFileReplaceView::slotResultOpenWith() void TDEFileReplaceView::slotResultOpenWith()
{ {
TQString currItem = currentPath(); TQString currItemPath = getItemPath(getCurrItemTopLevelParent());
if(!currItem.isEmpty()) if (!currItemPath.isEmpty())
{ {
KURL::List kurls; KURL::List kurls;
kurls.append(KURL(currItem)); kurls.append(KURL(currItemPath));
KRun::displayOpenWithDialog(kurls); KRun::displayOpenWithDialog(kurls);
m_lviCurrent = 0; m_lviCurrent = 0;
} }
@ -249,11 +263,11 @@ void TDEFileReplaceView::slotResultOpenWith()
void TDEFileReplaceView::slotResultDirOpen() void TDEFileReplaceView::slotResultDirOpen()
{ {
TQString currItem = currentPath(); TQString currItemPath = getItemPath(getCurrItemTopLevelParent());
if(!currItem.isEmpty()) if (!currItemPath.isEmpty())
{ {
TQFileInfo fi; TQFileInfo fi;
fi.setFile(currItem); fi.setFile(currItemPath);
(void) new KRun (KURL::fromPathOrURL(fi.dirPath()), 0, true, true); (void) new KRun (KURL::fromPathOrURL(fi.dirPath()), 0, true, true);
m_lviCurrent = 0; m_lviCurrent = 0;
} }
@ -304,21 +318,32 @@ void TDEFileReplaceView::slotResultEdit()
m_lviCurrent = 0; m_lviCurrent = 0;
} }
void TDEFileReplaceView::slotResultRemoveEntry()
{
TQListViewItem *currItem = getCurrItemTopLevelParent();
if (currItem)
{
delete currItem;
m_lviCurrent = 0;
}
}
void TDEFileReplaceView::slotResultDelete() void TDEFileReplaceView::slotResultDelete()
{ {
TQString currItem = currentPath(); TQListViewItem *currItem = getCurrItemTopLevelParent();
if (!currItem.isEmpty()) TQString currItemPath = getItemPath(currItem);
if (currItem)
{ {
TQFile fi; TQFile fi;
int answer = KMessageBox::warningContinueCancel(this, i18n("Do you really want to delete %1?").arg(currItem), int answer = KMessageBox::warningContinueCancel(this, i18n("Do you really want to delete %1?").arg(currItemPath),
TQString(),KStdGuiItem::del()); TQString(),KStdGuiItem::del());
if(answer == KMessageBox::Continue) if(answer == KMessageBox::Continue)
{ {
fi.setName(currItem); fi.setName(currItemPath);
fi.remove(); fi.remove();
delete m_lviCurrent; delete currItem;
m_lviCurrent = 0; m_lviCurrent = 0;
} }
} }
@ -549,12 +574,10 @@ void TDEFileReplaceView::initGUI()
i18n("&Open"), i18n("&Open"),
this, this,
TQT_SLOT(slotResultOpen())); TQT_SLOT(slotResultOpen()));
if(!quantaFound) m_menuResult->insertItem(SmallIconSet(TQString::fromLatin1("document-open")),
{ i18n("Open &With..."),
m_menuResult->insertItem(i18n("Open &With..."), this,
this, TQT_SLOT(slotResultOpenWith()));
TQT_SLOT(slotResultOpenWith()));
}
if(quantaFound) if(quantaFound)
{ {
@ -568,6 +591,10 @@ void TDEFileReplaceView::initGUI()
i18n("Open Parent &Folder"), i18n("Open Parent &Folder"),
this, this,
TQT_SLOT(slotResultDirOpen())); TQT_SLOT(slotResultDirOpen()));
m_menuResult->insertItem(SmallIconSet(TQString::fromLatin1("edit-clear")),
i18n("Remove &Entry"),
this,
TQT_SLOT(slotResultRemoveEntry()));
m_menuResult->insertItem(SmallIconSet(TQString::fromLatin1("edit-delete")), m_menuResult->insertItem(SmallIconSet(TQString::fromLatin1("edit-delete")),
i18n("&Delete"), i18n("&Delete"),
this, this,

@ -62,7 +62,8 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg
TDEFileReplaceView(RCOptions* info, TQWidget *parent,const char *name); TDEFileReplaceView(RCOptions* info, TQWidget *parent,const char *name);
public: public:
TQString currentPath(); TQString getItemPath(const TQListViewItem *lvi);
TQListViewItem* getCurrItemTopLevelParent();
void showSemaphore(TQString s); void showSemaphore(TQString s);
void displayScannedFiles(int foldersNumber, int filesNumber); void displayScannedFiles(int foldersNumber, int filesNumber);
void stringsInvert(bool invertAll); void stringsInvert(bool invertAll);
@ -83,6 +84,7 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg
void slotResultOpenWith(); void slotResultOpenWith();
void slotResultDirOpen(); void slotResultDirOpen();
void slotResultEdit(); void slotResultEdit();
void slotResultRemoveEntry();
void slotResultDelete(); void slotResultDelete();
void slotResultTreeExpand(); void slotResultTreeExpand();
void slotResultTreeReduce(); void slotResultTreeReduce();

Loading…
Cancel
Save