logic: more wstring usages
* removed header paths from VS Project setup message since VS doesn't send these anymore * implemented using wstring in IDE communication * fixed retrieving filepaths from QtDirectoryListbox that contain special characters * use wstring for source extensions * added special character as file extension to FileManagerTestSuite
This commit is contained in:
@@ -61,9 +61,9 @@ void QtListItemWidget::setText(QString text)
|
||||
{
|
||||
const FilePath path(text.toStdWString());
|
||||
const FilePath relPath = path.getRelativeTo(relativeRoot);
|
||||
if (relPath.str().size() < path.str().size())
|
||||
if (relPath.wstr().size() < path.wstr().size())
|
||||
{
|
||||
text = QString::fromStdString(relPath.str());
|
||||
text = QString::fromStdWString(relPath.wstr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,46 +239,45 @@ void QtDirectoryListBox::dropEvent(QDropEvent *event)
|
||||
|
||||
std::vector<FilePath> QtDirectoryListBox::getList()
|
||||
{
|
||||
std::vector<std::string> strList = getStringList();
|
||||
std::vector<FilePath> list;
|
||||
for (const std::string& str : strList)
|
||||
for (const std::wstring& s : getWStringList())
|
||||
{
|
||||
list.push_back(FilePath(str));
|
||||
list.push_back(FilePath(s));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
void QtDirectoryListBox::setList(const std::vector<FilePath>& list, bool readOnly)
|
||||
{
|
||||
std::vector<std::string> strList;
|
||||
std::vector<std::wstring> strList;
|
||||
for (const FilePath& path : list)
|
||||
{
|
||||
strList.push_back(path.str());
|
||||
strList.push_back(path.wstr());
|
||||
}
|
||||
setStringList(strList, readOnly);
|
||||
setWStringList(strList, readOnly);
|
||||
}
|
||||
|
||||
std::vector<std::string> QtDirectoryListBox::getStringList()
|
||||
std::vector<std::wstring> QtDirectoryListBox::getWStringList()
|
||||
{
|
||||
std::vector<std::string> list;
|
||||
std::vector<std::wstring> list;
|
||||
for (int i = 0; i < m_list->count(); ++i)
|
||||
{
|
||||
QtListItemWidget* widget = dynamic_cast<QtListItemWidget*>(m_list->itemWidget(m_list->item(i)));
|
||||
list.push_back(widget->getText().toStdString());
|
||||
list.push_back(widget->getText().toStdWString());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
void QtDirectoryListBox::setStringList(const std::vector<std::string>& list, bool readOnly)
|
||||
void QtDirectoryListBox::setWStringList(const std::vector<std::wstring>& list, bool readOnly)
|
||||
{
|
||||
clear();
|
||||
|
||||
FilePath root = m_relativeRootDirectory;
|
||||
m_relativeRootDirectory = FilePath();
|
||||
|
||||
for (const std::string& str : list)
|
||||
for (const std::wstring& str : list)
|
||||
{
|
||||
QtListItemWidget* itemWidget = addListBoxItemWithText(QString::fromStdString(str));
|
||||
QtListItemWidget* itemWidget = addListBoxItemWithText(QString::fromStdWString(str));
|
||||
itemWidget->setReadOnly(readOnly);
|
||||
}
|
||||
|
||||
@@ -286,6 +285,26 @@ void QtDirectoryListBox::setStringList(const std::vector<std::string>& list, boo
|
||||
m_relativeRootDirectory = root;
|
||||
}
|
||||
|
||||
std::vector<std::string> QtDirectoryListBox::getStringList()
|
||||
{
|
||||
std::vector<std::string> list;
|
||||
for (std::wstring s: getWStringList())
|
||||
{
|
||||
list.push_back(utility::encodeToUtf8(s));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
void QtDirectoryListBox::setStringList(const std::vector<std::string>& list, bool readOnly)
|
||||
{
|
||||
std::vector<std::wstring> wlist;
|
||||
for (std::string s : list)
|
||||
{
|
||||
wlist.push_back(utility::decodeFromUtf8(s));
|
||||
}
|
||||
setWStringList(wlist);
|
||||
}
|
||||
|
||||
QtListItemWidget* QtDirectoryListBox::addListBoxItemWithText(const QString& text)
|
||||
{
|
||||
QtListItemWidget* widget = addListBoxItem();
|
||||
|
||||
@@ -59,6 +59,9 @@ public:
|
||||
std::vector<FilePath> getList();
|
||||
void setList(const std::vector<FilePath>& list, bool readOnly = false);
|
||||
|
||||
std::vector<std::wstring> getWStringList();
|
||||
void setWStringList(const std::vector<std::wstring>& list, bool readOnly = false);
|
||||
|
||||
std::vector<std::string> getStringList();
|
||||
void setStringList(const std::vector<std::string>& list, bool readOnly = false);
|
||||
|
||||
|
||||
@@ -101,9 +101,9 @@ void QtStatusBar::setErrorCount(ErrorCountInfo errorCount)
|
||||
}
|
||||
}
|
||||
|
||||
void QtStatusBar::setIdeStatus(const std::string& text)
|
||||
void QtStatusBar::setIdeStatus(const std::wstring& text)
|
||||
{
|
||||
m_ideStatusText.setText(text.c_str());
|
||||
m_ideStatusText.setText(QString::fromStdWString(text));
|
||||
}
|
||||
|
||||
void QtStatusBar::resizeEvent(QResizeEvent* event)
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
void setText(const std::wstring& text, bool isError, bool showLoader);
|
||||
void setErrorCount(ErrorCountInfo errorCount);
|
||||
|
||||
void setIdeStatus(const std::string& text);
|
||||
void setIdeStatus(const std::wstring& text);
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
|
||||
@@ -45,7 +45,7 @@ bool QtIDECommunicationController::isListening() const
|
||||
return m_tcpWrapper.isListening();
|
||||
}
|
||||
|
||||
void QtIDECommunicationController::sendMessage(const std::string& message) const
|
||||
void QtIDECommunicationController::sendMessage(const std::wstring& message) const
|
||||
{
|
||||
m_tcpWrapper.sendMessage(message);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
virtual bool isListening() const;
|
||||
|
||||
private:
|
||||
virtual void sendMessage(const std::string& message) const;
|
||||
virtual void sendMessage(const std::wstring& message) const;
|
||||
|
||||
QtTcpWrapper m_tcpWrapper;
|
||||
|
||||
|
||||
@@ -43,10 +43,9 @@ QtTcpWrapper::~QtTcpWrapper()
|
||||
}
|
||||
}
|
||||
|
||||
void QtTcpWrapper::sendMessage(const std::string& message) const
|
||||
void QtTcpWrapper::sendMessage(const std::wstring& message) const
|
||||
{
|
||||
QByteArray data;
|
||||
data.append(message.c_str());
|
||||
QByteArray data = QString::fromStdWString(message).toUtf8();
|
||||
|
||||
QTcpSocket socket;
|
||||
socket.connectToHost(QHostAddress::LocalHost, m_clientPort);
|
||||
@@ -60,7 +59,7 @@ void QtTcpWrapper::sendMessage(const std::string& message) const
|
||||
}
|
||||
}
|
||||
|
||||
void QtTcpWrapper::setReadCallback(const std::function<void(const std::string&)>& callback)
|
||||
void QtTcpWrapper::setReadCallback(const std::function<void(const std::wstring&)>& callback)
|
||||
{
|
||||
m_readCallback = callback;
|
||||
}
|
||||
@@ -110,12 +109,11 @@ void QtTcpWrapper::startRead()
|
||||
QString string;
|
||||
stream >> string;*/
|
||||
|
||||
QString string = QString::fromUtf8(byteArray);
|
||||
QString message = QString::fromUtf8(byteArray);
|
||||
|
||||
if (m_readCallback != NULL)
|
||||
{
|
||||
std::string message = string.toStdString();
|
||||
m_readCallback(message);
|
||||
m_readCallback(message.toStdWString());
|
||||
}
|
||||
|
||||
/*char buffer[1024] = { 0 };
|
||||
|
||||
@@ -19,9 +19,9 @@ public:
|
||||
void startListening();
|
||||
void stopListening();
|
||||
|
||||
void sendMessage(const std::string& message) const;
|
||||
void sendMessage(const std::wstring& message) const;
|
||||
|
||||
void setReadCallback(const std::function<void(const std::string&)>& callback);
|
||||
void setReadCallback(const std::function<void(const std::wstring&)>& callback);
|
||||
|
||||
quint16 getServerPort() const;
|
||||
void setServerPort(const quint16 serverPort);
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
quint16 m_clientPort;
|
||||
std::string m_ip;
|
||||
|
||||
std::function<void(const std::string&)> m_readCallback;
|
||||
std::function<void(const std::wstring&)> m_readCallback;
|
||||
|
||||
QTcpServer* m_tcpServer;
|
||||
QTcpSocket* m_tcpClient;
|
||||
|
||||
@@ -189,13 +189,12 @@ void QtMainView::handleMessage(MessageProjectEdit* message)
|
||||
|
||||
void QtMainView::handleMessage(MessageProjectNew* message)
|
||||
{
|
||||
std::string cdbPath = message->cdbPath;
|
||||
std::vector<std::string> headerPaths = message->headerPaths;
|
||||
FilePath cdbPath = message->cdbPath;
|
||||
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_window->newProjectFromCDB(cdbPath, headerPaths);
|
||||
m_window->newProjectFromCDB(cdbPath);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ void QtStatusBarView::setErrorCount(ErrorCountInfo errorCount)
|
||||
);
|
||||
}
|
||||
|
||||
void QtStatusBarView::showIdeStatus(const std::string& message)
|
||||
void QtStatusBarView::showIdeStatus(const std::wstring& message)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
virtual void showMessage(const std::wstring& message, bool isError, bool showLoader);
|
||||
virtual void setErrorCount(ErrorCountInfo errorCount);
|
||||
|
||||
virtual void showIdeStatus(const std::string& message);
|
||||
virtual void showIdeStatus(const std::wstring& message);
|
||||
|
||||
private:
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
|
||||
@@ -565,7 +565,7 @@ void QtMainWindow::newProject()
|
||||
wizzard->newProject();
|
||||
}
|
||||
|
||||
void QtMainWindow::newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths)
|
||||
void QtMainWindow::newProjectFromCDB(const FilePath& filePath)
|
||||
{
|
||||
QtProjectWizzard* wizzard = dynamic_cast<QtProjectWizzard*>(m_windowStack.getTopWindow());
|
||||
if (!wizzard)
|
||||
@@ -573,13 +573,7 @@ void QtMainWindow::newProjectFromCDB(const std::string& filePath, const std::vec
|
||||
wizzard = createWindow<QtProjectWizzard>();
|
||||
}
|
||||
|
||||
std::vector<FilePath> headerFilePaths;
|
||||
for (const std::string& s: headerPaths)
|
||||
{
|
||||
headerFilePaths.push_back(FilePath(s));
|
||||
}
|
||||
|
||||
wizzard->newProjectFromCDB(FilePath(filePath), headerFilePaths);
|
||||
wizzard->newProjectFromCDB(filePath);
|
||||
}
|
||||
|
||||
void QtMainWindow::openProject()
|
||||
|
||||
@@ -115,7 +115,7 @@ public slots:
|
||||
void hideStartScreen();
|
||||
|
||||
void newProject();
|
||||
void newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths);
|
||||
void newProjectFromCDB(const FilePath& filePath);
|
||||
void openProject();
|
||||
void editProject();
|
||||
|
||||
|
||||
@@ -25,6 +25,16 @@ std::string QtTextEditDialog::getText()
|
||||
return m_text->toPlainText().toStdString();
|
||||
}
|
||||
|
||||
void QtTextEditDialog::setWText(const std::wstring& text)
|
||||
{
|
||||
m_text->setPlainText(QString::fromStdWString(text));
|
||||
}
|
||||
|
||||
std::wstring QtTextEditDialog::getWText()
|
||||
{
|
||||
return m_text->toPlainText().toStdWString();
|
||||
}
|
||||
|
||||
void QtTextEditDialog::setReadOnly(bool readOnly)
|
||||
{
|
||||
m_text->setReadOnly(readOnly);
|
||||
|
||||
@@ -18,6 +18,9 @@ public:
|
||||
void setText(const std::string& text);
|
||||
std::string getText();
|
||||
|
||||
void setWText(const std::wstring& text);
|
||||
std::wstring getWText();
|
||||
|
||||
void setReadOnly(bool readOnly);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -65,7 +65,7 @@ void QtProjectWizzard::newProject()
|
||||
setup();
|
||||
}
|
||||
|
||||
void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::vector<FilePath>& headerPaths)
|
||||
void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath)
|
||||
{
|
||||
if (!m_projectSettings)
|
||||
{
|
||||
@@ -91,16 +91,11 @@ void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::ve
|
||||
std::shared_ptr<SourceGroupSettingsCxxCdb> sourceGroupSettings =
|
||||
std::make_shared<SourceGroupSettingsCxxCdb>(utility::getUuidString(), m_projectSettings.get());
|
||||
sourceGroupSettings->setCompilationDatabasePath(filePath);
|
||||
sourceGroupSettings->setSourcePaths(headerPaths);
|
||||
m_newSourceGroupSettings = sourceGroupSettings;
|
||||
|
||||
emptySourceGroupCDBVS();
|
||||
}
|
||||
|
||||
void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
|
||||
{
|
||||
}
|
||||
|
||||
void QtProjectWizzard::editProject(const FilePath& settingsPath)
|
||||
{
|
||||
std::shared_ptr<ProjectSettings> settings = std::make_shared<ProjectSettings>(settingsPath);
|
||||
|
||||
@@ -29,8 +29,7 @@ public:
|
||||
public slots:
|
||||
void newProject();
|
||||
|
||||
void newProjectFromCDB(const FilePath& filePath, const std::vector<FilePath>& headerPaths);
|
||||
void refreshProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
|
||||
void newProjectFromCDB(const FilePath& filePath);
|
||||
|
||||
void editProject(const FilePath& settingsPath);
|
||||
void editProject(std::shared_ptr<ProjectSettings> settings);
|
||||
|
||||
@@ -27,10 +27,10 @@ void QtProjectWizzardContentExtensions::populate(QGridLayout* layout, int& row)
|
||||
|
||||
void QtProjectWizzardContentExtensions::load()
|
||||
{
|
||||
m_sourceList->setStringList(m_settings->getSourceExtensions());
|
||||
m_sourceList->setWStringList(m_settings->getSourceExtensions());
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentExtensions::save()
|
||||
{
|
||||
m_settings->setSourceExtensions(m_sourceList->getStringList());
|
||||
m_settings->setSourceExtensions(m_sourceList->getWStringList());
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ bool QtProjectWizzardContentPaths::check()
|
||||
{
|
||||
if (!expandedPath.exists())
|
||||
{
|
||||
missingPaths.append((expandedPath.str() + "\n").c_str());
|
||||
missingPaths.append(QString::fromStdWString(expandedPath.wstr() + L"\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -94,7 +94,7 @@ bool QtProjectWizzardContentPaths::check()
|
||||
}
|
||||
}
|
||||
|
||||
if (expandedPaths.size() && expandedPaths.size() == existingCount)
|
||||
if (!expandedPaths.empty() && expandedPaths.size() == existingCount)
|
||||
{
|
||||
existingPaths.push_back(path);
|
||||
}
|
||||
@@ -648,13 +648,13 @@ void QtProjectWizzardContentPathsHeaderSearch::finishedSelectDetectIncludesRootP
|
||||
|
||||
void QtProjectWizzardContentPathsHeaderSearch::finishedAcceptDetectedIncludePathsDialog()
|
||||
{
|
||||
const std::vector<std::string> detectedPaths = utility::splitToVector(m_filesDialog->getText(), "\n");
|
||||
const std::vector<std::wstring> detectedPaths = utility::split<std::vector<std::wstring>>(m_filesDialog->getWText(), L"\n");
|
||||
closedFilesDialog();
|
||||
|
||||
std::vector<std::string> headerSearchPaths = m_list->getStringList();
|
||||
std::vector<std::wstring> headerSearchPaths = m_list->getWStringList();
|
||||
|
||||
headerSearchPaths.reserve(headerSearchPaths.size() + detectedPaths.size());
|
||||
for (const std::string& detectedPath : detectedPaths)
|
||||
for (const std::wstring& detectedPath : detectedPaths)
|
||||
{
|
||||
if (!detectedPath.empty())
|
||||
{
|
||||
@@ -662,7 +662,7 @@ void QtProjectWizzardContentPathsHeaderSearch::finishedAcceptDetectedIncludePath
|
||||
}
|
||||
}
|
||||
|
||||
m_list->setStringList(headerSearchPaths);
|
||||
m_list->setWStringList(headerSearchPaths);
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathsHeaderSearch::closedPathsDialog()
|
||||
|
||||
Reference in New Issue
Block a user