void Statistic::onArchiveLoad() { QString fileName = QFileDialog::getOpenFileName(NULL, trUtf8("Загрузка архива"), QString()/*, "HTML (*.html)"*/); if (fileName.isEmpty()) return; #ifdef DEBUG_VER QString tmp = "D:/CNC_stat"; #else QString tmp = QApplication::applicationDirPath(); #endif QDir logsDir(tmp + "/" + LOG_PATH); if (!logsDir.exists()) { QDir(tmp).mkpath(LOG_PATH); } QString copyFileName = tmp + "/" + ARCHIVE_PATH + "/" + QFileInfo(fileName).fileName(); if(QFile::exists(copyFileName)) QFile::remove(copyFileName); QFile::copy(fileName, copyFileName); if (unCompress(copyFileName)) { QFile(copyFileName).remove(); QMessageBox::information(this, trUtf8("Внимание"), trUtf8("Архив успешно распакован")); ui.curOperationLabel->setText(trUtf8("Нет текущих операций")); setCursor(Qt::ArrowCursor); } }
void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { Q_UNUSED(context); if (type == QtWarningMsg) return; QString dt = QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss"); QString date = QDateTime::currentDateTime().toString("dd.MM.yyyy"); QString txt = QString("[%1] ").arg(dt); //ConfigureInner &con = ConfigureInner::Instance(); switch (type) { case QtDebugMsg: { //if (con.log()){ //ConsoleTextColor color(ConsoleTextColor::ForeGroundWhite); txt += QString("[Debug]: %1").arg(msg); std::cout << txt.toStdString() << std::endl; break; //} } #ifndef QT_NO_DEBUG txt += QString("[Debug]: %1").arg(msg); std::cout << txt.toStdString() << std::endl; break; #else return; #endif case QtWarningMsg: { //ConsoleTextColor color(ConsoleTextColor::ForeGroundYellow); #ifndef QT_NO_DEBUG txt += QString("[Warning]: %1").arg(msg); std::cout << txt.toStdString() << std::endl; break; #else return; #endif } case QtCriticalMsg: { //ConsoleTextColor color(ConsoleTextColor::ForeGroundRed); txt += QString("[Critical]: %1").arg(msg); std::cout << txt.toStdString() << std::endl; break; } case QtFatalMsg: { //ConsoleTextColor color(ConsoleTextColor::ForeGroundRed); txt += QString("[Fatal]: %1").arg(msg); std::cout << txt.toStdString() << std::endl; abort(); break; } case QtInfoMsg: { //ConsoleTextColor color(ConsoleTextColor::ForeGroundWhite); txt += QString("[Info]: %1").arg(msg); std::cout << txt.toStdString() << std::endl; break; } default:{ //ConsoleTextColor color(ConsoleTextColor::ForeGroundWhite); txt += QString("[Info]: %1").arg(msg); std::cout << txt.toStdString() << std::endl; break; } } #ifdef QT_NO_DEBUG QDir logsDir("logs"); if (!logsDir.exists()) { if (!QDir("./").mkpath("logs")) { std::cout << "don't created logs directory." << std::endl; } } QString outPath = "logs/" + date + ".log"; QFile outFile(outPath); if (!outFile.open(QIODevice::WriteOnly | QIODevice::Append)) { std::cout << "don't logs file." << std::endl; } QTextStream textStream(&outFile); textStream << txt << "\r\n"; #endif }
SyncWindow::SyncWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::SyncWindow) { hide(); mProcessedPasswordManager = false; mSharedFilters = new QSet<QString>(); mIncludedFilters = g_GetIncludedFilterList(); mQuitAction = false; mBusy = false; ui->setupUi(this); setWindowTitle("OwnCloud Sync"); mEditingConfig = -1; mConflictsExist = false; loadApplicationSettings(); // Before anything else, connect to the SyncDebug connect(getSyncDebug(),SIGNAL(debugMessage(const QString)), this,SLOT(processDebugMessage(const QString))); mCurrentAccountEdit = 0; mTotalSyncs = 0; // Setup icons mDefaultIcon = QIcon(":images/owncloud.png"); mSyncIcon = QIcon(":images/owncloud_sync.png"); mDefaultConflictIcon = QIcon(":images/owncloud_conflict.png"); mSyncConflictIcon = QIcon(":images/owncloud_sync_conflict.png"); setWindowIcon(mDefaultIcon); // Add the tray, if available mSystemTray = new QSystemTrayIcon(this); mSystemTrayMenu = new QMenu(this); mSystemTrayMenu->addAction(ui->action_Quit); mSystemTray->setContextMenu(mSystemTrayMenu); mSystemTray->setIcon(mDefaultIcon); mSystemTray->setToolTip(tr("OwnCloud Sync Version %1").arg(_OCS_VERSION)); mSystemTray->show(); connect(mSystemTray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this,SLOT(systemTrayActivated(QSystemTrayIcon::ActivationReason))); // Start with the default tab ui->stackedWidget->setCurrentIndex(0); ui->listFilterView->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->listIncludedFilterView->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->listGlobalFilterView->setEditTriggers(QAbstractItemView::NoEditTriggers); // Create the Accounts SignalMapper mAccountsSignalMapper = new QSignalMapper(this); connect(mAccountsSignalMapper, SIGNAL(mapped(int)), this, SLOT(slotAccountsSignalMapper(int))); mConfigDirectory = QDir::toNativeSeparators(QDir::homePath()); #ifdef Q_OS_LINUX // In linux, we will store all databases in // $HOME/.local/share/data/owncloud_sync mConfigDirectory += QDir::toNativeSeparators("/.local/share/data/"); #endif #ifdef Q_OS_WIN mConfigDirectory += QDir::toNativeSeparators("/AppData/Local/"); #endif mConfigDirectory += "owncloud_sync"; QDir configDir(mConfigDirectory); configDir.mkpath(mConfigDirectory); QDir logsDir(QDir::toNativeSeparators(mConfigDirectory+"/logs")); logsDir.mkpath(QDir::toNativeSeparators(mConfigDirectory+"/logs")); importGlobalFilters(true); updateSharedFilterList(); }
void Statistic::onReport() { ui.curOperationLabel->setText(trUtf8("Анализ отчета...")); setCursor(Qt::WaitCursor); CXSettings* settings = CXSettings::inst(); settings->setValue(E_StartDate, QDateTime(ui.mStartDateEdit->date(), ui.mStartTimeEdit->time())); settings->setValue(E_EndDate, QDateTime(ui.mEndDateEdit->date(), ui.mEndTimeEdit->time())); QStringList xmlFiles; #ifdef DEBUG_VER QString tmp = "D:/CNC_stat"; #else QString tmp = QApplication::applicationDirPath(); #endif QDir logsDir(tmp + "/" + LOG_PATH); //QDir logsDir(QApplication::applicationDirPath() + "/" + LOG_PATH); QString tempFileName; QStringList dirs = logsDir.entryList(QDir::Dirs); for (int i = 0; i < dirs.count(); ++i) { tempFileName = logsDir.path() + "/" + dirs.at(i) + "/report.xml"; if (QFile::exists(tempFileName)) xmlFiles.append(tempFileName); } QList <SXReportError> errorList = Engine::generateReport(xmlFiles, settings->value(E_StartDate).toDateTime(), settings->value(E_EndDate).toDateTime()); //#ifndef QT_NO_DEBUG // ui.mErrorTree->clear(); // // QTreeWidgetItem* newItem = NULL; // QTreeWidgetItem* childItem = NULL; // QString lastFilename = ""; // // for (int i = 0; i < errorList.count(); ++i) // { // const SXReportError& curErrorData = errorList.at(i); // // if ((newItem == NULL) || ((newItem != NULL) && (lastFilename != curErrorData.mFileName))) // { // newItem = new QTreeWidgetItem(ui.mErrorTree); // lastFilename = curErrorData.mFileName; // newItem->setText(0, lastFilename); // } // // childItem = new QTreeWidgetItem(newItem); // childItem->setForeground(0, Qt::red); // childItem->setText(0, curErrorData.mError); // // ui.mErrorTree->addTopLevelItem(newItem); // } //#else QFile errorLog("errors.log"); errorLog.open(QIODevice::WriteOnly); QTextStream textStream(&errorLog); textStream.setCodec(QTextCodec::codecForName("UTF-8")); for (int i = 0; i < errorList.count(); ++i) { const SXReportError& curErrorData = errorList.at(i); textStream << curErrorData.mFileName << "\t-\t"; textStream << curErrorData.mError << "\n"; } //#endif ui.mReportView->setHtml(Engine::getReportText()); ui.curOperationLabel->setText(trUtf8("Нет текущих операций")); setCursor(Qt::ArrowCursor); }