RioMMKeywordsDialog Class Reference

#include <RioMMKeywordsDialog.h>

Public Member Functions

 RioMMKeywordsDialog (QWidget *parent=0, const char *name=0, WFlags f=0)
QString indexPositions ()
void Initialize (QDomDocument domTree)

Private Slots

void processKeyword ()

Private Member Functions

void buildKeywords (QDomDocument domTree)
int buildKeywordsTree (QListViewItem *parentItem, const QDomElement &parentElement, QPtrStack< QListViewItem > *stack)

Private Attributes

QGridLayout * main_layout
QListView * keywords
QPushButton * but_Ok
QPushButton * but_Cancel

Detailed Description

Definition at line 43 of file RioMMKeywordsDialog.h.


Constructor & Destructor Documentation

RioMMKeywordsDialog::RioMMKeywordsDialog ( QWidget *  parent = 0,
const char *  name = 0,
WFlags  f = 0 
)

Definition at line 22 of file RioMMKeywordsDialog.cpp.

00024     : QDialog( parent, name, true, f )
00025 {
00026 }


Member Function Documentation

void RioMMKeywordsDialog::buildKeywords ( QDomDocument  domTree  )  [private]

Definition at line 28 of file RioMMKeywordsDialog.cpp.

00029 {
00030     int readkeywords = 0;
00031 
00032     // Div. configuration of the list view.
00033     keywords->addColumn( "Palavras-chave", 1 );
00034     keywords->addColumn( "Index_Indices", 1 );
00035     keywords->setSorting( -1 );
00036 
00037     // A busca deve come�ar habilitada.
00038     keywords->setEnabled( true );
00039 
00040     // Get the header information from the DOM.
00041     QDomElement root = domTree.documentElement();
00042     QDomNode    node;
00043 
00044     // Create the tree view out of the DOM.
00045     QPtrStack<QListViewItem> stack;
00046     stack.setAutoDelete( false );
00047     stack.clear();
00048     readkeywords = buildKeywordsTree( 0, root, &stack );
00049     stack.clear();
00050 
00051     int tmp = ( readkeywords < MAX_KEYWORD_VIEW )? 0:1;
00052 
00053     keywords->setColumnWidth( 0, width() - 2*SPACING - tmp *
00054                               keywords->verticalScrollBar()->sizeHint().width()
00055                               - ADJUST_SCROLL );
00056 
00057     // Tamanho m�ximo comporta MAX_KEYWORD_VIEW palavras-chave.
00058     if( readkeywords < 3 )
00059         readkeywords = 3; // Menor tamanho deve comportar 3 palavras-chave
00060                           // (por est�tica).
00061 
00062     if( readkeywords < MAX_KEYWORD_VIEW )
00063         setFixedSize( DIALOG_WIDTH, DIALOG_HEIGHT + KEYWORDS_VBORDER +
00064                       KEYWORDS_HEIGHT*readkeywords );
00065     else
00066         setFixedSize( DIALOG_WIDTH, DIALOG_HEIGHT + KEYWORDS_VBORDER +
00067                       KEYWORDS_HEIGHT*MAX_KEYWORD_VIEW );
00068 
00069     keywords->setHScrollBarMode( QScrollView::Auto );
00070     keywords->show();
00071 
00072 }

int RioMMKeywordsDialog::buildKeywordsTree ( QListViewItem *  parentItem,
const QDomElement &  parentElement,
QPtrStack< QListViewItem > *  stack 
) [private]

Definition at line 74 of file RioMMKeywordsDialog.cpp.

00077 {
00078     QListViewItem *thisItem = 0;
00079     QListViewItem *previousItem;
00080     QDomNode       node = parentElement.firstChild();
00081     QString        name;
00082     int            readkeywords=0;
00083     int            recreadkeywords=0;
00084 
00085     while( !node.isNull() )
00086     {
00087 
00088         if( node.isElement() && ( node.nodeName() == "main_title" ) )
00089             setCaption( node.toElement().text() +
00090                         "- selecione uma palavra-chave" );
00091         else if( node.isElement() && ( node.nodeName() == "name" ) )
00092         {
00093             name = node.toElement().text();
00094             readkeywords++;
00095 
00096             // index_position vem logo ap�s name_index no XML.
00097             node = node.nextSibling();
00098 
00099             if( stack->isEmpty() )
00100                 previousItem = parentItem;
00101             else
00102                 previousItem = stack->top();
00103 
00104             // Add a new list view item for the outline.
00105             if( parentItem == 0 )
00106                 thisItem = new QListViewItem( keywords, previousItem );
00107             else
00108                 thisItem = new QListViewItem( parentItem, previousItem );
00109 
00110             thisItem->setPixmap( 0, QPixmap( (const char **) keyword ) );
00111             thisItem->setOpen( TRUE );
00112             thisItem->setText( 0, name );
00113             thisItem->setText( 1,
00114                                node.toElement().text().simplifyWhiteSpace() );
00115             stack->push( thisItem );
00116         }
00117 
00118         else if( node.isElement() && ( node.nodeName() == "keyword_item" ) )
00119             recreadkeywords += buildKeywordsTree( thisItem, node.toElement(),
00120                                                   stack );
00121 
00122         node = node.nextSibling();
00123     }
00124 
00125     // Desempilhando os filhos do item atual.
00126     while( stack->top() != thisItem )
00127         stack->pop();
00128 
00129     return readkeywords + recreadkeywords;
00130 }

QString RioMMKeywordsDialog::indexPositions (  ) 

Definition at line 167 of file RioMMKeywordsDialog.cpp.

00168 {
00169     QListViewItem *item;
00170     item = keywords->selectedItem();
00171 
00172     if( item != 0 )
00173         return item->text( 1 );
00174     else
00175         return QString( "nenhum item foi selecionado" );
00176 
00177 }

void RioMMKeywordsDialog::Initialize ( QDomDocument  domTree  ) 

Definition at line 132 of file RioMMKeywordsDialog.cpp.

00133 {
00134     // Ponteiro para o layout do di�logo (usado para organizar os objetos do
00135     // di�logo).
00136     main_layout = new QGridLayout( this, 2, 2, MARGIN, SPACING,
00137                                    "main_layout" );
00138     // Ponteiro para o bjeto QListView que ir� armazenar a estrutura
00139     // hier�rquica com as palavras-chave (definida pelo par�metro domTree).
00140     keywords = new QListView( this );
00141     // Configura a altura e o comprimento do di�logo.
00142     setFixedWidth( DIALOG_WIDTH );
00143     setFixedHeight( DIALOG_HEIGHT );
00144     // Adiciona o ponteiro para a QListView ao estilo do di�logo
00145     main_layout->addMultiCellWidget( keywords, 0, 0, 0, 1 );
00146     // Cria os dois bot�es do di�logo (um usado para o usu�rio escolher uma
00147     // palavra-chave e fechar o di�logo - o bot�o OK, e um outro usado para o
00148     // usu�rio abortar a sele��o de uma palavra chave - o bot�o Cancel).
00149     // Tamb�m adiciona estes bot�es ao layout do di�logo, e inicializa os seus
00150     // r�tulos.
00151     but_Ok = new QPushButton( "Ok", this );
00152     main_layout->addWidget( but_Ok, 1, 0 );
00153     but_Cancel = new QPushButton ( "Cancel", this );
00154     main_layout->addWidget( but_Cancel, 1, 1 );
00155     setCaption( "Selececione uma palavra-chave" );
00156     // Define a ordem de tabula��o dos bot�es.
00157     setTabOrder( keywords, but_Ok );
00158     setTabOrder( but_Ok, but_Cancel );
00159     // Conecta dois sinais (um de cada bot�o) �s fun��es que os tratam.
00160     connect( but_Ok, SIGNAL( clicked() ), this, SLOT( processKeyword() ) );
00161     connect( but_Cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
00162     // Constr�i a estrutura hier�rquica com as palavras-chave.
00163     buildKeywords( domTree );
00164 }

void RioMMKeywordsDialog::processKeyword (  )  [private, slot]

Definition at line 179 of file RioMMKeywordsDialog.cpp.

00180 {
00181 
00182     if( keywords->selectedItem() == 0 ) 
00183         QMessageBox::critical( this, "Erro", "Selecione uma palavra-chave" );
00184     else
00185         accept();
00186 
00187 }


Field Documentation

QPushButton* RioMMKeywordsDialog::but_Cancel [private]

Definition at line 55 of file RioMMKeywordsDialog.h.

QPushButton* RioMMKeywordsDialog::but_Ok [private]

Definition at line 53 of file RioMMKeywordsDialog.h.

QListView* RioMMKeywordsDialog::keywords [private]

Definition at line 51 of file RioMMKeywordsDialog.h.

QGridLayout* RioMMKeywordsDialog::main_layout [private]

Definition at line 48 of file RioMMKeywordsDialog.h.


The documentation for this class was generated from the following files:
Generated on Wed Jul 4 16:03:36 2012 for RIO by  doxygen 1.6.3