summaryrefslogtreecommitdiffstats
path: root/kfind
diff options
context:
space:
mode:
Diffstat (limited to 'kfind')
-rw-r--r--kfind/AUTHORS18
-rw-r--r--kfind/CMakeLists.txt61
-rw-r--r--kfind/ChangeLog141
-rw-r--r--kfind/Kfind.desktop79
-rw-r--r--kfind/Makefile.am36
-rw-r--r--kfind/README24
-rw-r--r--kfind/TODO13
-rw-r--r--kfind/findpart.desktop82
-rw-r--r--kfind/hi16-app-kfind.pngbin0 -> 996 bytes
-rw-r--r--kfind/hi22-app-kfind.pngbin0 -> 1417 bytes
-rw-r--r--kfind/hi32-app-kfind.pngbin0 -> 2247 bytes
-rw-r--r--kfind/hi48-app-kfind.pngbin0 -> 4298 bytes
-rw-r--r--kfind/hi64-app-kfind.pngbin0 -> 6131 bytes
-rw-r--r--kfind/kdatecombo.cpp131
-rw-r--r--kfind/kdatecombo.h49
-rw-r--r--kfind/kfind.cpp192
-rw-r--r--kfind/kfind.h64
-rw-r--r--kfind/kfinddlg.cpp293
-rw-r--r--kfind/kfinddlg.h69
-rw-r--r--kfind/kfindpart.cpp213
-rw-r--r--kfind/kfindpart.desktop87
-rw-r--r--kfind/kfindpart.h104
-rw-r--r--kfind/kfindpart.kdevprj178
-rw-r--r--kfind/kfindpart.kdevses20
-rw-r--r--kfind/kftabdlg.cpp871
-rw-r--r--kfind/kftabdlg.h136
-rw-r--r--kfind/kfwin.cpp434
-rw-r--r--kfind/kfwin.h75
-rw-r--r--kfind/kquery.cpp532
-rw-r--r--kfind/kquery.h102
-rw-r--r--kfind/main.cpp65
-rw-r--r--kfind/pics/CMakeLists.txt12
-rw-r--r--kfind/pics/Makefile.am2
-rw-r--r--kfind/pics/lo22-action-archive.pngbin0 -> 508 bytes
-rw-r--r--kfind/pics/lo22-action-delete.pngbin0 -> 473 bytes
-rw-r--r--kfind/pics/lo22-action-idea.pngbin0 -> 407 bytes
-rw-r--r--kfind/pics/lo22-action-info.pngbin0 -> 420 bytes
-rw-r--r--kfind/pics/lo22-action-openfile.pngbin0 -> 328 bytes
-rw-r--r--kfind/pics/lo22-action-save.pngbin0 -> 360 bytes
-rw-r--r--kfind/pics/lo22-action-search.pngbin0 -> 365 bytes
-rw-r--r--kfind/version.h3
41 files changed, 4086 insertions, 0 deletions
diff --git a/kfind/AUTHORS b/kfind/AUTHORS
new file mode 100644
index 000000000..cf0c32eb6
--- /dev/null
+++ b/kfind/AUTHORS
@@ -0,0 +1,18 @@
+kfind has been developed by :
+
+ Eric Coquelle <[email protected]>
+ Beppe Grimaldi <[email protected]>
+ Martin Hartig
+ Stephan Kulow <[email protected]>
+ Mario Weilguni <[email protected]>
+ Alex Zepeda <[email protected]>
+ Miroslav Fl�r <[email protected]>
+ Harri Porten <[email protected]>
+ Dima Rogozin <[email protected]>
+ Carsten Pfeiffer <[email protected]>
+ Hans Petter Bieker <[email protected]>
+ Waldo Bastian <[email protected]>
+ Alexander Neundorf <[email protected]>
+ Albert R. Valiev <[email protected]>
+ Clarence Dang <[email protected]>
+
diff --git a/kfind/CMakeLists.txt b/kfind/CMakeLists.txt
new file mode 100644
index 000000000..4162c1319
--- /dev/null
+++ b/kfind/CMakeLists.txt
@@ -0,0 +1,61 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+if( NOT BUILD_LIBKONQ )
+ include( "${TDE_CMAKE_DIR}/libkonq.cmake" )
+endif( NOT BUILD_LIBKONQ )
+
+add_subdirectory( pics )
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/libkonq
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### other data ################################
+
+tde_install_icons( kfind )
+install( FILES Kfind.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
+install( FILES kfindpart.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+install( FILES findpart.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
+
+
+##### libkfindpart (module) #####################
+
+tde_add_kpart( libkfindpart AUTOMOC
+ SOURCES kfindpart.cpp
+ LINK kfind_common-static konq-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
+
+
+##### kfind (executable) ######################
+
+tde_add_executable( kfind AUTOMOC
+ SOURCES kfwin.cpp kfinddlg.cpp main.cpp
+ LINK kfind_common-static
+ DESTINATION ${BIN_INSTALL_DIR}
+)
+
+
+##### kfind_common (static) #####################
+
+tde_add_library( kfind_common STATIC_PIC AUTOMOC
+ SOURCES kftabdlg.cpp kfind.cpp kquery.cpp kdatecombo.cpp
+ LINK tdeparts-shared
+)
diff --git a/kfind/ChangeLog b/kfind/ChangeLog
new file mode 100644
index 000000000..18b80091a
--- /dev/null
+++ b/kfind/ChangeLog
@@ -0,0 +1,141 @@
+Fri Jul 30 22:33:25 1999 Carsten Pfeiffer <[email protected]>
+
+ * kfwin.cpp, kfwin.h: The listview items show a mini-pixmap, like those
+ in tdefiledialog. For now, they're static icons (only folder and document
+ icons), maybe we can show the correct icons for the mimetypes, later.
+
+ Also introduced drag-support, you can drag files from the list.
+
+ * kftabdlg.cpp: accept Key_Enter to start the search, too.
+
+1999-06-13 Harri Porten <[email protected]>
+
+ * kftabdlg.cpp: introduced flexible geometry managment. Patch provided
+ by Dima Rogozin <[email protected]>.
+
+1999-04-30 Harri Porten <[email protected]>
+
+ * kftabdlg.cpp: Default to '*' when no filenames are specified and
+ allow case insensitive text search. Patch provided by Dima Rogozin
+
+1999-04-06 Harri Porten <[email protected]>
+
+ * kfind.cpp: replaced simple delete and free() with delete [] iBuffer
+
+1998-12-07 Mario Weilguni <[email protected]>
+
+ * made it work with Qt 2.0
+
+1998-12-07 Alex Zepeda <[email protected]>
+
+ * kfindtop.cpp: Commented out _height, as it's not used.
+
+1998-11-30 Miroslav Fl�dr <[email protected]>
+
+ * Dissabled multiple selection in view because it was not fully
+ handled
+ * Fixed problem in nameBox, dirBox combos which caused improper
+ find query generation (it is still neccesary to fix multiplication of
+ list entries)
+
+1998-10-23 Alex Zepeda <[email protected]>
+
+ * LICENSE: remove it, it's redundant.
+
+ * kfind/README: Tidy up, and mention inclusion in tdebase.
+
+ver. 0.4.1: Mario Weilguni <[email protected]>
+ * temporary files are no longer needed
+ * found files are now shown while searching
+ * KDE compliant "Help" menu
+ * max-/min-size box is now disabled per default
+ * GUI is disabled while searching, makes it easier to see
+ progress
+ * kfind compiles now without warnings with -Wall
+ * result list is now scrollable without having the focus (only page
+ up and page down)
+ * moc files are now #included in moc.cpp instead of compiling
+ separate files. Speeds up compilation and makes binary smaller
+ * file patterns are remembered between sessions
+ * introduced new filetypes for searching: files, folders,
+ symlinks, special files, executables, suid executables
+ * better keyboard support
+
+ver. 0.4: Mario Weilguni <[email protected]>
+ * introduced this ChangeLog
+ * kfind now uses KShellProcess instead of TDEProcess, makes
+ regular expression search possible with egrep/xargs
+ * kftabdlg.cpp: tab-dialog isn't closed anymore if Escape key
+ is pressed
+ * kfind can now search for contained text (with egrep)
+ * "Select All" and "Invert Selection" work now as expected
+ * "Copy" copies the currently selected items to the X11 selection
+ * "Unselect All" added for completeness
+
+ver. 0.3.4:
+
+ o removed some resizing problems
+ o kfinds icons now uses only 16 color
+ o mimetype browser removed from preferences
+ (something like that should be in kcc)
+ o kfind sets icon for kwmII
+
+ver. 0.3.3:
+
+ o uses TDEProcess
+ o supports other languages then english (at this time german and czech)
+
+ver. 0.3.2:
+
+ o uses KTopLevelWidget and TDEToolBar
+ o new documentations
+
+ver. 0.3.1:
+ o new documentation contributed by Mark Roberts
+
+ver. 0.3:
+ o entry Open in File menu or doubleclick on file executes default binding
+ o removed bug causing segfaults
+
+ver. 0.2.9:
+ o uses of autoconf
+ o you can specify searched directory as kfind argument
+ o added Icon entry in all provided filetypes (some were
+ missing this entry and kfm didn't liked it)
+
+ver. 0.2.8:
+ o kfind is now KDE AWARE application!!
+ o uses libkde0.7 (=> kmsgbox and ktabctl removed from kfind distribution)
+ o uses filetypes introduced by Torben Weis for kfm (kfind installs
+ some more filetypes)
+ o it is possible to store files in archives
+ o preferences dialog added
+ - it is possible to determine filename for results saving
+ - it is possible to browse available filetypes details
+ - it is possible to browse available archivers details
+ (in next version you will be able to change the details)
+ o calls kfm for properties dialog
+ o menu entry "remove" removed (kfm properties dialog does the job)
+ o removed some bugs
+
+ver. 0.2.6:
+ o reflects changes made by Martin Hartig (known as version 0.2.1)
+
+ver. 0.2.5:
+ o implemented dir selection box (it is actually a littlebit changed
+ and striped down version of QFileDialog)
+ o delete, rename, properties functions are implemented
+ o function "Open containing folder" implemented (it calls KFM)
+ o search results are now saved in file ~/.kfind-results.html
+ (I finally recognized this is better choice than plain text file)
+ o removed nasty bug causing segfaults when compiler optimization were
+ used
+ o improved Makefile
+
+ver. 0.2:
+ o all in kfind available options work now ;-))
+ o better calling of find. It's now separate process => interface isn't
+ blocked anymore during searching
+
+ver. 0.1: first official release
diff --git a/kfind/Kfind.desktop b/kfind/Kfind.desktop
new file mode 100644
index 000000000..92352a990
--- /dev/null
+++ b/kfind/Kfind.desktop
@@ -0,0 +1,79 @@
+[Desktop Entry]
+Exec=kfind %f
+Icon=kfind
+X-DocPath=kfind/index.html
+Path=
+Type=Application
+Terminal=false
+Name=Find Files/Folders
+Name[af]=Soek Lêers/Gidse
+Name[ar]=إبحث عن ملفات/مجلّدات
+Name[be]=Шукаць файлы/тэчкі
+Name[bg]=Търсене на файлове
+Name[bn]=ফাইল/ফোল্ডার অনুসন্ধান
+Name[br]=Klask restroù/renkelloù
+Name[bs]=Pronađi datoteke
+Name[ca]=Cerca fitxers i carpetes
+Name[cs]=Najít soubory/složky
+Name[csb]=Szëkba lopków/katalogów
+Name[da]=Find filer/mapper
+Name[de]=Dateien/Ordner suchen
+Name[el]=Αναζήτηση αρχείων/φακέλων
+Name[eo]=Trovu Dosierojn/Dosierujojn
+Name[es]=Buscar archivos/carpetas
+Name[et]=Failide/kataloogide otsimine
+Name[eu]=Bilatu fitxategiak/karpetak
+Name[fa]=یافتن پرونده‌ها/پوشه‌ها
+Name[fi]=Etsi tiedostoja ja kansioita
+Name[fr]=Recherche de fichiers/dossiers
+Name[fy]=Triemmen/mappen sykje
+Name[ga]=Aimsigh Comhaid/Comhadlanna
+Name[gl]=Buscar Ficheiros/Cartafoles
+Name[he]=חפש קבצים או תיקיות
+Name[hr]=Traži datoteke/mape
+Name[hu]=Fájlkereső
+Name[is]=Finna skrár/möppur
+Name[it]=Trova file/cartelle
+Name[ja]=ファイル/フォルダを検索
+Name[ka]=ფაილთა და საქაღალდეთა ძიება
+Name[kk]=Файлды не қапшықты табу
+Name[km]=រក​ឯកសារ/ថត
+Name[ko]=파일/폴더 찾기
+Name[lt]=Rasti bylas/aplankus
+Name[lv]=Meklēt Failus/Mapes
+Name[mk]=Пронајди датотеки/папки
+Name[ms]=Cari Fail/Folder
+Name[nb]=Finn filer/mapper
+Name[nds]=Dateien/Ornern söken
+Name[ne]=फाइल/फोल्डर फेला पार्नुहोस्
+Name[nl]=Bestanden/mappen zoeken
+Name[nn]=Finn filer/mapper
+Name[pa]=ਫਾਇਲ/ਫੋਲਡਰ ਖੋਜ
+Name[pl]=Wyszukiwanie plików/katalogów
+Name[pt]=Procurar Ficheiros/Pastas
+Name[pt_BR]=Procurar arquivos/pastas
+Name[ro]=Caută fișiere/foldere
+Name[ru]=Поиск файлов и папок
+Name[rw]=Gushaka Amadosiye/Ububiko
+Name[se]=Oza fiillaid dahje máhpaid
+Name[sk]=Hľadať súbory/priečinky
+Name[sl]=Najdi datoteke in mape
+Name[sr]=Тражење фајлова/фасцикли
+Name[sr@Latn]=Traženje fajlova/fascikli
+Name[sv]=Hitta filer eller kataloger
+Name[ta]=கோப்புகள்/அடைவுகளைக் கண்டுபிடி
+Name[te]=దస్త్రాలు/ఫొల్డర్లను వెతుకు
+Name[tg]=Ҷустуҷӯи файлҳо ва феҳрастҳо
+Name[th]=ค้นหาแฟ้ม/โฟลเดอร์
+Name[tr]=Dosya/Dizin Bul
+Name[tt]=Birem/Törgäk Ezläw
+Name[uk]=Пошук файлів та тек
+Name[uz]=Fayl/jildlarni qidirish
+Name[uz@cyrillic]=Файл/жилдларни қидириш
+Name[vi]=Tìm Tập tin/Thư mục
+Name[wa]=Trover des fitchîs/ridants
+Name[zh_CN]=查找文件/文件夹
+Name[zh_TW]=尋找檔案/資料夾
+X-TDE-StartupNotify=true
+OnlyShowIn=TDE;
+Categories=Qt;TDE;Core;
diff --git a/kfind/Makefile.am b/kfind/Makefile.am
new file mode 100644
index 000000000..96b033088
--- /dev/null
+++ b/kfind/Makefile.am
@@ -0,0 +1,36 @@
+#Global section
+METASOURCES = AUTO
+EXTRA_DIST = DESCRIPTION
+SUBDIRS = pics
+KDE_ICON = kfind
+# set the include path for X, qt and KDE
+INCLUDES= -I$(top_srcdir)/libkonq $(all_includes)
+
+noinst_LTLIBRARIES = libkfind_common.la
+libkfind_common_la_SOURCES = kftabdlg.cpp kfind.cpp kquery.cpp kdatecombo.cpp
+
+#This section is kfindpart
+kde_module_LTLIBRARIES = libkfindpart.la
+
+libkfindpart_la_SOURCES = kfindpart.cpp
+libkfindpart_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
+libkfindpart_la_LIBADD = libkfind_common.la $(LIB_TDEPARTS) $(top_builddir)/libkonq/libkonq.la
+
+noinst_HEADERS = kftabdlg.h kfind.h version.h kquery.h kdatecombo.h
+
+xdg_apps_DATA = Kfind.desktop
+
+kde_services_DATA = kfindpart.desktop
+kde_servicetypes_DATA = findpart.desktop
+
+messages:
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kfindpart.pot
+
+#And this is for kfind
+
+bin_PROGRAMS = kfind
+kfind_SOURCES = kfwin.cpp kfinddlg.cpp main.cpp
+kfind_LDADD = libkfind_common.la $(LIB_TDEPARTS)
+
+# the library search path.
+kfind_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor
diff --git a/kfind/README b/kfind/README
new file mode 100644
index 000000000..7b6c24890
--- /dev/null
+++ b/kfind/README
@@ -0,0 +1,24 @@
+kfind
+=====
+
+Kfind is a graphical replacement for the utility `find' inspired by
+the find utility from NT.
+
+At this time it is fully functional. All options available in kfind
+are working. You can save the results, delete, change properties of
+found files/directories and ask konqueror to open the directory
+containing this file or execute default binding.
+
+THANKS
+------
+
+I want to thank Alexander Sanda <[email protected]> for making
+KTabCtl which is used in Kfind and Torben Weis
+<[email protected]> for his wonderful file manager konqueror.
+
+
+I hope you will find this program somehow useful and I would
+appreciate any suggestions and comments.
+
+ Miroslav Fl�dr
diff --git a/kfind/TODO b/kfind/TODO
new file mode 100644
index 000000000..0bf6ac832
--- /dev/null
+++ b/kfind/TODO
@@ -0,0 +1,13 @@
+TODO
+====
+
+ o support the more esoterical features of find
+
+DONE:
+
+ o drag found files to somewhere
+ o some layout managment
+ o context menus
+ o get preference dialog to work
+ o find pattern history
+ o support for finding files belonging to somebody
diff --git a/kfind/findpart.desktop b/kfind/findpart.desktop
new file mode 100644
index 000000000..bc4732fcc
--- /dev/null
+++ b/kfind/findpart.desktop
@@ -0,0 +1,82 @@
+[Desktop Entry]
+Type=ServiceType
+X-TDE-ServiceType=Konqueror/FindPart
+X-TDE-Derived=Browser/View
+Name=Find Part
+Name[af]=Soek Deel
+Name[ar]=ابحث عن جزء
+Name[az]=Parça tap
+Name[be]=Модуль пошуку
+Name[bg]=Търсене на модули
+Name[bn]=পার্ট অনুসন্ধান
+Name[br]=Kavout perzh
+Name[bs]=Nađi dio
+Name[ca]=Cerca la part
+Name[cs]=Najít soubor
+Name[csb]=Mòduł szëkbë
+Name[cy]=Canfod Rhan
+Name[da]=Find del
+Name[de]=Einbettungsfähiges Programm (Komponente) suchen
+Name[el]=Part Αναζήτηση
+Name[eo]=Trovokomponento
+Name[es]=Buscar parte
+Name[et]=Failide otsimise komponent
+Name[eu]=Bilatu partea
+Name[fa]=یافتن جزء
+Name[fi]=Etsi osa
+Name[fr]=Composant de recherche
+Name[fy]=In diel sykje
+Name[ga]=Aimsigh Páirt
+Name[gl]=Busca
+Name[he]=רכיב חיפוש
+Name[hi]=हिस्सा ढूंढें
+Name[hr]=Pronađi dio
+Name[hu]=Keresési objektum
+Name[id]=Cari bagian
+Name[is]=Finna hluti
+Name[it]=Trova parte
+Name[ja]=検索パート
+Name[ka]=ძიება შემადგენლობის მიხედვით
+Name[kk]=Мазмұнынан табу
+Name[km]=រក​ផ្នែក
+Name[ko]=찾기 부분
+Name[lo]=ຄັ້ນຫາບາງສ່ວນ
+Name[lt]=Surasti dalį
+Name[lv]=Meklēt Daļu
+Name[mk]=Пронајди дел
+Name[mn]=Хэсэг хайх
+Name[ms]=Cari Bahagian
+Name[mt]=Sib Parti
+Name[nb]=Finn del
+Name[nds]=Söök-Komponent
+Name[ne]=भाग फेला पार्नुहोस्
+Name[nl]=Gedeelte zoeken
+Name[nn]=Finn del
+Name[nso]=Hwetsa Seripa
+Name[pa]=ਹਿੱਸੇ ਖੋਜ
+Name[pl]=Moduł szukania
+Name[pt]=Componente de Pesquisa
+Name[pt_BR]=Componente de Busca
+Name[ro]=Componentă de căutare
+Name[ru]=Поиск по содержимому
+Name[rw]=Gushaka Igice
+Name[se]=Oza osiid
+Name[sk]=Nájsť Part
+Name[sl]=Najdi del
+Name[sr]=Део за тражење
+Name[sr@Latn]=Deo za traženje
+Name[sv]=Sökdel
+Name[ta]=பகுதி கண்டுபிடி
+Name[te]=వెతుకు భాగం
+Name[tg]=Қисматро пайдо кунед
+Name[th]=ค้นหาบางส่วน
+Name[tr]=Parça bul
+Name[tt]=Eçtälek Ezläw
+Name[uk]=Складова пошуку
+Name[ven]=Todani tshipida
+Name[vi]=Tìm từng phần
+Name[wa]=Trover des pårteyes
+Name[xh]=Fumana Indawana
+Name[zh_CN]=查找部件
+Name[zh_TW]=尋找組件
+Name[zu]=Thola Ingxenye
diff --git a/kfind/hi16-app-kfind.png b/kfind/hi16-app-kfind.png
new file mode 100644
index 000000000..f2b60daa7
--- /dev/null
+++ b/kfind/hi16-app-kfind.png
Binary files differ
diff --git a/kfind/hi22-app-kfind.png b/kfind/hi22-app-kfind.png
new file mode 100644
index 000000000..647dc2196
--- /dev/null
+++ b/kfind/hi22-app-kfind.png
Binary files differ
diff --git a/kfind/hi32-app-kfind.png b/kfind/hi32-app-kfind.png
new file mode 100644
index 000000000..171c2b1d2
--- /dev/null
+++ b/kfind/hi32-app-kfind.png
Binary files differ
diff --git a/kfind/hi48-app-kfind.png b/kfind/hi48-app-kfind.png
new file mode 100644
index 000000000..1d472379a
--- /dev/null
+++ b/kfind/hi48-app-kfind.png
Binary files differ
diff --git a/kfind/hi64-app-kfind.png b/kfind/hi64-app-kfind.png
new file mode 100644
index 000000000..fa5b5f0c4
--- /dev/null
+++ b/kfind/hi64-app-kfind.png
Binary files differ
diff --git a/kfind/kdatecombo.cpp b/kfind/kdatecombo.cpp
new file mode 100644
index 000000000..869753c5b
--- /dev/null
+++ b/kfind/kdatecombo.cpp
@@ -0,0 +1,131 @@
+/***********************************************************************
+ *
+ * kdatecombo.cpp
+ *
+ ***********************************************************************/
+
+#include <tqtimer.h>
+
+#include <tdeglobal.h>
+#include <tdelocale.h>
+#include <kdatepicker.h>
+#include <kdatetbl.h>
+#include <kdebug.h>
+
+#include "kdatecombo.h"
+
+#include "kdatecombo.moc"
+
+KDateCombo::KDateCombo(TQWidget *parent, const char *name ) : TQComboBox(FALSE, parent,name)
+{
+ TQDate date = TQDate::currentDate();
+ initObject(date, parent, name);
+}
+
+KDateCombo::KDateCombo(const TQDate & date, TQWidget *parent, const char *name) : TQComboBox(FALSE, parent,name)
+{
+ initObject(date, parent, name);
+}
+
+void KDateCombo::initObject(const TQDate & date, TQWidget *, const char *)
+{
+ clearValidator();
+ popupFrame = new TDEPopupFrame(this, "popupFrame");
+ popupFrame->installEventFilter(this);
+ datePicker = new KDatePicker(popupFrame, date, "datePicker");
+ datePicker->setMinimumSize(datePicker->sizeHint());
+ datePicker->installEventFilter(this);
+ popupFrame->setMainWidget(datePicker);
+ setDate(date);
+
+ connect(datePicker, TQT_SIGNAL(dateSelected(TQDate)), this, TQT_SLOT(dateEnteredEvent(TQDate)));
+}
+
+KDateCombo::~KDateCombo()
+{
+ delete datePicker;
+ delete popupFrame;
+}
+
+TQString KDateCombo::date2String(const TQDate & date)
+{
+ return(TDEGlobal::locale()->formatDate(date, true));
+}
+
+TQDate & KDateCombo::string2Date(const TQString & str, TQDate *qd)
+{
+ return *qd = TDEGlobal::locale()->readDate(str);
+}
+
+TQDate & KDateCombo::getDate(TQDate *currentDate)
+{
+ return string2Date(currentText(), currentDate);
+}
+
+bool KDateCombo::setDate(const TQDate & newDate)
+{
+ if (newDate.isValid())
+ {
+ if (count())
+ clear();
+ insertItem(date2String(newDate));
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void KDateCombo::dateEnteredEvent(TQDate newDate)
+{
+ if (!newDate.isValid())
+ newDate = datePicker->date();
+ popupFrame->hide();
+ setDate(newDate);
+}
+
+void KDateCombo::mousePressEvent (TQMouseEvent * e)
+{
+ if (e->button() & Qt::LeftButton)
+ {
+ if (TQT_TQRECT_OBJECT(rect()).contains( e->pos()))
+ {
+ TQDate tempDate;
+ getDate(& tempDate);
+ datePicker->setDate(tempDate);
+ popupFrame->popup(mapToGlobal(TQPoint(0, height())));
+ //datePicker->setFocus();
+ }
+ }
+}
+
+bool KDateCombo::eventFilter (TQObject*, TQEvent* e)
+{
+ if ( e->type() == TQEvent::MouseButtonPress )
+ {
+ TQMouseEvent *me = (TQMouseEvent *)e;
+ TQPoint p = mapFromGlobal( me->globalPos() );
+ if (TQT_TQRECT_OBJECT(rect()).contains( p ) )
+ {
+ TQTimer::singleShot(10, this, TQT_SLOT(dateEnteredEvent()));
+ return true;
+ }
+ }
+ else if ( e->type() == TQEvent::KeyRelease )
+ {
+ TQKeyEvent *k = (TQKeyEvent *)e;
+ //Press return == pick selected date and close the combo
+ if((k->key()==Qt::Key_Return)||(k->key()==Qt::Key_Enter))
+ {
+ dateEnteredEvent(datePicker->date());
+ return true;
+ }
+ else if (k->key()==Qt::Key_Escape)
+ {
+ popupFrame->hide();
+ return true;
+ }
+ else
+ return false;
+ }
+
+ return false;
+}
diff --git a/kfind/kdatecombo.h b/kfind/kdatecombo.h
new file mode 100644
index 000000000..d1aa3ecdc
--- /dev/null
+++ b/kfind/kdatecombo.h
@@ -0,0 +1,49 @@
+/***********************************************************************
+ *
+ * kdatecombo.h
+ *
+ ***********************************************************************/
+
+#ifndef KDATECOMBO_H
+#define KDATECOMBO_H
+
+#include <tqwidget.h>
+#include <tqcombobox.h>
+#include <tqdatetime.h>
+
+/**
+ *@author Beppe Grimaldi
+ */
+
+class KDatePicker;
+class TDEPopupFrame;
+
+class KDateCombo : public TQComboBox {
+ Q_OBJECT
+
+public:
+ KDateCombo(TQWidget *parent=0, const char *name=0);
+ KDateCombo(const TQDate & date, TQWidget *parent=0, const char *name=0);
+ ~KDateCombo();
+
+ TQDate & getDate(TQDate *currentDate);
+ bool setDate(const TQDate & newDate);
+
+private:
+ TDEPopupFrame * popupFrame;
+ KDatePicker * datePicker;
+
+ void initObject(const TQDate & date, TQWidget *parent, const char *name);
+
+ TQString date2String(const TQDate &);
+ TQDate & string2Date(const TQString &, TQDate * );
+
+protected:
+ bool eventFilter (TQObject*, TQEvent*);
+ virtual void mousePressEvent (TQMouseEvent * e);
+
+protected slots:
+ void dateEnteredEvent(TQDate d=TQDate());
+};
+
+#endif
diff --git a/kfind/kfind.cpp b/kfind/kfind.cpp
new file mode 100644
index 000000000..1675d9d71
--- /dev/null
+++ b/kfind/kfind.cpp
@@ -0,0 +1,192 @@
+/***********************************************************************
+ *
+ * Kfind.cpp
+ *
+ * This is KFind, released under GPL
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * KFind (c) 1998-2003 The KDE Developers
+ Martin Hartig
+ Stephan Kulow <[email protected]>
+ Mario Weilguni <[email protected]>
+ Alex Zepeda <[email protected]>
+ Miroslav Fl�dr <[email protected]>
+ Harri Porten <[email protected]>
+ Dima Rogozin <[email protected]>
+ Carsten Pfeiffer <[email protected]>
+ Hans Petter Bieker <[email protected]>
+ Waldo Bastian <[email protected]>
+ Beppe Grimaldi <[email protected]>
+ Eric Coquelle <[email protected]>
+
+ **********************************************************************/
+
+#include <kpushbutton.h>
+#include <tqlayout.h>
+#include <tqvbox.h>
+
+#include <kdialog.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <kseparator.h>
+#include <tqlineedit.h>
+#include <tqcheckbox.h>
+#include <kstdguiitem.h>
+
+#include "kftabdlg.h"
+#include "kquery.h"
+
+#include "kfind.moc"
+
+Kfind::Kfind(TQWidget *parent, const char *name)
+ : TQWidget( parent, name )
+{
+ kdDebug() << "Kfind::Kfind " << this << endl;
+ TQBoxLayout * mTopLayout = new TQBoxLayout( this, TQBoxLayout::LeftToRight,
+ KDialog::marginHint(), KDialog::spacingHint() );
+
+ // create tabwidget
+ tabWidget = new KfindTabWidget( this );
+ mTopLayout->addWidget(tabWidget);
+
+ /*
+ * This is ugly. Might be a KSeparator bug, but it makes a small black
+ * pixel for me which is visually distracting (GS).
+ // create separator
+ KSeparator * mActionSep = new KSeparator( this );
+ mActionSep->setFocusPolicy( TQWidget::ClickFocus );
+ mActionSep->setOrientation( TQFrame::VLine );
+ mTopLayout->addWidget(mActionSep);
+ */
+
+ // create button box
+ TQVBox * mButtonBox = new TQVBox( this );
+ TQVBoxLayout *lay = (TQVBoxLayout*)mButtonBox->layout();
+ lay->addStretch(1);
+ mTopLayout->addWidget(mButtonBox);
+
+ mSearch = new KPushButton( KGuiItem(i18n("&Find"), "edit-find"), mButtonBox );
+ mButtonBox->setSpacing( (tabWidget->sizeHint().height()-4*mSearch->sizeHint().height()) / 4);
+ connect( mSearch, TQT_SIGNAL(clicked()), this, TQT_SLOT( startSearch() ) );
+ mStop = new KPushButton( KGuiItem(i18n("Stop"), "process-stop"), mButtonBox );
+ connect( mStop, TQT_SIGNAL(clicked()), this, TQT_SLOT( stopSearch() ) );
+ mSave = new KPushButton( KStdGuiItem::saveAs(), mButtonBox );
+ connect( mSave, TQT_SIGNAL(clicked()), this, TQT_SLOT( saveResults() ) );
+
+ KPushButton * mClose = new KPushButton( KStdGuiItem::close(), mButtonBox );
+ connect( mClose, TQT_SIGNAL(clicked()), this, TQT_SIGNAL( destroyMe() ) );
+
+ // react to search requests from widget
+ connect( tabWidget, TQT_SIGNAL(startSearch()), this, TQT_SLOT( startSearch() ) );
+
+ mSearch->setEnabled(true); // Enable "Search"
+ mStop->setEnabled(false); // Disable "Stop"
+ mSave->setEnabled(false); // Disable "Save..."
+
+ dirlister=new KDirLister();
+}
+
+Kfind::~Kfind()
+{
+ stopSearch();
+ dirlister->stop();
+ delete dirlister;
+ kdDebug() << "Kfind::~Kfind" << endl;
+}
+
+void Kfind::setURL( const KURL &url )
+{
+ tabWidget->setURL( url );
+}
+
+void Kfind::startSearch()
+{
+ tabWidget->setQuery(query);
+ emit started();
+
+ //emit resultSelected(false);
+ //emit haveResults(false);
+
+ mSearch->setEnabled(false); // Disable "Search"
+ mStop->setEnabled(true); // Enable "Stop"
+ mSave->setEnabled(false); // Disable "Save..."
+
+ tabWidget->beginSearch();
+
+ dirlister->openURL(KURL(tabWidget->dirBox->currentText().stripWhiteSpace()));
+
+ query->start();
+}
+
+void Kfind::stopSearch()
+{
+ // will call KFindPart::slotResult, which calls searchFinished here
+ query->kill();
+}
+
+/*
+void Kfind::newSearch()
+{
+ // WABA: Not used any longer?
+ stopSearch();
+
+ tabWidget->setDefaults();
+
+ emit haveResults(false);
+ emit resultSelected(false);
+
+ setFocus();
+}
+*/
+
+void Kfind::searchFinished()
+{
+ mSearch->setEnabled(true); // Enable "Search"
+ mStop->setEnabled(false); // Disable "Stop"
+ // ## TODO mSave->setEnabled(true); // Enable "Save..."
+
+ tabWidget->endSearch();
+ setFocus();
+}
+
+
+void Kfind::saveResults()
+{
+ // TODO
+}
+
+void Kfind::setFocus()
+{
+ tabWidget->setFocus();
+}
+
+void Kfind::saveState( TQDataStream *stream )
+{
+ query->kill();
+ *stream << tabWidget->nameBox->currentText();
+ *stream << tabWidget->dirBox->currentText();
+ *stream << tabWidget->typeBox->currentItem();
+ *stream << tabWidget->textEdit->text();
+ *stream << (int)( tabWidget->subdirsCb->isChecked() ? 0 : 1 );
+}
+
+void Kfind::restoreState( TQDataStream *stream )
+{
+ TQString namesearched, dirsearched,containing;
+ int typeIdx;
+ int subdirs;
+ *stream >> namesearched;
+ *stream >> dirsearched;
+ *stream >> typeIdx;
+ *stream >> containing;
+ *stream >> subdirs;
+ tabWidget->nameBox->insertItem( namesearched, 0);
+ tabWidget->dirBox->insertItem ( dirsearched, 0);
+ tabWidget->typeBox->setCurrentItem(typeIdx);
+ tabWidget->textEdit->setText ( containing );
+ tabWidget->subdirsCb->setChecked( ( subdirs==0 ? true : false ));
+}
diff --git a/kfind/kfind.h b/kfind/kfind.h
new file mode 100644
index 000000000..fda0028ca
--- /dev/null
+++ b/kfind/kfind.h
@@ -0,0 +1,64 @@
+/***********************************************************************
+ *
+ * Kfind.h
+ *
+ ***********************************************************************/
+
+#ifndef KFIND_H
+#define KFIND_H
+
+#include <tqwidget.h>
+#include <tdefileitem.h>
+#include <kdirlister.h>
+
+class TQString;
+class KPushButton;
+
+class KQuery;
+class KURL;
+class KfindTabWidget;
+
+class Kfind: public TQWidget
+{
+ Q_OBJECT
+
+public:
+ Kfind(TQWidget * parent = 0, const char * name = 0);
+ ~Kfind();
+
+ void setURL( const KURL &url );
+
+ void setQuery(KQuery * q) { query = q; }
+ void searchFinished();
+
+ void saveState( TQDataStream *stream );
+ void restoreState( TQDataStream *stream );
+
+public slots:
+ void startSearch();
+ void stopSearch();
+ //void newSearch();
+ void saveResults();
+
+signals:
+ void haveResults(bool);
+ void resultSelected(bool);
+
+ void started();
+ void destroyMe();
+
+private:
+ void setFocus();
+ KfindTabWidget *tabWidget;
+ KPushButton *mSearch;
+ KPushButton *mStop;
+ KPushButton *mSave;
+ KQuery *query;
+
+public:
+ KDirLister *dirlister;
+};
+
+#endif
+
+
diff --git a/kfind/kfinddlg.cpp b/kfind/kfinddlg.cpp
new file mode 100644
index 000000000..29e3010b4
--- /dev/null
+++ b/kfind/kfinddlg.cpp
@@ -0,0 +1,293 @@
+/***********************************************************************
+ *
+ * Kfinddlg.cpp
+ *
+ **********************************************************************/
+
+#include <tqlayout.h>
+#include <tqpushbutton.h>
+
+#include <tdelocale.h>
+#include <tdeglobal.h>
+#include <kguiitem.h>
+#include <kstatusbar.h>
+#include <tdemessagebox.h>
+#include <kdebug.h>
+#include <tdeaboutapplication.h>
+#include <kstandarddirs.h>
+
+#include "kftabdlg.h"
+#include "kquery.h"
+#include "kfwin.h"
+
+#include "kfinddlg.h"
+#include "kfinddlg.moc"
+
+KfindDlg::KfindDlg(const KURL & url, TQWidget *parent, const char *name)
+ : KDialogBase( Plain, TQString::null,
+ User1 | User2 | Apply | Close | Help, Apply,
+ parent, name, true, false,
+ KGuiItem(i18n("Stop"), "process-stop"),
+ KStdGuiItem::saveAs())
+{
+ TQWidget::setCaption( i18n("Find Files/Folders" ) );
+ setButtonBoxOrientation(Qt::Vertical);
+
+ enableButton(Apply, true); // Enable "Find"
+ enableButton(User1, false); // Disable "Stop"
+ enableButton(User2, false); // Disable "Save As..."
+
+ setButtonApply(KGuiItem(i18n("&Find"), "edit-find"));
+
+ isResultReported = false;
+
+ TQFrame *frame = plainPage();
+
+ // create tabwidget
+ tabWidget = new KfindTabWidget( frame, "dialog");
+ tabWidget->setURL( url );
+
+ // prepare window for find results
+ win = new KfindWindow(frame,"window");
+
+ mStatusBar = new KStatusBar(frame);
+ mStatusBar->insertFixedItem(i18n("AMiddleLengthText..."), 0, true);
+ setStatusMsg(i18n("Ready."));
+ mStatusBar->setItemAlignment(0, AlignLeft | AlignVCenter);
+ mStatusBar->insertItem(TQString::null, 1, 1, true);
+ mStatusBar->setItemAlignment(1, AlignLeft | AlignVCenter);
+
+ TQVBoxLayout *vBox = new TQVBoxLayout(frame);
+ vBox->addWidget(tabWidget, 0);
+ vBox->addWidget(win, 1);
+ vBox->addWidget(mStatusBar, 0);
+
+ connect(this, TQT_SIGNAL(applyClicked()),
+ this, TQT_SLOT(startSearch()));
+ connect(this, TQT_SIGNAL(user1Clicked()),
+ this, TQT_SLOT(stopSearch()));
+ connect(this, TQT_SIGNAL(user2Clicked()),
+ win, TQT_SLOT(saveResults()));
+
+ connect(win ,TQT_SIGNAL(resultSelected(bool)),
+ this,TQT_SIGNAL(resultSelected(bool)));
+
+ query = new KQuery(TQT_TQOBJECT(frame));
+ connect(query, TQT_SIGNAL(addFile(const KFileItem*,const TQString&)),
+ TQT_SLOT(addFile(const KFileItem*,const TQString&)));
+ connect(query, TQT_SIGNAL(result(int)), TQT_SLOT(slotResult(int)));
+
+ dirwatch=NULL;
+}
+
+KfindDlg::~KfindDlg()
+{
+ stopSearch();
+}
+
+void KfindDlg::closeEvent(TQCloseEvent *)
+{
+ stopSearch();
+ slotClose();
+}
+
+void KfindDlg::setProgressMsg(const TQString &msg)
+{
+ mStatusBar->changeItem(msg, 1);
+}
+
+void KfindDlg::setStatusMsg(const TQString &msg)
+{
+ mStatusBar->changeItem(msg, 0);
+}
+
+
+void KfindDlg::startSearch()
+{
+ tabWidget->setQuery(query);
+
+ isResultReported = false;
+
+ // Reset count - use the same i18n as below
+ setProgressMsg(i18n("one file found", "%n files found", 0));
+
+ emit resultSelected(false);
+ emit haveResults(false);
+
+ enableButton(Apply, false); // Disable "Find"
+ enableButton(User1, true); // Enable "Stop"
+ enableButton(User2, false); // Disable "Save As..."
+
+ if(dirwatch!=NULL)
+ delete dirwatch;
+ dirwatch=new KDirWatch();
+ connect(dirwatch, TQT_SIGNAL(created(const TQString&)), this, TQT_SLOT(slotNewItems(const TQString&)));
+ connect(dirwatch, TQT_SIGNAL(deleted(const TQString&)), this, TQT_SLOT(slotDeleteItem(const TQString&)));
+ dirwatch->addDir(query->url().path(),true);
+
+#if 0
+ // waba: Watching for updates is disabled for now because even with FAM it causes too
+ // much problems. See BR68220, BR77854, BR77846, BR79512 and BR85802
+ // There are 3 problems:
+ // 1) addDir() keeps looping on recursive symlinks
+ // 2) addDir() scans all subdirectories, so it basically does the same as the process that
+ // is started by KQuery but in-process, undoing the advantages of using a seperate find process
+ // A solution could be to let KQuery emit all the directories it has searched in.
+ // Either way, putting dirwatchers on a whole file system is probably just too much.
+ // 3) FAM has a tendency to deadlock with so many files (See BR77854) This has hopefully
+ // been fixed in KDirWatch, but that has not yet been confirmed.
+
+ //Getting a list of all subdirs
+ if(tabWidget->isSearchRecursive() && (dirwatch->internalMethod() == KDirWatch::FAM))
+ {
+ TQStringList subdirs=getAllSubdirs(query->url().path());
+ for(TQStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it)
+ dirwatch->addDir(*it,true);
+ }
+#endif
+
+ win->beginSearch(query->url());
+ tabWidget->beginSearch();
+
+ setStatusMsg(i18n("Searching..."));
+ query->start();
+}
+
+void KfindDlg::stopSearch()
+{
+ query->kill();
+}
+
+void KfindDlg::newSearch()
+{
+ // WABA: Not used any longer?
+ stopSearch();
+
+ tabWidget->setDefaults();
+
+ emit haveResults(false);
+ emit resultSelected(false);
+
+ setFocus();
+}
+
+void KfindDlg::slotResult(int errorCode)
+{
+ if (errorCode == 0)
+ setStatusMsg(i18n("Ready."));
+ else if (errorCode == TDEIO::ERR_USER_CANCELED)
+ setStatusMsg(i18n("Aborted."));
+ else if (errorCode == TDEIO::ERR_MALFORMED_URL)
+ {
+ setStatusMsg(i18n("Error."));
+ KMessageBox::sorry( this, i18n("Please specify an absolute path in the \"Look in\" box."));
+ }
+ else if (errorCode == TDEIO::ERR_DOES_NOT_EXIST)
+ {
+ setStatusMsg(i18n("Error."));
+ KMessageBox::sorry( this, i18n("Could not find the specified folder."));
+ }
+ else
+ {
+ kdDebug()<<"TDEIO error code: "<<errorCode<<endl;
+ setStatusMsg(i18n("Error."));
+ };
+
+ enableButton(Apply, true); // Enable "Find"
+ enableButton(User1, false); // Disable "Stop"
+ enableButton(User2, true); // Enable "Save As..."
+
+ win->endSearch();
+ tabWidget->endSearch();
+ setFocus();
+
+}
+
+void KfindDlg::addFile(const KFileItem* item, const TQString& matchingLine)
+{
+ win->insertItem(*item,matchingLine);
+
+ if (!isResultReported)
+ {
+ emit haveResults(true);
+ isResultReported = true;
+ }
+
+ int count = win->childCount();
+ TQString str = i18n("one file found", "%n files found", count);
+ setProgressMsg(str);
+}
+
+void KfindDlg::setFocus()
+{
+ tabWidget->setFocus();
+}
+
+void KfindDlg::copySelection()
+{
+ win->copySelection();
+}
+
+void KfindDlg::about ()
+{
+ TDEAboutApplication dlg(this, "about", true);
+ dlg.exec ();
+}
+
+void KfindDlg::slotDeleteItem(const TQString& file)
+{
+ kdDebug()<<TQString(TQString("Will remove one item: %1").arg(file))<<endl;
+ TQListViewItem *iter;
+ TQString iterwithpath;
+
+ iter=win->firstChild();
+ while( iter ) {
+ iterwithpath=query->url().path(+1)+iter->text(1)+iter->text(0);
+
+ if(iterwithpath==file)
+ {
+ win->takeItem(iter);
+ break;
+ }
+ iter = iter->nextSibling();
+ }
+}
+
+void KfindDlg::slotNewItems( const TQString& file )
+{
+ kdDebug()<<TQString("Will add this item")<<endl;
+ TQStringList newfiles;
+ TQListViewItem *checkiter;
+ TQString checkiterwithpath;
+
+ if(file.find(query->url().path(+1))==0)
+ {
+ kdDebug()<<TQString("Can be added, path OK")<<endl;
+ checkiter=win->firstChild();
+ while( checkiter ) {
+ checkiterwithpath=query->url().path(+1)+checkiter->text(1)+checkiter->text(0);
+ if(file==checkiterwithpath)
+ return;
+ checkiter = checkiter->nextSibling();
+ }
+ query->slotListEntries(TQStringList(file));
+ }
+}
+
+TQStringList KfindDlg::getAllSubdirs(TQDir d)
+{
+ TQStringList dirs;
+ TQStringList subdirs;
+
+ d.setFilter( TQDir::Dirs );
+ dirs = d.entryList();
+
+ for(TQStringList::Iterator it = dirs.begin(); it != dirs.end(); ++it)
+ {
+ if((*it==".")||(*it==".."))
+ continue;
+ subdirs.append(d.path()+"/"+*it);
+ subdirs+=getAllSubdirs(d.path()+"/"+*it);
+ }
+ return subdirs;
+}
diff --git a/kfind/kfinddlg.h b/kfind/kfinddlg.h
new file mode 100644
index 000000000..d8080ec46
--- /dev/null
+++ b/kfind/kfinddlg.h
@@ -0,0 +1,69 @@
+/***********************************************************************
+ *
+ * KfindDlg.h
+ *
+ ***********************************************************************/
+
+#ifndef KFINDDLG_H
+#define KFINDDLG_H
+
+#include <kdialogbase.h>
+#include <kdirlister.h>
+#include <kdirwatch.h>
+
+class TQString;
+
+class KQuery;
+class KURL;
+class KFileItem;
+class KfindTabWidget;
+class KfindWindow;
+class KStatusBar;
+
+class KfindDlg: public KDialogBase
+{
+Q_OBJECT
+
+public:
+ KfindDlg(const KURL & url, TQWidget * parent = 0, const char * name = 0);
+ ~KfindDlg();
+ void copySelection();
+
+ void setStatusMsg(const TQString &);
+ void setProgressMsg(const TQString &);
+
+private:
+ void closeEvent(TQCloseEvent *);
+ /*Return a TQStringList of all subdirs of d*/
+ TQStringList getAllSubdirs(TQDir d);
+
+public slots:
+ void startSearch();
+ void stopSearch();
+ void newSearch();
+ void addFile(const KFileItem* item, const TQString& matchingLine);
+ void setFocus();
+ void slotResult(int);
+// void slotSearchDone();
+ void about ();
+ void slotDeleteItem(const TQString&);
+ void slotNewItems( const TQString& );
+
+signals:
+ void haveResults(bool);
+ void resultSelected(bool);
+
+private:
+ KfindTabWidget *tabWidget;
+ KfindWindow * win;
+
+ bool isResultReported;
+ KQuery *query;
+ KStatusBar *mStatusBar;
+ KDirLister *dirlister;
+ KDirWatch *dirwatch;
+};
+
+#endif
+
+
diff --git a/kfind/kfindpart.cpp b/kfind/kfindpart.cpp
new file mode 100644
index 000000000..54de01e9b
--- /dev/null
+++ b/kfind/kfindpart.cpp
@@ -0,0 +1,213 @@
+/* This file is part of the KDE projects
+ Copyright (C) 2000 David Faure <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kfind.h"
+#include "kfindpart.h"
+#include "kquery.h"
+
+#include <tdeparts/genericfactory.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+
+#include <tqdir.h>
+#include <kinstance.h>
+
+class KonqDirPart;
+
+typedef KParts::GenericFactory<KFindPart> KFindFactory;
+K_EXPORT_COMPONENT_FACTORY( libkfindpart, KFindFactory )
+
+KFindPart::KFindPart( TQWidget * parentWidget, const char *widgetName,
+ TQObject *parent, const char *name ,
+ const TQStringList & /*args*/ )
+ : KonqDirPart (parent, name )/*KParts::ReadOnlyPart*/
+{
+ setInstance( KFindFactory::instance() );
+
+ setBrowserExtension( new KonqDirPartBrowserExtension( this ) );
+
+ kdDebug() << "KFindPart::KFindPart " << this << endl;
+ m_kfindWidget = new Kfind( parentWidget, widgetName );
+ m_kfindWidget->setMaximumHeight(m_kfindWidget->minimumSizeHint().height());
+ const KFileItem *item = ((KonqDirPart*)parent)->currentItem();
+ kdDebug() << "Kfind: currentItem: " << ( item ? item->url().path().local8Bit() : TQString("null") ) << endl;
+ TQDir d;
+ if( item && d.exists( item->url().path() ))
+ m_kfindWidget->setURL( item->url() );
+
+ setWidget( m_kfindWidget );
+
+ connect( m_kfindWidget, TQT_SIGNAL(started()),
+ this, TQT_SLOT(slotStarted()) );
+ connect( m_kfindWidget, TQT_SIGNAL(destroyMe()),
+ this, TQT_SLOT(slotDestroyMe()) );
+ connect(m_kfindWidget->dirlister,TQT_SIGNAL(deleteItem(KFileItem*)), this, TQT_SLOT(removeFile(KFileItem*)));
+ connect(m_kfindWidget->dirlister,TQT_SIGNAL(newItems(const KFileItemList&)), this, TQT_SLOT(newFiles(const KFileItemList&)));
+ //setXMLFile( "kfind.rc" );
+ query = new KQuery(this);
+ connect(query, TQT_SIGNAL(addFile(const KFileItem *, const TQString&)),
+ TQT_SLOT(addFile(const KFileItem *, const TQString&)));
+ connect(query, TQT_SIGNAL(result(int)),
+ TQT_SLOT(slotResult(int)));
+
+ m_kfindWidget->setQuery(query);
+ m_bShowsResult = false;
+
+ m_lstFileItems.setAutoDelete( true );
+}
+
+KFindPart::~KFindPart()
+{
+}
+
+TDEAboutData *KFindPart::createAboutData()
+{
+ return new TDEAboutData( "kfindpart", I18N_NOOP( "Find Component" ), "1.0" );
+}
+
+bool KFindPart::doOpenURL( const KURL &url )
+{
+ m_kfindWidget->setURL( url );
+ return true;
+}
+
+void KFindPart::slotStarted()
+{
+ kdDebug() << "KFindPart::slotStarted" << endl;
+ m_bShowsResult = true;
+ m_lstFileItems.clear(); // clear our internal list
+ emit started();
+ emit clear();
+}
+
+void KFindPart::addFile(const KFileItem *item, const TQString& /*matchingLine*/)
+{
+ // item is deleted by caller
+ // we need to clone it
+ KFileItem *clonedItem = new KFileItem(*item);
+ m_lstFileItems.append( clonedItem );
+
+ KFileItemList lstNewItems;
+ lstNewItems.append(clonedItem);
+ emit newItems(lstNewItems);
+
+ /*
+ win->insertItem(item);
+
+ if (!isResultReported)
+ {
+ emit haveResults(true);
+ isResultReported = true;
+ }
+
+ */
+}
+
+/* An item has been removed, so update konqueror's view */
+void KFindPart::removeFile(KFileItem *item)
+{
+ KFileItem *iter;
+ KFileItemList listiter;
+
+ emit started();
+ emit clear();
+
+ m_lstFileItems.remove( item ); //not working ?
+
+ for(iter=m_lstFileItems.first(); iter; iter=m_lstFileItems.next() ) {
+ if(iter->url()!=item->url())
+ listiter.append(iter);
+ }
+
+ emit newItems(listiter);
+ emit finished();
+}
+
+void KFindPart::newFiles(const KFileItemList&)
+{
+ if(m_bShowsResult)
+ return;
+ emit started();
+ emit clear();
+ if (m_lstFileItems.count())
+ emit newItems(m_lstFileItems);
+ emit finished();
+}
+
+void KFindPart::slotResult(int errorCode)
+{
+ if (errorCode == 0)
+ emit finished();
+ //setStatusMsg(i18n("Ready."));
+ else if (errorCode == TDEIO::ERR_USER_CANCELED)
+ emit canceled();
+ //setStatusMsg(i18n("Aborted."));
+ else
+ emit canceled(); // TODO ?
+ //setStatusMsg(i18n("Error."));
+ m_bShowsResult=false;
+ m_kfindWidget->searchFinished();
+}
+
+void KFindPart::slotDestroyMe()
+{
+ m_kfindWidget->stopSearch();
+ emit clear(); // this is necessary to clear the delayed-mimetypes items list
+ m_lstFileItems.clear(); // clear our internal list
+ emit findClosed();
+}
+
+void KFindPart::saveState( TQDataStream& stream )
+{
+ KonqDirPart::saveState(stream);
+
+ m_kfindWidget->saveState( &stream );
+ //Now we'll save the search result
+ KFileItem *fileitem=m_lstFileItems.first();
+ stream << m_lstFileItems.count();
+ while(fileitem!=NULL)
+ {
+ stream << *fileitem;
+ fileitem=m_lstFileItems.next();
+ }
+}
+
+void KFindPart::restoreState( TQDataStream& stream )
+{
+ KonqDirPart::restoreState(stream);
+ int nbitems;
+ KURL itemUrl;
+
+ m_kfindWidget->restoreState( &stream );
+
+ stream >> nbitems;
+ slotStarted();
+ for(int i=0;i<nbitems;i++)
+ {
+ KFileItem* item = new KFileItem( KFileItem::Unknown, KFileItem::Unknown, KURL() );
+ stream >> *item;
+ m_lstFileItems.append(item);
+ }
+ if (nbitems)
+ emit newItems(m_lstFileItems);
+
+ emit finished();
+}
+
+#include "kfindpart.moc"
diff --git a/kfind/kfindpart.desktop b/kfind/kfindpart.desktop
new file mode 100644
index 000000000..c9cb0c025
--- /dev/null
+++ b/kfind/kfindpart.desktop
@@ -0,0 +1,87 @@
+[Desktop Entry]
+Type=Service
+Name=Find Part
+Name[af]=Soek Deel
+Name[ar]=ابحث عن جزء
+Name[az]=Parça tap
+Name[be]=Модуль пошуку
+Name[bg]=Търсене на модули
+Name[bn]=পার্ট অনুসন্ধান
+Name[br]=Kavout perzh
+Name[bs]=Nađi dio
+Name[ca]=Cerca la part
+Name[cs]=Najít soubor
+Name[csb]=Mòduł szëkbë
+Name[cy]=Canfod Rhan
+Name[da]=Find del
+Name[de]=Einbettungsfähiges Programm (Komponente) suchen
+Name[el]=Part Αναζήτηση
+Name[eo]=Trovokomponento
+Name[es]=Buscar parte
+Name[et]=Failide otsimise komponent
+Name[eu]=Bilatu partea
+Name[fa]=یافتن جزء
+Name[fi]=Etsi osa
+Name[fr]=Composant de recherche
+Name[fy]=In diel sykje
+Name[ga]=Aimsigh Páirt
+Name[gl]=Busca
+Name[he]=רכיב חיפוש
+Name[hi]=हिस्सा ढूंढें
+Name[hr]=Pronađi dio
+Name[hu]=Keresési objektum
+Name[id]=Cari bagian
+Name[is]=Finna hluti
+Name[it]=Trova parte
+Name[ja]=検索パート
+Name[ka]=ძიება შემადგენლობის მიხედვით
+Name[kk]=Мазмұнынан табу
+Name[km]=រក​ផ្នែក
+Name[ko]=찾기 부분
+Name[lo]=ຄັ້ນຫາບາງສ່ວນ
+Name[lt]=Surasti dalį
+Name[lv]=Meklēt Daļu
+Name[mk]=Пронајди дел
+Name[mn]=Хэсэг хайх
+Name[ms]=Cari Bahagian
+Name[mt]=Sib Parti
+Name[nb]=Finn del
+Name[nds]=Söök-Komponent
+Name[ne]=भाग फेला पार्नुहोस्
+Name[nl]=Gedeelte zoeken
+Name[nn]=Finn del
+Name[nso]=Hwetsa Seripa
+Name[pa]=ਹਿੱਸੇ ਖੋਜ
+Name[pl]=Moduł szukania
+Name[pt]=Componente de Pesquisa
+Name[pt_BR]=Componente de Busca
+Name[ro]=Componentă de căutare
+Name[ru]=Поиск по содержимому
+Name[rw]=Gushaka Igice
+Name[se]=Oza osiid
+Name[sk]=Nájsť Part
+Name[sl]=Najdi del
+Name[sr]=Део за тражење
+Name[sr@Latn]=Deo za traženje
+Name[sv]=Sökdel
+Name[ta]=பகுதி கண்டுபிடி
+Name[te]=వెతుకు భాగం
+Name[tg]=Қисматро пайдо кунед
+Name[th]=ค้นหาบางส่วน
+Name[tr]=Parça bul
+Name[tt]=Eçtälek Ezläw
+Name[uk]=Складова пошуку
+Name[ven]=Todani tshipida
+Name[vi]=Tìm từng phần
+Name[wa]=Trover des pårteyes
+Name[xh]=Fumana Indawana
+Name[zh_CN]=查找部件
+Name[zh_TW]=尋找組件
+Name[zu]=Thola Ingxenye
+MimeType=
+X-TDE-ServiceTypes=Konqueror/FindPart
+X-TDE-Library=libkfindpart
+X-TDE-BrowserView-AllowAsDefault=true
+X-TDE-BrowserView-HideFromMenus=true
+X-TDE-BrowserView-PassiveMode=true
+X-TDE-InitialPreference=10
diff --git a/kfind/kfindpart.h b/kfind/kfindpart.h
new file mode 100644
index 000000000..3ec83970a
--- /dev/null
+++ b/kfind/kfindpart.h
@@ -0,0 +1,104 @@
+/* This file is part of the KDE projects
+ Copyright (C) 2000 David Faure <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef kfindpart__h
+#define kfindpart__h
+
+#include <tdeparts/browserextension.h>
+#include <tdeparts/part.h>
+#include <tdefileitem.h>
+#include <kdebug.h>
+#include <tqptrlist.h>
+#include <konq_dirpart.h>
+
+class KQuery;
+class TDEAboutData;
+//added
+class KonqPropsView;
+class TDEAction;
+class TDEToggleAction;
+class TDEActionMenu;
+class TQIconViewItem;
+class IconViewBrowserExtension;
+//end added
+
+class KFindPart : public KonqDirPart//KParts::ReadOnlyPart
+{
+ friend class KFindPartBrowserExtension;
+ Q_OBJECT
+ TQ_PROPERTY( bool showsResult READ showsResult )
+public:
+ KFindPart( TQWidget * parentWidget, const char *widgetName,
+ TQObject *parent, const char *name, const TQStringList & /*args*/ );
+ virtual ~KFindPart();
+
+ static TDEAboutData *createAboutData();
+
+ virtual bool doOpenURL( const KURL &url );
+ virtual bool doCloseURL() { return true; }
+ virtual bool openFile() { return false; }
+
+ bool showsResult() const { return m_bShowsResult; }
+
+ virtual void saveState( TQDataStream &stream );
+ virtual void restoreState( TQDataStream &stream );
+
+ // "Cut" icons : disable those whose URL is in lst, enable the rest //added for konqdirpart
+ virtual void disableIcons( const KURL::List & ){};
+ virtual const KFileItem * currentItem(){return 0;};
+
+signals:
+ // Konqueror connects directly to those signals
+ void started(); // started a search
+ void clear(); // delete all items
+ void newItems(const KFileItemList&); // found this/these item(s)
+ void finished(); // finished searching
+ void canceled(); // the user canceled the search
+ void findClosed(); // close us
+ void deleteItem( KFileItem *item);
+
+protected slots:
+ void slotStarted();
+ void slotDestroyMe();
+ void addFile(const KFileItem *item, const TQString& matchingLine);
+ /* An item has been removed, so update konqueror's view */
+ void removeFile(KFileItem *item);
+ void slotResult(int errorCode);
+ void newFiles(const KFileItemList&);
+ // slots connected to the directory lister //added for konqdirpart
+// virtual void slotStarted();
+ virtual void slotCanceled(){};
+ virtual void slotCompleted(){};
+ virtual void slotNewItems( const KFileItemList& ){};
+ virtual void slotDeleteItem( KFileItem * ){};
+ virtual void slotRefreshItems( const KFileItemList& ){};
+ virtual void slotClear(){};
+ virtual void slotRedirection( const KURL & ){};
+
+private:
+ Kfind * m_kfindWidget;
+ KQuery *query;
+ bool m_bShowsResult; // whether the dirpart shows the results of a search or not
+ /**
+ * The internal storage of file items
+ */
+ TQPtrList<KFileItem> m_lstFileItems;
+};
+
+#endif
diff --git a/kfind/kfindpart.kdevprj b/kfind/kfindpart.kdevprj
new file mode 100644
index 000000000..d9fbfc7e2
--- /dev/null
+++ b/kfind/kfindpart.kdevprj
@@ -0,0 +1,178 @@
+[./AUTHORS]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[./ChangeLog]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[./Makefile.am]
+files=./AUTHORS,./ChangeLog,./README,./TODO,./findpart.desktop,./kfind.cpp,./kfind.h,./kfindpart.cpp,./kfindpart.desktop,./kfindpart.h,./kftabdlg.cpp,./kftabdlg.h,./kquery.cpp,./kquery.h,./version.h,./kfindpart.kdevprj,
+sub_dirs=pics,
+type=normal
+
+[./README]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[./TODO]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[./findpart.desktop]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[./kfind.cpp]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[./kfind.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[./kfindpart.cpp]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[./kfindpart.desktop]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[./kfindpart.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[./kfindpart.kdevprj]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[./kftabdlg.cpp]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[./kftabdlg.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[./kquery.cpp]
+dist=true
+install=false
+install_location=
+type=SOURCE
+
+[./kquery.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[./version.h]
+dist=true
+install=false
+install_location=
+type=HEADER
+
+[Config for BinMakefileAm]
+addcxxflags=
+bin_program=kfindpart
+cxxflags=
+ldadd=
+ldflags=
+
+[General]
+AMChanged=false
+author=eric
+kdevprj_version=1.3
+lfv_open_groups=
+makefiles=./Makefile.am,pics/Makefile.am,
+project_name=kfindpart
+project_type=normal_empty
+sub_dir=
+version=
+version_control=CVS
+workspace=1
+
+[LFV Groups]
+Desktop=*.desktop,
+GNU=AUTHORS,COPYING,ChangeLog,INSTALL,README,TODO,NEWS,
+Headers=*.h,*.hxx,*.hpp,*.H,
+Others=*,
+Sources=*.cpp,*.c,*.cc,*.C,*.cxx,*.ec,*.ecpp,*.lxx,*.l++,*.ll,*.l,
+Translations=*.ts,*.po,
+User Interface=*.ui,*.kdevdlg,*.rc,
+groups=Headers,Sources,GNU,Translations,User Interface,Desktop,Others
+
+[pics/Makefile.am]
+files=pics/lo22-action-archive.png,pics/lo22-action-delete.png,pics/lo22-action-idea.png,pics/lo22-action-info.png,pics/lo22-action-openfile.png,pics/lo22-action-save.png,pics/lo22-action-search.png,
+sub_dirs=
+type=normal
+
+[pics/lo22-action-archive.png]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[pics/lo22-action-delete.png]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[pics/lo22-action-idea.png]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[pics/lo22-action-info.png]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[pics/lo22-action-openfile.png]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[pics/lo22-action-save.png]
+dist=true
+install=false
+install_location=
+type=DATA
+
+[pics/lo22-action-search.png]
+dist=true
+install=false
+install_location=
+type=DATA
diff --git a/kfind/kfindpart.kdevses b/kfind/kfindpart.kdevses
new file mode 100644
index 000000000..3a5983ecf
--- /dev/null
+++ b/kfind/kfindpart.kdevses
@@ -0,0 +1,20 @@
+<?xml version = '1.0' encoding = 'UTF-8'?>
+<!DOCTYPE KDevPrjSession>
+<KDevPrjSession>
+ <Mainframe MaximizeMode="0" />
+ <DocsAndViews NumberOfDocuments="4" >
+ <Doc0 CursorPosLine="44" Type="KWriteDoc" NumberOfViews="1" CursorPosCol="0" FileName="/home/eric/kde/tdebase/kfind/kfind.cpp" >
+ <View0 Top="0" Width="754" Attach="1" Height="388" Left="0" Focus="0" Type="KWriteView" MinMaxMode="0" />
+ </Doc0>
+ <Doc1 CursorPosLine="20" Type="KWriteDoc" NumberOfViews="1" CursorPosCol="0" FileName="/home/eric/kde/tdebase/kfind/kfind.h" >
+ <View0 Top="0" Width="754" Attach="1" Height="388" Left="0" Focus="0" Type="KWriteView" MinMaxMode="0" />
+ </Doc1>
+ <Doc2 CursorPosLine="31" Type="KWriteDoc" NumberOfViews="1" CursorPosCol="0" FileName="/home/eric/kde/tdebase/kfind/kftabdlg.h" >
+ <View0 Top="0" Width="754" Attach="1" Height="388" Left="0" Focus="0" Type="KWriteView" MinMaxMode="0" />
+ </Doc2>
+ <Doc3 CursorPosLine="51" Type="KWriteDoc" NumberOfViews="1" CursorPosCol="0" FileName="/home/eric/kde/tdebase/kfind/kftabdlg.cpp" >
+ <View0 Top="0" Width="754" Attach="1" Height="388" Left="0" Focus="1" Type="KWriteView" MinMaxMode="0" />
+ </Doc3>
+ </DocsAndViews>
+ <LastCompileConfig>(Default)</LastCompileConfig>
+</KDevPrjSession>
diff --git a/kfind/kftabdlg.cpp b/kfind/kftabdlg.cpp
new file mode 100644
index 000000000..c2df7aa67
--- /dev/null
+++ b/kfind/kftabdlg.cpp
@@ -0,0 +1,871 @@
+/***********************************************************************
+ *
+ * kftabdlg.cpp
+ *
+ **********************************************************************/
+
+#include <tqbuttongroup.h>
+#include <tqradiobutton.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqcheckbox.h>
+#include <tqwhatsthis.h>
+#include <tqtooltip.h>
+#include <tqcombobox.h>
+#include <tqspinbox.h>
+#include <tqpushbutton.h>
+#include <tqapplication.h>
+
+#include <kcalendarsystem.h>
+#include <tdeglobal.h>
+#include <kcombobox.h>
+#include <klineedit.h>
+#include <tdelocale.h>
+#include <tdemessagebox.h>
+#include <tdefiledialog.h>
+#include <kregexpeditorinterface.h>
+#include <tdeparts/componentfactory.h>
+#include <kstandarddirs.h>
+
+#include "kquery.h"
+#include "kftabdlg.h"
+
+// Static utility functions
+static void save_pattern(TQComboBox *, const TQString &, const TQString &);
+
+#define SPECIAL_TYPES 7
+
+class KSortedMimeTypeList : public TQPtrList<KMimeType>
+{
+public:
+ KSortedMimeTypeList() { };
+ int compareItems(TQPtrCollection::Item s1, TQPtrCollection::Item s2)
+ {
+ KMimeType *item1 = (KMimeType *) s1;
+ KMimeType *item2 = (KMimeType *) s2;
+ if (item1->comment() > item2->comment()) return 1;
+ if (item1->comment() == item2->comment()) return 0;
+ return -1;
+ }
+};
+
+KfindTabWidget::KfindTabWidget(TQWidget *parent, const char *name)
+ : TQTabWidget( parent, name ), regExpDialog(0)
+{
+ // This validator will be used for all numeric edit fields
+ //KDigitValidator *digitV = new KDigitValidator(this);
+
+ // ************ Page One ************
+
+ pages[0] = new TQWidget( this, "page1" );
+
+ nameBox = new KComboBox(TRUE, pages[0], "combo1");
+ nameBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed); // allow smaller than widest entry
+ TQLabel * namedL = new TQLabel(nameBox, i18n("&Named:"), pages[0], "named");
+ TQToolTip::add( namedL, i18n("You can use wildcard matching and \";\" for separating multiple names") );
+ dirBox = new KComboBox(TRUE, pages[0], "combo2");
+ dirBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed); // allow smaller than widest entry
+ TQLabel * lookinL = new TQLabel(dirBox, i18n("Look &in:"), pages[0], "named");
+ subdirsCb = new TQCheckBox(i18n("Include &subfolders"), pages[0]);
+ caseSensCb = new TQCheckBox(i18n("Case s&ensitive search"), pages[0]);
+ browseB = new TQPushButton(i18n("&Browse..."), pages[0]);
+ useLocateCb = new TQCheckBox(i18n("&Use files index"), pages[0]);
+
+ // Setup
+
+ subdirsCb->setChecked(true);
+ caseSensCb->setChecked(false);
+ useLocateCb->setChecked(false);
+ if(TDEStandardDirs::findExe("locate")==NULL)
+ useLocateCb->setEnabled(false);
+
+ nameBox->setDuplicatesEnabled(FALSE);
+ nameBox->setFocus();
+ dirBox->setDuplicatesEnabled(FALSE);
+
+ nameBox->setInsertionPolicy(TQComboBox::AtTop);
+ dirBox->setInsertionPolicy(TQComboBox::AtTop);
+
+ const TQString nameWhatsThis
+ = i18n("<qt>Enter the filename you are looking for. <br>"
+ "Alternatives may be separated by a semicolon \";\".<br>"
+ "<br>"
+ "The filename may contain the following special characters:"
+ "<ul>"
+ "<li><b>?</b> matches any single character</li>"
+ "<li><b>*</b> matches zero or more of any characters</li>"
+ "<li><b>[...]</b> matches any of the characters in braces</li>"
+ "</ul>"
+ "<br>"
+ "Example searches:"
+ "<ul>"
+ "<li><b>*.kwd;*.txt</b> finds all files ending with .kwd or .txt</li>"
+ "<li><b>go[dt]</b> finds god and got</li>"
+ "<li><b>Hel?o</b> finds all files that start with \"Hel\" and end with \"o\", "
+ "having one character in between</li>"
+ "<li><b>My Document.kwd</b> finds a file of exactly that name</li>"
+ "</ul></qt>");
+ TQWhatsThis::add(nameBox,nameWhatsThis);
+ TQWhatsThis::add(namedL,nameWhatsThis);
+ const TQString whatsfileindex
+ = i18n("<qt>This lets you use the files' index created by the <i>slocate</i> "
+ "package to speed-up the search; remember to update the index from time to time "
+ "(using <i>updatedb</i>)."
+ "</qt>");
+ TQWhatsThis::add(useLocateCb,whatsfileindex);
+
+ // Layout
+
+ TQGridLayout *grid = new TQGridLayout( pages[0], 3, 2,
+ KDialog::marginHint(),
+ KDialog::spacingHint() );
+ TQBoxLayout *subgrid = new TQVBoxLayout( -1 , "subgrid" );
+ grid->addWidget( namedL, 0, 0 );
+ grid->addMultiCellWidget( nameBox, 0, 0, 1, 2 );
+ grid->addWidget( lookinL, 1, 0 );
+ grid->addWidget( dirBox, 1, 1 );
+ grid->addWidget( browseB, 1, 2);
+ grid->setColStretch(1,1);
+ grid->addMultiCellLayout( subgrid, 2, 2, 1, 2 );
+ subgrid->addWidget( subdirsCb );
+ subgrid->addWidget( caseSensCb);
+ subgrid->addWidget( useLocateCb );
+ subgrid->addStretch(1);
+
+ // Signals
+
+ connect( browseB, TQT_SIGNAL(clicked()),
+ this, TQT_SLOT(getDirectory()) );
+
+ connect( nameBox, TQT_SIGNAL(activated(int)),
+ this, TQT_SIGNAL(startSearch()));
+
+ // ************ Page Two
+
+ pages[1] = new TQWidget( this, "page2" );
+
+ findCreated = new TQCheckBox(i18n("Find all files created or &modified:"), pages[1]);
+ bg = new TQButtonGroup();
+ rb[0] = new TQRadioButton(i18n("&between"), pages[1] );
+ rb[1] = new TQRadioButton(i18n("&during the previous"), pages[1] );
+ TQLabel * andL = new TQLabel(i18n("and"), pages[1], "and");
+ betweenType = new KComboBox(FALSE, pages[1], "comboBetweenType");
+ betweenType->insertItem(i18n("minute(s)"));
+ betweenType->insertItem(i18n("hour(s)"));
+ betweenType->insertItem(i18n("day(s)"));
+ betweenType->insertItem(i18n("month(s)"));
+ betweenType->insertItem(i18n("year(s)"));
+ betweenType->setCurrentItem(1);
+
+
+ TQDate dt = TDEGlobal::locale()->calendar()->addYears(TQDate::currentDate(), -1);
+
+ fromDate = new KDateCombo(dt, pages[1], "fromDate");
+ toDate = new KDateCombo(pages[1], "toDate");
+ timeBox = new TQSpinBox(1, 60, 1, pages[1], "timeBox");
+
+ sizeBox =new KComboBox(FALSE, pages[1], "sizeBox");
+ TQLabel * sizeL =new TQLabel(sizeBox,i18n("File &size is:"), pages[1],"size");
+ sizeEdit=new TQSpinBox(0, INT_MAX, 1, pages[1], "sizeEdit" );
+ sizeEdit->setValue(1);
+ sizeUnitBox =new KComboBox(FALSE, pages[1], "sizeUnitBox");
+
+ m_usernameBox = new KComboBox( true, pages[1], "m_combo1");
+ TQLabel *usernameLabel= new TQLabel(m_usernameBox,i18n("Files owned by &user:"),pages[1]);
+ m_groupBox = new KComboBox( true, pages[1], "m_combo2");
+ TQLabel *groupLabel= new TQLabel(m_groupBox,i18n("Owned by &group:"),pages[1]);
+
+ sizeBox ->insertItem( i18n("(none)") );
+ sizeBox ->insertItem( i18n("At Least") );
+ sizeBox ->insertItem( i18n("At Most") );
+ sizeBox ->insertItem( i18n("Equal To") );
+
+ sizeUnitBox ->insertItem( i18n("Bytes") );
+ sizeUnitBox ->insertItem( i18n("KB") );
+ sizeUnitBox ->insertItem( i18n("MB") );
+ sizeUnitBox ->insertItem( i18n("GB") );
+ sizeUnitBox ->setCurrentItem(1);
+
+ int tmp = sizeEdit->fontMetrics().width(" 000000000 ");
+ sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height());
+
+ m_usernameBox->setDuplicatesEnabled(FALSE);
+ m_groupBox->setDuplicatesEnabled(FALSE);
+ m_usernameBox->setInsertionPolicy(TQComboBox::AtTop);
+ m_groupBox->setInsertionPolicy(TQComboBox::AtTop);
+
+
+ // Setup
+ timeBox->setButtonSymbols(TQSpinBox::PlusMinus);
+ rb[0]->setChecked(true);
+ bg->insert( rb[0] );
+ bg->insert( rb[1] );
+
+ // Layout
+
+ TQGridLayout *grid1 = new TQGridLayout( pages[1], 5, 6,
+ KDialog::marginHint(),
+ KDialog::spacingHint() );
+
+ grid1->addMultiCellWidget(findCreated, 0, 0, 0, 3 );
+ grid1->addColSpacing(0, KDialog::spacingHint());
+
+ grid1->addWidget(rb[0], 1, 1 );
+ grid1->addWidget(fromDate, 1, 2 );
+ grid1->addWidget(andL, 1, 3, Qt::AlignHCenter );
+ grid1->addWidget(toDate, 1, 4 );
+
+ grid1->addWidget(rb[1], 2, 1 );
+ grid1->addMultiCellWidget(timeBox, 2, 2, 2, 3);
+ grid1->addWidget(betweenType, 2, 4 );
+
+ grid1->addMultiCellWidget(sizeL,3,3,0,1);
+ grid1->addWidget(sizeBox,3,2);
+ grid1->addWidget(sizeEdit,3,3);
+ grid1->addWidget(sizeUnitBox,3,4);
+
+ grid1->addMultiCellWidget(usernameLabel,4,4,0,1);
+ grid1->addWidget(m_usernameBox,4,2);
+ grid1->addWidget(groupLabel,4,3);
+ grid1->addWidget(m_groupBox,4,4);
+
+ for (int c=1; c<=4; c++)
+ grid1->setColStretch(c,1);
+
+ grid1->setRowStretch(6,1);
+
+ // Connect
+ connect( findCreated, TQT_SIGNAL(toggled(bool)), TQT_SLOT(fixLayout()) );
+ connect( bg, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(fixLayout()) );
+ connect( sizeBox, TQT_SIGNAL(highlighted(int)), this, TQT_SLOT(slotSizeBoxChanged(int)));
+
+
+ // ************ Page Three
+
+ pages[2] = new TQWidget( this, "page3" );
+
+ typeBox =new KComboBox(FALSE, pages[2], "typeBox");
+ typeBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed); // allow smaller than widest entry
+ TQLabel * typeL =new TQLabel(typeBox, i18n("File &type:"), pages[2], "type");
+ textEdit=new KLineEdit(pages[2], "textEdit" );
+ TQLabel * textL =new TQLabel(textEdit, i18n("C&ontaining text:"), pages[2], "text");
+
+ connect( textEdit, TQT_SIGNAL(returnPressed(const TQString &)), TQT_SIGNAL( startSearch()));
+
+ const TQString containingtext
+ = i18n("<qt>If specified, only files that contain this text"
+ " are found. Note that not all file types from the list"
+ " above are supported. Please refer to the documentation"
+ " for a list of supported file types."
+ "</qt>");
+ TQToolTip::add(textEdit,containingtext);
+ TQWhatsThis::add(textL,containingtext);
+
+ caseContextCb =new TQCheckBox(i18n("Case s&ensitive"), pages[2]);
+ binaryContextCb =new TQCheckBox(i18n("Include &binary files"), pages[2]);
+ regexpContentCb =new TQCheckBox(i18n("Regular e&xpression"), pages[2]);
+
+ const TQString binaryTooltip
+ = i18n("<qt>This lets you search in any type of file, "
+ "even those that usually do not contain text (for example "
+ "program files and images).</qt>");
+ TQToolTip::add(binaryContextCb,binaryTooltip);
+
+ TQPushButton* editRegExp = 0;
+ if ( !TDETrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty() ) {
+ // The editor is available, so lets use it.
+ editRegExp = new TQPushButton(i18n("&Edit..."), pages[2], "editRegExp");
+ }
+
+ metainfokeyEdit=new KLineEdit(pages[2], "textEdit" );
+ metainfoEdit=new KLineEdit(pages[2], "textEdit" );
+ TQLabel * textMetaInfo = new TQLabel(metainfoEdit, i18n("fo&r:"), pages[2], "text");
+ TQLabel * textMetaKey = new TQLabel(metainfokeyEdit, i18n("Search &metainfo sections:"), pages[2], "text");
+
+ // Setup
+ typeBox->insertItem(i18n("All Files & Folders"));
+ typeBox->insertItem(i18n("Files"));
+ typeBox->insertItem(i18n("Folders"));
+ typeBox->insertItem(i18n("Symbolic Links"));
+ typeBox->insertItem(i18n("Special Files (Sockets, Device Files, ...)"));
+ typeBox->insertItem(i18n("Executable Files"));
+ typeBox->insertItem(i18n("SUID Executable Files"));
+ typeBox->insertItem(i18n("All Images"));
+ typeBox->insertItem(i18n("All Video"));
+ typeBox->insertItem(i18n("All Sounds"));
+
+ initMimeTypes();
+ initSpecialMimeTypes();
+
+ for ( KMimeType::List::ConstIterator it = m_types.begin();
+ it != m_types.end(); ++it )
+ {
+ KMimeType::Ptr typ = *it;
+ typeBox->insertItem(typ->pixmap( TDEIcon::Small ), typ->comment());
+ }
+
+ if ( editRegExp ) {
+ // The editor was available, so lets use it.
+ connect( regexpContentCb, TQT_SIGNAL(toggled(bool) ), editRegExp, TQT_SLOT(setEnabled(bool)) );
+ editRegExp->setEnabled(false);
+ connect( editRegExp, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotEditRegExp() ) );
+ }
+ else
+ regexpContentCb->hide();
+
+ // Layout
+ tmp = sizeEdit->fontMetrics().width(" 00000 ");
+ sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height());
+
+ TQGridLayout *grid2 = new TQGridLayout( pages[2], 5, 4,
+ KDialog::marginHint(),
+ KDialog::spacingHint() );
+ grid2->addWidget( typeL, 0, 0 );
+ grid2->addWidget( textL, 1, 0 );
+ grid2->addMultiCellWidget( typeBox, 0, 0, 1, 3 );
+ grid2->addMultiCellWidget( textEdit, 1, 1, 1, 3 );
+ grid2->addWidget( regexpContentCb, 2, 2);
+ grid2->addWidget( caseContextCb, 2, 1 );
+ grid2->addWidget( binaryContextCb, 3, 1);
+
+ grid2->addWidget( textMetaKey, 4, 0 );
+ grid2->addWidget( metainfokeyEdit, 4, 1 );
+ grid2->addWidget( textMetaInfo, 4, 2, Qt::AlignHCenter );
+ grid2->addWidget( metainfoEdit, 4, 3 );
+
+ metainfokeyEdit->setText("*");
+
+ if ( editRegExp ) {
+ // The editor was available, so lets use it.
+ grid2->addWidget( editRegExp, 2, 3 );
+ }
+
+ addTab( pages[0], i18n("Name/&Location") );
+ addTab( pages[2], i18n("C&ontents") );
+ addTab( pages[1], i18n("&Properties") );
+
+
+ // Setup
+ const TQString whatsmetainfo
+ = i18n("<qt>Search within files' specific comments/metainfo<br>"
+ "These are some examples:<br>"
+ "<ul>"
+ "<li><b>Audio files (mp3...)</b> Search in id3 tag for a title, an album</li>"
+ "<li><b>Images (png...)</b> Search images with a special resolution, comment...</li>"
+ "</ul>"
+ "</qt>");
+ const TQString whatsmetainfokey
+ = i18n("<qt>If specified, search only in this field<br>"
+ "<ul>"
+ "<li><b>Audio files (mp3...)</b> This can be Title, Album...</li>"
+ "<li><b>Images (png...)</b> Search only in Resolution, Bitdepth...</li>"
+ "</ul>"
+ "</qt>");
+ TQWhatsThis::add(textMetaInfo,whatsmetainfo);
+ TQToolTip::add(metainfoEdit,whatsmetainfo);
+ TQWhatsThis::add(textMetaKey,whatsmetainfokey);
+ TQToolTip::add(metainfokeyEdit,whatsmetainfokey);
+
+
+ fixLayout();
+ loadHistory();
+}
+
+KfindTabWidget::~KfindTabWidget()
+{
+ delete pages[0];
+ delete pages[1];
+ delete pages[2];
+}
+
+void KfindTabWidget::setURL( const KURL & url )
+{
+ TDEConfig *conf = TDEGlobal::config();
+ conf->setGroup("History");
+ m_url = url;
+ TQStringList sl = conf->readPathListEntry("Directories");
+ dirBox->clear(); // make sure there is no old Stuff in there
+
+ if(!sl.isEmpty()) {
+ dirBox->insertStringList(sl);
+ // If the _searchPath already exists in the list we do not
+ // want to add it again
+ int indx = sl.findIndex(m_url.prettyURL());
+ if(indx == -1)
+ dirBox->insertItem(m_url.prettyURL(), 0); // make it the first one
+ else
+ dirBox->setCurrentItem(indx);
+ }
+ else {
+ TQDir m_dir("/lib");
+ dirBox ->insertItem( m_url.prettyURL() );
+ dirBox ->insertItem( "file:" + TQDir::homeDirPath() );
+ dirBox ->insertItem( "file:/" );
+ dirBox ->insertItem( "file:/usr" );
+ if (m_dir.exists())
+ dirBox ->insertItem( "file:/lib" );
+ dirBox ->insertItem( "file:/home" );
+ dirBox ->insertItem( "file:/etc" );
+ dirBox ->insertItem( "file:/var" );
+ dirBox ->insertItem( "file:/mnt" );
+ }
+}
+
+void KfindTabWidget::initMimeTypes()
+{
+ KMimeType::List tmp = KMimeType::allMimeTypes();
+ KSortedMimeTypeList sortedList;
+ for ( KMimeType::List::ConstIterator it = tmp.begin();
+ it != tmp.end(); ++it )
+ {
+ KMimeType * type = *it;
+ if ((!type->comment().isEmpty())
+ && (!type->name().startsWith("kdedevice/"))
+ && (!type->name().startsWith("all/")))
+ sortedList.append(type);
+ }
+ sortedList.sort();
+ for ( KMimeType *type = sortedList.first(); type; type = sortedList.next())
+ {
+ m_types.append(type);
+ }
+}
+
+void KfindTabWidget::initSpecialMimeTypes()
+{
+ KMimeType::List tmp = KMimeType::allMimeTypes();
+
+ for ( KMimeType::List::ConstIterator it = tmp.begin(); it != tmp.end(); ++it )
+ {
+ KMimeType * type = *it;
+
+ if(!type->comment().isEmpty()) {
+ if(type->name().startsWith("image/"))
+ m_ImageTypes.append(type->name());
+ else if(type->name().startsWith("video/"))
+ m_VideoTypes.append(type->name());
+ else if(type->name().startsWith("audio/"))
+ m_AudioTypes.append(type->name());
+ }
+ }
+}
+
+void KfindTabWidget::saveHistory()
+{
+ save_pattern(nameBox, "History", "Patterns");
+ save_pattern(dirBox, "History", "Directories");
+}
+
+void KfindTabWidget::loadHistory()
+{
+ // Load pattern history
+ TDEConfig *conf = TDEGlobal::config();
+ conf->setGroup("History");
+ TQStringList sl = conf->readListEntry("Patterns");
+ if(!sl.isEmpty())
+ nameBox->insertStringList(sl);
+ else
+ nameBox->insertItem("*");
+
+ sl = conf->readPathListEntry("Directories");
+ if(!sl.isEmpty()) {
+ dirBox->insertStringList(sl);
+ // If the _searchPath already exists in the list we do not
+ // want to add it again
+ int indx = sl.findIndex(m_url.prettyURL());
+ if(indx == -1)
+ dirBox->insertItem(m_url.prettyURL(), 0); // make it the first one
+ else
+ dirBox->setCurrentItem(indx);
+ }
+ else {
+ TQDir m_dir("/lib");
+ dirBox ->insertItem( m_url.prettyURL() );
+ dirBox ->insertItem( "file:" + TQDir::homeDirPath() );
+ dirBox ->insertItem( "file:/" );
+ dirBox ->insertItem( "file:/usr" );
+ if (m_dir.exists())
+ dirBox ->insertItem( "file:/lib" );
+ dirBox ->insertItem( "file:/home" );
+ dirBox ->insertItem( "file:/etc" );
+ dirBox ->insertItem( "file:/var" );
+ dirBox ->insertItem( "file:/mnt" );
+ }
+}
+
+void KfindTabWidget::slotEditRegExp()
+{
+ if ( ! regExpDialog )
+ regExpDialog = KParts::ComponentFactory::createInstanceFromQuery<TQDialog>( "KRegExpEditor/KRegExpEditor", TQString(), TQT_TQOBJECT(this) );
+
+ KRegExpEditorInterface *iface = static_cast<KRegExpEditorInterface *>( regExpDialog->tqt_cast( "KRegExpEditorInterface" ) );
+ if ( !iface )
+ return;
+
+ iface->setRegExp( textEdit->text() );
+ bool ok = regExpDialog->exec();
+ if ( ok )
+ textEdit->setText( iface->regExp() );
+}
+
+void KfindTabWidget::setFocus()
+{
+ nameBox->setFocus();
+ nameBox->lineEdit()->selectAll();
+}
+
+void KfindTabWidget::slotSizeBoxChanged(int index)
+{
+ sizeEdit->setEnabled((bool)(index != 0));
+ sizeUnitBox->setEnabled((bool)(index != 0));
+}
+
+void KfindTabWidget::setDefaults()
+{
+ TQDate dt = TDEGlobal::locale()->calendar()->addYears(TQDate::currentDate(), -1);
+
+ fromDate ->setDate(dt);
+ toDate ->setDate(TQDate::currentDate());
+
+ timeBox->setValue(1);
+ betweenType->setCurrentItem(1);
+
+ typeBox ->setCurrentItem(0);
+ sizeBox ->setCurrentItem(0);
+ sizeUnitBox ->setCurrentItem(1);
+ sizeEdit->setValue(1);
+}
+
+/*
+ Checks if dates are correct and popups a error box
+ if they are not.
+*/
+bool KfindTabWidget::isDateValid()
+{
+ // All files
+ if ( !findCreated->isChecked() ) return TRUE;
+
+ if (rb[1]->isChecked())
+ {
+ if (timeBox->value() > 0 ) return TRUE;
+
+ KMessageBox::sorry(this, i18n("Unable to search within a period that is less than a minute."));
+ return FALSE;
+ }
+
+ // If we can not parse either of the dates or
+ // "from" date is bigger than "to" date return FALSE.
+ TQDate hi1, hi2;
+
+ TQString str;
+ if ( ! fromDate->getDate(&hi1).isValid() ||
+ ! toDate->getDate(&hi2).isValid() )
+ str = i18n("The date is not valid.");
+ else if ( hi1 > hi2 )
+ str = i18n("Invalid date range.");
+ else if ( TQDate::currentDate() < hi1 )
+ str = i18n("Unable to search dates in the future.");
+
+ if (!str.isNull()) {
+ KMessageBox::sorry(0, str);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void KfindTabWidget::setQuery(KQuery *query)
+{
+ TDEIO::filesize_t size;
+ TDEIO::filesize_t sizeunit;
+ bool itemAlreadyContained(false);
+ // only start if we have valid dates
+ if (!isDateValid()) return;
+
+ query->setPath(KURL(dirBox->currentText().stripWhiteSpace()));
+
+ for (int idx=0; idx<dirBox->count(); idx++)
+ if (dirBox->text(idx)==dirBox->currentText())
+ itemAlreadyContained=true;
+
+ if (!itemAlreadyContained)
+ dirBox->insertItem(dirBox->currentText().stripWhiteSpace(),0);
+
+ TQString regex = nameBox->currentText().isEmpty() ? "*" : nameBox->currentText();
+ query->setRegExp(regex, caseSensCb->isChecked());
+ itemAlreadyContained=false;
+ for (int idx=0; idx<nameBox->count(); idx++)
+ if (nameBox->text(idx)==nameBox->currentText())
+ itemAlreadyContained=true;
+
+ if (!itemAlreadyContained)
+ nameBox->insertItem(nameBox->currentText(),0);
+
+ query->setRecursive(subdirsCb->isChecked());
+
+ switch (sizeUnitBox->currentItem())
+ {
+ case 0:
+ sizeunit = 1; //one byte
+ break;
+ case 2:
+ sizeunit = 1048576; //1M
+ break;
+ case 3:
+ sizeunit = 1073741824; //1GB
+ break;
+ case 1: //fall to default case
+ default:
+ sizeunit = 1024; //1k
+ break;
+ }
+ size = sizeEdit->value() * sizeunit;
+
+// TODO: troeder: do we need this check since it is very unlikely-
+// to exceed ULLONG_MAX with INT_MAX * 1024^3.-
+// Or is there an arch where this can happen?
+#if 0
+ if (size < 0) // overflow
+ if (KMessageBox::warningYesNo(this, i18n("Size is too big. Set maximum size value?"), i18n("Error"),i18n("Set"),i18n("Do Not Set"))
+ == KMessageBox::Yes)
+ {
+ sizeEdit->setValue(INT_MAX);
+ sizeUnitBox->setCurrentItem(0);
+ size = INT_MAX;
+ }
+ else
+ return;
+#endif
+
+ // set range mode and size value
+ query->setSizeRange(sizeBox->currentItem(),size,0);
+
+ // dates
+ TQDateTime epoch;
+ epoch.setTime_t(0);
+
+ // Add date predicate
+ if (findCreated->isChecked()) { // Modified
+ if (rb[0]->isChecked()) { // Between dates
+ TQDate q1, q2;
+ fromDate->getDate(&q1);
+ toDate->getDate(&q2);
+
+ // do not generate negative numbers .. find doesn't handle that
+ time_t time1 = epoch.secsTo(TQDateTime(q1));
+ time_t time2 = epoch.secsTo(TQDateTime(q2.addDays(1))) - 1; // Include the last day
+
+ query->setTimeRange(time1, time2);
+ }
+ else
+ {
+ time_t cur = time(NULL);
+ time_t minutes = cur;
+
+ switch (betweenType->currentItem())
+ {
+ case 0: // minutes
+ minutes = timeBox->value();
+ break;
+ case 1: // hours
+ minutes = 60 * timeBox->value();
+ break;
+ case 2: // days
+ minutes = 60 * 24 * timeBox->value();
+ break;
+ case 3: // months
+ minutes = 60 * 24 * (time_t)(timeBox->value() * 30.41667);
+ break;
+ case 4: // years
+ minutes = 12 * 60 * 24 * (time_t)(timeBox->value() * 30.41667);
+ break;
+ }
+
+ query->setTimeRange(cur - minutes * 60, 0);
+ }
+ }
+ else
+ query->setTimeRange(0, 0);
+
+ query->setUsername( m_usernameBox->currentText() );
+ query->setGroupname( m_groupBox->currentText() );
+
+ query->setFileType(typeBox->currentItem());
+
+ int id = typeBox->currentItem()-10;
+
+ if ((id >= -3) && (id < (int) m_types.count()))
+ {
+ switch(id)
+ {
+ case -3:
+ query->setMimeType( m_ImageTypes );
+ break;
+ case -2:
+ query->setMimeType( m_VideoTypes );
+ break;
+ case -1:
+ query->setMimeType( m_AudioTypes );
+ break;
+ default:
+ query->setMimeType( m_types[id]->name() );
+ }
+ }
+ else
+ {
+ query->setMimeType( TQString() );
+ }
+
+ //Metainfo
+ query->setMetaInfo(metainfoEdit->text(), metainfokeyEdit->text());
+
+ //Use locate to speed-up search ?
+ query->setUseFileIndex(useLocateCb->isChecked());
+
+ query->setContext(textEdit->text(), caseContextCb->isChecked(),
+ binaryContextCb->isChecked(), regexpContentCb->isChecked());
+}
+
+TQString KfindTabWidget::date2String(const TQDate & date) {
+ return(TDEGlobal::locale()->formatDate(date, true));
+}
+
+TQDate &KfindTabWidget::string2Date(const TQString & str, TQDate *qd) {
+ return *qd = TDEGlobal::locale()->readDate(str);
+}
+
+void KfindTabWidget::getDirectory()
+{
+ TQString result =
+ KFileDialog::getExistingDirectory( dirBox->text(dirBox->currentItem()).stripWhiteSpace(),
+ this );
+
+ if (!result.isEmpty())
+ {
+ for (int i = 0; i < dirBox->count(); i++)
+ if (result == dirBox->text(i)) {
+ dirBox->setCurrentItem(i);
+ return;
+ }
+ dirBox->insertItem(result, 0);
+ dirBox->setCurrentItem(0);
+ }
+}
+
+void KfindTabWidget::beginSearch()
+{
+/// dirlister->openURL(KURL(dirBox->currentText().stripWhiteSpace()));
+
+ saveHistory();
+ setEnabled( FALSE );
+}
+
+void KfindTabWidget::endSearch()
+{
+ setEnabled( TRUE );
+}
+
+/*
+ Disables/enables all edit fields depending on their
+ respective check buttons.
+*/
+void KfindTabWidget::fixLayout()
+{
+ int i;
+ // If "All files" is checked - disable all edits
+ // and second radio group on page two
+
+ if(! findCreated->isChecked()) {
+ fromDate->setEnabled(FALSE);
+ toDate->setEnabled(FALSE);
+ timeBox->setEnabled(FALSE);
+ for(i=0; i<2; i++)
+ rb[i]->setEnabled(FALSE);
+ betweenType->setEnabled(FALSE);
+ }
+ else {
+ for(i=0; i<2; i++)
+ rb[i]->setEnabled(TRUE);
+
+ fromDate->setEnabled(rb[0]->isChecked());
+ toDate->setEnabled(rb[0]->isChecked());
+ timeBox->setEnabled(rb[1]->isChecked());
+ betweenType->setEnabled(rb[1]->isChecked());
+ }
+
+ // Size box on page three
+ sizeEdit->setEnabled(sizeBox->currentItem() != 0);
+ sizeUnitBox->setEnabled(sizeBox->currentItem() != 0);
+}
+
+bool KfindTabWidget::isSearchRecursive()
+{
+ return subdirsCb->isChecked();
+}
+
+
+/**
+ Digit validator. Allows only digits to be typed.
+**/
+KDigitValidator::KDigitValidator( TQWidget * parent, const char *name )
+ : TQValidator( TQT_TQOBJECT(parent), name )
+{
+ r = new TQRegExp("^[0-9]*$");
+}
+
+KDigitValidator::~KDigitValidator()
+{
+ delete r;
+}
+
+TQValidator::State KDigitValidator::validate( TQString & input, int & ) const
+{
+ if (r->search(input) < 0) {
+ // Beep on user if he enters non-digit
+ TQApplication::beep();
+ return TQValidator::Invalid;
+ }
+ else
+ return TQValidator::Acceptable;
+}
+
+//*******************************************************
+// Static utility functions
+//*******************************************************
+static void save_pattern(TQComboBox *obj,
+ const TQString & group, const TQString & entry)
+{
+ // TQComboBox allows insertion of items more than specified by
+ // maxCount() (QT bug?). This API call will truncate list if needed.
+ obj->setMaxCount(15);
+
+ // make sure the current item is saved first so it will be the
+ // default when started next time
+ TQStringList sl;
+ TQString cur = obj->currentText();
+ sl.append(cur);
+ for (int i = 0; i < obj->count(); i++) {
+ if( cur != obj->text(i) ) {
+ sl.append(obj->text(i));
+ }
+ }
+
+ TDEConfig *conf = TDEGlobal::config();
+ conf->setGroup(group);
+ conf->writePathEntry(entry, sl);
+}
+
+TQSize KfindTabWidget::sizeHint() const
+{
+ // #44662: avoid a huge default size when the comboboxes have very large items
+ // Like in minicli, we changed the combobox size policy so that they can resize down,
+ // and then we simply provide a reasonable size hint for the whole window, depending
+ // on the screen width.
+ TQSize sz = TQTabWidget::sizeHint();
+ KfindTabWidget* me = const_cast<KfindTabWidget*>( this );
+ const int screenWidth = tqApp->desktop()->screenGeometry(me).width();
+ if ( sz.width() > screenWidth / 2 )
+ sz.setWidth( screenWidth / 2 );
+ return sz;
+}
+
+#include "kftabdlg.moc"
diff --git a/kfind/kftabdlg.h b/kfind/kftabdlg.h
new file mode 100644
index 000000000..c080c44d4
--- /dev/null
+++ b/kfind/kftabdlg.h
@@ -0,0 +1,136 @@
+/***********************************************************************
+ *
+ * kftabdlg.h
+ *
+ ***********************************************************************/
+
+#ifndef KFTABDLG_H
+#define KFTABDLG_H
+
+#include <tqtabwidget.h>
+#include <tqvalidator.h> // for KDigitValidator
+
+#include <kurl.h>
+#include <kmimetype.h>
+
+#include "kdatecombo.h"
+
+class TQButtonGroup;
+class TQPushButton;
+class TQRadioButton;
+class TQCheckBox;
+class TQLineEdit;
+class TQString;
+class TQDate;
+class TQRegExp;
+class TQDialog;
+class TQComboBox;
+class TQSpinBox;
+
+class KfDirDialog;
+
+class KfindTabWidget: public TQTabWidget
+{
+ Q_OBJECT
+
+public:
+ KfindTabWidget(TQWidget * parent = 0, const char *name=0);
+ virtual ~KfindTabWidget();
+ void initMimeTypes();
+ void initSpecialMimeTypes();
+ void setQuery(class KQuery * query);
+ void setDefaults();
+
+ void beginSearch();
+ void endSearch();
+ void loadHistory();
+ void saveHistory();
+ bool isSearchRecursive();
+
+ void setURL( const KURL & url );
+
+ virtual TQSize sizeHint() const;
+
+public slots:
+ void setFocus();
+
+private slots:
+ void getDirectory();
+ void fixLayout();
+ void slotSizeBoxChanged(int);
+ void slotEditRegExp();
+
+signals:
+ void startSearch();
+
+protected:
+public:
+ TQComboBox *nameBox;
+ TQComboBox *dirBox;
+ // for first page
+ TQCheckBox *subdirsCb;
+ TQCheckBox *useLocateCb;
+ // for third page
+ TQComboBox *typeBox;
+ TQLineEdit * textEdit;
+ TQCheckBox *caseSensCb;
+ TQComboBox *m_usernameBox;
+ TQComboBox *m_groupBox;
+ //for fourth page
+ TQLineEdit *metainfoEdit;
+ TQLineEdit *metainfokeyEdit;
+
+private:
+ bool isDateValid();
+
+ TQString date2String(const TQDate &);
+ TQDate &string2Date(const TQString &, TQDate * );
+
+ TQWidget *pages[3];
+
+ //1st page
+ TQPushButton *browseB;
+
+ KfDirDialog *dirselector;
+
+ //2nd page
+ TQCheckBox *findCreated;
+ TQComboBox *betweenType;
+ TQButtonGroup *bg;
+ TQRadioButton *rb[2];
+ KDateCombo * fromDate;
+ KDateCombo * toDate;
+ TQSpinBox *timeBox;
+
+ //3rd page
+ TQComboBox *sizeBox;
+ TQComboBox *sizeUnitBox;
+ TQSpinBox *sizeEdit;
+ TQCheckBox *caseContextCb;
+ TQCheckBox *binaryContextCb;
+ TQCheckBox *regexpContentCb;
+ TQDialog *regExpDialog;
+
+ KURL m_url;
+
+ KMimeType::List m_types;
+ TQStringList m_ImageTypes;
+ TQStringList m_VideoTypes;
+ TQStringList m_AudioTypes;
+};
+
+class KDigitValidator : public TQValidator
+{
+ Q_OBJECT
+
+public:
+ KDigitValidator(TQWidget * parent, const char *name = 0 );
+ ~KDigitValidator();
+
+ TQValidator::State validate(TQString & input, int &) const;
+
+ private:
+ TQRegExp *r;
+};
+
+#endif
diff --git a/kfind/kfwin.cpp b/kfind/kfwin.cpp
new file mode 100644
index 000000000..f068d031e
--- /dev/null
+++ b/kfind/kfwin.cpp
@@ -0,0 +1,434 @@
+/***********************************************************************
+ *
+ * Kfwin.cpp
+ *
+ **********************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <pwd.h>
+#include <grp.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <time.h>
+
+#include <tqtextstream.h>
+#include <tqfileinfo.h>
+#include <tqdir.h>
+#include <tqclipboard.h>
+#include <tqpixmap.h>
+#include <tqdragobject.h>
+
+#include <tdefiledialog.h>
+#include <tdelocale.h>
+#include <tdeapplication.h>
+#include <krun.h>
+#include <kprocess.h>
+#include <kpropertiesdialog.h>
+#include <kstandarddirs.h>
+#include <tdemessagebox.h>
+#include <kmimetype.h>
+#include <tdeglobal.h>
+#include <tdepopupmenu.h>
+#include <tdeio/netaccess.h>
+#include <kurldrag.h>
+#include <tqptrlist.h>
+#include <kdebug.h>
+#include <kiconloader.h>
+
+#include "kfwin.h"
+
+#include "kfwin.moc"
+
+template class TQPtrList<KfFileLVI>;
+
+// Permission strings
+static const char* perm[4] = {
+ I18N_NOOP( "Read-write" ),
+ I18N_NOOP( "Read-only" ),
+ I18N_NOOP( "Write-only" ),
+ I18N_NOOP( "Inaccessible" ) };
+#define RW 0
+#define RO 1
+#define WO 2
+#define NA 3
+
+KfFileLVI::KfFileLVI(KfindWindow* lv, const KFileItem &item, const TQString& matchingLine)
+ : TQListViewItem(lv),
+ fileitem(item)
+{
+ fileInfo = new TQFileInfo(item.url().path());
+
+ TQString size = TDEGlobal::locale()->formatNumber(item.size(), 0);
+
+ TQDateTime dt;
+ dt.setTime_t(item.time(TDEIO::UDS_MODIFICATION_TIME));
+ TQString date = TDEGlobal::locale()->formatDateTime(dt);
+
+ int perm_index;
+ if(fileInfo->isReadable())
+ perm_index = fileInfo->isWritable() ? RW : RO;
+ else
+ perm_index = fileInfo->isWritable() ? WO : NA;
+
+ // Fill the item with data
+ setText(0, item.url().fileName(false));
+ setText(1, lv->reducedDir(item.url().directory(false)));
+ setText(2, size);
+ setText(3, date);
+ setText(4, i18n(perm[perm_index]));
+ setText(5, matchingLine);
+
+ // put the icon into the leftmost column
+ setPixmap(0, item.pixmap(16));
+}
+
+KfFileLVI::~KfFileLVI()
+{
+ delete fileInfo;
+}
+
+TQString KfFileLVI::key(int column, bool) const
+{
+ switch (column) {
+ case 2:
+ // Returns size in bytes. Used for sorting
+ return TQString().sprintf("%010d", fileInfo->size());
+ case 3:
+ // Returns time in secs from 1/1/1970. Used for sorting
+ return TQString().sprintf("%010ld", fileitem.time(TDEIO::UDS_MODIFICATION_TIME));
+ }
+
+ return text(column);
+}
+
+KfindWindow::KfindWindow( TQWidget *parent, const char *name )
+ : TDEListView( parent, name )
+,m_baseDir("")
+,m_menu(0)
+{
+ setSelectionMode( TQListView::Extended );
+ setShowSortIndicator( TRUE );
+
+ addColumn(i18n("Name"));
+ addColumn(i18n("In Subfolder"));
+ addColumn(i18n("Size"));
+ setColumnAlignment(2, AlignRight);
+ addColumn(i18n("Modified"));
+ setColumnAlignment(3, AlignRight);
+ addColumn(i18n("Permissions"));
+ setColumnAlignment(4, AlignRight);
+
+ addColumn(i18n("First Matching Line"));
+ setColumnAlignment(5, AlignLeft);
+
+ // Disable autoresize for all columns
+ // Resizing is done by resetColumns() function
+ for (int i = 0; i < 6; i++)
+ setColumnWidthMode(i, Manual);
+
+ resetColumns(true);
+
+ connect( this, TQT_SIGNAL(selectionChanged()),
+ this, TQT_SLOT( selectionHasChanged() ));
+
+ connect(this, TQT_SIGNAL(contextMenu(TDEListView *, TQListViewItem*,const TQPoint&)),
+ this, TQT_SLOT(slotContextMenu(TDEListView *,TQListViewItem*,const TQPoint&)));
+
+ connect(this, TQT_SIGNAL(executed(TQListViewItem*)),
+ this, TQT_SLOT(slotExecute(TQListViewItem*)));
+ setDragEnabled(true);
+
+}
+
+
+TQString KfindWindow::reducedDir(const TQString& fullDir)
+{
+ if (fullDir.find(m_baseDir)==0)
+ {
+ TQString tmp=fullDir.mid(m_baseDir.length());
+ return tmp;
+ };
+ return fullDir;
+}
+
+void KfindWindow::beginSearch(const KURL& baseUrl)
+{
+ kdDebug()<<TQString(TQString("beginSearch in: %1").arg(baseUrl.path()))<<endl;
+ m_baseDir=baseUrl.path(+1);
+ haveSelection = false;
+ clear();
+}
+
+void KfindWindow::endSearch()
+{
+}
+
+void KfindWindow::insertItem(const KFileItem &item, const TQString& matchingLine)
+{
+ new KfFileLVI(this, item, matchingLine);
+}
+
+// copy to clipboard aka X11 selection
+void KfindWindow::copySelection()
+{
+ TQDragObject *drag_obj = dragObject();
+
+ if (drag_obj)
+ {
+ TQClipboard *cb = kapp->clipboard();
+ cb->setData(drag_obj);
+ }
+}
+
+void KfindWindow::saveResults()
+{
+ TQListViewItem *item;
+
+ KFileDialog *dlg = new KFileDialog(TQString::null, TQString::null, this,
+ "filedialog", true);
+ dlg->setOperationMode (KFileDialog::Saving);
+
+ dlg->setCaption(i18n("Save Results As"));
+
+ TQStringList list;
+
+ list << "text/plain" << "text/html";
+
+ dlg->setOperationMode(KFileDialog::Saving);
+
+ dlg->setMimeFilter(list, TQString("text/plain"));
+
+ dlg->exec();
+
+ KURL u = dlg->selectedURL();
+ KMimeType::Ptr mimeType = dlg->currentFilterMimeType();
+ delete dlg;
+
+ if (!u.isValid() || !u.isLocalFile())
+ return;
+
+ TQString filename = u.path();
+
+ TQFile file(filename);
+
+ if ( !file.open(IO_WriteOnly) )
+ KMessageBox::error(parentWidget(),
+ i18n("Unable to save results."));
+ else {
+ TQTextStream stream( &file );
+ stream.setEncoding( TQTextStream::Locale );
+
+ if ( mimeType->name() == "text/html") {
+ stream << TQString::fromLatin1("<HTML><HEAD>\n"
+ "<!DOCTYPE %1>\n"
+ "<TITLE>%2</TITLE></HEAD>\n"
+ "<BODY><H1>%3</H1>"
+ "<DL><p>\n")
+ .arg(i18n("KFind Results File"))
+ .arg(i18n("KFind Results File"))
+ .arg(i18n("KFind Results File"));
+
+ item = firstChild();
+ while(item != NULL)
+ {
+ TQString path=((KfFileLVI*)item)->fileitem.url().url();
+ TQString pretty=((KfFileLVI*)item)->fileitem.url().htmlURL();
+ stream << TQString::fromLatin1("<DT><A HREF=\"") << path
+ << TQString::fromLatin1("\">") << pretty
+ << TQString::fromLatin1("</A>\n");
+
+ item = item->nextSibling();
+ }
+ stream << TQString::fromLatin1("</DL><P></BODY></HTML>\n");
+ }
+ else {
+ item = firstChild();
+ while(item != NULL)
+ {
+ TQString path=((KfFileLVI*)item)->fileitem.url().url();
+ stream << path << endl;
+ item = item->nextSibling();
+ }
+ }
+
+ file.close();
+ KMessageBox::information(parentWidget(),
+ i18n("Results were saved to file\n")+
+ filename);
+ }
+}
+
+// This function is called when selection is changed (both selected/deselected)
+// It notifies the parent about selection status and enables/disables menubar
+void KfindWindow::selectionHasChanged()
+{
+ emit resultSelected(true);
+
+ TQListViewItem *item = firstChild();
+ while(item != 0L)
+ {
+ if(isSelected(item)) {
+ emit resultSelected( true );
+ haveSelection = true;
+ return;
+ }
+
+ item = item->nextSibling();
+ }
+
+ haveSelection = false;
+ emit resultSelected(false);
+}
+
+void KfindWindow::deleteFiles()
+{
+ TQString tmp = i18n("Do you really want to delete the selected file?",
+ "Do you really want to delete the %n selected files?",selectedItems().count());
+ if (KMessageBox::warningContinueCancel(parentWidget(), tmp, "", KGuiItem( i18n("&Delete"), "edit-delete")) == KMessageBox::Cancel)
+ return;
+
+ // Iterate on all selected elements
+ TQPtrList<TQListViewItem> selected = selectedItems();
+ for ( uint i = 0; i < selected.count(); i++ ) {
+ KfFileLVI *item = (KfFileLVI *) selected.at(i);
+ KFileItem file = item->fileitem;
+
+ TDEIO::NetAccess::del(file.url(), this);
+ }
+ selected.setAutoDelete(true);
+}
+
+void KfindWindow::fileProperties()
+{
+ // This dialog must be modal because it parent dialog is modal as well.
+ // Non-modal property dialog will hide behind the main window
+ (void) new KPropertiesDialog( &((KfFileLVI *)currentItem())->fileitem, this,
+ "propDialog", true);
+}
+
+void KfindWindow::openFolder()
+{
+ KFileItem fileitem = ((KfFileLVI *)currentItem())->fileitem;
+ KURL url = fileitem.url();
+ url.setFileName(TQString::null);
+
+ (void) new KRun(url);
+}
+
+void KfindWindow::openBinding()
+{
+ ((KfFileLVI*)currentItem())->fileitem.run();
+}
+
+void KfindWindow::slotExecute(TQListViewItem* item)
+{
+ if (item==0)
+ return;
+ ((KfFileLVI*)item)->fileitem.run();
+}
+
+// Resizes TDEListView to occupy all visible space
+void KfindWindow::resizeEvent(TQResizeEvent *e)
+{
+ TDEListView::resizeEvent(e);
+ resetColumns(false);
+ clipper()->repaint();
+}
+
+TQDragObject * KfindWindow::dragObject()
+{
+ KURL::List uris;
+ TQPtrList<TQListViewItem> selected = selectedItems();
+
+ // create a list of URIs from selection
+ for ( uint i = 0; i < selected.count(); i++ )
+ {
+ KfFileLVI *item = (KfFileLVI *) selected.at( i );
+ if (item)
+ {
+ uris.append( item->fileitem.url() );
+ }
+ }
+
+ if ( uris.count() <= 0 )
+ return 0;
+
+ TQUriDrag *ud = new KURLDrag( uris, (TQWidget *) this, "kfind uridrag" );
+
+ const TQPixmap *pix = currentItem()->pixmap(0);
+ if ( pix && !pix->isNull() )
+ ud->setPixmap( *pix );
+
+ return ud;
+}
+
+void KfindWindow::resetColumns(bool init)
+{
+ TQFontMetrics fm = fontMetrics();
+ if (init)
+ {
+ setColumnWidth(2, TQMAX(fm.width(columnText(2)), fm.width("0000000")) + 15);
+ TQString sampleDate =
+ TDEGlobal::locale()->formatDateTime(TQDateTime::currentDateTime());
+ setColumnWidth(3, TQMAX(fm.width(columnText(3)), fm.width(sampleDate)) + 15);
+ setColumnWidth(4, TQMAX(fm.width(columnText(4)), fm.width(i18n(perm[RO]))) + 15);
+ setColumnWidth(5, TQMAX(fm.width(columnText(5)), fm.width("some text")) + 15);
+ }
+
+ int free_space = visibleWidth() -
+ columnWidth(2) - columnWidth(3) - columnWidth(4) - columnWidth(5);
+
+// int name_w = TQMIN((int)(free_space*0.5), 150);
+// int dir_w = free_space - name_w;
+ int name_w = TQMAX((int)(free_space*0.5), fm.width("some long filename"));
+ int dir_w = name_w;
+
+ setColumnWidth(0, name_w);
+ setColumnWidth(1, dir_w);
+}
+
+void KfindWindow::slotContextMenu(TDEListView *,TQListViewItem *item,const TQPoint&p)
+{
+ if (!item) return;
+ int count = selectedItems().count();
+
+ if (count == 0)
+ {
+ return;
+ };
+
+ if (m_menu==0)
+ m_menu = new TDEPopupMenu(this);
+ else
+ m_menu->clear();
+
+ if (count == 1)
+ {
+ //menu = new TDEPopupMenu(item->text(0), this);
+ m_menu->insertTitle(item->text(0));
+ m_menu->insertItem(SmallIcon("document-open"),i18n("Menu item", "Open"), this, TQT_SLOT(openBinding()));
+ m_menu->insertItem(SmallIcon("window-new"),i18n("Open Folder"), this, TQT_SLOT(openFolder()));
+ m_menu->insertSeparator();
+ m_menu->insertItem(SmallIcon("edit-copy"),i18n("Copy"), this, TQT_SLOT(copySelection()));
+ m_menu->insertItem(SmallIcon("edit-delete"),i18n("Delete"), this, TQT_SLOT(deleteFiles()));
+ m_menu->insertSeparator();
+ m_menu->insertItem(i18n("Open With..."), this, TQT_SLOT(slotOpenWith()));
+ m_menu->insertSeparator();
+ m_menu->insertItem(i18n("Properties"), this, TQT_SLOT(fileProperties()));
+ }
+ else
+ {
+ m_menu->insertTitle(i18n("Selected Files"));
+ m_menu->insertItem(SmallIcon("edit-copy"),i18n("Copy"), this, TQT_SLOT(copySelection()));
+ m_menu->insertItem(SmallIcon("edit-delete"),i18n("Delete"), this, TQT_SLOT(deleteFiles()));
+ }
+ m_menu->popup(p, 1);
+}
+
+void KfindWindow::slotOpenWith()
+{
+ KRun::displayOpenWithDialog( KURL::split(((KfFileLVI*)currentItem())->fileitem.url()) );
+}
diff --git a/kfind/kfwin.h b/kfind/kfwin.h
new file mode 100644
index 000000000..5a019a382
--- /dev/null
+++ b/kfind/kfwin.h
@@ -0,0 +1,75 @@
+/***********************************************************************
+ *
+ * Kfwin.h
+ *
+ ***********************************************************************/
+
+#ifndef KFWIN_H
+#define KFWIN_H
+
+#include <tdelistview.h>
+#include <tdefileitem.h>
+#include <kurl.h>
+
+class KfArchiver;
+class TQPixmap;
+class TQFileInfo;
+class TDEPopupMenu;
+class KfindWindow;
+
+class KfFileLVI : public TQListViewItem
+{
+ public:
+ KfFileLVI(KfindWindow* lv, const KFileItem &item,const TQString& matchingLine);
+ ~KfFileLVI();
+
+ TQString key(int column, bool) const;
+
+ TQFileInfo *fileInfo;
+ KFileItem fileitem;
+};
+
+class KfindWindow: public TDEListView
+{
+ Q_OBJECT
+public:
+ KfindWindow( TQWidget * parent = 0, const char * name = 0 );
+
+ void beginSearch(const KURL& baseUrl);
+ void endSearch();
+
+ void insertItem(const KFileItem &item, const TQString& matchingLine);
+
+ TQString reducedDir(const TQString& fullDir);
+
+public slots:
+ void copySelection();
+ void slotContextMenu(TDEListView *,TQListViewItem *item,const TQPoint&p);
+
+private slots:
+ void deleteFiles();
+ void fileProperties();
+ void openFolder();
+ void saveResults();
+ void openBinding();
+ void selectionHasChanged();
+ void slotExecute(TQListViewItem*);
+ void slotOpenWith();
+
+protected:
+ virtual void resizeEvent(TQResizeEvent *e);
+
+ virtual TQDragObject *dragObject();
+
+signals:
+ void resultSelected(bool);
+
+private:
+ TQString m_baseDir;
+ TDEPopupMenu *m_menu;
+ bool haveSelection;
+ bool m_pressed;
+ void resetColumns(bool init);
+};
+
+#endif
diff --git a/kfind/kquery.cpp b/kfind/kquery.cpp
new file mode 100644
index 000000000..1e3617c70
--- /dev/null
+++ b/kfind/kquery.cpp
@@ -0,0 +1,532 @@
+#include <stdlib.h>
+
+#include <tqfileinfo.h>
+#include <kdebug.h>
+#include <tdefileitem.h>
+#include <tdefilemetainfo.h>
+#include <tdeapplication.h>
+#include <tdemessagebox.h>
+#include <tdelocale.h>
+#include <kstandarddirs.h>
+#include <kzip.h>
+
+#include "kquery.h"
+
+KQuery::KQuery(TQObject *parent, const char * name)
+ : TQObject(parent, name),
+ m_sizemode(0), m_sizeboundary1(0), m_sizeboundary2(0),
+ m_timeFrom(0), m_timeTo(0),
+ job(0), m_insideCheckEntries(false), m_result(0)
+{
+ m_regexps.setAutoDelete(true);
+ m_fileItems.setAutoDelete(true);
+ processLocate = new TDEProcess(this);
+ connect(processLocate,TQT_SIGNAL(receivedStdout(TDEProcess*, char*, int)),this,TQT_SLOT(slotreceivedSdtout(TDEProcess*,char*,int)));
+ connect(processLocate,TQT_SIGNAL(receivedStderr(TDEProcess*, char*, int)),this,TQT_SLOT(slotreceivedSdterr(TDEProcess*,char*,int)));
+ connect(processLocate,TQT_SIGNAL(processExited(TDEProcess*)),this,TQT_SLOT(slotendProcessLocate(TDEProcess*)));
+
+ // Files with these mime types can be ignored, even if
+ // findFormatByFileContent() in some cases may claim that
+ // these are text files:
+ ignore_mimetypes.append("application/pdf");
+ ignore_mimetypes.append("application/postscript");
+
+ // PLEASE update the documentation when you add another
+ // file type here:
+ ooo_mimetypes.append("application/vnd.sun.xml.writer");
+ ooo_mimetypes.append("application/vnd.sun.xml.calc");
+ ooo_mimetypes.append("application/vnd.sun.xml.impress");
+ // OASIS mimetypes, used by OOo-2.x and KOffice >= 1.4
+ //ooo_mimetypes.append("application/vnd.oasis.opendocument.chart");
+ //ooo_mimetypes.append("application/vnd.oasis.opendocument.graphics");
+ //ooo_mimetypes.append("application/vnd.oasis.opendocument.graphics-template");
+ //ooo_mimetypes.append("application/vnd.oasis.opendocument.formula");
+ //ooo_mimetypes.append("application/vnd.oasis.opendocument.image");
+ ooo_mimetypes.append("application/vnd.oasis.opendocument.presentation-template");
+ ooo_mimetypes.append("application/vnd.oasis.opendocument.presentation");
+ ooo_mimetypes.append("application/vnd.oasis.opendocument.spreadsheet-template");
+ ooo_mimetypes.append("application/vnd.oasis.opendocument.spreadsheet");
+ ooo_mimetypes.append("application/vnd.oasis.opendocument.text-template");
+ ooo_mimetypes.append("application/vnd.oasis.opendocument.text");
+ // KOffice-1.3 mimetypes
+ koffice_mimetypes.append("application/x-kword");
+ koffice_mimetypes.append("application/x-kspread");
+ koffice_mimetypes.append("application/x-kpresenter");
+}
+
+KQuery::~KQuery()
+{
+}
+
+void KQuery::kill()
+{
+ if (job)
+ job->kill(false);
+ if (processLocate->isRunning())
+ processLocate->kill();
+ m_fileItems.clear();
+}
+
+void KQuery::start()
+{
+ m_fileItems.clear();
+ if(m_useLocate) //use "locate" instead of the internal search method
+ {
+ m_url.cleanPath();
+ processLocate->clearArguments();
+ *processLocate << "locate";
+ *processLocate << m_url.path(1).latin1();
+ bufferLocate=NULL;
+ bufferLocateLength=0;
+ processLocate->start(TDEProcess::NotifyOnExit,TDEProcess::AllOutput);
+ return;
+ }
+
+ if (m_recursive)
+ job = TDEIO::listRecursive( m_url, false );
+ else
+ job = TDEIO::listDir( m_url, false );
+
+ connect(job, TQT_SIGNAL(entries(TDEIO::Job *, const TDEIO::UDSEntryList &)),
+ TQT_SLOT(slotListEntries(TDEIO::Job *, const TDEIO::UDSEntryList &)));
+ connect(job, TQT_SIGNAL(result(TDEIO::Job *)), TQT_SLOT(slotResult(TDEIO::Job *)));
+ connect(job, TQT_SIGNAL(canceled(TDEIO::Job *)), TQT_SLOT(slotCanceled(TDEIO::Job *)));
+}
+
+void KQuery::slotResult( TDEIO::Job * _job )
+{
+ if (job != _job) return;
+ job = 0;
+
+ m_result=_job->error();
+ checkEntries();
+}
+
+void KQuery::slotCanceled( TDEIO::Job * _job )
+{
+ if (job != _job) return;
+ job = 0;
+
+ m_fileItems.clear();
+ m_result=TDEIO::ERR_USER_CANCELED;
+ checkEntries();
+}
+
+void KQuery::slotListEntries(TDEIO::Job*, const TDEIO::UDSEntryList& list)
+{
+ KFileItem * file = 0;
+ TDEIO::UDSEntryListConstIterator end = list.end();
+ for (TDEIO::UDSEntryListConstIterator it = list.begin(); it != end; ++it)
+ {
+ file = new KFileItem(*it, m_url, true, true);
+ m_fileItems.enqueue(file);
+ }
+ checkEntries();
+}
+
+void KQuery::checkEntries()
+{
+ if (m_insideCheckEntries)
+ return;
+ m_insideCheckEntries=true;
+ metaKeyRx=new TQRegExp(m_metainfokey,true,true);
+ KFileItem * file = 0;
+ while ((file=m_fileItems.dequeue()))
+ {
+ processQuery(file);
+ delete file;
+ }
+ delete metaKeyRx;
+ m_insideCheckEntries=false;
+ if (job==0)
+ emit result(m_result);
+}
+
+/* List of files found using slocate */
+void KQuery::slotListEntries( TQStringList list )
+{
+ KFileItem * file = 0;
+ metaKeyRx=new TQRegExp(m_metainfokey,true,true);
+
+ TQStringList::Iterator it = list.begin();
+ TQStringList::Iterator end = list.end();
+
+ for (; it != end; ++it)
+ {
+ file = new KFileItem( KFileItem::Unknown, KFileItem::Unknown, KURL::fromPathOrURL(*it));
+ processQuery(file);
+ delete file;
+ }
+
+ delete metaKeyRx;
+}
+
+/* Check if file meets the find's requirements*/
+void KQuery::processQuery( KFileItem* file)
+{
+ TQRegExp *filename_match;
+
+ if ( file->name() == "." || file->name() == ".." )
+ return;
+
+ bool matched=false;
+
+ for ( filename_match = m_regexps.first(); !matched && filename_match; filename_match = m_regexps.next() )
+ {
+ matched |= filename_match->isEmpty() ||
+ (filename_match->exactMatch( file->url().fileName( true ) ) );
+ }
+ if (!matched)
+ return;
+
+ switch( m_sizemode )
+ {
+ case 1: // "at least"
+ if ( file->size() < m_sizeboundary1 ) return;
+ break;
+ case 2: // "at most"
+ if ( file->size() > m_sizeboundary1 ) return;
+ break;
+ case 3: // "equal"
+ if ( file->size() != m_sizeboundary1 ) return;
+ break;
+ case 4: // "between"
+ if ( (file->size() < m_sizeboundary1) || (file->size() > m_sizeboundary2) ) return;
+ break;
+ case 0: // "none" -> fall to default
+ default:
+ break;
+ }
+
+ // make sure it's in the correct date range
+ // what about 0 times?
+ if ( m_timeFrom && m_timeFrom > file->time(TDEIO::UDS_MODIFICATION_TIME) )
+ return;
+ if ( m_timeTo && m_timeTo < file->time(TDEIO::UDS_MODIFICATION_TIME) )
+ return;
+
+ // username / group match
+ if ( (!m_username.isEmpty()) && (m_username != file->user()) )
+ return;
+ if ( (!m_groupname.isEmpty()) && (m_groupname != file->group()) )
+ return;
+
+ // file type
+ switch (m_filetype)
+ {
+ case 0:
+ break;
+ case 1: // plain file
+ if ( !S_ISREG( file->mode() ) )
+ return;
+ break;
+ case 2:
+ if ( !file->isDir() )
+ return;
+ break;
+ case 3:
+ if ( !file->isLink() )
+ return;
+ break;
+ case 4:
+ if ( !S_ISCHR ( file->mode() ) && !S_ISBLK ( file->mode() ) &&
+ !S_ISFIFO( file->mode() ) && !S_ISSOCK( file->mode() ) )
+ return;
+ break;
+ case 5: // binary
+ if ( (file->permissions() & 0111) != 0111 || file->isDir() )
+ return;
+ break;
+ case 6: // suid
+ if ( (file->permissions() & 04000) != 04000 ) // fixme
+ return;
+ break;
+ default:
+ if (!m_mimetype.isEmpty() && !m_mimetype.contains(file->mimetype()))
+ return;
+ }
+
+ // match datas in metainfo...
+ if ((!m_metainfo.isEmpty()) && (!m_metainfokey.isEmpty()))
+ {
+ bool foundmeta=false;
+ TQString filename = file->url().path();
+
+ if(filename.startsWith("/dev/"))
+ return;
+
+ KFileMetaInfo metadatas(filename);
+ KFileMetaInfoItem metaitem;
+ TQStringList metakeys;
+ TQString strmetakeycontent;
+
+ if(metadatas.isEmpty())
+ return;
+
+ metakeys=metadatas.supportedKeys();
+ for ( TQStringList::Iterator it = metakeys.begin(); it != metakeys.end(); ++it )
+ {
+ if (!metaKeyRx->exactMatch(*it))
+ continue;
+ metaitem=metadatas.item(*it);
+ strmetakeycontent=metaitem.string();
+ if(strmetakeycontent.find(m_metainfo)!=-1)
+ {
+ foundmeta=true;
+ break;
+ }
+ }
+ if (!foundmeta)
+ return;
+ }
+
+ // match contents...
+ TQString matchingLine;
+ if (!m_context.isEmpty())
+ {
+
+ if( !m_search_binary && ignore_mimetypes.findIndex(file->mimetype()) != -1 ) {
+ kdDebug() << "ignoring, mime type is in exclusion list: " << file->url() << endl;
+ return;
+ }
+
+ bool found = false;
+ bool isZippedOfficeDocument=false;
+ int matchingLineNumber=0;
+
+ // FIXME: doesn't work with non local files
+
+ TQString filename;
+ TQTextStream* stream=0;
+ TQFile qf;
+ TQRegExp xmlTags;
+ TQByteArray zippedXmlFileContent;
+
+ // KWord's and OpenOffice.org's files are zipped...
+ if( ooo_mimetypes.findIndex(file->mimetype()) != -1 ||
+ koffice_mimetypes.findIndex(file->mimetype()) != -1 )
+ {
+ KZip zipfile(file->url().path());
+ KZipFileEntry *zipfileEntry;
+
+ if(zipfile.open(IO_ReadOnly))
+ {
+ const KArchiveDirectory *zipfileContent = zipfile.directory();
+
+ if( koffice_mimetypes.findIndex(file->mimetype()) != -1 )
+ zipfileEntry = (KZipFileEntry*)zipfileContent->entry("maindoc.xml");
+ else
+ zipfileEntry = (KZipFileEntry*)zipfileContent->entry("content.xml"); //for OpenOffice.org
+
+ if(!zipfileEntry) {
+ kdWarning() << "Expected XML file not found in ZIP archive " << file->url() << endl;
+ return;
+ }
+
+ zippedXmlFileContent = zipfileEntry->data();
+ xmlTags.setPattern("<.*>");
+ xmlTags.setMinimal(true);
+ stream = new TQTextStream(zippedXmlFileContent, IO_ReadOnly);
+ stream->setEncoding(TQTextStream::UnicodeUTF8);
+ isZippedOfficeDocument = true;
+ } else {
+ kdWarning() << "Cannot open supposed ZIP file " << file->url() << endl;
+ }
+ } else if( !m_search_binary && !file->mimetype().startsWith("text/") &&
+ file->url().isLocalFile() ) {
+ KMimeType::Format f = KMimeType::findFormatByFileContent(file->url().path());
+ if ( !f.text ) {
+ kdDebug() << "ignoring, not a text file: " << file->url() << endl;
+ return;
+ }
+ }
+
+ if(!isZippedOfficeDocument) //any other file or non-compressed KWord
+ {
+ filename = file->url().path();
+ if(filename.startsWith("/dev/"))
+ return;
+ qf.setName(filename);
+ qf.open(IO_ReadOnly);
+ stream=new TQTextStream(&qf);
+ stream->setEncoding(TQTextStream::Locale);
+ }
+
+ while ( ! stream->atEnd() )
+ {
+ TQString str = stream->readLine();
+ matchingLineNumber++;
+
+ if (str.isNull()) break;
+ if(isZippedOfficeDocument)
+ str.replace(xmlTags, "");
+
+ if (m_regexpForContent)
+ {
+ if (m_regexp.search(str)>=0)
+ {
+ matchingLine=TQString::number(matchingLineNumber)+": "+str;
+ found = true;
+ break;
+ }
+ }
+ else
+ {
+ if ((!str.isNull()) && (!m_context.isNull())) {
+ if (str.find(m_context, 0, m_casesensitive) != -1)
+ {
+ matchingLine=TQString::number(matchingLineNumber)+": "+str;
+ found = true;
+ break;
+ }
+ }
+ else {
+ return;
+ }
+ }
+ kapp->processEvents();
+ }
+ delete stream;
+
+ if (!found)
+ return;
+ }
+ emit addFile(file,matchingLine);
+}
+
+void KQuery::setContext(const TQString & context, bool casesensitive,
+ bool search_binary, bool useRegexp)
+{
+ m_context = context;
+ m_casesensitive = casesensitive;
+ m_search_binary = search_binary;
+ m_regexpForContent=useRegexp;
+ m_regexp.setWildcard(!m_regexpForContent);
+ m_regexp.setCaseSensitive(casesensitive);
+ if (m_regexpForContent)
+ m_regexp.setPattern(m_context);
+}
+
+void KQuery::setMetaInfo(const TQString &metainfo, const TQString &metainfokey)
+{
+ m_metainfo=metainfo;
+ m_metainfokey=metainfokey;
+}
+
+void KQuery::setMimeType(const TQStringList &mimetype)
+{
+ m_mimetype = mimetype;
+}
+
+void KQuery::setFileType(int filetype)
+{
+ m_filetype = filetype;
+}
+
+void KQuery::setSizeRange(int mode, TDEIO::filesize_t value1, TDEIO::filesize_t value2)
+{
+ m_sizemode = mode;
+ m_sizeboundary1 = value1;
+ m_sizeboundary2 = value2;
+}
+
+void KQuery::setTimeRange(time_t from, time_t to)
+{
+ m_timeFrom = from;
+ m_timeTo = to;
+}
+
+void KQuery::setUsername(TQString username)
+{
+ m_username = username;
+}
+
+void KQuery::setGroupname(TQString groupname)
+{
+ m_groupname = groupname;
+}
+
+
+void KQuery::setRegExp(const TQString &regexp, bool caseSensitive)
+{
+ TQRegExp *regExp;
+ TQRegExp sep(";");
+ TQStringList strList=TQStringList::split( sep, regexp, false);
+// TQRegExp globChars ("[\\*\\?\\[\\]]", TRUE, FALSE);
+
+ m_regexps.clear();
+// m_regexpsContainsGlobs.clear();
+ for ( TQStringList::ConstIterator it = strList.begin(); it != strList.end(); ++it ) {
+ regExp = new TQRegExp((*it),caseSensitive,true);
+// m_regexpsContainsGlobs.append(regExp->pattern().contains(globChars));
+ m_regexps.append(regExp);
+ }
+}
+
+void KQuery::setRecursive(bool recursive)
+{
+ m_recursive = recursive;
+}
+
+void KQuery::setPath(const KURL &url)
+{
+ m_url = url;
+}
+
+void KQuery::setUseFileIndex(bool useLocate)
+{
+ m_useLocate=useLocate;
+}
+
+void KQuery::slotreceivedSdterr(TDEProcess* ,char* str,int)
+{
+ KMessageBox::error(NULL, TQString(str), i18n("Error while using locate"));
+}
+
+void KQuery::slotreceivedSdtout(TDEProcess*,char* str,int l)
+{
+ int i;
+
+ bufferLocateLength+=l;
+ str[l]='\0';
+ bufferLocate=(char*)realloc(bufferLocate,sizeof(char)*(bufferLocateLength));
+ for (i=0;i<l;i++)
+ bufferLocate[bufferLocateLength-l+i]=str[i];
+}
+
+void KQuery::slotendProcessLocate(TDEProcess*)
+{
+ TQString qstr;
+ TQStringList strlist;
+ int i,j,k;
+
+ if((bufferLocateLength==0)||(bufferLocate==NULL))
+ {
+ emit result(0);
+ return;
+ }
+
+ i=0;
+ do
+ {
+ j=1;
+ while(bufferLocate[i]!='\n')
+ {
+ i++;
+ j++;
+ }
+ qstr="";
+ for(k=0;k<j-1;k++)
+ qstr.append(bufferLocate[k+i-j+1]);
+ strlist.append(qstr);
+ i++;
+
+ }while(i<bufferLocateLength);
+ bufferLocateLength=0;
+ free(bufferLocate);
+ bufferLocate=NULL;
+ slotListEntries(strlist );
+ emit result(0);
+}
+
+#include "kquery.moc"
diff --git a/kfind/kquery.h b/kfind/kquery.h
new file mode 100644
index 000000000..8f12e782c
--- /dev/null
+++ b/kfind/kquery.h
@@ -0,0 +1,102 @@
+#ifndef KQUERY_H
+#define KQUERY_H
+
+#include <time.h>
+
+#include <tqobject.h>
+#include <tqregexp.h>
+#include <tqptrqueue.h>
+#include <tqdir.h>
+#include <tqstringlist.h>
+
+#include <tdeio/job.h>
+#include <kurl.h>
+#include <kprocess.h>
+
+class KFileItem;
+
+class KQuery : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ KQuery(TQObject *parent = 0, const char * name = 0);
+ ~KQuery();
+
+ void setSizeRange( int mode, TDEIO::filesize_t value1, TDEIO::filesize_t value2 );
+ void setTimeRange( time_t from, time_t to );
+ void setRegExp( const TQString &regexp, bool caseSensitive );
+ void setRecursive( bool recursive );
+ void setPath(const KURL & url );
+ void setFileType( int filetype );
+ void setMimeType( const TQStringList & mimetype );
+ void setContext( const TQString & context, bool casesensitive,
+ bool search_binary, bool useRegexp );
+ void setUsername( TQString username );
+ void setGroupname( TQString groupname );
+ void setMetaInfo(const TQString &metainfo, const TQString &metainfokey);
+ void setUseFileIndex(bool);
+
+ void start();
+ void kill();
+ const KURL& url() {return m_url;};
+
+ private:
+ /* Check if file meets the find's requirements*/
+ inline void processQuery(KFileItem*);
+
+ public slots:
+ /* List of files found using slocate */
+ void slotListEntries(TQStringList);
+ protected slots:
+ /* List of files found using TDEIO */
+ void slotListEntries(TDEIO::Job *, const TDEIO::UDSEntryList &);
+ void slotResult(TDEIO::Job *);
+ void slotCanceled(TDEIO::Job *);
+ void slotreceivedSdtout(TDEProcess*,char*,int);
+ void slotreceivedSdterr(TDEProcess*,char*,int);
+ void slotendProcessLocate(TDEProcess*);
+
+ signals:
+ void addFile(const KFileItem *filename, const TQString& matchingLine);
+ void result(int);
+
+ private:
+ void checkEntries();
+
+ int m_filetype;
+ int m_sizemode;
+ TDEIO::filesize_t m_sizeboundary1;
+ TDEIO::filesize_t m_sizeboundary2;
+ KURL m_url;
+ time_t m_timeFrom;
+ time_t m_timeTo;
+ TQRegExp m_regexp;// regexp for file content
+ bool m_recursive;
+ TQStringList m_mimetype;
+ TQString m_context;
+ TQString m_username;
+ TQString m_groupname;
+ TQString m_metainfo;
+ TQString m_metainfokey;
+ bool m_casesensitive;
+ bool m_search_binary;
+ bool m_regexpForContent;
+ bool m_useLocate;
+ char* bufferLocate;
+ int bufferLocateLength;
+ TQStringList locateList;
+ TDEProcess *processLocate;
+ TQPtrList<TQRegExp> m_regexps;// regexps for file name
+// TQValueList<bool> m_regexpsContainsGlobs; // what should this be good for ? Alex
+ TDEIO::ListJob *job;
+ bool m_insideCheckEntries;
+ TQPtrQueue<KFileItem> m_fileItems;
+ TQRegExp* metaKeyRx;
+ int m_result;
+ TQStringList ignore_mimetypes;
+ TQStringList ooo_mimetypes; // OpenOffice.org mimetypes
+ TQStringList koffice_mimetypes;
+};
+
+#endif
diff --git a/kfind/main.cpp b/kfind/main.cpp
new file mode 100644
index 000000000..e0e8bc498
--- /dev/null
+++ b/kfind/main.cpp
@@ -0,0 +1,65 @@
+#include <tqdir.h>
+#include <tqfile.h>
+
+#include <tdeapplication.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+#include <tdeaboutdata.h>
+#include <kopenwith.h>
+
+#include "kfinddlg.h"
+#include "version.h"
+
+static const char description[] =
+ I18N_NOOP("TDE file find utility");
+
+static TDECmdLineOptions options[] =
+{
+ { "+[searchpath]", I18N_NOOP("Path(s) to search"), 0 },
+ TDECmdLineLastOption
+};
+
+int main( int argc, char ** argv )
+{
+ TDELocale::setMainCatalogue("kfindpart");
+ TDEAboutData aboutData( "kfind", I18N_NOOP("KFind"),
+ KFIND_VERSION, description, TDEAboutData::License_GPL,
+ I18N_NOOP("(c) 1998-2003, The KDE Developers"));
+
+ aboutData.addAuthor("Eric Coquelle", I18N_NOOP("Current Maintainer"), "[email protected]");
+ aboutData.addAuthor("Mark W. Webb", I18N_NOOP("Developer"), "[email protected]");
+ aboutData.addAuthor("Beppe Grimaldi", I18N_NOOP("UI Design & more search options"), "[email protected]");
+ aboutData.addAuthor("Martin Hartig");
+ aboutData.addAuthor("Stephan Kulow", 0, "[email protected]");
+ aboutData.addAuthor("Mario Weilguni",0, "[email protected]");
+ aboutData.addAuthor("Alex Zepeda",0, "[email protected]");
+ aboutData.addAuthor("Miroslav Fl�r",0, "[email protected]");
+ aboutData.addAuthor("Harri Porten",0, "[email protected]");
+ aboutData.addAuthor("Dima Rogozin",0, "[email protected]");
+ aboutData.addAuthor("Carsten Pfeiffer",0, "[email protected]");
+ aboutData.addAuthor("Hans Petter Bieker", 0, "[email protected]");
+ aboutData.addAuthor("Waldo Bastian", I18N_NOOP("UI Design"), "[email protected]");
+ aboutData.addAuthor("Alexander Neundorf", 0, "[email protected]");
+ aboutData.addAuthor("Clarence Dang", 0, "[email protected]");
+
+ TDECmdLineArgs::init( argc, argv, &aboutData );
+ TDECmdLineArgs::addCmdLineOptions( options );
+
+ TDEApplication app;
+
+ TDECmdLineArgs *args= TDECmdLineArgs::parsedArgs();
+
+ KURL url;
+ if (args->count() > 0)
+ url = args->url(0);
+ if (url.isEmpty())
+ url = TQDir::currentDirPath();
+ if (url.isEmpty())
+ url = TQDir::homeDirPath();
+ args->clear();
+
+ KfindDlg kfinddlg(url, 0, "dialog");
+ return kfinddlg.exec();
+}
+
+
diff --git a/kfind/pics/CMakeLists.txt b/kfind/pics/CMakeLists.txt
new file mode 100644
index 000000000..14a63b2f8
--- /dev/null
+++ b/kfind/pics/CMakeLists.txt
@@ -0,0 +1,12 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+tde_install_icons( DESTINATION ${DATA_INSTALL_DIR}/kfindpart/icons )
diff --git a/kfind/pics/Makefile.am b/kfind/pics/Makefile.am
new file mode 100644
index 000000000..0d31d2cf2
--- /dev/null
+++ b/kfind/pics/Makefile.am
@@ -0,0 +1,2 @@
+kfind_pics_datadir = $(kde_datadir)/kfindpart/icons
+kfind_pics_data_ICON = AUTO
diff --git a/kfind/pics/lo22-action-archive.png b/kfind/pics/lo22-action-archive.png
new file mode 100644
index 000000000..54e73c2f9
--- /dev/null
+++ b/kfind/pics/lo22-action-archive.png
Binary files differ
diff --git a/kfind/pics/lo22-action-delete.png b/kfind/pics/lo22-action-delete.png
new file mode 100644
index 000000000..1018d6e22
--- /dev/null
+++ b/kfind/pics/lo22-action-delete.png
Binary files differ
diff --git a/kfind/pics/lo22-action-idea.png b/kfind/pics/lo22-action-idea.png
new file mode 100644
index 000000000..e348d48b6
--- /dev/null
+++ b/kfind/pics/lo22-action-idea.png
Binary files differ
diff --git a/kfind/pics/lo22-action-info.png b/kfind/pics/lo22-action-info.png
new file mode 100644
index 000000000..41aec81ef
--- /dev/null
+++ b/kfind/pics/lo22-action-info.png
Binary files differ
diff --git a/kfind/pics/lo22-action-openfile.png b/kfind/pics/lo22-action-openfile.png
new file mode 100644
index 000000000..bdf6c55d9
--- /dev/null
+++ b/kfind/pics/lo22-action-openfile.png
Binary files differ
diff --git a/kfind/pics/lo22-action-save.png b/kfind/pics/lo22-action-save.png
new file mode 100644
index 000000000..4ae7ad4cd
--- /dev/null
+++ b/kfind/pics/lo22-action-save.png
Binary files differ
diff --git a/kfind/pics/lo22-action-search.png b/kfind/pics/lo22-action-search.png
new file mode 100644
index 000000000..2ed5031c4
--- /dev/null
+++ b/kfind/pics/lo22-action-search.png
Binary files differ
diff --git a/kfind/version.h b/kfind/version.h
new file mode 100644
index 000000000..24f2c33c1
--- /dev/null
+++ b/kfind/version.h
@@ -0,0 +1,3 @@
+#ifndef KFIND_VERSION
+#define KFIND_VERSION "2.0"
+#endif