PageRenderTime 54ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/managefile/exportconvertdialog.cpp

http://filesearch.googlecode.com/
C++ | 144 lines | 97 code | 23 blank | 24 comment | 15 complexity | b6e6cde0a2cdaa0f19638f41e0896a68 MD5 | raw file
  1. /*
  2. For general Sqliteman copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Sqliteman
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. #include <QFileDialog>
  8. #include <QMessageBox>
  9. #include <QtDebug>
  10. #include <QDir>
  11. #include <QStandardItemModel>
  12. #include <QDesktopServices>
  13. #include <QUrl>
  14. #include "exportconvertdialog.h"
  15. #include "preferences.h"
  16. #include "utils.h"
  17. #include "fileutils.h"
  18. ExportConvertDialog::ExportConvertDialog(QWidget * parent, const QString & dir)
  19. : QDialog(parent),
  20. m_parent(parent),
  21. m_dir(dir),update(false)
  22. {
  23. setupUi(this);
  24. // Set UI
  25. // ??????
  26. QString tdestDir = m_dir;
  27. // convertTypeCmb
  28. convertTypeCmb->clear();
  29. convertTypeCmb->insertItems(0, QStringList()
  30. << ""
  31. << tr("Convert Office to Pdf")
  32. << tr("Convert Pdf to Office")
  33. << tr("Convert Picture to Pdf")
  34. << tr("Convert Ppt to Picture")
  35. );
  36. QFileInfo file(m_dir);
  37. this->setWindowIcon(Utils::getIcon("document-import.png"));
  38. this->setWindowTitle(tr("Doc Export -") + file.fileName() );
  39. progressBar->hide();
  40. pgfilename->hide();
  41. cancelled = false;
  42. connect(fileSelBtn, SIGNAL(clicked()), this, SLOT(fileSelBtn_clicked()));
  43. connect(buttonBox, SIGNAL(accepted()), this, SLOT(confirmBtn_clicked()));
  44. connect(buttonBox,SIGNAL(rejected()),this,SLOT(cancelBtn_clicked()));
  45. }
  46. // ??????
  47. void ExportConvertDialog::fileSelBtn_clicked()
  48. {
  49. QString path = QFileDialog::getExistingDirectory(this, tr("Select existing Export directory"),
  50. tr("Choose a directory"), QFileDialog::ShowDirsOnly);
  51. if (path.isEmpty()){
  52. return;
  53. }
  54. path = QDir::toNativeSeparators(path);
  55. // ??????
  56. fileSelDir->setText(path);
  57. m_exportDir = path;
  58. }
  59. //// ???? ?????????????????????????????
  60. void ExportConvertDialog::confirmBtn_clicked(){
  61. // ??????????
  62. if(m_exportDir.isEmpty()){
  63. QMessageBox::warning(this, tr("Warning"), tr("Please Select the Path to Export Into.."), QMessageBox::Yes);
  64. return;
  65. }
  66. // ?????????
  67. this->setEnabled(false);
  68. pgfilename->show();
  69. progressBar->show();
  70. // ????
  71. progressBar->setWindowModality(Qt::WindowModal);
  72. progressBar->setRange(0, 100);
  73. // ????
  74. int index = convertTypeCmb->currentIndex();
  75. QFileInfo file(m_dir);
  76. if(index == 0){
  77. QString filepath = file.absoluteFilePath();
  78. QString displayfilepath = file.fileName();
  79. pgfilename->setText(displayfilepath);
  80. FileUtils::copyFileToDir(filepath, m_exportDir, true);
  81. setProgress(100);
  82. }else{
  83. // ??
  84. // Convert Office to Pdf
  85. if(index == 1){
  86. }
  87. // Convert Pdf to Office
  88. if(index == 2){
  89. }
  90. // Convert Picture to Pdf
  91. if(index == 3){
  92. }
  93. // Convert Ppt to Picture
  94. if(index == 4){
  95. }
  96. }
  97. update = true;
  98. // ??????
  99. int com = QMessageBox::information(this, tr("Message"), tr("Documents Exported Success!"), QMessageBox::Yes);
  100. if (com == QMessageBox::Yes)
  101. {
  102. this->close();
  103. QDesktopServices::openUrl(QUrl("file:///" + m_exportDir));
  104. return;
  105. }
  106. }
  107. // ??????
  108. bool ExportConvertDialog::setProgress(int p)
  109. {
  110. if (cancelled){
  111. return false;
  112. }
  113. progressBar->setValue(p);
  114. return true;
  115. }
  116. // ????
  117. void ExportConvertDialog::cancelBtn_clicked(){
  118. cancelled = true;
  119. update = false;
  120. this->close();
  121. }