summaryrefslogtreecommitdiffstats
path: root/src/app/Dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/Dialogs')
-rw-r--r--src/app/Dialogs/Makefile.am22
-rw-r--r--src/app/Dialogs/checksumdlg.cpp603
-rw-r--r--src/app/Dialogs/checksumdlg.h54
-rw-r--r--src/app/Dialogs/krdialogs.cpp256
-rw-r--r--src/app/Dialogs/krdialogs.h116
-rw-r--r--src/app/Dialogs/krkeydialog.cpp157
-rw-r--r--src/app/Dialogs/krkeydialog.h38
-rw-r--r--src/app/Dialogs/krmaskchoice.cpp179
-rw-r--r--src/app/Dialogs/krmaskchoice.h77
-rw-r--r--src/app/Dialogs/krpleasewait.cpp153
-rw-r--r--src/app/Dialogs/krpleasewait.h84
-rw-r--r--src/app/Dialogs/krprogress.cpp270
-rw-r--r--src/app/Dialogs/krprogress.h87
-rw-r--r--src/app/Dialogs/krspecialwidgets.cpp239
-rw-r--r--src/app/Dialogs/krspecialwidgets.h129
-rw-r--r--src/app/Dialogs/krspwidgets.cpp316
-rw-r--r--src/app/Dialogs/krspwidgets.h110
-rw-r--r--src/app/Dialogs/krsqueezedtextlabel.cpp80
-rw-r--r--src/app/Dialogs/krsqueezedtextlabel.h45
-rw-r--r--src/app/Dialogs/kurllistrequester.cpp202
-rw-r--r--src/app/Dialogs/kurllistrequester.h77
-rw-r--r--src/app/Dialogs/newftpgui.cpp182
-rw-r--r--src/app/Dialogs/newftpgui.h55
-rw-r--r--src/app/Dialogs/packgui.cpp122
-rw-r--r--src/app/Dialogs/packgui.h54
-rw-r--r--src/app/Dialogs/packguibase.cpp468
-rw-r--r--src/app/Dialogs/packguibase.h110
-rw-r--r--src/app/Dialogs/percentalsplitter.cpp193
-rw-r--r--src/app/Dialogs/percentalsplitter.h59
-rw-r--r--src/app/Dialogs/popularurls.cpp307
-rw-r--r--src/app/Dialogs/popularurls.h86
31 files changed, 4930 insertions, 0 deletions
diff --git a/src/app/Dialogs/Makefile.am b/src/app/Dialogs/Makefile.am
new file mode 100644
index 0000000..83cc13d
--- /dev/null
+++ b/src/app/Dialogs/Makefile.am
@@ -0,0 +1,22 @@
+noinst_LIBRARIES = libDialogs.a
+
+INCLUDES = $(all_includes)
+
+libDialogs_a_METASOURCES = AUTO
+
+libDialogs_a_SOURCES = \
+ krsqueezedtextlabel.cpp \
+ krprogress.cpp \
+ packgui.cpp \
+ packguibase.cpp \
+ newftpgui.cpp \
+ krspwidgets.cpp \
+ krspecialwidgets.cpp \
+ krpleasewait.cpp \
+ krmaskchoice.cpp \
+ krdialogs.cpp \
+ kurllistrequester.cpp \
+ popularurls.cpp \
+ checksumdlg.cpp \
+ percentalsplitter.cpp \
+ krkeydialog.cpp
diff --git a/src/app/Dialogs/checksumdlg.cpp b/src/app/Dialogs/checksumdlg.cpp
new file mode 100644
index 0000000..6e3191d
--- /dev/null
+++ b/src/app/Dialogs/checksumdlg.cpp
@@ -0,0 +1,603 @@
+#include "checksumdlg.h"
+#include "../krusader.h"
+#include <tdelocale.h>
+#include <tqlayout.h>
+#include <tqlabel.h>
+#include <tqcheckbox.h>
+#include <klineedit.h>
+#include <tdelistview.h>
+#include <tqpixmap.h>
+#include <kcursor.h>
+#include <tdemessagebox.h>
+#include <tqfile.h>
+#include <tqtextstream.h>
+#include <tdefiledialog.h>
+#include <tqframe.h>
+#include <kiconloader.h>
+#include <kcombobox.h>
+#include <tqfileinfo.h>
+#include <kurlrequester.h>
+#include "../krservices.h"
+#include <tqptrlist.h>
+#include <tqmap.h>
+#include <tdetempfile.h>
+#include <kstandarddirs.h>
+
+class CS_Tool; // forward
+typedef void PREPARE_PROC_FUNC(TDEProcess& proc, CS_Tool *self, const TQStringList& files,
+ const TQString checksumFile, bool recursive, const TQString& stdoutFileName,
+ const TQString& stderrFileName, const TQString& type);
+typedef TQStringList GET_FAILED_FUNC(const TQStringList& stdOut, const TQStringList& stdErr);
+
+class CS_Tool {
+public:
+ enum Type {
+ MD5=0, SHA1, SHA256, TIGER, WHIRLPOOL, SFV, CRC,
+ SHA224, SHA384, SHA512,
+ NumOfTypes
+ };
+
+ Type type;
+ TQString binary;
+ bool recursive;
+ bool standardFormat;
+ PREPARE_PROC_FUNC *create, *verify;
+ GET_FAILED_FUNC *failed;
+};
+
+class CS_ToolByType {
+public:
+ TQPtrList<CS_Tool> tools, r_tools; // normal and recursive tools
+};
+
+// handles md5sum and sha1sum
+void sumCreateFunc(TDEProcess& proc, CS_Tool *self, const TQStringList& files,
+ const TQString, bool recursive, const TQString& stdoutFileName,
+ const TQString& stderrFileName, const TQString&) {
+ proc.setUseShell(true, "/bin/bash");
+ proc << KrServices::fullPathName( self->binary );
+ Q_ASSERT(!recursive);
+ proc << files << "1>" << stdoutFileName << "2>" << stderrFileName;
+}
+
+void sumVerifyFunc(TDEProcess& proc, CS_Tool *self, const TQStringList& /* files */,
+ const TQString checksumFile, bool recursive, const TQString& stdoutFileName,
+ const TQString& stderrFileName, const TQString& /* type */) {
+ proc.setUseShell(true, "/bin/bash");
+ proc << KrServices::fullPathName( self->binary );
+ Q_ASSERT(!recursive);
+ proc << "-c" << checksumFile << "1>" << stdoutFileName << "2>" << stderrFileName;
+}
+
+TQStringList sumFailedFunc(const TQStringList& stdOut, const TQStringList& stdErr) {
+ // md5sum and sha1sum print "...: FAILED" for failed files and display
+ // the number of failures to stderr. so if stderr is empty, we'll assume all is ok
+ TQStringList result;
+ if (stdErr.size()==0) return result;
+ result += stdErr;
+ // grep for the ":FAILED" substring
+ const TQString tmp = TQString(": FAILED").local8Bit();
+ for (uint i=0; i<stdOut.size();++i) {
+ if (stdOut[i].find(tmp) != -1)
+ result += stdOut[i];
+ }
+
+ return result;
+}
+
+// handles *deep binaries
+void deepCreateFunc(TDEProcess& proc, CS_Tool *self, const TQStringList& files,
+ const TQString, bool recursive, const TQString& stdoutFileName,
+ const TQString& stderrFileName, const TQString&) {
+ proc.setUseShell(true, "/bin/bash");
+ proc << KrServices::fullPathName( self->binary );
+ if (recursive) proc << "-r";
+ proc << "-l" << files << "1>" << stdoutFileName << "2>" << stderrFileName;
+}
+
+void deepVerifyFunc(TDEProcess& proc, CS_Tool *self, const TQStringList& files,
+ const TQString checksumFile, bool recursive, const TQString& stdoutFileName,
+ const TQString& stderrFileName, const TQString&) {
+ proc.setUseShell(true, "/bin/bash");
+ proc << KrServices::fullPathName( self->binary );
+ if (recursive) proc << "-r";
+ proc << "-x" << checksumFile << files << "1>" << stdoutFileName << "2>" << stderrFileName;
+}
+
+TQStringList deepFailedFunc(const TQStringList& stdOut, const TQStringList&/* stdErr */) {
+ // *deep dumps (via -x) all failed hashes to stdout
+ return stdOut;
+}
+
+// handles cfv binary
+void cfvCreateFunc(TDEProcess& proc, CS_Tool *self, const TQStringList& files,
+ const TQString, bool recursive, const TQString& stdoutFileName,
+ const TQString& stderrFileName, const TQString& type) {
+ proc.setUseShell(true, "/bin/bash");
+ proc << KrServices::fullPathName( self->binary ) << "-C" << "-VV";
+ if (recursive) proc << "-rr";
+ proc << "-t" << type << "-f-" << "-U" << files << "1>" << stdoutFileName << "2>" << stderrFileName;
+}
+
+void cfvVerifyFunc(TDEProcess& proc, CS_Tool *self, const TQStringList& /* files */,
+ const TQString checksumFile, bool recursive, const TQString& stdoutFileName,
+ const TQString& stderrFileName, const TQString&type) {
+ proc.setUseShell(true, "/bin/bash");
+ proc << KrServices::fullPathName( self->binary ) << "-M";
+ if (recursive) proc << "-rr";
+ proc << "-U" << "-VV" << "-t" << type << "-f" << checksumFile << "1>" << stdoutFileName << "2>" << stderrFileName;// << files;
+}
+
+TQStringList cfvFailedFunc(const TQStringList& /* stdOut */, const TQStringList& stdErr) {
+ // cfv dumps all failed hashes to stderr
+ return stdErr;
+}
+
+// important: this table should be ordered like so that all md5 tools should be
+// one after another, and then all sha1 and so on and so forth. they tools must be grouped,
+// since the code in getTools() counts on it!
+CS_Tool cs_tools[] = {
+ // type binary recursive stdFmt create_func verify_func failed_func
+ {CS_Tool::MD5, "md5sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc},
+ {CS_Tool::MD5, "md5deep", true, true, deepCreateFunc, deepVerifyFunc, deepFailedFunc},
+ {CS_Tool::MD5, "cfv", true, true, cfvCreateFunc, cfvVerifyFunc, cfvFailedFunc},
+ {CS_Tool::SHA1, "sha1sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc},
+ {CS_Tool::SHA1, "sha1deep", true, true, deepCreateFunc, deepVerifyFunc, deepFailedFunc},
+ {CS_Tool::SHA1, "cfv", true, true, cfvCreateFunc, cfvVerifyFunc, cfvFailedFunc},
+ {CS_Tool::SHA224, "sha224sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc},
+ {CS_Tool::SHA256, "sha256sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc},
+ {CS_Tool::SHA256, "sha256deep", true, true, deepCreateFunc, deepVerifyFunc, deepFailedFunc},
+ {CS_Tool::SHA384, "sha384sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc},
+ {CS_Tool::SHA512, "sha512sum", false, true, sumCreateFunc, sumVerifyFunc, sumFailedFunc},
+ {CS_Tool::TIGER, "tigerdeep", true, true, deepCreateFunc, deepVerifyFunc, deepFailedFunc},
+ {CS_Tool::WHIRLPOOL, "whirlpooldeep", true, true, deepCreateFunc, deepVerifyFunc, deepFailedFunc},
+ {CS_Tool::SFV, "cfv", true, false, cfvCreateFunc, cfvVerifyFunc, cfvFailedFunc},
+ {CS_Tool::CRC, "cfv", true, false, cfvCreateFunc, cfvVerifyFunc, cfvFailedFunc},
+};
+
+TQMap<TQString, CS_Tool::Type> cs_textToType;
+TQMap<CS_Tool::Type, TQString> cs_typeToText;
+
+void initChecksumModule() {
+ // prepare the dictionaries - pity it has to be manually
+ cs_textToType["md5"]=CS_Tool::MD5;
+ cs_textToType["sha1"]=CS_Tool::SHA1;
+ cs_textToType["sha256"]=CS_Tool::SHA256;
+ cs_textToType["sha224"]=CS_Tool::SHA224;
+ cs_textToType["sha384"]=CS_Tool::SHA384;
+ cs_textToType["sha512"]=CS_Tool::SHA512;
+ cs_textToType["tiger"]=CS_Tool::TIGER;
+ cs_textToType["whirlpool"]=CS_Tool::WHIRLPOOL;
+ cs_textToType["sfv"]=CS_Tool::SFV;
+ cs_textToType["crc"]=CS_Tool::CRC;
+
+ cs_typeToText[CS_Tool::MD5]="md5";
+ cs_typeToText[CS_Tool::SHA1]="sha1";
+ cs_typeToText[CS_Tool::SHA256]="sha256";
+ cs_typeToText[CS_Tool::SHA224]="sha224";
+ cs_typeToText[CS_Tool::SHA384]="sha384";
+ cs_typeToText[CS_Tool::SHA512]="sha512";
+ cs_typeToText[CS_Tool::TIGER]="tiger";
+ cs_typeToText[CS_Tool::WHIRLPOOL]="whirlpool";
+ cs_typeToText[CS_Tool::SFV]="sfv";
+ cs_typeToText[CS_Tool::CRC]="crc";
+
+ // build the checksumFilter (for usage in KRQuery)
+ TQMap<TQString, CS_Tool::Type>::Iterator it;
+ for (it=cs_textToType.begin(); it!=cs_textToType.end(); ++it)
+ MatchChecksumDlg::checksumTypesFilter += ("*."+it.key()+" ");
+}
+
+// --------------------------------------------------
+
+// returns a list of tools which can work with recursive or non-recursive mode and are installed
+// note: only 1 tool from each type is suggested
+static TQPtrList<CS_Tool> getTools(bool folders) {
+ TQPtrList<CS_Tool> result;
+ uint i;
+ for (i=0; i < sizeof(cs_tools)/sizeof(CS_Tool); ++i) {
+ if (result.last() && result.last()->type == cs_tools[i].type) continue; // 1 from each type please
+ if (folders && !cs_tools[i].recursive) continue;
+ if (KrServices::cmdExist(cs_tools[i].binary))
+ result.append(&cs_tools[i]);
+ }
+
+ return result;
+}
+
+// ------------- CreateChecksumDlg
+
+CreateChecksumDlg::CreateChecksumDlg(const TQStringList& files, bool containFolders, const TQString& path):
+ KDialogBase(Plain, i18n("Create Checksum"), Ok | Cancel, Ok, krApp) {
+
+ TQPtrList<CS_Tool> tools = getTools(containFolders);
+
+ if (tools.count() == 0) { // nothing was suggested?!
+ TQString error = i18n("<qt>Can't calculate checksum since no supported tool was found. "
+ "Please check the <b>Dependencies</b> page in Krusader's settings.</qt>");
+ if (containFolders)
+ error += i18n("<qt><b>Note</b>: you've selected directories, and probably have no recursive checksum tool installed."
+ " Krusader currently supports <i>md5deep, sha1deep, sha256deep, tigerdeep and cfv</i></qt>");
+ KMessageBox::error(0, error);
+ return;
+ }
+
+ TQGridLayout *layout = new TQGridLayout( plainPage(), 1, 1,
+ KDialogBase::marginHint(), KDialogBase::spacingHint());
+
+ int row=0;
+
+ // title (icon+text)
+ TQHBoxLayout *hlayout = new TQHBoxLayout(layout, KDialogBase::spacingHint());
+ TQLabel *p = new TQLabel(plainPage());
+ p->setPixmap(krLoader->loadIcon("application-octet-stream", TDEIcon::Desktop, 32));
+ hlayout->addWidget(p);
+ TQLabel *l1 = new TQLabel(i18n("About to calculate checksum for the following files") +
+ (containFolders ? i18n(" and folders:") : ":"), plainPage());
+ hlayout->addWidget(l1);
+ layout->addMultiCellLayout(hlayout, row, row, 0, 1, TQt::AlignLeft);
+ ++row;
+
+ // file list
+ TDEListBox *lb = new TDEListBox(plainPage());
+ lb->insertStringList(files);
+ layout->addMultiCellWidget(lb, row, row, 0, 1);
+ ++row;
+
+ // checksum method
+ TQHBoxLayout *hlayout2 = new TQHBoxLayout(layout, KDialogBase::spacingHint());
+ TQLabel *l2 = new TQLabel(i18n("Select the checksum method:"), plainPage());
+ hlayout2->addWidget(l2);
+ KComboBox *method = new KComboBox(plainPage());
+ // -- fill the combo with available methods
+ uint i;
+ for ( i=0; i<tools.count(); ++i )
+ method->insertItem( cs_typeToText[tools.at(i)->type], i);
+ method->setFocus();
+ hlayout2->addWidget(method);
+ layout->addMultiCellLayout(hlayout2, row, row, 0, 1, TQt::AlignLeft);
+ ++row;
+
+ if (exec() != Accepted) return;
+ // else implied: run the process
+ tmpOut = new KTempFile(locateLocal("tmp", "krusader"), ".stdout" );
+ tmpErr = new KTempFile(locateLocal("tmp", "krusader"), ".stderr" );
+ TDEProcess proc;
+ CS_Tool *mytool = tools.at(method->currentItem());
+ mytool->create(proc, mytool, KrServices::quote(files), TQString(), containFolders,
+ tmpOut->name(), tmpErr->name(), method->currentText());
+
+ krApp->startWaiting(i18n("Calculating checksums ..."), 0, true);
+ TQApplication::setOverrideCursor( KCursor::waitCursor() );
+ bool r = proc.start(TDEProcess::NotifyOnExit, TDEProcess::AllOutput);
+ if (r) while ( proc.isRunning() ) {
+ usleep( 500 );
+ tqApp->processEvents();
+ if (krApp->wasWaitingCancelled()) { // user cancelled
+ proc.kill();
+ TQApplication::restoreOverrideCursor();
+ return;
+ }
+ };
+ krApp->stopWait();
+ TQApplication::restoreOverrideCursor();
+ if (!r || !proc.normalExit()) {
+ KMessageBox::error(0, i18n("<qt>There was an error while running <b>%1</b>.</qt>").arg(mytool->binary));
+ return;
+ }
+
+ // suggest a filename
+ TQString suggestedFilename = path + '/';
+ if (files.count() > 1) suggestedFilename += ("checksum." + cs_typeToText[mytool->type]);
+ else suggestedFilename += (files[0] + '.' + cs_typeToText[mytool->type]);
+ // send both stdout and stderr
+ TQStringList stdOut, stdErr;
+ if (!KrServices::fileToStringList(tmpOut->textStream(), stdOut) ||
+ !KrServices::fileToStringList(tmpErr->textStream(), stdErr)) {
+ KMessageBox::error(krApp, i18n("Error reading stdout or stderr"));
+ return;
+ }
+
+ ChecksumResultsDlg dlg( stdOut, stdErr, suggestedFilename, mytool->binary, cs_typeToText[mytool->type], mytool->standardFormat);
+ tmpOut->unlink(); delete tmpOut;
+ tmpErr->unlink(); delete tmpErr;
+}
+
+// ------------- MatchChecksumDlg
+
+TQString MatchChecksumDlg::checksumTypesFilter;
+
+MatchChecksumDlg::MatchChecksumDlg(const TQStringList& files, bool containFolders,
+ const TQString& path, const TQString& checksumFile):
+ KDialogBase(Plain, i18n("Verify Checksum"), Ok | Cancel, Ok, krApp) {
+
+ TQPtrList<CS_Tool> tools = getTools(containFolders);
+
+ if (tools.count() == 0) { // nothing was suggested?!
+ TQString error = i18n("<qt>Can't verify checksum since no supported tool was found. "
+ "Please check the <b>Dependencies</b> page in Krusader's settings.</qt>");
+ if (containFolders)
+ error += i18n("<qt><b>Note</b>: you've selected directories, and probably have no recursive checksum tool installed."
+ " Krusader currently supports <i>md5deep, sha1deep, sha256deep, tigerdeep and cfv</i></qt>");
+ KMessageBox::error(0, error);
+ return;
+ }
+
+ TQGridLayout *layout = new TQGridLayout( plainPage(), 1, 1,
+ KDialogBase::marginHint(), KDialogBase::spacingHint());
+
+ int row=0;
+
+ // title (icon+text)
+ TQHBoxLayout *hlayout = new TQHBoxLayout(layout, KDialogBase::spacingHint());
+ TQLabel *p = new TQLabel(plainPage());
+ p->setPixmap(krLoader->loadIcon("application-octet-stream", TDEIcon::Desktop, 32));
+ hlayout->addWidget(p);
+ TQLabel *l1 = new TQLabel(i18n("About to verify checksum for the following files") +
+ (containFolders ? i18n(" and folders:") : ":"), plainPage());
+ hlayout->addWidget(l1);
+ layout->addMultiCellLayout(hlayout, row, row, 0, 1, TQt::AlignLeft);
+ ++row;
+
+ // file list
+ TDEListBox *lb = new TDEListBox(plainPage());
+ lb->insertStringList(files);
+ layout->addMultiCellWidget(lb, row, row, 0, 1);
+ ++row;
+
+ // checksum file
+ TQHBoxLayout *hlayout2 = new TQHBoxLayout(layout, KDialogBase::spacingHint());
+ TQLabel *l2 = new TQLabel(i18n("Checksum file:"), plainPage());
+ hlayout2->addWidget(l2);
+ KURLRequester *checksumFileReq = new KURLRequester( plainPage() );
+ if (!checksumFile.isEmpty())
+ checksumFileReq->setURL(checksumFile);
+ checksumFileReq->fileDialog()->setURL(path);
+ checksumFileReq->setFocus();
+ hlayout2->addWidget(checksumFileReq);
+ layout->addMultiCellLayout(hlayout2, row, row, 0, 1, TQt::AlignLeft);
+
+ if (exec() != Accepted) return;
+ TQString file = checksumFileReq->url();
+ TQString extension;
+ if (!verifyChecksumFile(file, extension)) {
+ KMessageBox::error(0, i18n("<qt>Error reading checksum file <i>%1</i>.<br />Please specify a valid checksum file.</qt>").arg(file));
+ return;
+ }
+
+ // do we have a tool for that extension?
+ uint i;
+ CS_Tool *mytool = 0;
+ for ( i=0; i < tools.count(); ++i )
+ if (cs_typeToText[tools.at(i)->type] == extension.lower()) {
+ mytool = tools.at(i);
+ break;
+ }
+ if (!mytool) {
+ KMessageBox::error(0, i18n("<qt>Krusader can't find a checksum tool that handles %1 on your system. Please check the <b>Dependencies</b> page in Krusader's settings.</qt>").arg(extension));
+ return;
+ }
+
+ // else implied: run the process
+ tmpOut = new KTempFile(locateLocal("tmp", "krusader"), ".stdout" );
+ tmpErr = new KTempFile(locateLocal("tmp", "krusader"), ".stderr" );
+ TDEProcess proc;
+ mytool->verify(proc, mytool, KrServices::quote(files), KrServices::quote(file), containFolders, tmpOut->name(), tmpErr->name(), extension);
+ krApp->startWaiting(i18n("Verifying checksums ..."), 0, true);
+ TQApplication::setOverrideCursor( KCursor::waitCursor() );
+ bool r = proc.start(TDEProcess::NotifyOnExit, TDEProcess::AllOutput);
+ if (r) while ( proc.isRunning() ) {
+ usleep( 500 );
+ tqApp->processEvents();
+ if (krApp->wasWaitingCancelled()) { // user cancelled
+ proc.kill();
+ TQApplication::restoreOverrideCursor();
+ return;
+ }
+ };
+ if (!r || !proc.normalExit()) {
+ KMessageBox::error(0, i18n("<qt>There was an error while running <b>%1</b>.</qt>").arg(mytool->binary));
+ return;
+ }
+ TQApplication::restoreOverrideCursor();
+ krApp->stopWait();
+ // send both stdout and stderr
+ TQStringList stdOut,stdErr;
+ if (!KrServices::fileToStringList(tmpOut->textStream(), stdOut) ||
+ !KrServices::fileToStringList(tmpErr->textStream(), stdErr)) {
+ KMessageBox::error(krApp, i18n("Error reading stdout or stderr"));
+ return;
+ }
+ VerifyResultDlg dlg(mytool->failed(stdOut, stdErr));
+ tmpOut->unlink(); delete tmpOut;
+ tmpErr->unlink(); delete tmpErr;
+}
+
+bool MatchChecksumDlg::verifyChecksumFile(TQString path, TQString& extension) {
+ TQFileInfo f(path);
+ if (!f.exists() || f.isDir()) return false;
+ // find the extension
+ extension = path.mid(path.findRev(".")+1);
+
+ // TODO: do we know the extension? if not, ask the user for one
+
+
+ return true;
+}
+
+// ------------- VerifyResultDlg
+VerifyResultDlg::VerifyResultDlg(const TQStringList& failed):
+ KDialogBase(Plain, i18n("Verify Checksum"), Close, Close, krApp) {
+ TQGridLayout *layout = new TQGridLayout( plainPage(), 1, 1,
+ KDialogBase::marginHint(), KDialogBase::spacingHint());
+
+ bool errors = failed.size()>0;
+ int row = 0;
+
+ // create the icon and title
+ TQHBoxLayout *hlayout = new TQHBoxLayout(layout, KDialogBase::spacingHint());
+ TQLabel p(plainPage());
+ p.setPixmap(krLoader->loadIcon(errors ? "messagebox_critical" : "messagebox_info", TDEIcon::Desktop, 32));
+ hlayout->addWidget(&p);
+
+ TQLabel *l1 = new TQLabel((errors ? i18n("Errors were detected while verifying the checksums") :
+ i18n("Checksums were verified successfully")), plainPage());
+ hlayout->addWidget(l1);
+ layout->addMultiCellLayout(hlayout,row,row,0,1, TQt::AlignLeft);
+ ++row;
+
+ if (errors) {
+ TQLabel *l3 = new TQLabel(i18n("The following files have failed:"), plainPage());
+ layout->addMultiCellWidget(l3, row, row, 0, 1);
+ ++row;
+ TDEListBox *lb2 = new TDEListBox(plainPage());
+ lb2->insertStringList(failed);
+ layout->addMultiCellWidget(lb2, row, row, 0, 1);
+ ++row;
+ }
+
+ exec();
+}
+
+// ------------- ChecksumResultsDlg
+
+ChecksumResultsDlg::ChecksumResultsDlg(const TQStringList& stdOut, const TQStringList& stdErr,
+ const TQString& suggestedFilename, const TQString& binary, const TQString& /* type */, bool standardFormat):
+ KDialogBase(Plain, i18n("Create Checksum"), Ok | Cancel, Ok, krApp), _binary(binary) {
+ TQGridLayout *layout = new TQGridLayout( plainPage(), 1, 1,
+ KDialogBase::marginHint(), KDialogBase::spacingHint());
+
+ // md5 tools display errors into stderr, so we'll use that to determine the result of the job
+ bool errors = stdErr.size()>0;
+ bool successes = stdOut.size()>0;
+ int row = 0;
+
+ // create the icon and title
+ TQHBoxLayout *hlayout = new TQHBoxLayout(layout, KDialogBase::spacingHint());
+ TQLabel p(plainPage());
+ p.setPixmap(krLoader->loadIcon(errors ? "messagebox_critical" : "messagebox_info", TDEIcon::Desktop, 32));
+ hlayout->addWidget(&p);
+
+ TQLabel *l1 = new TQLabel((errors ? i18n("Errors were detected while creating the checksums") :
+ i18n("Checksums were created successfully")), plainPage());
+ hlayout->addWidget(l1);
+ layout->addMultiCellLayout(hlayout,row,row,0,1, TQt::AlignLeft);
+ ++row;
+
+ if (successes) {
+ if (errors) {
+ TQLabel *l2 = new TQLabel(i18n("Here are the calculated checksums:"), plainPage());
+ layout->addMultiCellWidget(l2, row, row, 0, 1);
+ ++row;
+ }
+ TDEListView *lv = new TDEListView(plainPage());
+ if(standardFormat){
+ lv->addColumn(i18n("Hash"));
+ lv->addColumn(i18n("File"));
+ lv->setAllColumnsShowFocus(true);
+ } else {
+ lv->addColumn(i18n("File and hash"));
+ }
+ for ( TQStringList::ConstIterator it = stdOut.begin(); it != stdOut.end(); ++it ) {
+ TQString line = (*it);
+ if(standardFormat) {
+ int space = line.find(' ');
+ new TDEListViewItem(lv, line.left(space), line.mid(space+2));
+ } else {
+ new TDEListViewItem(lv, line);
+ }
+ }
+ layout->addMultiCellWidget(lv, row, row, 0, 1);
+ ++row;
+ }
+
+ if (errors) {
+ TQFrame *line1 = new TQFrame( plainPage() );
+ line1->setGeometry( TQRect( 60, 210, 501, 20 ) );
+ line1->setFrameShape( TQFrame::HLine );
+ line1->setFrameShadow( TQFrame::Sunken );
+ layout->addMultiCellWidget(line1, row, row, 0, 1);
+ ++row;
+
+ TQLabel *l3 = new TQLabel(i18n("Here are the errors received:"), plainPage());
+ layout->addMultiCellWidget(l3, row, row, 0, 1);
+ ++row;
+ TDEListBox *lb = new TDEListBox(plainPage());
+ lb->insertStringList(stdErr);
+ layout->addMultiCellWidget(lb, row, row, 0, 1);
+ ++row;
+ }
+
+ // save checksum to disk, if any hashes are found
+ KURLRequester *checksumFile=0;
+ TQCheckBox *saveFileCb=0;
+ if (successes) {
+ TQHBoxLayout *hlayout2 = new TQHBoxLayout(layout, KDialogBase::spacingHint());
+ saveFileCb = new TQCheckBox(i18n("Save checksum to file:"), plainPage());
+ saveFileCb->setChecked(true);
+ hlayout2->addWidget(saveFileCb);
+
+ checksumFile = new KURLRequester( suggestedFilename, plainPage() );
+ hlayout2->addWidget(checksumFile, TQt::AlignLeft);
+ layout->addMultiCellLayout(hlayout2, row, row,0,1, TQt::AlignLeft);
+ ++row;
+ connect(saveFileCb, TQ_SIGNAL(toggled(bool)), checksumFile, TQ_SLOT(setEnabled(bool)));
+ checksumFile->setFocus();
+ }
+
+ TQCheckBox *onePerFile=0;
+ if (stdOut.size() > 1 && standardFormat) {
+ onePerFile = new TQCheckBox(i18n("Checksum file for each source file"), plainPage());
+ onePerFile->setChecked(false);
+ // clicking this, disables the 'save as' part
+ connect(onePerFile, TQ_SIGNAL(toggled(bool)), saveFileCb, TQ_SLOT(toggle()));
+ connect(onePerFile, TQ_SIGNAL(toggled(bool)), saveFileCb, TQ_SLOT(setDisabled(bool)));
+ connect(onePerFile, TQ_SIGNAL(toggled(bool)), checksumFile, TQ_SLOT(setDisabled(bool)));
+ layout->addMultiCellWidget(onePerFile, row, row,0,1, TQt::AlignLeft);
+ ++row;
+ }
+
+ if (exec() == Accepted && successes) {
+ if (stdOut.size()>1 && standardFormat && onePerFile->isChecked()) {
+ savePerFile(stdOut, suggestedFilename.mid(suggestedFilename.findRev('.')));
+ } else if (saveFileCb->isEnabled() && saveFileCb->isChecked() && !checksumFile->url().simplifyWhiteSpace().isEmpty()) {
+ saveChecksum(stdOut, checksumFile->url());
+ }
+ }
+}
+
+bool ChecksumResultsDlg::saveChecksum(const TQStringList& data, TQString filename) {
+ if (TQFile::exists(filename) &&
+ KMessageBox::warningContinueCancel(this,
+ i18n("File %1 already exists.\nAre you sure you want to overwrite it?").arg(filename),
+ i18n("Warning"), i18n("Overwrite")) != KMessageBox::Continue) {
+ // find a better name to save to
+ filename = KFileDialog::getSaveFileName(TQString(), "*", 0, i18n("Select a file to save to"));
+ if (filename.simplifyWhiteSpace().isEmpty()) return false;
+ }
+ TQFile file(filename);
+ if (!file.open(IO_WriteOnly)) {
+ KMessageBox::detailedError(0, i18n("Error saving file %1").arg(filename),
+ file.errorString());
+ return false;
+ }
+ TQTextStream stream(&file);
+ for ( TQStringList::ConstIterator it = data.constBegin(); it != data.constEnd(); ++it)
+ stream << *it << "\n";
+ file.close();
+ return true;
+}
+
+void ChecksumResultsDlg::savePerFile(const TQStringList& data, const TQString& type) {
+ krApp->startWaiting(i18n("Saving checksum files..."), 0);
+ for ( TQStringList::ConstIterator it = data.begin(); it != data.end(); ++it ) {
+ TQString line = (*it);
+ TQString filename = line.mid(line.find(' ')+2)+type;
+ if (!saveChecksum(*it, filename)) {
+ KMessageBox::error(0, i18n("Errors occured while saving multiple checksums. Stopping"));
+ krApp->stopWait();
+ return;
+ }
+ }
+ krApp->stopWait();
+}
diff --git a/src/app/Dialogs/checksumdlg.h b/src/app/Dialogs/checksumdlg.h
new file mode 100644
index 0000000..a145a35
--- /dev/null
+++ b/src/app/Dialogs/checksumdlg.h
@@ -0,0 +1,54 @@
+#ifndef CHECKSUMDLG_H
+#define CHECKSUMDLG_H
+
+#include <kdialogbase.h>
+#include <tqvaluelist.h>
+
+class KTempFile;
+extern void initChecksumModule();
+
+class CreateChecksumDlg: public KDialogBase {
+public:
+ CreateChecksumDlg(const TQStringList& files, bool containFolders, const TQString& path);
+
+private:
+ KTempFile *tmpOut, *tmpErr;
+};
+
+
+class MatchChecksumDlg: public KDialogBase {
+public:
+ MatchChecksumDlg(const TQStringList& files, bool containFolders,
+ const TQString& path, const TQString& checksumFile=TQString());
+
+ static TQString checksumTypesFilter;
+
+protected:
+ bool verifyChecksumFile(TQString path, TQString& extension);
+
+private:
+ KTempFile *tmpOut, *tmpErr;
+};
+
+
+class ChecksumResultsDlg: public KDialogBase {
+public:
+ ChecksumResultsDlg(const TQStringList& stdOut, const TQStringList& stdErr,
+ const TQString& suggestedFilename, const TQString& binary, const TQString& type,
+ bool standardFormat);
+
+protected:
+ bool saveChecksum(const TQStringList& data, TQString filename);
+ void savePerFile(const TQStringList& data, const TQString& type);
+
+private:
+ TQString _binary;
+};
+
+
+class VerifyResultDlg: public KDialogBase {
+public:
+ VerifyResultDlg(const TQStringList& failed);
+};
+
+#endif // CHECKSUMDLG_H
diff --git a/src/app/Dialogs/krdialogs.cpp b/src/app/Dialogs/krdialogs.cpp
new file mode 100644
index 0000000..d5b2000
--- /dev/null
+++ b/src/app/Dialogs/krdialogs.cpp
@@ -0,0 +1,256 @@
+/***************************************************************************
+ krdialogs.cpp
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ S o u r c e F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+
+// Krusader includes
+#include "krdialogs.h"
+// TQt includes
+#include <tqmessagebox.h>
+#include <tqwidget.h>
+#include <tqapplication.h>
+#include <tqfontmetrics.h>
+#include <tqtooltip.h>
+// TDE includes
+#include <tdelocale.h>
+#include <kurlcompletion.h>
+#include <tdeapplication.h>
+#include <kstandarddirs.h>
+#include <klineedit.h>
+#include <kurlrequester.h>
+#include <kstandarddirs.h>
+#include <tdeversion.h>
+#include <tqcheckbox.h>
+#include <tderecentdocument.h>
+#include <tqhbox.h>
+// Krusader includes
+#include "../krusader.h"
+#include "../resources.h"
+#include "../VFS/vfs.h"
+#include "../defaults.h"
+#include <tqdir.h>
+
+KURL KChooseDir::getDir(TQString text,const KURL& url, const KURL& cwd) {
+ KURLRequesterDlg *dlg = new KURLRequesterDlg( vfs::pathOrURL( url, 1 ),text,krApp,"");
+ dlg->urlRequester()->completionObject()->setDir(cwd.url());
+ dlg->urlRequester()->setMode(KFile::LocalOnly | KFile::Directory);
+ KURL u;
+ if (dlg->exec() == TQDialog::Accepted) {
+ u = vfs::fromPathOrURL(dlg->urlRequester()->completionObject()->replacedPath(
+ dlg->urlRequester()->lineEdit()->text()));
+ if (u.isRelativeURL(u.url())) {
+ KURL temp = u;
+ u = cwd;
+ u.addPath(temp.url());
+ u.cleanPath();
+ if( u.protocol() == "zip" || u.protocol() == "krarc" || u.protocol() == "tar" || u.protocol() == "iso" ) {
+ if( TQDir( u.path() ).exists() )
+ u.setProtocol( "file" );
+ }
+ }
+ }
+ delete dlg;
+ return u;
+}
+
+KURL KChooseDir::getDir(TQString text,const KURL& url, const KURL& cwd, bool &preserveAttrs ) {
+ KURLRequesterDlgForCopy *dlg = new KURLRequesterDlgForCopy( vfs::pathOrURL( url, 1 ),text, preserveAttrs, krApp,"" );
+ dlg->urlRequester()->completionObject()->setDir(cwd.url());
+ KURL u;
+ if (dlg->exec() == TQDialog::Accepted) {
+ u = vfs::fromPathOrURL(dlg->urlRequester()->completionObject()->replacedPath(
+ dlg->urlRequester()->lineEdit()->text()));
+ if (u.isRelativeURL(u.url())) {
+ KURL temp = u;
+ u = cwd;
+ u.addPath(temp.url());
+ u.cleanPath();
+ if( u.protocol() == "zip" || u.protocol() == "krarc" || u.protocol() == "tar" || u.protocol() == "iso" ) {
+ if( TQDir( u.path() ).exists() )
+ u.setProtocol( "file" );
+ }
+ }
+ }
+ preserveAttrs = dlg->preserveAttrs();
+ delete dlg;
+ return u;
+}
+
+KURL KChooseDir::getDir(TQString text,const KURL& url, const KURL& cwd, bool &preserveAttrs, KURL &baseURL ) {
+ KURLRequesterDlgForCopy *dlg = new KURLRequesterDlgForCopy( vfs::pathOrURL( url, 1 ),text, preserveAttrs, krApp,"", true, baseURL );
+ dlg->urlRequester()->completionObject()->setDir(cwd.url());
+ KURL u;
+ if (dlg->exec() == TQDialog::Accepted) {
+ u = vfs::fromPathOrURL(dlg->urlRequester()->completionObject()->replacedPath(
+ dlg->urlRequester()->lineEdit()->text()));
+ if (u.isRelativeURL(u.url())) {
+ KURL temp = u;
+ u = cwd;
+ u.addPath(temp.url());
+ u.cleanPath();
+ if( u.protocol() == "zip" || u.protocol() == "krarc" || u.protocol() == "tar" || u.protocol() == "iso" ) {
+ if( TQDir( u.path() ).exists() )
+ u.setProtocol( "file" );
+ }
+ }
+
+ if( dlg->copyDirStructure() ) {
+ baseURL = dlg->baseURL();
+ } else {
+ baseURL = KURL();
+ }
+ }
+ preserveAttrs = dlg->preserveAttrs();
+ delete dlg;
+ return u;
+}
+
+KURLRequesterDlgForCopy::KURLRequesterDlgForCopy( const TQString& urlName, const TQString& _text, bool presAttrs, TQWidget *parent,
+ const char *name, bool modal, KURL baseURL )
+ : KDialogBase( Plain, TQString(), Ok|Cancel|User1, Ok, parent, name, modal, true, KStdGuiItem::clear() ),
+ baseUrlCombo( 0 ), copyDirStructureCB( 0 ) {
+
+ TQVBoxLayout * topLayout = new TQVBoxLayout( plainPage(), 0, spacingHint() );
+
+ TQLabel * label = new TQLabel( _text, plainPage() );
+ topLayout->addWidget( label );
+
+ urlRequester_ = new KURLRequester( urlName, plainPage(), "urlRequester" );
+ urlRequester_->setMinimumWidth( urlRequester_->sizeHint().width() * 3 );
+ topLayout->addWidget( urlRequester_ );
+ preserveAttrsCB = new TQCheckBox(i18n("Preserve attributes (only for local targets)"), plainPage());
+ preserveAttrsCB->setChecked( presAttrs );
+ topLayout->addWidget( preserveAttrsCB );
+ if( !baseURL.isEmpty() ) {
+ TQFrame *line = new TQFrame( plainPage(), "sepLine" );
+ line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken );
+ topLayout->addWidget( line );
+ copyDirStructureCB = new TQCheckBox(i18n("Keep virtual directory structure"), plainPage());
+ connect( copyDirStructureCB, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotDirStructCBChanged() ) );
+ copyDirStructureCB->setChecked( false );
+ topLayout->addWidget( copyDirStructureCB );
+ TQHBox * hbox = new TQHBox( plainPage(), "copyDirStructure" );
+ new TQLabel( i18n("Base URL:"), hbox, "baseURLLabel" );
+
+ baseUrlCombo = new TQComboBox( hbox, "baseUrlRequester" );
+ baseUrlCombo->setMinimumWidth( baseUrlCombo->sizeHint().width() * 3 );
+ baseUrlCombo->setEnabled( copyDirStructureCB->isChecked() );
+ KURL temp = baseURL, tempOld;
+ do {
+ TQString baseURLText = vfs::pathOrURL( temp );
+ baseUrlCombo->insertItem( baseURLText );
+ tempOld = temp;
+ temp = temp.upURL();
+ }while( !tempOld.equals( temp, true ) );
+ baseUrlCombo->setCurrentItem( 0 );
+
+ topLayout->addWidget( hbox );
+ }
+ urlRequester_->setFocus();
+ connect( urlRequester_->lineEdit(), TQ_SIGNAL(textChanged(const TQString&)),
+ TQ_SLOT(slotTextChanged(const TQString&)) );
+ bool state = !urlName.isEmpty();
+ enableButtonOK( state );
+ enableButton( KDialogBase::User1, state );
+ connect( this, TQ_SIGNAL( user1Clicked() ), TQ_SLOT( slotClear() ) );
+}
+
+KURLRequesterDlgForCopy::KURLRequesterDlgForCopy() {
+}
+
+bool KURLRequesterDlgForCopy::preserveAttrs() {
+ return preserveAttrsCB->isChecked();
+}
+
+bool KURLRequesterDlgForCopy::copyDirStructure() {
+ if( copyDirStructureCB == 0 )
+ return false;
+ return copyDirStructureCB->isChecked();
+}
+
+void KURLRequesterDlgForCopy::slotTextChanged(const TQString & text) {
+ bool state = !text.stripWhiteSpace().isEmpty();
+ enableButtonOK( state );
+ enableButton( KDialogBase::User1, state );
+}
+
+void KURLRequesterDlgForCopy::slotClear() {
+ urlRequester_->clear();
+}
+
+void KURLRequesterDlgForCopy::slotDirStructCBChanged() {
+ baseUrlCombo->setEnabled( copyDirStructureCB->isChecked() );
+}
+
+KURL KURLRequesterDlgForCopy::selectedURL() const {
+ if ( result() == TQDialog::Accepted ) {
+ KURL url = KURL::fromPathOrURL( urlRequester_->url() );
+ if( url.isValid() )
+ TDERecentDocument::add(url);
+ return url;
+ }
+ else
+ return KURL();
+}
+
+KURLRequester * KURLRequesterDlgForCopy::urlRequester() {
+ return urlRequester_;
+}
+
+KURL KURLRequesterDlgForCopy::baseURL() const {
+ if( baseUrlCombo == 0 )
+ return KURL();
+ return vfs::fromPathOrURL( baseUrlCombo->currentText() );
+}
+
+KRGetDate::KRGetDate(TQDate date, TQWidget *parent, const char *name) : KDialog(parent, name,true,WStyle_DialogBorder) {
+ dateWidget = new KDatePicker(this, date);
+ dateWidget->resize(dateWidget->sizeHint());
+ setMinimumSize(dateWidget->sizeHint());
+ setMaximumSize(dateWidget->sizeHint());
+ resize(minimumSize());
+ connect(dateWidget, TQ_SIGNAL(dateSelected(TQDate)), this, TQ_SLOT(setDate(TQDate)));
+ connect(dateWidget, TQ_SIGNAL(dateEntered(TQDate)), this, TQ_SLOT(setDate(TQDate)));
+
+ // keep the original date - incase ESC is pressed
+ originalDate = date;
+}
+
+TQDate KRGetDate::getDate() {
+ if (exec() == TQDialog::Rejected) chosenDate.setYMD(0,0,0);
+ hide();
+ return chosenDate;
+}
+
+void KRGetDate::setDate(TQDate date) {
+ chosenDate = date;
+ accept();
+}
+
+#include "krdialogs.moc"
diff --git a/src/app/Dialogs/krdialogs.h b/src/app/Dialogs/krdialogs.h
new file mode 100644
index 0000000..ca447bf
--- /dev/null
+++ b/src/app/Dialogs/krdialogs.h
@@ -0,0 +1,116 @@
+/***************************************************************************
+ krdialogs.h
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ email : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ H e a d e r F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef KCHOSEDIR_H
+#define KCHOSEDIR_H
+
+// TDE includes
+#include <kdialog.h>
+#include <kanimwidget.h>
+#include <kurlrequesterdlg.h>
+#include <kdatepicker.h>
+#include <kdialogbase.h>
+// TQt includes
+#include <tqlineedit.h>
+#include <tqlayout.h>
+#include <tqlabel.h>
+#include <tqpushbutton.h>
+#include <tqdatetime.h>
+#include <tqpixmap.h>
+#include <tqprogressdialog.h>
+#include <tqcheckbox.h>
+#include <tqcombobox.h>
+
+/** \class KChooseDir
+ * Used for asking the user for a folder.
+ * example:
+ * \code
+ * KURL u = KChooseDir::getDir("target folder", "/suggested/path", ACTIVE_PANEL->virtualPath());
+ * if (u.isEmpty()) {
+ * // user canceled (either by pressing cancel, or esc
+ * } else {
+ * // do you thing here: you've got a safe url to use
+ * }
+ * \endcode
+ */
+class KChooseDir {
+public:
+ /**
+ * \param text - description of the info requested from the user
+ * \param url - a suggested url to appear in the box as a default choice
+ * \param cwd - a path which is the current working directory (usually ACTIVE_PANEL->virtualPath()).
+ * this is used for completion of partial urls
+ */
+ static KURL getDir(TQString text,const KURL& url, const KURL& cwd);
+ static KURL getDir(TQString text,const KURL& url, const KURL& cwd, bool & preserveAttrs );
+ static KURL getDir(TQString text,const KURL& url, const KURL& cwd, bool & preserveAttrs, KURL &baseURL );
+};
+
+class KURLRequesterDlgForCopy : public KDialogBase {
+ TQ_OBJECT
+
+public:
+ KURLRequesterDlgForCopy( const TQString& url, const TQString& text, bool presAttrs,
+ TQWidget *parent, const char *name, bool modal=true, KURL baseURL = KURL() );
+ KURLRequesterDlgForCopy();
+
+ KURL selectedURL() const;
+ KURL baseURL() const;
+ bool preserveAttrs();
+ bool copyDirStructure();
+
+ KURLRequester *urlRequester();
+private slots:
+ void slotClear();
+ void slotTextChanged(const TQString &);
+ void slotDirStructCBChanged();
+private:
+ KURLRequester *urlRequester_;
+ TQComboBox *baseUrlCombo;
+ TQCheckBox *preserveAttrsCB;
+ TQCheckBox *copyDirStructureCB;
+};
+
+class KRGetDate : public KDialog {
+ TQ_OBJECT
+
+public:
+ KRGetDate(TQDate date=TQDate::currentDate(), TQWidget *parent = 0, const char *name = 0);
+ TQDate getDate();
+
+private slots:
+ void setDate(TQDate);
+
+private:
+ KDatePicker *dateWidget;
+ TQDate chosenDate, originalDate;
+};
+
+#endif
diff --git a/src/app/Dialogs/krkeydialog.cpp b/src/app/Dialogs/krkeydialog.cpp
new file mode 100644
index 0000000..0be43e7
--- /dev/null
+++ b/src/app/Dialogs/krkeydialog.cpp
@@ -0,0 +1,157 @@
+//
+// C++ Implementation: krkeydialog
+//
+// Description:
+//
+//
+// Author: Jonas Bähr <http://jonas-baehr.de/>, (C) 2006
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "krkeydialog.h"
+
+#include <tqlayout.h>
+#include <tqwhatsthis.h>
+#include <tdelocale.h>
+#include <kpushbutton.h>
+#include <tdemessagebox.h>
+#include <tdefiledialog.h>
+#include <tdeglobal.h>
+#include <kstandarddirs.h>
+#include <tdeconfig.h>
+#include <tdeactionshortcutlist.h>
+#include <kdebug.h>
+
+#include "../krusader.h"
+
+//This is the filter in the KFileDialog of Import/Export:
+static const char* FILE_FILTER = I18N_NOOP("*.keymap|Krusader keymaps\n*|all files");
+
+
+KrKeyDialog::KrKeyDialog( TQWidget * parent ) : KKeyDialog( false /* allow letter shortcuts */, parent ) {
+ insert( krApp->actionCollection() );
+
+ // HACK This fetches the layout of the buttonbox from KDialogBase, although it is not accessable with KDialogBase's API
+ // None the less it's quite save to use since this implementation hasn't changed since KDE-3.3 (I haven't looked at earlier
+ // versions since we don't support them) and now all work is done in KDE-4.
+ TQWidget* buttonBox = static_cast<TQWidget*>( actionButton(KDialogBase::Ok)->parent() );
+ TQBoxLayout* buttonBoxLayout = static_cast<TQBoxLayout*>( buttonBox->layout() );
+
+ KPushButton* importButton = new KPushButton( i18n("Import shortcuts"), buttonBox );
+ TQWhatsThis::add( importButton, i18n( "Load a keybinding profile, e.g., total_commander.keymap" ) );
+ buttonBoxLayout->insertWidget( 1, importButton ); // the defaults-button should stay on position 0
+ connect( importButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotImportShortcuts() ) );
+
+ KPushButton* exportButton = new KPushButton( i18n("Export shortcuts"), buttonBox );
+ TQWhatsThis::add( exportButton, i18n( "Save current keybindings in a keymap file." ) );
+ buttonBoxLayout->insertWidget( 2, exportButton );
+ connect( exportButton, TQ_SIGNAL( clicked() ), TQ_SLOT( slotExportShortcuts() ) );
+
+ // Also quite HACK 'isch but unfortunately KKeyDialog don't giveus access to this widget
+ _chooser = static_cast<KKeyChooser*>( mainWidget() );
+
+ configure( true /* SaveSettings */ ); // this runs the dialog
+}
+
+KrKeyDialog::~KrKeyDialog() {
+}
+
+void KrKeyDialog::slotImportShortcuts() {
+ // find $TDEDIR/share/apps/krusader
+ TQString basedir = TDEGlobal::dirs()->findResourceDir("appdata", "total_commander.keymap");
+ // let the user select a file to load
+ TQString filename = KFileDialog::getOpenFileName(basedir, i18n(FILE_FILTER), 0, i18n("Select a keymap file"));
+ if ( filename.isEmpty() )
+ return;
+
+ TDEConfig conf( filename, true /*read only*/, false /*no KDEGlobal*/ );
+ if ( ! conf.hasGroup("Shortcuts") ) {
+ int answer = KMessageBox::warningContinueCancel( this, //parent
+ i18n("This file does not seem to be a valid keymap.\n"
+ "It may be a keymap using a legacy format. The import can't be undone!"), //text
+ i18n("Try to import legacy format?"), //caption
+ i18n("Import anyway"), //Label for the continue-button
+ "Confirm Import Legacy Shortcuts" //dontAskAgainName (for the config-file)
+ );
+ if ( answer == KMessageBox::Continue )
+ importLegacyShortcuts( filename );
+ else
+ return;
+ }
+ else
+ _chooser->syncToConfig( "Shortcuts", &conf, false /* don't delete shortcuts of actions not listed in conf */ );
+}
+
+void KrKeyDialog::importLegacyShortcuts( const TQString& file ) {
+/*
+ * This is basicaly Shie's code. It's copied from Kronfigurator's loog&feel page and adapted to the dialog
+ */
+ // check if there's an info file with the keymap
+ TQFile info(file+".info");
+ if (info.open(IO_ReadOnly)) {
+ TQTextStream stream(&info);
+ TQStringList infoText = TQStringList::split("\n", stream.read());
+ if (KMessageBox::questionYesNoList(krApp, i18n("The following information was attached to the keymap. Do you really want to import this keymap?"), infoText)!=KMessageBox::Yes)
+ return;
+ }
+
+ // ok, import away
+ TQFile f(file);
+ if (!f.open(IO_ReadOnly)) {
+ krOut << "Error opening " << file << endl;
+ return;
+ }
+ char *actionName;
+ TQDataStream stream(&f);
+ int key;
+ TDEAction *action;
+ while (!stream.atEnd()) {
+ stream >> actionName >> key;
+ action = krApp->actionCollection()->action(actionName);
+ if (action) {
+ action->setShortcut(key);
+// krOut << "set shortcut for " << actionName <<endl;
+ } else {
+ krOut << "unknown action " << actionName << endl;
+ }
+ }
+ f.close();
+
+ KMessageBox::information( this, // parent
+ i18n("Please restart this dialog in order to see the changes"), // text
+ i18n("Legacy import completed") // caption
+ );
+}
+
+void KrKeyDialog::slotExportShortcuts() {
+ TQString filename = KFileDialog::getSaveFileName( TQString(), i18n(FILE_FILTER), 0, i18n("Select a keymap file") );
+ if ( filename.isEmpty() )
+ return;
+ TQFile f( filename );
+ if ( f.exists() &&
+ KMessageBox::warningContinueCancel( this,
+ i18n("<qt>File <b>%1</b> already exists. Do you really want to overwrite it?</qt>").arg(filename),
+ i18n("Warning"), i18n("Overwrite") )
+ != KMessageBox::Continue)
+ return;
+ if ( f.open( IO_WriteOnly ) )
+ // This is the only way to detect if the file is writable since we don't get feetback from TDEConfig's sync
+ // Additionaly this prevents merging if the file already contains some shortcuts
+ f.close();
+ else {
+ KMessageBox::error( this, i18n("<qt>Can't open <b>%1</b> for writing!</qt>").arg(filename) );
+ return;
+ }
+
+ TDEConfig conf( filename, false /*read only*/, false /*no KDEGlobal*/ );
+
+ // unfortunately we can't use this function since it only writes the actions which are different from default.
+ //krApp->actionCollection()->writeShortcutSettings( "Shortcuts", &conf );
+ TDEActionShortcutList list( krApp->actionCollection() );
+ list.writeSettings( "Shortcuts", &conf, true /* write all actions */ );
+ // That does TDEActionShortcutList::writeSettings for us
+ //conf.sync(); // write back all changes
+}
+
+#include "krkeydialog.moc"
diff --git a/src/app/Dialogs/krkeydialog.h b/src/app/Dialogs/krkeydialog.h
new file mode 100644
index 0000000..082ac0a
--- /dev/null
+++ b/src/app/Dialogs/krkeydialog.h
@@ -0,0 +1,38 @@
+//
+// C++ Interface: krkeydialog
+//
+// Description:
+//
+//
+// Author: Jonas Bähr <http://jonas-baehr.de/>, (C) 2006
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef KRKEYDIALOG_H
+#define KRKEYDIALOG_H
+
+#include <kkeydialog.h>
+
+/**
+ * @short KDE's KKeyDialog extended by the ability to export/import shortcuts
+ * @author Jonas Bähr
+ */
+class KrKeyDialog : protected KKeyDialog
+{
+TQ_OBJECT
+
+public:
+ KrKeyDialog( TQWidget* parent = 0 );
+ ~KrKeyDialog();
+
+private slots:
+ void slotImportShortcuts();
+ void slotExportShortcuts();
+
+private:
+ void importLegacyShortcuts( const TQString& file );
+ KKeyChooser* _chooser;
+};
+
+#endif
diff --git a/src/app/Dialogs/krmaskchoice.cpp b/src/app/Dialogs/krmaskchoice.cpp
new file mode 100644
index 0000000..159cbf9
--- /dev/null
+++ b/src/app/Dialogs/krmaskchoice.cpp
@@ -0,0 +1,179 @@
+/***************************************************************************
+ krmaskchoice.cpp
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ S o u r c e F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#include "krmaskchoice.h"
+
+#include <tqcombobox.h>
+#include <tqgroupbox.h>
+#include <tqlabel.h>
+#include <tqlistbox.h>
+#include <tqpushbutton.h>
+#include <tqlayout.h>
+#include <tqvariant.h>
+#include <tqtooltip.h>
+#include <tqwhatsthis.h>
+#include <tqmessagebox.h>
+#include <tdelocale.h>
+#include <tqlineedit.h>
+
+/*
+ * Constructs a KRMaskChoice which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * true to construct a modal dialog.
+ */
+KRMaskChoice::KRMaskChoice( TQWidget* parent, const char* name, bool modal, WFlags fl )
+ : TQDialog( parent, name, modal, fl )
+{
+ if ( !name )
+ setName( "KRMaskChoice" );
+ resize( 401, 314 );
+ setCaption( i18n( "Choose Files" ) );
+ setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)5, (TQSizePolicy::SizeType)5 ) );
+
+ selection = new TQComboBox( false, this, "selection" );
+ int height = TQFontMetrics( selection->font() ).height();
+ height = height + 5*(height > 14) + 6;
+ selection->setGeometry( TQRect( 12, 48, 377, height) );
+ selection->setEditable( true );
+ selection->setInsertionPolicy( TQComboBox::AtTop );
+ selection->setAutoCompletion( true );
+
+ TQWidget* Layout7 = new TQWidget( this, "Layout7" );
+ Layout7->setGeometry( TQRect( 10, 10, 380, 30 ) );
+ hbox = new TQHBoxLayout( Layout7 );
+ hbox->setSpacing( 6 );
+ hbox->setMargin( 0 );
+
+ PixmapLabel1 = new TQLabel( Layout7, "PixmapLabel1" );
+ PixmapLabel1->setScaledContents( true );
+ PixmapLabel1->setMaximumSize( TQSize( 31, 31 ) );
+ // now, add space for the pixmap
+ hbox->addWidget( PixmapLabel1 );
+
+ label = new TQLabel( Layout7, "label" );
+ label->setText( i18n( "Select the following files:" ) );
+ hbox->addWidget( label );
+
+ GroupBox1 = new TQGroupBox( this, "GroupBox1" );
+ GroupBox1->setGeometry( TQRect( 11, 77, 379, 190 ) );
+ GroupBox1->setTitle( i18n( "Predefined Selections" ) );
+
+ TQWidget* Layout6 = new TQWidget( GroupBox1, "Layout6" );
+ Layout6->setGeometry( TQRect( 10, 20, 360, 160 ) );
+ hbox_2 = new TQHBoxLayout( Layout6 );
+ hbox_2->setSpacing( 6 );
+ hbox_2->setMargin( 0 );
+
+ preSelections = new TQListBox( Layout6, "preSelections" );
+ preSelections->setVScrollBarMode( TQListBox::AlwaysOn );
+ TQWhatsThis::add( preSelections, i18n( "A predefined selection is a file-mask which you use often.\nSome examples are: \"*.c, *.h\", \"*.c, *.o\", etc.\nYou can add these masks to the list by typing them and pressing the Add button.\nDelete removes a predefined selection and Clear removes all of them.\nNotice that the line in which you edit the mask has it's own history, you can scroll it, if needed." ) );
+ hbox_2->addWidget( preSelections );
+
+ vbox = new TQVBoxLayout;
+ vbox->setSpacing( 6 );
+ vbox->setMargin( 0 );
+
+ PushButton7 = new TQPushButton( Layout6, "PushButton7" );
+ PushButton7->setText( i18n( "Add" ) );
+ TQToolTip::add( PushButton7, i18n( "Adds the selection in the line-edit to the list" ) );
+ vbox->addWidget( PushButton7 );
+
+ PushButton7_2 = new TQPushButton( Layout6, "PushButton7_2" );
+ PushButton7_2->setText( i18n( "Delete" ) );
+ TQToolTip::add( PushButton7_2, i18n( "Delete the marked selection from the list" ) );
+ vbox->addWidget( PushButton7_2 );
+
+ PushButton7_3 = new TQPushButton( Layout6, "PushButton7_3" );
+ PushButton7_3->setText( i18n( "Clear" ) );
+ TQToolTip::add( PushButton7_3, i18n( "Clears the entire list of selections" ) );
+ vbox->addWidget( PushButton7_3 );
+ TQSpacerItem* spacer = new TQSpacerItem( 20, 54, TQSizePolicy::Fixed, TQSizePolicy::Expanding );
+ vbox->addItem( spacer );
+ hbox_2->addLayout( vbox );
+
+ TQWidget* Layout18 = new TQWidget( this, "Layout18" );
+ Layout18->setGeometry( TQRect( 10, 280, 379, 30 ) );
+ hbox_3 = new TQHBoxLayout( Layout18 );
+ hbox_3->setSpacing( 6 );
+ hbox_3->setMargin( 0 );
+ TQSpacerItem* spacer_2 = new TQSpacerItem( 205, 20, TQSizePolicy::Expanding, TQSizePolicy::Fixed );
+ hbox_3->addItem( spacer_2 );
+
+ PushButton3 = new TQPushButton( Layout18, "PushButton3" );
+ PushButton3->setText( i18n( "OK" ) );
+ hbox_3->addWidget( PushButton3 );
+
+ PushButton3_2 = new TQPushButton( Layout18, "PushButton3_2" );
+ PushButton3_2->setText( i18n( "Cancel" ) );
+ hbox_3->addWidget( PushButton3_2 );
+
+ // signals and slots connections
+ connect( PushButton3_2, TQ_SIGNAL( clicked() ), this, TQ_SLOT( reject() ) );
+ connect( PushButton3, TQ_SIGNAL( clicked() ), this, TQ_SLOT( accept() ) );
+ connect( PushButton7, TQ_SIGNAL( clicked() ), this, TQ_SLOT( addSelection() ) );
+ connect( PushButton7_2, TQ_SIGNAL( clicked() ), this, TQ_SLOT( deleteSelection() ) );
+ connect( PushButton7_3, TQ_SIGNAL( clicked() ), this, TQ_SLOT( clearSelections() ) );
+ connect( selection, TQ_SIGNAL( activated(const TQString&) ), selection, TQ_SLOT( setEditText(const TQString &) ) );
+ connect( selection->lineEdit(), TQ_SIGNAL( returnPressed() ), this, TQ_SLOT( accept() ));
+ connect( preSelections, TQ_SIGNAL( doubleClicked(TQListBoxItem*) ), this, TQ_SLOT( acceptFromList(TQListBoxItem *) ) );
+ connect( preSelections, TQ_SIGNAL( highlighted(const TQString&) ), selection, TQ_SLOT( setEditText(const TQString &) ) );
+ connect( preSelections, TQ_SIGNAL( returnPressed(TQListBoxItem*) ), this, TQ_SLOT( acceptFromList(TQListBoxItem *) ) );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+KRMaskChoice::~KRMaskChoice()
+{
+ // no need to delete child widgets, TQt does it all for us
+}
+
+void KRMaskChoice::addSelection()
+{
+ tqWarning( "KRMaskChoice::addSelection(): Not implemented yet!" );
+}
+
+void KRMaskChoice::clearSelections()
+{
+ tqWarning( "KRMaskChoice::clearSelections(): Not implemented yet!" );
+}
+
+void KRMaskChoice::deleteSelection()
+{
+ tqWarning( "KRMaskChoice::deleteSelection(): Not implemented yet!" );
+}
+
+void KRMaskChoice::acceptFromList(TQListBoxItem *)
+{
+ tqWarning( "KRMaskChoice::acceptFromList(TQListBoxItem *): Not implemented yet!" );
+}
+
+#include "krmaskchoice.moc"
diff --git a/src/app/Dialogs/krmaskchoice.h b/src/app/Dialogs/krmaskchoice.h
new file mode 100644
index 0000000..a4324da
--- /dev/null
+++ b/src/app/Dialogs/krmaskchoice.h
@@ -0,0 +1,77 @@
+/***************************************************************************
+ krmaskchoice.h
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ email : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ H e a d e r F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef KRMASKCHOICE_H
+#define KRMASKCHOICE_H
+
+#include <tqdialog.h>
+class TQVBoxLayout;
+class TQHBoxLayout;
+class TQGridLayout;
+class TQComboBox;
+class TQGroupBox;
+class TQLabel;
+class TQListBox;
+class TQListBoxItem;
+class TQPushButton;
+
+class KRMaskChoice : public TQDialog
+{
+ TQ_OBJECT
+
+
+public:
+ KRMaskChoice( TQWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
+ ~KRMaskChoice();
+
+ TQComboBox* selection;
+ TQLabel* PixmapLabel1;
+ TQLabel* label;
+ TQGroupBox* GroupBox1;
+ TQListBox* preSelections;
+ TQPushButton* PushButton7;
+ TQPushButton* PushButton7_2;
+ TQPushButton* PushButton7_3;
+ TQPushButton* PushButton3;
+ TQPushButton* PushButton3_2;
+
+public slots:
+ virtual void addSelection();
+ virtual void clearSelections();
+ virtual void deleteSelection();
+ virtual void acceptFromList(TQListBoxItem *);
+
+protected:
+ TQHBoxLayout* hbox;
+ TQHBoxLayout* hbox_2;
+ TQHBoxLayout* hbox_3;
+ TQVBoxLayout* vbox;
+};
+
+#endif // KRMASKCHOICE_H
diff --git a/src/app/Dialogs/krpleasewait.cpp b/src/app/Dialogs/krpleasewait.cpp
new file mode 100644
index 0000000..55521f7
--- /dev/null
+++ b/src/app/Dialogs/krpleasewait.cpp
@@ -0,0 +1,153 @@
+/***************************************************************************
+ krpleasewait.cpp
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ S o u r c e F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "krpleasewait.h"
+#include <tqtimer.h>
+#include <tqdatetime.h>
+#include <tqapplication.h>
+#include <tqpushbutton.h>
+#include <unistd.h>
+#include "../krusader.h"
+#include "tdelocale.h"
+#include <kcursor.h>
+
+KRPleaseWait::KRPleaseWait( TQString msg, int count, bool cancel ):
+ TQProgressDialog( cancel ? 0 : krApp,0, !cancel) , inc(true) {
+
+ timer = new TQTimer(this);
+ setCaption( i18n( "Krusader::Wait" ) );
+
+ setMinimumDuration(500);
+ setAutoClose(false);
+ setAutoReset(false);
+
+ connect( timer,TQ_SIGNAL(timeout()), this, TQ_SLOT(cycleProgress()));
+
+ TQProgressBar* progress = new TQProgressBar(count,this);
+ progress->setCenterIndicator(true);
+ setBar(progress);
+
+ TQLabel* label = new TQLabel(this);
+ setLabel(label);
+
+ TQPushButton* btn = new TQPushButton(i18n("&Cancel"),this);
+ setCancelButton(btn);
+
+ btn->setEnabled(canClose = cancel);
+ setLabelText(msg);
+
+ show();
+}
+
+void KRPleaseWait::closeEvent ( TQCloseEvent * e )
+{
+ if( canClose ) {
+ emit cancelled();
+ e->accept();
+ } else /* if cancel is not allowed, we disable */
+ e->ignore(); /* the window closing [x] also */
+}
+
+void KRPleaseWait::incProgress(int howMuch){
+ setProgress(progress()+howMuch);
+}
+
+void KRPleaseWait::cycleProgress(){
+ if (inc) setProgress(progress()+1);
+ else setProgress(progress()-1);
+ if ( progress() >= 9 ) inc = false;
+ if ( progress() <= 0 ) inc = true;
+}
+
+KRPleaseWaitHandler::KRPleaseWaitHandler() : TQObject(), job(), dlg( 0 ) {
+}
+
+void KRPleaseWaitHandler::stopWait(){
+ if( dlg != 0 ) delete dlg;
+ dlg=0;
+ cycleMutex=incMutex=false;
+ // return cursor to normal arrow
+ krApp->setCursor(KCursor::arrowCursor());
+}
+
+
+void KRPleaseWaitHandler::startWaiting( TQString msg, int count , bool cancel){
+ if ( dlg == 0 ){
+ dlg = new KRPleaseWait( msg , count, cancel);
+ connect( dlg,TQ_SIGNAL(cancelled()),this,TQ_SLOT(killJob()) );
+ }
+ incMutex=cycleMutex=_wasCancelled=false;
+ dlg->setProgress(0);
+
+ dlg->setLabelText(msg);
+ if ( count == 0) {
+ dlg->setTotalSteps(10);
+ cycle = true ;
+ cycleProgress();
+ }
+ else {
+ dlg->setTotalSteps(count);
+ cycle = false;
+ }
+}
+
+void KRPleaseWaitHandler::cycleProgress(){
+ if (cycleMutex) return;
+ cycleMutex=true;
+ if (dlg) dlg->cycleProgress();
+ if (cycle) TQTimer::singleShot(2000,this,TQ_SLOT(cycleProgress()));
+ cycleMutex=false;
+}
+
+void KRPleaseWaitHandler::killJob(){
+ if( !job.isNull() ) job->kill(false);
+ stopWait();
+ _wasCancelled = true;
+}
+
+void KRPleaseWaitHandler::setJob(TDEIO::Job* j){ job=j; }
+
+void KRPleaseWaitHandler::incProgress(int i){
+ if (incMutex) return;
+ incMutex=true;
+ if(dlg) dlg->incProgress(i);
+ incMutex=false;
+}
+
+void KRPleaseWaitHandler::incProgress( TDEProcess *, char *buffer, int buflen ) {
+ int howMuch = 0;
+ for ( int i = 0 ; i < buflen; ++i )
+ if ( buffer[ i ] == '\n' )
+ ++howMuch;
+
+ incProgress( howMuch );
+}
+
+#include "krpleasewait.moc"
diff --git a/src/app/Dialogs/krpleasewait.h b/src/app/Dialogs/krpleasewait.h
new file mode 100644
index 0000000..246ef3c
--- /dev/null
+++ b/src/app/Dialogs/krpleasewait.h
@@ -0,0 +1,84 @@
+/***************************************************************************
+ krpleasewait.h
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ H e a d e r F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRPLEASEWAIT_H
+#define KRPLEASEWAIT_H
+
+#include <tqprogressdialog.h>
+#include <tqtimer.h>
+#include <tqguardedptr.h>
+#include <tdeio/jobclasses.h>
+
+class TDEProcess;
+class KRPleaseWait;
+
+class KRPleaseWaitHandler : public TQObject {
+ TQ_OBJECT
+
+
+public:
+ KRPleaseWaitHandler();
+
+public slots:
+
+ void startWaiting(TQString msg, int count = 0, bool cancel = false);
+ void stopWait();
+ void cycleProgress();
+ void incProgress(int i);
+ void incProgress( TDEProcess *, char *buffer, int buflen );
+ void killJob();
+ void setJob(TDEIO::Job* j);
+ bool wasCancelled() const { return _wasCancelled; }
+
+private:
+ TQGuardedPtr<TDEIO::Job> job;
+ KRPleaseWait * dlg;
+ bool cycle, cycleMutex, incMutex, _wasCancelled;
+};
+
+
+class KRPleaseWait : public TQProgressDialog {
+ TQ_OBJECT
+
+public:
+ KRPleaseWait( TQString msg, int count = 0 ,bool cancel = false );
+
+public slots:
+ void incProgress(int howMuch);
+ void cycleProgress();
+
+protected:
+ bool inc;
+ TQTimer* timer;
+ virtual void closeEvent ( TQCloseEvent * e );
+ bool canClose;
+};
+
+#endif
diff --git a/src/app/Dialogs/krprogress.cpp b/src/app/Dialogs/krprogress.cpp
new file mode 100644
index 0000000..1d489d5
--- /dev/null
+++ b/src/app/Dialogs/krprogress.cpp
@@ -0,0 +1,270 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2000 Matej Koss <koss@miesto.sk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <tqtimer.h>
+#include <tqlayout.h>
+#include <tqtooltip.h>
+#include <tqdatetime.h>
+
+#include <tdeapplication.h>
+#include <kdialog.h>
+#include <kstringhandler.h>
+#include <tdeglobal.h>
+#include <tdelocale.h>
+#include <kiconloader.h>
+#include <kpushbutton.h>
+#include <kstdguiitem.h>
+#include <twin.h>
+
+#include <tdeio/jobclasses.h>
+
+#include "krprogress.h"
+#include "../krusader.h"
+
+KrProgress::KrProgress( TDEIO::Job* job )
+ : ProgressBase( krApp ),
+ m_iTotalSize(0), m_iTotalFiles(0), m_iTotalDirs(0),
+ m_iProcessedSize(0), m_iProcessedDirs(0), m_iProcessedFiles(0){
+
+#ifdef TQ_WS_X11 //FIXME(E): Remove once all the KWin::foo calls have been ported to TQWS
+ // Set a useful icon for this window!
+ KWin::setIcons( winId(),
+ TDEGlobal::iconLoader()->loadIcon( "document-save", TDEIcon::NoGroup, 32 ),
+ TDEGlobal::iconLoader()->loadIcon( "document-save", TDEIcon::NoGroup, 16 ) );
+#endif
+
+ TQVBoxLayout *topLayout = new TQVBoxLayout( this, KDialog::marginHint(),
+ KDialog::spacingHint() );
+ topLayout->addStrut( 360 ); // makes dlg at least that wide
+
+ TQGridLayout *grid = new TQGridLayout( 2, 3 );
+ topLayout->addLayout(grid);
+ grid->addColSpacing(1, KDialog::spacingHint());
+ // filenames or action name
+ grid->addWidget(new TQLabel(i18n("Source:"), this), 0, 0);
+
+ sourceLabel = new KSqueezedTextLabel(this);
+ grid->addWidget(sourceLabel, 0, 2);
+
+ destInvite = new TQLabel(i18n("Destination:"), this);
+ grid->addWidget(destInvite, 1, 0);
+
+ destLabel = new KSqueezedTextLabel(this);
+ grid->addWidget(destLabel, 1, 2);
+
+ m_pProgressBar = new KProgress(this);
+ topLayout->addWidget( m_pProgressBar );
+
+ // processed info
+ TQHBoxLayout *hBox = new TQHBoxLayout();
+ topLayout->addLayout(hBox);
+
+ sizeLabel = new TQLabel(this);
+ hBox->addWidget(sizeLabel);
+
+ resumeLabel = new TQLabel(this);
+ hBox->addWidget(resumeLabel);
+
+ progressLabel = new TQLabel( this );
+/* progressLabel->setSizePolicy( TQSizePolicy( TQSizePolicy::MinimumExpanding,
+ TQSizePolicy::Preferred ) );*/
+ progressLabel->setAlignment( TQLabel::AlignRight );
+ hBox->addWidget( progressLabel );
+
+ hBox = new TQHBoxLayout();
+ topLayout->addLayout(hBox);
+
+ speedLabel = new TQLabel(this);
+ hBox->addWidget(speedLabel, 1);
+
+ TQFrame *line = new TQFrame( this );
+ line->setFrameShape( TQFrame::HLine );
+ line->setFrameShadow( TQFrame::Sunken );
+ topLayout->addWidget( line );
+
+ hBox = new TQHBoxLayout();
+ topLayout->addLayout(hBox);
+
+ hBox->addStretch(1);
+
+ KPushButton *pb = new KPushButton( KStdGuiItem::cancel(), this );
+ connect( pb, TQ_SIGNAL( clicked() ), TQ_SLOT( slotStop() ) );
+ hBox->addWidget( pb );
+
+ resize( sizeHint() );
+ setMaximumHeight(sizeHint().height());
+
+ setCaption(i18n("Krusader Progress")); // show something better than tdeio_uiserver
+
+ setJob(job);
+ setOnlyClean(false);
+ setStopOnClose(true);
+ // Connect global progress info signals
+ connect( job, TQ_SIGNAL( percent( TDEIO::Job*, unsigned long ) ),
+ TQ_SLOT( slotPercent( TDEIO::Job*, unsigned long ) ) );
+ connect( job, TQ_SIGNAL( infoMessage( TDEIO::Job*, const TQString & ) ),
+ TQ_SLOT( slotInfoMessage( TDEIO::Job*, const TQString & ) ) );
+ connect( job, TQ_SIGNAL( totalSize( TDEIO::Job*, TDEIO::filesize_t ) ),
+ TQ_SLOT( slotTotalSize( TDEIO::Job*, TDEIO::filesize_t ) ) );
+ connect( job, TQ_SIGNAL( processedSize( TDEIO::Job*, TDEIO::filesize_t ) ),
+ TQ_SLOT( slotProcessedSize( TDEIO::Job*, TDEIO::filesize_t ) ) );
+ connect( job, TQ_SIGNAL( speed( TDEIO::Job*, unsigned long ) ),
+ TQ_SLOT( slotSpeed( TDEIO::Job*, unsigned long ) ) );
+
+ // change to modal & move to Krusader's center
+ TQPoint center((krApp->width()-width())/2,(krApp->height()-height())/2);
+ center = center+(krApp->pos());
+ reparent(krApp,WType_Modal,center);
+ //setWFlags(WType_Modal);
+ //move((krApp->width()-width())/2,(krApp->height()-height())/2);
+ show();
+}
+
+KrProgress::~KrProgress(){}
+
+void KrProgress::slotTotalSize( TDEIO::Job*, TDEIO::filesize_t bytes ){
+ m_iTotalSize = bytes;
+}
+
+
+void KrProgress::slotTotalFiles( TDEIO::Job*, unsigned long files ){
+ m_iTotalFiles = files;
+ showTotals();
+}
+
+
+void KrProgress::slotTotalDirs( TDEIO::Job*, unsigned long dirs ){
+ m_iTotalDirs = dirs;
+ showTotals();
+}
+
+void KrProgress::showTotals(){
+ // Show the totals in the progress label, if we still haven't
+ // processed anything. This is useful when the stat'ing phase
+ // of CopyJob takes a long time (e.g. over networks).
+ if ( m_iProcessedFiles == 0 && m_iProcessedDirs == 0 )
+ {
+ TQString tmps;
+ if ( m_iTotalDirs > 1 )
+ // that we have a singular to translate looks weired but is only logical
+ tmps = i18n("%n directory", "%n directories", m_iTotalDirs) + " ";
+ tmps += i18n("%n file", "%n files", m_iTotalFiles);
+ progressLabel->setText( tmps );
+ }
+}
+
+void KrProgress::slotPercent( TDEIO::Job*, unsigned long percent ){
+ TQString tmp(i18n( "%1% of %2 ").arg( percent ).arg( TDEIO::convertSize(m_iTotalSize)));
+ m_pProgressBar->setValue( percent );
+ tmp.append(i18n(" (Reading)"));
+
+ setCaption( tmp );
+}
+
+
+void KrProgress::slotInfoMessage( TDEIO::Job*, const TQString & msg )
+{
+ speedLabel->setText( msg );
+ speedLabel->setAlignment( speedLabel->alignment() & ~TQt::WordBreak );
+}
+
+
+void KrProgress::slotProcessedSize( TDEIO::Job*, TDEIO::filesize_t bytes ) {
+ m_iProcessedSize = bytes;
+
+ TQString tmp;
+ tmp = i18n( "%1 of %2 complete").arg( TDEIO::convertSize(bytes) ).arg( TDEIO::convertSize(m_iTotalSize));
+ sizeLabel->setText( tmp );
+}
+
+
+void KrProgress::slotProcessedDirs( TDEIO::Job*, unsigned long dirs )
+{
+ m_iProcessedDirs = dirs;
+
+ TQString tmps;
+ tmps = i18n("%1 / %n directory", "%1 / %n directories", m_iTotalDirs).arg( m_iProcessedDirs );
+ tmps += " ";
+ tmps += i18n("%1 / %n file", "%1 / %n files", m_iTotalFiles).arg( m_iProcessedFiles );
+ progressLabel->setText( tmps );
+}
+
+
+void KrProgress::slotProcessedFiles( TDEIO::Job*, unsigned long files )
+{
+ m_iProcessedFiles = files;
+
+ TQString tmps;
+ if ( m_iTotalDirs > 1 ) {
+ tmps = i18n("%1 / %n directory", "%1 / %n directories", m_iTotalDirs).arg( m_iProcessedDirs );
+ tmps += " ";
+ }
+ tmps += i18n("%1 / %n file", "%1 / %n files", m_iTotalFiles).arg( m_iProcessedFiles );
+ progressLabel->setText( tmps );
+}
+
+
+void KrProgress::slotSpeed( TDEIO::Job*, unsigned long bytes_per_second )
+{
+ if ( bytes_per_second == 0 ) {
+ speedLabel->setText( i18n( "Working") );
+ } else {
+#if KDE_IS_VERSION(3,4,0)
+ unsigned int seconds = TDEIO::calculateRemainingSeconds( m_iTotalSize, m_iProcessedSize, bytes_per_second );
+ TQString remaining = TDEIO::convertSeconds(seconds);
+#else
+ TQString remaining = TDEIO::calculateRemaining( m_iTotalSize, m_iProcessedSize, bytes_per_second ).toString();
+#endif
+ speedLabel->setText( i18n( "%1/s ( %2 remaining )").arg( TDEIO::convertSize( bytes_per_second )).arg( remaining ) );
+ }
+}
+
+
+void KrProgress::setDestVisible( bool visible )
+{
+ // We can't hide the destInvite/destLabel labels,
+ // because it screws up the TQGridLayout.
+ if (visible)
+ {
+ destInvite->setText( i18n("Destination:") );
+ }
+ else
+ {
+ destInvite->setText( TQString() );
+ destLabel->setText( TQString() );
+ }
+}
+
+void KrProgress::virtual_hook( int id, void* data ){
+ ProgressBase::virtual_hook( id, data );
+}
+
+void KrProgress::slotStop(){
+ if ( m_pJob ) {
+ m_pJob->kill(false); // this will call slotFinished
+ m_pJob = 0L;
+ } else {
+ slotFinished( 0 ); // here we call it ourselves
+ }
+
+ emit stopped();
+}
+
+void KrProgress::closeEvent( TQCloseEvent* ) { hide(); slotStop(); }
+
+#include "krprogress.moc"
diff --git a/src/app/Dialogs/krprogress.h b/src/app/Dialogs/krprogress.h
new file mode 100644
index 0000000..70196df
--- /dev/null
+++ b/src/app/Dialogs/krprogress.h
@@ -0,0 +1,87 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2000 Matej Koss <koss@miesto.sk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+/** This file was modified for Krusader by Shie Erlich & Rafi Yanai **/
+
+#ifndef __kr_progress_h__
+#define __kr_progress_h__
+
+#include <tqlabel.h>
+
+#include <tdeio/global.h>
+
+#include <kprogress.h>
+#include <ksqueezedtextlabel.h>
+
+#include <tdeio/progressbase.h>
+
+#include <tqobject.h>
+
+class KrProgress : public TDEIO::ProgressBase {
+ TQ_OBJECT
+
+public:
+
+ KrProgress(TDEIO::Job* job);
+ virtual ~KrProgress();
+
+public slots:
+ virtual void slotTotalSize( TDEIO::Job*, TDEIO::filesize_t bytes );
+ virtual void slotTotalFiles( TDEIO::Job*, unsigned long files );
+ virtual void slotTotalDirs( TDEIO::Job*, unsigned long dirs );
+
+ virtual void slotProcessedSize( TDEIO::Job*, TDEIO::filesize_t bytes );
+ virtual void slotProcessedFiles( TDEIO::Job*, unsigned long files );
+ virtual void slotProcessedDirs( TDEIO::Job*, unsigned long dirs );
+
+ virtual void slotSpeed( TDEIO::Job*, unsigned long bytes_per_second );
+ virtual void slotPercent( TDEIO::Job*, unsigned long percent );
+ virtual void slotInfoMessage( TDEIO::Job*, const TQString & msg );
+
+ virtual void slotStop();
+ virtual void closeEvent( TQCloseEvent* );
+
+protected:
+ void showTotals();
+ void setDestVisible( bool visible );
+
+ KSqueezedTextLabel* sourceLabel;
+ KSqueezedTextLabel* destLabel;
+ TQLabel* progressLabel;
+ TQLabel* destInvite;
+ TQLabel* speedLabel;
+ TQLabel* sizeLabel;
+ TQLabel* resumeLabel;
+
+ KProgress* m_pProgressBar;
+
+ TDEIO::filesize_t m_iTotalSize;
+ unsigned long m_iTotalFiles;
+ unsigned long m_iTotalDirs;
+
+ TDEIO::filesize_t m_iProcessedSize;
+ unsigned long m_iProcessedDirs;
+ unsigned long m_iProcessedFiles;
+
+protected:
+ virtual void virtual_hook( int id, void* data );
+};
+
+
+#endif // __kr_progress_h__
+
diff --git a/src/app/Dialogs/krspecialwidgets.cpp b/src/app/Dialogs/krspecialwidgets.cpp
new file mode 100644
index 0000000..ecc5e28
--- /dev/null
+++ b/src/app/Dialogs/krspecialwidgets.cpp
@@ -0,0 +1,239 @@
+/***************************************************************************
+ krspecialwidgets.cpp
+ -------------------
+copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+e-mail : krusader@users.sourceforge.net
+web site : http://krusader.sourceforge.net
+---------------------------------------------------------------------------
+Description
+***************************************************************************
+
+A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ S o u r c e F i l e
+
+***************************************************************************
+* *
+* 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. *
+* *
+***************************************************************************/
+
+
+
+#include "krspecialwidgets.h"
+#include "krmaskchoice.h"
+#include "newftpgui.h"
+#include "../krusader.h"
+#include "../MountMan/kmountman.h"
+#include <math.h>
+#include <tdefileitem.h>
+#include <tdelocale.h>
+#include <klineedit.h>
+#include <kdebug.h>
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////// Pie related widgets /////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// The pie-related widgets use hard-coded coordinates to create the look.
+// This is ok since the whole widget is fitted into an existing view and thus
+// no re-alignments are needed.
+
+#define LEFT 10
+#define BOTTOM 150
+#define WIDTH 120
+#define HEIGHT 40
+#define Z_HEIGHT 10
+#define STARTANGLE 0
+#define DEG(x) (16*(x))
+
+TQColor KRPie::colors[ 12 ] = {TQt::red, TQt::blue, TQt::green, TQt::cyan, TQt::magenta, TQt::gray,
+ TQt::black, TQt::white, TQt::darkRed, TQt::darkBlue, TQt::darkMagenta,
+ TQt::darkCyan};
+
+//////////////////////////////////////////////////////////////////////////////
+/////////////// KRFSDisplay - Filesystem / Freespace Display /////////////////
+//////////////////////////////////////////////////////////////////////////////
+// This is the full constructor: use it for a mounted filesystem
+KRFSDisplay::KRFSDisplay( TQWidget *parent, TQString _alias, TQString _realName,
+ TDEIO::filesize_t _total, TDEIO::filesize_t _free ) : TQWidget( parent ), totalSpace( _total ),
+ freeSpace( _free ), alias( _alias ), realName( _realName ), mounted( true ),
+empty( false ), supermount( false ) {
+ resize( 150, 200 );
+ show();
+}
+
+// Use this one for an unmounted filesystem
+KRFSDisplay::KRFSDisplay( TQWidget *parent, TQString _alias, TQString _realName, bool sm ) :
+ TQWidget( parent ), alias( _alias ), realName( _realName ), mounted( false ),
+empty( false ), supermount( sm ) {
+ resize( 150, 200 );
+ show();
+}
+
+// This is used only when an empty widget needs to be displayed (for example:
+// when filesystem statistics haven't been calculated yet)
+KRFSDisplay::KRFSDisplay( TQWidget *parent ) : TQWidget( parent ), empty( true ) {
+ resize( 150, 200 );
+ show();
+}
+
+
+// The main painter!
+void KRFSDisplay::paintEvent( TQPaintEvent * ) {
+ TQPainter paint( this );
+ if ( !empty ) {
+ // create the text
+ // first, name and location
+ paint.setFont( TQFont( "helvetica", 12, TQFont::Bold ) );
+ paint.drawText( 10, 20, alias );
+ paint.setFont( TQFont( "helvetica", 12, TQFont::Normal ) );
+ paint.drawText( 10, 37, "(" + realName + ")" );
+ if ( mounted ) { // incase the filesystem is already mounted
+ // second, the capacity
+ paint.drawText( 10, 70, i18n( "Capacity: " ) + TDEIO::convertSizeFromKB( totalSpace ) );
+ // third, the 2 boxes (used, free)
+ TQPen systemPen = paint.pen();
+ paint.setPen( TQt::black );
+ paint.drawRect( 10, 90, 10, 10 );
+ paint.fillRect( 11, 91, 8, 8, TQBrush( TQt::gray ) );
+ paint.drawRect( 10, 110, 10, 10 );
+ paint.fillRect( 11, 111, 8, 8, TQBrush( TQt::white ) );
+ // now, the text for the boxes
+ paint.setPen( systemPen );
+ paint.drawText( 25, 100, i18n( "Used: " ) + TDEIO::convertSizeFromKB( totalSpace - freeSpace ) );
+ paint.drawText( 25, 120, i18n( "Free: " ) + TDEIO::convertSizeFromKB( freeSpace ) );
+ // first, create the empty pie
+ // bottom...
+ paint.setPen( TQt::black );
+ paint.setBrush( TQt::white );
+ paint.drawPie( LEFT, BOTTOM, WIDTH, HEIGHT, STARTANGLE, DEG( 360 ) );
+ // body...
+ paint.setPen( TQt::lightGray );
+ for ( int i = 1; i < Z_HEIGHT; ++i )
+ paint.drawPie( LEFT, BOTTOM - i, WIDTH, HEIGHT, STARTANGLE, DEG( 360 ) );
+ // side lines...
+ paint.setPen( TQt::black );
+ paint.drawLine( LEFT, BOTTOM + HEIGHT / 2, LEFT, BOTTOM + HEIGHT / 2 - Z_HEIGHT );
+ paint.drawLine( LEFT + WIDTH, BOTTOM + HEIGHT / 2, LEFT + WIDTH, BOTTOM + HEIGHT / 2 - Z_HEIGHT );
+ // top of the pie
+ paint.drawPie( LEFT, BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, DEG( 360 ) );
+ // the "used space" slice
+ float i = ( ( float ) ( totalSpace - freeSpace ) / ( totalSpace ) ) * 360.0;
+ paint.setBrush( TQt::gray );
+ paint.drawPie( LEFT, BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, ( int ) DEG( i ) );
+ // if we need to draw a 3d stripe ...
+ if ( i > 180.0 ) {
+ for ( int j = 1; j < Z_HEIGHT; ++j )
+ paint.drawArc( LEFT, BOTTOM - j, WIDTH, HEIGHT, STARTANGLE - 16 * 180, ( int ) ( DEG( i - 180.0 ) ) );
+ }
+ } else { // if the filesystem is unmounted...
+ paint.setFont( TQFont( "helvetica", 12, TQFont::Bold ) );
+ paint.drawText( 10, 60, i18n( "Not mounted." ) );
+ }
+ } else { // if the widget is in empty situation...
+
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+KRPie::KRPie( TDEIO::filesize_t _totalSize, TQWidget *parent ) : TQWidget( parent, 0 ), totalSize( _totalSize ) {
+ slices.setAutoDelete( true ); // kill items when they are removed
+ slices.append( new KRPieSlice( 100, TQt::yellow, "DEFAULT" ) );
+ sizeLeft = totalSize;
+ resize( 300, 300 );
+}
+
+void KRPie::paintEvent( TQPaintEvent * ) {
+ TQPainter paint( this );
+ // now create the slices
+ KRPieSlice *slice;
+ float sAngle = STARTANGLE;
+ for ( slice = slices.first(); slice != 0; slice = slices.next() ) {
+ paint.setBrush( slice->getColor() );
+ paint.setPen( slice->getColor() );
+ // angles are negative to create a clock-wise drawing of slices
+ float angle = -( slice->getPerct() / 100 * 360 ) * 16;
+ for ( int i = 1; i < Z_HEIGHT; ++i )
+ paint.drawPie( LEFT, BOTTOM + i, WIDTH, HEIGHT, ( int ) sAngle, ( int ) angle );
+ sAngle += angle;
+ }
+ paint.setPen( TQt::yellow ); // pen
+ paint.setBrush( TQt::yellow ); // fill
+ // for (int i=1; i<Z_HEIGHT; ++i)
+ // paint.drawPie(LEFT,BOTTOM+i,WIDTH,HEIGHT,sAngle,360*16-(STARTANGLE-sAngle));
+ sAngle = STARTANGLE;
+ for ( slice = slices.first(); slice != 0; slice = slices.next() ) {
+ paint.setBrush( slice->getColor() );
+ paint.setPen( slice->getColor() );
+ // angles are negative to create a clock-wise drawing of slices
+ float angle = -( slice->getPerct() / 100 * 360 ) * 16;
+ paint.drawPie( LEFT, BOTTOM, WIDTH, HEIGHT, ( int ) sAngle, ( int ) angle );
+ sAngle += angle;
+ }
+
+
+ paint.setPen( TQt::black );
+ // the pie
+ // paint.drawPie(LEFT,BOTTOM,WIDTH,HEIGHT,STARTANGLE,360*16);
+ ///////////////////////// end of empty pie /////////////////////////
+ // now, the pie is ready to draw slices on...
+ // to make a good look on the perimiter, draw another black circle
+ paint.setPen( TQt::black );
+ paint.drawArc( LEFT, BOTTOM, WIDTH, HEIGHT, STARTANGLE, 360 * 16 );
+
+}
+
+void KRPie::addSlice( TDEIO::filesize_t size, TQString label ) {
+ int i = ( slices.count() % 12 );
+ slices.removeLast();
+ slices.append( new KRPieSlice( size * 100 / totalSize, colors[ i ], label ) );
+ sizeLeft -= size;
+ slices.append( new KRPieSlice( sizeLeft * 100 / totalSize, TQt::yellow, "DEFAULT" ) );
+}
+
+////////////////////////////////////////////////////
+/////////////////// KrQuickSearch /////////////////
+////////////////////////////////////////////////////
+KrQuickSearch::KrQuickSearch( TQWidget *parent, const char * name ) : KLineEdit( parent, name ) {}
+
+void KrQuickSearch::myKeyPressEvent( TQKeyEvent *e ) {
+ switch ( e->key() ) {
+ case Key_Escape:
+ emit stop( 0 );
+ break;
+ case Key_Return:
+ case Key_Enter:
+ case Key_Tab:
+ case Key_Right:
+ case Key_Left:
+ emit stop( e );
+ break;
+ case Key_Down:
+ otherMatching( text(), 1 );
+ break;
+ case Key_Up:
+ otherMatching( text(), -1 );
+ break;
+ case Key_Insert:
+ case Key_Home:
+ case Key_End:
+ process( e );
+ break;
+ default:
+ keyPressEvent( e );
+ }
+}
+
+
+
+#include "krspecialwidgets.moc"
diff --git a/src/app/Dialogs/krspecialwidgets.h b/src/app/Dialogs/krspecialwidgets.h
new file mode 100644
index 0000000..bcb8d0f
--- /dev/null
+++ b/src/app/Dialogs/krspecialwidgets.h
@@ -0,0 +1,129 @@
+/***************************************************************************
+ krspecialwidgets.h
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+---------------------------------------------------------------------------
+Description
+***************************************************************************
+
+A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ H e a d e r F i l e
+
+***************************************************************************
+* *
+* 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. *
+* *
+***************************************************************************/
+
+
+#ifndef KRSPECIALWIDGETS_H
+#define KRSPECIALWIDGETS_H
+
+#include <tqwidget.h>
+#include <tqpainter.h>
+#include <tqcolor.h>
+#include <tqptrlist.h>
+#include <klineedit.h>
+#include <tqevent.h>
+#include <tdeio/global.h>
+
+class KRPieSlice;
+
+class KRPie : public TQWidget {
+ TQ_OBJECT
+
+ public:
+ KRPie( TDEIO::filesize_t _totalSize, TQWidget *parent = 0 );
+ void addSlice( TDEIO::filesize_t size, TQString label );
+
+ protected:
+ void paintEvent( TQPaintEvent * );
+
+ private:
+ TQPtrList<KRPieSlice> slices;
+ TDEIO::filesize_t totalSize, sizeLeft;
+ static TQColor colors[ 12 ];
+};
+
+class KRFSDisplay : public TQWidget {
+ TQ_OBJECT
+
+ public:
+ // this constructor is used for a mounted filesystem
+ KRFSDisplay( TQWidget *parent, TQString _alias, TQString _realName,
+ TDEIO::filesize_t _total, TDEIO::filesize_t _free );
+ // this one is for an unmounted/supermount file system
+ KRFSDisplay( TQWidget *parent, TQString _alias, TQString _realName, bool sm = false );
+ // the last one is used inside MountMan(R), when no filesystem is selected
+ KRFSDisplay( TQWidget *parent );
+ inline void setTotalSpace( TDEIO::filesize_t t ) { totalSpace = t; }
+ inline void setFreeSpace( TDEIO::filesize_t t ) { freeSpace = t; }
+ inline void setAlias( TQString a ) { alias = a; }
+ inline void setRealName( TQString r ) { realName = r; }
+ inline void setMounted( bool m ) { mounted = m; }
+ inline void setEmpty( bool e ) { empty = e; }
+ inline void setSupermount( bool s ) { supermount = s; }
+
+ protected:
+ void paintEvent( TQPaintEvent * );
+
+ private:
+ TDEIO::filesize_t totalSpace, freeSpace;
+ TQString alias, realName;
+ bool mounted, empty, supermount;
+};
+
+class KRPieSlice {
+ public:
+ KRPieSlice( float _perct, TQColor _color, TQString _label ) :
+ perct( _perct ), color( _color ), label( _label ) {}
+ inline TQColor getColor() { return color; }
+ inline float getPerct() { return perct; }
+ inline TQString getLabel() { return label; }
+ inline void setPerct( float _perct ) { perct = _perct; }
+ inline void setLabel( TQString _label ) { label = _label; }
+
+ private:
+ float perct;
+ TQColor color;
+ TQString label;
+};
+
+class KrQuickSearch: public KLineEdit {
+ TQ_OBJECT
+
+ public:
+ KrQuickSearch(TQWidget *parent, const char * name = 0);
+ void addText(const TQString &str) { setText(text()+str); }
+ void myKeyPressEvent(TQKeyEvent *e);
+ void myIMStartEvent(TQIMEvent* e) {
+ imStartEvent(e);
+ }
+ void myIMEndEvent(TQIMEvent* e) {
+ imEndEvent(e);
+ }
+ void myIMComposeEvent(TQIMEvent* e) {
+ imComposeEvent(e);
+ }
+
+ signals:
+ void stop(TQKeyEvent *e);
+ void process(TQKeyEvent *e);
+ void otherMatching(const TQString &, int);
+
+};
+
+#endif
diff --git a/src/app/Dialogs/krspwidgets.cpp b/src/app/Dialogs/krspwidgets.cpp
new file mode 100644
index 0000000..b0fcf5d
--- /dev/null
+++ b/src/app/Dialogs/krspwidgets.cpp
@@ -0,0 +1,316 @@
+/***************************************************************************
+ krspwidgets.cpp
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ S o u r c e F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "krspwidgets.h"
+#include "../krusader.h"
+#include "../krusaderview.h"
+#include "../Panel/listpanel.h"
+#include "../kicons.h"
+#include "../Filter/filtertabs.h"
+#include <tqcombobox.h>
+#include <tqlabel.h>
+#include <tqlineedit.h>
+#include <tqcheckbox.h>
+#include <tqlistbox.h>
+#include <tqspinbox.h>
+#include <tdelocale.h>
+#include <kcombobox.h>
+#include <kiconloader.h>
+#include <kcursor.h>
+#include <tqbitmap.h>
+#include "../resources.h"
+
+///////////////////// initiation of the static members ////////////////////////
+TQStrList KRSpWidgets::maskList;
+
+///////////////////////////////////////////////////////////////////////////////
+
+KRSpWidgets::KRSpWidgets(){
+}
+
+KRQuery KRSpWidgets::getMask(TQString caption, bool nameOnly ) {
+ if( !nameOnly ) {
+ return FilterTabs::getQuery();
+ }
+ else {
+ KRMaskChoiceSub *p=new KRMaskChoiceSub();
+ p->setCaption(caption);
+ p->exec();
+ if (p->selection->currentText()=="") return KRQuery();
+ else return KRQuery( p->selection->currentText() );
+ }
+}
+
+/////////////////////////// newFTP ////////////////////////////////////////
+KURL KRSpWidgets::newFTP() {
+ newFTPSub *p=new newFTPSub();
+ p->exec();
+ if (p->url->currentText()=="") return KURL(); // empty url
+ KURL url;
+
+ TQString protocol = p->prefix->currentText();
+ protocol.truncate(protocol.length() - 3); // remove the trailing ://
+ TQString username = p->username->text().simplifyWhiteSpace();
+ TQString password = p->password->text().simplifyWhiteSpace();
+ TQString uri = p->url->currentText();
+
+ int uriStart = uri.findRev( '@' ); /* lets the user enter user and password in the URI field */
+ if( uriStart != -1 ) {
+ TQString uriUser = uri.left( uriStart );
+ TQString uriPsw = TQString();
+ uri = uri.mid( uriStart + 1 );
+
+ int pswStart = uriUser.find( ':' ); /* getting the password name from the URL */
+ if( pswStart != -1 ) {
+ uriPsw = uriUser.mid( pswStart + 1 );
+ uriUser = uriUser.left( pswStart );
+ }
+
+ if( !uriUser.isEmpty() ) /* handling the ftp proxy username and password also */
+ username = username.isEmpty() ? uriUser : username + "@" + uriUser;
+
+ if( !uriPsw.isEmpty() ) /* handling the ftp proxy username and password also */
+ password = password.isEmpty() ? uriPsw : password + "@" + uriPsw;
+ }
+
+ TQString host = uri; /* separating the hostname and path from the uri */
+ TQString path = TQString();
+ int pathStart = uri.find( "/" );
+ if( pathStart != -1 ) {
+ path = host.mid( pathStart );
+ host = host.left( pathStart );
+ }
+
+ /* setting the parameters of the URL */
+ url.setProtocol(protocol);
+ url.setHost( host );
+ url.setPath( path );
+ if ( protocol == "ftp" || protocol == "fish" || protocol == "sftp" )
+ url.setPort(p->port->cleanText().toInt());
+ if (!username.isEmpty())
+ url.setUser( username );
+ if (!password.isEmpty())
+ url.setPass( password );
+
+ return url;
+}
+
+newFTPSub::newFTPSub() : newFTPGUI(0,0,true) {
+ url->setFocus();
+ setGeometry(krApp->x()+krApp->width()/2-width()/2,krApp->y()+krApp->height()/2-height()/2,width(),height());
+}
+
+void newFTPSub::accept() {
+ url->addToHistory( url->currentText() );
+ // save the history and completion list when the history combo is
+ // destroyed
+ krConfig->setGroup("Private");
+ TQStringList list = url->completionObject()->items();
+ krConfig->writeEntry( "newFTP Completion list", list );
+ list = url->historyItems();
+ krConfig->writeEntry( "newFTP History list", list );
+
+ newFTPGUI::accept();
+}
+
+void newFTPSub::reject() {
+ url->setCurrentText("");
+ newFTPGUI::reject();
+}
+
+/////////////////////////// KRMaskChoiceSub ///////////////////////////////
+KRMaskChoiceSub::KRMaskChoiceSub() : KRMaskChoice(0,0,true) {
+ PixmapLabel1->setPixmap(krLoader->loadIcon("kr_select", TDEIcon::Desktop, 32));
+ label->setText(i18n("Enter a selection:"));
+ // the predefined selections list
+ krConfig->setGroup("Private");
+ TQStrList lst;
+ int i=krConfig->readListEntry("Predefined Selections",lst);
+ if (i>0) preSelections->insertStrList(lst);
+ // the combo-box tweaks
+ selection->setDuplicatesEnabled(false);
+ selection->insertStrList(KRSpWidgets::maskList);
+ selection->lineEdit()->setText("*");
+ selection->lineEdit()->selectAll();
+ selection->setFocus();
+}
+
+void KRMaskChoiceSub::reject() {
+ selection->clear();
+ KRMaskChoice::reject();
+}
+
+void KRMaskChoiceSub::accept() {
+ bool add = true;
+ char *tmp;
+ // make sure we don't have that already
+ for ( tmp = KRSpWidgets::maskList.first(); tmp ; tmp = KRSpWidgets::maskList.next() )
+ if (TQString(tmp).simplifyWhiteSpace() == selection->currentText().simplifyWhiteSpace()) {
+ // break if we found one such as this
+ add = false;
+ break;
+ }
+
+ if (add)
+ KRSpWidgets::maskList.insert(0,selection->currentText().local8Bit());
+ // write down the predefined selections list
+ TQStrList list;
+ TQListBoxItem *i=preSelections->firstItem();
+ while (i!=0) {
+ if (i->text().find(i18n("compare mode"))==-1)
+ list.append(i->text().local8Bit());
+ i=i->next();
+ }
+ krConfig->setGroup("Private");
+ krConfig->writeEntry("Predefined Selections",list);
+ KRMaskChoice::accept();
+}
+
+void KRMaskChoiceSub::addSelection() {
+ TQString temp=selection->currentText();
+ bool itemExists=false;
+ TQListBoxItem *i=preSelections->firstItem();
+ // check if the selection already exists
+ while (i!=0)
+ if (i->text()==temp) {
+ itemExists=true;
+ break;
+ } else i=i->next();
+ if (temp!="" && !itemExists) {
+ preSelections->insertItem(selection->currentText());
+ preSelections->update();
+ }
+}
+
+void KRMaskChoiceSub::deleteSelection() {
+ if (preSelections->currentItem()!=-1 &&
+ preSelections->currentText().find(i18n("compare mode"))==-1) {
+ preSelections->removeItem(preSelections->currentItem());
+ preSelections->update();
+ }
+}
+
+void KRMaskChoiceSub::clearSelections() {
+ preSelections->clear();
+ preSelections->update();
+}
+
+void KRMaskChoiceSub::acceptFromList(TQListBoxItem *i) {
+ selection->insertItem(i->text(),0);
+ accept();
+}
+
+////////////////////////// QuickNavLineEdit ////////////////////
+
+QuickNavLineEdit::QuickNavLineEdit(const TQString &string, TQWidget *parent, const char *name):
+ KLineEdit(string, parent, name) { init(); }
+
+QuickNavLineEdit::QuickNavLineEdit(TQWidget *parent, const char *name):
+ KLineEdit(parent, name) { init(); }
+
+int QuickNavLineEdit::findCharFromPos(const TQString & str, const TQFontMetrics & metrics, int pos)
+{
+ if (pos < 0)
+ return -1;
+ for (int i = 1; i <= (int)str.length(); ++i)
+ if (metrics.width(str, i) > pos)
+ return i;
+ return str.length();
+}
+
+void QuickNavLineEdit::init() {
+ _numOfSelectedChars=0;
+ _dummyDisplayed=false;
+ _pop=0;
+ //setCompletionMode( TDEGlobalSettings::CompletionPopupAuto ); ==> removed by public demand
+}
+
+void QuickNavLineEdit::leaveEvent(TQEvent *) {
+ clearAll();
+}
+
+void QuickNavLineEdit::mousePressEvent( TQMouseEvent *m ) {
+ if (m->state()!=ControlButton) clearAll();
+ else
+ {
+ if (!_numOfSelectedChars)
+ {
+ _numOfSelectedChars = charCount(m);
+ if (_numOfSelectedChars < 0)
+ _numOfSelectedChars = 0;
+ }
+ if (_numOfSelectedChars)
+ emit returnPressed(text().left(_numOfSelectedChars));
+ }
+ KLineEdit::mousePressEvent(m);
+}
+
+int QuickNavLineEdit::charCount(const TQMouseEvent * const m,TQString * const str) {
+ // find how much of the string we've selected (approx)
+ // and select from from the start to the closet slash (on the right)
+ const TQString tx = text().simplifyWhiteSpace();
+ if (tx.isEmpty()) {
+ clearAll();
+ return -1;
+ }
+
+ int numOfChars = findCharFromPos(tx, fontMetrics(), m->x() - 5);
+ if(str) *str=tx;
+ return tx.find('/', numOfChars);
+}
+
+void QuickNavLineEdit::mouseMoveEvent( TQMouseEvent *m) {
+ if (m->state()!=ControlButton) { // works only with ctrl pressed
+ clearAll();
+ KLineEdit::mouseMoveEvent(m);
+ return;
+ }
+ TQString tx;
+ int idx=charCount(m,&tx);
+ if (idx == -1 && !_dummyDisplayed) { // pointing on or after the current directory
+ if (_pop) delete _pop;
+ _pop = KPassivePopup::message( i18n("Quick Navigation"),
+ "<qt>" + i18n("Already at <i>%1</i>").arg(tx.left(idx)) + "</qt>",
+ *(KCursor::handCursor().bitmap()), this);
+
+ _dummyDisplayed=true;
+ _numOfSelectedChars=0;
+ } else if (idx>0 && idx!=_numOfSelectedChars) {
+ _numOfSelectedChars=idx;
+ if (_pop) delete _pop;
+ _dummyDisplayed=false;
+
+ _pop = KPassivePopup::message( i18n("Quick Navigation"),
+ "<qt>" + i18n("Click to go to <i>%1</i>").arg(tx.left(idx)) + "</qt>",
+ *(KCursor::handCursor().bitmap()), this );
+ }
+ KLineEdit::mouseMoveEvent(m);
+}
+
diff --git a/src/app/Dialogs/krspwidgets.h b/src/app/Dialogs/krspwidgets.h
new file mode 100644
index 0000000..13098dc
--- /dev/null
+++ b/src/app/Dialogs/krspwidgets.h
@@ -0,0 +1,110 @@
+/***************************************************************************
+ krspwidgets.h
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ H e a d e r F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef KRSPWIDGETS_H
+#define KRSPWIDGETS_H
+
+#include <tqstrlist.h>
+#include <kurl.h>
+#include "krmaskchoice.h"
+#include "newftpgui.h"
+#include "../VFS/krquery.h"
+#include <klineedit.h>
+#include <kpassivepopup.h>
+
+class newFTPGUI;
+
+class KRMaskChoiceSub;
+
+class KRSpWidgets {
+ friend class KRMaskChoiceSub;
+
+public:
+ KRSpWidgets();
+
+ static KRQuery getMask( TQString caption, bool nameOnly=false ); // get file-mask for (un)selecting files
+ static KURL newFTP();
+
+private:
+ static TQStrList maskList; // used by KRMaskChoiceSub
+};
+
+/////////////////////////// newFTPSub ///////////////////////////////////////
+class newFTPSub : public newFTPGUI {
+public:
+ newFTPSub();
+
+protected:
+ void reject();
+ void accept();
+};
+
+/////////////////////////// KRMaskChoiceSub /////////////////////////////////
+// Inherits KRMaskChoice's generated code to fully implement the functions //
+/////////////////////////////////////////////////////////////////////////////
+class KRMaskChoiceSub : public KRMaskChoice {
+public:
+ KRMaskChoiceSub();
+
+public slots:
+ void addSelection();
+ void deleteSelection();
+ void clearSelections();
+ void acceptFromList(TQListBoxItem *i);
+
+protected:
+ void reject();
+ void accept();
+};
+
+/////////////////////////// QuickNavLineEdit //////////////////////////
+// same as line edit, but hold ctrl while pointing to it... and see! //
+///////////////////////////////////////////////////////////////////////
+
+class QuickNavLineEdit: public KLineEdit {
+public:
+ QuickNavLineEdit(const TQString &string, TQWidget *parent, const char *name=0);
+ QuickNavLineEdit(TQWidget *parent=0, const char *name=0);
+ virtual ~QuickNavLineEdit() {}
+ static int findCharFromPos(const TQString &, const TQFontMetrics &, int pos);
+protected:
+ void mouseMoveEvent( TQMouseEvent *m);
+ void leaveEvent( TQEvent * );
+ void mousePressEvent( TQMouseEvent *m );
+ inline void clearAll() { _numOfSelectedChars = 0; if (_pop) delete _pop; _dummyDisplayed=false; }
+ void init();
+
+private:
+ int charCount(const TQMouseEvent * const , TQString* const =0) ;
+ int _numOfSelectedChars;
+ bool _dummyDisplayed;
+ TQGuardedPtr<KPassivePopup> _pop;
+};
+
+#endif
diff --git a/src/app/Dialogs/krsqueezedtextlabel.cpp b/src/app/Dialogs/krsqueezedtextlabel.cpp
new file mode 100644
index 0000000..7a5ef8d
--- /dev/null
+++ b/src/app/Dialogs/krsqueezedtextlabel.cpp
@@ -0,0 +1,80 @@
+#include "krsqueezedtextlabel.h"
+#include <kstringhandler.h>
+#include <kurldrag.h>
+#include <tqtooltip.h>
+
+KrSqueezedTextLabel::KrSqueezedTextLabel(TQWidget *parent, const char *name):
+ KSqueezedTextLabel(parent, name), acceptDrops( false ), _index(-1), _length(-1) {
+}
+
+
+KrSqueezedTextLabel::~KrSqueezedTextLabel() {
+}
+
+void KrSqueezedTextLabel::mousePressEvent(TQMouseEvent *) {
+ emit clicked();
+
+}
+
+void KrSqueezedTextLabel::enableDrops( bool flag )
+{
+ setAcceptDrops( acceptDrops = flag );
+}
+
+void KrSqueezedTextLabel::dropEvent(TQDropEvent *e) {
+ emit dropped(e);
+}
+
+void KrSqueezedTextLabel::dragEnterEvent(TQDragEnterEvent *e) {
+ if( acceptDrops )
+ e->accept( KURLDrag::canDecode( e ) );
+ else
+ KSqueezedTextLabel::dragEnterEvent( e );
+}
+
+void KrSqueezedTextLabel::squeezeTextToLabel(int index, int length) {
+ if (index==-1 || length==-1)
+ KSqueezedTextLabel::squeezeTextToLabel();
+ else {
+ TQString sqtext=fullText;
+ TQFontMetrics fm(fontMetrics());
+ int labelWidth = size().width();
+ int textWidth = fm.width(sqtext);
+ if (textWidth > labelWidth) {
+ int avgCharSize = textWidth / sqtext.length();
+ int numOfExtraChars = (textWidth-labelWidth)/avgCharSize;
+ int delta;
+
+ // remove as much as possible from the left, and then from the right
+ if (index>3) {
+ delta=TQMIN(index, numOfExtraChars);
+ numOfExtraChars -= delta;
+ sqtext.replace(0, delta, "...");
+ }
+
+ if (numOfExtraChars>0 && ((int)sqtext.length() > length+3)) {
+ delta = TQMIN(numOfExtraChars, (int)sqtext.length() - (length+3));
+ sqtext.replace(sqtext.length()-delta, delta, "...");
+ }
+ TQLabel::setText(sqtext);
+
+ TQToolTip::remove( this );
+ TQToolTip::add( this, fullText );
+ } else {
+ TQLabel::setText(fullText);
+
+ TQToolTip::remove( this );
+ TQToolTip::hide();
+ }
+ }
+}
+
+void KrSqueezedTextLabel::setText( const TQString &text, int index, int length ) {
+ _index=index;
+ _length=length;
+ fullText = text;
+ squeezeTextToLabel(_index,_length);
+}
+
+#include "krsqueezedtextlabel.moc"
+
diff --git a/src/app/Dialogs/krsqueezedtextlabel.h b/src/app/Dialogs/krsqueezedtextlabel.h
new file mode 100644
index 0000000..320953f
--- /dev/null
+++ b/src/app/Dialogs/krsqueezedtextlabel.h
@@ -0,0 +1,45 @@
+#ifndef KRSQUEEZEDTEXTLABEL_H
+#define KRSQUEEZEDTEXTLABEL_H
+
+#include <ksqueezedtextlabel.h>
+
+class TQMouseEvent;
+class TQDropEvent;
+class TQDragEnterEvent;
+
+/**
+This class overloads KSqueezedTextLabel and simply adds a clicked signal,
+so that users will be able to click the label and switch focus between panels.
+
+NEW: a special setText() method allows to choose which part of the string should
+ be displayed (example: make sure that search results won't be cut out)
+*/
+class KrSqueezedTextLabel : public KSqueezedTextLabel {
+TQ_OBJECT
+
+ public:
+ KrSqueezedTextLabel(TQWidget *parent = 0, const char *name = 0);
+ ~KrSqueezedTextLabel();
+
+ void enableDrops( bool flag );
+
+ public slots:
+ void setText( const TQString &text, int index=-1, int length=-1 );
+
+ signals:
+ void clicked(); /**< emitted when someone clicks on the label */
+ void dropped(TQDropEvent *); /**< emitted when someone drops URL onto the label */
+
+ protected:
+ void resizeEvent( TQResizeEvent * ) { squeezeTextToLabel(_index, _length); }
+ virtual void mousePressEvent(TQMouseEvent *e);
+ virtual void dropEvent(TQDropEvent *e);
+ virtual void dragEnterEvent(TQDragEnterEvent *e);
+ void squeezeTextToLabel(int index=-1, int length=-1);
+
+ private:
+ bool acceptDrops;
+ int _index, _length;
+};
+
+#endif
diff --git a/src/app/Dialogs/kurllistrequester.cpp b/src/app/Dialogs/kurllistrequester.cpp
new file mode 100644
index 0000000..449da8f
--- /dev/null
+++ b/src/app/Dialogs/kurllistrequester.cpp
@@ -0,0 +1,202 @@
+/***************************************************************************
+ kurllistrequester.cpp - description
+ -------------------
+ copyright : (C) 2005 by Csaba Karai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ S o u r c e F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "kurllistrequester.h"
+#include "../VFS/vfs.h"
+#include <tqpixmap.h>
+#include <tqcursor.h>
+#include <tqlayout.h>
+#include <tdefiledialog.h>
+#include <tdepopupmenu.h>
+#include <kiconloader.h>
+#include <tdelocale.h>
+#include <tdemessagebox.h>
+
+#define DELETE_ITEM_ID 100
+
+KURLListRequester::KURLListRequester( TQWidget *parent, const char * name ) : TQWidget( parent, name )
+{
+ TDEIconLoader *iconLoader = new TDEIconLoader();
+ TQPixmap imageAdd = iconLoader->loadIcon( "1downarrow", TDEIcon::Panel, 16 );
+ TQPixmap imageFolder = iconLoader->loadIcon( "folder", TDEIcon::Panel, 16 );
+
+ // Creating the widget
+
+ TQGridLayout *urlListRequesterGrid = new TQGridLayout( this );
+ urlListRequesterGrid->setSpacing( 0 );
+ urlListRequesterGrid->setMargin( 0 );
+
+ urlLineEdit = new KLineEdit( this, "urlLineEdit" );
+ urlListRequesterGrid->addWidget( urlLineEdit, 0, 0 );
+
+ urlListBox = new TQListBox( this, "urlListBox" );
+ urlListBox->setSelectionMode( TQListBox::Extended );
+ urlListRequesterGrid->addMultiCellWidget( urlListBox, 1, 1, 0, 2 );
+
+ urlAddBtn = new TQToolButton( this, "urlAddBtn" );
+ urlAddBtn->setText( "" );
+ urlAddBtn->setPixmap( imageAdd );
+ urlListRequesterGrid->addWidget( urlAddBtn, 0, 1 );
+
+ urlBrowseBtn = new TQToolButton( this, "urlBrowseBtn" );
+ urlBrowseBtn->setText( "" );
+ urlBrowseBtn->setPixmap( imageFolder );
+ urlListRequesterGrid->addWidget( urlBrowseBtn, 0, 2 );
+
+ // add shell completion
+
+ completion.setMode( KURLCompletion::FileCompletion );
+ urlLineEdit->setCompletionObject( &completion );
+
+ // connection table
+
+ connect( urlAddBtn, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotAdd() ) );
+ connect( urlBrowseBtn, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotBrowse() ) );
+ connect( urlLineEdit, TQ_SIGNAL( returnPressed(const TQString&) ), this, TQ_SLOT( slotAdd() ) );
+ connect( urlListBox, TQ_SIGNAL( rightButtonClicked ( TQListBoxItem *, const TQPoint & ) ), this,
+ TQ_SLOT( slotRightClicked( TQListBoxItem * ) ) );
+}
+
+void KURLListRequester::slotAdd()
+{
+ TQString text = urlLineEdit->text().simplifyWhiteSpace();
+ if( text.length() )
+ {
+ TQString error = TQString();
+ emit checkValidity( text, error );
+
+ if( !error.isNull() )
+ KMessageBox::error( this, error );
+ else
+ {
+ urlListBox->insertItem( text );
+ urlLineEdit->clear();
+ }
+ }
+}
+
+void KURLListRequester::slotBrowse()
+{
+ KURL url = KFileDialog::getExistingURL( TQString(), this );
+ if( !url.isEmpty())
+ urlLineEdit->setText( vfs::pathOrURL( url ) );
+ urlLineEdit->setFocus();
+}
+
+void KURLListRequester::keyPressEvent(TQKeyEvent *e)
+{
+ if( e->key() == Key_Delete )
+ {
+ if( urlListBox->hasFocus() )
+ {
+ deleteSelectedItems();
+ return;
+ }
+ }
+
+ TQWidget::keyPressEvent( e );
+}
+
+void KURLListRequester::deleteSelectedItems()
+{
+ int i=0;
+ TQListBoxItem *item;
+
+ while( (item = urlListBox->item(i)) )
+ {
+ if( item->isSelected() )
+ {
+ urlListBox->removeItem( i );
+ continue;
+ }
+ i++;
+ }
+}
+
+void KURLListRequester::slotRightClicked( TQListBoxItem *item )
+{
+ if( item == 0 )
+ return;
+
+ TDEPopupMenu popupMenu( this );
+ popupMenu.insertItem( i18n( "Delete" ), DELETE_ITEM_ID );
+
+ switch( popupMenu.exec( TQCursor::pos() ) )
+ {
+ case DELETE_ITEM_ID:
+ if( item->isSelected() )
+ deleteSelectedItems();
+ else
+ urlListBox->removeItem( urlListBox->index( item ) );
+ break;
+ }
+}
+
+KURL::List KURLListRequester::urlList()
+{
+ KURL::List urls;
+
+ TQString text = urlLineEdit->text().simplifyWhiteSpace();
+ if (!text.isEmpty())
+ {
+ TQString error = TQString();
+ emit checkValidity( text, error );
+ if( error.isNull() )
+ urls.append( vfs::fromPathOrURL( text ) );
+ }
+
+ TQListBoxItem *item = urlListBox->firstItem();
+ while ( item )
+ {
+ TQString text = item->text().simplifyWhiteSpace();
+
+ TQString error = TQString();
+ emit checkValidity( text, error );
+ if( error.isNull() )
+ urls.append( vfs::fromPathOrURL( text ) );
+
+ item = item->next();
+ }
+
+ return urls;
+}
+
+void KURLListRequester::setUrlList( KURL::List urlList )
+{
+ urlLineEdit->clear();
+ urlListBox->clear();
+
+ KURL::List::iterator it;
+
+ for ( it = urlList.begin(); it != urlList.end(); ++it )
+ urlListBox->insertItem( vfs::pathOrURL(*it) );
+}
+
+#include "kurllistrequester.moc"
diff --git a/src/app/Dialogs/kurllistrequester.h b/src/app/Dialogs/kurllistrequester.h
new file mode 100644
index 0000000..8c49611
--- /dev/null
+++ b/src/app/Dialogs/kurllistrequester.h
@@ -0,0 +1,77 @@
+/***************************************************************************
+ kurllistrequester.h - description
+ -------------------
+ copyright : (C) 2005 by Csaba Karai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ H e a d e r F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef __KURLLISTREQUESTER_H__
+#define __KURLLISTREQUESTER_H__
+
+#include <tqwidget.h>
+#include <tqlistbox.h>
+#include <tqtoolbutton.h>
+#include <klineedit.h>
+#include <kurl.h>
+#include <kurlcompletion.h>
+
+class KURLListRequester : public TQWidget
+{
+ TQ_OBJECT
+
+
+public:
+ KURLListRequester( TQWidget *parent = 0, const char * name = 0 );
+
+ KURL::List urlList();
+ void setUrlList( KURL::List );
+
+ KLineEdit *lineEdit() {return urlLineEdit;}
+ TQListBox *listBox() {return urlListBox;}
+
+ void setCompletionDir( TQString dir ) { completion.setDir( dir ); }
+
+signals:
+ void checkValidity( TQString &text, TQString &error );
+
+protected slots:
+ void slotAdd();
+ void slotBrowse();
+ void slotRightClicked( TQListBoxItem * );
+
+protected:
+ virtual void keyPressEvent(TQKeyEvent *e);
+ void deleteSelectedItems();
+
+ KLineEdit *urlLineEdit;
+ TQListBox *urlListBox;
+ TQToolButton *urlAddBtn;
+ TQToolButton *urlBrowseBtn;
+
+ KURLCompletion completion;
+};
+
+#endif /* __KURLLISTREQUESTER_H__ */
diff --git a/src/app/Dialogs/newftpgui.cpp b/src/app/Dialogs/newftpgui.cpp
new file mode 100644
index 0000000..56eef7c
--- /dev/null
+++ b/src/app/Dialogs/newftpgui.cpp
@@ -0,0 +1,182 @@
+/****************************************************************************
+** Form implementation generated from reading ui file 'newftpgui.ui'
+**
+** Created: Fri Oct 27 23:47:10 2000
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+#include "newftpgui.h"
+
+#include <tqlabel.h>
+#include <tqlineedit.h>
+#include <tqpushbutton.h>
+#include <tqspinbox.h>
+#include <tqlayout.h>
+#include <tqhbox.h>
+#include <tqgrid.h>
+#include <tqvariant.h>
+#include <tqtooltip.h>
+#include <tqwhatsthis.h>
+#include <tqimage.h>
+#include <tqpixmap.h>
+#include <tdelocale.h>
+#include <kprotocolinfo.h>
+#include <kcombobox.h>
+#include <kiconloader.h>
+#include "../krusader.h"
+
+
+/*
+ * Constructs a newFTPGUI which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * true to construct a modal dialog.
+ */
+
+ #define SIZE_MINIMUM TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0 )
+
+newFTPGUI::newFTPGUI( TQWidget* parent, const char* name, bool modal, WFlags fl )
+ : TQDialog( parent, name, modal, fl ){
+
+ TQVBoxLayout * layout = new TQVBoxLayout( this, 11, 6, "newFTPGUI_layout" );
+ layout->setAutoAdd(true);
+
+ if ( !name )
+ setName( "newFTPGUI" );
+ resize( 342, 261 );
+ setCaption( i18n( "New Network Connection" ) );
+// setSizeGripEnabled( true );
+ setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)5, (TQSizePolicy::SizeType)5, sizePolicy().hasHeightForWidth() ) );
+ setMinimumSize( TQSize( 342, 261 ) );
+
+
+ TQHBox* hbox_image = new TQHBox( this, "hbox_image" );
+ hbox_image->setSpacing( 6 );
+
+ PixmapLabel1 = new TQLabel( hbox_image, "PixmapLabel1" );
+ PixmapLabel1->setPixmap( krLoader->loadIcon("network", TDEIcon::Desktop, 32) );
+ PixmapLabel1->setSizePolicy( SIZE_MINIMUM );
+
+ TextLabel3 = new TQLabel( i18n( "About to connect to..." ), hbox_image, "TextLabel3" );
+ TQFont TextLabel3_font( TextLabel3->font() );
+ TextLabel3_font.setBold( true );
+ TextLabel3->setFont( TextLabel3_font );
+
+
+ TQGrid* grid_host = new TQGrid( 3, this, "grid_host" );
+
+ TextLabel1 = new TQLabel( i18n( "Protocol:" ), grid_host, "TextLabel1" );
+ TextLabel1_22 = new TQLabel( i18n( "Host:"), grid_host, "TextLabel_2" );
+ TextLabel1_3 = new TQLabel( i18n( "Port:" ), grid_host, "TextLabel1_3" );
+
+ TQStringList protocols = KProtocolInfo::protocols();
+
+ prefix = new KComboBox( false, grid_host, "protocol" );
+ if( protocols.contains("ftp") )
+ prefix->insertItem( i18n( "ftp://" ) );
+ if( protocols.contains("smb") )
+ prefix->insertItem( i18n( "smb://" ) );
+ if( protocols.contains("fish") )
+ prefix->insertItem( i18n( "fish://" ));
+ if( protocols.contains("sftp") )
+ prefix->insertItem( i18n( "sftp://" ));
+ prefix->setAcceptDrops( false );
+ prefix->setEnabled( true );
+ prefix->setSizePolicy( SIZE_MINIMUM );
+ connect( prefix,TQ_SIGNAL(activated(const TQString& )),
+ this,TQ_SLOT(slotTextChanged(const TQString& )));
+
+ url = new KHistoryCombo( grid_host, "url" );
+ url->setMaximumHeight( 20 );
+ url->setMaxCount( 25 );
+ url->setDuplicatesEnabled( false );
+ connect( url, TQ_SIGNAL( activated( const TQString& )),
+ url, TQ_SLOT( addToHistory( const TQString& )));
+ // load the history and completion list after creating the history combo
+ krConfig->setGroup("Private");
+ TQStringList list = krConfig->readListEntry( "newFTP Completion list" );
+ url->completionObject()->setItems( list );
+ list = krConfig->readListEntry( "newFTP History list" );
+ url->setHistoryItems( list );
+
+ port = new TQSpinBox( grid_host, "port" );
+ port->setMaxValue( 65535 );
+ port->setValue( 21 );
+ port->setSizePolicy( SIZE_MINIMUM );
+
+
+ TextLabel1_2 = new TQLabel( i18n( "Username:" ), this, "TextLabel1_2" );
+ username = new TQLineEdit( this, "username" );
+ TextLabel1_2_2 = new TQLabel( i18n( "Password:" ), this, "TextLabel1_2_2" );
+ password = new TQLineEdit( this, "password" );
+ password->setEchoMode( TQLineEdit::Password );
+
+
+ TQWidget* Layout6 = new TQWidget( this, "Layout6" );
+ hbox = new TQHBoxLayout( Layout6 );
+ hbox->setSpacing( 6 );
+ hbox->setMargin( 0 );
+
+ hbox->addItem(new TQSpacerItem(1,1,TQSizePolicy::Expanding));
+
+ connectBtn = new TQPushButton( i18n( "&Connect" ), Layout6, "connectBtn" );
+ connectBtn->setAutoDefault( true );
+ connectBtn->setDefault( true );
+ hbox->addWidget( connectBtn );
+
+ //saveBtn = new TQPushButton( i18n( "&Save" ), Layout6, "saveBtn" );
+ //saveBtn->setAutoDefault( true );
+ //hbox->addWidget( saveBtn );
+
+ cancelBtn = new TQPushButton( i18n( "&Cancel" ), Layout6, "cancelBtn" );
+ cancelBtn->setAutoDefault( true );
+ hbox->addWidget( cancelBtn );
+
+ // signals and slots connections
+ connect( connectBtn, TQ_SIGNAL( clicked() ), this, TQ_SLOT( accept() ) );
+ connect( cancelBtn, TQ_SIGNAL( clicked() ), this, TQ_SLOT( reject() ) );
+
+ // tab order
+ setTabOrder( url, username );
+ setTabOrder( username, password );
+ setTabOrder( password, connectBtn );
+ setTabOrder( connectBtn, cancelBtn );
+ setTabOrder( cancelBtn, prefix );
+ setTabOrder( prefix, url );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+newFTPGUI::~newFTPGUI(){
+ // no need to delete child widgets, TQt does it all for us
+}
+
+void newFTPGUI::slotTextChanged(const TQString& string){
+ if( string.startsWith("ftp") || string.startsWith("sftp") || string.startsWith("fish") )
+ {
+ if( port->value() == 21 || port->value() == 22 )
+ port->setValue( string.startsWith("ftp") ? 21 : 22 );
+ port->setEnabled(true);
+ }
+ else
+ port->setEnabled(false);
+}
+
+/*
+ * Main event handler. Reimplemented to handle application
+ * font changes
+ */
+bool newFTPGUI::event( TQEvent* ev ) {
+ bool ret = TQDialog::event( ev );
+ if ( ev->type() == TQEvent::ApplicationFontChange ) {
+ TQFont TextLabel3_font( TextLabel3->font() );
+ TextLabel3_font.setBold( true );
+ TextLabel3->setFont( TextLabel3_font );
+ }
+ return ret;
+}
+
+#include "newftpgui.moc"
diff --git a/src/app/Dialogs/newftpgui.h b/src/app/Dialogs/newftpgui.h
new file mode 100644
index 0000000..d3808e5
--- /dev/null
+++ b/src/app/Dialogs/newftpgui.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+** Form interface generated from reading ui file 'newftpgui.ui'
+**
+** Created: Fri Oct 27 23:47:08 2000
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+#ifndef NEWFTPGUI_H
+#define NEWFTPGUI_H
+
+#include <tqvariant.h>
+#include <tqdialog.h>
+class TQVBoxLayout;
+class TQHBoxLayout;
+class TQGridLayout;
+class TQLabel;
+class TQLineEdit;
+class TQPushButton;
+class TQSpinBox;
+class KComboBox;
+class KHistoryCombo;
+
+class newFTPGUI : public TQDialog {
+ TQ_OBJECT
+
+public:
+ newFTPGUI( TQWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
+ ~newFTPGUI();
+
+ TQLabel* TextLabel1;
+ KComboBox* prefix;
+ TQLabel* TextLabel1_2_2;
+ TQLabel* TextLabel1_22;
+ TQLabel* TextLabel1_2;
+ TQLabel* TextLabel1_3;
+ TQSpinBox* port;
+ TQLineEdit* password;
+ TQPushButton* connectBtn;
+ TQPushButton* saveBtn;
+ TQPushButton* cancelBtn;
+ TQLabel* PixmapLabel1;
+ TQLabel* TextLabel3;
+ TQLineEdit* username;
+ KHistoryCombo* url;
+
+public slots:
+ void slotTextChanged(const TQString& string);
+
+protected:
+ TQHBoxLayout* hbox;
+ bool event( TQEvent* );
+};
+
+#endif // NEWFTPGUI_H
diff --git a/src/app/Dialogs/packgui.cpp b/src/app/Dialogs/packgui.cpp
new file mode 100644
index 0000000..e479060
--- /dev/null
+++ b/src/app/Dialogs/packgui.cpp
@@ -0,0 +1,122 @@
+/***************************************************************************
+ packgui.cpp
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ S o u r c e F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "packgui.h"
+#include <tdefiledialog.h>
+#include "../krusader.h"
+#include "../defaults.h"
+#include <tqlineedit.h>
+#include <tqcheckbox.h>
+#include <tqstringlist.h>
+#include <tqlabel.h>
+#include <tqpushbutton.h>
+
+#define PS(x) lst.contains(x)>0
+
+// clear the statics first
+TQString PackGUI::filename=0;
+TQString PackGUI::destination=0;
+TQString PackGUI::type=0;
+TQMap<TQString, TQString> PackGUI::extraProps;
+
+PackGUI::PackGUI(TQString defaultName, TQString defaultPath, int noOfFiles, TQString filename) :
+ PackGUIBase(0,0,true) {
+ // first, fill the WhatToPack textfield with information
+ if(noOfFiles == 1)
+ TextLabel1->setText( i18n("Pack %1").arg(filename) );
+ else
+ TextLabel1->setText( i18n("Pack %n file", "Pack %n files", noOfFiles) );
+
+ // now, according to the Konfigurator, fill the combobox with the information
+ // about what kind of packing we can do
+ krConfig->setGroup("Archives");
+ TQStringList lst=krConfig->readListEntry("Supported Packers");
+ // now, clear the type combo and begin...
+ typeData->clear();
+ if (PS("tar")) typeData->insertItem("tar");
+ if (PS("tar") && PS("gzip")) typeData->insertItem("tar.gz");
+ if (PS("tar") && PS("bzip2")) typeData->insertItem("tar.bz2");
+ if (PS("tar") && PS("xz")) typeData->insertItem("tar.xz");
+ if (PS("zip")) typeData->insertItem("zip");
+ if (PS("rar")) typeData->insertItem("rar");
+ if (PS("lha")) typeData->insertItem("lha");
+ if (PS("arj")) typeData->insertItem("arj");
+ if (PS("7z")) typeData->insertItem("7z");
+ if (PS("xz")) typeData->insertItem("xz");
+ // set the last used packer as the top one
+ TQString tmp=krConfig->readEntry("lastUsedPacker",TQString());
+ if (tmp!=TQString()) {
+ for (unsigned int i=0; i< typeData->listBox()->count(); ++i)
+ if (typeData->listBox()->item(i)->text() == tmp) {
+ typeData->listBox()->removeItem(i);
+ typeData->listBox()->insertItem(tmp,0);
+ break;
+ }
+ }
+ checkConsistency();
+
+ // and go on with the normal stuff
+ dirData->setText(defaultPath);
+ nameData->setText(defaultName);
+ nameData->setFocus();
+ if (typeData->listBox()->count()==0) // if no packers are availble
+ okButton->setEnabled(false);
+ setGeometry(krApp->x()+krApp->width()/2-width()/2,krApp->y()+krApp->height()/2-height()/2,width(),height());
+ exec();
+}
+
+void PackGUI::browse() {
+ TQString temp=KFileDialog::getExistingDirectory(dirData->text(),0,i18n("Please select a directory"));
+ if (temp != TQString())
+ dirData->setText(temp);
+}
+
+void PackGUI::accept() {
+ if( !extraProperties( extraProps ) )
+ return;
+
+ filename=nameData->text();
+ destination=dirData->text();
+ type=typeData->currentText();
+ // write down the packer chosen, to be lastUsedPacker
+ krConfig->setGroup("Archives");
+ krConfig->writeEntry("lastUsedPacker",type);
+ krConfig->sync();
+ PackGUIBase::accept();
+}
+
+void PackGUI::reject() {
+ filename=TQString();
+ destination=TQString();
+ type=TQString();
+ PackGUIBase::reject();
+}
+
+#include "packgui.moc"
diff --git a/src/app/Dialogs/packgui.h b/src/app/Dialogs/packgui.h
new file mode 100644
index 0000000..2601b25
--- /dev/null
+++ b/src/app/Dialogs/packgui.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ packgui.h
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ H e a d e r F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef PACKGUI_H
+#define PACKGUI_H
+
+#include "packguibase.h"
+
+class PackGUI : public PackGUIBase {
+ TQ_OBJECT
+
+public:
+ PackGUI(TQString defaultName, TQString defaultPath, int noOfFiles, TQString filename="");
+
+public slots:
+ void browse();
+
+protected slots:
+ void accept();
+ void reject();
+
+public:
+ static TQString filename, destination, type;
+ static TQMap<TQString, TQString> extraProps;
+};
+
+#endif
diff --git a/src/app/Dialogs/packguibase.cpp b/src/app/Dialogs/packguibase.cpp
new file mode 100644
index 0000000..1d66cd4
--- /dev/null
+++ b/src/app/Dialogs/packguibase.cpp
@@ -0,0 +1,468 @@
+/***************************************************************************
+ packguibase.cpp
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ S o u r c e F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#include "packguibase.h"
+
+#include <tqcheckbox.h>
+#include <tqcombobox.h>
+#include <tqlabel.h>
+#include <tqlineedit.h>
+#include <tqpushbutton.h>
+#include <tqtoolbutton.h>
+#include <tqlayout.h>
+#include <tqvariant.h>
+#include <tqtooltip.h>
+#include <tqwhatsthis.h>
+#include <tqimage.h>
+#include <tqpixmap.h>
+#include <tqspinbox.h>
+#include <tqslider.h>
+#include <tqhbox.h>
+#include <tqvbox.h>
+#include <kiconloader.h>
+#include <tdeglobalsettings.h>
+#include <kcombobox.h>
+#include <tdemessagebox.h>
+#include <tdeio/global.h>
+#include "../krusader.h"
+
+/*
+ * Constructs a PackGUIBase which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * true to construct a modal dialog.
+ */
+PackGUIBase::PackGUIBase( TQWidget* parent, const char* name, bool modal, WFlags fl )
+ : TQDialog( parent, name, modal, fl ), expanded( false )
+{
+ if ( !name )
+ setName( "PackGUIBase" );
+ resize( 430, 140 );
+ setCaption( i18n( "Pack" ) );
+ grid = new TQGridLayout( this );
+ grid->setSpacing( 6 );
+ grid->setMargin( 11 );
+
+ hbox = new TQHBoxLayout;
+ hbox->setSpacing( 6 );
+ hbox->setMargin( 0 );
+
+ TextLabel3 = new TQLabel( this, "TextLabel3" );
+ TextLabel3->setText( i18n( "To archive" ) );
+ hbox->addWidget( TextLabel3 );
+
+ nameData = new TQLineEdit( this, "nameData" );
+ hbox->addWidget( nameData );
+
+ typeData = new TQComboBox( false, this, "typeData" );
+ typeData->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1, (TQSizePolicy::SizeType)0 ) );
+ connect( typeData, TQ_SIGNAL( activated( const TQString & ) ), this, TQ_SLOT( checkConsistency() ) );
+ connect( typeData, TQ_SIGNAL( highlighted( const TQString & ) ), this, TQ_SLOT( checkConsistency() ) );
+ hbox->addWidget( typeData );
+
+ grid->addLayout( hbox, 1, 0 );
+
+ hbox_2 = new TQHBoxLayout;
+ hbox_2->setSpacing( 6 );
+ hbox_2->setMargin( 0 );
+
+ TextLabel5 = new TQLabel( this, "TextLabel5" );
+ TextLabel5->setText( i18n( "In directory" ) );
+ hbox_2->addWidget( TextLabel5 );
+
+ dirData = new TQLineEdit( this, "dirData" );
+ hbox_2->addWidget( dirData );
+
+ browseButton = new TQToolButton( this, "browseButton" );
+ browseButton->setIconSet( SmallIcon( "document-open" ) );
+ hbox_2->addWidget( browseButton );
+ TQSpacerItem* spacer = new TQSpacerItem( 48, 20, TQSizePolicy::Fixed, TQSizePolicy::Fixed );
+ hbox_2->addItem( spacer );
+
+ grid->addLayout( hbox_2, 2, 0 );
+
+ hbox_3 = new TQHBoxLayout;
+ hbox_3->setSpacing( 6 );
+ hbox_3->setMargin( 0 );
+
+ PixmapLabel1 = new TQLabel( this, "PixmapLabel1" );
+ PixmapLabel1->setPixmap( krLoader->loadIcon("package", TDEIcon::Desktop, 32) );
+ PixmapLabel1->setScaledContents( true );
+ PixmapLabel1->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)0, (TQSizePolicy::SizeType)0 ) );
+ hbox_3->addWidget( PixmapLabel1 );
+
+ TextLabel1 = new TQLabel( this, "TextLabel1" );
+ TextLabel1->setText( i18n( "Pack" ) );
+ hbox_3->addWidget( TextLabel1 );
+
+ grid->addLayout( hbox_3, 0, 0 );
+
+
+ hbox_4 = new TQHBoxLayout;
+ hbox_4->setSpacing( 6 );
+ hbox_4->setMargin( 0 );
+
+ TQSpacerItem* spacer_3 = new TQSpacerItem( 20, 26, TQSizePolicy::Fixed, TQSizePolicy::Expanding );
+ hbox_4->addItem( spacer_3 );
+ grid->addLayout( hbox_4, 3, 0 );
+
+ advancedWidget = new TQWidget( this, "advancedWidget" );
+
+ hbox_5 = new TQGridLayout( advancedWidget );
+ hbox_5->setSpacing( 6 );
+ hbox_5->setMargin( 0 );
+
+
+ TQVBoxLayout *compressLayout = new TQVBoxLayout;
+ compressLayout->setSpacing( 6 );
+ compressLayout->setMargin( 0 );
+
+ multipleVolume = new TQCheckBox( i18n( "Multiple volume archive" ), advancedWidget, "multipleVolume" );
+ connect( multipleVolume, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( checkConsistency() ) );
+ compressLayout->addWidget( multipleVolume, 0, 0 );
+
+ TQHBoxLayout * volumeHbox = new TQHBoxLayout;
+
+ TQSpacerItem* spacer_5 = new TQSpacerItem( 20, 26, TQSizePolicy::Fixed, TQSizePolicy::Fixed );
+ volumeHbox->addItem( spacer_5 );
+
+ TextLabel7 = new TQLabel( i18n("Size:" ), advancedWidget, "TextLabel7" );
+ volumeHbox->addWidget( TextLabel7 );
+
+ volumeSpinBox = new TQSpinBox( advancedWidget, "volumeSpinBox" );
+ volumeSpinBox->setMinValue( 1 );
+ volumeSpinBox->setMaxValue( 9999 );
+ volumeSpinBox->setValue( 1440 );
+ volumeHbox->addWidget( volumeSpinBox );
+
+ volumeUnitCombo = new TQComboBox( false, advancedWidget, "volumeUnitCombo" );
+ volumeUnitCombo->insertItem( "B" );
+ volumeUnitCombo->insertItem( "KB" );
+ volumeUnitCombo->insertItem( "MB" );
+ volumeUnitCombo->setCurrentItem( 1 );
+ volumeHbox->addWidget( volumeUnitCombo );
+
+ compressLayout->addLayout ( volumeHbox );
+
+ setCompressionLevel = new TQCheckBox( i18n( "Set compression level" ), advancedWidget, "multipleVolume" );
+ connect( setCompressionLevel, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( checkConsistency() ) );
+ compressLayout->addWidget( setCompressionLevel, 0, 0 );
+
+ TQHBoxLayout * sliderHbox = new TQHBoxLayout;
+
+ TQSpacerItem* spacer_6 = new TQSpacerItem( 20, 26, TQSizePolicy::Fixed, TQSizePolicy::Fixed );
+ sliderHbox->addItem( spacer_6 );
+
+ TQVBox * sliderVBox = new TQVBox( advancedWidget );
+
+ compressionSlider = new TQSlider( 1, 9, 1, 5, TQt::Horizontal, sliderVBox, "compressionSlider" );
+ compressionSlider->setTickmarks( TQSlider::Below );
+
+ TQHBox * minmaxHBox = new TQHBox( sliderVBox );
+ minLabel = new TQLabel( i18n("MIN"), minmaxHBox );
+ maxLabel = new TQLabel( i18n("MAX"), minmaxHBox );
+ maxLabel->setSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed );
+
+ sliderHbox->addWidget( sliderVBox );
+
+ compressLayout->addLayout( sliderHbox );
+
+ compressLayout->addStretch( 0 );
+ hbox_5->addLayout( compressLayout, 0, 0 );
+
+ TQFrame *vline = new TQFrame( advancedWidget, "vline" );
+ vline->setFrameStyle( TQFrame::VLine | TQFrame::Sunken );
+ vline->setMinimumWidth( 20 );
+ hbox_5->addWidget( vline, 0, 1 );
+
+
+ TQGridLayout * passwordGrid = new TQGridLayout;
+ passwordGrid->setSpacing( 6 );
+ passwordGrid->setMargin( 0 );
+
+ TextLabel4 = new TQLabel( advancedWidget, "TextLabel4" );
+ TextLabel4->setText( i18n( "Password" ) );
+ passwordGrid->addWidget( TextLabel4, 0, 0 );
+
+ password = new TQLineEdit( advancedWidget, "password" );
+ password->setEchoMode( TQLineEdit::Password );
+ connect( password, TQ_SIGNAL( textChanged ( const TQString & ) ), this, TQ_SLOT( checkConsistency() ) );
+
+ passwordGrid->addWidget( password, 0, 1 );
+
+ TextLabel6 = new TQLabel( advancedWidget, "TextLabel6" );
+ TextLabel6->setText( i18n( "Again" ) );
+ passwordGrid->addWidget( TextLabel6, 1, 0 );
+
+ passwordAgain = new TQLineEdit( advancedWidget, "password" );
+ passwordAgain->setEchoMode( TQLineEdit::Password );
+ connect( passwordAgain, TQ_SIGNAL( textChanged ( const TQString & ) ), this, TQ_SLOT( checkConsistency() ) );
+
+ passwordGrid->addWidget( passwordAgain, 1, 1 );
+
+ TQHBoxLayout *consistencyHbox = new TQHBoxLayout;
+
+ TQSpacerItem* spacer_cons = new TQSpacerItem( 48, 20, TQSizePolicy::Expanding, TQSizePolicy::Fixed );
+ consistencyHbox->addItem( spacer_cons );
+
+ passwordConsistencyLabel = new TQLabel( advancedWidget, "passwordConsistencyLabel" );
+ consistencyHbox->addWidget( passwordConsistencyLabel );
+ passwordGrid->addMultiCellLayout ( consistencyHbox, 2, 2, 0, 1 );
+
+ encryptHeaders = new TQCheckBox( i18n( "Encrypt headers" ), advancedWidget, "encryptHeaders" );
+ passwordGrid->addMultiCellWidget ( encryptHeaders, 3, 3, 0, 1 );
+
+ TQSpacerItem* spacer_psw = new TQSpacerItem( 20, 20, TQSizePolicy::Fixed, TQSizePolicy::Expanding );
+ passwordGrid->addItem( spacer_psw, 4, 0 );
+
+ hbox_5->addLayout( passwordGrid, 0, 2 );
+
+ hbox_7 = new TQHBoxLayout;
+ hbox_7->setSpacing( 6 );
+ hbox_7->setMargin( 0 );
+
+ TextLabel8 = new TQLabel( i18n( "Command line switches:" ), advancedWidget, "TextLabel8" );
+ TextLabel8->setSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed );
+ hbox_7->addWidget( TextLabel8 );
+
+ commandLineSwitches = new KHistoryCombo( advancedWidget, "commandLineSwitches" );
+ commandLineSwitches->setMaxCount(25); // remember 25 items
+ commandLineSwitches->setDuplicatesEnabled(false);
+ krConfig->setGroup("Archives");
+ TQStringList list = krConfig->readListEntry("Command Line Switches");
+ commandLineSwitches->setHistoryItems(list);
+
+ hbox_7->addWidget( commandLineSwitches );
+
+ hbox_5->addMultiCellLayout( hbox_7, 1, 1, 0, 2 );
+
+
+ advancedWidget->hide();
+ checkConsistency();
+
+ grid->addWidget( advancedWidget, 4, 0 );
+
+ hbox_6 = new TQHBoxLayout;
+ hbox_6->setSpacing( 6 );
+ hbox_6->setMargin( 0 );
+
+ advancedButton = new TQPushButton( this, "advancedButton" );
+ advancedButton->setText( i18n( "&Advanced" ) + " >>" );
+ hbox_6->addWidget( advancedButton );
+
+ TQSpacerItem* spacer_2 = new TQSpacerItem( 140, 20, TQSizePolicy::Expanding, TQSizePolicy::Fixed );
+ hbox_6->addItem( spacer_2 );
+
+ okButton = new TQPushButton( this, "okButton" );
+ okButton->setText( i18n( "Ok" ) );
+ okButton->setDefault( true );
+ hbox_6->addWidget( okButton );
+
+ cancelButton = new TQPushButton( this, "cancelButton" );
+ cancelButton->setText( i18n( "Cancel" ) );
+ hbox_6->addWidget( cancelButton );
+
+ grid->addLayout( hbox_6, 6, 0 );
+
+ // signals and slots connections
+ connect( okButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( accept() ) );
+ connect( advancedButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( expand() ) );
+ connect( cancelButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( reject() ) );
+ connect( browseButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( browse() ) );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+PackGUIBase::~PackGUIBase()
+{
+ // no need to delete child widgets, TQt does it all for us
+}
+
+void PackGUIBase::browse()
+{
+ tqWarning( "PackGUIBase::browse(): Not implemented yet!" );
+}
+
+void PackGUIBase::expand() {
+ expanded = !expanded;
+
+ advancedButton->setText( i18n( "&Advanced" ) + ( expanded ? " <<" : " >>" ) );
+
+ if( expanded )
+ advancedWidget->show();
+ else {
+ advancedWidget->hide();
+ layout()->activate();
+ TQSize minSize = minimumSize();
+ resize( width(), minSize.height() );
+ }
+ show();
+}
+
+void PackGUIBase::checkConsistency() {
+ if( password->text().isEmpty() && passwordAgain->text().isEmpty()) {
+ passwordConsistencyLabel->setPaletteForegroundColor( TDEGlobalSettings::textColor() );
+ passwordConsistencyLabel->setText( i18n( "No password specified" ) );
+ }
+ else
+ if( password->text() == passwordAgain->text() ) {
+ passwordConsistencyLabel->setPaletteForegroundColor( TDEGlobalSettings::textColor() );
+ passwordConsistencyLabel->setText( i18n( "The passwords are equal" ) );
+ }
+ else {
+ passwordConsistencyLabel->setPaletteForegroundColor( TQt::red );
+ passwordConsistencyLabel->setText( i18n( "The passwords are different" ) );
+ }
+
+ TQString packer = typeData->currentText();
+
+ bool passworded = false;
+ if( packer == "7z" || packer == "rar" || packer == "zip" || packer == "arj" )
+ passworded = true;
+
+ passwordConsistencyLabel->setEnabled( passworded );
+ password->setEnabled( passworded );
+ passwordAgain->setEnabled( passworded );
+ TextLabel4->setEnabled( passworded );
+ TextLabel6->setEnabled( passworded );
+
+ encryptHeaders->setEnabled( packer == "rar" );
+
+ multipleVolume->setEnabled( packer == "rar" || packer == "arj" );
+ bool volumeEnabled = multipleVolume->isEnabled() && multipleVolume->isChecked();
+ volumeSpinBox->setEnabled( volumeEnabled );
+ volumeUnitCombo->setEnabled( volumeEnabled );
+ TextLabel7->setEnabled( volumeEnabled );
+
+ /* TODO */
+ setCompressionLevel->setEnabled( packer == "rar" || packer == "arj" || packer == "zip" ||
+ packer == "7z" );
+ bool sliderEnabled = setCompressionLevel->isEnabled() && setCompressionLevel->isChecked();
+ compressionSlider->setEnabled( sliderEnabled );
+ minLabel->setEnabled( sliderEnabled );
+ maxLabel->setEnabled( sliderEnabled );
+}
+
+bool PackGUIBase::extraProperties( TQMap<TQString,TQString> & inMap ) {
+ inMap.clear();
+
+ if( password->isEnabled() && passwordAgain->isEnabled() ) {
+ if( password->text() != passwordAgain->text() ) {
+ KMessageBox::error( this, i18n( "Cannot pack! The passwords are different!" ) );
+ return false;
+ }
+
+ if( !password->text().isEmpty() ) {
+ inMap[ "Password" ] = password->text();
+
+ if( encryptHeaders->isEnabled() && encryptHeaders->isChecked() )
+ inMap[ "EncryptHeaders" ] = "1";
+ }
+ }
+
+ if( multipleVolume->isEnabled() && multipleVolume->isChecked() ) {
+ TDEIO::filesize_t size = volumeSpinBox->value();
+
+ switch( volumeUnitCombo->currentItem() ) {
+ case 2:
+ size *= 1000;
+ case 1:
+ size *= 1000;
+ default:
+ break;
+ }
+
+ if( size < 10000 ) {
+ KMessageBox::error( this, i18n( "Invalid volume size!" ) );
+ return false;
+ }
+
+ TQString sbuffer;
+ sbuffer.sprintf("%llu",size);
+
+ inMap[ "VolumeSize" ] = sbuffer;
+ }
+
+ if( setCompressionLevel->isEnabled() && setCompressionLevel->isChecked() ) {
+ inMap[ "CompressionLevel" ] = TQString("%1").arg( compressionSlider->value() );
+ }
+
+ TQString cmdArgs = commandLineSwitches->currentText().stripWhiteSpace();
+ if( !cmdArgs.isEmpty() ) {
+ bool firstChar = true;
+ TQChar quote = '\0';
+
+ for( unsigned i=0; i < cmdArgs.length(); i++ ) {
+ TQChar ch( cmdArgs[ i ] );
+ if( ch.isSpace() )
+ continue;
+
+ if( ch == quote ) {
+ quote = '\0';
+ continue;
+ }
+
+ if( firstChar && ch != '-' ) {
+ KMessageBox::error( this, i18n( "Invalid command line switch!\nSwitch must start with '-'!" ) );
+ return false;
+ }
+
+ firstChar = false;
+
+ if( quote == '"' )
+ continue;
+ if( quote == '\0' && ( ch == '\'' || ch == '"' ) )
+ quote = ch;
+ if( ch == '\\' ) {
+ if( i == cmdArgs.length() - 1 ) {
+ KMessageBox::error( this, i18n( "Invalid command line switch!\nBackslash cannot be the last character" ) );
+ return false;
+ }
+ i++;
+ }
+ }
+
+ if( quote != '\0' ) {
+ KMessageBox::error( this, i18n( "Invalid command line switch!\nUnclosed quotation mark!" ) );
+ return false;
+ }
+
+ commandLineSwitches->addToHistory( cmdArgs );
+ TQStringList list = commandLineSwitches->historyItems();
+ krConfig->setGroup("Archives");
+ krConfig->writeEntry("Command Line Switches", list);
+
+ inMap[ "CommandLineSwitches" ] = cmdArgs;
+ }
+ return true;
+}
+
+#include "packguibase.moc"
diff --git a/src/app/Dialogs/packguibase.h b/src/app/Dialogs/packguibase.h
new file mode 100644
index 0000000..202f67f
--- /dev/null
+++ b/src/app/Dialogs/packguibase.h
@@ -0,0 +1,110 @@
+/***************************************************************************
+ packguibase.h
+ -------------------
+ copyright : (C) 2000 by Shie Erlich & Rafi Yanai
+ email : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ H e a d e r F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef PACKGUIBASE_H
+#define PACKGUIBASE_H
+
+#include <tdelocale.h>
+#include <tqdialog.h>
+#include <tqmap.h>
+
+
+class TQVBoxLayout;
+class TQHBoxLayout;
+class TQGridLayout;
+class TQCheckBox;
+class TQComboBox;
+class TQLabel;
+class TQLineEdit;
+class TQPushButton;
+class TQToolButton;
+class TQSpinBox;
+class TQSlider;
+class KHistoryCombo;
+
+class PackGUIBase : public TQDialog
+{
+ TQ_OBJECT
+
+
+public:
+ PackGUIBase( TQWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
+ ~PackGUIBase();
+
+ TQLabel* TextLabel3;
+ TQLineEdit* nameData;
+ TQComboBox* typeData;
+ TQLabel* TextLabel5;
+ TQLineEdit* dirData;
+ TQToolButton* browseButton;
+ TQWidget* advancedWidget;
+ TQLabel* PixmapLabel1;
+ TQLabel* TextLabel1;
+ TQLabel* TextLabel4;
+ TQLabel* TextLabel6;
+ TQLabel* TextLabel7;
+ TQLabel* TextLabel8;
+ TQLabel* minLabel;
+ TQLabel* maxLabel;
+ TQLineEdit* password;
+ TQLineEdit* passwordAgain;
+ TQLabel* passwordConsistencyLabel;
+ TQPushButton* okButton;
+ TQPushButton* cancelButton;
+ TQPushButton* advancedButton;
+ TQCheckBox* encryptHeaders;
+ TQCheckBox* multipleVolume;
+ TQSpinBox* volumeSpinBox;
+ TQComboBox* volumeUnitCombo;
+ TQCheckBox* setCompressionLevel;
+ TQSlider* compressionSlider;
+ KHistoryCombo *commandLineSwitches;
+
+public slots:
+ virtual void browse();
+ virtual bool extraProperties( TQMap<TQString,TQString> & );
+
+ void expand();
+ void checkConsistency();
+
+protected:
+ TQHBoxLayout* hbox;
+ TQHBoxLayout* hbox_2;
+ TQHBoxLayout* hbox_3;
+ TQHBoxLayout* hbox_4;
+ TQGridLayout* hbox_5;
+ TQHBoxLayout* hbox_6;
+ TQHBoxLayout* hbox_7;
+ TQGridLayout* grid;
+
+private:
+ bool expanded;
+};
+
+#endif // PACKGUIBASE_H
diff --git a/src/app/Dialogs/percentalsplitter.cpp b/src/app/Dialogs/percentalsplitter.cpp
new file mode 100644
index 0000000..4aefc41
--- /dev/null
+++ b/src/app/Dialogs/percentalsplitter.cpp
@@ -0,0 +1,193 @@
+/***************************************************************************
+ percentalsplitter.h - description
+ -------------------
+ copyright : (C) 2006 + by Csaba Karai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ H e a d e r F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "percentalsplitter.h"
+#include <tqtooltip.h>
+#include <tqpainter.h>
+#include <tqapplication.h>
+
+class PercentalSplitterToolTip : public TQToolTip {
+public:
+ PercentalSplitterToolTip( TQWidget * parent ) : TQToolTip( parent ) {
+ }
+
+ virtual ~PercentalSplitterToolTip() {
+ remove( parentWidget() );
+ }
+
+ void maybeTip( const TQPoint & point ) {
+ if( parentWidget()->inherits( "PercentalSplitter" ) ) {
+ PercentalSplitter *splitter = (PercentalSplitter *)parentWidget();
+
+ TQString tipString = splitter->toolTipString();
+ TQRect rect = TQRect( parentWidget()->rect() );
+
+ if( splitter->orientation() == TQt::Vertical ) {
+ rect.setY( splitter->sizes()[ 0 ] );
+ rect.setHeight( splitter->handleWidth() );
+ }
+ else {
+ rect.setX( splitter->sizes()[ 0 ] );
+ rect.setWidth( splitter->handleWidth() );
+ }
+ if( rect.contains( point ) )
+ tip( rect, tipString );
+ }
+ }
+};
+
+PercentalSplitter::PercentalSplitter( TQWidget * parent, const char * name ) : TQSplitter( parent, name ), label( 0 ), opaqueOldPos( -1 ) {
+ toolTip = new PercentalSplitterToolTip( this );
+}
+
+PercentalSplitter::~PercentalSplitter() {
+ delete toolTip;
+}
+
+TQString PercentalSplitter::toolTipString( int p ) {
+ TQValueList<int> values = sizes();
+ if( values.count() == 2 && ( values[ 0 ] + values[ 1 ] != 0 ) ) {
+ if( p < 0 )
+ p = values[ 0 ];
+ int percent = (int)(((double)p / (double)( values[ 0 ] + values[ 1 ] )) * 10000. + 0.5);
+ return TQString( "%1.%2%3" ).arg( percent / 100 ).arg( ( percent / 10 )%10 ).arg( percent % 10 ) + "%";
+ }
+ return TQString();
+}
+
+void PercentalSplitter::setRubberband ( int p ) {
+ if( p == opaqueOldPos )
+ return;
+
+ TQPainter paint( this );
+ paint.setPen( gray );
+ paint.setBrush( gray );
+ paint.setRasterOp( XorROP );
+ TQRect r = contentsRect();
+ const int rBord = 3; // customizable?
+ int hw = handleWidth();
+
+ if( orientation() == TQt::Horizontal ) {
+ if ( opaqueOldPos >= 0 ) {
+ if( label == 0 )
+ paint.drawRect( opaqueOldPos + hw / 2 - rBord, r.y(), 2 * rBord, r.height() );
+ else {
+ TQPoint labelLoc = mapFromGlobal( labelLocation );
+ if( labelLoc.y() > r.y() )
+ paint.drawRect( opaqueOldPos + hw / 2 - rBord, r.y(), 2 * rBord, labelLoc.y() );
+ if( labelLoc.y() + label->height() < r.height() )
+ paint.drawRect( opaqueOldPos + hw / 2 - rBord, labelLoc.y() + label->height(), 2 * rBord, r.height() - labelLoc.y() - label->height() );
+ }
+ }
+ } else {
+ if ( opaqueOldPos >= 0 ) {
+ if( label == 0 )
+ paint.drawRect( r.x(), opaqueOldPos + hw / 2 - rBord, r.width(), 2 * rBord );
+ else {
+ TQPoint labelLoc = mapFromGlobal( labelLocation );
+ if( labelLoc.x() > r.x() )
+ paint.drawRect( r.x(), opaqueOldPos + hw / 2 - rBord, labelLoc.x(), 2 * rBord );
+ if( labelLoc.x() + label->width() < r.width() )
+ paint.drawRect( labelLoc.x() + label->width(), opaqueOldPos + hw / 2 - rBord, r.width() - labelLoc.x() - label->width(), 2 * rBord );
+ }
+ }
+ }
+
+ if( p < 0 ) {
+ if( label ) {
+ delete label;
+ label = 0;
+ }
+ }
+ else {
+ int scr = TQApplication::desktop()->screenNumber( this );
+
+ if( label == 0 ) {
+ label = new TQLabel( TQApplication::desktop()->screen( scr ), "SplitterPercent", WStyle_StaysOnTop |
+ WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WX11BypassWM );
+ label->setMargin(1);
+ label->setAutoMask( false );
+ label->setFrameStyle( TQFrame::Plain | TQFrame::Box );
+ label->setLineWidth( 1 );
+ label->setAlignment( AlignAuto | AlignTop );
+ label->setIndent(0);
+
+ TQFontMetrics fm = label->fontMetrics();
+ label->setMinimumWidth( fm.width( "99.99%" ) + 5 );
+
+ label->polish();
+ }
+
+ label->setText( toolTipString( p ) );
+ label->adjustSize();
+
+ if( orientation() == TQt::Horizontal ) {
+ labelLocation = mapToGlobal( TQPoint( p - label->width()/2, r.y() + r.height()/2 ) );
+ if( labelLocation.x() < 0 )
+ labelLocation.setX( 0 );
+ } else {
+ labelLocation = mapToGlobal( TQPoint( r.x() + r.width()/2, p - label->height()/2 ) );
+ if( labelLocation.y() < 0 )
+ labelLocation.setY( 0 );
+ }
+
+#ifdef TQ_WS_MAC
+ TQRect screen = TQApplication::desktop()->availableGeometry( scr );
+#else
+ TQRect screen = TQApplication::desktop()->screenGeometry( scr );
+#endif
+
+ TQPoint labelLoc = mapFromGlobal( labelLocation );
+ if( orientation() == TQt::Horizontal ) {
+ if( labelLocation.x() + label->width() > screen.width() )
+ labelLocation.setX( screen.width() - label->width() );
+ label->move( labelLocation );
+ label->show();
+
+ if( labelLoc.y() > r.y() )
+ paint.drawRect( p + hw / 2 - rBord, r.y(), 2 * rBord, labelLoc.y() );
+ if( labelLoc.y() + label->height() < r.height() )
+ paint.drawRect( p + hw / 2 - rBord, labelLoc.y() + label->height(), 2 * rBord, r.height() - labelLoc.y() - label->height() );
+ } else {
+ if( labelLocation.y() + label->height() > screen.height() )
+ labelLocation.setY( screen.height() - label->height() );
+ label->move( labelLocation );
+ label->show();
+
+ if( labelLoc.x() > r.x() )
+ paint.drawRect( r.x(), p + hw / 2 - rBord, labelLoc.x(), 2 * rBord );
+ if( labelLoc.x() + label->width() < r.width() )
+ paint.drawRect( labelLoc.x() + label->width(), p + hw / 2 - rBord, r.width() - labelLoc.x() - label->width(), 2 * rBord );
+ }
+ }
+ opaqueOldPos = p;
+}
+
+#include "percentalsplitter.moc"
diff --git a/src/app/Dialogs/percentalsplitter.h b/src/app/Dialogs/percentalsplitter.h
new file mode 100644
index 0000000..414f133
--- /dev/null
+++ b/src/app/Dialogs/percentalsplitter.h
@@ -0,0 +1,59 @@
+/***************************************************************************
+ percentalsplitter.h - description
+ -------------------
+ copyright : (C) 2006 + by Csaba Karai
+ e-mail : krusader@users.sourceforge.net
+ web site : http://krusader.sourceforge.net
+ ---------------------------------------------------------------------------
+ Description
+ ***************************************************************************
+
+ A
+
+ db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b.
+ 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D
+ 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY'
+ 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b
+ 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88.
+ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
+
+ H e a d e r F i l e
+
+ ***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef __PERCENTAL_SPLITTER__
+#define __PERCENTAL_SPLITTER__
+
+#include <tqsplitter.h>
+#include <tqlabel.h>
+
+class PercentalSplitterToolTip;
+
+class PercentalSplitter : public TQSplitter {
+ TQ_OBJECT
+
+
+public:
+ PercentalSplitter( TQWidget * parent = 0, const char * name = 0 );
+ virtual ~PercentalSplitter();
+
+ TQString toolTipString( int p = -1 );
+
+protected:
+ virtual void setRubberband ( int p );
+
+private:
+ PercentalSplitterToolTip * toolTip;
+ TQLabel * label;
+ int opaqueOldPos;
+ TQPoint labelLocation;
+};
+
+#endif /* __PERCENTAL_SPLITTER__ */
diff --git a/src/app/Dialogs/popularurls.cpp b/src/app/Dialogs/popularurls.cpp
new file mode 100644
index 0000000..9fe2184
--- /dev/null
+++ b/src/app/Dialogs/popularurls.cpp
@@ -0,0 +1,307 @@
+#include <tdemessagebox.h>
+#include <tdelocale.h>
+#include <tqpushbutton.h>
+#include <tdelistview.h>
+#include <kiconloader.h>
+#include <tdelistviewsearchline.h>
+#include <tqheader.h>
+#include <tqlayout.h>
+#include <tqlabel.h>
+#include <tdetoolbarbutton.h>
+#include "../krusader.h"
+#include "../krslots.h"
+#include "popularurls.h"
+
+#define STARTING_RANK 20
+#define INCREASE 2
+#define DECREASE 1
+
+PopularUrls::PopularUrls(TQObject *parent, const char *name) : TQObject(parent, name),
+ head(0), tail(0), count(0) {
+ dlg = new PopularUrlsDlg();
+}
+
+PopularUrls::~PopularUrls() {
+ clearList();
+ delete dlg;
+}
+
+void PopularUrls::clearList() {
+ if (head) {
+ UrlNodeP p=head, tmp;
+ while (p) {
+ tmp = p;
+ p=p->next;
+ delete tmp;
+ }
+ }
+ ranks.clear();
+ head = tail = 0;
+}
+
+void PopularUrls::save() {
+ TDEConfigGroupSaver svr(krConfig, "Private");
+ // prepare the string list containing urls and int list with ranks
+ TQStringList urlList;
+ TQValueList<int> rankList;
+ UrlNodeP p = head;
+ while (p) {
+ urlList << p->url.prettyURL();
+ rankList << p->rank;
+ p = p->next;
+ }
+ krConfig->writeEntry("PopularUrls", urlList);
+ krConfig->writeEntry("PopularUrlsRank", rankList);
+}
+
+void PopularUrls::load() {
+ TDEConfigGroupSaver svr(krConfig, "Private");
+ TQStringList urlList = krConfig->readListEntry("PopularUrls");
+ TQValueList<int> rankList = krConfig->readIntListEntry("PopularUrlsRank");
+ if (urlList.count() != rankList.count()) {
+ KMessageBox::error(krApp, i18n("Saved 'Popular Urls' are invalid. List will be cleared"));
+ return;
+ }
+ clearList();
+ count = 0;
+ // iterate through both lists and
+ TQStringList::Iterator uit;
+ TQValueList<int>::Iterator rit;
+ for (uit=urlList.begin(), rit=rankList.begin(); uit!=urlList.end() && rit!=rankList.end(); ++uit, ++rit) {
+ UrlNodeP node = new UrlNode;
+ node->url = KURL::fromPathOrURL( *uit );
+ node->rank = *rit;
+ appendNode(node);
+ ranks.insert(*uit, node);
+ }
+}
+
+
+// returns a url list with the 'max' top popular urls
+KURL::List PopularUrls::getMostPopularUrls(int max) {
+ // get at most 'max' urls
+ KURL::List list;
+ UrlNodeP p = head;
+ int tmp = 0;
+ if (maxUrls < max) max = maxUrls; // don't give more than maxUrls
+ while (p && tmp < max) {
+ list << p->url;
+ p = p->next;
+ ++tmp;
+ }
+
+ return list;
+}
+
+// adds a url to the list, or increase rank of an existing url, making
+// sure to bump it up the list if needed
+void PopularUrls::addUrl(const KURL& url) {
+ KURL tmpurl = url;
+ tmpurl.adjustPath(1); // make a uniform trailing slash policy
+ UrlNodeP pnode;
+
+ decreaseRanks();
+ if (!head) { // if the list is empty ... (assumes dict to be empty as well)
+ pnode = new UrlNode;
+ pnode->rank = STARTING_RANK;
+ pnode->url = tmpurl;
+ appendNode(pnode);
+ ranks.insert(tmpurl.url(), head);
+ } else {
+ pnode = ranks.find(tmpurl.url());
+ if (!pnode) { // is the added url new? if so, append it
+ pnode = new UrlNode;
+ pnode->rank = STARTING_RANK;
+ pnode->url = tmpurl;
+ appendNode(pnode);
+ ranks.insert(tmpurl.url(), pnode);
+ } else {
+ pnode->rank += INCREASE;
+ }
+ }
+
+ // do we need to change location for this one?
+ relocateIfNeeded(pnode);
+
+ // too many urls?
+ if (count > maxUrls) removeNode(tail);
+
+ //dumpList();
+}
+
+// checks if 'node' needs to be bumped-up the ranking list and does it if needed
+void PopularUrls::relocateIfNeeded(UrlNodeP node) {
+ if (node->prev && (node->prev->rank < node->rank)) {
+ // iterate until we find the correct place to put it
+ UrlNodeP tmp = node->prev->prev;
+ while (tmp) {
+ if (tmp->rank >= node->rank)
+ break; // found it!
+ else tmp = tmp->prev;
+ }
+ // now, if tmp isn't null, we need to move node to tmp->next
+ // else move it to become head
+ removeNode(node);
+ insertNode(node, tmp);
+ }
+}
+
+
+// iterate over the list, decreasing each url's rank
+// this is very naive, but a 1..30 for loop is acceptable (i hope)
+void PopularUrls::decreaseRanks() {
+ if (head) {
+ UrlNodeP p=head;
+ while (p) {
+ if (p->rank-DECREASE>=0)
+ p->rank -= DECREASE;
+ else p->rank = 0;
+ p=p->next;
+ }
+ }
+}
+
+// removes a node from the list, but doesn't free memory!
+// note: this will be buggy in case the list becomes empty (which should never happen)
+void PopularUrls::removeNode(UrlNodeP node) {
+ if (node->prev) {
+ if (tail == node) tail = node->prev;
+ node->prev->next = node->next;
+ }
+ if (node->next) {
+ if (head == node) head = node->next;
+ node->next->prev = node->prev;
+ }
+ --count;
+}
+
+void PopularUrls::insertNode(UrlNodeP node, UrlNodeP after) {
+ if (!after) { // make node head
+ node->next = head;
+ node->prev = 0;
+ head->prev = node;
+ head = node;
+ } else {
+ if (tail == after) tail = node;
+ node->prev = after;
+ node->next = after->next;
+ if( node->next ) {
+ after->next->prev = node;
+ after->next = node;
+ }
+ }
+ ++count;
+}
+
+// appends 'node' to the end of the list, collecting garbage if needed
+void PopularUrls::appendNode(UrlNodeP node) {
+ if (!tail) { // creating the first element
+ head = tail = node;
+ node->prev = node->next = 0;
+ } else {
+ node->next = 0;
+ node->prev = tail;
+ tail->next = node;
+ tail = node;
+ }
+ ++count;
+}
+
+void PopularUrls::dumpList() {
+ UrlNodeP p = head;
+ printf("====start %d====\n",count);
+ while (p) {
+ printf("%d : %s\n", p->rank, p->url.url().latin1());
+ p = p->next;
+ }
+ fflush(stdout);
+}
+
+void PopularUrls::showDialog() {
+ KURL::List list = getMostPopularUrls(maxUrls);
+ dlg->run(list);
+ if (dlg->result() == -1) return;
+ SLOTS->refresh(list[dlg->result()]);
+ //printf("running %s\n", list[dlg->result()].url().latin1());fflush(stdout);
+}
+
+// ===================================== PopularUrlsDlg ======================================
+PopularUrlsDlg::PopularUrlsDlg():
+ KDialogBase(Plain, i18n("Popular Urls"), Close, KDialogBase::NoDefault, krApp) {
+ TQGridLayout *layout = new TQGridLayout( plainPage(), 0, KDialog::spacingHint() );
+
+ // listview to contain the urls
+ urls = new TDEListView(plainPage());
+ urls->header()->hide();
+ urls->addColumn("");
+ urls->setSorting(-1);
+ urls->setVScrollBarMode(TQScrollView::AlwaysOn);
+
+ // quick search
+ TQToolButton *btn = new TQToolButton(plainPage());
+ btn->setIconSet(SmallIcon("locationbar_erase"));
+ search = new TDEListViewSearchLine(plainPage(), urls);
+ search->setTrapReturnKey(true);
+ TQLabel *lbl = new TQLabel(search, i18n(" &Search: "), plainPage());
+
+ layout->addWidget(btn,0,0);
+ layout->addWidget(lbl,0,1);
+ layout->addWidget(search,0,2);
+ layout->addMultiCellWidget(urls,1,1,0,2);
+ setMaximumSize(600, 500);
+
+ setTabOrder(search, urls);
+ setTabOrder(urls, actionButton(Close));
+
+ connect(urls, TQ_SIGNAL(executed(TQListViewItem*)),
+ this, TQ_SLOT(slotItemSelected(TQListViewItem*)));
+ connect(urls, TQ_SIGNAL(returnPressed(TQListViewItem*)),
+ this, TQ_SLOT(slotItemSelected(TQListViewItem*)));
+ connect(btn, TQ_SIGNAL(clicked()), search, TQ_SLOT(clear()));
+ connect(search, TQ_SIGNAL(returnPressed(const TQString&)),
+ this, TQ_SLOT(slotSearchReturnPressed(const TQString&)));
+}
+
+void PopularUrlsDlg::slotItemSelected(TQListViewItem *it) {
+ selection = urls->itemIndex(it);
+ accept();
+}
+
+void PopularUrlsDlg::slotSearchReturnPressed(const TQString&) {
+ urls->setFocus();
+ // select the first visible item
+ TQListViewItemIterator it( urls );
+ while ( it.current() ) {
+ if ( it.current()->isVisible() ) {
+ urls->setSelected(it.current(), true);
+ urls->setCurrentItem(it.current());
+ break;
+ } else ++it;
+ }
+}
+
+PopularUrlsDlg::~PopularUrlsDlg() {
+ delete search;
+ delete urls;
+}
+
+void PopularUrlsDlg::run(KURL::List list) {
+ // populate the listview
+ urls->clear();
+ KURL::List::Iterator it;
+ for (it = list.begin(); it!=list.end(); ++it) {
+ TDEListViewItem *item = new TDEListViewItem(urls, urls->lastItem());
+ item->setText(0, (*it).isLocalFile() ? (*it).path() : (*it).prettyURL());
+ item->setPixmap(0, (*it).isLocalFile() ? SmallIcon("folder") : SmallIcon("folder_html"));
+ }
+ //urls->setCurrentItem(urls->firstChild());
+ //urls->setSelected(urls->firstChild(), true);
+ setMinimumSize(urls->sizeHint().width()+45, 400);
+
+ search->clear();
+ search->setFocus();
+ selection = -1;
+ exec();
+}
+
+#include "popularurls.moc"
diff --git a/src/app/Dialogs/popularurls.h b/src/app/Dialogs/popularurls.h
new file mode 100644
index 0000000..775a356
--- /dev/null
+++ b/src/app/Dialogs/popularurls.h
@@ -0,0 +1,86 @@
+#ifndef POPULARURLS_H
+#define POPULARURLS_H
+
+#include <tqobject.h>
+#include <kurl.h>
+#include <tqdict.h>
+#include <kdialogbase.h>
+
+// the class holds a list of most popular links in a dual data structure
+// * linked list, with head and tail: for fast append/prepend support
+// * dictionary that maps urls to list nodes: to save the need to iterate
+// over the list in order to find the correct node for each new url
+//
+// also, the class holds a maximum number of urls. two variables affect this:
+// * maxUrls - the num. of urls the user can see
+// * hardLimit - the actual number of urls kept.
+// when the number of urls reaches hardLimit, a garbage collection is done and
+// the bottom (hardLimit-maxUrls) entries are removed from the list
+typedef struct _UrlNode* UrlNodeP;
+typedef struct _UrlNode {
+ UrlNodeP prev;
+ KURL url;
+ int rank;
+ UrlNodeP next;
+} UrlNode;
+
+class PopularUrlsDlg;
+
+class PopularUrls : public TQObject {
+ TQ_OBJECT
+
+public:
+ PopularUrls(TQObject *parent = 0, const char *name = 0);
+ ~PopularUrls();
+ void save();
+ void load();
+ void addUrl(const KURL& url);
+ KURL::List getMostPopularUrls(int max);
+
+public slots:
+ void showDialog();
+
+protected:
+ // NOTE: the following methods append/insert/remove a node to the list
+ // but NEVER free memory or allocate memory!
+ void appendNode(UrlNodeP node);
+ void insertNode(UrlNodeP node, UrlNodeP after);
+ void removeNode(UrlNodeP node);
+ void relocateIfNeeded(UrlNodeP node);
+ void clearList();
+ void dumpList();
+ void decreaseRanks();
+
+private:
+ UrlNodeP head, tail;
+ TQDict<UrlNode> ranks; // actually holds UrlNode*
+ int count;
+ static const int maxUrls = 30;
+ PopularUrlsDlg *dlg;
+};
+
+class TDEListView;
+class TDEListViewSearchLine;
+
+class PopularUrlsDlg: public KDialogBase {
+ TQ_OBJECT
+
+public:
+ PopularUrlsDlg();
+ ~PopularUrlsDlg();
+ void run(KURL::List list); // use this to open the dialog
+ inline int result() const { return selection; } // returns index 0 - topmost, or -1
+
+
+protected slots:
+ void slotSearchReturnPressed(const TQString&);
+ void slotItemSelected(TQListViewItem *it);
+
+private:
+ TDEListView *urls;
+ TDEListViewSearchLine *search;
+ int selection;
+};
+
+
+#endif