GUIInterface(parent),
ui(new Ui::MainWindow) {
+ #ifdef Q_WS_MAEMO_5
+ setAttribute(Qt::WA_Maemo5StackedWindow);
+ #endif
+
this->backbone = backbone;
initializeUI();
void MainWindow::initializeUI() {
ui->setupUi(this);
+ //showFullScreen();
//sets attribute to maemo's stacked window
- #ifdef Q_WS_MAEMO_5
- setAttribute(Qt::WA_Maemo5StackedWindow);
- #endif
+
searchBarWidget = new SearchBarWidget;
searchPushButton = new QPushButton(tr("Search"));
- searchPushButton->setMinimumWidth(150);
+ searchPushButton->setMinimumWidth(125);
#ifndef Q_WS_MAEMO_5
searchPushButton->setMinimumHeight(
searchPushButton->sizeHint().height()*2);
#endif
searchWordLineEdit = new QLineEdit();
- searchWordLineEdit->setMinimumWidth(300);
+ searchWordLineEdit->setMinimumWidth(250);
#ifndef Q_WS_MAEMO_5
searchWordLineEdit->setMinimumHeight(
clearSearchWordToolButton->sizeHint().height()*2);
#endif
+ fullScreenToolButton = new QToolButton();
+ #ifdef Q_WS_MAEMO_5
+ fullScreenToolButton->setIcon(
+ generateIcon(QIcon::fromTheme("general_fullsize")));
+ #else
+ fullScreenToolButton->setIcon(
+ generateIcon(QIcon::fromTheme("view-fullscreen")));
+ fullScreenToolButton->setMinimumSize(
+ fullScreenToolButton->sizeHint().height()*2,
+ fullScreenToolButton->sizeHint().height()*2);
+ #endif
+
searchingProgressBar = new QProgressBar();
//progress bar have minimum and maximum values set to 0, which will effect
horizontalLayout->addWidget(historyPrevToolButton);
horizontalLayout->addWidget(historyShowToolButton);
horizontalLayout->addWidget(historyNextToolButton);
+ horizontalLayout->addWidget(fullScreenToolButton);
//adding clear toolButton to textEdit with right alignment
lineEditLayout->addWidget(clearSearchWordToolButton, 0,
QToolButton* historyPrevToolButton;
QToolButton* historyNextToolButton;
QToolButton* historyShowToolButton;
+ QToolButton* fullScreenToolButton;
QHBoxLayout* horizontalLayout;
QProgressBar* searchingProgressBar;
}
void TranslationWidget::show(QStringList translations) {
+
show();
textEdit->clear();
connect(zoomInToolButton, SIGNAL(clicked()),
this, SIGNAL(updateSize()));
+ /* #ifdef Q_WS_MAEMO_5
+ fullScreenButton = new QToolButton(this);
+ fullScreenButton->setIcon(QIcon::fromTheme("general_fullsize"));
+ fullScreenButton->setMinimumSize(fullScreenButton->sizeHint());
+ int x = QApplication::desktop()->screenGeometry(this).width() -
+ fullScreenButton->sizeHint().width();
+ int y = QApplication::desktop()->screenGeometry(this).height() -
+ fullScreenButton->sizeHint().height();
+ fullScreenButton->move(QPoint(x,y));
+ fullScreenButton->show();
+ fullScreenButton->setWindowOpacity(0.5);
+
+
+ backButton = new QToolButton(this);
+ backButton->setIcon(QIcon::fromTheme("general_overlay_back"));
+ backButton->setMinimumSize(fullScreenButton->sizeHint());
+ x = QApplication::desktop()->screenGeometry(this).width() -
+ backButton->sizeHint().width();
+ y = 0;
+ backButton->move(QPoint(x,y));
+ backButton->show();
+ backButton->setWindowOpacity(0.5);
+
+ connect(backButton, SIGNAL(clicked()),
+ this, SLOT(hide()));
+ #endif*/
}
QTextEdit *textEdit;
QToolButton* zoomInToolButton;
QToolButton* zoomOutToolButton;
+ #ifdef Q_WS_MAEMO_5
+ QToolButton* fullScreenButton;
+ QToolButton* backButton;
+ #endif
QVBoxLayout *verticalLayout;
QHBoxLayout* horizontalLayout;
TranslationWidgetAutoResizer* resizer;
#endif
WordListWidget::WordListWidget(QWidget *parent):
- QListWidget(parent) {
+ QTreeView(parent) {
- connect(this, SIGNAL(itemPressed(QListWidgetItem*)),
- this, SLOT(wordPressed(QListWidgetItem*)));
+ model = new QStandardItemModel(this);
+ setModel(model);
+ setHeaderHidden(true);
+ setRootIsDecorated(false);
-
- connect(this, SIGNAL(itemClicked(QListWidgetItem*)),
- this, SLOT(wordClicked(QListWidgetItem*)));
+ #ifdef Q_WS_MAEMO_5
+ checkBoxWidth = 70;
+ #else
+ checkBoxWidth = 25;
+ #endif
setStyle(new WordListProxyStyle);
- setLayoutDirection(Qt::RightToLeft);
-
}
-void WordListWidget::addWord(QString word) {
- QListWidgetItem* item = new QListWidgetItem(word, this);
- item->setCheckState(Qt::Unchecked);
- item->setTextAlignment(Qt::AlignRight);
+void WordListWidget::addWord(QString word, int row) {
+ QStandardItem* item = new QStandardItem(word);
+ item->setFlags(item->flags() ^ Qt::ItemIsEditable);
+ QStandardItem* itemCheckBox = new QStandardItem();
+ itemCheckBox->setFlags(itemCheckBox->flags() ^ Qt::ItemIsEditable |
+ Qt::ItemIsUserCheckable);
+ itemCheckBox->setCheckState(Qt::Checked);
+
+ model->setItem(row,0, item);
+ model->setItem(row,1, itemCheckBox);
}
void WordListWidget::showSearchResults(
QHash<QString, QList<Translation *> > result) {
- clear();
+ model->clear();
searchResult.clear();
+ model->setColumnCount(2);
+ model->setRowCount(result.count());
+
searchResult = result;
+ int row=0;
QHash<QString, QList<Translation*> >::iterator i;
for(i = result.begin(); i != result.end(); i++) {
- addWord(i.key());
+ addWord(i.key(), row++);
}
+
+ qDebug()<<width();
+ setColumnWidth(0, width()-checkBoxWidth - 20);
+ setColumnWidth(1, checkBoxWidth);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+}
+
+void WordListWidget::wordClicked(QModelIndex index) {
+ emit showTranslation(
+ searchResult[index.data().toString()]);
}
-void WordListWidget::wordClicked(QListWidgetItem *item) {
- if(itemState == item->checkState()) {
- emit showTranslation(
- searchResult[item->data(Qt::DisplayRole).toString()]);
+void WordListWidget::wordChecked(QModelIndex index) {
+ Qt::CheckState state =
+ Qt::CheckState(index.data(Qt::CheckStateRole).toInt());
+
+ QModelIndex item = selectedIndexes().at(0);
+
+ if(state == Qt::Checked) {
+ qDebug()<<"Added "<<item.data().toString();
+ emit addBookmark(searchResult[item.data().toString()]);
}
else {
- if(item->checkState() == Qt::Checked) {
- emit addBookmark(
- searchResult[item->data(Qt::DisplayRole).toString()]);
- }
- else {
- emit removeBookmark(
- searchResult[item->data(Qt::DisplayRole).toString()]);
- }
+ qDebug()<<"Removed "<<item.data().toString();
+ emit removeBookmark(searchResult[item.data().toString()]);
}
}
-void WordListWidget::wordPressed(QListWidgetItem *item) {
- itemState = item->checkState();
+
+void WordListWidget::mouseReleaseEvent(QMouseEvent *event) {
+ QTreeView::mouseReleaseEvent(event);
+
+
+ QModelIndex index = indexAt(event->pos());
+ int c = index.column();
+ if(c==0)
+ wordClicked(index);
+ else
+ wordChecked(index);
}
+void WordListWidget::resizeEvent(QResizeEvent *event) {
+ setColumnWidth(0, width()-checkBoxWidth - 20);
+ setColumnWidth(1, checkBoxWidth);
+ QTreeView::resizeEvent(event);
+}
void WordListWidget::lockList() {
setEnabled(false);
/*!
It allow user to select word to see it's translation or to mark it as "star"
*/
-class WordListWidget : public QListWidget {
+class WordListWidget : public QTreeView {
Q_OBJECT
public:
explicit WordListWidget(QWidget *parent = 0);
+
Q_SIGNALS:
//! Request to show translation which is described by passed translations
//! objects
//! Unlocks words list
void unlockList();
+protected:
+ void mouseReleaseEvent(QMouseEvent *event);
+ void resizeEvent(QResizeEvent *event);
+
private Q_SLOTS:
- void wordClicked(QListWidgetItem* item);
- void wordPressed(QListWidgetItem* item);
+ void wordClicked(QModelIndex index);
+ void wordChecked(QModelIndex index);
private:
- void addWord(QString word);
+ void addWord(QString word, int row);
+ QStandardItemModel* model;
+ int checkBoxWidth;
Qt::CheckState itemState;
QHash<QString, QList<Translation*> > searchResult;