Optimized some inappropriate code.

This commit is contained in:
iaom 2021-03-25 10:46:26 +08:00
parent 8164757937
commit 4c0d791052
7 changed files with 10 additions and 10 deletions

View File

@ -272,7 +272,7 @@ void AppMatch::appNameMatch(QString appname,QMap<NameString,QStringList> &instal
installed.insert(name,list); installed.insert(name,list);
return; return;
} }
for(int i;i<pinyinlist.size()/2;i++){ for(int i = 0;i<pinyinlist.size()/2;i++){
QString shouzimu=pinyinlist.at(2*i+1);// 中文转首字母 QString shouzimu=pinyinlist.at(2*i+1);// 中文转首字母
if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){ if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){
// installed.insert(name,m_installAppMap.value(name)); // installed.insert(name,m_installAppMap.value(name));

View File

@ -53,13 +53,13 @@ ContentWidget::~ContentWidget()
* @brief initUI homepage和resultpage * @brief initUI homepage和resultpage
*/ */
void ContentWidget::initUI() { void ContentWidget::initUI() {
m_homePage = new QWidget; m_homePage = new QWidget(this);
m_homePageLyt = new QVBoxLayout(m_homePage); m_homePageLyt = new QVBoxLayout(m_homePage);
m_homePageLyt->setSpacing(0); m_homePageLyt->setSpacing(0);
m_homePageLyt->setContentsMargins(0,0,0,0); m_homePageLyt->setContentsMargins(0,0,0,0);
m_homePage->setLayout(m_homePageLyt); m_homePage->setLayout(m_homePageLyt);
m_resultPage = new QWidget; m_resultPage = new QWidget(this);
m_resultPageLyt = new QHBoxLayout(m_resultPage); m_resultPageLyt = new QHBoxLayout(m_resultPage);
m_resultPageLyt->setSpacing(0); m_resultPageLyt->setSpacing(0);
m_resultPageLyt->setContentsMargins(0, 0, 0, 0); m_resultPageLyt->setContentsMargins(0, 0, 0, 0);
@ -74,7 +74,7 @@ void ContentWidget::initUI() {
m_resultPageLyt->addWidget(m_resultDetailArea); m_resultPageLyt->addWidget(m_resultDetailArea);
m_resultPage->setLayout(m_resultPageLyt); m_resultPage->setLayout(m_resultPageLyt);
m_resultList = new QWidget(m_resultDetailArea); m_resultList = new QWidget(m_resultListArea);
m_resultDetail = new QWidget(m_resultDetailArea); m_resultDetail = new QWidget(m_resultDetailArea);
m_listLyt = new QVBoxLayout(m_resultList); m_listLyt = new QVBoxLayout(m_resultList);
m_detailLyt = new QVBoxLayout(m_resultDetail); m_detailLyt = new QVBoxLayout(m_resultDetail);

View File

@ -26,7 +26,7 @@
#include <QTextDocument> #include <QTextDocument>
#include <QAbstractTextDocumentLayout> #include <QAbstractTextDocumentLayout>
HighlightItemDelegate::HighlightItemDelegate() HighlightItemDelegate::HighlightItemDelegate(QObject *parent) : QStyledItemDelegate (parent)
{ {
} }

View File

@ -27,7 +27,7 @@ class HighlightItemDelegate : public QStyledItemDelegate
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit HighlightItemDelegate(); explicit HighlightItemDelegate(QObject *parent = nullptr);
void setSearchKeyword(const QString &); void setSearchKeyword(const QString &);
private: private:
QString m_regFindKeyWords = 0; QString m_regFindKeyWords = 0;

View File

@ -27,7 +27,7 @@ SearchListView::SearchListView(QWidget * parent, const QStringList& list, const
this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionBehavior(QAbstractItemView::SelectRows);
setSelectionMode(QAbstractItemView::SingleSelection); setSelectionMode(QAbstractItemView::SingleSelection);
m_model = new SearchItemModel; m_model = new SearchItemModel(this);
m_item = new SearchItem; m_item = new SearchItem;
m_item->setSearchList(type, list); m_item->setSearchList(type, list);
m_model->setItem(m_item); m_model->setItem(m_item);
@ -40,7 +40,7 @@ SearchListView::SearchListView(QWidget * parent, const QStringList& list, const
this->setAttribute(Qt::WA_TranslucentBackground, true); this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setAutoFillBackground(false); this->setAutoFillBackground(false);
this->setStyleSheet("QWidget{background:transparent;}"); this->setStyleSheet("QWidget{background:transparent;}");
m_styleDelegate = new HighlightItemDelegate(); m_styleDelegate = new HighlightItemDelegate(this);
// m_styleDelegate->setSearchKeyword(keyword); // m_styleDelegate->setSearchKeyword(keyword);
this->setItemDelegate(m_styleDelegate); this->setItemDelegate(m_styleDelegate);

View File

@ -21,7 +21,7 @@
#include "search-item-model.h" #include "search-item-model.h"
#include <QDebug> #include <QDebug>
SearchItemModel::SearchItemModel() SearchItemModel::SearchItemModel(QObject *parent) : QAbstractItemModel (parent)
{ {
} }

View File

@ -32,7 +32,7 @@ class SearchItemModel : public QAbstractItemModel
friend class SearchItem; friend class SearchItem;
Q_OBJECT Q_OBJECT
public: public:
explicit SearchItemModel(); explicit SearchItemModel(QObject *parent = nullptr);
~SearchItemModel(); ~SearchItemModel();
enum SearchInfo { enum SearchInfo {