Last active
March 10, 2021 19:37
-
-
Save qxornet/0ccf3a5e24de63b7f201975693f5e0a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int | |
FileManager::getFilesNameFromPath(QString filePath, QTreeWidgetItem* widgetItem) | |
{ | |
QDir directory; | |
directory.setPath(filePath); | |
directory.setFilter(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::AllEntries | QDir::NoDotAndDotDot); | |
directory.setSorting(QDir::Size | QDir::Reversed); | |
if(directory.count() == 0) | |
return 1; | |
QFileInfoList fileList = directory.entryInfoList(); | |
for (auto item : fileList) | |
{ | |
if(item.isDir() == true) | |
{ | |
auto bufferDirectory = new QTreeWidgetItem(); | |
bufferDirectory->setText(0, item.fileName()); | |
if(this->getFilesNameFromPath(item.filePath(), bufferDirectory) == 0) | |
widgetItem->addChild(bufferDirectory); | |
} | |
else | |
{ | |
auto bufferItem = new QTreeWidgetItem(); | |
bufferItem->setToolTip(0, item.path()); | |
bufferItem->setText(0, item.fileName()); | |
widgetItem->addChild(bufferItem); | |
} | |
} | |
return 0; | |
} | |
void | |
CommandPrompt::exec(QString command) | |
{ | |
auto handler = command.split(" "); | |
auto search = commands.find(handler[0]); | |
bool foundSubCOmmand = false; | |
if(search == commands.end()) | |
{ | |
this->sendMessage("command not found"); | |
return; | |
} | |
if(handler.count() <= 1) | |
{ | |
this->sendMessage("not enough arguments"); | |
return; | |
} | |
auto subCommands = commands.equal_range(handler[0]); | |
for(auto item = subCommands.first; item != subCommands.second; item++) | |
{ | |
if(item->second != handler[1]) continue; | |
this->sendMessage("execute <a style='color: #C47240'>" + item->second + "</a>"); | |
foundSubCOmmand = true; | |
} | |
if(foundSubCOmmand == false) | |
this->sendMessage("sub-command not found"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment