code cleaning. Removed comments at end of conditional

This commit is contained in:
csoler 2017-10-19 22:20:23 +02:00
parent 74d5069225
commit 0fbcf0148c

View file

@ -243,26 +243,26 @@ bool RsCollectionDialog::eventFilter(QObject *obj, QEvent *event)
for (it = selectedItems.begin(); it != selectedItems.end(); ++it) { for (it = selectedItems.begin(); it != selectedItems.end(); ++it) {
if ((*it)->checkState(COLUMN_FILE) != checkState) if ((*it)->checkState(COLUMN_FILE) != checkState)
(*it)->setCheckState(COLUMN_FILE, checkState); (*it)->setCheckState(COLUMN_FILE, checkState);
}//for (it }
}//if (item) }
return true; // eat event return true; // eat event
}//if (keyEvent && keyEvent->key() == Qt::Key_Space) }
if (keyEvent && (keyEvent->key() == Qt::Key_Delete)) { if (keyEvent && (keyEvent->key() == Qt::Key_Delete)) {
// Delete pressed // Delete pressed
remove(); remove();
return true; // eat event return true; // eat event
}//if (keyEvent && keyEvent->key() == Qt::Key_Delete) }
if (keyEvent && (keyEvent->key() == Qt::Key_Plus)) { if (keyEvent && (keyEvent->key() == Qt::Key_Plus)) {
// Plus pressed // Plus pressed
makeDir(); makeDir();
return true; // eat event return true; // eat event
}//if (keyEvent && keyEvent->key() == Qt::Key_Plus) }
}//if (event->type() == QEvent::KeyPress) }
}//if (obj == ui._fileEntriesTW) }
if (obj == ui._systemFileTW) { if (obj == ui._systemFileTW) {
if (event->type() == QEvent::KeyPress) { if (event->type() == QEvent::KeyPress) {
@ -277,9 +277,9 @@ bool RsCollectionDialog::eventFilter(QObject *obj, QEvent *event)
} }
return true; // eat event return true; // eat event
}//if (keyEvent && keyEvent->key() == Qt::Key_Enter... }
}//if (event->type() == QEvent::KeyPress) }
}//if (obj == ui._systemFileTW) }
// pass the event on to the parent class // pass the event on to the parent class
return QDialog::eventFilter(obj, event); return QDialog::eventFilter(obj, event);
@ -452,7 +452,7 @@ bool RsCollectionDialog::addChild(QTreeWidgetItem* parent, const std::vector<Col
item->setToolTip(COLUMN_FILEC, tr("Real File Count=%1").arg(1)); item->setToolTip(COLUMN_FILEC, tr("Real File Count=%1").arg(1));
item->setData(COLUMN_FILEC, ROLE_FILEC, 1); item->setData(COLUMN_FILEC, ROLE_FILEC, 1);
item->setData(COLUMN_FILEC, ROLE_SELFILEC, 1); item->setData(COLUMN_FILEC, ROLE_SELFILEC, 1);
}//if (colFileInfo.type==DIR_TYPE_DIR }
item->setFont(COLUMN_FILE, font); item->setFont(COLUMN_FILE, font);
if (colFileInfo.filename_has_wrong_characters) if (colFileInfo.filename_has_wrong_characters)
@ -487,12 +487,12 @@ bool RsCollectionDialog::addChild(QTreeWidgetItem* parent, const std::vector<Col
itemParent->setText(COLUMN_FILEC, QString("%1").arg(parentSelFileCount)); itemParent->setText(COLUMN_FILEC, QString("%1").arg(parentSelFileCount));
itemParent = itemParent->parent(); itemParent = itemParent->parent();
}//while (itemParent) }
}//if (itemParent) }
}//if (colFileInfo.type==DIR_TYPE_FILE) }
founds.push_back(item); founds.push_back(item);
}//(founds.empty()) }
if (!founds.empty()) { if (!founds.empty()) {
@ -624,7 +624,7 @@ void RsCollectionDialog::changeFileName()
if (qddOldFile.setContent(&file)) { if (qddOldFile.setContent(&file)) {
QDomElement docOldElem = qddOldFile.elementsByTagName("RsCollection").at(0).toElement(); QDomElement docOldElem = qddOldFile.elementsByTagName("RsCollection").at(0).toElement();
collFile.recursCollectColFileInfos(docOldElem,_newColFileInfos,QString(),false); collFile.recursCollectColFileInfos(docOldElem,_newColFileInfos,QString(),false);
}//(qddOldFile.setContent(&file)) }
} else if (mb.clickedButton()==btnCancel) { } else if (mb.clickedButton()==btnCancel) {
return; return;
@ -636,7 +636,7 @@ void RsCollectionDialog::changeFileName()
//create a new empty file to check if name if good. //create a new empty file to check if name if good.
if (!file.open(QFile::WriteOnly)) return; if (!file.open(QFile::WriteOnly)) return;
file.remove(); file.remove();
}//if(file.exists()) }
_fileName = fileName; _fileName = fileName;
@ -686,7 +686,7 @@ void RsCollectionDialog::addRecursive(bool recursive)
} else { } else {
continue; continue;
} }
}//if (fileInfo.isDir()) }
if (fileInfo.isFile()){ if (fileInfo.isFile()){
fileToHash.append(fileInfo.absoluteFilePath()); fileToHash.append(fileInfo.absoluteFilePath());
++count; ++count;
@ -694,9 +694,9 @@ void RsCollectionDialog::addRecursive(bool recursive)
_listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),fileInfo.absolutePath()); _listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),fileInfo.absolutePath());
else else
_listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),""); _listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),"");
}//if (fileInfo.isFile()) }
}//if (index.column()==0) }
}//foreach (QModelIndex index, milSelectionList) }
// Process Dirs // Process Dirs
QTreeWidgetItem *item = NULL; QTreeWidgetItem *item = NULL;
@ -705,8 +705,8 @@ void RsCollectionDialog::addRecursive(bool recursive)
if (item) { if (item) {
while (item->data(COLUMN_HASH, ROLE_TYPE).toUInt() != DIR_TYPE_DIR) { while (item->data(COLUMN_HASH, ROLE_TYPE).toUInt() != DIR_TYPE_DIR) {
item = item->parent();//Only Dir as Parent item = item->parent();//Only Dir as Parent
}//while }
}//if (item) }
int index = 0; int index = 0;
while (index < dirToAdd.count()) while (index < dirToAdd.count())
@ -722,7 +722,7 @@ void RsCollectionDialog::addRecursive(bool recursive)
//QMap is ordered, so we get parent before child //QMap is ordered, so we get parent before child
//Iterator is moved inside this function //Iterator is moved inside this function
processItem(dirToAdd, index, root); processItem(dirToAdd, index, root);
}//while (index < dirToAdd.count()) }
//Update liste before attach files to be sure when file is hashed, parent directory exists. //Update liste before attach files to be sure when file is hashed, parent directory exists.
updateList(); updateList();
@ -736,9 +736,9 @@ void RsCollectionDialog::addRecursive(bool recursive)
} else if(item) { } else if(item) {
if (item->data(COLUMN_HASH, ROLE_NAME) != "") { if (item->data(COLUMN_HASH, ROLE_NAME) != "") {
it.value() = item->text(COLUMN_FILEPATH); it.value() = item->text(COLUMN_FILEPATH);
}//if (item->data(COLUMN_HASH, ROLE_NAME) != "") }
}//if (dirToAdd.contains(path)) }
}//for (QHash<QString,QString>::Iterator it }
// Process Files once all done // Process Files once all done
ui._hashBox->addAttachments(fileToHash,RS_FILE_REQ_ANONYMOUS_ROUTING /*, 0*/); ui._hashBox->addAttachments(fileToHash,RS_FILE_REQ_ANONYMOUS_ROUTING /*, 0*/);
@ -781,13 +781,13 @@ bool RsCollectionDialog::addAllChild(QFileInfo &fileInfoParent
default: default:
// should never be reached // should never be reached
break; break;
}//switch (ret) }
} }
if (fileInfo.isDir()) { if (fileInfo.isDir()) {
dirToAdd.insert(fileInfo.absoluteFilePath(),fileInfo.absolutePath()); dirToAdd.insert(fileInfo.absoluteFilePath(),fileInfo.absolutePath());
++count; ++count;
if (!addAllChild(fileInfo, dirToAdd, fileToHash, count)) return false; if (!addAllChild(fileInfo, dirToAdd, fileToHash, count)) return false;
}//if (fileInfo.isDir()) }
if (fileInfo.isFile()){ if (fileInfo.isFile()){
fileToHash.append(fileInfo.absoluteFilePath()); fileToHash.append(fileInfo.absoluteFilePath());
++count; ++count;
@ -795,8 +795,8 @@ bool RsCollectionDialog::addAllChild(QFileInfo &fileInfoParent
_listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),fileInfo.absolutePath()); _listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),fileInfo.absolutePath());
else else
_listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),""); _listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),"");
}//if (fileInfo.isFile()) }
}//foreach (QFileInfo fileInfo, dirParent.entryInfoList()) }
return true; return true;
} }
@ -821,10 +821,10 @@ void RsCollectionDialog::remove()
item->setSelected(false); item->setSelected(false);
} else { } else {
listDir += item->data(COLUMN_HASH, ROLE_NAME).toString() +"<br>"; listDir += item->data(COLUMN_HASH, ROLE_NAME).toString() +"<br>";
}//if (listDir.contains(item->data(COLUMN_HASH, ROLE_PATH).toString())) }
}//if (item->data(COLUMN_HASH, ROLE_TYPE).toUInt() == DIR_TYPE_DIR) }
}//if (item != getRootItem()) }
}//for (int curs = 0; curs < count; ++curs) }
//If directories, ask to remove them or not //If directories, ask to remove them or not
if (!listDir.isEmpty()){ if (!listDir.isEmpty()){
@ -870,14 +870,14 @@ void RsCollectionDialog::remove()
case QMessageBox::Cancel: { case QMessageBox::Cancel: {
delete msgBox; delete msgBox;
return; return;
}//case QMessageBox::Cancel: }
break; break;
default: default:
// should never be reached // should never be reached
break; break;
}//switch (ret) }
delete msgBox; delete msgBox;
}//if (!listDir.isEmpty()) }
//Remove wanted items //Remove wanted items
int leftItem = 0; int leftItem = 0;
@ -966,7 +966,7 @@ void RsCollectionDialog::processItem(QMap<QString, QString> &dirToAdd
} else { } else {
_newColFileInfos.push_back(newChild); _newColFileInfos.push_back(newChild);
} }
}//(index < count) }
} }
/** /**
@ -1006,13 +1006,13 @@ void RsCollectionDialog::makeDir()
default: default:
// should never be reached // should never be reached
break; break;
}//switch (ret) }
}//if (badChar) }
} else {//if (ok && !childName.isEmpty()) } else {//if (ok && !childName.isEmpty())
return; return;
}//if (ok && !childName.isEmpty()) }
}//while (!nameOK) }
// Process all selected items // Process all selected items
int count = ui._fileEntriesTW->selectedItems().count(); int count = ui._fileEntriesTW->selectedItems().count();
@ -1040,8 +1040,8 @@ void RsCollectionDialog::makeDir()
if (item == getRootItem()) newChild.path = ""; if (item == getRootItem()) newChild.path = "";
_newColFileInfos.push_back(newChild); _newColFileInfos.push_back(newChild);
}//if (item) }
}//for (; curs < count; ++curs) }
updateList(); updateList();
@ -1074,7 +1074,7 @@ void RsCollectionDialog::fileHashingFinished(QList<HashedFile> hashedFiles)
//File Added in directory, find its parent //File Added in directory, find its parent
colFileInfo.path = _listOfFilesAddedInDir.value(hashedFile.filepath,""); colFileInfo.path = _listOfFilesAddedInDir.value(hashedFile.filepath,"");
_listOfFilesAddedInDir.remove(hashedFile.filepath); _listOfFilesAddedInDir.remove(hashedFile.filepath);
}//if (_listOfFilesAddedInDir.value(hashedFile.filepath,"")!="") }
_newColFileInfos.push_back(colFileInfo); _newColFileInfos.push_back(colFileInfo);
@ -1112,7 +1112,7 @@ void RsCollectionDialog::itemChanged(QTreeWidgetItem *item, int col)
itemParent->setText(COLUMN_FILEC, QString("%1").arg(parentFileCount)); itemParent->setText(COLUMN_FILEC, QString("%1").arg(parentFileCount));
itemParent = itemParent->parent(); itemParent = itemParent->parent();
}//while (itemParent) }
updateSizes() ; updateSizes() ;
@ -1258,8 +1258,8 @@ void RsCollectionDialog::download()
std::list<RsPeerId>()); std::list<RsPeerId>());
} else {//if (item->checkState(COLUMN_FILE) == Qt::Checked) } else {//if (item->checkState(COLUMN_FILE) == Qt::Checked)
std::cerr<<"Skipping file : " << item->data(COLUMN_HASH,ROLE_NAME).toString().toStdString() << std::endl; std::cerr<<"Skipping file : " << item->data(COLUMN_HASH,ROLE_NAME).toString().toStdString() << std::endl;
}//if (item->checkState(COLUMN_FILE) == Qt::Checked) }
}//while ((item = *itemIterator) != NULL) }
close(); close();
} }