--- Title: pythonでfoobarのalternativeを作る 26 Author: yamasyuh68 Web: https://mimemo.io/m/mqLXOlJKy64zQ19 --- 190610 # Player 作り込み - label の文字列をセンターに 色々調べたけど単純にdesignerで設定した( ´∀`) 画像が無いときにテキストを表示するだけ ファイルに画像が埋め込まれていないときはフォルダを調べるようにしたいんだけどそれはまだ - 行の削除 この機能は必須ですよね、モデルの操作になる 一つずつとまとめての二種類ある アルバム行を削除する場合はその個°小野タイトル行も削除するようにした foobarと同じ挙動です ``` QStandardItemModel.removeRows (self, int row, int count, QModelIndex parent = QModelIndex()) QAbstractItemModel.removeRows (self, int row, int count, QModelIndex parent = QModelIndex()) ``` - 削除キーを使うのでtreeviewのサブクラスに実装した ``` keyPressEvent (self, QKeyEvent event) int QKeyEvent.key (self) == Qt.Key_Delete ``` - Toolbarにスライダーをつける ``` QAction QToolBar.addSeparator (self) QAction QToolBar.addWidget (self, QWidget widget) ``` 表示するのは簡単だった 使い方はまだわかんない( ´∀`) 普通のスライダーだと、演奏時間に応じてずりずりするのと、マウスのグリグリで進めたり戻ったりさせることになるね ## リストへのドラッグ関係 - リストの末尾へのドラッグは出来た(・∀・)ノ insertでいけた 基本はドロップ先のインデクスの+1になる - 精密にやるのならこれと組み合わせるのかな QAbstractItemView.DropIndicatorPosition ドロップ先のインデクスとIndicatorの値の組み合わせで挙動を変える必要ありだと思う >This enum indicates the position of the drop indicator in relation to the index at the current mouse position: QAbstractItemView.OnItem 0 The item will be dropped on the index. QAbstractItemView.AboveItem 1 The item will be dropped above the index. QAbstractItemView.BelowItem 2 The item will be dropped below the index. QAbstractItemView.OnViewport 3 The item will be dropped onto a region of the viewport with no items. The way each view handles items dropped onto the viewport depends on the behavior of the underlying model in use. - DropIndicatorを消す ドロップ後も消えないバグがあった デフォルト動作のままなら消えるので、自分で実装したので何かが不足してるんだと思う QAbstractItemView.setDropIndicatorShown (self, bool enable) これを使ってドロップの後で消して、dragMoveEvent で見えるようにしたらまあまあうまく動いてます