mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
*! Reverted all the changes made to groups screen in revision 200.
This commit is contained in:
parent
3c34e48089
commit
589e56dda2
|
@ -27,18 +27,8 @@ Groups::Groups( QWidget * parent,
|
|||
this, SLOT( addNew() ) );
|
||||
connect( ui.renameGroup, SIGNAL( clicked() ),
|
||||
this, SLOT( renameCurrent() ) );
|
||||
// connect( ui.emptyGroup, SIGNAL( clicked() ),
|
||||
// this, SLOT( emptyCurrent() ) );
|
||||
connect( ui.removeGroup, SIGNAL( clicked() ),
|
||||
this, SLOT( removeCurrent() ) );
|
||||
connect( ui.removeGroups, SIGNAL( clicked() ),
|
||||
this, SLOT( removeAll() ) );
|
||||
|
||||
connect( ui.tbAddDictsToGroup, SIGNAL( clicked() ),
|
||||
this, SLOT( addDictsToCurrentGroup() ) );
|
||||
connect( ui.tbRemoveDictsFromGroup, SIGNAL( clicked() ),
|
||||
this, SLOT( removeDictsFromCurrentGroup() ) );
|
||||
|
||||
|
||||
countChanged();
|
||||
}
|
||||
|
@ -53,12 +43,7 @@ void Groups::countChanged()
|
|||
bool en = ui.groups->count();
|
||||
|
||||
ui.renameGroup->setEnabled( en );
|
||||
// ui.emptyGroup->setEnabled( en );
|
||||
ui.removeGroup->setEnabled( en );
|
||||
ui.removeGroups->setEnabled( en );
|
||||
|
||||
ui.tbAddDictsToGroup->setEnabled( en );
|
||||
ui.tbRemoveDictsFromGroup->setEnabled( en );
|
||||
}
|
||||
|
||||
void Groups::addNew()
|
||||
|
@ -93,38 +78,6 @@ void Groups::renameCurrent()
|
|||
ui.groups->renameCurrentGroup( name );
|
||||
}
|
||||
|
||||
//void Groups::emptyCurrent()
|
||||
//{
|
||||
// int current = ui.groups->currentIndex();
|
||||
//
|
||||
// if ( current < 0 || QMessageBox::question( this, tr( "Empty group contents" ),
|
||||
// tr( "Are you sure you want to remove all the dictionaries from this group?" ),
|
||||
// QMessageBox::Yes, QMessageBox::Cancel ) != QMessageBox::Yes )
|
||||
// return;
|
||||
//
|
||||
// ui.groups->emptyCurrentGroup();
|
||||
//}
|
||||
|
||||
void Groups::addDictsToCurrentGroup()
|
||||
{
|
||||
int current = ui.groups->currentIndex();
|
||||
|
||||
if ( current >= 0 )
|
||||
{
|
||||
ui.groups->getCurrentModel()->addSelectedUniqueFromModel( ui.dictionaries->selectionModel() );
|
||||
}
|
||||
}
|
||||
|
||||
void Groups::removeDictsFromCurrentGroup()
|
||||
{
|
||||
int current = ui.groups->currentIndex();
|
||||
|
||||
if ( current >= 0 )
|
||||
{
|
||||
ui.groups->getCurrentModel()->removeSelectedRows( ui.groups->getCurrentSelectionModel() );
|
||||
}
|
||||
}
|
||||
|
||||
void Groups::removeCurrent()
|
||||
{
|
||||
int current = ui.groups->currentIndex();
|
||||
|
@ -137,16 +90,3 @@ void Groups::removeCurrent()
|
|||
countChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Groups::removeAll()
|
||||
{
|
||||
int current = ui.groups->currentIndex();
|
||||
|
||||
if ( current >= 0 && QMessageBox::question( this, tr( "Remove all groups" ),
|
||||
tr( "Are you sure you want to remove all the groups?" ),
|
||||
QMessageBox::Yes, QMessageBox::Cancel ) == QMessageBox::Yes )
|
||||
{
|
||||
ui.groups->removeAllGroups();
|
||||
countChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,13 +30,10 @@ private:
|
|||
void countChanged();
|
||||
|
||||
private slots:
|
||||
|
||||
void addNew();
|
||||
void renameCurrent();
|
||||
//void emptyCurrent();
|
||||
void addDictsToCurrentGroup();
|
||||
void removeDictsFromCurrentGroup();
|
||||
void removeCurrent();
|
||||
void removeAll();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
255
src/groups.ui
255
src/groups.ui
|
@ -1,196 +1,109 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<ui version="4.0" >
|
||||
<class>Groups</class>
|
||||
<widget class="QDialog" name="Groups">
|
||||
<property name="windowModality">
|
||||
<widget class="QDialog" name="Groups" >
|
||||
<property name="windowModality" >
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>784</width>
|
||||
<height>505</height>
|
||||
<width>726</width>
|
||||
<height>535</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<property name="windowTitle" >
|
||||
<string>Groups</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" >
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Dictionaries available</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="DictListWidget" name="dictionaries"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3" >
|
||||
<item>
|
||||
<widget class="QToolButton" name="tbAddDictsToGroup">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>></string>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Dictionaries available:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tbRemoveDictsFromGroup">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="DictListWidget" name="dictionaries" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>User groups</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="addGroup">
|
||||
<property name="toolTip">
|
||||
<string>Create a new dictionary group</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Add group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="renameGroup">
|
||||
<property name="toolTip">
|
||||
<string>Change current group's name</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Re&name group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeGroup">
|
||||
<property name="toolTip">
|
||||
<string>Remove group</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Remove group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeGroups">
|
||||
<property name="toolTip">
|
||||
<string>Remove all groups</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove all groups</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="DictGroupsWidget" name="groups">
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::North</enum>
|
||||
</property>
|
||||
<property name="tabShape">
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="elideMode">
|
||||
<enum>Qt::ElideRight</enum>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_4">
|
||||
<attribute name="title">
|
||||
<string>Tab 2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Groups:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="DictGroupsWidget" name="groups" >
|
||||
<property name="tabPosition" >
|
||||
<enum>QTabWidget::North</enum>
|
||||
</property>
|
||||
<property name="elideMode" >
|
||||
<enum>Qt::ElideRight</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_4" >
|
||||
<attribute name="title" >
|
||||
<string>Tab 2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||
<item>
|
||||
<widget class="QPushButton" name="addGroup" >
|
||||
<property name="text" >
|
||||
<string>&Add group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="renameGroup" >
|
||||
<property name="text" >
|
||||
<string>Re&name group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeGroup" >
|
||||
<property name="text" >
|
||||
<string>&Remove group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Drag & drop dictionaries to and from the groups, move them inside the groups, reorder the groups using your mouse.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttons">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Drag&drop dictionaries to and from the groups, move them inside the groups, reorder the groups using your mouse.</string>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttons" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -215,11 +128,11 @@
|
|||
<receiver>Groups</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<hint type="sourcelabel" >
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<hint type="destinationlabel" >
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
|
@ -231,11 +144,11 @@
|
|||
<receiver>Groups</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<hint type="sourcelabel" >
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<hint type="destinationlabel" >
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
|
|
|
@ -79,80 +79,9 @@ std::vector< sptr< Dictionary::Class > > const &
|
|||
return dictionaries;
|
||||
}
|
||||
|
||||
void DictListModel::removeSelectedRows( QItemSelectionModel * source )
|
||||
{
|
||||
if ( !source )
|
||||
return;
|
||||
|
||||
QModelIndexList rows = source->selectedRows();
|
||||
|
||||
if ( !rows.count() )
|
||||
return;
|
||||
|
||||
for ( int i = rows.count()-1; i >= 0; --i )
|
||||
{
|
||||
dictionaries.erase( dictionaries.begin() + rows.at( i ).row() );
|
||||
}
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
void DictListModel::addSelectedUniqueFromModel( QItemSelectionModel * source )
|
||||
{
|
||||
if ( !source )
|
||||
return;
|
||||
|
||||
QModelIndexList rows = source->selectedRows();
|
||||
|
||||
if ( !rows.count() )
|
||||
return;
|
||||
|
||||
const DictListModel * baseModel = dynamic_cast< const DictListModel * > ( source->model() );
|
||||
if ( !baseModel )
|
||||
return;
|
||||
|
||||
QVector< Dictionary::Class * > list;
|
||||
QVector< Dictionary::Class * > dicts;
|
||||
for ( int i = 0; i < dictionaries.size(); i++ )
|
||||
dicts.append( dictionaries.at( i ).get() );
|
||||
|
||||
for ( int i = 0; i < rows.count(); i++ )
|
||||
{
|
||||
Dictionary::Class * d =
|
||||
static_cast< Dictionary::Class * > ( rows.at( i ).internalPointer() );
|
||||
|
||||
//qDebug() << "rows.at( i ).internalPointer() " << rows.at( i ).internalPointer();
|
||||
|
||||
if ( !d )
|
||||
continue;
|
||||
|
||||
// sptr< Dictionary::Class > s ( d );
|
||||
//
|
||||
// if ( std::find( dictionaries.begin(), dictionaries.end(), s ) == dictionaries.end() )
|
||||
// continue;
|
||||
//
|
||||
// qDebug() << "std::find ";
|
||||
|
||||
if ( !dicts.contains( d ) )
|
||||
list.append( d );
|
||||
|
||||
//list.push_back( s );
|
||||
}
|
||||
|
||||
if ( list.empty() )
|
||||
return;
|
||||
|
||||
// qDebug() << "list " << list.size();
|
||||
|
||||
for ( int i = 0; i < list.size(); i++ )
|
||||
dictionaries.push_back( sptr< Dictionary::Class > ( list.at( i ) ) );
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
Qt::ItemFlags DictListModel::flags( QModelIndex const & index ) const
|
||||
{
|
||||
Qt::ItemFlags defaultFlags = QAbstractItemModel::flags( index );
|
||||
Qt::ItemFlags defaultFlags = QAbstractListModel::flags( index );
|
||||
|
||||
if (index.isValid())
|
||||
return Qt::ItemIsDragEnabled | defaultFlags;
|
||||
|
@ -172,69 +101,20 @@ QVariant DictListModel::data( QModelIndex const & index, int role ) const
|
|||
if ( !item )
|
||||
return QVariant();
|
||||
|
||||
switch ( index.column() )
|
||||
switch ( role )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
switch ( role )
|
||||
{
|
||||
case Qt::DisplayRole :
|
||||
return QString::fromUtf8( item->getName().c_str() );
|
||||
// + QString(" lang: %1 %2").arg( langCoder.decode(item->getLangFrom()),
|
||||
// langCoder.decode(item->getLangTo()) );
|
||||
case Qt::DisplayRole :
|
||||
return QString::fromUtf8( item->getName().c_str() );
|
||||
// + QString(" lang: %1 %2").arg( langCoder.decode(item->getLangFrom()),
|
||||
// langCoder.decode(item->getLangTo()) );
|
||||
|
||||
case Qt::EditRole :
|
||||
return QString::fromUtf8( item->getId().c_str() );
|
||||
case Qt::EditRole :
|
||||
return QString::fromUtf8( item->getId().c_str() );
|
||||
|
||||
case Qt::DecorationRole:
|
||||
return item->getIcon();
|
||||
|
||||
default:;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
switch ( role )
|
||||
{
|
||||
case Qt::DisplayRole :
|
||||
return LangCoder::decode( item->getLangFrom() ).left( 3 );
|
||||
|
||||
case Qt::EditRole :
|
||||
break;
|
||||
|
||||
case Qt::DecorationRole:
|
||||
return LangCoder::icon( item->getLangFrom() );
|
||||
|
||||
default:;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
switch ( role )
|
||||
{
|
||||
case Qt::DisplayRole :
|
||||
return LangCoder::decode( item->getLangTo() ).left( 3 );
|
||||
|
||||
case Qt::EditRole :
|
||||
break;
|
||||
|
||||
case Qt::DecorationRole:
|
||||
return LangCoder::icon( item->getLangTo() );
|
||||
|
||||
default:;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case Qt::DecorationRole:
|
||||
return item->getIcon();
|
||||
|
||||
default:;
|
||||
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
@ -261,7 +141,7 @@ bool DictListModel::removeRows( int row, int count,
|
|||
|
||||
beginRemoveRows( parent, row, row + count - 1 );
|
||||
dictionaries.erase( dictionaries.begin() + row,
|
||||
count == INT_MAX ? dictionaries.end() : dictionaries.begin() + row + count );
|
||||
dictionaries.begin() + row + count );
|
||||
endRemoveRows();
|
||||
|
||||
return true;
|
||||
|
@ -280,80 +160,45 @@ bool DictListModel::setData( QModelIndex const & index, const QVariant & value,
|
|||
return true;
|
||||
}
|
||||
|
||||
// if ( role == Qt::EditRole )
|
||||
// {
|
||||
// Config::Group g;
|
||||
//
|
||||
// g.dictionaries.push_back( Config::DictionaryRef( value.toString(), QString() ) );
|
||||
//
|
||||
// Instances::Group i( g, *allDicts );
|
||||
//
|
||||
// if ( i.dictionaries.size() == 1 )
|
||||
// {
|
||||
// // Found that dictionary
|
||||
// dictionaries[ index.row() ] = i.dictionaries.front();
|
||||
//
|
||||
// emit dataChanged( index, index );
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
if ( role == Qt::EditRole )
|
||||
{
|
||||
Config::Group g;
|
||||
|
||||
g.dictionaries.push_back( Config::DictionaryRef( value.toString(), QString() ) );
|
||||
|
||||
Instances::Group i( g, *allDicts );
|
||||
|
||||
if ( i.dictionaries.size() == 1 )
|
||||
{
|
||||
// Found that dictionary
|
||||
dictionaries[ index.row() ] = i.dictionaries.front();
|
||||
|
||||
emit dataChanged( index, index );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::DropActions DictListModel::supportedDropActions() const
|
||||
{
|
||||
return 0; //Qt::MoveAction;
|
||||
}
|
||||
|
||||
QModelIndex DictListModel::index( int row, int column, const QModelIndex &parent ) const
|
||||
{
|
||||
return createIndex( row, column, dictionaries.at( row ).get() );
|
||||
}
|
||||
|
||||
QModelIndex DictListModel::parent( const QModelIndex & child ) const
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QVariant DictListModel::headerData ( int section, Qt::Orientation orientation, int role ) const
|
||||
{
|
||||
if ( role == Qt::DisplayRole )
|
||||
{
|
||||
switch ( section )
|
||||
{
|
||||
case 0: return tr( "Dictionary" );
|
||||
case 1: return tr( "Source" );
|
||||
case 2: return tr( "Target" );
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
return QAbstractItemModel::headerData( section, orientation, role );
|
||||
return Qt::MoveAction;
|
||||
}
|
||||
|
||||
/// DictListWidget
|
||||
|
||||
DictListWidget::DictListWidget( QWidget * parent ): QTreeView( parent ),
|
||||
DictListWidget::DictListWidget( QWidget * parent ): QListView( parent ),
|
||||
model( this )
|
||||
{
|
||||
setModel( &model );
|
||||
|
||||
setSelectionMode( ExtendedSelection );
|
||||
|
||||
setDragEnabled( false );
|
||||
setAcceptDrops( false );
|
||||
setDropIndicatorShown( false );
|
||||
|
||||
setRootIsDecorated( false );
|
||||
setItemsExpandable( false );
|
||||
// setSortingEnabled( true );
|
||||
|
||||
header()->setAlternatingRowColors( true );
|
||||
header()->setResizeMode( QHeaderView::ResizeToContents );
|
||||
// header()->setSortIndicatorShown( true );
|
||||
// header()->setSortIndicator( 1, Qt::AscendingOrder );
|
||||
setDragEnabled( true );
|
||||
setAcceptDrops( true );
|
||||
setDropIndicatorShown( true );
|
||||
}
|
||||
|
||||
DictListWidget::~DictListWidget()
|
||||
|
@ -436,32 +281,6 @@ Config::Groups DictGroupsWidget::makeGroups() const
|
|||
return result;
|
||||
}
|
||||
|
||||
DictListModel * DictGroupsWidget::getCurrentModel() const
|
||||
{
|
||||
int current = currentIndex();
|
||||
|
||||
if ( current >= 0 )
|
||||
{
|
||||
DictGroupWidget * w = ( DictGroupWidget * ) widget( current );
|
||||
return w->getModel();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
QItemSelectionModel * DictGroupsWidget::getCurrentSelectionModel() const
|
||||
{
|
||||
int current = currentIndex();
|
||||
|
||||
if ( current >= 0 )
|
||||
{
|
||||
DictGroupWidget * w = ( DictGroupWidget * ) widget( current );
|
||||
return w->getSelectionModel();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DictGroupsWidget::addNewGroup( QString const & name )
|
||||
{
|
||||
if ( !allDicts )
|
||||
|
@ -498,17 +317,6 @@ void DictGroupsWidget::renameCurrentGroup( QString const & name )
|
|||
setTabText( current, escapeAmps( name ) );
|
||||
}
|
||||
|
||||
void DictGroupsWidget::emptyCurrentGroup()
|
||||
{
|
||||
int current = currentIndex();
|
||||
|
||||
if ( current >= 0 )
|
||||
{
|
||||
DictGroupWidget * w = ( DictGroupWidget * ) widget( current );
|
||||
w->getModel()->removeRows( );
|
||||
}
|
||||
}
|
||||
|
||||
void DictGroupsWidget::removeCurrentGroup()
|
||||
{
|
||||
int current = currentIndex();
|
||||
|
@ -520,14 +328,3 @@ void DictGroupsWidget::removeCurrentGroup()
|
|||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
void DictGroupsWidget::removeAllGroups()
|
||||
{
|
||||
while ( count() )
|
||||
{
|
||||
QWidget * w = widget( 0 );
|
||||
removeTab( 0 );
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,20 +6,20 @@
|
|||
|
||||
// Various custom widgets used in the Groups dialog
|
||||
|
||||
#include <QtGui>
|
||||
#include <QListWidget>
|
||||
#include "config.hh"
|
||||
#include "dictionary.hh"
|
||||
#include <vector>
|
||||
|
||||
/// A model to be projected into the view, according to Qt's MVC model
|
||||
class DictListModel: public QAbstractItemModel
|
||||
class DictListModel: public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
DictListModel( QWidget * parent ):
|
||||
QAbstractItemModel( parent ), isSource( false ), allDicts( 0 )
|
||||
QAbstractListModel( parent ), isSource( false ), allDicts( 0 )
|
||||
{}
|
||||
|
||||
/// Populates the current model with the given dictionaries. This is
|
||||
|
@ -32,20 +32,12 @@ public:
|
|||
/// Returns the dictionaries the model currently has listed
|
||||
std::vector< sptr< Dictionary::Class > > const & getCurrentDictionaries() const;
|
||||
|
||||
void removeSelectedRows( QItemSelectionModel * source );
|
||||
void addSelectedUniqueFromModel( QItemSelectionModel * source );
|
||||
|
||||
Qt::ItemFlags flags( QModelIndex const &index ) const;
|
||||
int rowCount( QModelIndex const & parent ) const;
|
||||
int columnCount( QModelIndex const & parent ) const { return 3; }
|
||||
QVariant data( QModelIndex const & index, int role ) const;
|
||||
bool insertRows( int row, int count, const QModelIndex & parent = QModelIndex() );
|
||||
bool removeRows( int row = 0, int count = INT_MAX, const QModelIndex & parent = QModelIndex() );
|
||||
bool insertRows( int row, int count, const QModelIndex & parent );
|
||||
bool removeRows( int row, int count, const QModelIndex & parent );
|
||||
bool setData( QModelIndex const & index, const QVariant & value, int role );
|
||||
QModelIndex index( int row, int column,
|
||||
const QModelIndex &parent = QModelIndex() ) const;
|
||||
QModelIndex parent( const QModelIndex &child ) const;
|
||||
QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
|
||||
|
||||
Qt::DropActions supportedDropActions() const;
|
||||
|
||||
|
@ -58,7 +50,7 @@ private:
|
|||
|
||||
/// This widget is for dictionaries' lists, it handles drag-n-drop operations
|
||||
/// with them etc.
|
||||
class DictListWidget: public QTreeView
|
||||
class DictListWidget: public QListView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -75,8 +67,6 @@ public:
|
|||
/// Returns the dictionaries the widget currently has listed
|
||||
std::vector< sptr< Dictionary::Class > > const & getCurrentDictionaries() const;
|
||||
|
||||
DictListModel * getModel()
|
||||
{ return & model; }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -100,12 +90,6 @@ public:
|
|||
/// (it is known by the containing tab widget only), it is returned as empty.
|
||||
Config::Group makeGroup() const;
|
||||
|
||||
DictListModel * getModel() const
|
||||
{ return ui.dictionaries->getModel(); }
|
||||
|
||||
QItemSelectionModel * getSelectionModel() const
|
||||
{ return ui.dictionaries->selectionModel(); }
|
||||
|
||||
private:
|
||||
Ui::DictGroupWidget ui;
|
||||
unsigned groupId;
|
||||
|
@ -133,21 +117,12 @@ public:
|
|||
/// Changes the name of the currently chosen group, if any, to the given one
|
||||
void renameCurrentGroup( QString const & );
|
||||
|
||||
void emptyCurrentGroup();
|
||||
|
||||
/// Removes the currently chosen group, if any
|
||||
void removeCurrentGroup();
|
||||
|
||||
/// Removes all the groups
|
||||
void removeAllGroups();
|
||||
|
||||
/// Creates groups from what is currently set up
|
||||
Config::Groups makeGroups() const;
|
||||
|
||||
DictListModel * getCurrentModel() const;
|
||||
|
||||
QItemSelectionModel * getCurrentSelectionModel() const;
|
||||
|
||||
private:
|
||||
|
||||
unsigned nextId;
|
||||
|
|
Loading…
Reference in a new issue