/*! \internal Constructs the output file path based on formatting tags specified in output path property. */ QString SpdrImportPrivate::getOutputFilePath(const QString &inputFilePath) const { Q_Q(const SpdrImport); // TODO: allow to change the input file name, too! QFileInfo fileInfo(inputFilePath); QDateTime creationDate(fileInfo.lastModified()); // Reads both Unix and Windows paths QStringList pathSegments(q->outputPath().split(mPathSeparatorRegularExpression, QString::KeepEmptyParts)); pathSegments.append(fileInfo.fileName()); QStringList outputPathSegments; foreach (const QString &segment, pathSegments) { if (!segment.contains("<") && !segment.contains(">")) { outputPathSegments.append(segment); continue; } int lessThanIndex = segment.indexOf("<") + 1; int greaterThanIndex = segment.indexOf(">", lessThanIndex); QString dateFormat(segment.mid(lessThanIndex, greaterThanIndex - lessThanIndex)); QString resultSegment(segment); resultSegment.replace(QLatin1String("<") + dateFormat + QLatin1String(">"), creationDate.toString(dateFormat)); outputPathSegments.append(resultSegment); } QString result(outputPathSegments.join("/")); q->log(QCoreApplication::translate("SpdrImportPrivate", "Output file path set to: %1").arg(result), Spdr::Debug); return result; }
void createBuyingAd(Data* data){ clearScreen(); string title, description = "", tmp = "", category, condition; float price; time_t t = time(0); // get time now struct tm * now = localtime( & t ); int year=now->tm_year + 1900; int month=now->tm_mon + 1 ; int day= now->tm_mday; Date creationDate(day,month,year); cout << "\nTitle: "; getline(cin, title); cout << "\nCategory: \n ( Agriculture, Animals, BabyAndChildren, Fashion, Home, Job, Leisure,\n" "PhonesAndTablets, RealEstate, Services, Sports, Technology, Vehicles,\n" "Others ) : "; getline(cin,category); while (!validCategory(category)) { cout<<"\nWrite a valid Category: "; getline(cin,category); } Category cat = stringToCategory(category); cout << "\nDescription: "; getline(cin, description); cout << "\nPrice: "; cin >> price; cin.ignore(); cin.clear(); Advertisement* ad = new Purchase(data->getSignedInUser(), title, cat, description, price); ad->setCreationDate(creationDate); cout << "\nIs the price negotiable? (Y/N)\n"; string answer; unsigned int i = 0; do{ if(i > 0) cout << "Please introduce a valid option. (Y/N)\n"; getline(cin,answer); if(answer == "N" || answer == "n") ad->setNegotiable(false); i++; }while(answer != "Y" && answer != "y" && answer != "N" && answer != "n"); data->addAdvertisement(ad); cout << "Ad has been successfully created\n"; signedInMenu(data); }
bool StandardCategory::addItself(RootItem *parent) { // Now, add category to persistent storage. QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); int new_id = DatabaseQueries::addCategory(database, parent->id(), parent->getParentServiceRoot()->accountId(), title(), description(), creationDate(), icon()); if (new_id <= 0) { return false; } else { setId(new_id); setCustomId(new_id); return true; } }
bool StandardFeed::addItself(RootItem* parent) { // Now, add feed to persistent storage. QSqlDatabase database = qApp->database()->connection(metaObject()->className()); bool ok; int new_id = DatabaseQueries::addFeed(database, parent->id(), parent->getParentServiceRoot()->accountId(), title(), description(), creationDate(), icon(), encoding(), url(), passwordProtected(), username(), password(), autoUpdateType(), autoUpdateInitialInterval(), type(), &ok); if (!ok) { // Query failed. return false; } else { // New feed was added, fetch is primary id from the database. setId(new_id); setCustomId(QString::number(new_id)); return true; } }