fileInstallWidget.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 static const char *fileinstallwidget_id =
00032 "$Id: fileInstallWidget.cc,v 1.25.4.5 2003/03/17 22:32:47 adridg Exp $";
00033
00034 #ifndef _KPILOT_OPTIONS_H
00035 #include "options.h"
00036 #endif
00037
00038 #include <unistd.h>
00039
00040 #include <qlistbox.h>
00041 #include <qstring.h>
00042 #include <qlabel.h>
00043 #include <qpushbutton.h>
00044 #include <qdragobject.h>
00045 #include <qlayout.h>
00046 #include <qwhatsthis.h>
00047 #include <qmultilineedit.h>
00048
00049 #include <kfiledialog.h>
00050
00051 #include "kpilotConfig.h"
00052 #include "fileInstaller.h"
00053
00054
00055 #include "fileInstallWidget.moc"
00056
00057 FileInstallWidget::FileInstallWidget(QWidget * parent,
00058 const QString & path) :
00059 PilotComponent(parent, "component_files", path),
00060 fSaveFileList(false),
00061 fInstaller(0L)
00062 {
00063 FUNCTIONSETUP;
00064
00065 QGridLayout *grid = new QGridLayout(this, 5, 5, SPACING);
00066
00067 QLabel *label = new QLabel(i18n("Files to install:"), this);
00068
00069 grid->addWidget(label, 1, 1);
00070
00071 QPushButton *abutton;
00072
00073 abutton = clearButton= new QPushButton(i18n("Clear List"), this);
00074
00075 connect(abutton, SIGNAL(clicked()), this, SLOT(slotClearButton()));
00076 grid->addWidget(abutton, 3, 1);
00077 QWhatsThis::add(abutton,
00078 i18n
00079 ("<qt>Clear the list of files to install. No files will be installed.</qt>"));
00080
00081 abutton = addButton = new QPushButton(i18n("Add File"), this);
00082 connect(abutton, SIGNAL(clicked()), this, SLOT(slotAddFile()));
00083 grid->addWidget(abutton, 4, 1);
00084 QWhatsThis::add(abutton,
00085 i18n
00086 ("<qt>Choose a file to add to the list of files to install.</qt>"));
00087
00088 fListBox = new QListBox(this);
00089 grid->addMultiCellWidget(fListBox, 1, 4, 2, 3);
00090 QWhatsThis::add(fListBox,
00091 i18n
00092 ("<qt>This lists files that will be installed on the Pilot during the next HotSync. Drag files here or use the Add button.</qt>"));
00093
00094 grid->setRowStretch(2, 100);
00095 grid->setColStretch(2, 50);
00096 grid->setColStretch(2, 50);
00097 grid->addColSpacing(4, SPACING);
00098 grid->addRowSpacing(5, SPACING);
00099
00100 fInstaller = new FileInstaller;
00101 connect(fInstaller, SIGNAL(filesChanged()),
00102 this, SLOT(refreshFileInstallList()));
00103
00104 setAcceptDrops(true);
00105
00106 (void) fileinstallwidget_id;
00107 }
00108
00109 FileInstallWidget::~FileInstallWidget()
00110 {
00111 KPILOT_DELETE(fInstaller);
00112 }
00113
00114 void FileInstallWidget::dragEnterEvent(QDragEnterEvent * event)
00115 {
00116 FUNCTIONSETUP;
00117 event->accept(QUriDrag::canDecode(event));
00118 }
00119
00120
00121 void FileInstallWidget::dropEvent(QDropEvent * drop)
00122 {
00123 FUNCTIONSETUP;
00124
00125 QStrList list;
00126
00127 QUriDrag::decode(drop, list);
00128
00129 #ifdef DEBUG
00130 DEBUGKPILOT << ": Got " << list.first() << endl;
00131 #endif
00132
00133 if (list.first() != 0L)
00134 {
00135 fInstaller->addFiles(list);
00136 }
00137 }
00138
00139 void FileInstallWidget::slotClearButton()
00140 {
00141 FUNCTIONSETUP;
00142 fInstaller->clearPending();
00143 }
00144
00145 void FileInstallWidget::initialize()
00146 {
00147 FUNCTIONSETUP;
00148 refreshFileInstallList();
00149 }
00150
00151 void FileInstallWidget::slotAddFile()
00152 {
00153 FUNCTIONSETUP;
00154
00155 QStringList fileNames = KFileDialog::getOpenFileNames();
00156
00157 for (QStringList::Iterator fileName = fileNames.begin(); fileName != fileNames.end(); ++fileName)
00158 {
00159 fInstaller->addFile(*fileName);
00160 }
00161 }
00162
00163 bool FileInstallWidget::preHotSync(QString &)
00164 {
00165 FUNCTIONSETUP;
00166
00167 fListBox->setEnabled(false);
00168 fInstaller->setEnabled(false);
00169 addButton->setEnabled(false);
00170 clearButton->setEnabled(false);
00171
00172 return true;
00173 }
00174
00175 void FileInstallWidget::postHotSync()
00176 {
00177 FUNCTIONSETUP;
00178 fInstaller->setEnabled(true);
00179 fListBox->setEnabled(true);
00180 addButton->setEnabled(true);
00181 clearButton->setEnabled(true);
00182 refreshFileInstallList();
00183 }
00184
00185
00186 void FileInstallWidget::refreshFileInstallList()
00187 {
00188 FUNCTIONSETUP;
00189
00190 fListBox->clear();
00191 fListBox->insertStringList(fInstaller->fileNames());
00192 }
00193
00194
This file is part of the documentation for kdelibs Version 3.1.4.