• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

parley

containerview.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003     Copyright 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
00004 
00005  ***************************************************************************/
00006 
00007 /***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  ***************************************************************************/
00015 
00016 #include "containerview.h"
00017 
00018 #include "prefs.h"
00019 #include "containermodel.h"
00020 
00021 #include <KAction>
00022 #include <KMessageBox>
00023 #include <KInputDialog>
00024 #include <kdebug.h>
00025 #include <klocale.h>
00026 #include <kiconloader.h>
00027 #include <kicon.h>
00028 #include <kconfig.h>
00029 #include <keduvocdocument.h>
00030 #include <keduvoclesson.h>
00031 #include <keduvocwordtype.h>
00032 #include <keduvocexpression.h>
00033 #include <QTreeView>
00034 #include <QHeaderView>
00035 #include <QMenu>
00036 #include <QContextMenuEvent>
00037 
00038 ContainerView::ContainerView(QWidget *parent) : QTreeView(parent)
00039 {
00040     header()->setStretchLastSection(false);
00041     header()->setVisible(false);
00042 
00043     setAlternatingRowColors(true);
00044 
00045     // show the actions added by addAction() as right click menu.
00046     setContextMenuPolicy(Qt::ActionsContextMenu);
00047     setSelectionMode(QAbstractItemView::SingleSelection);
00048     // setSelectionBehavior(QAbstractItemView::SelectRows);
00049 
00050     setDragEnabled(true);
00051     setAcceptDrops(true);
00052     setDropIndicatorShown(true);
00053     setDragDropMode(QAbstractItemView::DragDrop);
00054 }
00055 
00056 void ContainerView::setModel(ContainerModel *model)
00057 {
00058     QTreeView::setModel(model);
00059     m_model = model;
00060 
00061     header()->setResizeMode(0, QHeaderView::Stretch);
00062     header()->setResizeMode(1, QHeaderView::ResizeToContents);
00063 }
00064 
00065 void ContainerView::setTranslation(KEduVocExpression * entry, int translation)
00066 {
00068     if (entry == 0) {
00069         return;
00070     }
00071 
00072     // who am I
00073     if(m_model->containerType() == KEduVocContainer::Lesson) {
00074         QModelIndex current = m_model->index(entry->lesson());
00075         selectionModel()->select(current, QItemSelectionModel::ClearAndSelect);
00076         scrollTo(current);
00077         return;
00078     }
00079 
00080     if(m_model->containerType() == KEduVocContainer::WordType) {    
00081     // attempt to find the container to select
00082         QModelIndex modelIndex;
00083         modelIndex = m_model->index(entry->translation(translation)->wordType());
00084         scrollTo(modelIndex);
00085         selectionModel()->select(modelIndex, QItemSelectionModel::ClearAndSelect);
00086         return;
00087     }
00088 // leitner as well?
00089 
00090     selectionModel()->clearSelection();
00091     return;
00092 }
00093 
00094 void ContainerView::slotRename()
00095 {
00096     edit(selectionModel()->currentIndex());
00097 }
00098 
00099 #include "containerview.moc"
00100 
00101 

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  •     lib
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal