ConstraintTable::ConstraintTable(QWidget * parent, ConstraintCanvas * c) : Q3Table(c->elements.count(), 4, parent) { setSorting(true); setSelectionMode(NoSelection); setRowMovingEnabled(FALSE); horizontalHeader()->setLabel(0, TR("visible")); horizontalHeader()->setLabel(1, " "); horizontalHeader()->setLabel(2, TR("element")); horizontalHeader()->setLabel(3, TR("constraint")); setColumnStretchable(0, FALSE); setColumnStretchable(1, FALSE); int row; bool v = c->indicate_visible; Q3ValueList<BrowserNode *> & hv = c->hidden_visible; BrowserNodeList & elts = c->elements; BrowserNode * bn; QString yes = TR(" yes"); QString empty; elts.sort(); for (bn = elts.first(), row = 0; bn != 0; bn = elts.next(), row += 1) { if ((v) ? hv.findIndex(bn) != -1 : hv.findIndex(bn) == -1) setText(row, 0, yes); setPixmap(row, 1, *(bn->pixmap(0))); TableItem * ti; ti = new TableItem(this, Q3TableItem::Never, bn->full_name(TRUE)); ti->setReplaceable(FALSE); setItem(row, 2, ti); QString s = toUnicode(bn->constraint()); int n = s.count('\n'); ti = new TableItem(this, Q3TableItem::Never, s); ti->setReplaceable(FALSE); setItem(row, 3, ti); if (n != 0) { // note : adjustRow(row) does nothing setRowHeight(row, rowHeight(row) * (n + 1)); } } adjustColumn(0); adjustColumn(1); setColumnStretchable(2, TRUE); setColumnStretchable(3, TRUE); connect(this, SIGNAL(pressed(int, int, int, const QPoint &)), this, SLOT(button_pressed(int, int, int, const QPoint &))); }
void ColMsgTable::refresh() { setNumRows(0); flat_msg_list.clear(); refresh(msgs); adjustColumn(ABS_RANK_COL); adjustColumn(HI_RANK_COL); adjustColumn(FROM_COL); adjustColumn(TO_COL); adjustColumn(CMD_COL); setColumnStretchable(MSG_COL, TRUE); }
bool ListView::eventFilter(QObject *o, QEvent *e) { if ((o == verticalScrollBar()) && ((e->type() == QEvent::Show) || (e->type() == QEvent::Hide))) adjustColumn(); return QTreeWidget::eventFilter(o, e); }
//Credit to amaroK for this //Seems like it can become the next plugin to do since amarok is really cool (just missing plugin arch) bool SongList::eventFilter(QObject *o, QEvent *e ) { if(o == header() && e->type() == QEvent::MouseButtonPress && static_cast<QMouseEvent*>(e)->button() == Qt::RightButton ) { KPopupMenu popup; //popup.setFont(this->font()); popup.setCheckable(true); popup.insertTitle(i18n("Available Columns")); int colcount=columns(); for( int i = 0; i < colcount; ++i ) //columns() references a property { popup.insertItem(columnText(i),i,i+1 ); popup.setItemChecked(i,columnWidth(i)!=0); } int col = popup.exec( static_cast<QMouseEvent *>(e)->globalPos() ); if( col != -1 ) { //TODO can result in massively wide column appearing! if( columnWidth( col ) == 0 ) { adjustColumn( col ); header()->setResizeEnabled( true, col ); } else hideColumn( col ); } //determine first visible column again, since it has changed //eat event return TRUE; } return KListView::eventFilter(o,e); }
ListView::ListView(QWidget *parent, const char *name) : QTreeWidget(parent) { m_menuId = MenuListView; if (!s_bInit){ s_bInit = true; Event eMenu(EventMenuCreate, (void*)MenuListView); eMenu.process(); setFocusPolicy( Qt::StrongFocus); Command cmd; cmd->id = CmdListDelete; cmd->text = I18N_NOOP("&Delete"); cmd->icon = "remove"; cmd->accel = "Del"; cmd->menu_id = MenuListView; cmd->menu_grp = 0x1000; cmd->flags = COMMAND_DEFAULT; Event eCmd(EventCommandCreate, cmd); eCmd.process(); } m_bAcceptDrop = false; viewport()->setAcceptDrops(true); m_pressedItem = NULL; m_expandingColumn = -1; verticalScrollBar()->installEventFilter(this); connect(header(), SIGNAL(sizeChange(int,int,int)), this, SLOT(sizeChange(int,int,int))); m_resizeTimer = new QTimer(this); connect(m_resizeTimer, SIGNAL(timeout()), this, SLOT(adjustColumn())); }
void GUITabla::ajustarTamano(int fila, int columna) { adjustColumn(columna); if (fila + 1 == numRows()) { insertRows ( fila+1, 10); } }
void GUITabla::llenarTabla(QStringList strlist) { int cont = 0; for ( uint f = 0; f < strlist.count() / numCols(); f++) { for ( uint c = 0; c < numCols(); c++) { setText ( f, c, strlist[cont ]); adjustColumn(c); cont++; } } }
Table::Table() : QTable( 10, 100, 0, "table" ) { setSorting( TRUE ); horizontalHeader()->setLabel( 0, tr( "File" ) ); horizontalHeader()->setLabel( 1, tr( "Size (bytes)" ) ); horizontalHeader()->setLabel( 2, tr( "Use in Sum" ) ); initTable(); adjustColumn( 0 ); // if the user edited something we might need to recalculate the sum connect( this, SIGNAL( valueChanged( int, int ) ), this, SLOT( recalcSum( int, int ) ) ); }
RelTable::RelTable(QWidget * parent, ClassInstanceData * inst, bool visit) : MyTable(parent) { const QList<SlotRel> & rels = inst->get_relations(); setRowCount(rels.count()); setColumnCount((visit) ? 5 : 6); setSelectionMode(QTableWidget::SingleSelection); //setSortingEnabled(true); setHorizontalHeaderLabel(0, tr("Class Inst.")); setHorizontalHeaderLabel(1, tr("Role")); setHorizontalHeaderLabel(2, tr("kind")); setHorizontalHeaderLabel(3, tr("Role")); setHorizontalHeaderLabel(4, tr("Class Inst.")); setHorizontalHeaderLabel(5, tr("Delete")); QString role = inst->get_browser_node()->get_name() + QString(":") + inst->get_class()->get_name(); int row = 0; QList<SlotRel>::ConstIterator it; for (it = rels.begin(); it != rels.end(); ++it) init_row(*it, row++, role, visit); setColumnStretchable(1, TRUE); setColumnStretchable(3, TRUE); adjustColumn(0); adjustColumn(2); adjustColumn(4); if (! visit) adjustColumn(5); connect(this, SIGNAL(pressed(int, int, int, const QPoint &)), this, SLOT(button_pressed(int, int, int, const QPoint &))); }
QStringList GUITabla::obtenerDatos() { QStringList datos; int cont = 0; for ( int f = 0; f < numRows() / numCols(); f++) { for (int c = 0; c < numCols(); c++) { datos.append(text( f, c)); adjustColumn(c); cont++; } } return datos; }
GUITabla::GUITabla(int filas, QStringList encabezado, QWidget *parent, const char *name) :QTable(parent, name) { QHeader *header = horizontalHeader(); { header->setMovingEnabled(true); setNumCols(encabezado.count()); setNumRows(filas); for(uint i = 0; i < encabezado.count(); i++) { header->setLabel( i, tr(encabezado[i]) ); adjustColumn(i); } connect(this, SIGNAL(valueChanged(int,int) ), SLOT(ajustarTamano(int, int))); show(); } setReadOnly ( true ); }
bool QListView::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: clear(); break; case 1: invertSelection(); break; case 2: selectAll((bool)static_QUType_bool.get(_o+1)); break; case 3: triggerUpdate(); break; case 4: setContentsPos((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 5: adjustColumn((int)static_QUType_int.get(_o+1)); break; case 6: updateContents(); break; case 7: doAutoScroll(); break; case 8: changeSortColumn((int)static_QUType_int.get(_o+1)); break; case 9: handleIndexChange(); break; case 10: updateDirtyItems(); break; case 11: makeVisible(); break; case 12: handleSizeChange((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break; case 13: startRename(); break; case 14: openFocusItem(); break; default: return QScrollView::qt_invoke( _id, _o ); } return TRUE; }
void UserListBase::fill() { m_pressedItem = NULL; clear(); GroupItem *grpItem; ContactItem *contactItem; UserViewItemBase *divItem; UserViewItemBase *divItemOnline = NULL; UserViewItemBase *divItemOffline = NULL; ContactList *list = getContacts(); ContactList::GroupIterator grp_it; ContactList::ContactIterator contact_it; Group *grp; Contact *contact; switch (m_groupMode){ case 0: divItemOnline = NULL; divItemOffline = NULL; while ((contact = ++contact_it) != NULL){ if (contact->getIgnore() || contact->getTemporary()) continue; unsigned style; string icons; unsigned status = getUserStatus(contact, style, icons); unsigned unread = getUnread(contact->id()); bool bShow = false; ListUserData *data = (ListUserData*)contact->getUserData(CorePlugin::m_plugin->list_data_id); if (data && data->ShowAllways) bShow = true; if ((unread == 0) && !bShow && (status == STATUS_OFFLINE) && m_bShowOnline) continue; divItem = (status == STATUS_OFFLINE) ? divItemOffline : divItemOnline; if (divItem == NULL){ if (status == STATUS_OFFLINE){ divItemOffline = new DivItem(this, DIV_OFFLINE); setOpen(divItemOffline, true); divItem = divItemOffline; }else{ divItemOnline = new DivItem(this, DIV_ONLINE); setOpen(divItemOnline, true); divItem = divItemOnline; } } new ContactItem(divItem, contact, status, style, icons.c_str(), unread); } break; case 1: while ((grp = ++grp_it) != NULL){ if (grp->id() == 0) continue; grpItem = new GroupItem(this, grp, true); } grp = list->group(0); if (grp){ grpItem = new GroupItem(this, grp, true); } while ((contact = ++contact_it) != NULL){ if (contact->getIgnore() || contact->getTemporary()) continue; unsigned style; string icons; unsigned status = getUserStatus(contact, style, icons); unsigned unread = getUnread(contact->id()); bool bShow = false; ListUserData *data = (ListUserData*)contact->getUserData(CorePlugin::m_plugin->list_data_id); if (data && data->ShowAllways) bShow = true; if ((status == STATUS_OFFLINE) && !bShow && (unread == 0) && m_bShowOnline) continue; grpItem = findGroupItem(contact->getGroup()); if (grpItem == NULL) continue; contactItem = new ContactItem(grpItem, contact, status, style, icons.c_str(), unread); grpItem->m_nContacts++; if ((status != STATUS_OFFLINE) && !m_bShowOnline){ grpItem->m_nContactsOnline++; contactItem->m_bOnline = true; } } break; case 2: divItemOnline = new DivItem(this, DIV_ONLINE); setOpen(divItemOnline, true); while ((grp = ++grp_it) != NULL){ if (grp->id() == 0) continue; grpItem = new GroupItem(divItemOnline, grp, false); } grp = list->group(0); if (grp){ grpItem = new GroupItem(divItemOnline, grp, false); } if (!m_bShowOnline){ divItemOffline = new DivItem(this, DIV_OFFLINE); setOpen(divItemOffline, true); grp_it.reset(); while ((grp = ++grp_it) != NULL){ if (grp->id() == 0) continue; grpItem = new GroupItem(divItemOffline, grp, true); } grp = list->group(0); if (grp){ grpItem = new GroupItem(divItemOffline, grp, true); } } while ((contact = ++contact_it) != NULL){ if (contact->getIgnore() || contact->getTemporary()) continue; unsigned style; string icons; unsigned status = getUserStatus(contact, style, icons); unsigned unread = getUnread(contact->id()); bool bShow = false; ListUserData *data = (ListUserData*)contact->getUserData(CorePlugin::m_plugin->list_data_id); if (data && data->ShowAllways) bShow = true; if ((unread == 0) && !bShow && (status == STATUS_OFFLINE) && m_bShowOnline) continue; if (status == STATUS_OFFLINE){ if (divItemOffline == NULL){ divItemOffline = new DivItem(this, DIV_OFFLINE); setOpen(divItemOffline, true); } divItem = divItemOffline; }else{ divItem = divItemOnline; } grpItem = findGroupItem(contact->getGroup(), divItem); if (grpItem == NULL){ Group *grp = getContacts()->group(contact->getGroup()); if (grp == NULL) continue; grpItem = new GroupItem(divItem, grp, true); } new ContactItem(grpItem, contact, status, style, icons.c_str(), unread); grpItem->m_nContacts++; } break; } adjustColumn(); }
void CServerStatusTable::refresh() { if (isBlocked()) return; setBlocked(true); bool max_scroll = false; int scroll = is_first ? 0 : verticalScrollBar()->value(); if (scroll >= verticalScrollBar()->maxValue() - 1 && scroll != 0) max_scroll = true; if (is_traditional) { if (keepColumnWidth() && numCols() > 0) for (int i = 0; i < numCols(); i++) previous_columns_map.insert(i, CTable::OldColumn(horizontalHeader()->sectionSize(i), horizontalHeader()->label(i))); clearCellWidget(currentRow(), currentColumn()); if (is_first) ensureVisible(0, 0); setNumRows(0); if (sorting()) horizontalHeader()->setSortIndicator( -1 ); } if (query()->exec("SHOW STATUS")) { uint num_rows = query()->numRows(); uint num_fields = query()->numFields(); bool adjust = false; if (is_traditional) { bool columns_ok = (keepColumnWidth() && previous_columns_map.count() == num_fields); if (columns_ok) for (uint i = 0; i < num_fields; i++) columns_ok &= (previous_columns_map[i].label == query()->fields(i).name); if (!columns_ok) { adjust = true; if (keepColumnWidth()) previous_columns_map.clear(); } setNumRows(num_rows); setNumCols(num_fields); if (is_first) { for (uint i = 0; i < num_fields; i++) if (columns_ok && previous_columns_map[i].label == query()->fields(i).name) horizontalHeader()->setLabel(i, query()->fields(i).name, previous_columns_map[i].size); else horizontalHeader()->setLabel(i, query()->fields(i).name); if (columnsWindow->isVisible()) columnsWindow->refresh(); is_first = false; adjust = true; } uint j = 0; while (query()->next()) { for (uint i = 0; i < num_fields; i++) { const char * val = query()->row(i) ? query()->row(i) : NULL_TEXT; setText(j, i, val); } j++; } } else { if (is_first) { setNumRows(0); setNumCols(num_rows); int i = 0; while (query()->next()) horizontalHeader()->setLabel(i++, query()->row(0)); if (columnsWindow->isVisible()) columnsWindow->refresh(); is_first = false; adjust = true; query()->dataSeek(0); } setNumRows(numRows() + 1); ulong i = 0; while (query()->next()) { const char * val = query()->row(1) ? query()->row(1) : NULL_TEXT; setText(numRows() - 1, i++, val); } } if (adjust) for (int j = 0; j < numCols(); j++) adjustColumn(j); if (max_scroll) scroll = verticalScrollBar()->maxValue(); verticalScrollBar()->setValue(scroll); } setBlocked(false); applyLastSort(); }
bool QTable::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: setNumRows((int)static_QUType_int.get(_o+1)); break; case 1: setNumCols((int)static_QUType_int.get(_o+1)); break; case 2: setShowGrid((bool)static_QUType_bool.get(_o+1)); break; case 3: hideRow((int)static_QUType_int.get(_o+1)); break; case 4: hideColumn((int)static_QUType_int.get(_o+1)); break; case 5: showRow((int)static_QUType_int.get(_o+1)); break; case 6: showColumn((int)static_QUType_int.get(_o+1)); break; case 7: static_QUType_bool.set(_o,isRowHidden((int)static_QUType_int.get(_o+1))); break; case 8: static_QUType_bool.set(_o,isColumnHidden((int)static_QUType_int.get(_o+1))); break; case 9: setColumnWidth((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 10: setRowHeight((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 11: adjustColumn((int)static_QUType_int.get(_o+1)); break; case 12: adjustRow((int)static_QUType_int.get(_o+1)); break; case 13: setColumnStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break; case 14: setRowStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break; case 15: static_QUType_bool.set(_o,isColumnStretchable((int)static_QUType_int.get(_o+1))); break; case 16: static_QUType_bool.set(_o,isRowStretchable((int)static_QUType_int.get(_o+1))); break; case 17: setSorting((bool)static_QUType_bool.get(_o+1)); break; case 18: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 19: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break; case 20: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 21: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break; case 22: swapCells((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(int)static_QUType_int.get(_o+4)); break; case 23: setLeftMargin((int)static_QUType_int.get(_o+1)); break; case 24: setTopMargin((int)static_QUType_int.get(_o+1)); break; case 25: setCurrentCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 26: clearSelection(); break; case 27: clearSelection((bool)static_QUType_bool.get(_o+1)); break; case 28: setColumnMovingEnabled((bool)static_QUType_bool.get(_o+1)); break; case 29: setRowMovingEnabled((bool)static_QUType_bool.get(_o+1)); break; case 30: setReadOnly((bool)static_QUType_bool.get(_o+1)); break; case 31: setRowReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break; case 32: setColumnReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break; case 33: setDragEnabled((bool)static_QUType_bool.get(_o+1)); break; case 34: static_QUType_bool.set(_o,dragEnabled()); break; case 35: insertRows((int)static_QUType_int.get(_o+1)); break; case 36: insertRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 37: insertColumns((int)static_QUType_int.get(_o+1)); break; case 38: insertColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 39: removeRow((int)static_QUType_int.get(_o+1)); break; case 40: removeRows((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break; case 41: removeColumn((int)static_QUType_int.get(_o+1)); break; case 42: removeColumns((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break; case 43: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 44: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break; case 45: setRowLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break; case 46: setColumnLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break; case 47: columnWidthChanged((int)static_QUType_int.get(_o+1)); break; case 48: rowHeightChanged((int)static_QUType_int.get(_o+1)); break; case 49: columnIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break; case 50: rowIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break; case 51: columnClicked((int)static_QUType_int.get(_o+1)); break; case 52: doAutoScroll(); break; case 53: doValueChanged(); break; case 54: updateGeometriesSlot(); break; default: return QScrollView::qt_invoke( _id, _o ); } return TRUE; }
void TableEditor::adjustCols() { for(int c=0;c<numCols();c++) adjustColumn(c); }
KeyValuesTable::KeyValuesTable(HaveKeyValueData * hv, QWidget * parent, bool isReadOnly) : StringTable(((hv == 0) ? 0 : hv->get_n_keys()) + ((isReadOnly) ? 0 : 1), (isReadOnly) ? 2 : 3, parent, isReadOnly) { horizontalHeader()->setLabel(0, TR("Key")); horizontalHeader()->setLabel(1, TR("Value")); if (!isReadOnly) horizontalHeader()->setLabel(2, TR("do")); int index; int sup = 0; if(hv) sup = hv->get_n_keys(); if (isReadOnly) { for (index = 0; index < sup; index += 1) { TableItem * ti; ti = new TableItem(this, Q3TableItem::Never, toUnicode(hv->get_key(index))); ti->setReplaceable(FALSE); setItem(index, 0, ti); QString s = toUnicode(hv->get_value(index)); int n = s.count('\n'); ti = new TableItem(this, Q3TableItem::Never, s); ti->setReplaceable(FALSE); setItem(index, 1, ti); if (n != 0) { // note : adjustRow(index) does nothing setRowHeight(index, rowHeight(index) * (n + 1)); } } } else { props.setAutoDelete(TRUE); QStringList items; for (index = 0; index < sup; index += 1) { QString k = toUnicode(hv->get_key(index)); QString v = toUnicode(hv->get_value(index)); QStringList * psl = props[k]; setText(index, 0, k); if (psl != 0) setItem(index, 1, new ComboItem(this, v, *psl, FALSE)); if ((k.contains(':') == 2) && ProfiledStereotypes::enumerated(k, items)) { psl = new QStringList(items); props.insert(k, psl); setItem(index, 1, new ComboItem(this, v, *psl, FALSE)); } else setItem(index, 1, new MLinesItem(this, v)); setText(index, 2, QString()); setRowStretchable(index, TRUE); } setText(index, 0, QString()); setItem(index, 1, new MLinesItem(this, QString())); setText(index, 2, QString()); setRowStretchable(index, TRUE); } horizontalHeader()->setResizeEnabled(TRUE, 0); //setColumnStretchable (0, TRUE); setColumnStretchable(1, TRUE); if (! isReadOnly) { adjustColumn(2); setColumnStretchable(2, FALSE); } }
void KeyValuesTable::updateThisFromNode(HaveKeyValueData *hv, bool isReadOnly) { if (!isReadOnly) { if(numCols() == 2) insertColumns(2); horizontalHeader()->setLabel(2, TR("do")); } else { if(numCols() == 3) removeColumn(2); } int index; int sup = 0; if(hv) sup = hv->get_n_keys(); int rowCount = numRows(); for (index = rowCount - 1; index > sup; index -= 1) removeRow(index); if (isReadOnly) { for (index = 0; index < sup; index += 1) { TableItem * tiKey = nullptr; TableItem * tiValue = nullptr; QString s = toUnicode(hv->get_value(index)); int n = s.count('\n'); if(index == numRows() || numRows() == 0) { tiKey = new TableItem(this, Q3TableItem::Never, toUnicode(hv->get_key(index))); tiValue = new TableItem(this, Q3TableItem::Never, s); setItem(index, 0, tiKey); setItem(index, 1, tiValue); } else { tiKey = dynamic_cast<TableItem*>(item(index, 0)); tiKey->setText(hv->get_key(index)); tiValue = dynamic_cast<TableItem*>(item(index, 1)); tiValue->setText(s); } tiKey->setReplaceable(FALSE); tiValue->setReplaceable(FALSE); if (n != 0) { // note : adjustRow(index) does nothing setRowHeight(index, rowHeight(index) * (n + 1)); } } } else { props.setAutoDelete(TRUE); QStringList items; for (index = 0; index < sup; index += 1) { QString k = toUnicode(hv->get_key(index)); QString v = toUnicode(hv->get_value(index)); QStringList * psl = props[k]; setText(index, 0, k); if (psl != 0) setItem(index, 1, new ComboItem(this, v, *psl, FALSE)); if ((k.contains(':') == 2) && ProfiledStereotypes::enumerated(k, items)) { psl = new QStringList(items); props.insert(k, psl); setItem(index, 1, new ComboItem(this, v, *psl, FALSE)); } else setItem(index, 1, new MLinesItem(this, v)); setText(index, 2, QString()); setRowStretchable(index, TRUE); } if(index == numRows()) insertRows(numRows()); setText(index, 0, QString()); setItem(index, 1, new MLinesItem(this, QString())); setText(index, 2, QString()); setRowStretchable(index, TRUE); } horizontalHeader()->setResizeEnabled(TRUE, 0); //setColumnStretchable (0, TRUE); setColumnStretchable(1, TRUE); if (! isReadOnly) { adjustColumn(2); setColumnStretchable(2, FALSE); } }
void ListView::setExpandingColumn(int n) { m_expandingColumn = n; adjustColumn(); }
void CProcessListTable::refresh() { if (isBlocked()) return; setBlocked(true); bool max_scroll = false; int scroll = is_first ? 0 : verticalScrollBar()->value(); if (scroll >= verticalScrollBar()->maxValue() - 1 && scroll != 0) max_scroll = true; if (keepColumnWidth() && numCols() > 0) for (int i = 0; i < numCols(); i++) previous_columns_map.insert(i, CTable::OldColumn(horizontalHeader()->sectionSize(i), horizontalHeader()->label(i))); clearCellWidget(currentRow(), currentColumn()); if (is_first) ensureVisible(0, 0); query()->freeResult(); setNumRows(0); horizontalHeader()->setSortIndicator( -1 ); if (query()->exec(sql)) { uint num_rows = qry->numRows(); uint num_fields = qry->numFields(); bool columns_ok = (keepColumnWidth() && previous_columns_map.count() == num_fields); if (columns_ok) for (uint i = 0; i < num_fields; i++) columns_ok &= (previous_columns_map[i].label == query()->fields(i).name); if (!columns_ok && keepColumnWidth()) previous_columns_map.clear(); setNumRows(num_rows); setNumCols(num_fields); if (is_first) { for (uint i = 0; i < num_fields; i++) { if (columns_ok && previous_columns_map[i].label == query()->fields(i).name) horizontalHeader()->setLabel(i, qry->fields(i).name, previous_columns_map[i].size); else horizontalHeader()->setLabel(i, qry->fields(i).name); setColumnReadOnly (i, (i != 0)); } is_first = false; } if (hasProcessEvents()) qApp->processEvents(); else updateScrollBars(); uint j = 0; while (query()->next()) { for (uint i = 0; i < num_fields; i++) { const char *val = query()->row(i) ? query()->row(i) : NULL_TEXT; if (i == 0) setItem (j, i, new CCheckTableItem(this, val)); else setText(j, i, val); } j++; } if (!columns_ok) for (j = 0; j < num_fields; j++) adjustColumn(j); if (max_scroll) scroll = verticalScrollBar()->maxValue(); verticalScrollBar()->setValue(scroll); } setBlocked(false); applyLastSort(); }
void ListView::resizeEvent(QResizeEvent *e) { QListView::resizeEvent(e); adjustColumn(); }
void ListView::resizeEvent(QResizeEvent *e) { QTreeWidget::resizeEvent(e); adjustColumn(); }
void FolderListView::adjustColumns() { for (int i=0; i < columns (); i++) adjustColumn(i); }
void ListView::sizeChange(int,int,int) { QTimer::singleShot(0, this, SLOT(adjustColumn())); }
void *JabberBrowser::processEvent(Event *e) { if (e->type() == EventAgentInfo){ JabberAgentInfo *data = (JabberAgentInfo*)(e->param()); if (m_search_id == data->ReqID.ptr){ if (data->Type.ptr == NULL){ if (data->nOptions.value){ QString err; if (data->Label.ptr && *data->Label.ptr) err = i18n(data->Label.ptr); if (err.isEmpty()) err = i18n("Error %1") .arg(data->nOptions.value); m_search_id = ""; delete m_search; m_search = NULL; Command cmd; cmd->id = CmdBrowseSearch; cmd->param = this; Event eWidget(EventCommandWidget, cmd); QWidget *parent = (QWidget*)(eWidget.process()); if (parent == NULL) parent = this; BalloonMsg::message(err, parent); }else{ m_search->m_search->addWidget(data); QTimer::singleShot(0, this, SLOT(showSearch())); } m_search_id = ""; return e->param(); } m_search->m_search->addWidget(data); return e->param(); } if (m_reg_id == data->ReqID.ptr){ if (data->Type.ptr == NULL){ if (data->nOptions.value){ QString err; if (data->Label.ptr && *data->Label.ptr) err = i18n(data->Label.ptr); if (err.isEmpty()) err = i18n("Error %1") .arg(data->nOptions.value); m_reg_id = ""; delete m_reg; m_reg = NULL; Command cmd; cmd->id = CmdRegister; cmd->param = this; Event eWidget(EventCommandWidget, cmd); QWidget *parent = (QWidget*)(eWidget.process()); if (parent == NULL) parent = this; BalloonMsg::message(err, parent); }else{ m_reg->m_search->addWidget(data); QTimer::singleShot(0, this, SLOT(showReg())); } m_reg_id = ""; return e->param(); } m_reg->m_search->addWidget(data); return e->param(); } if (m_config_id == data->ReqID.ptr){ if (data->Type.ptr == NULL){ if (data->nOptions.value){ QString err; if (data->Label.ptr && *data->Label.ptr) err = i18n(data->Label.ptr); if (err.isEmpty()) err = i18n("Error %1") .arg(data->nOptions.value); m_config_id = ""; delete m_config; m_config = NULL; Command cmd; cmd->id = CmdBrowseConfigure; cmd->param = this; Event eWidget(EventCommandWidget, cmd); QWidget *parent = (QWidget*)(eWidget.process()); if (parent == NULL) parent = this; BalloonMsg::message(err, parent); }else{ m_config->m_search->addWidget(data); QTimer::singleShot(0, this, SLOT(showConfig())); } m_config_id = ""; return e->param(); } m_config->m_search->addWidget(data); return e->param(); } } if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->param != this) return NULL; if (cmd->menu_id != MenuBrowser) return NULL; cmd->flags &= ~COMMAND_CHECKED; switch (cmd->id){ case CmdOneLevel: if (!m_client->getAllLevels()) cmd->flags |= COMMAND_CHECKED; return e->param(); case CmdAllLevels: if (m_client->getAllLevels()) cmd->flags |= COMMAND_CHECKED; return e->param(); case CmdModeDisco: if (m_client->getBrowseType() & BROWSE_DISCO) cmd->flags |= COMMAND_CHECKED; return e->param(); case CmdModeBrowse: if (m_client->getBrowseType() & BROWSE_BROWSE) cmd->flags |= COMMAND_CHECKED; return e->param(); case CmdModeAgents: if (m_client->getBrowseType() & BROWSE_AGENTS) cmd->flags |= COMMAND_CHECKED; return e->param(); } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->param != this) return NULL; QListViewItem *item = m_list->currentItem(); if (cmd->menu_id == MenuBrowser){ cmd->flags &= ~COMMAND_CHECKED; unsigned mode = m_client->getBrowseType(); switch (cmd->id){ case CmdOneLevel: m_client->setAllLevels(false); changeMode(); return e->param(); case CmdAllLevels: m_client->setAllLevels(true); changeMode(); return e->param(); case CmdModeDisco: mode ^= BROWSE_DISCO; m_client->setBrowseType(mode); changeMode(); return e->param(); case CmdModeBrowse: mode ^= BROWSE_BROWSE; m_client->setBrowseType(mode); changeMode(); return e->param(); case CmdModeAgents: mode ^= BROWSE_AGENTS; m_client->setBrowseType(mode); changeMode(); return e->param(); } return NULL; } if (item){ if (cmd->id == CmdBrowseSearch){ if (m_search) delete m_search; m_search = new JabberWizard(this, i18n("%1 Search") .arg(item->text(COL_NAME).utf8()), "find", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search"); m_search_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search"); return e->param(); } if (cmd->id == CmdRegister){ if (m_reg) delete m_reg; m_reg = new JabberWizard(this, i18n("%1 Register") .arg(item->text(COL_NAME).utf8()), "reg", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register"); m_reg_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register"); return e->param(); } if (cmd->id == CmdBrowseConfigure){ if (m_config) delete m_config; m_config = new JabberWizard(this, i18n("%1 Configure") .arg(item->text(COL_NAME).utf8()), "configure", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data"); m_config_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data"); return e->param(); } if (cmd->id == CmdBrowseInfo){ if (m_info == NULL) m_info = new DiscoInfo(this, m_list->currentItem()->text(COL_FEATURES), item->text(COL_NAME), item->text(COL_TYPE), item->text(COL_CATEGORY)); m_info->reset(); raiseWindow(m_info); return e->param(); } } if (cmd->id == CmdBack){ if (m_historyPos){ m_historyPos--; QString url = QString::fromUtf8(m_history[m_historyPos].c_str()); QString node; if (!m_nodes[m_historyPos].empty()) node = QString::fromUtf8(m_nodes[m_historyPos].c_str()); go(url, node); } } if (cmd->id == CmdForward){ if (m_historyPos + 1 < (int)(m_history.size())){ m_historyPos++; QString url = QString::fromUtf8(m_history[m_historyPos].c_str()); QString node; if (!m_nodes[m_historyPos].empty()) node = QString::fromUtf8(m_nodes[m_historyPos].c_str()); go(url, node); } } if (cmd->id == CmdUrl){ if (m_bInProcess){ stop(""); return e->param(); } QString jid; QString node; Command cmd; cmd->id = CmdUrl; cmd->param = this; Event eWidget(EventCommandWidget, cmd); CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process()); if (cmbUrl) jid = cmbUrl->lineEdit()->text(); cmd->id = CmdNode; CToolCombo *cmbNode = (CToolCombo*)(eWidget.process()); if (cmbNode) node = cmbNode->lineEdit()->text(); if (!jid.isEmpty()){ addHistory(jid); goUrl(jid, node); } return e->param(); } } if (e->type() == EventDiscoItem){ if (!m_bInProcess) return NULL; DiscoItem *item = (DiscoItem*)(e->param()); QListViewItem *it = findItem(COL_ID_DISCO_ITEMS, item->id.c_str()); if (it){ if (item->jid.empty()){ it->setText(COL_ID_DISCO_ITEMS, ""); if (it != m_list->firstChild()){ checkDone(); adjustColumn(it); return e->param(); } QString err; if (!item->name.empty()){ err = QString::fromUtf8(item->name.c_str()); }else if (!item->node.empty()){ err = i18n("Error %1") .arg(atol(item->node.c_str())); } if (!err.isEmpty()){ unsigned mode = atol(it->text(COL_MODE).latin1()); if (((mode & BROWSE_BROWSE) == 0) || (it->text(COL_ID_BROWSE).isEmpty() & m_bError)) stop(err); m_bError = true; } checkDone(); adjustColumn(it); return e->param(); } if (it->firstChild() == NULL){ it->setExpandable(true); if ((it == m_list->firstChild()) || (it == m_list->currentItem())) it->setOpen(true); } QListViewItem *i; for (i = it->firstChild(); i; i = i->nextSibling()){ if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) && (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str()))) return e->param(); } i = new QListViewItem(it); i->setText(COL_JID, QString::fromUtf8(item->jid.c_str())); i->setText(COL_NAME, item->name.empty() ? QString::fromUtf8(item->jid.c_str()) : QString::fromUtf8(item->name.c_str())); i->setText(COL_NODE, QString::fromUtf8(item->node.c_str())); int mode = 0; if (m_client->getBrowseType() & BROWSE_DISCO){ i->setText(COL_ID_DISCO_INFO, m_client->discoInfo(item->jid.c_str(), item->node.c_str()).c_str()); mode |= BROWSE_INFO; } i->setText(COL_MODE, QString::number(mode)); if (m_client->getAllLevels()) loadItem(i); return e->param(); } it = findItem(COL_ID_DISCO_INFO, item->id.c_str()); if (it){ if (item->jid.empty()){ it->setText(COL_ID_DISCO_INFO, ""); checkDone(); adjustColumn(it); return e->param(); } if (it->text(COL_NAME) == it->text(COL_JID)) it->setText(COL_NAME, QString::fromUtf8(item->name.c_str())); it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str())); it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str())); it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str())); if ((m_client->getAllLevels()) || (it == m_list->currentItem())) loadItem(it); setItemPict(it); if (it == m_list->currentItem()) currentChanged(it); return e->param(); } it = findItem(COL_ID_BROWSE, item->id.c_str()); if (it){ if (item->jid.empty()){ it->setText(COL_ID_BROWSE, ""); if (it != m_list->firstChild()){ checkDone(); adjustColumn(it); return e->param(); } QString err; if (!item->name.empty()){ err = QString::fromUtf8(item->name.c_str()); }else if (!item->node.empty()){ err = i18n("Error %1") .arg(atol(item->node.c_str())); } if (!err.isEmpty()){ unsigned mode = atol(it->text(COL_MODE).latin1()); if (((mode & BROWSE_DISCO) == 0) || (it->text(COL_ID_DISCO_ITEMS).isEmpty() & m_bError)) stop(err); m_bError = true; } checkDone(); adjustColumn(it); return e->param(); } if (it->text(COL_JID) != QString::fromUtf8(item->jid.c_str())){ QListViewItem *i; for (i = it->firstChild(); i; i = i->nextSibling()){ if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) && (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str()))) break; } if (i){ it = i; }else{ if (it->firstChild() == NULL){ it->setExpandable(true); if ((it == m_list->firstChild()) || (it == m_list->currentItem())) it->setOpen(true); } it = new QListViewItem(it); it->setText(COL_JID, QString::fromUtf8(item->jid.c_str())); if (m_client->getAllLevels()) loadItem(it); } } if (it->text(COL_NAME) == it->text(COL_JID)) it->setText(COL_NAME, QString::fromUtf8(item->name.c_str())); it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str())); it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str())); it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str())); if (m_client->getAllLevels() || (it == m_list->currentItem())) loadItem(it); setItemPict(it); return e->param(); } } return NULL; }