MCPcopy Create free account
hub / github.com/ckaiser/Lightscreen / getName

Method getName

tools/screenshot.cpp:69–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69QString Screenshot::getName(const NamingOptions &options, const QString &prefix, const QDir &directory)
70{
71 QString naming;
72 int naming_largest = 0;
73
74 if (options.flip) {
75 naming = "%1" % prefix;
76 } else {
77 naming = prefix % "%1";
78 }
79
80 switch (options.naming) {
81 case Screenshot::Numeric: // Numeric
82 // Iterating through the folder to find the largest numeric naming.
83 for (auto file : directory.entryList(QDir::Files)) {
84 if (file.contains(prefix)) {
85 file.chop(file.size() - file.lastIndexOf("."));
86 file.remove(prefix);
87
88 if (file.toInt() > naming_largest) {
89 naming_largest = file.toInt();
90 }
91 }
92 }
93
94 if (options.leadingZeros > 0) {
95 //Pretty, huh?
96 QString format;
97 QTextStream(&format) << "%0" << (options.leadingZeros + 1) << "d";
98
99 naming = naming.arg(QString().sprintf(format.toLatin1(), naming_largest + 1));
100 } else {
101 naming = naming.arg(naming_largest + 1);
102 }
103 break;
104 case Screenshot::Date: // Date
105 naming = naming.arg(QLocale().toString(QDateTime::currentDateTime(), options.dateFormat));
106 break;
107 case Screenshot::Timestamp: // Timestamp
108 naming = naming.arg(QDateTime::currentDateTime().toTime_t());
109 break;
110 case Screenshot::Empty:
111 naming = naming.arg("");
112 break;
113 }
114
115 return naming;
116}
117
118const QString &Screenshot::unloadedFileName()
119{

Callers

nothing calls this directly

Calls 1

QStringClass · 0.85

Tested by

no test coverage detected