forked from blue/squawk
trust level display in delegate, list size tweaking
This commit is contained in:
parent
d4bf7e599a
commit
b72a837754
10 changed files with 203 additions and 27 deletions
|
@ -15,4 +15,6 @@ target_sources(squawk PRIVATE
|
|||
resizer.h
|
||||
shadowoverlay.cpp
|
||||
shadowoverlay.h
|
||||
expandinglist.cpp
|
||||
expandinglist.h
|
||||
)
|
||||
|
|
43
ui/utils/expandinglist.cpp
Normal file
43
ui/utils/expandinglist.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Squawk messenger.
|
||||
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
//
|
||||
// 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "expandinglist.h"
|
||||
|
||||
QSize ExpandingList::viewportSizeHint() const {
|
||||
if (QAbstractItemView::sizeAdjustPolicy() != QAbstractScrollArea::AdjustToContents)
|
||||
return QListView::viewportSizeHint();
|
||||
|
||||
if (model() == nullptr)
|
||||
return QSize(0, 0);
|
||||
if (model()->rowCount() == 0)
|
||||
return QSize(0, 0);
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
|
||||
const int rowCount = model()->rowCount();
|
||||
int height = 0;
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
height += QListView::sizeHintForRow(i);
|
||||
}
|
||||
return QSize(QListView::viewportSizeHint().width(), height);
|
||||
#else
|
||||
return QListView::viewportSizeHint();
|
||||
#endif
|
||||
}
|
||||
|
||||
QSize ExpandingList::minimumSizeHint() const {
|
||||
return viewportSizeHint();
|
||||
}
|
||||
|
31
ui/utils/expandinglist.h
Normal file
31
ui/utils/expandinglist.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Squawk messenger.
|
||||
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
//
|
||||
// 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EXPANDINGLIST_H
|
||||
#define EXPANDINGLIST_H
|
||||
|
||||
#include <QListView>
|
||||
|
||||
class ExpandingList : public QListView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
using QListView::QListView; //explicit constructor inheriatnce
|
||||
|
||||
QSize viewportSizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
};
|
||||
|
||||
#endif // EXPANDINGLIST_H
|
Loading…
Add table
Add a link
Reference in a new issue