bool ItemsList::generateSchedule() { if (!m_actualTable.isEmpty() && mainOrderActive ) { setAnimationVisible(true); emit animationVisible(getAnimationVisible()); if( setPath().isEmpty() ) { runMsg("Nie wybrano lokalizacji."); setAnimationVisible(false); emit animationVisible(getAnimationVisible()); return false; } QAxObject* excel; QAxObject* wbooks; QAxObject* book; QFileInfo scheduleFile("schedule.xlsm"); QVariant excelPath; QVariant destPath; excelPath = QVariant(scheduleFile.absoluteFilePath().replace("/", "\\\\")); excel = new QAxObject("Excel.Application", this); excel->setProperty("Visible", false); excel->setProperty("DisplayAlerts",0); wbooks = excel->querySubObject("Workbooks"); book = wbooks->querySubObject("Open (const QString&)", excelPath); destPath = excel->dynamicCall("Run(QVariant)", QVariant("runMacro")); book->dynamicCall("Close()"); excel->dynamicCall("Quit()"); runMsg("Wygenerowano harmonogram",destPath.toString()); delete book; delete wbooks; delete excel; setAnimationVisible(false); emit animationVisible(getAnimationVisible()); csvFile->remove(); tableDialog->model->clear(); mainOrderActive = false; return true; } else if(m_actualTable.isEmpty() || !mainOrderActive ) { runMsg("Zamówienie jest puste."); return false; } return false; }
void Settings::loadSchedule() { QFile schedule_file(scheduleFile()); if (not schedule_file.open(QIODevice::ReadOnly)) { return; } m_schedules = File::readLines(&schedule_file); schedule_file.close(); }
void Settings::saveSchedule() { QFile schedule_file(scheduleFile()); if (not schedule_file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { throw new ErrorWritingSourcesFile; } QTextStream out(&schedule_file); out << m_schedules.join("\n"); schedule_file.close(); }