util/kconfig:xconf(QT): Update QT version of xconf

Update the qconf.cc and qconf.h to upstream code, which added support
of QT5 and removed the support of QT3.

All code is ported from kernel.org, with only one line added to qconf.cc.
int kconfig_warnings = 0;

Change-Id: Ice77cddcc00e43375039379978e55f42acf867f7
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>
Reviewed-on: https://review.coreboot.org/13130
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
zbao 2016-01-22 18:54:22 +08:00 committed by Stefan Reinauer
parent 420caafee8
commit 11a262c86c
3 changed files with 463 additions and 426 deletions

View File

@ -232,48 +232,20 @@ $(objk)/.tmp_qtcheck: $(srck)/Makefile
# QT needs some extra effort... # QT needs some extra effort...
$(objk)/.tmp_qtcheck: $(objk)/.tmp_qtcheck:
@set -e; echo " CHECK qt"; dir=""; pkg=""; \ @set -e; echo " CHECK qt"; dir=""; pkg=""; \
if ! pkg-config --exists QtCore 2> /dev/null; then \ if pkg-config --exists Qt5Core; then \
echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \ cflags="-std=c++11 -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets`"; \
pkg-config --exists qt 2> /dev/null && pkg=qt; \ libs=`pkg-config --libs Qt5Core Qt5Gui Qt5Widgets`; \
pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \ moc=`pkg-config --variable=host_bins Qt5Core`/moc; \
if [ -n "$$pkg" ]; then \ elif pkg-config --exists QtCore; then \
cflags="\$$(shell pkg-config $$pkg --cflags)"; \ cflags=`pkg-config --cflags QtCore QtGui`; \
libs="\$$(shell pkg-config $$pkg --libs)"; \ libs=`pkg-config --libs QtCore QtGui`; \
moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \ moc=`pkg-config --variable=moc_location QtCore`; \
dir="$$(pkg-config $$pkg --variable=prefix)"; \
else \
for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
done; \
if [ -z "$$dir" ]; then \
echo >&2 "*"; \
echo >&2 "* Unable to find any QT installation. Please make sure that"; \
echo >&2 "* the QT4 or QT3 development package is correctly installed and"; \
echo >&2 "* either qmake can be found or install pkg-config or set"; \
echo >&2 "* the QTDIR environment variable to the correct location."; \
echo >&2 "*"; \
false; \
fi; \
libpath=$$dir/lib; lib=qt; osdir=""; \
$(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
test -f $$libpath/libqt-mt.so && lib=qt-mt; \
cflags="-I$$dir/include"; \
libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
moc="$$dir/bin/moc"; \
fi; \
if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
echo "*"; \
echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
echo "*"; \
moc="/usr/bin/moc"; \
fi; \
else \ else \
cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \ echo >&2 "*"; \
libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \ echo >&2 "* Could not find Qt via pkg-config."; \
moc="\$$(shell pkg-config QtCore --variable=moc_location)"; \ echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"; \
[ -n "$$moc" ] || moc="\$$(shell pkg-config QtCore --variable=prefix)/bin/moc"; \ echo >&2 "*"; \
exit 1; \
fi; \ fi; \
echo "KC_QT_CFLAGS=$$cflags" > $@; \ echo "KC_QT_CFLAGS=$$cflags" > $@; \
echo "KC_QT_LIBS=$$libs" >> $@; \ echo "KC_QT_LIBS=$$libs" >> $@; \

File diff suppressed because it is too large Load Diff

View File

@ -3,26 +3,18 @@
* Released under the terms of the GNU GPL v2.0. * Released under the terms of the GNU GPL v2.0.
*/ */
#if QT_VERSION < 0x040000 #include <QTextBrowser>
#include <qlistview.h> #include <QTreeWidget>
#else #include <QMainWindow>
#include <q3listview.h> #include <QHeaderView>
#endif
#include <qsettings.h> #include <qsettings.h>
#include <QPushButton>
#if QT_VERSION < 0x040000 #include <QSettings>
#define Q3ValueList QValueList #include <QLineEdit>
#define Q3PopupMenu QPopupMenu #include <QSplitter>
#define Q3ListView QListView #include <QCheckBox>
#define Q3ListViewItem QListViewItem #include <QDialog>
#define Q3VBox QVBox #include "expr.h"
#define Q3TextBrowser QTextBrowser
#define Q3MainWindow QMainWindow
#define Q3Action QAction
#define Q3ToolBar QToolBar
#define Q3ListViewItemIterator QListViewItemIterator
#define Q3FileDialog QFileDialog
#endif
class ConfigView; class ConfigView;
class ConfigList; class ConfigList;
@ -33,8 +25,8 @@ class ConfigMainWindow;
class ConfigSettings : public QSettings { class ConfigSettings : public QSettings {
public: public:
ConfigSettings(); ConfigSettings();
Q3ValueList<int> readSizes(const QString& key, bool *ok); QList<int> readSizes(const QString& key, bool *ok);
bool writeSizes(const QString& key, const Q3ValueList<int>& value); bool writeSizes(const QString& key, const QList<int>& value);
}; };
enum colIdx { enum colIdx {
@ -47,9 +39,9 @@ enum optionMode {
normalOpt = 0, allOpt, promptOpt normalOpt = 0, allOpt, promptOpt
}; };
class ConfigList : public Q3ListView { class ConfigList : public QTreeWidget {
Q_OBJECT Q_OBJECT
typedef class Q3ListView Parent; typedef class QTreeWidget Parent;
public: public:
ConfigList(ConfigView* p, const char *name = 0); ConfigList(ConfigView* p, const char *name = 0);
void reinit(void); void reinit(void);
@ -61,10 +53,10 @@ public:
protected: protected:
void keyPressEvent(QKeyEvent *e); void keyPressEvent(QKeyEvent *e);
void contentsMousePressEvent(QMouseEvent *e); void mousePressEvent(QMouseEvent *e);
void contentsMouseReleaseEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e);
void contentsMouseMoveEvent(QMouseEvent *e); void mouseMoveEvent(QMouseEvent *e);
void contentsMouseDoubleClickEvent(QMouseEvent *e); void mouseDoubleClickEvent(QMouseEvent *e);
void focusInEvent(QFocusEvent *e); void focusInEvent(QFocusEvent *e);
void contextMenuEvent(QContextMenuEvent *e); void contextMenuEvent(QContextMenuEvent *e);
@ -95,32 +87,23 @@ public:
} }
ConfigItem* firstChild() const ConfigItem* firstChild() const
{ {
return (ConfigItem *)Parent::firstChild(); return (ConfigItem *)children().first();
} }
int mapIdx(colIdx idx) void addColumn(colIdx idx)
{ {
return colMap[idx]; showColumn(idx);
}
void addColumn(colIdx idx, const QString& label)
{
colMap[idx] = Parent::addColumn(label);
colRevMap[colMap[idx]] = idx;
} }
void removeColumn(colIdx idx) void removeColumn(colIdx idx)
{ {
int col = colMap[idx]; hideColumn(idx);
if (col >= 0) {
Parent::removeColumn(col);
colRevMap[col] = colMap[idx] = -1;
}
} }
void setAllOpen(bool open); void setAllOpen(bool open);
void setParentMenu(void); void setParentMenu(void);
bool menuSkip(struct menu *); bool menuSkip(struct menu *);
template <class P> void updateMenuList(ConfigItem *parent, struct menu*);
void updateMenuList(P*, struct menu*); void updateMenuList(ConfigList *parent, struct menu*);
bool updateAll; bool updateAll;
@ -132,30 +115,26 @@ public:
enum listMode mode; enum listMode mode;
enum optionMode optMode; enum optionMode optMode;
struct menu *rootEntry; struct menu *rootEntry;
QColorGroup disabledColorGroup; QPalette disabledColorGroup;
QColorGroup inactivedColorGroup; QPalette inactivedColorGroup;
Q3PopupMenu* headerPopup; QMenu* headerPopup;
private:
int colMap[colNr];
int colRevMap[colNr];
}; };
class ConfigItem : public Q3ListViewItem { class ConfigItem : public QTreeWidgetItem {
typedef class Q3ListViewItem Parent; typedef class QTreeWidgetItem Parent;
public: public:
ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v) ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
: Parent(parent, after), menu(m), visible(v), goParent(false) : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
{ {
init(); init();
} }
ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
: Parent(parent, after), menu(m), visible(v), goParent(false) : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
{ {
init(); init();
} }
ConfigItem(Q3ListView *parent, ConfigItem *after, bool v) ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
: Parent(parent, after), menu(0), visible(v), goParent(true) : Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
{ {
init(); init();
} }
@ -166,33 +145,43 @@ public:
void testUpdateMenu(bool v); void testUpdateMenu(bool v);
ConfigList* listView() const ConfigList* listView() const
{ {
return (ConfigList*)Parent::listView(); return (ConfigList*)Parent::treeWidget();
} }
ConfigItem* firstChild() const ConfigItem* firstChild() const
{ {
return (ConfigItem *)Parent::firstChild(); return (ConfigItem *)Parent::child(0);
} }
ConfigItem* nextSibling() const ConfigItem* nextSibling()
{ {
return (ConfigItem *)Parent::nextSibling(); ConfigItem *ret = NULL;
ConfigItem *_parent = (ConfigItem *)parent();
if(_parent) {
ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1);
} else {
QTreeWidget *_treeWidget = treeWidget();
ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1);
}
return ret;
} }
void setText(colIdx idx, const QString& text) void setText(colIdx idx, const QString& text)
{ {
Parent::setText(listView()->mapIdx(idx), text); Parent::setText(idx, text);
} }
QString text(colIdx idx) const QString text(colIdx idx) const
{ {
return Parent::text(listView()->mapIdx(idx)); return Parent::text(idx);
} }
void setPixmap(colIdx idx, const QPixmap& pm) void setPixmap(colIdx idx, const QIcon &icon)
{ {
Parent::setPixmap(listView()->mapIdx(idx), pm); Parent::setIcon(idx, icon);
} }
const QPixmap* pixmap(colIdx idx) const const QIcon pixmap(colIdx idx) const
{ {
return Parent::pixmap(listView()->mapIdx(idx)); return icon(idx);
} }
void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); // TODO: Implement paintCell
ConfigItem* nextItem; ConfigItem* nextItem;
struct menu *menu; struct menu *menu;
@ -216,9 +205,9 @@ public:
ConfigItem *item; ConfigItem *item;
}; };
class ConfigView : public Q3VBox { class ConfigView : public QWidget {
Q_OBJECT Q_OBJECT
typedef class Q3VBox Parent; typedef class QWidget Parent;
public: public:
ConfigView(QWidget* parent, const char *name = 0); ConfigView(QWidget* parent, const char *name = 0);
~ConfigView(void); ~ConfigView(void);
@ -249,9 +238,9 @@ public:
static QAction *showPromptAction; static QAction *showPromptAction;
}; };
class ConfigInfoView : public Q3TextBrowser { class ConfigInfoView : public QTextBrowser {
Q_OBJECT Q_OBJECT
typedef class Q3TextBrowser Parent; typedef class QTextBrowser Parent;
public: public:
ConfigInfoView(QWidget* parent, const char *name = 0); ConfigInfoView(QWidget* parent, const char *name = 0);
bool showDebug(void) const { return _showDebug; } bool showDebug(void) const { return _showDebug; }
@ -271,8 +260,8 @@ protected:
QString debug_info(struct symbol *sym); QString debug_info(struct symbol *sym);
static QString print_filter(const QString &str); static QString print_filter(const QString &str);
static void expr_print_help(void *data, struct symbol *sym, const char *str); static void expr_print_help(void *data, struct symbol *sym, const char *str);
Q3PopupMenu* createPopupMenu(const QPoint& pos); QMenu *createStandardContextMenu(const QPoint & pos);
void contentsContextMenuEvent(QContextMenuEvent *e); void contextMenuEvent(QContextMenuEvent *e);
struct symbol *sym; struct symbol *sym;
struct menu *_menu; struct menu *_menu;
@ -299,10 +288,10 @@ protected:
struct symbol **result; struct symbol **result;
}; };
class ConfigMainWindow : public Q3MainWindow { class ConfigMainWindow : public QMainWindow {
Q_OBJECT Q_OBJECT
static Q3Action *saveAction; static QAction *saveAction;
static void conf_changed(void); static void conf_changed(void);
public: public:
ConfigMainWindow(void); ConfigMainWindow(void);
@ -331,8 +320,11 @@ protected:
ConfigView *configView; ConfigView *configView;
ConfigList *configList; ConfigList *configList;
ConfigInfoView *helpText; ConfigInfoView *helpText;
Q3ToolBar *toolBar; QToolBar *toolBar;
Q3Action *backAction; QAction *backAction;
QSplitter* split1; QAction *singleViewAction;
QSplitter* split2; QAction *splitViewAction;
QAction *fullViewAction;
QSplitter *split1;
QSplitter *split2;
}; };