TemplateListView::TemplateListView(bool includeCmdAlarms, const QString& whatsThisText, QWidget* parent, const char* name) : EventListViewBase(parent, name), mWhatsThisText(whatsThisText), mIconColumn(0), mNameColumn(1), mExcludeCmdAlarms(!includeCmdAlarms) { addColumn(QString::null); // icon column addLastColumn(i18n("Name")); setSorting(mNameColumn); // sort initially by name setColumnAlignment(mIconColumn, Qt::AlignHCenter); setColumnWidthMode(mIconColumn, QListView::Maximum); mInstanceList.append(this); }
AlarmListView::AlarmListView(const QValueList<int> &order, QWidget *parent, const char *name) : EventListViewBase(parent, name), mMousePressed(false), mDrawMessageInColour(false), mShowExpired(false) { static QString titles[COLUMN_COUNT] = { i18n("Time"), i18n("Time To"), i18n("Repeat"), QString::null, QString::null, i18n("Message, File or Command") }; setSelectionMode(QListView::Extended); // Set the column order int i; bool ok = false; if(order.count() >= COLUMN_COUNT) { // The column order is specified bool posns[COLUMN_COUNT]; for(i = 0; i < COLUMN_COUNT; ++i) posns[i] = false; for(i = 0; i < COLUMN_COUNT; ++i) { int ord = order[i]; if(ord < COLUMN_COUNT && ord >= 0) { mColumn[i] = ord; posns[ord] = true; } } ok = true; for(i = 0; i < COLUMN_COUNT; ++i) if(!posns[i]) ok = false; if(ok && mColumn[MESSAGE_COLUMN] != MESSAGE_COLUMN) { // Shift the message column to be last, since otherwise // column widths get screwed up. int messageCol = mColumn[MESSAGE_COLUMN]; for(i = 0; i < COLUMN_COUNT; ++i) if(mColumn[i] > messageCol) --mColumn[i]; mColumn[MESSAGE_COLUMN] = MESSAGE_COLUMN; } } if(!ok) { // Either no column order was specified, or it was invalid, // so use the default order for(i = 0; i < COLUMN_COUNT; ++i) mColumn[i] = i; } // Initialise the columns for(i = 0; i < COLUMN_COUNT; ++i) { for(int j = 0; j < COLUMN_COUNT; ++j) if(mColumn[j] == i) { if(j != MESSAGE_COLUMN) addColumn(titles[j]); break; } } addLastColumn(titles[MESSAGE_COLUMN]); setSorting(mColumn[TIME_COLUMN]); // sort initially by date/time mTimeColumnHeaderWidth = columnWidth(mColumn[TIME_COLUMN]); mTimeToColumnHeaderWidth = columnWidth(mColumn[TIME_TO_COLUMN]); setColumnAlignment(mColumn[REPEAT_COLUMN], Qt::AlignHCenter); setColumnWidthMode(mColumn[REPEAT_COLUMN], QListView::Maximum); // Set the width of the colour column in proportion to height setColumnWidth(mColumn[COLOUR_COLUMN], itemHeight() * 3 / 4); setColumnWidthMode(mColumn[COLOUR_COLUMN], QListView::Manual); // Set the width of the alarm type column to exactly accommodate the icons. // Don't allow the user to resize it (to avoid refresh problems, and bearing // in mind that resizing doesn't seem very useful anyway). setColumnWidth(mColumn[TYPE_COLUMN], AlarmListViewItem::typeIconWidth(this)); setColumnWidthMode(mColumn[TYPE_COLUMN], QListView::Manual); header()->setResizeEnabled(false, mColumn[TYPE_COLUMN]); mInstanceList.append(this); mTooltip = new AlarmListTooltip(viewport()); }