<file>button/up_enable.png</file>
<file>button/down_enable.png</file>
<file>button/revert.png</file>
+ <file>button/checkboxCheckedDis.png</file>
+ <file>button/checkboxDis.png</file>
</qresource>
</RCC>
roles[ContentRole] = "content";
roles[NumberRole] = "number";
setRoleNames(roles);
-
setContents(contents);
}
SearchBarWidget::SearchBarWidget(QWidget *parent) : QWidget(parent) {
- qDebug()<<"test1";
+
+ completerModel = new QStringList;
+ lineEditCompleter = new QCompleter(this);
+ lineEditCompleter->setModel(new QStringListModel(*completerModel));
+ lineEditCompleter->setCaseSensitivity(Qt::CaseInsensitive);
+ lineEditCompleter->setCompletionMode(QCompleter::InlineCompletion);
+
#ifndef Q_WS_MAEMO_5
this->setMaximumHeight(50);
busyTimer=new QTimer;
progressBar->hide();
view= new QDeclarativeView();
+ ctxt = view->rootContext();
+
view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/SearchBarWidget.qml"));
view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
view->setAlignment(Qt::AlignCenter);
this, SIGNAL(historyPrev()));
connect(rootObject, SIGNAL(historyShowToolButtonClicked()),
this, SLOT(showHistoryButtonClicked()));
+ connect(rootObject, SIGNAL(textChange(QString)),
+ this, SLOT(textChange(QString)));
+ connect(rootObject, SIGNAL(nextCompleter()),
+ this, SLOT(nextCompleter()));
+ connect(rootObject, SIGNAL(prevCompleter()),
+ this, SLOT(prevCompleter()));
connect(this, SIGNAL(progresSetMax(QVariant)),
rootObject2, SLOT(setMax(QVariant)));
connect(this, SIGNAL(setLineEditEnables(QVariant)),
rootObject, SLOT(setEnableLineEdit(QVariant)));
+ connect(this, SIGNAL(setCompleterText(QVariant)),
+ rootObject, SLOT(setCompleterText(QVariant)));
+
connect(busyTimer, SIGNAL(timeout()),
this, SLOT(updateBusyTimer()));
emit setEnableHistoryShow(false);
emit setEnableHistoryPrev(false);
- completerModel = new QStringListModel(this);
connect(&delayTimer, SIGNAL(timeout()),
this, SLOT(delaySearchTimeout()));
connect(&delayTimer, SIGNAL(timeout()),
this, SLOT(delaySearchTimeout()));
-
searchWordLineEdit->setFocus();
#endif
}
+void SearchBarWidget::textChange(QString text){
+ QLineEdit line;
+ QString toSend="";
+ QString tempString;
+ actualString=text;
+ completerActualList.clear();
+
+ line.setCompleter(lineEditCompleter);
+ line.completer()->setCompletionPrefix(text);
+ for (int i = 0; lineEditCompleter->setCurrentRow(i); i++)
+ completerActualList.append(lineEditCompleter->currentCompletion());
+
+ completerActualList.sort();
+ if(completerActualList.contains(preferedCompliter)){
+ tempString = preferedCompliter;
+ toSend = tempString.remove(0,text.size());
+ emit setCompleterText(toSend);
+ }
+ else if(completerActualList.size()>0 && text.size()>0){
+ toSend = completerActualList.at(0);
+ preferedCompliter= toSend;
+ toSend=toSend.remove(0,text.size());
+ if(toSend.size()>0)
+ emit setCompleterText(toSend);
+ else if(completerActualList.size()>1){
+ toSend = completerActualList.at(1);
+ preferedCompliter= toSend;
+ toSend=toSend.remove(0,text.size());
+ emit setCompleterText(toSend);
+ }
+ }
+ else{
+ preferedCompliter="";
+ emit setCompleterText(toSend);
+ }
+}
+
+void SearchBarWidget::prevCompleter(){
+ QString tempString;
+ if(!preferedCompliter.isEmpty()){
+ int index = completerActualList.indexOf(preferedCompliter);
+ qDebug()<<"index"<<index<<"size"<<completerActualList.size()<<"+1";
+ if(index!=-1 && completerActualList.size()>index+1){
+ preferedCompliter = completerActualList.at(index+1);
+ tempString=preferedCompliter;
+ QString toSend = tempString.remove(0,actualString.size());
+ emit setCompleterText(toSend);
+ }
+ }
+}
+
+void SearchBarWidget::nextCompleter(){
+ QString tempString;
+ if(!preferedCompliter.isEmpty()){
+ int index = completerActualList.indexOf(preferedCompliter);
+ if(index>0){
+ preferedCompliter = completerActualList.at(index-1);
+ tempString=preferedCompliter;
+ QString toSend = tempString.remove(0,actualString.size());
+ emit setCompleterText(toSend);
+ }
+ }
+}
+
+
QIcon SearchBarWidget::generateIcon(QIcon original, qreal rotation) {
qDebug()<<"test2";
QPixmap p = original.pixmap(64);
searchWordLineEdit = new QLineEdit;
searchWordLineEdit->setMinimumWidth(250);
- completerModel = new QStringListModel(this);
-
- lineEditCompleter = new QCompleter(searchWordLineEdit);
- lineEditCompleter->setModel(completerModel);
- lineEditCompleter->setCaseSensitivity(Qt::CaseInsensitive);
- lineEditCompleter->setCompletionMode(QCompleter::InlineCompletion);
searchWordLineEdit->setCompleter(lineEditCompleter);
#ifndef Q_WS_MAEMO_5
}
void SearchBarWidget::search(QString word) {
- qDebug()<<"test7";
- qDebug()<<word;
if(!busy && !word.isEmpty()) {
- completerModel->insertRow(completerModel->rowCount());
- QModelIndex index=completerModel->index(completerModel->rowCount() -1);
- completerModel->setData(index, word);
-
+ while(word.lastIndexOf(" ")==word.size()-1 && word.size()>0)
+ word=word.remove(word.size()-1,1);
+ if(!completerModel->contains(word))
+ completerModel->append(word);
+ QAbstractItemModel *temp=lineEditCompleter->model();
+ lineEditCompleter->setModel(new QStringListModel(*completerModel));
+ delete temp;
#ifndef Q_WS_MAEMO_5
emit setLineEditText(word);
#else
void progresSetMin(QVariant);
void progresSetValue(QVariant);
void progresSetValue2(QVariant);
+ void setCompleterText(QVariant);
//! Requests to search for a list of words matching a word passed as
//! a parameter
//! shows history
void showHistoryButtonClicked();
+ void textChange(QString text);
+
+ void nextCompleter();
+
+ void prevCompleter();
private:
QDeclarativeView *progressBar;
QTimer *busyTimer;
bool progressMax;
+ QDeclarativeContext *ctxt;
+ QStringList* completerModel;
+ QCompleter* lineEditCompleter;
+ QString preferedCompliter;
+ QString actualString;
+ QStringList completerActualList;
QLineEdit* searchWordLineEdit;
- QCompleter* lineEditCompleter;
- QStringListModel* completerModel;
QToolButton* clearSearchWordToolButton;
QPushButton* searchPushButton;
QToolButton* historyPrevToolButton;
anchors.horizontalCenterOffset: 0
onLinkActivated: linkClicked(link);
}
-
- /* MySpinBox {
- id: test01
- y:20;
- x:20;
- width: 40
- height: 20;
- }
- */
}
BorderImage {
id: button
property alias textInButton: buttonText.text
- signal clicked
- opacity: 1
+ property bool checkable: false
+ property bool checked: false
+
+ height: 20;
+ width: 60;
+
+ signal clicked;
+ signal changeCheck;
function setText(string) { textInButton = qsTr(string); }
function press() { mouseArea.pressed }
height: parent.height;
onClicked: {
button.clicked();
+ if(checkable){
+ button.checked=!button.checked;
+ button.changeCheck();
+ }
}
}
Text {
z:1
id: buttonText
+ width: parent.width;
anchors.centerIn: parent;
+ horizontalAlignment: Text.AlignHCenter
font.pixelSize: parent.height * .5
elide: Text.ElideRight;
style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
Image {
id: image1
- width: (35*parent.height)/107 +1
+ width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1 //(35*parent.height)/107 +1
height: parent.height
anchors.left: parent.left
source: "qrc:/button/buttonLeft.png"
Image {
id: image2
smooth: true
- width: (35*parent.height)/107 +1
+ width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1//(35*parent.height)/107 +1
height: parent.height
anchors.right: parent.right
source: "qrc:/button/buttonR.png"
states: [
State {
name: "pressed";
- when: (mouseArea.pressed == true && button.enabled == true);
+ when: ((button.enabled) && (mouseArea.pressed || (button.checkable && button.checked) ) )
PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" }
PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" }
property bool selected
property string pathToCheckedImage: "qrc:/button/checkboxChecked.png"
property string pathToUncheckedImage: "qrc:/button/checkbox.png"
+ property string pathToCheckedDicImage: "qrc:/button/checkboxCheckedDis.png"
+ property string pathToUncheckedDicImage: "qrc:/button/checkboxDis.png"
signal changed
height: {
var aspectRatio = sourceSize.height / sourceSize.width
smooth: true
states: [
State {
- name: "checked";
- when: (checkbox.selected == true);
+ name: "checkeEn";
+ when: (checkbox.selected && checkbox.enabled);
PropertyChanges { target: checkbox; source: pathToCheckedImage }
},
State {
- name: "unchecked";
- when: (checkbox.selected == false);
+ name: "uncheckeEn";
+ when: ( !checkbox.selected && checkbox.enabled);
PropertyChanges { target: checkbox; source: pathToUncheckedImage }
+ },
+ State {
+ name: "checkeDi";
+ when: (checkbox.selected && !checkbox.enabled);
+
+ PropertyChanges { target: checkbox; source: pathToCheckedDicImage }
+ },
+ State {
+ name: "uncheckeDi";
+ when: ( !checkbox.selected && !checkbox.enabled);
+
+ PropertyChanges { target: checkbox; source: pathToUncheckedDicImage }
}
]
MouseArea{
id: area
anchors.fill: parent
onClicked: {
- checkbox.selected = !checkbox.selected
- changed()
+ if(checkbox.enabled){
+ checkbox.selected = !checkbox.selected
+ changed()
+ }
}
}
}
property int expandedHeight
property int basicHeight
property string startValue
- height: basicHeight
+ height: 20
+
+ property variant parentField : rectangle1
function show(Boolean){
expanded = Boolean
ElementsListView{
id: list1
- width: parent.width
visible: false
- z: 0
property string selected: rectangle1.startValue
function selectedValue(nr, value) {
rectangle1.show(false)
}
- anchors.left: parent.left
- anchors.verticalCenter: parent.verticalCenter
- highlightResizeSpeed: 1000
+ anchors.rightMargin: 5
+ anchors.leftMargin: 5
+ anchors.bottomMargin: 10
+ anchors.topMargin: 10
+ anchors.fill: parent
+ highlightResizeSpeed: 1000
delegate: Component{
id: list1Delegate
Item {
id: contentText
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 5
+ elide: Text.ElideRight;
text: content
}
}
when: (rectangle1.expanded == true && rectangle1.disabled == false)
PropertyChanges { target: list1; z: 10; visible: true }
PropertyChanges { target: text1; z: 10; visible: false }
- PropertyChanges { target: rectangle1; border.width: 0}
+ PropertyChanges { target: rectangle1; border.width: 1}
PropertyChanges { target: rectangle1; height: rectangle1.expandedHeight}
PropertyChanges { target: imageDown; height: 0.5 * rectangle1.basicHeight}
PropertyChanges { target: shadeDisable; visible: false; z: -1}
+ PropertyChanges { target: rectangle1; anchors.fill: parentField}
},
State {
name: "disabled";
signal saveButtonClicked(string langFrom, string langTo);
+
+ id:rectangle1
height: infoLabel.height + fromLabel.height + toLabel.height + saveButton.height + 50
width: 200
+ color : myPalette.window;
- id:rectangle1
+ SystemPalette {
+ id: myPalette;
+ colorGroup:SystemPalette.Active
+ }
+
+ Item {
+ id: comboField
+ anchors.bottomMargin: 6
+ anchors.rightMargin: 0
+ anchors.left: fromLabel.right
+ anchors.right: revertButton.left
+ anchors.bottom: saveButton.top
+ anchors.top: parent.top
+ anchors.leftMargin: 2
+ z:2;
+ }
+
+ Text {
+ id: infoLabel
+ height: paintedHeight+5;
+ anchors.right: parent.right
+ anchors.left: parent.left
+ anchors.top: parent.top
+ wrapMode: Text.Wrap;
+ transformOrigin: Item.Left
+ font.pixelSize: 12
+ }
+
+
+ Text {
+ id: fromLabel
+ text: qsTr("From: ")
+ height: paintedHeight+5;
+ anchors.top: infoLabel.bottom
+ anchors.left: parent.left
+ wrapMode: Text.Wrap;
+ transformOrigin: Item.Left
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: toLabel
+ text: qsTr("To: ")
+ anchors.topMargin: 3
+ height: paintedHeight+5;
+ anchors.top: fromLabel.bottom
+ anchors.left: parent.left
+ wrapMode: Text.Wrap;
+ transformOrigin: Item.Left
+ font.pixelSize: 12
+ }
+
+ ComboBox{
+ id: comboFrom
+ model: comboBoxModel
+ anchors.right: revertButton.left
+ anchors.rightMargin: 5
+ anchors.left: fromLabel.right
+ anchors.leftMargin: 10
+ anchors.verticalCenter: fromLabel.verticalCenter
+
+ parentField: comboField
+ expanded: false
+ basicHeight: fromLabel.height
+ onExpandedChanged: {
+ if(expanded==true)
+ z=2;
+ else
+ z=0;
+ }
+ }
+
+ ComboBox{
+ id: comboTo
+ model: comboBoxModel
+ anchors.right: revertButton.left
+ anchors.rightMargin: 5
+ anchors.left: fromLabel.right
+ anchors.leftMargin: 10
+ anchors.verticalCenter: toLabel.verticalCenter
+
+ parentField: comboField;
+ expanded: false
+ basicHeight: fromLabel.height
+
+ onExpandedChanged: {
+ if(expanded==true)
+ z=2;
+ else
+ z=0;
+ }
+ }
+
+ IconButton{
+ id: revertButton
+ width: height
+ height: fromLabel.height
+ anchors.top: fromLabel.bottom
+ anchors.topMargin: -8
+ anchors.right: parent.right
+ pathToIcon: "qrc:/button/revert.png"
+ onClicked: { rectangle1.revertLang() }
+ }
+
+ Button {
+ id: saveButton
+ height: 30
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ anchors.left: parent.left
+ onClicked: {
+ rectangle1.saveButtonClicked(comboFrom.value, comboTo.value);
+ }
+ }
+
+ MouseArea {
+ id: mouse_area1
+ anchors.fill: parent
+ z:-1
+ onClicked: {
+ comboTo.expanded=false;
+ comboFrom.expanded=false;
+ }
+ }
+
+
+
+ states: [
+ State {
+ name: "new"
+ when: newPlugin==true
+ PropertyChanges { target: saveButton; textInButton: qsTr("Add") }
+ },
+ State {
+ name: "edit"
+ when: newPlugin==false
+ PropertyChanges { target: saveButton; textInButton: qsTr("Save settings") }
+ }
+ ]
+}
+
+
+/*
+Rectangle{
+ property bool newPlugin:false;
+
+ function setInfo(string){
+ infoLabel.text = string;
+ }
+ function setStartValues(startFrom, startTo, startFromIndex, startToIndex){
+ comboFrom.setStartValue(startFrom, startFromIndex)
+ comboTo.setStartValue(startTo, startToIndex)
+ }
+ function revertLang(){
+ var tmpidx = comboFrom.index
+ comboFrom.index = comboTo.index
+ comboTo.index = tmpidx
+ var tmpval = comboFrom.value
+ comboFrom.value = comboTo.value
+ comboTo.value = tmpval
+ }
+ function setNew(bool){
+ newPlugin=bool;
+ }
+
+ signal saveButtonClicked(string langFrom, string langTo);
+
+
+ id:rectangle1
+ height: infoLabel.height + fromLabel.height + toLabel.height + saveButton.height + 50
+ width: 200
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
color : myPalette.window;
}
ComboBox{
+ //parentField: rectangle1
+
id: comboFrom
model: comboBoxModel
anchors.left: parent.left
}
ComboBox{
+ //parentField: rectangle1;
id: comboTo
model: comboBoxModel
anchors.left: parent.left
}
]
}
+*/
property int maxValue:500;
property int minValue:0;
property alias value:text_input1.text
+ property bool isTextInMinValue:true;
+ property string textInMinValue:"inf";
+ property int singleStep: 2;
signal valueChange(int intiger);
function stringToInt(string){
var value=0;
var pow10=1;
- for (var i=string.length-1;i>=0;i--){
- value+=(string.charCodeAt(i)-48)*pow10;
- pow10= pow10*10;
- }
+ if(isTextInMinValue && textInMinValue==string)
+ value=minValue;
+ else
+ for (var i=string.length-1;i>=0;i--){
+ value+=(string.charCodeAt(i)-48)*pow10;
+ pow10= pow10*10;
+ }
if(value>maxValue)
return maxValue;
if(value<minValue)
selectByMouse: true;
font.pixelSize: rectangle1.height * .5;
onCursorPositionChanged: moveCursorSelection(cursorPosition);
- onTextChanged: rectangle1.valueChange(stringToInt(text_input1.text));
+ onTextChanged:{
+ if(isTextInMinValue && text_input1.text!="" && stringToInt(text_input1.text)==minValue)
+ text_input1.text=textInMinValue;
+
+ rectangle1.valueChange(stringToInt(text_input1.text));
+ }
onFocusChanged: {
if(focus==false)
text=stringToInt(text);
repeat: true
onTriggered:{
if(mouseAreaUp.pressedButtons==Qt.LeftButton)
- text_input1.text=((stringToInt(text_input1.text)+1)>maxValue)?(maxValue):(stringToInt(text_input1.text)+1);
+ text_input1.text=((stringToInt(text_input1.text)+singleStep)>maxValue)?(maxValue):(stringToInt(text_input1.text)+singleStep);
else
running=false;
}
running: false;
repeat: true
onTriggered:{
- if(mouseAreaDown.pressedButtons==Qt.LeftButton)
- text_input1.text=((stringToInt(text_input1.text)-1)<minValue)?(minValue):(stringToInt(text_input1.text)-1);
+ if(mouseAreaDown.pressedButtons==Qt.LeftButton){
+ text_input1.text=((stringToInt(text_input1.text)-singleStep)<minValue)?(minValue):(stringToInt(text_input1.text)-singleStep);
+ if(isTextInMinValue && stringToInt(text_input1.text)==minValue)
+ text_input1.text=textInMinValue
+ }
else
running=false;
}
height: rectangle1.height/2;
anchors.right: parent.right
anchors.top: parent.top
- onClicked: text_input1.text=((stringToInt(text_input1.text)+1)>maxValue)?(maxValue):(stringToInt(text_input1.text)+1);
+ onClicked: text_input1.text=((stringToInt(text_input1.text)+singleStep)>maxValue)?(maxValue):(stringToInt(text_input1.text)+singleStep);
onPressAndHold:{
timerUp.restart;
timerUp.running=true;
height: rectangle1.height/2;
anchors.right: parent.right
anchors.bottom: parent.bottom
- onClicked: text_input1.text=((stringToInt(text_input1.text)-1)<minValue)?(minValue):(stringToInt(text_input1.text)-1);
+ onClicked:{
+ text_input1.text=((stringToInt(text_input1.text)-singleStep)<minValue)?(minValue):(stringToInt(text_input1.text)-singleStep);
+ if(isTextInMinValue && stringToInt(text_input1.text)==minValue)
+ text_input1.text=textInMinValue
+ }
onPressAndHold:{
timerDown.restart;
timerDown.running=true;
}
}
-
- /* states: [
- State {
- name: "DisableState"; when: rectangle1.enabled==false;
- PropertyChanges { target: shadeDisable; z: 3; opacity: 0.5 }
- }
- ]
- */
}
radius: 10
border.color: "#000666";
property alias textInLineEdit:text_input1.text
+ property bool useCompleter:false
signal enterPressed(string text);
+ signal textChange(string text);
+
+ signal nextCompleter();
+ signal prevCompleter();
function setText(string) { textInLineEdit = string; }
+ function setCompleter(string) { completerItemText.text=string; }
+ function hideCompleter() { completerItem.visible=false; }
+
+ function addOneChar(){
+ if(completerItemText.text.length>0)
+ text_input1.text=text_input1.text+completerItemText.text.charAt(0);
+ }
+
+ function addAllChars(){
+ text_input1.text=text_input1.text+completerItemText.text;
+ completerItemText.text="";
+ }
TextInput {
id: text_input1
anchors.centerIn: parent
selectByMouse: true;
font.pixelSize: rectangle1.height * .5;
- onCursorPositionChanged: moveCursorSelection(cursorPosition);
+ onCursorPositionChanged: {
+ moveCursorSelection(cursorPosition);
+ if(cursorPosition==text.length && useCompleter)
+ completerItem.visible=true;
+ else
+ completerItem.visible=false;
+ }
focus: rectangle1.focus;
+ Keys.priority : Keys.AfterItem
Keys.onPressed: {
- if ((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return))
+ if ((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return)){
rectangle1.enterPressed(text_input1.text)
+ completerItem.visible=false;
+ }
+ if(useCompleter){
+ if (event.key == Qt.Key_Up)
+ rectangle1.nextCompleter();
+ if (event.key == Qt.Key_Down)
+ rectangle1.prevCompleter();
+ if ((event.key == Qt.Key_Right) && (cursorPosition==text.length))
+ addOneChar();
+ if(Qt.ControlModifier){
+ if (event.key == Qt.Key_Space){
+ if(completerItem.visible=false)
+ completerItem.visible=true
+ else
+ addAllChars()
+ }
+ }
+ if(event.key == Qt.Key_Escape)
+ completerItem.visible=false;
+ }
+ }
+ onTextChanged: rectangle1.textChange(text);
+ }
+
+
+ Rectangle {
+ id: completerItem
+ x: text_input1.x + text_input1.positionToRectangle(text_input1.cursorPosition).x +1
+ y: text_input1.y
+ width: completerItemText.paintedWidth;
+ visible: false;
+ height: text_input1.height
+ color: (completerItemText.text.length>0)?"#5e71fb":"#FFFFFF"
+ opacity: 0.5
+ Text {
+ id: completerItemText
+ anchors.fill: parent
+ text:""
+ font.pixelSize: text_input1.font.pixelSize;
}
}
function setEnableHistoryNext(Boolean) { historyNextToolButton.enabled = Boolean }
function setEnableHistoryShow(Boolean) { historyShowToolButton.enabled = Boolean }
function setEnableLineEdit(Boolean) { enableLineEdit = Boolean }
- function setLineEditText(string) { inputSearchText.setText(string) }
function clear() { inputSearchText.setText("") }
+ function setLineEditText(string) { inputSearchText.setText(string) }
+ function setCompleterText(string) { inputSearchText.setCompleter(string) }
+
signal searchButtonClicked(string text);
signal historyNextToolButtonClicked;
signal historyShowToolButtonClicked;
signal historyPrevToolButtonClicked;
+ signal textChange(string text);
+
+ signal nextCompleter();
+ signal prevCompleter();
MyTextLineEdit{
id: inputSearchText
anchors.verticalCenter: parent.verticalCenter
onEnterPressed: searchBarWidget.searchButtonClicked(text);
focus: searchBarWidget.focus
+ useCompleter: true;
IconButton {
id: clearButton;
width: inputSearchText.height-6;
pathToIcon: "qrc:/button/go-clear.png";
onClicked: clear();
}
+ onTextChange: searchBarWidget.textChange(text)
+ onNextCompleter: searchBarWidget.nextCompleter();
+ onPrevCompleter: searchBarWidget.prevCompleter();
}
Item {
anchors.right: historyPrevToolButton.left
anchors.verticalCenter: parent.verticalCenter
textInButton: qsTr("Search")
- onClicked: searchBarWidget.searchButtonClicked(inputSearchText.textInLineEdit);
+ onClicked:{
+ searchBarWidget.searchButtonClicked(inputSearchText.textInLineEdit);
+ inputSearchText.hideCompleter();
+ }
}
IconButton {
anchors.right: parent.right
anchors.rightMargin: 5
textInButton: qsTr("Save")
- onClicked: rectangle1.saveButtonClicked();
+ //onClicked: rectangle1.saveButtonClicked();
}
}
anchors.fill: parent
signal dictLink(string link);
+ signal fromChange(string value);
+ signal toChange(string value)
- ScrollBar2 {
- id: horizontalScrollBar1
- z:2;
- width: parent.width-12;
- windowHeight: parent.height
- anchors.left: parent.left
- orientation: Qt.Horizontal
- position: 100
+
+ function setFromStartValues(startFrom, startTo, startFromIndex, startToIndex){
+ comboFrom.setStartValue(startFrom, startFromIndex)
+ comboTo.setStartValue(startTo, startToIndex)
+ }
+
+ function setToStartValues(startFrom, startTo, startFromIndex, startToIndex){
+ comboFrom.setStartValue(startFrom, startFromIndex)
+ comboTo.setStartValue(startTo, startToIndex)
}
- ScrollBar2 {
- id: horizontalScrollBar2
- z:2;
- width: parent.width-12;
- windowHeight: parent.height
- anchors.left: horizontalScrollBar1.left
- anchors.leftMargin: horizontalScrollBar1.position
- orientation: Qt.Horizontal
- position: 100
+
+ MouseArea {
+ id: mouse_area1
+ anchors.fill: parent
+ z:-1
+ onClicked: {
+ comboTo.expanded=false;
+ comboFrom.expanded=false;
+ }
}
- ScrollBar2 {
- id: horizontalScrollBar3
- z:2;
- width: parent.width-12;
- windowHeight: parent.height
- anchors.left: horizontalScrollBar2.left
- anchors.leftMargin: horizontalScrollBar2.position
- orientation: Qt.Horizontal
- position: 100
+
+ ComboBox {
+ id: comboFrom
+ model: fromModell
+ anchors.right: comboFromField.right
+ anchors.left: comboFromField.left
+ parentField: comboFromField
+ expanded: false
+ height: 20
+ basicHeight:20
+ index: 1
+ onExpandedChanged: {
+ if(expanded==true){
+ z=2;
+ mouse_area1.z=1;
+ }
+ else{
+ z=0;
+ mouse_area1.z=-1;
+ }
+ }
+ onValueSelected: rectangle1.fromChange(value)
}
- ElementsListView{
- id: dictList
- width: rectangle1.width
+ ComboBox {
+ id: comboTo
+ model: fromModell
+ anchors.right: comboToField.right
+ anchors.left: comboToField.left
+ parentField: comboToField
+ expanded: false
+ height: 20
+ basicHeight:20
+ index: 1
+ onExpandedChanged: {
+ if(expanded==true){
+ z=2;
+ mouse_area1.z=1;
+ }
+ else{
+ z=0;
+ mouse_area1.z=-1;
+ }
+ }
+ onValueSelected: rectangle1.toChange(value)
+ }
+
+ Item {
+ id: comboFromField
+ width: 120
+ anchors.left: fromLabel.right
+ anchors.leftMargin: 5
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 10
anchors.top: parent.top
+ }
+
+ Item {
+ id: comboToField
+ width: 120
+ anchors.left: toLabel.right
+ anchors.leftMargin: 5
anchors.bottom: parent.bottom
- highlightResizeSpeed: 1000
-
- header: Component{
- id: dictListHeader
- Item {
- width: rectangle1.width
- height: 20
- Row {
- anchors.fill: parent
- Rectangle {
- id: fromRecHeader
- width: horizontalScrollBar1.position
- height: parent.height
- radius: 1
- gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+ anchors.bottomMargin: 10
+ anchors.top: parent.top
+ }
- Text {
- id: fromTextHeader
- text: qsTr("From");
- elide: Text.ElideRight
- font.pixelSize: 12
- anchors.centerIn: parent
+ Text {
+ id: fromLabel
+ text: qsTr("From: ");
+ anchors.top: parent.top
+ anchors.topMargin: 3
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: toLabel
+ text: qsTr("To: ");
+ anchors.left: comboFrom.right
+ anchors.leftMargin: 15
+ anchors.verticalCenterOffset: 0
+ anchors.verticalCenter: fromLabel.verticalCenter
+ font.pixelSize: 12
+ }
+
+ Item {
+ id: item1
+ anchors.topMargin: 30
+ anchors.fill: parent
+ ScrollBar2 {
+ id: horizontalScrollBar1
+ z:2;
+ width: parent.width-12;
+ windowHeight: parent.height
+ anchors.left: parent.left
+ orientation: Qt.Horizontal
+ position: 100
+ }
+ ScrollBar2 {
+ id: horizontalScrollBar2
+ z:2;
+ width: parent.width-12;
+ windowHeight: parent.height
+ anchors.left: horizontalScrollBar1.left
+ anchors.leftMargin: horizontalScrollBar1.position
+ orientation: Qt.Horizontal
+ position: 100
+ }
+ ScrollBar2 {
+ id: horizontalScrollBar3
+ z:2;
+ width: parent.width-12;
+ windowHeight: parent.height
+ anchors.left: horizontalScrollBar2.left
+ anchors.leftMargin: horizontalScrollBar2.position
+ orientation: Qt.Horizontal
+ position: 100
+ }
+
+ ElementsListView{
+ id: dictList
+ width: rectangle1.width
+ anchors.topMargin: 0
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ highlightResizeSpeed: 1000
+
+ header: Component{
+ id: dictListHeader
+ Item {
+ width: rectangle1.width
+ height: 20
+ Row {
+ anchors.fill: parent
+ Rectangle {
+ id: fromRecHeader
+ width: horizontalScrollBar1.position
+ height: parent.height
+ radius: 1
+ gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+
+ Text {
+ id: fromTextHeader
+ text: qsTr("From");
+ elide: Text.ElideRight
+ font.pixelSize: 12
+ anchors.centerIn: parent
+ }
}
- }
- Rectangle {
- id: toRecHeader
- width: horizontalScrollBar2.position
- height: parent.height
- radius: 1
- gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+ Rectangle {
+ id: toRecHeader
+ width: horizontalScrollBar2.position
+ height: parent.height
+ radius: 1
+ gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
- Text {
- id: toTextHeader
- text: qsTr("To");
- elide: Text.ElideRight
- font.pixelSize: 12
- anchors.centerIn: parent
+ Text {
+ id: toTextHeader
+ text: qsTr("To");
+ elide: Text.ElideRight
+ font.pixelSize: 12
+ anchors.centerIn: parent
+ }
}
- }
- Rectangle {
- id: nameRecHeader
- width: horizontalScrollBar3.position
- height: parent.height
- radius: 1
- gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+ Rectangle {
+ id: nameRecHeader
+ width: horizontalScrollBar3.position
+ height: parent.height
+ radius: 1
+ gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
- Text {
- id: nameTextHeader
- text: qsTr("Title");
- elide: Text.ElideRight
- font.pixelSize: 12
- anchors.centerIn: parent
+ Text {
+ id: nameTextHeader
+ text: qsTr("Title");
+ elide: Text.ElideRight
+ font.pixelSize: 12
+ anchors.centerIn: parent
+ }
}
- }
- Rectangle {
- id: sizeRecHeader
- width: 100;
- height: parent.height
- radius: 1
- gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+ Rectangle {
+ id: sizeRecHeader
+ width: 100;
+ height: parent.height
+ radius: 1
+ gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
- Text {
- id: sizeTextHeader
- text: qsTr("Size");
- elide: Text.ElideRight
- font.pixelSize: 12
- anchors.centerIn: parent
+ Text {
+ id: sizeTextHeader
+ text: qsTr("Size");
+ elide: Text.ElideRight
+ font.pixelSize: 12
+ anchors.centerIn: parent
+ }
}
}
}
}
- }
- delegate: Component{
- id: dictListDelegate
- Item {
- width: rectangle1.width
- height:nameText.height
- MouseArea{
- anchors.fill: parent
- onClicked: {
- dictList.currentIndex = index
- }
- onDoubleClicked: {
- rectangle1.dictLink(link)
- }
- }
- Row {
- anchors.fill: parent
- Text {
- id: fromText
- text: " "+from+" ";
- width: horizontalScrollBar1.position
- elide: Text.ElideRight
+ delegate: Component{
+ id: dictListDelegate
+ Item {
+ width: rectangle1.width
+ height:nameText.height
+ MouseArea{
+ anchors.fill: parent
+ onClicked: {
+ dictList.currentIndex = index
+ }
+ onDoubleClicked: {
+ rectangle1.dictLink(link)
+ }
}
+ Row {
+ anchors.fill: parent
+ Text {
+ id: fromText
+ text: " "+from+" ";
+ width: horizontalScrollBar1.position
+ elide: Text.ElideRight
+ }
- Text {
- id: toText
- text: " "+to+" ";
- width: horizontalScrollBar2.position
- elide: Text.ElideRight
- }
+ Text {
+ id: toText
+ text: " "+to+" ";
+ width: horizontalScrollBar2.position
+ elide: Text.ElideRight
+ }
- Text {
- id: nameText
- text: " "+name+" ";
- width: horizontalScrollBar3.position
- elide: Text.ElideRight
- }
- Text {
- id: sizeText
- text: " "+size+" ";
- width: 100
- elide: Text.ElideRight
+ Text {
+ id: nameText
+ text: " "+name+" ";
+ width: horizontalScrollBar3.position
+ elide: Text.ElideRight
+ }
+ Text {
+ id: sizeText
+ text: " "+size+" ";
+ width: 100
+ elide: Text.ElideRight
+ }
}
}
}
+ model: dictModel
}
- model: dictModel
}
}
pathToUncheckedImage: UncheckedPath
anchors.right: parent.right
anchors.rightMargin: 5
-
+ pathToCheckedDicImage: CheckedPath
+ pathToUncheckedDicImage: UncheckedPath
anchors.verticalCenter: parent.verticalCenter
onChanged: rectangle1.changeWordState(number, selected)
visible: {
QWidget *parent) :
QDialog(parent) {
-
setWindowTitle(tr("Select dictionary"));
-
//here removing already added dictionary
for (int i = 0; i < dicts.size(); i++){
if(QFile::exists(QDir::homePath() + "/.mdictionary/" + dicts[i].title() + ".xdxf")){
#ifndef Q_WS_MAEMO_5
model2 = new DictsListModel(dicts, this);
proxyModel2 = new DictsProxyListModel;
- proxyModel2->setSourceModel(model2);
- proxyModel2->setTo("Polish");
+ proxyModel2->setSourceModel(model2);;
view= new QDeclarativeView();
QDeclarativeContext* ctxt=view->rootContext();
ctxt->setContextProperty("dictModel", proxyModel2);
+
+ QSet<QString> languagesFrom;
+ for(int i=0; i < model2->rowCount(QModelIndex()); i++)
+ languagesFrom.insert(model2->data(model2->index(i, 0),DictsListModel::FromRole).toString());
+ languagesFrom.remove(QString());
+ QStringList langFromList = languagesFrom.toList();
+ qSort(langFromList);
+ QList<QString> langListFrom;
+ langListFrom.append(tr("Any"));
+ foreach(QString lang,langFromList)
+ langListFrom.append(lang);
+ fromModel = new ComboBoxModel(langListFrom);
+ ctxt->setContextProperty("fromModell", fromModel);
+
+ QSet<QString> languagesTo;
+ for(int i=0; i < model2->rowCount(QModelIndex()); i++)
+ languagesTo.insert(model2->data(model2->index(i, 0),DictsListModel::ToRole).toString());
+ languagesTo.remove(QString());
+ QStringList langToList = languagesTo.toList();
+ qSort(langToList);
+ QList<QString> langListTo;
+ langListTo.append(tr("Any"));
+ foreach(QString lang,langToList)
+ langListTo.append(lang);
+ toModel = new ComboBoxModel(langListTo);
+ ctxt->setContextProperty("toModell", toModel);
+
view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/TableWidget.qml"));
view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
view->setAlignment(Qt::AlignCenter);
mainLayout = new QVBoxLayout;
mainLayout->addWidget(view);
this->setLayout(mainLayout);
- proxyModel2->setTo("English");
QGraphicsObject *rootObject = view->rootObject();
connect(rootObject,SIGNAL(dictLink(QString)),
this,SLOT(itemClicked(QString)));
+ connect(rootObject,SIGNAL(fromChange(QString)),
+ this,SLOT(fromChange(QString)));
+ connect(rootObject,SIGNAL(toChange(QString)),
+ this,SLOT(toChange(QString)));
+
#else
layout = new QVBoxLayout;
#endif
}
+void XdxfDictSelectDialog::toChange(QString lang){
+ if(lang!=tr("Any"))
+ proxyModel2->setTo(lang);
+ else
+ proxyModel2->setTo("");
+}
+
+void XdxfDictSelectDialog::fromChange(QString lang){
+ if(lang!=tr("Any"))
+ proxyModel2->setFrom(lang);
+ else
+ proxyModel2->setFrom("");
+}
void XdxfDictSelectDialog::initializeDicts() {
//scan of all languages of dictionaries, using QSet to get only distinct languages
}
void XdxfDictSelectDialog::itemClicked(QModelIndex index) {
-#ifdef Q_WS_MAEMO_5
+#ifndef Q_WS_MAEMO_5
+ index;
+#else
_link = index.model()->data(index, Qt::UserRole).toString();
accept();
#endif
#include <QDir>
#include <QDeclarativeView>
#include <QDeclarativeContext>
+#include <QList>
#include "DownloadDict.h"
#include "DictsListModel.h"
#include "DictsModel.h"
#include "DictsProxyModel.h"
#include "DictsProxyListModel.h"
+#include "../../include/ComboBoxModel.h"
/*!
void itemClicked(QString link);
+ void toChange(QString lang);
+ void fromChange(QString lang);
+
private:
QVBoxLayout* mainLayout;
QDeclarativeView *view;
DictsListModel* model2;
DictsProxyListModel *proxyModel2;
+ ComboBoxModel *fromModel;
+ ComboBoxModel *toModel;
QTreeView* treeView;
DictsModel* model;
XdxfDictDownloadProgressDialog.cpp \
DictsModel.cpp \
HttpDownloader.cpp \
- DictsListModel.cpp
+ DictsListModel.cpp \
+ ../../include/ComboBoxModel.cpp
HEADERS += xdxfplugin.h \
TranslationXdxf.h \
../../include/translation.h \
../../include/settings.h \
../../include/CommonDictInterface.h \
+ ../../include/ComboBoxModel.h \
XdxfCachingDialog.h \
XdxfDialog.h \
XdxfDictDownloader.h \