44#include " layoutmodel.h"
55#include " evdev-lst-layouts.h"
66
7- Layout::Layout (QString code, QString desc)
8- {
9- m_code = code;
10- m_desc = desc;
11- }
12-
13- Layout::~Layout () { }
14-
157LayoutModel::LayoutModel (QObject *parent) : QAbstractListModel(parent)
168{
179 QString xkb_default_layout = environmentGet (" XKB_DEFAULT_LAYOUT" );
@@ -50,9 +42,9 @@ LayoutModel::~LayoutModel() { }
5042QString LayoutModel::getXkbDefaultLayout ()
5143{
5244 QString ret;
53- QVectorIterator<QSharedPointer<Layout >> iter (m_layouts);
45+ QVectorIterator<QSharedPointer<Pair >> iter (m_layouts);
5446 while (iter.hasNext ()) {
55- ret += iter.next ().get ()->code ();
47+ ret += iter.next ().get ()->value ();
5648 if (iter.hasNext ()) {
5749 ret += " ," ;
5850 }
@@ -74,7 +66,7 @@ QVariant LayoutModel::data(const QModelIndex &index, int role) const
7466 const int row = index.row ();
7567 switch (role) {
7668 case Qt::DisplayRole:
77- return m_layouts.at (row)->desc () + " [" + m_layouts.at (row)->code () + " ]" ;
69+ return m_layouts.at (row)->description () + " [" + m_layouts.at (row)->value () + " ]" ;
7870 }
7971 return {};
8072}
@@ -87,15 +79,15 @@ void LayoutModel::update(void)
8779
8880void LayoutModel::addLayout (const QString &code, const QString &desc)
8981{
90- QVectorIterator<QSharedPointer<Layout >> iter (m_layouts);
82+ QVectorIterator<QSharedPointer<Pair >> iter (m_layouts);
9183 while (iter.hasNext ()) {
92- if (iter.next ().get ()->code () == code) {
84+ if (iter.next ().get ()->value () == code) {
9385 qDebug () << " cannot add the same layout twice" ;
9486 return ;
9587 }
9688 }
9789
98- m_layouts.append (QSharedPointer<Layout >(new Layout (code, desc)));
90+ m_layouts.append (QSharedPointer<Pair >(new Pair (code, desc)));
9991 update ();
10092}
10193
0 commit comments