Fix qstring conversion 2

This commit is contained in:
altffour 2019-12-19 18:14:13 +03:00
parent efc2385bb8
commit e8854fb252
No known key found for this signature in database
GPG Key ID: 2E7B9E061AF66FC3
6 changed files with 70 additions and 60 deletions

View File

@ -3,5 +3,5 @@
mkdir build mkdir build
cd build cd build
cmake -DCMAKE_BUILD_TYPE=Debug .. cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j9 make -j${1:-1}
cd .. cd ..

View File

@ -2,5 +2,5 @@
mkdir build mkdir build
cd build cd build
cmake -DCMAKE_BUILD_TYPE=Release .. cmake -DCMAKE_BUILD_TYPE=Release ..
make -j9 make -j${1:1}
cd .. cd ..

View File

@ -44,11 +44,7 @@ static auto contract_getExpiry(const Contract &contract) -> QDate {
} }
static auto contract_setExpiry(Contract &contract, QDate date) -> void { static auto contract_setExpiry(Contract &contract, QDate date) -> void {
#ifdef __LINUX__ contract._expiry = date.toString(DATE_FORMAT).toStdString();
contract._expiry = date.toString(DATE_FORMAT).toUtf8().constData();
#elif defined(__WIN32__)
contract._expiry = date.toString(DATE_FORMAT).toLocal8Bit().constData();
#endif
} }

View File

@ -140,7 +140,7 @@ auto MainWindow::on_deleteBtn_clicked() -> void {
this->updateDB(); this->updateDB();
} }
auto MainWindow::on_treeView_itemClicked() -> void { auto MainWindow::on_treeView_itemClicked(QTreeWidgetItem* _item, int col) -> void {
// Reset state. // Reset state.
this->_selectedContract = nullptr; this->_selectedContract = nullptr;
this->_selectedCategory = nullptr; this->_selectedCategory = nullptr;
@ -149,11 +149,7 @@ auto MainWindow::on_treeView_itemClicked() -> void {
this->deleteBtn->setEnabled(false); this->deleteBtn->setEnabled(false);
// Get item selected // Get item selected
#ifdef __LINUX__ auto item = _item->text(0).toStdString();
auto item = this->treeView->currentItem()->text(0).toUtf8().constData();
#elif defined(__WIN32__)
auto item = this->treeView->currentItem()->text(0).toLocal8Bit().constData();
#endif
// Check if the item is from expired category. // Check if the item is from expired category.
for (int i = 0; i < _db._deactivatedCategory._contracts.size(); i++) { for (int i = 0; i < _db._deactivatedCategory._contracts.size(); i++) {

View File

@ -42,7 +42,7 @@ public slots:
void on_settingsBtn_clicked(); void on_settingsBtn_clicked();
void on_deleteBtn_clicked(); void on_deleteBtn_clicked();
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
void on_treeView_itemClicked(); void on_treeView_itemClicked(QTreeWidgetItem* _item, int column);
void on_actionExport_triggered(); void on_actionExport_triggered();
void on_actionImport_triggered(); void on_actionImport_triggered();
void on_actionAdd_Contract_triggered(); void on_actionAdd_Contract_triggered();

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>438</width> <width>438</width>
<height>441</height> <height>492</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -20,9 +20,25 @@
<x>10</x> <x>10</x>
<y>10</y> <y>10</y>
<width>421</width> <width>421</width>
<height>401</height> <height>451</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLineEdit" name="searchBox"/>
</item>
<item>
<widget class="QPushButton" name="searchBtn">
<property name="text">
<string>Search</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QTreeWidget" name="treeView"> <widget class="QTreeWidget" name="treeView">
@ -80,6 +96,8 @@
</layout> </layout>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</widget> </widget>
<widget class="QMenuBar" name="menuBar"> <widget class="QMenuBar" name="menuBar">