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
actionCollection()->action("results_infos")->setEnabled(hasItems);
actionCollection()->action("results_openfile")->setEnabled(hasItems);
actionCollection()->action("results_openfilewith")->setEnabled(hasItems);
if (actionCollection()->action("results_editfile"))
{
actionCollection()->action("results_editfile")->setEnabled(hasItems);
}
actionCollection()->action("results_opendir")->setEnabled(hasItems);
actionCollection()->action("results_removeentry")->setEnabled(hasItems);
actionCollection()->action("results_delete")->setEnabled(hasItems);
actionCollection()->action("results_treeexpand")->setEnabled(hasItems);
actionCollection()->action("results_treereduce")->setEnabled(hasItems);
@ -606,13 +610,15 @@ void TDEFileReplacePart::initGUI()
// Results
(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)
{
(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("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");
@ -659,8 +665,11 @@ void TDEFileReplacePart::freezeActions()
actionCollection()->action("results_infos")->setEnabled(false);
actionCollection()->action("results_openfile")->setEnabled(false);
if (actionCollection()->action("results_editfile"))
{
actionCollection()->action("results_editfile")->setEnabled(false);
}
actionCollection()->action("results_opendir")->setEnabled(false);
actionCollection()->action("results_removeentry")->setEnabled(false);
actionCollection()->action("results_delete")->setEnabled(false);
actionCollection()->action("results_treeexpand")->setEnabled(false);
actionCollection()->action("results_treereduce")->setEnabled(false);

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

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

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

Loading…
Cancel
Save