mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-14 03:09:08 +00:00
Added #1307 Full support for FTP merge options and icons for FTP window. This is the last commit for the first milestone.
This commit is contained in:
parent
e8412dd711
commit
907a09526b
11 changed files with 188 additions and 81 deletions
|
@ -24,6 +24,8 @@ SET(OVQT_PLUG_TRANSLATION_MANAGER_UIS translation_manager_settings_page.ui
|
|||
source_selection.ui
|
||||
ftp_selection.ui)
|
||||
|
||||
SET(OVQT_PLUG_TRANSLATION_MANAGER_RCS ftp_selection.qrc)
|
||||
|
||||
SET(QT_USE_QTGUI TRUE)
|
||||
SET(QT_USE_QTOPENGL TRUE)
|
||||
SET(QT_USE_QTNETWORK TRUE)
|
||||
|
|
|
@ -10,14 +10,21 @@ namespace Plugin
|
|||
_ui.setupUi(this);
|
||||
connect(_ui.connectButton, SIGNAL(clicked()), this, SLOT(ConnectButtonClicked()));
|
||||
connect(_ui.doneButton, SIGNAL(clicked()), this, SLOT(DoneButtonClicked()));
|
||||
connect(_ui.cancelButton, SIGNAL(clicked()), this, SLOT(CancelButtonClicked()));
|
||||
connect(_ui.cdToParrent, SIGNAL(clicked()), this, SLOT(cdToParent()));
|
||||
connect(_ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
||||
|
||||
// file list
|
||||
// file list
|
||||
connect(_ui.fileList, SIGNAL(itemActivated(QTreeWidgetItem*,int)),this, SLOT(processItem(QTreeWidgetItem*,int)));
|
||||
_ui.fileList->setEnabled(false);
|
||||
_ui.fileList->setRootIsDecorated(false);
|
||||
_ui.fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time"));
|
||||
_ui.fileList->header()->setStretchLastSection(false);
|
||||
|
||||
// buttons
|
||||
_ui.cdToParrent->setEnabled(false);
|
||||
_ui.doneButton->setEnabled(false);
|
||||
|
||||
status = false;
|
||||
}
|
||||
|
||||
void CFtpSelection::ConnectButtonClicked()
|
||||
|
@ -25,7 +32,9 @@ namespace Plugin
|
|||
conn = new QFtp(this);
|
||||
connect(conn, SIGNAL(commandFinished(int,bool)), this, SLOT(FtpCommandFinished(int,bool)));
|
||||
connect(conn, SIGNAL(listInfo(QUrlInfo)), this, SLOT(AddToList(QUrlInfo)));
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
setCursor(Qt::WaitCursor);
|
||||
#endif
|
||||
QUrl url(_ui.url->text());
|
||||
if (!url.isValid() || url.scheme().toLower() != QLatin1String("ftp")) {
|
||||
conn->connectToHost(_ui.url->text(), 21);
|
||||
|
@ -44,6 +53,9 @@ namespace Plugin
|
|||
|
||||
void CFtpSelection::FtpCommandFinished(int, bool error)
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
setCursor(Qt::ArrowCursor);
|
||||
#endif
|
||||
if (conn->currentCommand() == QFtp::ConnectToHost)
|
||||
{
|
||||
if (error)
|
||||
|
@ -64,6 +76,20 @@ namespace Plugin
|
|||
conn->list();
|
||||
}
|
||||
|
||||
if (conn->currentCommand() == QFtp::Get)
|
||||
{
|
||||
if(error)
|
||||
{
|
||||
status = false;
|
||||
file->close();
|
||||
file->remove();
|
||||
} else {
|
||||
file->close();
|
||||
status = true;
|
||||
}
|
||||
_ui.cancelButton->setEnabled(true);
|
||||
}
|
||||
|
||||
if (conn->currentCommand() == QFtp::List)
|
||||
{
|
||||
if (isDirectory.isEmpty()) {
|
||||
|
@ -82,7 +108,7 @@ namespace Plugin
|
|||
item->setText(3, urlInfo.group());
|
||||
item->setText(4, urlInfo.lastModified().toString("MMM dd yyyy"));
|
||||
|
||||
QPixmap pixmap(urlInfo.isDir() ? ":/images/dir.png" : ":/images/file.png");
|
||||
QPixmap pixmap(urlInfo.isDir() ? ":/translationManager/images/dir.png" : ":/translationManager/images/file.png");
|
||||
item->setIcon(0, pixmap);
|
||||
|
||||
isDirectory[urlInfo.name()] = urlInfo.isDir();
|
||||
|
@ -104,18 +130,58 @@ namespace Plugin
|
|||
currentPath += name;
|
||||
conn->cd(name);
|
||||
conn->list();
|
||||
//TODO: cursor
|
||||
#ifndef QT_NO_CURSOR
|
||||
setCursor(Qt::WaitCursor);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
_ui.doneButton->setEnabled(true);
|
||||
}
|
||||
|
||||
void CFtpSelection::cdToParent()
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
setCursor(Qt::WaitCursor);
|
||||
#endif
|
||||
_ui.fileList->clear();
|
||||
isDirectory.clear();
|
||||
currentPath = currentPath.left(currentPath.lastIndexOf('/'));
|
||||
if (currentPath.isEmpty()) {
|
||||
_ui.cdToParrent->setEnabled(false);
|
||||
conn->cd("/");
|
||||
} else {
|
||||
conn->cd(currentPath);
|
||||
}
|
||||
conn->list();
|
||||
}
|
||||
|
||||
void CFtpSelection::DoneButtonClicked()
|
||||
{
|
||||
QString fileName = _ui.fileList->currentItem()->text(0);
|
||||
|
||||
if (QFile::exists(fileName)) {
|
||||
QMessageBox::information(this, tr("FTP"),
|
||||
tr("There already exists a file called %1 in "
|
||||
"the current directory.")
|
||||
.arg(fileName));
|
||||
return;
|
||||
}
|
||||
|
||||
file = new QFile(fileName);
|
||||
#ifndef QT_NO_CURSOR
|
||||
setCursor(Qt::WaitCursor);
|
||||
#endif
|
||||
if (!file->open(QIODevice::WriteOnly)) {
|
||||
QMessageBox::information(this, tr("FTP"),
|
||||
tr("Unable to save the file %1: %2.")
|
||||
.arg(fileName).arg(file->errorString()));
|
||||
delete file;
|
||||
return;
|
||||
}
|
||||
_ui.cancelButton->setEnabled(false);
|
||||
conn->get(_ui.fileList->currentItem()->text(0), file);
|
||||
|
||||
reject();
|
||||
}
|
||||
|
||||
void CFtpSelection::CancelButtonClicked()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,11 +9,12 @@
|
|||
#define FTP_SELECTION_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtGui/QDialog>
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtCore/Qfile>
|
||||
#include <QtNetwork>
|
||||
#include <QtCore/QUrl>
|
||||
|
||||
#include "ui_ftp_selection.h"
|
||||
|
||||
|
@ -30,13 +31,15 @@ namespace Plugin {
|
|||
QHash<QString, bool> isDirectory;
|
||||
QString currentPath;
|
||||
private Q_SLOTS:
|
||||
void cdToParent();
|
||||
void processItem(QTreeWidgetItem*,int);
|
||||
void CancelButtonClicked();
|
||||
void ConnectButtonClicked();
|
||||
void DoneButtonClicked();
|
||||
void FtpCommandFinished(int, bool error);
|
||||
void AddToList(const QUrlInfo &urlInfo);
|
||||
public:
|
||||
bool status;
|
||||
QFile *file;
|
||||
CFtpSelection(QWidget* parent = 0);
|
||||
~CFtpSelection() {}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<RCC>
|
||||
<qresource prefix="translationManager">
|
||||
<file>images/cdtoparent.png</file>
|
||||
<file>images/dir.png</file>
|
||||
<file>images/file.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>383</width>
|
||||
<height>547</height>
|
||||
<width>388</width>
|
||||
<height>560</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -19,7 +19,7 @@
|
|||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>371</width>
|
||||
<height>501</height>
|
||||
<height>541</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
|
@ -28,10 +28,10 @@
|
|||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<x>10</x>
|
||||
<y>130</y>
|
||||
<width>371</width>
|
||||
<height>411</height>
|
||||
<width>351</width>
|
||||
<height>361</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
|
@ -40,7 +40,7 @@
|
|||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>141</width>
|
||||
<height>21</height>
|
||||
|
@ -53,9 +53,9 @@
|
|||
<widget class="QTreeWidget" name="fileList">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>361</width>
|
||||
<width>331</width>
|
||||
<height>311</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -69,10 +69,10 @@
|
|||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1</x>
|
||||
<x>11</x>
|
||||
<y>29</y>
|
||||
<width>361</width>
|
||||
<height>107</height>
|
||||
<width>351</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
|
@ -98,38 +98,44 @@
|
|||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="ftp_selection.qrc">
|
||||
<normaloff>:/translationManager/images/cdtoparent.png</normaloff>:/translationManager/images/cdtoparent.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>500</y>
|
||||
<width>371</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="doneButton">
|
||||
<property name="text">
|
||||
<string>Done</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>500</y>
|
||||
<width>361</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="doneButton">
|
||||
<property name="text">
|
||||
<string>Done</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="ftp_selection.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 139 B |
Binary file not shown.
After Width: | Height: | Size: 154 B |
Binary file not shown.
After Width: | Height: | Size: 129 B |
|
@ -20,13 +20,13 @@ class CSourceDialog : public QDialog
|
|||
Q_OBJECT
|
||||
private:
|
||||
Ui::SourceSelectionDialog _ui;
|
||||
QListWidgetItem *selected_item;
|
||||
private Q_SLOTS:
|
||||
void OkButtonClicked();
|
||||
public:
|
||||
CSourceDialog(QWidget *parent = 0);
|
||||
~CSourceDialog(){}
|
||||
void setSourceOptions(map<QListWidgetItem*, int> options);
|
||||
QListWidgetItem *selected_item;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -380,7 +380,26 @@ void CMainWindow::mergeSingleFile()
|
|||
{
|
||||
CEditor* editor_window = qobject_cast<CEditor*>(_ui.mdiArea->currentSubWindow());
|
||||
CSourceDialog *dialog = new CSourceDialog(this);
|
||||
CFtpSelection* ftp_dialog;
|
||||
map<QListWidgetItem*, int> methods;
|
||||
QString file_name;
|
||||
|
||||
if (_ui.mdiArea->subWindowList().size() == 0)
|
||||
{
|
||||
QErrorMessage error;
|
||||
error.showMessage(QString("Open a work file in editor for merge operation."));
|
||||
error.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
if(QString(editor_window->widget()->metaObject()->className()) != "QTableWidget") // Sheet Editor
|
||||
{
|
||||
QErrorMessage error;
|
||||
error.showMessage(QString("Please open or activate the window with a sheet file."));
|
||||
error.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
// create items
|
||||
QListWidgetItem* local_item = new QListWidgetItem();
|
||||
local_item->setText("Local directory");
|
||||
|
@ -392,40 +411,44 @@ void CMainWindow::mergeSingleFile()
|
|||
dialog->setSourceOptions(methods);
|
||||
dialog->show();
|
||||
dialog->exec();
|
||||
// get the file for merge
|
||||
if(dialog->selected_item == local_item) // Local directory
|
||||
{
|
||||
QString file_name;
|
||||
if (_ui.mdiArea->subWindowList().size() > 0)
|
||||
{
|
||||
file_name = QFileDialog::getOpenFileName(this);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if(QString(editor_window->widget()->metaObject()->className()) == "QTableWidget") // Sheet Editor
|
||||
{
|
||||
editor_window->activateWindow();
|
||||
CEditorWorksheet* current_window = qobject_cast<CEditorWorksheet*>(editor_window);
|
||||
if(current_window->windowFilePath() == file_name)
|
||||
return;
|
||||
if(current_window->compareWorksheetFile(file_name))
|
||||
{
|
||||
current_window->mergeWorksheetFile(file_name);
|
||||
} else {
|
||||
QErrorMessage error;
|
||||
error.showMessage(QString("The file: %1 has different columns from the current file in editor.").arg(file_name));
|
||||
error.exec();
|
||||
}
|
||||
}
|
||||
file_name = QFileDialog::getOpenFileName(this);
|
||||
} else if(dialog->selected_item == ftp_item) { // Ftp directory
|
||||
CFtpSelection* ftp_dialog = new CFtpSelection(this);
|
||||
ftp_dialog->show();
|
||||
ftp_dialog->exec();
|
||||
if(ftp_dialog->status == true)
|
||||
{
|
||||
file_name = ftp_dialog->file->fileName();
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
editor_window->activateWindow();
|
||||
CEditorWorksheet* current_window = qobject_cast<CEditorWorksheet*>(editor_window);
|
||||
if(current_window->windowFilePath() == file_name)
|
||||
return;
|
||||
if(current_window->compareWorksheetFile(file_name))
|
||||
{
|
||||
current_window->mergeWorksheetFile(file_name);
|
||||
} else {
|
||||
QErrorMessage error;
|
||||
error.showMessage(QString("The file: %1 has different columns from the current file in editor.").arg(file_name));
|
||||
error.exec();
|
||||
}
|
||||
if(dialog->selected_item == ftp_item)
|
||||
{
|
||||
if(!ftp_dialog->file->remove())
|
||||
{
|
||||
QErrorMessage error;
|
||||
error.showMessage(QString("Please remove the file from ftp server manually. The file is located on the same directory with OVQT application."));
|
||||
error.exec();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CMainWindow::readSettings()
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
QMenu *windowMenu;
|
||||
QSignalMapper *windowMapper;
|
||||
// config
|
||||
map<string,bool> initialize_settings;
|
||||
QMap<string,bool> initialize_settings;
|
||||
QList<QString> filters;
|
||||
QList<QString> languages;
|
||||
QString level_design_path;
|
||||
|
|
Loading…
Reference in a new issue