/***************************************************************************
* Copyright (C) 2006 by Lawrence Lee *
* valheru@facticius.net *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QHeaderView>
#include <QMessageBox>
#include "serverListModel.h"
serverListModel
::serverListModel( QObject *parent
){
p = parent;
}
serverListModel::~serverListModel()
{
}
{
}
{
}
int serverListModel
::rowCount( const QModelIndex &parent
) const {
return list.count();
}
int serverListModel
::columnCount( const QModelIndex &parent
) const {
if( p->objectName() == "serverTreeList" ){
return 1;
}
if( p->objectName() == "articleTreeList" ){
return 3;
}
}
{
return list.at( index.row() );
}
QVariant serverListModel
::headerData( int section, Qt
::Orientation orientation,
int role
) const {
if( role != Qt::DisplayRole ){
}else{
if( p->objectName() == "serverTreeList" ){
}
if( p->objectName() == "articleTreeList" ){
}
}
}
Qt
::ItemFlags serverListModel
::flags( const QModelIndex &index
) const{
return Qt::ItemIsEnabled;
}
{
list.replace(index.row(), value.toString());
emit dataChanged(index, index);
return true;
}
bool serverListModel
::insertRows( int position,
int rows,
const QModelIndex &parent
) {
beginInsertRows
( QModelIndex(), position, position
+ rows
- 1 );
for( int row = 0; row < rows; ++row ){
list.insert(position, "");
}
endInsertRows();
return true;
}
bool serverListModel
::removeRows( int position,
int rows,
const QModelIndex &parent
) {
beginRemoveRows
( QModelIndex(), position, position
+ rows
- 1 );
for( int row = 0; row < rows; ++row ){
list.removeAt(position);
}
endRemoveRows();
return true;
}
void serverListModel::addItem( const QString& item )
{
beginInsertRows( index, 1, 1 );
list.insert(list.size(), item);
endInsertRows();
for( int i = 0; i < list.size(); i++ ){
msg->exec();
}
}
/***************************************************************************
* Copyright (C) 2006 by Lawrence Lee *
* valheru@facticius.net *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QHeaderView>
#include <QMessageBox>
#include "serverListModel.h"
serverListModel::serverListModel( QObject *parent )
{
p = parent;
}
serverListModel::~serverListModel()
{
}
QModelIndex serverListModel::index( int row, int column, const QModelIndex &parent ) const
{
return QModelIndex();
}
QModelIndex serverListModel::parent( const QModelIndex &index ) const
{
return QModelIndex();
}
int serverListModel::rowCount( const QModelIndex &parent ) const
{
return list.count();
}
int serverListModel::columnCount( const QModelIndex &parent ) const
{
if( p->objectName() == "serverTreeList" ){
return 1;
}
if( p->objectName() == "articleTreeList" ){
return 3;
}
}
QVariant serverListModel::data( const QModelIndex &index, int role ) const
{
return list.at( index.row() );
}
QVariant serverListModel::headerData( int section, Qt::Orientation orientation, int role ) const
{
if( role != Qt::DisplayRole ){
return QVariant();
}else{
if( p->objectName() == "serverTreeList" ){
return QString( "Server List" );
}
if( p->objectName() == "articleTreeList" ){
return QString( "Article List" );
}
}
}
Qt::ItemFlags serverListModel::flags( const QModelIndex &index ) const
{
return Qt::ItemIsEnabled;
}
bool serverListModel::setData( const QModelIndex &index, const QVariant &value, int role )
{
list.replace(index.row(), value.toString());
emit dataChanged(index, index);
return true;
}
bool serverListModel::insertRows( int position, int rows, const QModelIndex &parent )
{
beginInsertRows( QModelIndex(), position, position + rows - 1 );
for( int row = 0; row < rows; ++row ){
list.insert(position, "");
}
endInsertRows();
return true;
}
bool serverListModel::removeRows( int position, int rows, const QModelIndex &parent )
{
beginRemoveRows( QModelIndex(), position, position + rows - 1 );
for( int row = 0; row < rows; ++row ){
list.removeAt(position);
}
endRemoveRows();
return true;
}
void serverListModel::addItem( const QString& item )
{
QModelIndex index;
beginInsertRows( index, 1, 1 );
list.insert(list.size(), item);
endInsertRows();
for( int i = 0; i < list.size(); i++ ){
QMessageBox *msg = new QMessageBox( "list", "list[" + QString::number(i) + "] = " + list[i],
QMessageBox::Information, QMessageBox::Ok, 0, 0 );
msg->exec();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks