summaryrefslogtreecommitdiffstats
path: root/tdefilereplace/tdefilereplaceview.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2019-06-18 22:59:34 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2019-06-18 22:59:34 +0900
commit588b1440b578cff0a4614a52946b978039ee6f7c (patch)
tree0d4377364809a2aff1b92ad6f99387a58eab8338 /tdefilereplace/tdefilereplaceview.cpp
parent75fedf7ef28b7f62c19f39a2229d6cc1ec9376e3 (diff)
downloadtdeutils-588b1440b578cff0a4614a52946b978039ee6f7c.tar.gz
tdeutils-588b1440b578cff0a4614a52946b978039ee6f7c.zip
tdefilereplace:
1) fixed delete button logic 2) added remove entry functionality Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdefilereplace/tdefilereplaceview.cpp')
-rw-r--r--tdefilereplace/tdefilereplaceview.cpp87
1 files changed, 57 insertions, 30 deletions
diff --git a/tdefilereplace/tdefilereplaceview.cpp b/tdefilereplace/tdefilereplaceview.cpp
index 4bf7319..dd23ad5 100644
--- a/tdefilereplace/tdefilereplaceview.cpp
+++ b/tdefilereplace/tdefilereplaceview.cpp
@@ -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,