|
// =====================================================================================
|
|
//
|
|
// Filename: FileUploadItem.h
|
|
//
|
|
// Description:
|
|
//
|
|
//
|
|
// Version: 1.0
|
|
// Created: 2010年07月19日 17时06分42秒
|
|
// Revision: none
|
|
// Compiler: g++
|
|
//
|
|
// Author: 宋志民 (Song Zhi-Min), cszhmsong@gmail.com
|
|
// Company: 希科系统开发小组(CxServer Development Team)
|
|
//
|
|
// =====================================================================================
|
|
|
|
#ifndef FILE_UPLOADITEM_H_
|
|
#define FILE_UPLOADITEM_H_
|
|
|
|
#include <WContainerWidget>
|
|
#include <WFileUpload>
|
|
|
|
#include "FilesUpload.h"
|
|
#include "Option.h"
|
|
#include "File.h"
|
|
|
|
class FilesUpload;
|
|
|
|
using namespace Wt;
|
|
using namespace Cs;
|
|
|
|
/**
|
|
* @addtogroup utils
|
|
*/
|
|
/*@{*/
|
|
|
|
/*! \class FileUploadItem FileUploadItem.h "utils/FileUploadItem.h"
|
|
* \brief A file upload item widget(a basic upload unit). This class is revised from AttachmentEdit
|
|
* of Wt's composer example.
|
|
*
|
|
* \image html FileUploadItem.png "A FileUploadItem work mechanism"
|
|
*/
|
|
|
|
class FileUploadItem : public WContainerWidget {
|
|
|
|
public:
|
|
|
|
/*! \brief Creates a file upload item.
|
|
*/
|
|
FileUploadItem(FilesUpload *container, WContainerWidget *parent = 0);
|
|
|
|
/*! \brief Return whether this item NEEDs to be uploaded NOW.
|
|
*/
|
|
bool uploadNow();
|
|
|
|
/*! \brief Returns whether this item uploading failed.
|
|
*/
|
|
bool uploadFailed() const { return uploadFailed_; }
|
|
|
|
/*! \brief Returns the file item(which has been successfully uploaded?).
|
|
*/
|
|
File file();
|
|
|
|
public slots:
|
|
|
|
/*! \brief Hides the cancel button.
|
|
*
|
|
* One situation is file has been spooled, another is if the file upload is mandatory.
|
|
*/
|
|
void hideCancel();
|
|
|
|
private slots:
|
|
|
|
/*! \brief Slot triggered when the WFileUpload completed an upload.
|
|
*/
|
|
void uploaded();
|
|
|
|
/*! \brief Slot triggered when the WFileUpload received an oversized file.
|
|
*/
|
|
void fileTooLarge(int size);
|
|
|
|
/*! \brief Slot triggered when the users wishes to cancel this file upload item.
|
|
*/
|
|
void cancel();
|
|
|
|
/*! \brief Slot triggered when the users wishes to remove this uploaded file.
|
|
*/
|
|
void remove();
|
|
|
|
private:
|
|
|
|
FilesUpload *container_;
|
|
WFileUpload *upload_;
|
|
Option *cancel_;
|
|
Text *uploaded_;
|
|
Option *remove_;
|
|
Text *error_;
|
|
bool uploadFailed_;
|
|
|
|
std::string fileName_;
|
|
std::string tmpFileName_;
|
|
std::string spoolDirFileName_;
|
|
std::wstring contentDescription_;
|
|
};
|
|
/*@}*/
|
|
#endif // FILE_UPLOADITEM_H_
|