[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kde-workspace/previewsoc13] kcontrol/keyboard: clean up - removed preview without boost and other m
From:       shivam makkar <amourphious1992 () gmail ! com>
Date:       2013-08-31 17:40:07
Message-ID: E1VFp9b-0006tl-Te () scm ! kde ! org
[Download RAW message or body]

Git commit 5b7e22ac070b37a4af89d14991b9b6d7b3c43d88 by shivam makkar.
Committed on 31/08/2013 at 17:39.
Pushed by makkar into branch 'previewsoc13'.

clean up - removed preview without boost and other minor changes

M  +8    -10   kcontrol/keyboard/CMakeLists.txt
M  +7    -1    kcontrol/keyboard/kcm_add_layout_dialog.cpp
M  +3    -2    kcontrol/keyboard/kcm_add_layout_dialog.h
M  +11   -3    kcontrol/keyboard/kcm_keyboard_widget.cpp
M  +2    -0    kcontrol/keyboard/kcm_keyboard_widget.h
M  +8    -9    kcontrol/keyboard/preview/geometry_components.cpp
M  +40   -1    kcontrol/keyboard/preview/geometry_parser.cpp
M  +49   -22   kcontrol/keyboard/preview/geometry_parser.h
M  +32   -2    kcontrol/keyboard/preview/kbpreviewframe.cpp
M  +3    -18   kcontrol/keyboard/preview/kbpreviewframe.h
D  +0    -392  kcontrol/keyboard/preview/kbpreviewframe_old.cpp
M  +1    -1    kcontrol/keyboard/preview/keyaliases.cpp
M  +67   -166  kcontrol/keyboard/preview/keyboardlayout.cpp
M  +49   -24   kcontrol/keyboard/preview/keyboardlayout.h
D  +0    -87   kcontrol/keyboard/preview/keyboardlayout_new.cpp
D  +0    -75   kcontrol/keyboard/preview/keyboardlayout_new.h
M  +39   -14   kcontrol/keyboard/preview/symbol_parser.cpp
M  +5    -3    kcontrol/keyboard/preview/symbol_parser.h

http://commits.kde.org/kde-workspace/5b7e22ac070b37a4af89d14991b9b6d7b3c43d88

diff --git a/kcontrol/keyboard/CMakeLists.txt b/kcontrol/keyboard/CMakeLists.txt
index 6c51586..c9a0ae3 100644
--- a/kcontrol/keyboard/CMakeLists.txt
+++ b/kcontrol/keyboard/CMakeLists.txt
@@ -111,13 +111,17 @@ if(Boost_FOUND)
     preview/geometry_components.cpp
     preview/geometry_parser.cpp
     preview/kbpreviewframe.cpp
-    preview/keyboardlayout_new.cpp
-    preview/symbol_parser.cpp)
+    preview/keyboardlayout.cpp
+    preview/symbol_parser.cpp
+    preview/keyaliases.cpp
+    preview/keyboardlayout.cpp
+    preview/keyboardpainter.cpp
+    preview/keysymbols.cpp
+    preview/keysymhelper.cpp
+    preview/keysym2ucs.cpp)
   
 else(Boost_FOUND)
   message("Boost not found, Install Boost Libraries to enable keyboard geometry \
                preview.")
-  set(preview_SRCS
-  preview/kbpreviewframe_old.cpp)
   
 
 endif(Boost_FOUND)
@@ -136,12 +140,6 @@ set(kcm_keyboard_PART_SRCS
     iso_codes.cpp
     kcmmisc.cpp
     bindings.cpp
-    preview/keyaliases.cpp
-    preview/keyboardlayout.cpp
-    preview/keyboardpainter.cpp
-    preview/keysymbols.cpp
-    preview/keysymhelper.cpp
-    preview/keysym2ucs.cpp
     ${preview_SRCS} )
 
 
diff --git a/kcontrol/keyboard/kcm_add_layout_dialog.cpp \
b/kcontrol/keyboard/kcm_add_layout_dialog.cpp index 29ca074..d893308 100644
--- a/kcontrol/keyboard/kcm_add_layout_dialog.cpp
+++ b/kcontrol/keyboard/kcm_add_layout_dialog.cpp
@@ -66,7 +66,12 @@ AddLayoutDialog::AddLayoutDialog(const Rules* rules_, Flags* \
flags_, bool showLa  languageChanged(0);
     connect(layoutDialogUi->languageComboBox, SIGNAL(activated(int)), this, \
                SLOT(languageChanged(int)));
     connect(layoutDialogUi->layoutComboBox, SIGNAL(activated(int)), this, \
SLOT(layoutChanged(int))); +
+#ifdef NEW_GEOMETRY
     connect(layoutDialogUi->prevbutton,SIGNAL(clicked()),this,SLOT(preview()));
+#endif
+    layoutDialogUi->prevbutton->setEnabled(false);
+
 }
 
 void AddLayoutDialog::languageChanged(int langIdx)
@@ -153,7 +158,7 @@ void AddLayoutDialog::accept()
 	QDialog::accept();
 }
 
-
+#ifdef NEW_GEOMETRY
 void AddLayoutDialog::preview(){
     int index = layoutDialogUi->variantComboBox->currentIndex();
     QString variant = layoutDialogUi->variantComboBox->itemData(index).toString();
@@ -165,3 +170,4 @@ void AddLayoutDialog::preview(){
 
     delete layoutPreview;
 }
+#endif
diff --git a/kcontrol/keyboard/kcm_add_layout_dialog.h \
b/kcontrol/keyboard/kcm_add_layout_dialog.h index 5273347..edf4336 100644
--- a/kcontrol/keyboard/kcm_add_layout_dialog.h
+++ b/kcontrol/keyboard/kcm_add_layout_dialog.h
@@ -43,8 +43,9 @@ public:
 public Q_SLOTS:
 	void languageChanged(int langIdx);
 	void layoutChanged(int layoutIdx);
-	void preview();
-
+#ifdef NEW_GEOMETRY
+    void preview();
+#endif
 private:
 	const Rules* rules;
 	Flags* flags;
diff --git a/kcontrol/keyboard/kcm_keyboard_widget.cpp \
b/kcontrol/keyboard/kcm_keyboard_widget.cpp index 8922dc6..ede5ce6 100644
--- a/kcontrol/keyboard/kcm_keyboard_widget.cpp
+++ b/kcontrol/keyboard/kcm_keyboard_widget.cpp
@@ -33,7 +33,9 @@
 #include <QtGui/QX11Info>
 
 #include "keyboard_config.h"
+#ifdef NEW_GEOMETRY
 #include "preview/keyboardpainter.h"
+#endif
 #include "xkb_rules.h"
 #include "flags.h"
 #include "x11_helper.h"
@@ -336,7 +338,9 @@ void KCMKeyboardWidget::initializeLayoutsUI()
 	connect(uiWidget->moveUpBtn, SIGNAL(clicked(bool)), this, SLOT(moveUp()));
 	connect(uiWidget->moveDownBtn, SIGNAL(clicked(bool)), this, SLOT(moveDown()));
 
+#ifdef NEW_GEOMETRY
     connect(uiWidget->previewbutton,SIGNAL(clicked(bool)),this,SLOT(previewLayout()));
 +#endif
 
 	connect(uiWidget->xkbGrpClearBtn, SIGNAL(clicked(bool)), this, \
SLOT(clearGroupShortcuts()));  connect(uiWidget->xkb3rdLevelClearBtn, \
SIGNAL(clicked(bool)), this, SLOT(clear3rdLevelShortcuts())); @@ -362,7 +366,7 @@ \
void KCMKeyboardWidget::initializeLayoutsUI()  \
connect(uiWidget->layoutLoopingCheckBox, SIGNAL(clicked(bool)), this, \
SLOT(uiChanged()));  connect(uiWidget->layoutLoopCountSpinBox, \
SIGNAL(valueChanged(int)), this, SLOT(uiChanged()));  }
-
+#ifdef NEW_GEOMETRY
 void KCMKeyboardWidget::previewLayout(){
     QMessageBox q;
     QModelIndex index = uiWidget->layoutsTableView->currentIndex() ;
@@ -392,7 +396,7 @@ void KCMKeyboardWidget::previewLayout(){
         layoutPreview->setModal(true);
     }
 }
-
+#endif
 void KCMKeyboardWidget::configureLayoutsChanged()
 {
 	if( uiWidget->layoutsGroupBox->isChecked()	&& keyboardConfig->layouts.isEmpty() ) {
@@ -421,8 +425,12 @@ void KCMKeyboardWidget::layoutSelectionChanged()
 	uiWidget->removeLayoutBtn->setEnabled( ! selected.isEmpty() );
 	QPair<int, int> rowsRange( getSelectedRowRange(selected) );
 	uiWidget->moveUpBtn->setEnabled( ! selected.isEmpty() && rowsRange.first > 0);
+#ifdef NEW_GEOMETRY
     uiWidget->previewbutton->setEnabled(! selected.isEmpty());
-	uiWidget->moveDownBtn->setEnabled( ! selected.isEmpty() && rowsRange.second < \
keyboardConfig->layouts.size()-1 ); +#else
+    uiWidget->previewbutton->setEnabled(false);
+#endif
+    uiWidget->moveDownBtn->setEnabled( ! selected.isEmpty() && rowsRange.second < \
keyboardConfig->layouts.size()-1 );  }
 
 void KCMKeyboardWidget::removeLayout()
diff --git a/kcontrol/keyboard/kcm_keyboard_widget.h \
b/kcontrol/keyboard/kcm_keyboard_widget.h index 58256df..e58aa46 100644
--- a/kcontrol/keyboard/kcm_keyboard_widget.h
+++ b/kcontrol/keyboard/kcm_keyboard_widget.h
@@ -68,7 +68,9 @@ private Q_SLOTS:
     void moveDown();
     void configureLayoutsChanged();
     void configureXkbOptionsChanged();
+#ifdef NEW_GEOMETRY
     void previewLayout();
+#endif
 
 private:
     Rules *rules;
diff --git a/kcontrol/keyboard/preview/geometry_components.cpp \
b/kcontrol/keyboard/preview/geometry_components.cpp index 1d8b69e..219b57b 100644
--- a/kcontrol/keyboard/preview/geometry_components.cpp
+++ b/kcontrol/keyboard/preview/geometry_components.cpp
@@ -14,8 +14,8 @@ void GShape::setCordinate(double a, double b){
 }
 
 void GShape::setApprox(double a, double b){
-    a-=approx.x();
-    b-=approx.y();
+    a -= approx.x();
+    b -= approx.y();
     approx = QPoint(a,b);
 }
 
@@ -33,7 +33,6 @@ void GShape::display(){
     qDebug()<<"( "<<approx.x()<<", "<<approx.y()<<"); ";
     for(int i=0;i<cordi_count;i++)
         qDebug()<<cordii[i];
-    qDebug()<<"\n";
 }
 
 double GShape::size(int vertical) const{
@@ -61,7 +60,7 @@ void Key::setKeyPosition(double x, double y){
 
 void Key::showKey(){
     qDebug()<<"\n\tKey: "<<name<<"\tshape: "<<shapeName<<"\toffset: "<<offset;
-    qDebug()<<"\tposition"<<position<<"\n";
+    qDebug()<<"\tposition"<<position;
 }
 
 
@@ -75,7 +74,7 @@ Row::Row(){
 
 
 void Row::addKey(){
-    qDebug() << "keyCount: "<<keyCount;
+    //qDebug() << "keyCount: "<<keyCount;
     keyCount++;
     keyList << Key();
 }
@@ -100,14 +99,14 @@ Section::Section(){
 }
 
 void Section::addRow(){
-    qDebug()<<"\nrowCount: "<<rowCount;
+    //qDebug()<<"\nrowCount: "<<rowCount;
     rowCount++;
     rowList << Row();
 }
 
 void Section::displaySection(){
-    qDebug()<<"\nSection: "<<name<<"\n\tposition: \
                ("<<left<<","<<top<<");"<<angle<<"\n";
-    qDebug()<<"vertical: "<<vertical;
+    //qDebug()<<"\nSection: "<<name<<"\n\tposition: \
("<<left<<","<<top<<");"<<angle<<"\n"; +    //qDebug()<<"vertical: "<<vertical;
     for(int i=0;i<rowCount;i++){
             qDebug()<<"\n\t";
             rowList[i].displayRow();
@@ -160,7 +159,7 @@ void Geometry::display(){
 }
 
 void Geometry::addSection(){
-    qDebug()<<"\nsectionCount: "<<sectionCount;
+    //qDebug()<<"\nsectionCount: "<<sectionCount;
     sectionCount++;
     sectionList << Section();
 }
diff --git a/kcontrol/keyboard/preview/geometry_parser.cpp \
b/kcontrol/keyboard/preview/geometry_parser.cpp index 7968242..6882e7d 100644
--- a/kcontrol/keyboard/preview/geometry_parser.cpp
+++ b/kcontrol/keyboard/preview/geometry_parser.cpp
@@ -30,6 +30,7 @@ keywords::keywords(){
 
 template<typename Iterator>
 Geometry_parser<Iterator>::Geometry_parser():Geometry_parser::base_type(start){
+
     using qi::lexeme;
     using qi::char_;
     using qi::lit;
@@ -253,6 +254,8 @@ template<typename Iterator>
         cy = geom.sectionList[geom.getSectionCount()].rowList[geom.sectionList[geom.getSectionCount()].getRowCount()].getTop();
  geom.sectionList[geom.getSectionCount()].rowList[geom.sectionList[geom.getSectionCou \
nt()].getRowCount()].setVertical(geom.sectionList[geom.getSectionCount()].getVertical());
  }
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::sectioninit(){
         geom.sectionList[geom.getSectionCount()].setTop(geom.sectionTop);
@@ -262,22 +265,33 @@ template<typename Iterator>
         geom.sectionList[geom.getSectionCount()].setShapeName(geom.getKeyShape());
         geom.sectionList[geom.getSectionCount()].setVertical(geom.getVertical());
     }
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setRowTop(double a){
         geom.sectionList[geom.getSectionCount()].rowList[geom.sectionList[geom.getSectionCount()].getRowCount()].setTop(a \
                + geom.sectionList[geom.getSectionCount()].getTop());
         cy = geom.sectionList[geom.getSectionCount()].rowList[geom.sectionList[geom.getSectionCount()].getRowCount()].getTop();
  }
+
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setRowLeft(double a){
         geom.sectionList[geom.getSectionCount()].rowList[geom.sectionList[geom.getSectionCount()].getRowCount()].setLeft(a \
                + geom.sectionList[geom.getSectionCount()].getLeft());
         cx = geom.sectionList[geom.getSectionCount()].rowList[geom.sectionList[geom.getSectionCount()].getRowCount()].getLeft();
  }
+
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setSectionTop(double a){
         //qDebug()<<"\nsectionCount"<<geom.sectionCount;
         geom.sectionList[geom.getSectionCount()].setTop(a + geom.sectionTop);
         cy = geom.sectionList[geom.getSectionCount()].getTop();
     }
+
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setSectionLeft(double a){
         //qDebug()<<"\nsectionCount"<<geom.sectionCount;
@@ -285,24 +299,36 @@ template<typename Iterator>
         cx = geom.sectionList[geom.getSectionCount()].getLeft();
 
     }
+
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setSectionAngle(double a){
         //qDebug()<<"\nsectionCount"<<geom.sectionCount;
         geom.sectionList[geom.getSectionCount()].setAngle(a);
     }
+
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setVerticalRow(){
         geom.sectionList[geom.getSectionCount()].rowList[geom.sectionList[geom.getSectionCount()].getRowCount()].setVertical(1);
  }
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setVerticalSection(){
         geom.sectionList[geom.getSectionCount()].setVertical(1);
     }
+
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setVerticalGeometry(){
         geom.setVertical(1);
     }
 
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setKeyName(std::string n){
         int secn = geom.getSectionCount();
@@ -311,6 +337,9 @@ template<typename Iterator>
         //qDebug()<<"\nsC: "<<secn<<"\trC: "<<rown<<"\tkn: "<<keyn;
         geom.sectionList[secn].rowList[rown].keyList[keyn].setKeyName(QString::fromUtf8(n.data(), \
n.size()));  }
+
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setKeyShape(std::string n){
         int secn = geom.getSectionCount();
@@ -319,6 +348,9 @@ template<typename Iterator>
         //qDebug()<<"\nsC: "<<secn<<"\trC: "<<rown<<"\tkn: "<<keyn;
         geom.sectionList[secn].rowList[rown].keyList[keyn].setShapeName(QString::fromUtf8(n.data(), \
n.size()));  }
+
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setKeyNameandShape(std::string n){
         int secn = geom.getSectionCount();
@@ -326,6 +358,9 @@ template<typename Iterator>
         setKeyName(n);
         setKeyShape(geom.sectionList[secn].rowList[rown].getShapeName().toUtf8().constData());
  }
+
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setKeyOffset(){
         //qDebug()<<"\nhere\n";
@@ -335,6 +370,9 @@ template<typename Iterator>
         //qDebug()<<"\nsC: "<<secn<<"\trC: "<<rown<<"\tkn: "<<keyn;
         geom.sectionList[secn].rowList[rown].keyList[keyn].setOffset(off);
     }
+
+
+
 template<typename Iterator>
     void Geometry_parser<Iterator>::setKeyCordi(){
         int secn = geom.getSectionCount();
@@ -358,6 +396,7 @@ template<typename Iterator>
         geom.sectionList[secn].rowList[rown].addKey();
     }
 
+
     QString mapModelToGeometry(QString model){
         QStringList pcmodels;
         QStringList msmodels;
@@ -447,7 +486,7 @@ template<typename Iterator>
         Geometry_parser g;
 
         QString geometry = mapModelToGeometry(model);
-        qDebug()<<geometry;
+        //qDebug()<<geometry;
         QStringList mapedModel = geometry.split('|');
         QString geometryfile = mapedModel.at(0);
         QString geometryName = mapedModel.at(1);
diff --git a/kcontrol/keyboard/preview/geometry_parser.h \
b/kcontrol/keyboard/preview/geometry_parser.h index 9beed17..ed13270 100644
--- a/kcontrol/keyboard/preview/geometry_parser.h
+++ b/kcontrol/keyboard/preview/geometry_parser.h
@@ -1,7 +1,6 @@
 #ifndef GEOMETRY_PARSER_H
 #define GEOMETRY_PARSER_H
 
-
 #include <boost/config/warning_disable.hpp>
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
@@ -14,6 +13,7 @@
 #include <boost/spirit/include/phoenix_bind.hpp>
 #include <boost/spirit/home/support/char_encoding/iso8859_1.hpp>
 
+
 #include <iostream>
 #include <QtCore/QDebug>
 
@@ -33,25 +33,46 @@ namespace grammar{
   
   template<typename Iterator>
   struct Geometry_parser :qi::grammar<Iterator, iso::space_type>{
+
+    //comments
+    qi::rule<Iterator, std::string(), iso::space_type>comments,ignore;
+    qi::rule<Iterator, double(), iso::space_type>localDimension,priority;
+
+    //general non-temrminals
     qi::rule<Iterator, std::string(), iso::space_type>name;
     qi::rule<Iterator, std::string(), iso::space_type>description;
     qi::rule<Iterator, std::string(), iso::space_type>in;
-    qi::rule<Iterator, int(), iso::space_type>setap;
     qi::rule<Iterator, std::string(), iso::space_type>info;
+
+    //non-teminals for shape
+    qi::rule<Iterator, int(), iso::space_type>shape;
+    qi::rule<Iterator, int(), iso::space_type>shapeDef;
+    qi::rule<Iterator, int(), iso::space_type>shapeC;
+    qi::rule<Iterator, int(), iso::space_type>set;
+    qi::rule<Iterator, int(), iso::space_type>setap;
+    qi::rule<Iterator, int(), iso::space_type>seta;
+    qi::rule<Iterator, int(), iso::space_type>cornerRadius;
+    qi::rule<Iterator, int(), iso::space_type>cordinatea;
+    qi::rule<Iterator, int(), iso::space_type>cordinates;
+
+    //non-teminals for key
+    qi::rule<Iterator, double(), iso::space_type>keygap;
     qi::rule<Iterator, std::string(), iso::space_type>keyName;
     qi::rule<Iterator, std::string(), iso::space_type>keyShape;
     qi::rule<Iterator, std::string(), iso::space_type>keyColor;
     qi::rule<Iterator, std::string(), iso::space_type>keyDesc;
     qi::rule<Iterator, std::string(), iso::space_type>keys;
+
     qi::rule<Iterator, std::string(), iso::space_type>row;
-    qi::rule<Iterator, std::string(), iso::space_type>geomShape;
+
     qi::rule<Iterator, std::string(), iso::space_type>section;
+
+    //non-teminals related to local data
     qi::rule<Iterator, std::string(), iso::space_type>localShape;
     qi::rule<Iterator, std::string(), iso::space_type>localColor;
-    qi::rule<Iterator, std::string(), iso::space_type>comments,ignore;
-    qi::rule<Iterator, double(), iso::space_type>localDimension,priority;
-    qi::rule<Iterator, double(), iso::space_type>keygap;
-    qi::rule<Iterator, int(), iso::space_type>cordinatea;
+
+    //Geometry non-terminals
+    qi::rule<Iterator, std::string(), iso::space_type>geomShape;
     qi::rule<Iterator, int(), iso::space_type>geomTop,geomVertical;
     qi::rule<Iterator, int(), iso::space_type>geomLeft;
     qi::rule<Iterator, int(), iso::space_type>geomRowTop;
@@ -63,40 +84,46 @@ namespace grammar{
     qi::rule<Iterator, int(), iso::space_type>left;
     qi::rule<Iterator, int(), iso::space_type>width;
     qi::rule<Iterator, int(), iso::space_type>height;
-    qi::rule<Iterator, int(), iso::space_type>cordinates;
-    qi::rule<Iterator, int(), iso::space_type>set;
-    qi::rule<Iterator, int(), iso::space_type>seta;
-    qi::rule<Iterator, int(), iso::space_type>shape;
-    qi::rule<Iterator, int(), iso::space_type>shapeDef;
-    qi::rule<Iterator, int(), iso::space_type>shapeC;
-    qi::rule<Iterator, int(), iso::space_type>cornerRadius;
+
     qi::rule<Iterator, iso::space_type>start;
     Geometry geom;
     keywords kw;
     double x,y,ax,ay,cx,cy,off;
     Geometry_parser();
+
+    //funcions for shape
+    void getShapeName(std::string n);
     void setCord();
-    void setSectionShape(std::string n);
-    void setRowShape(std::string n);
     void setApprox();
-    void addRow();
+
+    //functions for section
     void sectionName(std::string n);
-    void rowinit();
-    void sectioninit();
-    void setRowTop(double a);
-    void setRowLeft(double a);
+    void setSectionShape(std::string n);
     void setSectionTop(double a);
     void setSectionLeft(double a);
     void setSectionAngle(double a);
+    void sectioninit();
+
+    //funtions for row
+    void setRowShape(std::string n);
+    void setRowTop(double a);
+    void setRowLeft(double a);
+    void rowinit();
+    void addRow();
+
+    //functions for key
     void setKeyName(std::string n);
     void setKeyShape(std::string n);
     void setKeyNameandShape(std::string n);
     void setKeyOffset();
     void setKeyCordi();
+
+    //functionsfor geometry
     void setGeomShape(std::string n);
     void getName(std::string n);
     void getDescription(std::string n);
-    void getShapeName(std::string n);
+
+    //functions for alingment
     void setVerticalRow();
     void setVerticalSection();
     void setVerticalGeometry();
diff --git a/kcontrol/keyboard/preview/kbpreviewframe.cpp \
b/kcontrol/keyboard/preview/kbpreviewframe.cpp index b9378d3..91a6a46 100644
--- a/kcontrol/keyboard/preview/kbpreviewframe.cpp
+++ b/kcontrol/keyboard/preview/kbpreviewframe.cpp
@@ -21,7 +21,7 @@
 
 #include "geometry_parser.h"
 #include "geometry_components.h"
-#include "keyboardlayout_new.h"
+#include "keyboardlayout.h"
 #include "symbol_parser.h"
 
 #include <QtCore/QFile>
@@ -96,48 +96,70 @@ void KbPreviewFrame::drawKeySymbols(QPainter &painter,QPoint \
temp[], const GShap  void KbPreviewFrame::drawShape(QPainter &painter, const GShape& \
s,int x,int y,int i, const QString& name){  painter.setPen(Qt::black);
     int cordi_count = s.getCordi_count();
+
     if(geometry.sectionList[i].getAngle()==0){
         if (cordi_count == 1){
+
             int width = s.getCordii(0).x();
             int height = s.getCordii(0).y();
+
             painter.drawRoundedRect(scaleFactor*x+2,scaleFactor*y,scaleFactor*width,scaleFactor*height,4,4);
 +
             QPoint temp[4];
+
             temp[0]=QPoint(scaleFactor*x,scaleFactor*y);
             temp[1]=QPoint(scaleFactor*(s.getCordii(0).x()+x),scaleFactor*y);
             temp[2]=QPoint(scaleFactor*(s.getCordii(0).x()+x),scaleFactor*(s.getCordii(0).y()+y));
                
             temp[3]=QPoint(scaleFactor*(x),scaleFactor*(s.getCordii(0).y()+y));
+
             drawKeySymbols(painter,temp,s,name);
+
         }
+
         else{
+
             QPoint temp[cordi_count];
+
             for(int i=0;i<cordi_count;i++){
                 temp[i].setX(scaleFactor*(s.getCordii(i).x()+x+1));
                 temp[i].setY(scaleFactor*(s.getCordii(i).y()+y+1));
             }
+
             painter.drawPolygon(temp,cordi_count);
             drawKeySymbols(painter,temp,s,name);
         }
     }
+
     else{
+
         QPoint temp[cordi_count == 1 ? 4 : cordi_count];
         int size;
+
         if(cordi_count== 1){
+
             temp[0]=QPoint(x,y);
             temp[1]=QPoint(s.getCordii(0).x()+x,y);
             temp[2]=QPoint(s.getCordii(0).x()+x,s.getCordii(0).y()+y);
             temp[3]=QPoint(x,s.getCordii(0).y()+y);
             size = 4;
+
         }
+
         else{
+
             size = cordi_count;
+
             for(int i=0;i<cordi_count;i++){
                 temp[i].setX((s.getCordii(i).x()+x+1));
                 temp[i].setY((s.getCordii(i).y()+y+1));
             }
         }
+
         double refX,refY;
+
         refX = geometry.sectionList[i].getLeft();
         refY = geometry.sectionList[i].getTop();
+
         //qDebug()<<"\ntransform";
         for(int j=0;j<size;j++){
             double x = temp[j].x()-refX;
@@ -151,22 +173,29 @@ void KbPreviewFrame::drawShape(QPainter &painter, const GShape& \
s,int x,int y,in  //qDebug()<<"("<<x_<<","<<y_<<")\n";
             temp[j]=QPoint(scaleFactor*(x_+refX),scaleFactor*(y_+refY));
         }
+
         /*for(int i=0;i<size;i++){
             qDebug()<<temp[i];
         }*/
+
         painter.drawPolygon(temp,size);
         drawKeySymbols(painter,temp,s,name);
     }
 
+
 }
 
 bool KbPreviewFrame::event(QEvent* event){
+
     if (event->type() == QEvent::ToolTip) {
+
         QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
         int index = itemAt(helpEvent->pos());
+
         if (index != -1) {
             QToolTip::showText(helpEvent->globalPos(), tooltip.at(index));
         }
+
         else {
              QToolTip::hideText();
              event->ignore();
@@ -177,6 +206,7 @@ bool KbPreviewFrame::event(QEvent* event){
     return QWidget::event(event);
 }
 
+
 void KbPreviewFrame::paintEvent(QPaintEvent *)
 {
     QPainter painter(this);
@@ -196,7 +226,7 @@ void KbPreviewFrame::paintEvent(QPaintEvent *)
     scaleFactor = 1030/endx;
     if(scaleFactor<1)
         scaleFactor=1;
-    qDebug()<<"scaleFactor = "<<scaleFactor;
+    //qDebug()<<"scaleFactor = "<<scaleFactor;
     scaleFactor = 2.5;
     painter.drawRect(strtx, strty, scaleFactor*endx+60,scaleFactor*endy+60);
 
diff --git a/kcontrol/keyboard/preview/kbpreviewframe.h \
b/kcontrol/keyboard/preview/kbpreviewframe.h index f8a3ee3..eee708e 100644
--- a/kcontrol/keyboard/preview/kbpreviewframe.h
+++ b/kcontrol/keyboard/preview/kbpreviewframe.h
@@ -18,11 +18,7 @@
 #ifndef KBPREVIEWFRAME_H
 #define KBPREVIEWFRAME_H
 
-#ifdef NEW_GEOMETRY
-#include "keyboardlayout_new.h"
-#else
 #include "keyboardlayout.h"
-#endif
 
 #include "keysymhelper.h"
 #include "keyaliases.h"
@@ -32,10 +28,9 @@
 #include <QtCore/QHash>
 #include <QtGui/QToolTip>
 
-#ifdef NEW_GEOMETRY
 class Geometry;
 class GShape;
-#endif
+
 
 
 class KbPreviewFrame : public QFrame
@@ -48,23 +43,13 @@ private:
     QStringList tooltip;
     QList <QPoint> tipPoint;
     static const int width = 1100, height = 490;
-#ifdef NEW_GEOMETRY
+
     Geometry& geometry;
     void drawKeySymbols(QPainter &painter, QPoint temp[], const GShape& s, const \
QString& name);  float scaleFactor;
     KbLayout keyboardLayout;
     void drawShape(QPainter &painter, const GShape& s, int x, int y, int i, const \
                QString& name);
-#else
-    KeyboardLayout keyboardLayout;
-
-    void paintTLDE(QPainter &painter, int &x, int &y);
-    void paintAERow(QPainter &painter, int &x, int &y);
-    void paintADRow(QPainter &painter, int &x, int &y);
-    void paintACRow(QPainter &painter, int &x, int &y);
-    void paintABRow(QPainter &painter, int &x, int &y);
-    void paintBottomRow(QPainter &painter, int &x, int &y);
-    void paintFnKeys(QPainter &painter, int &x, int &y);
-#endif
+
 	
     int itemAt(const QPoint &pos);
 
diff --git a/kcontrol/keyboard/preview/kbpreviewframe_old.cpp \
b/kcontrol/keyboard/preview/kbpreviewframe_old.cpp deleted file mode 100644
index d7bcca0..0000000
--- a/kcontrol/keyboard/preview/kbpreviewframe_old.cpp
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- *  Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com)
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-
-#include "kbpreviewframe.h"
-#include "kbpreviewframe.moc"
-
-#include <QtCore/QFile>
-#include <QtGui/QFont>
-#include <QFileDialog>
-#include <math.h>
-
-#include <KApplication>
-#include <KLocale>
-
-
-
-KbPreviewFrame::KbPreviewFrame(QWidget *parent) :
-    QFrame(parent)
-{
-     setFrameStyle( QFrame::Box );
-     setFrameShadow(QFrame::Sunken);
-}
-
-
-KbPreviewFrame::~KbPreviewFrame() {
-
-}
-
-int KbPreviewFrame :: getWidth() const {return width;}
-int KbPreviewFrame :: getHeight() const {return height;}
-
-static const int keygap = 4, cornerRadius = 7;
-static const QColor keyBorderColor("#d4d4d4");
-static const QColor lev12color("#d4d4d4");
-static const QColor lev34color("#FF3300");
-static const int sz=20, kszx=70, kszy=70;
-
-static const int xOffset[] = {15, 15, 40, 40 };
-static const int yOffset[] = {10, 40, 10, 40 };
-static const QColor color[] = { lev12color, lev12color, lev34color, lev34color };
-
-void KbPreviewFrame::paintTLDE(QPainter &painter,int &x,int &y)
-{
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y, kszx, kszy,cornerRadius, cornerRadius);
-
-    const QList <QString> symbols = keyboardLayout.TLDE.symbols;
-
-    for(int level=0; level<symbols.size(); level++) {
-        painter.setPen(color[level]);
-        painter.drawText(x+xOffset[level], y+yOffset[level], sz, sz, Qt::AlignTop, \
                symbol.getKeySymbol(symbols.at(level)));
-    }
-
-}
-
-void KbPreviewFrame::paintAERow(QPainter &painter,int &x,int &y)
-{
-    paintTLDE(painter, x, y);
-
-    const int noAEk=12;
-    for(int i=0; i<noAEk; i++){
-        x+=kszx;
-        x+=keygap;
-
-        painter.setPen(keyBorderColor);
-        painter.drawRoundedRect(x, y, kszx, kszy,cornerRadius, cornerRadius);
-
-        QList<QString> symbols = keyboardLayout.AE[i].symbols;
-
-        for(int level=0; level<symbols.size(); level++) {
-            painter.setPen(color[level]);
-            painter.drawText(x+xOffset[level], y+yOffset[level], sz, sz, \
                Qt::AlignTop, symbol.getKeySymbol(symbols.at(level)));
-        }
-    }
-
-    x += kszx;
-    x += keygap;
-    const int bkspszx=100,bk1x=10;//,bk1y=20,
-    const int bk2y=60;
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y,bkspszx,kszy,cornerRadius, cornerRadius);
-
-    painter.setPen(lev12color);
-//    painter.drawText(x+bk1x, y+bk1y,i18n("<--"));
-    painter.drawText(x+bk1x, y+bk2y,i18n("Backspace"));
-}
-
-void KbPreviewFrame::paintADRow(QPainter &painter,int &x,int&y)
-{
-    const int noADk=12;
-    const int tabszx=100;
-    const int tab3y=45;
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y, tabszx,kszy,cornerRadius, cornerRadius);
-
-    painter.setPen(lev12color);
-//    painter.drawText(x+tab1x, y+tab1y,i18n("<--"));
-    painter.drawText(x+xOffset[0], y+tab3y, i18nc("Tab key", "Tab"));
-//    painter.drawText(x+tab2x, y+tab2y,i18n("-->"));
-    x+=tabszx;
-    x+=keygap;
-
-
-    for(int i=0; i<noADk; i++){
-        QList<QString> symbols = keyboardLayout.AD[i].symbols;
-
-        painter.setPen(keyBorderColor);
-        painter.drawRoundedRect(x, y,kszx,kszy,cornerRadius, cornerRadius);
-
-        for(int level=0; level<symbols.size(); level++) {
-            painter.setPen(color[level]);
-            painter.drawText(x+xOffset[level], y+yOffset[level], sz, sz, \
                Qt::AlignTop, symbol.getKeySymbol(symbols.at(level)));
-        }
-
-        x+=kszx;
-        x+=keygap;
-    }
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y,kszx,kszy,cornerRadius, cornerRadius);
-
-    QList<QString> symbols = keyboardLayout.BKSL.symbols;
-
-    for(int level=0; level<symbols.size(); level++) {
-        painter.setPen(color[level]);
-        painter.drawText(x+xOffset[level], y+yOffset[level], sz, sz, Qt::AlignTop, \
                symbol.getKeySymbol(symbols.at(level)));
-    }
-}
-
-void KbPreviewFrame::paintACRow(QPainter &painter,int &x,int &y)
-{
-    const int sz = 20, kszx = 70, kszy = 70, capszx = 100;
-    const int noACk = 11;
-    const int lvl2x = 40, shifx = 10, shify = 60, retsz = 140;
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y,capszx,kszy,cornerRadius, cornerRadius);
-
-    painter.setPen(lev12color);
-//    painter.drawText(x+shifx, y+sz,i18n("^"));
-    painter.drawText(x+shifx, y+shify,i18n("Caps Lock"));
-    x+=capszx;
-    x+=keygap;
-
-    for(int i=0; i<noACk; i++){
-        painter.setPen(keyBorderColor);
-        painter.drawRoundedRect(x, y,kszx,kszy, cornerRadius, cornerRadius);
-
-        QList<QString> symbols = keyboardLayout.AC[i].symbols;
-
-        for(int level=0; level<symbols.size(); level++) {
-            painter.setPen(color[level]);
-            painter.drawText(x+xOffset[level], y+yOffset[level], sz, sz, \
                Qt::AlignTop, symbol.getKeySymbol(symbols.at(level)));
-        }
-
-        x+=kszx;
-        x+=keygap;
-    }
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y,retsz,kszy,cornerRadius, cornerRadius);
-
-    painter.setPen(lev12color);
-//    painter.drawText(x+ret1x, y+ret1y,i18n("|"));
-//    painter.drawText(x+ret2x, y+ret2y,i18n("<--"));
-    painter.drawText(x+shify,y+lvl2x,i18n("Enter"));
-}
-
-void KbPreviewFrame::paintABRow(QPainter &painter,int &x,int &y)
-{
-    const int noABk=10;
-    for(int i=0; i<noABk; i++) {
-        painter.setPen(keyBorderColor);
-        painter.drawRoundedRect(x, y,kszx,kszy,cornerRadius, cornerRadius);
-
-        QList<QString> symbols = keyboardLayout.AB[i].symbols;
-
-        for(int level=0; level<symbols.size(); level++) {
-            painter.setPen(color[level]);
-            painter.drawText(x+xOffset[level], y+yOffset[level], sz, sz, \
                Qt::AlignTop, symbol.getKeySymbol(symbols.at(level)));
-        }
-
-        x+=kszx;
-        x+=keygap;
-    }
-}
-
-void KbPreviewFrame::paintBottomRow(QPainter &painter,int &x,int &y)
-{
-    const int txtx=30, txty=35, ctrlsz=100, altsz=100, spsz=400, kszy=70;
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y, ctrlsz, kszy, cornerRadius, cornerRadius);
-    painter.setPen(lev12color);
-    painter.drawText(x+txtx, y+txty,i18n("Ctrl"));
-
-    x+=ctrlsz;
-    x+=keygap;
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y, altsz, kszy, cornerRadius, cornerRadius);
-    painter.setPen(lev12color);
-    painter.drawText(x+txtx, y+txty,i18n("Alt"));
-
-    x+=altsz;
-    x+=keygap;
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y, spsz, kszy, cornerRadius, cornerRadius);
-
-    x+=spsz;
-    x+=keygap;
-
-    painter.drawRoundedRect(x, y, altsz, kszy,cornerRadius, cornerRadius);
-
-    painter.setPen(lev34color);
-    painter.drawText(x+txtx, y+txty,i18n("AltGr"));
-
-    x+=ctrlsz;
-    x+=keygap;
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y, ctrlsz, kszy, cornerRadius, cornerRadius);
-
-    painter.setPen(lev12color);
-    painter.drawText(x+txtx, y+txty, i18n("Ctrl"));
-}
-
-void KbPreviewFrame::paintFnKeys(QPainter &painter,int &x,int &y)
-{
-    const int escsz=50, escx=20, escy=55;
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y, escsz, escsz, cornerRadius, cornerRadius);
-
-    painter.setPen(lev12color);
-    painter.drawText(escx, escy, i18n("Esc"));
-
-    const int spacex=50;
-    x+=spacex;
-    x+=keygap;
-
-    const int fnkeyspace=60, fnkeysizex=50, fnkeysizey=50, fkc=15, fky=30, fnkig=4, \
                fng=3;
-    int f=1;
-
-    for(int i=0;i<fng;i++){
-        x+=spacex;
-        x+=keygap;
-
-        for(int j=0;j<fnkig;j++){
-            x += fnkeyspace;
-            painter.setPen(keyBorderColor);
-            painter.drawRoundedRect(x, y, fnkeysizex, fnkeysizey, cornerRadius, \
                cornerRadius);
-
-            painter.setPen(lev12color);
-            painter.drawText(x+fkc, y+fky, i18nc("Function key", "F%1", f));
-            f++;
-        }
-    }
-}
-
-void KbPreviewFrame::paintEvent(QPaintEvent *)
-{
-    QPainter painter(this);
-
-    QFont kbfont;
-    kbfont.setPointSize(12);
-
-    painter.setFont(kbfont);
-    painter.setBrush(QBrush(Qt::darkGray));
-
-    painter.setRenderHint(QPainter::Antialiasing);
-
-    const int strtx=0,strty=0,endx=1390,endy=490,kszy=70;
-    const int row1x=10,row1y=30,row2x=10,row2y=90,row5x=10,row5y=330,row3x=10,row3y=170,shifx=10,shify=60,row4x=10,row4y=250,row6x=110,row6y=410;
                
-    const int shiftsz=155;
-
-    painter.setPen(keyBorderColor);
-    painter.drawRect(strtx, strty, endx, endy);
-
-    painter.setPen(lev12color);
-    painter.setBrush(QBrush(Qt::black));
-
-    int x, y;
-    x=row1x;
-    y=row1y;
-
-    paintFnKeys(painter,x, y);
-
-    x=row2x;
-    y=row2y;
-
-    paintAERow(painter,x, y);
-
-    x=row3x;
-    y=row3y;
-
-    paintADRow(painter,x, y);
-
-    x=row4x;
-    y=row4y;
-
-    paintACRow(painter,x, y);
-
-    x=row5x;
-    y=row5y;
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y,shiftsz,kszy, cornerRadius, cornerRadius);
-    painter.setPen(lev12color);
-    painter.drawText(x+shifx, y+shify,i18n("Shift"));
-    x+=shiftsz;
-    x+=keygap;
-
-    paintABRow(painter,x, y);
-
-    painter.setPen(keyBorderColor);
-    painter.drawRoundedRect(x, y,shiftsz,kszy, cornerRadius, cornerRadius);
-    painter.setPen(lev12color);
-    painter.drawText(x+shifx, y+shify,i18n("Shift"));
-
-    x=row6x;
-    y=row6y;
-
-    paintBottomRow(painter,x, y);
-
-    if( symbol.isFailed() ) {
-        painter.setPen(keyBorderColor);
-        painter.drawRect(strtx, strty, endx, endy);
-
-        const int midx=470, midy=240;
-        painter.setPen(lev12color);
-        painter.drawText(midx, midy, i18n("No preview found"));
-    }
-
-}
-
-
-void KbPreviewFrame::generateKeyboardLayout(const QString& layout, const QString& \
                layoutVariant, const QString& model)
-{
-    QString filename = keyboardLayout.findSymbolBaseDir();
-    filename.append(layout);
-
-    QFile file(filename);
-    file.open(QIODevice::ReadOnly | QIODevice::Text);
-    QString content = file.readAll();
-    file.close();
-
-    QList<QString> symstr = content.split("xkb_symbols ");
-
-    if( layoutVariant.isEmpty() ) {
-        keyboardLayout.generateLayout(symstr.at(1), layout);
-    }
-    else {
-        for(int i=1;i<symstr.size();i++) {
-            QString h=symstr.at(i);
-            int k=h.indexOf("\"");
-            h=h.mid(k);
-            k=h.indexOf("{");
-            h=h.left(k);
-            h=h.remove(" ");
-            QString f="\"";
-            f.append(layoutVariant);
-            f.append("\"");
-            f=f.remove(" ");
-
-            if(h==f){
-                keyboardLayout.generateLayout(symstr.at(i), layout);
-                break;
-            }
-        }
-    }
-}
-
diff --git a/kcontrol/keyboard/preview/keyaliases.cpp \
b/kcontrol/keyboard/preview/keyaliases.cpp index 3eb45ec..b564595 100644
--- a/kcontrol/keyboard/preview/keyaliases.cpp
+++ b/kcontrol/keyboard/preview/keyaliases.cpp
@@ -89,7 +89,7 @@ QString Aliases::getAlias(const QString& cname, const QString& \
name)  {
     QMessageBox q;
     QString a=name;
-    if(cname=="ma"){
+    if(cname=="ma" || cname == "be" || cname == "fr"){
         a=azerty.value(name);
     }
     else{
diff --git a/kcontrol/keyboard/preview/keyboardlayout.cpp \
b/kcontrol/keyboard/preview/keyboardlayout.cpp index 6ac2f3f..86183d5 100644
--- a/kcontrol/keyboard/preview/keyboardlayout.cpp
+++ b/kcontrol/keyboard/preview/keyboardlayout.cpp
@@ -1,186 +1,87 @@
-/*
- *  Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com)
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
+ 
+#include "keyboardlayout.h"
 
+#include <QDebug>
+#include <QString>
+#include <QList>
 
-#include "keyboardlayout.h"
-#include "keysymbols.h"
+KbKey::KbKey(){
+    symbolCount = 0;
+    symbols << QString();
+}
 
-#include <QtGui/QMessageBox>
-#include <QtCore/QList>
-#include <QtCore/QFile>
-#include <QtCore/QDir>
+void KbKey::setKeyName(QString n){
+        keyName = n;
+}
+
+void KbKey::addSymbol(QString n, int i){
+    symbols[i] = n;
+    symbolCount++;
+    symbols << QString();
+}
 
-#include <QtGui/QX11Info>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/XKBlib.h>
-#include <X11/extensions/XKBrules.h>
-#include <fixx11h.h>
-#include <config-workspace.h>
 
+QString KbKey::getSymbol(int i){
+    if(i < symbolCount)
+        return symbols[i];
+    else
+        return QString();
+}
 
-//TODO: replace this with grammar parser (e.g. antlr)
+void KbKey::display(){
+    qDebug()<<keyName<<" : ";
+    for(int i=0; i<symbolCount; i++)
+        qDebug()<<"\t"<<symbols[i];
+}
 
 
-KeyboardLayout::KeyboardLayout()
-{
+KbLayout::KbLayout(){
+    keyCount = 0;
+    includeCount = 0;
+    keyList << KbKey();
+    include << QString();
 }
 
-void KeyboardLayout::generateLayout(QString a,const QString& cname)
-{
-    includeSymbol(a,cname);
-    int i=a.indexOf("name[Group1]=");
-    i+=13;
-
-    QString n=a.mid(i);
-    n=n.simplified();
-    i=n.indexOf("\"",1);
-    layoutName=n.left(i);
-    layoutName.remove("\"");
-    layoutName.simplified();
-    i=n.indexOf("key");
-    n=n.mid(i);
-
-    QList<QString> st;
-    st=n.split("key");
-
-    KeySymbols dum;
-    QString r,y;
-
-    for(int k=0;k<st.size();k++){
-        dum.setKey(st.at(k));
-        if(dum.keyname.startsWith("Lat"))
-            dum.keyname=alias.getAlias(cname,dum.keyname);
-        if(dum.keyname=="TLDE"){
-            r=st.at(k);
-            TLDE.setKey(r);
-        }
-        if(dum.keyname=="BKSL"){
-            r=st.at(k);
-            BKSL.setKey(r);
-        }
-        if(dum.keyname.contains("AE")){
-            QString ind=dum.keyname.right(2);
-            int index=ind.toInt();
-            r=st.at(k);
-            AE[index-1].setKey(r);
-        }
-        if(dum.keyname.contains("AD")){
-            QString ind=dum.keyname.right(2);
-            int index=ind.toInt();
-            r=st.at(k);
-            AD[index-1].setKey(r);
-        }
-        if(dum.keyname.contains("AC")){
-            QString ind=dum.keyname.right(2);
-            int index=ind.toInt();
-            r=st.at(k);
-            AC[index-1].setKey(r);
-        }
-        if(dum.keyname.contains("AB")){
-            QString ind=dum.keyname.right(2);
-            int index=ind.toInt();
-            r=st.at(k);
-            AB[index-1].setKey(r);
-        }
-    }
+void KbLayout::setName(QString n){
+    name = n;
 }
 
-void KeyboardLayout::includeSymbol(QString a,const QString& cname)
-{
-    int k=a.indexOf("include");
-    a=a.mid(k);
-
-    QList<QString>tobeinclude;
-    tobeinclude=a.split("include");
-
-    QString r;
-    for(int o=1;o<tobeinclude.size();o++){
-        QString d=tobeinclude.at(o);
-        d.simplified();
-        int k=d.indexOf("\"",2);
-
-        QString incsym=d.left(k);
-        incsym.remove(" ");
-        incsym.remove("\"");
-
-        QList<QString> incfile;
-        incfile=incsym.split("(");
-        for(int i=0;i<incfile.size();i++){
-                QString z=incfile.at(i);
-                z.remove(" ");
-            incfile[i]=z;
-        }
-        if(incfile.size()==1)
-            incfile<<"basic";
-        else{
-            QString ns=incfile.at(1);
-            ns.remove(")");
-            incfile[1]=ns;
-        }
-        r=incfile.at(0);
-        r.append(incfile.at(1));
-
-        QString filename=findSymbolBaseDir();
-        filename.append(incfile.at(0));
-
-        QFile file(filename);
-        file.open(QIODevice::ReadOnly | QIODevice::Text);
-
-        QString content = file.readAll();
-        QList<QString> symstrlist;
-
-        symstrlist=content.split("xkb_symbols ");
-        for(int u=1;u<symstrlist.size();u++){
-            QString cur=symstrlist.at(u);
-            int pos = cur.indexOf("{");
-            cur=cur.left(pos);
-            if(cur.contains(incfile.at(1))){
-                generateLayout(symstrlist.at(u),cname);
-                break;
-            }
-        }
+void KbLayout::addInclude(QString n){
+    if(!include.contains(n)){
+        include[includeCount] = n;
+        includeCount++;
+        include << QString();
     }
 }
 
-QString KeyboardLayout::findSymbolBaseDir()
-{
-    QString xkbParentDir;
-
-    QString base(XLIBDIR);
-    if( base.count('/') >= 3 ) {
-        // .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> \
                /usr/X11/share/X11/xkb
-        QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11";
-        QDir baseDir(base + delta);
-        if( baseDir.exists() ) {
-            xkbParentDir = baseDir.absolutePath();
-        }
-        else {
-            QDir baseDir(base + "/X11");	// .../usr/X11/lib/X11/xkb (old XFree)
-            if( baseDir.exists() ) {
-                xkbParentDir = baseDir.absolutePath();
-            }
+
+void KbLayout :: addKey(){
+    keyCount++;
+    keyList << KbKey();
+}
+
+QString KbLayout :: getInclude(int i){
+    if(i < includeCount)
+        return include[i];
+    else
+        return QString();
+}
+
+int KbLayout :: findKey(QString n){
+    for(int i = 0 ; i < keyCount ; i++){
+        if(keyList[i].keyName == n){
+            return i;
         }
     }
+    return -1;
+}
 
-    if( xkbParentDir.isEmpty() ) {
-        xkbParentDir = "/usr/share/X11";
+void KbLayout::display(){
+    qDebug()<< name <<"\n";
+    for(int i = 0; i<includeCount; i++){
+        qDebug()<<include[i];
+    }
+    for(int i = 0 ; i<keyCount; i++ ){
+        keyList[i].display();
     }
-
-    return QString("%1/xkb/symbols/").arg(xkbParentDir);
 }
diff --git a/kcontrol/keyboard/preview/keyboardlayout.h \
b/kcontrol/keyboard/preview/keyboardlayout.h index 4844382..5c7484a 100644
--- a/kcontrol/keyboard/preview/keyboardlayout.h
+++ b/kcontrol/keyboard/preview/keyboardlayout.h
@@ -15,36 +15,61 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
- 
-#ifndef KEYBOARDLAYOUT_H
-#define KEYBOARDLAYOUT_H
 
-#include "keysymbols.h"
+#ifndef KEYBOARDLAYOUT_NEW_H
+#define KEYBOARDLAYOUT_NEW_H
+
 #include "keyaliases.h"
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QList>
+
+class KbKey{
+    QList<QString> symbols;
+    int symbolCount;
+public :
+    QString keyName;
 
-#include <QtGui/QApplication>
+    KbKey();
+    void setKeyName(QString n);
+    void addSymbol(QString n,int i);
+    QString getSymbol(int i);
+    int getSymbolCount(){
+        return symbolCount;
+    }
 
-class KeyboardLayout
-{
-    QString layoutName;
-    Aliases alias;
-    
+    void display();
+};
+
+
+class KbLayout{
+    QList<QString> include;
+    QString name;
+    int keyCount, includeCount;
 public:
-    KeyboardLayout();
-
-    KeySymbols TLDE;
-    KeySymbols BKSL;
-    KeySymbols AE[12];
-    KeySymbols AD[12];
-    KeySymbols AC[11];
-    KeySymbols AB[11];
-
-    void generateLayout(QString a, const QString &cname);
-    QString findSymbolBaseDir();
-    void includeSymbol(QString a, const QString &cname);
+    QList <KbKey> keyList;
+    QString country;
+
+    KbLayout();
+    void setName(QString n);
+    void addInclude(QString n);
+    void addKey();
+
+    int getKeyCount(){
+        return keyCount;
+    }
+
+    int getIncludeCount(){
+        return includeCount;
+    }
+
     QString getLayoutName() const {
-    	return layoutName;
+        return name;
     }
+
+    QString getInclude(int i);
+    int findKey(QString n);
+    void display();
 };
 
-#endif // KEYBOARDLAYOUT_H
+#endif //KEYBOARDLAYOUT_NEW_H
diff --git a/kcontrol/keyboard/preview/keyboardlayout_new.cpp \
b/kcontrol/keyboard/preview/keyboardlayout_new.cpp deleted file mode 100644
index 42dbc63..0000000
--- a/kcontrol/keyboard/preview/keyboardlayout_new.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
- 
-#include "keyboardlayout_new.h"
-
-#include <QDebug>
-#include <QString>
-#include <QList>
-
-KbKey::KbKey(){
-    symbolCount = 0;
-    symbols << QString();
-}
-
-void KbKey::setKeyName(QString n){
-        keyName = n;
-}
-
-void KbKey::addSymbol(QString n, int i){
-    symbols[i] = n;
-    symbolCount++;
-    symbols << QString();
-}
-
-
-QString KbKey::getSymbol(int i){
-    if(i < symbolCount)
-        return symbols[i];
-    else
-        return QString();
-}
-
-void KbKey::display(){
-    qDebug()<<keyName<<" : ";
-    for(int i=0; i<symbolCount; i++)
-        qDebug()<<"\t"<<symbols[i];
-}
-
-
-KbLayout::KbLayout(){
-    keyCount = 0;
-    includeCount = 0;
-    keyList << KbKey();
-    include << QString();
-}
-
-void KbLayout::setName(QString n){
-    name = n;
-}
-
-void KbLayout::addInclude(QString n){
-    if(!include.contains(n)){
-        include[includeCount] = n;
-        includeCount++;
-        include << QString();
-    }
-}
-
-
-void KbLayout :: addKey(){
-    keyCount++;
-    keyList << KbKey();
-}
-
-QString KbLayout :: getInclude(int i){
-    if(i < includeCount)
-        return include[i];
-    else
-        return QString();
-}
-
-int KbLayout :: findKey(QString n){
-    for(int i = 0 ; i < keyCount ; i++){
-        if(keyList[i].keyName == n){
-            return i;
-        }
-    }
-    return -1;
-}
-
-void KbLayout::display(){
-    qDebug()<< name <<"\n";
-    for(int i = 0; i<includeCount; i++){
-        qDebug()<<include[i];
-    }
-    for(int i = 0 ; i<keyCount; i++ ){
-        keyList[i].display();
-    }
-}
diff --git a/kcontrol/keyboard/preview/keyboardlayout_new.h \
b/kcontrol/keyboard/preview/keyboardlayout_new.h deleted file mode 100644
index 5c7484a..0000000
--- a/kcontrol/keyboard/preview/keyboardlayout_new.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *  Copyright (C) 2012 Shivam Makkar (amourphious1992@gmail.com)
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-#ifndef KEYBOARDLAYOUT_NEW_H
-#define KEYBOARDLAYOUT_NEW_H
-
-#include "keyaliases.h"
-#include <QtCore/QString>
-#include <QtCore/QStringList>
-#include <QtCore/QList>
-
-class KbKey{
-    QList<QString> symbols;
-    int symbolCount;
-public :
-    QString keyName;
-
-    KbKey();
-    void setKeyName(QString n);
-    void addSymbol(QString n,int i);
-    QString getSymbol(int i);
-    int getSymbolCount(){
-        return symbolCount;
-    }
-
-    void display();
-};
-
-
-class KbLayout{
-    QList<QString> include;
-    QString name;
-    int keyCount, includeCount;
-public:
-    QList <KbKey> keyList;
-    QString country;
-
-    KbLayout();
-    void setName(QString n);
-    void addInclude(QString n);
-    void addKey();
-
-    int getKeyCount(){
-        return keyCount;
-    }
-
-    int getIncludeCount(){
-        return includeCount;
-    }
-
-    QString getLayoutName() const {
-        return name;
-    }
-
-    QString getInclude(int i);
-    int findKey(QString n);
-    void display();
-};
-
-#endif //KEYBOARDLAYOUT_NEW_H
diff --git a/kcontrol/keyboard/preview/symbol_parser.cpp \
b/kcontrol/keyboard/preview/symbol_parser.cpp index 381663d..dac8fe6 100644
--- a/kcontrol/keyboard/preview/symbol_parser.cpp
+++ b/kcontrol/keyboard/preview/symbol_parser.cpp
@@ -1,5 +1,5 @@
 #include "symbol_parser.h"
-#include "keyboardlayout_new.h"
+#include "keyboardlayout.h"
 #include "keyaliases.h"
 
 #include <QtCore/QString>
@@ -12,6 +12,8 @@
 #include <fixx11h.h>
 #include <config-workspace.h>
 
+
+
 namespace grammar{
 
 symbol_keywords :: symbol_keywords(){
@@ -22,6 +24,7 @@ symbol_keywords :: symbol_keywords(){
             ("*/",4)
         ;
 }
+
 template<typename Iterator>
 Symbol_parser<Iterator>::Symbol_parser():Symbol_parser::base_type(start){
     using qi::lexeme;
@@ -73,49 +76,55 @@ Symbol_parser<Iterator>::Symbol_parser():Symbol_parser::base_type(start){
  >>*(comments||char_);
 }
 
+
 template<typename Iterator>
 void Symbol_parser<Iterator>::getSymbol(std::string n){
     int index = layout.keyList[keyIndex].getSymbolCount();
     layout.keyList[keyIndex].addSymbol(QString::fromUtf8(n.data(), n.size()), \
                index);
-    qDebug()<<"adding symbol: "<<QString::fromUtf8(n.data(), n.size());
-    qDebug()<<"added symbol: "<<layout.keyList[keyIndex].getSymbol(index)<<" in \
"<<keyIndex<<" at "<<index; +    //qDebug()<<"adding symbol: \
"<<QString::fromUtf8(n.data(), n.size()); +    //qDebug()<<"added symbol: \
"<<layout.keyList[keyIndex].getSymbol(index)<<" in "<<keyIndex<<" at "<<index;  }
+
+
 template<typename Iterator>
 void Symbol_parser<Iterator>::addKeyName(std::string n){
     QString kname = QString::fromUtf8(n.data(), n.size());
     if(kname.startsWith("Lat"))
         kname = alias.getAlias(layout.country, kname);
     keyIndex = layout.findKey(kname);
-    qDebug()<<layout.getKeyCount();
+    //qDebug()<<layout.getKeyCount();
     if (keyIndex == -1){
         layout.keyList[layout.getKeyCount()].keyName = kname;
         keyIndex = layout.getKeyCount();
         newKey = 1;
     }
-    else
-        qDebug()<<"key at"<<keyIndex;
+       // qDebug()<<"key at"<<keyIndex;
 }
 
+
 template<typename Iterator>
 void Symbol_parser<Iterator>::addKey(){
     if(newKey == 1){
         layout.addKey();
         newKey = 0;
-        qDebug()<<"new key";
+        //qDebug()<<"new key";
     }
 }
 
+
 template<typename Iterator>
 void Symbol_parser<Iterator>::getInclude(std::string n){
     layout.addInclude(QString::fromUtf8(n.data(), n.size()));
 }
 
+
 template<typename Iterator>
 void Symbol_parser<Iterator>::setName(std::string n){
     layout.setName(QString::fromUtf8(n.data(), n.size()));
-    qDebug() << layout.getLayoutName();
+    //qDebug() << layout.getLayoutName();
 }
 
+
 QString findSymbolBaseDir()
 {
     QString xkbParentDir;
@@ -144,36 +153,45 @@ QString findSymbolBaseDir()
 }
 
 
+
 QString findLayout(const QString& layout, const QString& layoutVariant){
+
     QString symbolBaseDir = findSymbolBaseDir();
     QString symbolFile = symbolBaseDir.append(layout);
 
     QFile sfile(symbolFile);
     if (!sfile.open(QIODevice::ReadOnly | QIODevice::Text)){
-         qDebug()<<"unable to open the file";
+         //qDebug()<<"unable to open the file";
          return QString();
     }
+
     QString scontent = sfile.readAll();
     sfile.close();
     QStringList scontentList = scontent.split("xkb_symbols");
 
     QString variant;
     QString input;
+
     if(layoutVariant.isEmpty()){
         input = scontentList.at(1);
         input.prepend("xkb_symbols");
     }
+
     else{
         int i = 1;
+
         while (layoutVariant != variant && i < scontentList.size()) {
             input = scontentList.at(i);
+
             QString h = scontentList.at(i);
+
             int k = h.indexOf("\"");
             h = h.mid(k);
             k = h.indexOf("{");
             h = h.left(k);
             h = h.remove(" ");
             variant = h.remove("\"");
+
             input.prepend("xkb_symbols");
             i++;
         }
@@ -183,9 +201,11 @@ QString findLayout(const QString& layout, const QString& \
layoutVariant){  }
 
 KbLayout parseSymbols(const QString& layout, const QString& layoutVariant){
+
     using boost::spirit::iso8859_1::space;
     typedef std::string::const_iterator iterator_type;
     typedef grammar::Symbol_parser<iterator_type> Symbol_parser;
+
     Symbol_parser s;
 
     s.layout.country = layout;
@@ -197,7 +217,8 @@ KbLayout parseSymbols(const QString& layout, const QString& \
layoutVariant){  std::string::const_iterator end = xyz.end();
 
     bool r = phrase_parse(iter, end, s, space);
-    if (r && iter == end){
+
+    /*if (r && iter == end){
         std::cout << "-------------------------\n";
         std::cout << "Parsing succeeded\n";
         std::cout << "\n-------------------------\n";
@@ -207,7 +228,7 @@ KbLayout parseSymbols(const QString& layout, const QString& \
layoutVariant){  std::cout << "Parsing failed\n";
         std::cout << "-------------------------\n";
         qDebug()<<input;
-    }
+    }*/
 
 
     for(int j = 0; j < s.layout.getIncludeCount(); j++){
@@ -220,17 +241,20 @@ KbLayout parseSymbols(const QString& layout, const QString& \
layoutVariant){  input = findLayout(l,lv);
 
         }
+
         else{
             QString a = QString();
             input = findLayout(includeFile.at(0),a);
         }
+
         xyz = input.toUtf8().constData();
 
         std::string::const_iterator iter = xyz.begin();
         std::string::const_iterator end = xyz.end();
 
         bool r = phrase_parse(iter, end, s, space);
-        if (r && iter == end){
+
+        /*if (r && iter == end){
             std::cout << "-------------------------\n";
             std::cout << "Parsing succeeded\n";
             std::cout << "\n-------------------------\n";
@@ -240,10 +264,11 @@ KbLayout parseSymbols(const QString& layout, const QString& \
layoutVariant){  std::cout << "Parsing failed\n";
             std::cout << "-------------------------\n";
             qDebug()<<input;
-        }
+        }*/
     }
 
-    s.layout.display();
+    //s.layout.display();
+
     return s.layout;
 }
 
diff --git a/kcontrol/keyboard/preview/symbol_parser.h \
b/kcontrol/keyboard/preview/symbol_parser.h index 0c94f55..efd5aca 100644
--- a/kcontrol/keyboard/preview/symbol_parser.h
+++ b/kcontrol/keyboard/preview/symbol_parser.h
@@ -1,7 +1,6 @@
 #ifndef SYMBOL_PARSER_H
 #define SYMBOL_PARSER_H
 
-
 #include <boost/config/warning_disable.hpp>
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
@@ -17,7 +16,7 @@
 #include <iostream>
 #include <QtCore/QDebug>
 
-#include "keyboardlayout_new.h"
+#include "keyboardlayout.h"
 #include "keyaliases.h"
 
 namespace qi = boost::spirit::qi;
@@ -25,6 +24,9 @@ namespace ascii = boost::spirit::ascii;
 namespace phx = boost::phoenix;
 namespace iso = boost::spirit::iso8859_1;
 
+
+
+
 namespace grammar {
 
     struct symbol_keywords : qi::symbols<char, int>{
@@ -35,6 +37,7 @@ namespace grammar {
     struct Symbol_parser : qi::grammar<Iterator, iso::space_type>{
 
         Symbol_parser();
+        qi::rule<Iterator,  iso::space_type>start;
         qi::rule<Iterator, std::string(), iso::space_type>name;
         qi::rule<Iterator, std::string(), iso::space_type>keyName;
         qi::rule<Iterator, std::string(), iso::space_type>symbols;
@@ -42,7 +45,6 @@ namespace grammar {
         qi::rule<Iterator, std::string(), iso::space_type>type;
         qi::rule<Iterator, std::string(), iso::space_type>group;
         qi::rule<Iterator, std::string(), iso::space_type>symbol;
-        qi::rule<Iterator,  iso::space_type>start;
         qi::rule<Iterator, std::string(), iso::space_type>comments;
         qi::rule<Iterator, std::string(), iso::space_type>ee;
         qi::rule<Iterator, std::string(), iso::space_type>include;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic