MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / addUrls

Method addUrls

Gui/SequenceFileDialog.cpp:2059–2139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2057}
2058
2059void
2060UrlModel::addUrls(const std::vector<QUrl> &list,
2061 int startRow,
2062 bool removeExisting)
2063{
2064 if (startRow == -1) {
2065 startRow = rowCount();
2066 }
2067 startRow = qMin( startRow, rowCount() );
2068
2069 ///Remove already existent URLS
2070 ///Result is a pair new Url, clean url path
2071 std::vector<std::pair<QUrl, QString> > realList;
2072 for (U32 i = 0; i < list.size(); ++i) {
2073 QUrl url = list[i];
2074 if ( !url.isValid() || ( url.scheme() != QLatin1String("file") ) ) {
2075 continue;
2076 }
2077
2078 const QString cleanUrl = QDir::cleanPath( QtCompat::toLocalFileUrlFixed(url).toLocalFile() );
2079 QModelIndex idx = fileSystemModel->index(cleanUrl);
2080 if ( !cleanUrl.isEmpty() && !fileSystemModel->isDir(idx) ) {
2081 continue;
2082 }
2083
2084 bool found = false;
2085 int rc = rowCount();
2086 for (int j = 0; j < rc; ++j) {
2087 if (index(j, 0).data(UrlRole).toUrl().toLocalFile() == cleanUrl) {
2088 if (removeExisting) {
2089 if (j < startRow) {
2090 --startRow;
2091 }
2092 removeRow(j);
2093 ///remove it from wacthing too
2094 for (U32 k = 0; k < watching.size(); ++k) {
2095 if (watching[k].second == cleanUrl) {
2096 watching.erase(watching.begin() + k);
2097 break;
2098 }
2099 }
2100 } else {
2101 found = true;
2102 }
2103 break;
2104 }
2105 }
2106 if (!found) {
2107 // If not found, make sure it is not already in the realList
2108 for (std::size_t k = 0; k < realList.size(); ++k) {
2109 if (realList[k].second == cleanUrl) {
2110 found = true;
2111 break;
2112 }
2113 }
2114 if (!found) {
2115 realList.push_back( std::make_pair(QUrl::fromLocalFile(cleanUrl), cleanUrl) );
2116 }

Callers 3

restoreStateMethod · 0.45
addFavoriteMethod · 0.45
showPopupMethod · 0.45

Calls 13

cleanPathFunction · 0.85
toLocalFileUrlFixedFunction · 0.85
setUrlFunction · 0.85
isDirMethod · 0.80
emptyMethod · 0.80
sizeMethod · 0.45
isValidMethod · 0.45
indexMethod · 0.45
isEmptyMethod · 0.45
dataMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected